Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 2 additions & 0 deletions example-input-2.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "_id": "64db9dba7f18450dc250234", "firstName": "Mickey", "lastName": "Mouse", "email":"jason+test8@foo-corp.com", "emailVerified": true, "passwordHash":"$2b$10$.qHPp/srqo1NAAAAAvlkmOdqAbH2Rg0qPv2Txj3ZwXfjJnewSjc4m" }
{ "_id": "64db9dba7f18450dc250567", "firstName": "Donald", "lastName": "Duck", "email":"jason+test9@foo-corp.com", "emailVerified": false, "passwordHash":"$2b$10$.qHPp/srqo1NAAAAAvlkmOdqAbH2Rg0qPv2Txj3ZwXfjJnewSjc4m" }
19 changes: 15 additions & 4 deletions src/password-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import SQLite from "better-sqlite3";
import { Database, Password } from "./database";

const ExportedPassword = z.object({
_id: z.object({
$oid: z.string(),
}),
_id: z.union([
z.string(),
z.object({
$oid: z.string(),
}),
]),
passwordHash: z.string(),
});

Expand All @@ -30,10 +33,18 @@ export class PasswordStore {
for await (const line of ndjsonStream(passwordExportFilePath)) {
const exportedPassword = ExportedPassword.parse(line);

let auth0Id = typeof exportedPassword._id === 'string'
? exportedPassword._id
: exportedPassword._id.$oid;

if (!auth0Id.startsWith('auth0|')) {
auth0Id = `auth0|${auth0Id}`;
}

await this.db
.insertInto("passwords")
.values({
auth0_id: exportedPassword._id.$oid,
auth0_id: auth0Id,
password_hash: exportedPassword.passwordHash,
})
.onConflict((oc) => oc.doNothing())
Expand Down