pgkiln 0.64.0 → 0.65.0
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.
- package/db/migrations/133_app_user_passkeys_stepup.sql +54 -0
- package/docs/apex-feature-parity.md +5 -3
- package/docs/guide/08-security.md +41 -6
- package/docs/guide/12-development.md +10 -4
- package/docs/guide/13-rest-api.md +4 -0
- package/package.json +1 -1
- package/public/app.js +63 -0
- package/public/builder.js +1 -62
- package/src/account-mfa.ts +94 -3
- package/src/api.ts +9 -2
- package/src/builder/api.ts +3 -1
- package/src/builder/components.ts +1 -0
- package/src/builder/login-page.ts +10 -5
- package/src/builder/rest-modules.ts +1 -1
- package/src/builder/security.ts +3 -19
- package/src/builder/shared.ts +5 -3
- package/src/i18n/ar.ts +31 -0
- package/src/i18n/cs.ts +31 -0
- package/src/i18n/da.ts +31 -0
- package/src/i18n/de.ts +31 -0
- package/src/i18n/el.ts +31 -0
- package/src/i18n/es.ts +31 -0
- package/src/i18n/fi.ts +31 -0
- package/src/i18n/fr.ts +31 -0
- package/src/i18n/he.ts +31 -0
- package/src/i18n/it.ts +31 -0
- package/src/i18n/ja.ts +31 -0
- package/src/i18n/ko.ts +31 -0
- package/src/i18n/nb.ts +31 -0
- package/src/i18n/pl.ts +31 -0
- package/src/i18n/pt.ts +31 -0
- package/src/i18n/ru.ts +31 -0
- package/src/i18n/sv.ts +31 -0
- package/src/i18n/tr.ts +31 -0
- package/src/i18n/uk.ts +31 -0
- package/src/i18n/zh.ts +31 -0
- package/src/i18n.ts +62 -0
- package/src/metadata.ts +8 -2
- package/src/mfa.ts +18 -13
- package/src/runtime/account.ts +6 -3
- package/src/runtime/authz.ts +23 -4
- package/src/runtime/routes.ts +11 -1
- package/src/runtime/two-step.ts +379 -72
- package/src/webauthn.ts +20 -0
package/src/webauthn.ts
CHANGED
|
@@ -16,6 +16,26 @@ export const b64url = (b: Buffer | Uint8Array) => Buffer.from(b).toString('base6
|
|
|
16
16
|
export const unb64url = (s: string) => Buffer.from(String(s ?? ''), 'base64url');
|
|
17
17
|
export const newChallenge = () => b64url(randomBytes(32));
|
|
18
18
|
|
|
19
|
+
const CHALLENGE_SECONDS = 300;
|
|
20
|
+
type WithState = { state: Record<string, unknown> };
|
|
21
|
+
|
|
22
|
+
/** A one-time challenge kept in the session (for this purpose only), or null when there is none or it expired. */
|
|
23
|
+
export function takeChallenge(s: WithState, purpose: 'create' | 'get'): string | null {
|
|
24
|
+
try {
|
|
25
|
+
const p = JSON.parse(String(s.state.__PK ?? ''));
|
|
26
|
+
delete s.state.__PK;
|
|
27
|
+
return p && p.purpose === purpose && Date.now() - Number(p.at) < CHALLENGE_SECONDS * 1000 && typeof p.c === 'string' ? p.c : null;
|
|
28
|
+
} catch {
|
|
29
|
+
delete s.state.__PK;
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function giveChallenge(s: WithState, purpose: 'create' | 'get'): string {
|
|
34
|
+
const c = newChallenge();
|
|
35
|
+
s.state.__PK = JSON.stringify({ c, purpose, at: Date.now() });
|
|
36
|
+
return c;
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
// ------------------------------------------------------------------ CBOR (RFC 8949), only what WebAuthn uses
|
|
20
40
|
|
|
21
41
|
type Cbor = number | bigint | string | Buffer | boolean | null | undefined | Cbor[] | Map<Cbor, Cbor>;
|