cursedauth 0.1.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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/account/AccountMenu.d.ts +153 -0
- package/dist/account/AccountMenu.d.ts.map +1 -0
- package/dist/account/AccountMenu.js +388 -0
- package/dist/account/AccountMenu.js.map +1 -0
- package/dist/account/AccountNotice.d.ts +35 -0
- package/dist/account/AccountNotice.d.ts.map +1 -0
- package/dist/account/AccountNotice.js +133 -0
- package/dist/account/AccountNotice.js.map +1 -0
- package/dist/account/accountNotice.state.d.ts +20 -0
- package/dist/account/accountNotice.state.d.ts.map +1 -0
- package/dist/account/accountNotice.state.js +55 -0
- package/dist/account/accountNotice.state.js.map +1 -0
- package/dist/account/avatar.d.ts +37 -0
- package/dist/account/avatar.d.ts.map +1 -0
- package/dist/account/avatar.js +47 -0
- package/dist/account/avatar.js.map +1 -0
- package/dist/accountSlot.client.d.ts +113 -0
- package/dist/accountSlot.client.d.ts.map +1 -0
- package/dist/accountSlot.client.js +330 -0
- package/dist/accountSlot.client.js.map +1 -0
- package/dist/accountSlots.d.ts +192 -0
- package/dist/accountSlots.d.ts.map +1 -0
- package/dist/accountSlots.js +274 -0
- package/dist/accountSlots.js.map +1 -0
- package/dist/auth.d.ts +167 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +310 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.server.d.ts +35 -0
- package/dist/auth.server.d.ts.map +1 -0
- package/dist/auth.server.js +67 -0
- package/dist/auth.server.js.map +1 -0
- package/dist/clientDescription.d.ts +186 -0
- package/dist/clientDescription.d.ts.map +1 -0
- package/dist/clientDescription.js +278 -0
- package/dist/clientDescription.js.map +1 -0
- package/dist/constantTime.d.ts +35 -0
- package/dist/constantTime.d.ts.map +1 -0
- package/dist/constantTime.js +46 -0
- package/dist/constantTime.js.map +1 -0
- package/dist/contentCensus.d.ts +59 -0
- package/dist/contentCensus.d.ts.map +1 -0
- package/dist/contentCensus.js +55 -0
- package/dist/contentCensus.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/mountGatedApp.d.ts +128 -0
- package/dist/mountGatedApp.d.ts.map +1 -0
- package/dist/mountGatedApp.js +107 -0
- package/dist/mountGatedApp.js.map +1 -0
- package/dist/runtimeMode.d.ts +28 -0
- package/dist/runtimeMode.d.ts.map +1 -0
- package/dist/runtimeMode.js +37 -0
- package/dist/runtimeMode.js.map +1 -0
- package/dist/secureRequest.d.ts +22 -0
- package/dist/secureRequest.d.ts.map +1 -0
- package/dist/secureRequest.js +27 -0
- package/dist/secureRequest.js.map +1 -0
- package/dist/sso.d.ts +373 -0
- package/dist/sso.d.ts.map +1 -0
- package/dist/sso.js +420 -0
- package/dist/sso.js.map +1 -0
- package/dist/ssoAutoSignIn.d.ts +272 -0
- package/dist/ssoAutoSignIn.d.ts.map +1 -0
- package/dist/ssoAutoSignIn.js +431 -0
- package/dist/ssoAutoSignIn.js.map +1 -0
- package/dist/ssoConsumer.server.d.ts +295 -0
- package/dist/ssoConsumer.server.d.ts.map +1 -0
- package/dist/ssoConsumer.server.js +972 -0
- package/dist/ssoConsumer.server.js.map +1 -0
- package/dist/stageIdentity.d.ts +72 -0
- package/dist/stageIdentity.d.ts.map +1 -0
- package/dist/stageIdentity.js +74 -0
- package/dist/stageIdentity.js.map +1 -0
- package/dist/ui/popover.d.ts +190 -0
- package/dist/ui/popover.d.ts.map +1 -0
- package/dist/ui/popover.js +351 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/userSessions.d.ts +205 -0
- package/dist/userSessions.d.ts.map +1 -0
- package/dist/userSessions.js +419 -0
- package/dist/userSessions.js.map +1 -0
- package/package.json +115 -0
- package/src/account/AccountMenu.tsx +729 -0
- package/src/account/AccountNotice.tsx +223 -0
- package/src/account/accountNotice.state.ts +66 -0
- package/src/account/avatar.ts +50 -0
- package/src/accountSlot.client.ts +362 -0
- package/src/accountSlots.ts +305 -0
- package/src/auth.server.ts +89 -0
- package/src/auth.ts +515 -0
- package/src/clientDescription.ts +366 -0
- package/src/constantTime.ts +45 -0
- package/src/contentCensus.ts +106 -0
- package/src/index.ts +58 -0
- package/src/mountGatedApp.ts +240 -0
- package/src/runtimeMode.ts +37 -0
- package/src/secureRequest.ts +25 -0
- package/src/sso.ts +767 -0
- package/src/ssoAutoSignIn.ts +544 -0
- package/src/ssoConsumer.server.ts +1260 -0
- package/src/stageIdentity.ts +76 -0
- package/src/ui/popover.ts +390 -0
- package/src/userSessions.ts +678 -0
package/dist/sso.d.ts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SSO grant — the wire credential between `apps/auth` (the accounts
|
|
3
|
+
* satellite) and every satellite that shares its user set.
|
|
4
|
+
*
|
|
5
|
+
* ── The model (2026-07-28) ──────────────────────────────────────────────────
|
|
6
|
+
* One satellite (`apps/auth`) owns the user registry: passwords, reset emails,
|
|
7
|
+
* the admin page. A satellite that wants a signed-in user redirects the browser
|
|
8
|
+
* to auth's `/sso/authorize`; auth answers with a GRANT — a short-lived,
|
|
9
|
+
* single-audience, Ed25519-signed statement "this user, for that app, right
|
|
10
|
+
* now" — and the satellite trades it for its OWN per-app session cookie and
|
|
11
|
+
* never sees a password. Auth built once; every future private satellite
|
|
12
|
+
* integrates by mounting the consumer (`cursedauth/sso-consumer`).
|
|
13
|
+
*
|
|
14
|
+
* ── Why Ed25519 and not an HMAC shared secret ───────────────────────────────
|
|
15
|
+
* A shared secret would let ANY satellite mint grants for every other one — the
|
|
16
|
+
* blast radius of one compromised app becomes the whole fleet. With a keypair,
|
|
17
|
+
* satellites hold only the PUBLIC key; compromising one leaks nothing that can
|
|
18
|
+
* sign. Ed25519 over RSA/ECDSA: built into node:crypto, no parameters to get
|
|
19
|
+
* wrong, 64-byte signatures.
|
|
20
|
+
*
|
|
21
|
+
* ── Why grants are single-use and 60 seconds ────────────────────────────────
|
|
22
|
+
* The grant rides a redirect URL, and URLs leak — proxy logs, referrer headers,
|
|
23
|
+
* a pasted link. A leaked grant must therefore be worth as little as possible:
|
|
24
|
+
* it expires in seconds, names exactly one consumer app (`aud`), and the
|
|
25
|
+
* consumer refuses to accept the same nonce twice (`createNonceGuard`). This is
|
|
26
|
+
* the OAuth authorization-code posture without the second server-to-server
|
|
27
|
+
* round trip — the signature already proves the issuer, so there is nothing a
|
|
28
|
+
* code exchange would add here but a runtime dependency on auth being up.
|
|
29
|
+
*
|
|
30
|
+
* The payload deliberately carries the user snapshot (email, name, admin) so a
|
|
31
|
+
* consumer can answer "who is this?" without ever calling auth at request time.
|
|
32
|
+
* Auth being down means new LOGINS fail; every existing session keeps working.
|
|
33
|
+
*/
|
|
34
|
+
import { type KeyObject } from "node:crypto";
|
|
35
|
+
/** How long a grant is valid. Long enough for one redirect hop on a slow
|
|
36
|
+
* connection, short enough that a logged URL is stale before anyone reads
|
|
37
|
+
* the log. */
|
|
38
|
+
export declare const GRANT_TTL_MS: number;
|
|
39
|
+
/** The user snapshot a grant carries — everything a consumer app may cache. */
|
|
40
|
+
export interface SsoGrantUser {
|
|
41
|
+
/** The auth registry's user id. Stable across apps — satellites key their
|
|
42
|
+
* own rows on it. */
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
name: string;
|
|
46
|
+
/** The registry-level admin flag (may add/delete users on auth's admin
|
|
47
|
+
* page). Consumer apps MAY surface it (e.g. show an "Accounts" link) but
|
|
48
|
+
* must gate their own privileged surfaces on their own rules. */
|
|
49
|
+
admin: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Is this the person who OWNS the machine (2026-08-02)? Distinct from
|
|
52
|
+
* `admin` on purpose — admin is a flag on a row that an admin can hand to
|
|
53
|
+
* anyone, and the fleet directory uses this one to decide whether somebody
|
|
54
|
+
* is shown localhost links. Nobody else has a machine those URLs resolve
|
|
55
|
+
* on, so a wrong answer here is either a dead link or a map of the owner's
|
|
56
|
+
* private ports.
|
|
57
|
+
*
|
|
58
|
+
* OPTIONAL on the wire, and absent must read as `false`: auth and its
|
|
59
|
+
* consumers deploy independently, so a grant minted by an auth that predates
|
|
60
|
+
* this field has to keep working — and it has to fail CLOSED, which "absent
|
|
61
|
+
* means not the owner" does.
|
|
62
|
+
*/
|
|
63
|
+
owner?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Did auth grant this account access to THIS app explicitly, rather than by
|
|
66
|
+
* the app's default tier (2026-08-02)? It is what lets a household member
|
|
67
|
+
* into an admin-tier app without being made an admin of the user registry.
|
|
68
|
+
*
|
|
69
|
+
* Consumers read it as an ALTERNATIVE to `requireAdmin`, never as a
|
|
70
|
+
* replacement for the audience check: a grant still proves only what it was
|
|
71
|
+
* minted for. Optional and absent-means-false, same deploy-skew reason.
|
|
72
|
+
*/
|
|
73
|
+
granted?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface SsoGrantClaims extends SsoGrantUser {
|
|
76
|
+
/** Which consumer app this grant is FOR — its registered app key. A grant
|
|
77
|
+
* for "hobbies" proves nothing to "roms". */
|
|
78
|
+
aud: string;
|
|
79
|
+
/** Issued-at, ms epoch. */
|
|
80
|
+
iat: number;
|
|
81
|
+
/** Expiry, ms epoch (iat + GRANT_TTL_MS). */
|
|
82
|
+
exp: number;
|
|
83
|
+
/** 128-bit random single-use marker — see `createNonceGuard`. */
|
|
84
|
+
nonce: string;
|
|
85
|
+
/** Key id that signed this grant, so rotation can overlap keys. */
|
|
86
|
+
kid: string;
|
|
87
|
+
v: 1;
|
|
88
|
+
}
|
|
89
|
+
export interface SsoKeyPair {
|
|
90
|
+
/** PKCS8 PEM. Lives ONLY in auth's data dir / secrets — never in a consumer. */
|
|
91
|
+
privateKeyPem: string;
|
|
92
|
+
/** SPKI PEM. What consumers verify with; public by definition. */
|
|
93
|
+
publicKeyPem: string;
|
|
94
|
+
/** First 16 hex chars of SHA-256 of the SPKI DER — stable, collision-safe
|
|
95
|
+
* at fleet scale, short enough to read in a log line. */
|
|
96
|
+
kid: string;
|
|
97
|
+
}
|
|
98
|
+
export declare const kidOfPublicKeyPem: (publicKeyPem: string) => string;
|
|
99
|
+
export declare function generateSsoKeyPair(): SsoKeyPair;
|
|
100
|
+
export interface MintGrantOptions {
|
|
101
|
+
privateKeyPem: string;
|
|
102
|
+
kid: string;
|
|
103
|
+
aud: string;
|
|
104
|
+
user: SsoGrantUser;
|
|
105
|
+
now?: () => number;
|
|
106
|
+
/** Test hook only — production grants are always GRANT_TTL_MS. */
|
|
107
|
+
ttlMs?: number;
|
|
108
|
+
}
|
|
109
|
+
/** `base64url(payload JSON).base64url(signature)` — no header, because the
|
|
110
|
+
* algorithm is pinned (Ed25519) and the kid lives in the payload. Not a JWT on
|
|
111
|
+
* purpose: nothing here should ever be handed to a general JWT library with
|
|
112
|
+
* its algorithm-confusion surface. */
|
|
113
|
+
export declare function mintGrant(options: MintGrantOptions): string;
|
|
114
|
+
/** How long a revocation ticket is valid — same posture as a grant. */
|
|
115
|
+
export declare const REVOCATION_TTL_MS: number;
|
|
116
|
+
/**
|
|
117
|
+
* What the consumer should do with the named user.
|
|
118
|
+
*
|
|
119
|
+
* `revoke` — end every session; keep the `sso_users` snapshot row. This is
|
|
120
|
+
* "disabled" and "password reset": the person still exists and their app data
|
|
121
|
+
* must stay keyed to them for when they come back.
|
|
122
|
+
*
|
|
123
|
+
* `delete` — end every session AND drop the snapshot row, so the account stops
|
|
124
|
+
* appearing in the app's own user lists. App data keyed on the id is orphaned
|
|
125
|
+
* rather than cascaded, exactly as auth's own delete already warns.
|
|
126
|
+
*/
|
|
127
|
+
export type RevocationAction = "revoke" | "delete";
|
|
128
|
+
export interface SsoRevocationClaims {
|
|
129
|
+
/** Kind discriminator — checked FIRST by both verifiers. */
|
|
130
|
+
k: "revoke";
|
|
131
|
+
/** Which consumer this ticket is for. A ticket for "roms" does nothing at
|
|
132
|
+
* "hobbies", so one compromised consumer cannot sign the fleet out. */
|
|
133
|
+
aud: string;
|
|
134
|
+
/** The auth registry user id whose sessions end. */
|
|
135
|
+
sub: string;
|
|
136
|
+
action: RevocationAction;
|
|
137
|
+
/**
|
|
138
|
+
* ONE session of `sub`, by its public handle (2026-08-12) — "sign this
|
|
139
|
+
* laptop out" rather than "sign this person out".
|
|
140
|
+
*
|
|
141
|
+
* Absent is the original meaning and stays the default: every session of
|
|
142
|
+
* `sub` ends. Present narrows the SAME ticket rather than introducing a
|
|
143
|
+
* second revocation path, which is the whole point — the fleet has exactly
|
|
144
|
+
* one way for auth to end a session, and the session list drives it.
|
|
145
|
+
*
|
|
146
|
+
* Only legal with `action: "revoke"`. A `delete` drops the account's
|
|
147
|
+
* snapshot row, which is not a thing one session can be half of, and the
|
|
148
|
+
* verifier refuses the combination rather than quietly ignoring the field.
|
|
149
|
+
*/
|
|
150
|
+
sid?: string;
|
|
151
|
+
iat: number;
|
|
152
|
+
exp: number;
|
|
153
|
+
nonce: string;
|
|
154
|
+
kid: string;
|
|
155
|
+
v: 1;
|
|
156
|
+
}
|
|
157
|
+
export interface MintRevocationOptions {
|
|
158
|
+
privateKeyPem: string;
|
|
159
|
+
kid: string;
|
|
160
|
+
aud: string;
|
|
161
|
+
sub: string;
|
|
162
|
+
action: RevocationAction;
|
|
163
|
+
/** End only this one session of `sub` — see {@link SsoRevocationClaims.sid}. */
|
|
164
|
+
sid?: string;
|
|
165
|
+
now?: () => number;
|
|
166
|
+
/** Test hook only. */
|
|
167
|
+
ttlMs?: number;
|
|
168
|
+
}
|
|
169
|
+
export declare function mintRevocation(options: MintRevocationOptions): string;
|
|
170
|
+
export type VerifyRevocationResult = {
|
|
171
|
+
ok: true;
|
|
172
|
+
claims: SsoRevocationClaims;
|
|
173
|
+
} | {
|
|
174
|
+
ok: false;
|
|
175
|
+
reason: string;
|
|
176
|
+
};
|
|
177
|
+
export interface VerifyRevocationOptions {
|
|
178
|
+
keyOf: (kid: string) => KeyObject | null;
|
|
179
|
+
/** The consumer's OWN app key. */
|
|
180
|
+
aud: string;
|
|
181
|
+
now?: () => number;
|
|
182
|
+
}
|
|
183
|
+
export declare function verifyRevocation(ticket: string, options: VerifyRevocationOptions): VerifyRevocationResult;
|
|
184
|
+
/** How long a census ticket is valid — same posture as a grant. */
|
|
185
|
+
export declare const CENSUS_TTL_MS: number;
|
|
186
|
+
/** How many accounts one ticket may ask about. The admin dialog asks about the
|
|
187
|
+
* people a single change moves, which is a household; a bound is here so a
|
|
188
|
+
* malformed caller cannot turn one request into a table scan per user. */
|
|
189
|
+
export declare const CENSUS_MAX_SUBJECTS = 200;
|
|
190
|
+
/** One kind of thing an account made, as the app itself names it. */
|
|
191
|
+
export interface ContentCensusItem {
|
|
192
|
+
/** Stable machine id for the kind — `save-states`, `shelves`. Never shown. */
|
|
193
|
+
kind: string;
|
|
194
|
+
/** How the owner should read it, plural: "save states", "tracked items". */
|
|
195
|
+
label: string;
|
|
196
|
+
count: number;
|
|
197
|
+
}
|
|
198
|
+
/** What one account has in one app. */
|
|
199
|
+
export interface ContentCensusUser {
|
|
200
|
+
userId: string;
|
|
201
|
+
items: ContentCensusItem[];
|
|
202
|
+
/** Sum of `items` — the number the dialog leads with. */
|
|
203
|
+
total: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* An app's answer about who made what.
|
|
207
|
+
*
|
|
208
|
+
* `per-user` — this app attributes rows to accounts and here are the counts.
|
|
209
|
+
* `shared` — this app HAS data, but none of it is keyed to an individual
|
|
210
|
+
* account (the notes corpus, the family tree). Losing access loses
|
|
211
|
+
* nothing personal, and saying so is as useful as a count.
|
|
212
|
+
*
|
|
213
|
+
* A consumer that implements no census at all is a THIRD answer (`unknown`),
|
|
214
|
+
* produced by auth rather than by the app — see `ssoConsumer.server.ts`. The
|
|
215
|
+
* three must stay distinct: "nothing of theirs is here" and "I could not find
|
|
216
|
+
* out" lead an owner to opposite decisions.
|
|
217
|
+
*/
|
|
218
|
+
export type ContentCensus = {
|
|
219
|
+
scope: "per-user";
|
|
220
|
+
users: ContentCensusUser[];
|
|
221
|
+
note?: string;
|
|
222
|
+
} | {
|
|
223
|
+
scope: "shared";
|
|
224
|
+
note: string;
|
|
225
|
+
};
|
|
226
|
+
export interface SsoCensusClaims {
|
|
227
|
+
/** Kind discriminator — checked FIRST by the verifier. */
|
|
228
|
+
k: "census";
|
|
229
|
+
/** Which consumer this ticket is for. */
|
|
230
|
+
aud: string;
|
|
231
|
+
/** The registry user ids being asked about. */
|
|
232
|
+
subs: string[];
|
|
233
|
+
iat: number;
|
|
234
|
+
exp: number;
|
|
235
|
+
nonce: string;
|
|
236
|
+
kid: string;
|
|
237
|
+
v: 1;
|
|
238
|
+
}
|
|
239
|
+
export interface MintCensusOptions {
|
|
240
|
+
privateKeyPem: string;
|
|
241
|
+
kid: string;
|
|
242
|
+
aud: string;
|
|
243
|
+
subs: string[];
|
|
244
|
+
now?: () => number;
|
|
245
|
+
/** Test hook only. */
|
|
246
|
+
ttlMs?: number;
|
|
247
|
+
}
|
|
248
|
+
export declare function mintCensus(options: MintCensusOptions): string;
|
|
249
|
+
export type VerifyCensusResult = {
|
|
250
|
+
ok: true;
|
|
251
|
+
claims: SsoCensusClaims;
|
|
252
|
+
} | {
|
|
253
|
+
ok: false;
|
|
254
|
+
reason: string;
|
|
255
|
+
};
|
|
256
|
+
export interface VerifyCensusOptions {
|
|
257
|
+
keyOf: (kid: string) => KeyObject | null;
|
|
258
|
+
/** The consumer's OWN app key. */
|
|
259
|
+
aud: string;
|
|
260
|
+
now?: () => number;
|
|
261
|
+
}
|
|
262
|
+
export declare function verifyCensus(ticket: string, options: VerifyCensusOptions): VerifyCensusResult;
|
|
263
|
+
/** How long a session-list ticket is valid — same posture as a grant. */
|
|
264
|
+
export declare const SESSIONS_TTL_MS: number;
|
|
265
|
+
/**
|
|
266
|
+
* How many sessions one app may report for one account.
|
|
267
|
+
*
|
|
268
|
+
* A person has a handful of devices; a bound is here so a compromised or
|
|
269
|
+
* confused consumer cannot turn one question into an unbounded response auth
|
|
270
|
+
* has to hold in memory and render.
|
|
271
|
+
*/
|
|
272
|
+
export declare const SESSIONS_MAX_PER_APP = 200;
|
|
273
|
+
/**
|
|
274
|
+
* One live session as a consumer reports it.
|
|
275
|
+
*
|
|
276
|
+
* Structurally a `SessionRecord` (`userSessions.ts`) minus the row id and minus
|
|
277
|
+
* `current` — "the session you are holding" is a fact about a browser, and this
|
|
278
|
+
* is a server-to-server answer where nobody is holding anything.
|
|
279
|
+
*/
|
|
280
|
+
export interface SsoSessionSummary {
|
|
281
|
+
/** The session's public handle — what a revoke-one ticket names. */
|
|
282
|
+
handle: string;
|
|
283
|
+
/** Whose it is. Auth drops anything that is not the account it asked about. */
|
|
284
|
+
userId: string;
|
|
285
|
+
createdAt: number;
|
|
286
|
+
lastSeenAt: number;
|
|
287
|
+
expiresAt: number;
|
|
288
|
+
/** The user-agent verbatim; auth renders it. `""` when the app has none. */
|
|
289
|
+
userAgent: string;
|
|
290
|
+
ip: string;
|
|
291
|
+
/**
|
|
292
|
+
* Where the address was when the session was created — "Austin, Texas, US",
|
|
293
|
+
* or `""` when the app could not place it.
|
|
294
|
+
*
|
|
295
|
+
* OPTIONAL on the wire, and read defensively by auth: a satellite that has
|
|
296
|
+
* not been redeployed since 2026-08-25 answers without it, and a fleet-wide
|
|
297
|
+
* list that went blank for every app awaiting a deploy would be a worse
|
|
298
|
+
* regression than the missing city it is reporting.
|
|
299
|
+
*/
|
|
300
|
+
place?: string;
|
|
301
|
+
}
|
|
302
|
+
export interface SsoSessionsClaims {
|
|
303
|
+
/** Kind discriminator — checked FIRST by the verifier. */
|
|
304
|
+
k: "sessions";
|
|
305
|
+
/** Which consumer this ticket is for. */
|
|
306
|
+
aud: string;
|
|
307
|
+
/** The one registry user id whose sessions are being asked about. Singular,
|
|
308
|
+
* unlike the census: this question is always asked about one account, on
|
|
309
|
+
* one screen, and a list endpoint that can be asked about everybody at once
|
|
310
|
+
* is a different (and much larger) disclosure. */
|
|
311
|
+
sub: string;
|
|
312
|
+
iat: number;
|
|
313
|
+
exp: number;
|
|
314
|
+
nonce: string;
|
|
315
|
+
kid: string;
|
|
316
|
+
v: 1;
|
|
317
|
+
}
|
|
318
|
+
export interface MintSessionsOptions {
|
|
319
|
+
privateKeyPem: string;
|
|
320
|
+
kid: string;
|
|
321
|
+
aud: string;
|
|
322
|
+
sub: string;
|
|
323
|
+
now?: () => number;
|
|
324
|
+
/** Test hook only. */
|
|
325
|
+
ttlMs?: number;
|
|
326
|
+
}
|
|
327
|
+
export declare function mintSessionsRequest(options: MintSessionsOptions): string;
|
|
328
|
+
export type VerifySessionsResult = {
|
|
329
|
+
ok: true;
|
|
330
|
+
claims: SsoSessionsClaims;
|
|
331
|
+
} | {
|
|
332
|
+
ok: false;
|
|
333
|
+
reason: string;
|
|
334
|
+
};
|
|
335
|
+
export interface VerifySessionsOptions {
|
|
336
|
+
keyOf: (kid: string) => KeyObject | null;
|
|
337
|
+
/** The consumer's OWN app key. */
|
|
338
|
+
aud: string;
|
|
339
|
+
now?: () => number;
|
|
340
|
+
}
|
|
341
|
+
export declare function verifySessionsRequest(ticket: string, options: VerifySessionsOptions): VerifySessionsResult;
|
|
342
|
+
export type VerifyGrantResult = {
|
|
343
|
+
ok: true;
|
|
344
|
+
claims: SsoGrantClaims;
|
|
345
|
+
} | {
|
|
346
|
+
ok: false;
|
|
347
|
+
reason: string;
|
|
348
|
+
};
|
|
349
|
+
export interface VerifyGrantOptions {
|
|
350
|
+
/** Resolve a kid to a verification key, or null for an unknown kid. A
|
|
351
|
+
* consumer backed by a JWKS cache uses the miss to trigger a refresh. */
|
|
352
|
+
keyOf: (kid: string) => KeyObject | null;
|
|
353
|
+
/** The consumer's OWN app key — a grant for anyone else is refused. */
|
|
354
|
+
aud: string;
|
|
355
|
+
now?: () => number;
|
|
356
|
+
}
|
|
357
|
+
export declare function verifyGrant(grant: string, options: VerifyGrantOptions): VerifyGrantResult;
|
|
358
|
+
/**
|
|
359
|
+
* Single-use enforcement for grant nonces, in memory.
|
|
360
|
+
*
|
|
361
|
+
* In memory is CORRECT here, not a shortcut: a nonce only needs to be
|
|
362
|
+
* remembered for the grant's own 60-second lifetime (after `exp` the expiry
|
|
363
|
+
* check refuses it regardless), every satellite is a single Bun process, and a
|
|
364
|
+
* process restart forgetting the set merely re-opens a ≤60s replay window for
|
|
365
|
+
* a URL that already succeeded once — against a session the same browser
|
|
366
|
+
* already holds.
|
|
367
|
+
*/
|
|
368
|
+
export interface NonceGuard {
|
|
369
|
+
/** True the FIRST time a nonce is seen; false on any replay. */
|
|
370
|
+
consume(nonce: string, expiresAt: number): boolean;
|
|
371
|
+
}
|
|
372
|
+
export declare function createNonceGuard(now?: () => number): NonceGuard;
|
|
373
|
+
//# sourceMappingURL=sso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../src/sso.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAGN,KAAK,SAAS,EAKd,MAAM,aAAa,CAAC;AAErB;;eAEe;AACf,eAAO,MAAM,YAAY,QAAY,CAAC;AAEtC,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC5B;0BACsB;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb;;sEAEkE;IAClE,KAAK,EAAE,OAAO,CAAC;IACf;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IACnD;kDAC8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE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