pgkiln 0.63.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/SECURITY.md +2 -0
- package/db/migrations/132_app_user_mfa.sql +58 -0
- package/db/migrations/133_app_user_passkeys_stepup.sql +54 -0
- package/docs/apex-feature-parity.md +6 -1
- package/docs/guide/08-security.md +81 -5
- package/docs/guide/09-reference.md +5 -1
- package/docs/guide/11-from-apex.md +2 -1
- package/docs/guide/12-development.md +13 -1
- package/docs/guide/13-rest-api.md +4 -0
- package/package.json +1 -1
- package/public/app.css +10 -0
- package/public/app.js +63 -0
- package/public/builder.js +1 -62
- package/src/account-mfa.ts +184 -0
- package/src/api.ts +9 -2
- package/src/builder/advisor.ts +8 -0
- package/src/builder/api.ts +3 -1
- package/src/builder/components.ts +1 -0
- package/src/builder/i18n/de.ts +6 -0
- package/src/builder/i18n/en.ts +6 -0
- package/src/builder/i18n/es.ts +6 -0
- package/src/builder/i18n/fr.ts +6 -0
- package/src/builder/i18n/nl.ts +6 -0
- package/src/builder/i18n/pt.ts +6 -0
- package/src/builder/login-page.ts +32 -3
- package/src/builder/rest-modules.ts +1 -1
- package/src/builder/security.ts +3 -19
- package/src/builder/shared.ts +5 -3
- package/src/builder/users.ts +34 -3
- package/src/i18n/ar.ts +65 -0
- package/src/i18n/cs.ts +65 -0
- package/src/i18n/da.ts +65 -0
- package/src/i18n/de.ts +65 -0
- package/src/i18n/el.ts +65 -0
- package/src/i18n/es.ts +65 -0
- package/src/i18n/fi.ts +65 -0
- package/src/i18n/fr.ts +65 -0
- package/src/i18n/he.ts +65 -0
- package/src/i18n/it.ts +65 -0
- package/src/i18n/ja.ts +65 -0
- package/src/i18n/ko.ts +65 -0
- package/src/i18n/nb.ts +65 -0
- package/src/i18n/pl.ts +65 -0
- package/src/i18n/pt.ts +65 -0
- package/src/i18n/ru.ts +65 -0
- package/src/i18n/sv.ts +65 -0
- package/src/i18n/tr.ts +65 -0
- package/src/i18n/uk.ts +65 -0
- package/src/i18n/zh.ts +65 -0
- package/src/i18n.ts +130 -0
- package/src/metadata.ts +11 -2
- package/src/mfa.ts +94 -65
- package/src/remember.ts +1 -1
- package/src/runtime/account.ts +7 -1
- package/src/runtime/authz.ts +23 -4
- package/src/runtime/routes.ts +21 -7
- package/src/runtime/two-step.ts +702 -0
- package/src/sharedlogin.ts +1 -1
- package/src/webauthn.ts +20 -0
package/src/sharedlogin.ts
CHANGED
|
@@ -73,7 +73,7 @@ export async function useShared(req: FastifyRequest, reply: FastifyReply, a: Sha
|
|
|
73
73
|
await owner.query('delete from meta.shared_login where token_hash = $1', [hash]);
|
|
74
74
|
return clear(), null;
|
|
75
75
|
}
|
|
76
|
-
if (row.method === 'password' && (await passwordDaysLeft(row.username)) === 0) return null;
|
|
76
|
+
if (row.method.split('+')[0] === 'password' && (await passwordDaysLeft(row.username)) === 0) return null;
|
|
77
77
|
const access = await ssoAccess(a.id, row.username, row.groups);
|
|
78
78
|
if (!access.allowed) return null; // no access to this app: its own sign-in page (the shared sign-in stays for the others)
|
|
79
79
|
return { username: row.username, roles: access.roles, groups: row.groups, method: row.method, hash };
|
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>;
|