@schemavaults/auth-common 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,7 @@ export declare const availableMfaFactorSchema: z.ZodObject<{
|
|
|
13
13
|
last_used_at: number | null;
|
|
14
14
|
}>;
|
|
15
15
|
export type AvailableMfaFactor = z.infer<typeof availableMfaFactorSchema>;
|
|
16
|
+
export declare function collapseWebauthnFactors(factors: AvailableMfaFactor[]): AvailableMfaFactor[];
|
|
16
17
|
export declare const authenticatedAuthenticateResultSchema: z.ZodObject<{
|
|
17
18
|
kind: z.ZodLiteral<"authenticated">;
|
|
18
19
|
success: z.ZodBoolean;
|
|
@@ -7,6 +7,35 @@ export const availableMfaFactorSchema = z
|
|
|
7
7
|
last_used_at: z.number().int().positive().nullable(),
|
|
8
8
|
})
|
|
9
9
|
.strict();
|
|
10
|
+
// Collapse a user's verified factors for the login factor picker: every
|
|
11
|
+
// passkey folds into a single representative `webauthn` entry while all other
|
|
12
|
+
// factor types pass through unchanged.
|
|
13
|
+
//
|
|
14
|
+
// Why: at login the WebAuthn assertion lists *all* of a user's enrolled
|
|
15
|
+
// passkeys in `allowCredentials`, and the platform/browser sheet is what lets
|
|
16
|
+
// them pick between those passkeys — so rendering one picker row per passkey
|
|
17
|
+
// is redundant and undifferentiated (the same "Passkey / Security key" label
|
|
18
|
+
// repeated). For a webauthn proof the selected factor_id is advisory:
|
|
19
|
+
// evaluateMfaProof resolves the credential the authenticator actually signed
|
|
20
|
+
// with, so any enrolled passkey still verifies against the single row.
|
|
21
|
+
//
|
|
22
|
+
// Order is preserved and the *first* passkey encountered is kept as the
|
|
23
|
+
// representative. Callers pass a list already sorted last_used_at DESC NULLS
|
|
24
|
+
// LAST, so the survivor is the most-recently-used passkey — keeping the
|
|
25
|
+
// picker's "default to most-recently-used factor" behaviour intact.
|
|
26
|
+
export function collapseWebauthnFactors(factors) {
|
|
27
|
+
const collapsed = [];
|
|
28
|
+
let keptWebauthn = false;
|
|
29
|
+
for (const factor of factors) {
|
|
30
|
+
if (factor.factor_type === "webauthn") {
|
|
31
|
+
if (keptWebauthn)
|
|
32
|
+
continue;
|
|
33
|
+
keptWebauthn = true;
|
|
34
|
+
}
|
|
35
|
+
collapsed.push(factor);
|
|
36
|
+
}
|
|
37
|
+
return collapsed;
|
|
38
|
+
}
|
|
10
39
|
export const authenticatedAuthenticateResultSchema = z
|
|
11
40
|
.object({
|
|
12
41
|
kind: z.literal("authenticated"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate_result.js","sourceRoot":"","sources":["../src/authenticate_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC5B,WAAW,EAAE,mBAAmB;IAChC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACrD,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC;KACnD,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,kBAAkB,EAAE,CAAC;SAClB,MAAM,EAAE;SACR,GAAG,CAAC,EAAE,EAAE,wDAAwD,CAAC;CACrE,CAAC;KACD,MAAM,EAAE,CAAC;AAMZ,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC;KACjD,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,O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
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * from "./middleware";
|
|
|
10
10
|
export type * from "./middleware";
|
|
11
11
|
export * from "./pkce";
|
|
12
12
|
export type * from "./pkce";
|
|
13
|
-
export { authenticateResultSchema, authenticatedAuthenticateResultSchema, mfaRequiredAuthenticateResultSchema, authenticateFailureResultSchema, challengeExpiredAuthenticateResultSchema, availableMfaFactorSchema, type AuthenticateResult, type AuthenticatedAuthenticateResult, type MfaRequiredAuthenticateResult, type AuthenticateFailureResult, type ChallengeExpiredAuthenticateResult, type AvailableMfaFactor, } from "./authenticate_result";
|
|
13
|
+
export { authenticateResultSchema, authenticatedAuthenticateResultSchema, mfaRequiredAuthenticateResultSchema, authenticateFailureResultSchema, challengeExpiredAuthenticateResultSchema, availableMfaFactorSchema, collapseWebauthnFactors, type AuthenticateResult, type AuthenticatedAuthenticateResult, type MfaRequiredAuthenticateResult, type AuthenticateFailureResult, type ChallengeExpiredAuthenticateResult, type AvailableMfaFactor, } from "./authenticate_result";
|
|
14
14
|
export * from "./mfa";
|
|
15
15
|
export { requestTokensResultSchema, type RequestTokensResult, successfullyGeneratedTokensRecordSchema, type SuccessfullyGeneratedTokensRecord, } from "./request_tokens_result";
|
|
16
16
|
export * from "./auth_acquire_tokens_grant_types";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./credentials";
|
|
|
5
5
|
export * from "./token-data";
|
|
6
6
|
export * from "./middleware";
|
|
7
7
|
export * from "./pkce";
|
|
8
|
-
export { authenticateResultSchema, authenticatedAuthenticateResultSchema, mfaRequiredAuthenticateResultSchema, authenticateFailureResultSchema, challengeExpiredAuthenticateResultSchema, availableMfaFactorSchema, } from "./authenticate_result";
|
|
8
|
+
export { authenticateResultSchema, authenticatedAuthenticateResultSchema, mfaRequiredAuthenticateResultSchema, authenticateFailureResultSchema, challengeExpiredAuthenticateResultSchema, availableMfaFactorSchema, collapseWebauthnFactors, } from "./authenticate_result";
|
|
9
9
|
export * from "./mfa";
|
|
10
10
|
export { requestTokensResultSchema, successfullyGeneratedTokensRecordSchema, } from "./request_tokens_result";
|
|
11
11
|
export * from "./auth_acquire_tokens_grant_types";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAE5D,cAAc,eAAe,CAAC;AAG9B,mBAAmB;AACnB,cAAc,cAAc,CAAC;AAM7B,cAAc,cAAc,CAAC;AAG7B,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACL,wBAAwB,EACxB,qCAAqC,EACrC,mCAAmC,EACnC,+BAA+B,EAC/B,wCAAwC,EACxC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAE5D,cAAc,eAAe,CAAC;AAG9B,mBAAmB;AACnB,cAAc,cAAc,CAAC;AAM7B,cAAc,cAAc,CAAC;AAG7B,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACL,wBAAwB,EACxB,qCAAqC,EACrC,mCAAmC,EACnC,+BAA+B,EAC/B,wCAAwC,EACxC,wBAAwB,EACxB,uBAAuB,GAOxB,MAAM,uBAAuB,CAAC;AAE/B,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,yBAAyB,EAEzB,uCAAuC,GAExC,MAAM,yBAAyB,CAAC;AAEjC,cAAc,mCAAmC,CAAC;AAGlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAA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