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
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const userSchema = z.object({
private_metadata: z.record(z.string(), z.unknown()).optional(),
/** Metadata saved on the user, that can be updated from both the Frontend and Backend APIs. Note: Since this data can be modified from the frontend, it is not guaranteed to be safe. */
unsafe_metadata: z.record(z.string(), z.unknown()).optional(),
createdAt: z.string().optional(),
});

type User = z.infer<typeof userSchema>;
Expand All @@ -78,6 +79,7 @@ const createUser = (userData: User) =>
privateMetadata: userData.private_metadata,
publicMetadata: userData.public_metadata,
unsafeMetadata: userData.unsafe_metadata,
createdAt: userData.createdAt,
})
: clerkClient.users.createUser({
externalId: userData.userId,
Expand All @@ -88,6 +90,7 @@ const createUser = (userData: User) =>
privateMetadata: userData.private_metadata,
publicMetadata: userData.public_metadata,
unsafeMetadata: userData.unsafe_metadata,
createdAt: userData.createdAt,
});

const now = new Date().toISOString().split(".")[0]; // YYYY-MM-DDTHH:mm:ss
Expand Down
9 changes: 9 additions & 0 deletions samples/authjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,5 +798,14 @@
"lastName": "One Hundred",
"password": "$2a$12$9HhLqMJxqBKhlZasxjlhger67GFcC4aOAtpcU.THpcSLiQve4mq6.",
"passwordHasher": "bcrypt"
},
{
"userId": "101",
"email": "[email protected]",
"firstName": "User",
"lastName": "One Hundred and One",
"password": "$2a$12$9HhLqMJxqBKhlZasxjlhger67GFcC4aOAtpcU.THpcSLiQve4mq6.",
"passwordHasher": "bcrypt"
"createdAt": "2025-03-13T18:47:11.37331+00:00",
}
]