mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
renamed passkey to security key to stay aligned with the UI and other backend naming.
This commit is contained in:
@@ -8,7 +8,7 @@ export default async function migration() {
|
||||
|
||||
try {
|
||||
db.transaction((trx) => {
|
||||
trx.run(sql`CREATE TABLE 'passkey' (
|
||||
trx.run(sql`CREATE TABLE 'securityKey' (
|
||||
'credentialId' text PRIMARY KEY NOT NULL,
|
||||
'userId' text NOT NULL,
|
||||
'publicKey' text NOT NULL,
|
||||
|
||||
@@ -14,7 +14,7 @@ export default async function migration() {
|
||||
db.pragma("foreign_keys = OFF");
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS passkey (
|
||||
CREATE TABLE IF NOT EXISTS securityKey (
|
||||
credentialId TEXT PRIMARY KEY,
|
||||
userId TEXT NOT NULL,
|
||||
publicKey TEXT NOT NULL,
|
||||
@@ -28,9 +28,9 @@ export default async function migration() {
|
||||
`);
|
||||
})(); // executes the transaction immediately
|
||||
db.pragma("foreign_keys = ON");
|
||||
console.log(`Created passkey table`);
|
||||
console.log(`Created securityKey table`);
|
||||
} catch (e) {
|
||||
console.error("Unable to create passkey table");
|
||||
console.error("Unable to create securityKey table");
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -14,22 +14,22 @@ export default async function migration() {
|
||||
db.pragma("foreign_keys = OFF");
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS passkeyChallenge (
|
||||
CREATE TABLE IF NOT EXISTS securityKeyChallenge (
|
||||
sessionId TEXT PRIMARY KEY,
|
||||
challenge TEXT NOT NULL,
|
||||
passkeyName TEXT,
|
||||
securityKeyName TEXT,
|
||||
userId TEXT,
|
||||
expiresAt INTEGER NOT NULL,
|
||||
FOREIGN KEY (userId) REFERENCES user(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_passkeyChallenge_expiresAt ON passkeyChallenge(expiresAt);
|
||||
CREATE INDEX IF NOT EXISTS idx_securityKeyChallenge_expiresAt ON securityKeyChallenge(expiresAt);
|
||||
`);
|
||||
})(); // executes the transaction immediately
|
||||
db.pragma("foreign_keys = ON");
|
||||
console.log(`Created passkeyChallenge table`);
|
||||
console.log(`Created securityKeyChallenge table`);
|
||||
} catch (e) {
|
||||
console.error("Unable to create passkeyChallenge table");
|
||||
console.error("Unable to create securityKeyChallenge table");
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ export default async function migrate() {
|
||||
|
||||
// Rename the table
|
||||
await db.run(`
|
||||
ALTER TABLE passkeyChallenge RENAME TO webauthnChallenge;
|
||||
ALTER TABLE securityKeyChallenge RENAME TO webauthnChallenge;
|
||||
`);
|
||||
console.log("Successfully renamed table");
|
||||
|
||||
// Rename the index
|
||||
await db.run(`
|
||||
DROP INDEX IF EXISTS idx_passkeyChallenge_expiresAt;
|
||||
DROP INDEX IF EXISTS idx_securityKeyChallenge_expiresAt;
|
||||
CREATE INDEX IF NOT EXISTS idx_webauthnChallenge_expiresAt ON webauthnChallenge(expiresAt);
|
||||
`);
|
||||
console.log("Successfully updated index");
|
||||
|
||||
console.log(`Renamed passkeyChallenge table to webauthnChallenge`);
|
||||
console.log(`Renamed securityKeyChallenge table to webauthnChallenge`);
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
console.error("Unable to rename passkeyChallenge table:", error);
|
||||
console.error("Unable to rename securityKeyChallenge table:", error);
|
||||
console.error("Error details:", error.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user