@voltro/plugin-auth 0.86.0 → 0.88.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/CHANGELOG.md +5484 -0
- package/README.md +83 -0
- package/THIRD-PARTY-NOTICES.md +3 -227
- package/dist/admission.js +1 -2
- package/dist/appUserStore.js +1 -2
- package/dist/authExtensions.js +8 -0
- package/dist/csrf.js +1 -2
- package/dist/emailVerification.js +14 -13
- package/dist/guest.d.ts +99 -0
- package/dist/guest.js +3 -0
- package/dist/guestClient.js +236 -0
- package/dist/guestCredential.js +11 -0
- package/dist/guestPasswordUpgrade.js +84 -0
- package/dist/guestPlugin.js +165 -0
- package/dist/guestSchema.js +19 -0
- package/dist/guestSecrets.js +9 -0
- package/dist/guestService.js +223 -0
- package/dist/handlers.js +114 -115
- package/dist/impersonation.js +80 -80
- package/dist/index.d.ts +265 -15
- package/dist/index.js +27 -19
- package/dist/invitations.js +24 -25
- package/dist/mail.js +1 -2
- package/dist/memberships.js +1 -2
- package/dist/native/guestStorage.js +40 -0
- package/dist/native.d.ts +110 -0
- package/dist/native.js +46 -45
- package/dist/nativeRoutes.js +62 -74
- package/dist/overlayPlugin.js +166 -0
- package/dist/passkeyHandlers.js +1 -2
- package/dist/password.js +1 -2
- package/dist/plugin.d.ts +119 -10
- package/dist/plugin.js +100 -80
- package/dist/postgresUserStore.js +20 -9
- package/dist/revocation.js +41 -25
- package/dist/schema.d.ts +41 -1
- package/dist/schema.js +100 -100
- package/dist/session.js +1 -2
- package/dist/sessionFamily.js +14 -0
- package/dist/sessionRegistry.js +94 -80
- package/dist/signedClaims.js +23 -0
- package/dist/strategy.d.ts +13 -9
- package/dist/strategy.js +27 -24
- package/dist/subjectGuard.js +1 -2
- package/dist/tokens.js +1 -2
- package/dist/totp.js +1 -2
- package/dist/userStore.js +146 -140
- package/dist/web/guestStorage.js +46 -0
- package/dist/web/passkeyClient.js +1 -2
- package/dist/web/requireAuth.js +1 -2
- package/dist/web/subjectContext.js +1 -2
- package/dist/web.d.ts +94 -0
- package/dist/web.js +4 -2
- package/dist/webauthn.js +1 -2
- package/package.json +9 -4
package/dist/web.d.ts
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Subject } from '@voltro/protocol';
|
|
3
|
+
import { SubjectIdentity } from '@voltro/protocol';
|
|
4
|
+
|
|
5
|
+
/** Serializes operations in one client. A rejected existing credential never
|
|
6
|
+
* creates a replacement identity. Storage failures never enable memory fallback. */
|
|
7
|
+
export declare const createGuestClient: (options: GuestClientOptions) => {
|
|
8
|
+
connect: () => Promise<GuestClientSession>;
|
|
9
|
+
/** Prepare without replacing the active proof, persist both proofs, then
|
|
10
|
+
* commit. A later connect recovers the same identity after a lost response. */
|
|
11
|
+
rotate: () => Promise<GuestClientSession>;
|
|
12
|
+
/** Revoke on the server first. Keep the durable proof on transport failure
|
|
13
|
+
* so the caller can retry; erase locally only after confirmed revocation. */
|
|
14
|
+
revoke: () => Promise<void>;
|
|
15
|
+
/** Turn this guest into an email/password account under the same subject ID
|
|
16
|
+
* (`authRoutesPlugin({ guestUpgrade })`). The device proof is erased only after the
|
|
17
|
+
* server confirmed the account; on any refusal or transport failure it stays. */
|
|
18
|
+
upgrade: (input: {
|
|
19
|
+
readonly email: string;
|
|
20
|
+
readonly password: string;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
readonly subject: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
/** The registered account signed in on this device (cookie clients), or null. */
|
|
25
|
+
account: () => Promise<GuestClientAccount | null>;
|
|
26
|
+
/** The signed-in account if there is one, else this device's guest (resumed or created once).
|
|
27
|
+
* The usual entry for a game that offers accounts: a reload after `upgrade` or `signIn` stays the account. */
|
|
28
|
+
start: () => Promise<GuestClientPlayer>;
|
|
29
|
+
/** Sign in to an existing account with email and password (`authRoutesPlugin`), e.g. on a second
|
|
30
|
+
* device. This device's guest proof stays: after `signOut`, `start` resumes that guest. */
|
|
31
|
+
signIn: (input: {
|
|
32
|
+
readonly email: string;
|
|
33
|
+
readonly password: string;
|
|
34
|
+
}) => Promise<GuestClientAccount>;
|
|
35
|
+
/** End the account session on the server and clear its cookie. */
|
|
36
|
+
signOut: () => Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A registered account signed in on this device (by upgrade or sign-in), through the session cookie. */
|
|
40
|
+
export declare interface GuestClientAccount {
|
|
41
|
+
readonly subject: Extract<SubjectIdentity, {
|
|
42
|
+
readonly type: 'user';
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare class GuestClientError extends Error {
|
|
47
|
+
readonly code: 'storage_unavailable' | 'credential_rejected' | 'upgrade_conflict' | 'account_signed_in' | 'transport_failed' | 'invalid_response';
|
|
48
|
+
readonly status?: number | undefined;
|
|
49
|
+
constructor(code: 'storage_unavailable' | 'credential_rejected' | 'upgrade_conflict' | 'account_signed_in' | 'transport_failed' | 'invalid_response', status?: number | undefined);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare interface GuestClientOptions {
|
|
53
|
+
readonly apiBaseUrl: string;
|
|
54
|
+
readonly storage: GuestCredentialStore;
|
|
55
|
+
readonly prefix?: string;
|
|
56
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
57
|
+
/** Web clients include cookies and obtain a signed CSRF token for each post. */
|
|
58
|
+
readonly cookies?: boolean;
|
|
59
|
+
/** Prefix of the app's auth routes, for `upgrade`, `account`, `signIn` and `signOut` (default `/auth`). */
|
|
60
|
+
readonly accountPrefix?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What `start` found: the signed-in account, else this device's guest. */
|
|
64
|
+
export declare type GuestClientPlayer = {
|
|
65
|
+
readonly kind: 'account';
|
|
66
|
+
readonly subject: GuestClientAccount['subject'];
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'guest';
|
|
69
|
+
readonly subject: GuestClientSession['subject'];
|
|
70
|
+
readonly session: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export declare interface GuestClientSession {
|
|
74
|
+
readonly subject: Extract<SubjectIdentity, {
|
|
75
|
+
readonly type: 'user';
|
|
76
|
+
}> & {
|
|
77
|
+
readonly kind: 'guest';
|
|
78
|
+
};
|
|
79
|
+
readonly session: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Platform-backed durable secret storage. Native implementations use the
|
|
83
|
+
* operating system's secure store; writes resolve only after persistence. */
|
|
84
|
+
export declare interface GuestCredentialStore {
|
|
85
|
+
/** Serialize the whole read/create/write operation across users of this
|
|
86
|
+
* namespace, including other browser tabs or native client instances. */
|
|
87
|
+
readonly exclusive: <A>(work: () => Promise<A>) => Promise<A>;
|
|
88
|
+
readonly read: () => Promise<string | null>;
|
|
89
|
+
/** Persist the opaque value, including an in-progress rotation journal. */
|
|
90
|
+
readonly write: (value: string) => Promise<void>;
|
|
91
|
+
readonly remove: () => Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** IndexedDB is the web device-proof store. Missing/blocked storage rejects;
|
|
95
|
+
* there is deliberately no localStorage or volatile substitute. */
|
|
96
|
+
export declare const indexedDbGuestStore: (namespace: string) => GuestCredentialStore;
|
|
3
97
|
|
|
4
98
|
/** True when this browser can do WebAuthn at all. */
|
|
5
99
|
export declare const isPasskeySupported: () => boolean;
|
package/dist/web.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SubjectProvider as e, useOptionalSubject as t, useSubject as n } from "./web/subjectContext.js";
|
|
2
2
|
import { RequireAuth as r } from "./web/requireAuth.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { GuestClientError as i, createGuestClient as a } from "./guestClient.js";
|
|
4
|
+
import { indexedDbGuestStore as o } from "./web/guestStorage.js";
|
|
5
|
+
import { isPasskeySupported as s, registerPasskey as c, signInWithPasskey as l } from "./web/passkeyClient.js";
|
|
6
|
+
export { i as GuestClientError, r as RequireAuth, e as SubjectProvider, a as createGuestClient, o as indexedDbGuestStore, s as isPasskeySupported, c as registerPasskey, l as signInWithPasskey, t as useOptionalSubject, n as useSubject };
|
package/dist/webauthn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash as e, createPublicKey as t, createVerify as n, randomBytes as r, timingSafeEqual as i, verify as a } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// src/webauthn.ts
|
|
3
3
|
var o = (e) => {
|
|
4
4
|
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
5
5
|
return Buffer.from(t, "base64");
|
|
@@ -314,5 +314,4 @@ var o = (e) => {
|
|
|
314
314
|
let n = Buffer.from(e), r = Buffer.from(t);
|
|
315
315
|
return n.length === r.length && i(n, r);
|
|
316
316
|
}, D = () => s(r(32));
|
|
317
|
-
//#endregion
|
|
318
317
|
export { D as generateChallenge, w as verifyAssertion, C as verifyRegistration };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "Authentication primitives: password hashing, session creation, schema mixin + tables. Pairs with the `auth` app template for the UI; both independently usable. Server-side only (uses node:crypto).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -73,6 +73,11 @@
|
|
|
73
73
|
"import": "./dist/native.js",
|
|
74
74
|
"default": "./dist/native.js"
|
|
75
75
|
},
|
|
76
|
+
"./guest": {
|
|
77
|
+
"types": "./dist/guest.d.ts",
|
|
78
|
+
"import": "./dist/guest.js",
|
|
79
|
+
"default": "./dist/guest.js"
|
|
80
|
+
},
|
|
76
81
|
"./package.json": "./package.json"
|
|
77
82
|
},
|
|
78
83
|
"main": "./dist/index.js",
|
|
@@ -83,11 +88,11 @@
|
|
|
83
88
|
"node": ">=24.0.0"
|
|
84
89
|
},
|
|
85
90
|
"dependencies": {
|
|
86
|
-
"@voltro/database": "0.
|
|
87
|
-
"@voltro/protocol": "0.
|
|
91
|
+
"@voltro/database": "0.88.0",
|
|
92
|
+
"@voltro/protocol": "0.88.0"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
90
|
-
"effect": "4.0
|
|
95
|
+
"effect": "4.1.0",
|
|
91
96
|
"react": "^19.0.0"
|
|
92
97
|
},
|
|
93
98
|
"peerDependenciesMeta": {
|