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
40 changes: 35 additions & 5 deletions server/test/api/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,13 @@ describe("authentication", () => {
expect(customer).toHaveBeenCalledWith(
expect.objectContaining({
flow: { name: "signup", type: "signup" },
customer: { id, tags: [{ name: "source", value: "12345", type: "string" }] },
customer: {
id,
tags: [
{ name: "source", value: "12345", type: "string" },
{ name: "auth_method", value: "siwe", type: "string" },
],
},
}),
);

Expand All @@ -463,7 +469,13 @@ describe("authentication", () => {
expect(customer).toHaveBeenCalledWith(
expect.objectContaining({
flow: { name: "signup", type: "signup" },
customer: { id, tags: [{ name: "source", value: "EXA", type: "string" }] },
customer: {
id,
tags: [
{ name: "source", value: "EXA", type: "string" },
{ name: "auth_method", value: "siwe", type: "string" },
],
},
}),
);

Expand Down Expand Up @@ -704,7 +716,13 @@ describe("registration", () => {
expect(customer).toHaveBeenCalledWith(
expect.objectContaining({
flow: { name: "signup", type: "signup" },
customer: { id, tags: [{ name: "source", value: "EXA", type: "string" }] },
customer: {
id,
tags: [
{ name: "source", value: "EXA", type: "string" },
{ name: "auth_method", value: "siwe", type: "string" },
],
},
}),
);

Expand Down Expand Up @@ -775,7 +793,13 @@ describe("registration", () => {
expect(customer).toHaveBeenCalledWith(
expect.objectContaining({
flow: { name: "signup", type: "signup" },
customer: { id: "dGVzdC1jcmVkLWlk2", tags: [{ name: "source", value: "12345", type: "string" }] },
customer: {
id: "dGVzdC1jcmVkLWlk2",
tags: [
{ name: "source", value: "12345", type: "string" },
{ name: "auth_method", value: "webauthn", type: "string" },
],
},
}),
);

Expand Down Expand Up @@ -850,7 +874,13 @@ describe("registration", () => {
expect(customer).toHaveBeenCalledWith(
expect.objectContaining({
flow: { name: "signup", type: "signup" },
customer: { id: "YW5vdGhlci1jcmVkLWlk2", tags: [{ name: "source", value: "EXA", type: "string" }] },
customer: {
id: "YW5vdGhlci1jcmVkLWlk2",
tags: [
{ name: "source", value: "EXA", type: "string" },
{ name: "auth_method", value: "webauthn", type: "string" },
],
},
}),
);
const credential = await database.query.credentials.findFirst({
Expand Down
5 changes: 4 additions & 1 deletion server/utils/createCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export default async function createCredential<C extends string>(
flow: { name: "signup", type: "signup" },
customer: {
id: credentialId,
tags: [{ name: "source", value: options?.source ?? "EXA", type: "string" }],
tags: [
{ name: "source", value: options?.source ?? "EXA", type: "string" },
{ name: "auth_method", value: isAddress(credentialId) ? "siwe" : "webauthn", type: "string" },
Comment thread
aguxez marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive the tag from the verified auth method

When a WebAuthn authenticator returns an address-shaped credential ID (for example, 0x followed by 40 hex characters), the ID satisfies both the Base64URL validator and isAddress(). The registration path still verifies it as WebAuthn and supplies options.webauthn, but this ternary reports siwe to Sardine, corrupting the authentication-method signal. Derive the value from the verified request method or the presence of options.webauthn instead of the credential ID's syntax.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the new tag in sorted order

The new tag is appended after source, leaving this project-controlled array unsorted even though the repository requires additions to arrays to be inserted in the middle or in sorted position for diff friendliness. Place auth_method before source here and in the corresponding test expectations so future edits preserve the established ordering convention.

AGENTS.md reference: AGENTS.md:L16-L16

Useful? React with 👍 / 👎.

],
},
}).catch((error: unknown) => captureException(error, { level: "error" })),
]);
Expand Down
Loading