@iqauth/sdk 2.6.4 → 2.7.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/README.md +173 -1
- package/dist/browser-session.d.mts +4 -4
- package/dist/browser-session.d.ts +4 -4
- package/dist/browser-session.js +181 -41
- package/dist/browser-session.mjs +3 -3
- package/dist/browser.d.mts +5 -5
- package/dist/browser.d.ts +5 -5
- package/dist/browser.js +271 -32
- package/dist/browser.mjs +5 -5
- package/dist/{chunk-6I6RM4MN.mjs → chunk-6PJRLRB4.mjs} +33 -3
- package/dist/{chunk-LIZYFXH7.mjs → chunk-DFWHSDYQ.mjs} +1 -1
- package/dist/chunk-GLXSIGVS.mjs +66 -0
- package/dist/{chunk-DJIBN2N7.mjs → chunk-GN37E64I.mjs} +29 -7
- package/dist/{chunk-WQWBJSSS.mjs → chunk-HVHNYPDC.mjs} +6 -6
- package/dist/{chunk-W3F4JYGP.mjs → chunk-JXQI62A7.mjs} +108 -18
- package/dist/{chunk-UNYDG2L4.mjs → chunk-NUO2I65G.mjs} +56 -23
- package/dist/chunk-PMAFENVI.mjs +229 -0
- package/dist/chunk-RR2MGPTK.mjs +2724 -0
- package/dist/{chunk-XAWYUPMO.mjs → chunk-RTJAIBXY.mjs} +220 -20
- package/dist/{chunk-6TDJJER7.mjs → chunk-RUJXRTEW.mjs} +164 -5
- package/dist/{chunk-3JULWS6F.mjs → chunk-WCELYTJ3.mjs} +3 -3
- package/dist/{chunk-MKKZULZR.mjs → chunk-WIFG74IK.mjs} +1 -1
- package/dist/{chunk-BVV54LPI.mjs → chunk-YVALAG3B.mjs} +10 -4
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.mjs +2 -2
- package/dist/{client-kYlJFgPv.d.mts → client-BGFnBpfc.d.mts} +47 -4
- package/dist/{client-BNQe3AgF.d.ts → client-CDQ21LvW.d.ts} +47 -4
- package/dist/{doctor-YYNHNMLD.mjs → doctor-JAFXWU3X.mjs} +2 -2
- package/dist/errors-Jl1Jtm-6.d.mts +107 -0
- package/dist/errors-Jl1Jtm-6.d.ts +107 -0
- package/dist/{express-B6_1vBYZ.d.mts → express-CVNQEkOr.d.mts} +2 -2
- package/dist/{express-CHpfa7D_.d.ts → express-Piv2WhWM.d.ts} +2 -2
- package/dist/express.d.mts +7 -6
- package/dist/express.d.ts +7 -6
- package/dist/express.js +349 -52
- package/dist/express.mjs +39 -12
- package/dist/fastify.d.mts +2 -0
- package/dist/fastify.d.ts +2 -0
- package/dist/fastify.js +332 -52
- package/dist/fastify.mjs +23 -8
- package/dist/hono.d.mts +2 -0
- package/dist/hono.d.ts +2 -0
- package/dist/hono.js +329 -52
- package/dist/hono.mjs +20 -8
- package/dist/index-5KSZEnDe.d.ts +1626 -0
- package/dist/index-CKoZHAoc.d.mts +1626 -0
- package/dist/index.d.mts +56 -8
- package/dist/index.d.ts +56 -8
- package/dist/index.js +565 -69
- package/dist/index.mjs +29 -9
- package/dist/{keys-NLWFAOEM.mjs → keys-6Y776TG2.mjs} +2 -2
- package/dist/locales.d.mts +1 -1
- package/dist/locales.d.ts +1 -1
- package/dist/mobile.d.mts +77 -7
- package/dist/mobile.d.ts +77 -7
- package/dist/mobile.js +276 -41
- package/dist/mobile.mjs +98 -3
- package/dist/next.d.mts +2 -1
- package/dist/next.d.ts +2 -1
- package/dist/next.js +391 -201
- package/dist/next.mjs +22 -7
- package/dist/{provisioningBridge-DnTfzdZK.d.ts → provisioningBridge-CGpMRie4.d.ts} +1 -1
- package/dist/{provisioningBridge-88xjOS2n.d.mts → provisioningBridge-M5G47LWO.d.mts} +1 -1
- package/dist/{publishableKey-BaR0HoAH.d.ts → publishableKey-f2kq-rKw.d.mts} +1 -1
- package/dist/{publishableKey-BaR0HoAH.d.mts → publishableKey-f2kq-rKw.d.ts} +1 -1
- package/dist/react-permissions.d.mts +52 -0
- package/dist/react-permissions.d.ts +52 -0
- package/dist/react-permissions.js +239 -0
- package/dist/react-permissions.mjs +97 -0
- package/dist/react.d.mts +9 -1624
- package/dist/react.d.ts +9 -1624
- package/dist/react.js +313 -33
- package/dist/react.mjs +58 -2632
- package/dist/{reverify-4UEJXUS6.mjs → reverify-C64QXKJO.mjs} +2 -2
- package/dist/server/handlers.d.mts +148 -3
- package/dist/server/handlers.d.ts +148 -3
- package/dist/server/handlers.js +410 -11
- package/dist/server/handlers.mjs +12 -3
- package/dist/server.d.mts +151 -8
- package/dist/server.d.ts +151 -8
- package/dist/server.js +406 -50
- package/dist/server.mjs +93 -11
- package/dist/service.d.mts +4 -4
- package/dist/service.d.ts +4 -4
- package/dist/service.js +181 -41
- package/dist/service.mjs +3 -3
- package/dist/{signIn-OCr88Zf8.d.ts → signIn-BLFnz8SV.d.ts} +78 -3
- package/dist/{signIn-4OKLDEIH.mjs → signIn-SHBW6Z4T.mjs} +1 -1
- package/dist/{signIn-CiIBTJIh.d.mts → signIn-T-CZ6t6r.d.mts} +78 -3
- package/dist/test.mjs +3 -3
- package/dist/{tokens-DCyzzn8L.d.mts → tokens-Bqhmqq_R.d.ts} +9 -2
- package/dist/{tokens-aHiGFr_E.d.ts → tokens-CITeoG6P.d.mts} +9 -2
- package/dist/{types-6bNdxesb.d.ts → types-BdQ2lqfT.d.mts} +1 -1
- package/dist/{types-6bNdxesb.d.mts → types-BdQ2lqfT.d.ts} +1 -1
- package/dist/{types-DZAflmmq.d.mts → types-XOV9XPVi.d.mts} +99 -10
- package/dist/{types-DZAflmmq.d.ts → types-XOV9XPVi.d.ts} +99 -10
- package/dist/webhooks.d.mts +100 -17
- package/dist/webhooks.d.ts +100 -17
- package/dist/webhooks.js +164 -15
- package/dist/webhooks.mjs +7 -1
- package/dist/ws.d.mts +2 -2
- package/dist/ws.d.ts +2 -2
- package/dist/ws.js +80 -30
- package/dist/ws.mjs +4 -4
- package/docs/error-handling.md +101 -0
- package/docs/guides/effective-permissions.md +171 -0
- package/package.json +13 -3
- package/dist/chunk-UKZLOHZG.mjs +0 -83
- package/dist/errors-CDdl24MP.d.mts +0 -52
- package/dist/errors-CDdl24MP.d.ts +0 -52
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as ParsedPublishableKey } from './publishableKey-
|
|
2
|
-
import { J as JwtClaims,
|
|
1
|
+
import { c as ParsedPublishableKey } from './publishableKey-f2kq-rKw.js';
|
|
2
|
+
import { J as JwtClaims, S as SessionUser } from './types-XOV9XPVi.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* SessionManager — core browser-side session state.
|
|
@@ -120,11 +120,53 @@ interface SessionManagerOptions {
|
|
|
120
120
|
refresh?: string;
|
|
121
121
|
access?: string;
|
|
122
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Task #126: When `debug` is true, the SessionManager emits
|
|
125
|
+
* `console.debug("[iqauth_session]", evt)` for `bootstrap` and `refresh`
|
|
126
|
+
* phases. When `onTimingEvent` is set, the same event is also forwarded.
|
|
127
|
+
* Use to push browser timings into your APM. Events have shape
|
|
128
|
+
* `{ phase, durationMs, ok, code? }`.
|
|
129
|
+
*/
|
|
130
|
+
debug?: boolean;
|
|
131
|
+
onTimingEvent?: (event: {
|
|
132
|
+
phase: "bootstrap" | "refresh" | "signIn";
|
|
133
|
+
durationMs: number;
|
|
134
|
+
ok: boolean;
|
|
135
|
+
code?: string;
|
|
136
|
+
}) => void;
|
|
123
137
|
}
|
|
124
138
|
declare class SessionManager {
|
|
125
139
|
private snapshot;
|
|
126
140
|
private listeners;
|
|
127
141
|
private refreshPromise;
|
|
142
|
+
/**
|
|
143
|
+
* Cancellation handle for the in-flight refresh, if any. `signOut()` (or a
|
|
144
|
+
* `session:signout` broadcast from another tab) calls `abort()` so the
|
|
145
|
+
* refresh response is dropped before it can write a fresh access cookie
|
|
146
|
+
* on top of the just-cleared session — the second root cause of "ghost
|
|
147
|
+
* signed-in" sessions after Sign Out.
|
|
148
|
+
*/
|
|
149
|
+
private refreshAbort;
|
|
150
|
+
/**
|
|
151
|
+
* Set to `true` by `signOut()` / `signOutLocal()` for the lifetime of the
|
|
152
|
+
* call. Used as a safety belt: even if a refresh response arrives while
|
|
153
|
+
* `refreshAbort` was unable to interrupt the network call (e.g. the body
|
|
154
|
+
* was already streaming back), `runRefresh` checks this flag before
|
|
155
|
+
* mutating session state and bails out.
|
|
156
|
+
*/
|
|
157
|
+
private signoutInProgress;
|
|
158
|
+
/**
|
|
159
|
+
* Per-session opaque idempotency token. Sent as `X-IQAuth-Idempotency` on
|
|
160
|
+
* every /refresh and /signout request the SDK makes through a framework
|
|
161
|
+
* adapter (Express/Fastify/Hono/Next), so the adapter's `SignoutRegistry`
|
|
162
|
+
* can collapse a refresh that lands moments after a signout — even when
|
|
163
|
+
* the two requests are routed to different server instances (multi-replica
|
|
164
|
+
* deployments).
|
|
165
|
+
*
|
|
166
|
+
* Generated lazily on first use, rotated on signout so the next session
|
|
167
|
+
* starts with a fresh token. Opaque random — never the raw refresh token.
|
|
168
|
+
*/
|
|
169
|
+
private idempotencyToken;
|
|
128
170
|
private channel;
|
|
129
171
|
private readonly tabId;
|
|
130
172
|
private readonly fetchImpl;
|
|
@@ -138,26 +180,59 @@ declare class SessionManager {
|
|
|
138
180
|
private readonly crossTabLockTimeoutMs;
|
|
139
181
|
private readonly serverManagedSession;
|
|
140
182
|
private readonly refreshCookieName;
|
|
183
|
+
private readonly debug;
|
|
184
|
+
private readonly onTimingEvent;
|
|
141
185
|
private proactiveTimer;
|
|
142
186
|
private bootstrapped;
|
|
143
187
|
/** Pending refresh awaited by other tabs after a `refresh:claim` from us. */
|
|
144
188
|
private remoteRefreshWaiters;
|
|
145
189
|
/** Active claims by other tabs (keyed by source tabId). */
|
|
146
190
|
private foreignClaim;
|
|
191
|
+
/** Resolver for an in-flight cross-tab `session:probe`, set during bootstrap. */
|
|
192
|
+
private probeResolver;
|
|
147
193
|
constructor(options: SessionManagerOptions);
|
|
148
194
|
get publishableKey(): ParsedPublishableKey;
|
|
149
195
|
get appKey(): string;
|
|
150
196
|
get tenantIdFromKey(): string;
|
|
151
197
|
get issuerUrl(): string;
|
|
198
|
+
/**
|
|
199
|
+
* SDK 2.7.0 (Task #124) — The hosted IQAuth host derived from the
|
|
200
|
+
* publishable key's `iss` claim, normalized to URL form. This is what
|
|
201
|
+
* `<SignIn/>` and `buildSignInUrl` use to talk to the hosted UI; it
|
|
202
|
+
* deliberately ignores the `issuer` constructor override so a misrouted
|
|
203
|
+
* `issuer` (e.g. pointed at the consumer app's own domain) cannot break
|
|
204
|
+
* the hosted flow. Use {@link issuerUrl} for token / discovery endpoints.
|
|
205
|
+
*/
|
|
206
|
+
get hostedIssuerUrl(): string;
|
|
152
207
|
/** Cookie name the SDK uses for the refresh token (overridable via `cookieNames.refresh`). */
|
|
153
208
|
get refreshCookie(): string;
|
|
209
|
+
/**
|
|
210
|
+
* Returns the current per-session idempotency token, generating one
|
|
211
|
+
* lazily on first use. Sent as the `X-IQAuth-Idempotency` header on
|
|
212
|
+
* /refresh and /signout requests so the framework adapter's
|
|
213
|
+
* `SignoutRegistry` can collapse a refresh-vs-signout race even across
|
|
214
|
+
* server instances.
|
|
215
|
+
*/
|
|
216
|
+
getIdempotencyToken(): string;
|
|
154
217
|
getSnapshot(): SessionSnapshot;
|
|
155
218
|
subscribe(listener: (s: SessionSnapshot) => void): () => void;
|
|
156
219
|
/**
|
|
157
220
|
* One-time bootstrap: warm the session from the refresh cookie if present.
|
|
158
221
|
* Safe to call multiple times.
|
|
159
222
|
*/
|
|
223
|
+
/**
|
|
224
|
+
* Task #126: Public timing-event emitter. Used by the browser sign-in
|
|
225
|
+
* helpers (redirectToSignIn / handleAuthCallback) to surface signIn-phase
|
|
226
|
+
* timings through the same `debug` + `onTimingEvent` channel as
|
|
227
|
+
* bootstrap/refresh. Safe to call from anywhere — internal callers
|
|
228
|
+
* pre-compute durationMs.
|
|
229
|
+
*/
|
|
230
|
+
recordTiming(phase: "bootstrap" | "refresh" | "signIn", durationMs: number, ok: boolean, code?: string): void;
|
|
231
|
+
/** Task #126: emit a session timing event to debug log + onTimingEvent hook. */
|
|
232
|
+
private emitTiming;
|
|
160
233
|
bootstrap(): Promise<void>;
|
|
234
|
+
private bootstrapInner;
|
|
235
|
+
private probePeers;
|
|
161
236
|
/**
|
|
162
237
|
* Single-flight token refresh, coordinated across tabs via BroadcastChannel.
|
|
163
238
|
*
|
|
@@ -485,4 +560,4 @@ declare function handleAuthCallback(manager: SessionManager, options?: {
|
|
|
485
560
|
*/
|
|
486
561
|
declare function signOut(manager: SessionManager, opts?: SignOutOptions): Promise<void>;
|
|
487
562
|
|
|
488
|
-
export { AccountRegistry as A, clearCookie as B, type CallbackResult as C, getCookie as D, setCookie as E, type LinkedIdentity as L, type MagicLinkRequestInput as M, type PasswordlessOptions as P, type RefreshTokenStore as R, SessionManager as S, type UnlinkProviderInput as U, type
|
|
563
|
+
export { AccountRegistry as A, clearCookie as B, type CallbackResult as C, getCookie as D, setCookie as E, type LinkedIdentity as L, type MagicLinkRequestInput as M, type PasswordlessOptions as P, type RefreshTokenStore as R, SessionManager as S, type UnlinkProviderInput as U, type SessionSnapshot as a, type SignInOptions as b, type SignOutOptions as c, type LinkProviderInput as d, type SessionManagerOptions as e, type SessionStatus as f, beginPasskeyAuthentication as g, finishPasskeyAuthentication as h, beginPasskeyRegistration as i, finishPasskeyRegistration as j, enrollPasskey as k, listLinkedIdentities as l, linkProvider as m, type PasskeyAuthInput as n, MultiAccountTokenStore as o, type AccountRecord as p, buildSignInUrl as q, requestMagicLink as r, signInWithPasskey as s, handleAuthCallback as t, unlinkProvider as u, verifyMagicLink as v, redirectToSignIn as w, signIn as x, signOut as y, REFRESH_COOKIE as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as ParsedPublishableKey } from './publishableKey-
|
|
2
|
-
import { J as JwtClaims,
|
|
1
|
+
import { c as ParsedPublishableKey } from './publishableKey-f2kq-rKw.mjs';
|
|
2
|
+
import { J as JwtClaims, S as SessionUser } from './types-XOV9XPVi.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* SessionManager — core browser-side session state.
|
|
@@ -120,11 +120,53 @@ interface SessionManagerOptions {
|
|
|
120
120
|
refresh?: string;
|
|
121
121
|
access?: string;
|
|
122
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Task #126: When `debug` is true, the SessionManager emits
|
|
125
|
+
* `console.debug("[iqauth_session]", evt)` for `bootstrap` and `refresh`
|
|
126
|
+
* phases. When `onTimingEvent` is set, the same event is also forwarded.
|
|
127
|
+
* Use to push browser timings into your APM. Events have shape
|
|
128
|
+
* `{ phase, durationMs, ok, code? }`.
|
|
129
|
+
*/
|
|
130
|
+
debug?: boolean;
|
|
131
|
+
onTimingEvent?: (event: {
|
|
132
|
+
phase: "bootstrap" | "refresh" | "signIn";
|
|
133
|
+
durationMs: number;
|
|
134
|
+
ok: boolean;
|
|
135
|
+
code?: string;
|
|
136
|
+
}) => void;
|
|
123
137
|
}
|
|
124
138
|
declare class SessionManager {
|
|
125
139
|
private snapshot;
|
|
126
140
|
private listeners;
|
|
127
141
|
private refreshPromise;
|
|
142
|
+
/**
|
|
143
|
+
* Cancellation handle for the in-flight refresh, if any. `signOut()` (or a
|
|
144
|
+
* `session:signout` broadcast from another tab) calls `abort()` so the
|
|
145
|
+
* refresh response is dropped before it can write a fresh access cookie
|
|
146
|
+
* on top of the just-cleared session — the second root cause of "ghost
|
|
147
|
+
* signed-in" sessions after Sign Out.
|
|
148
|
+
*/
|
|
149
|
+
private refreshAbort;
|
|
150
|
+
/**
|
|
151
|
+
* Set to `true` by `signOut()` / `signOutLocal()` for the lifetime of the
|
|
152
|
+
* call. Used as a safety belt: even if a refresh response arrives while
|
|
153
|
+
* `refreshAbort` was unable to interrupt the network call (e.g. the body
|
|
154
|
+
* was already streaming back), `runRefresh` checks this flag before
|
|
155
|
+
* mutating session state and bails out.
|
|
156
|
+
*/
|
|
157
|
+
private signoutInProgress;
|
|
158
|
+
/**
|
|
159
|
+
* Per-session opaque idempotency token. Sent as `X-IQAuth-Idempotency` on
|
|
160
|
+
* every /refresh and /signout request the SDK makes through a framework
|
|
161
|
+
* adapter (Express/Fastify/Hono/Next), so the adapter's `SignoutRegistry`
|
|
162
|
+
* can collapse a refresh that lands moments after a signout — even when
|
|
163
|
+
* the two requests are routed to different server instances (multi-replica
|
|
164
|
+
* deployments).
|
|
165
|
+
*
|
|
166
|
+
* Generated lazily on first use, rotated on signout so the next session
|
|
167
|
+
* starts with a fresh token. Opaque random — never the raw refresh token.
|
|
168
|
+
*/
|
|
169
|
+
private idempotencyToken;
|
|
128
170
|
private channel;
|
|
129
171
|
private readonly tabId;
|
|
130
172
|
private readonly fetchImpl;
|
|
@@ -138,26 +180,59 @@ declare class SessionManager {
|
|
|
138
180
|
private readonly crossTabLockTimeoutMs;
|
|
139
181
|
private readonly serverManagedSession;
|
|
140
182
|
private readonly refreshCookieName;
|
|
183
|
+
private readonly debug;
|
|
184
|
+
private readonly onTimingEvent;
|
|
141
185
|
private proactiveTimer;
|
|
142
186
|
private bootstrapped;
|
|
143
187
|
/** Pending refresh awaited by other tabs after a `refresh:claim` from us. */
|
|
144
188
|
private remoteRefreshWaiters;
|
|
145
189
|
/** Active claims by other tabs (keyed by source tabId). */
|
|
146
190
|
private foreignClaim;
|
|
191
|
+
/** Resolver for an in-flight cross-tab `session:probe`, set during bootstrap. */
|
|
192
|
+
private probeResolver;
|
|
147
193
|
constructor(options: SessionManagerOptions);
|
|
148
194
|
get publishableKey(): ParsedPublishableKey;
|
|
149
195
|
get appKey(): string;
|
|
150
196
|
get tenantIdFromKey(): string;
|
|
151
197
|
get issuerUrl(): string;
|
|
198
|
+
/**
|
|
199
|
+
* SDK 2.7.0 (Task #124) — The hosted IQAuth host derived from the
|
|
200
|
+
* publishable key's `iss` claim, normalized to URL form. This is what
|
|
201
|
+
* `<SignIn/>` and `buildSignInUrl` use to talk to the hosted UI; it
|
|
202
|
+
* deliberately ignores the `issuer` constructor override so a misrouted
|
|
203
|
+
* `issuer` (e.g. pointed at the consumer app's own domain) cannot break
|
|
204
|
+
* the hosted flow. Use {@link issuerUrl} for token / discovery endpoints.
|
|
205
|
+
*/
|
|
206
|
+
get hostedIssuerUrl(): string;
|
|
152
207
|
/** Cookie name the SDK uses for the refresh token (overridable via `cookieNames.refresh`). */
|
|
153
208
|
get refreshCookie(): string;
|
|
209
|
+
/**
|
|
210
|
+
* Returns the current per-session idempotency token, generating one
|
|
211
|
+
* lazily on first use. Sent as the `X-IQAuth-Idempotency` header on
|
|
212
|
+
* /refresh and /signout requests so the framework adapter's
|
|
213
|
+
* `SignoutRegistry` can collapse a refresh-vs-signout race even across
|
|
214
|
+
* server instances.
|
|
215
|
+
*/
|
|
216
|
+
getIdempotencyToken(): string;
|
|
154
217
|
getSnapshot(): SessionSnapshot;
|
|
155
218
|
subscribe(listener: (s: SessionSnapshot) => void): () => void;
|
|
156
219
|
/**
|
|
157
220
|
* One-time bootstrap: warm the session from the refresh cookie if present.
|
|
158
221
|
* Safe to call multiple times.
|
|
159
222
|
*/
|
|
223
|
+
/**
|
|
224
|
+
* Task #126: Public timing-event emitter. Used by the browser sign-in
|
|
225
|
+
* helpers (redirectToSignIn / handleAuthCallback) to surface signIn-phase
|
|
226
|
+
* timings through the same `debug` + `onTimingEvent` channel as
|
|
227
|
+
* bootstrap/refresh. Safe to call from anywhere — internal callers
|
|
228
|
+
* pre-compute durationMs.
|
|
229
|
+
*/
|
|
230
|
+
recordTiming(phase: "bootstrap" | "refresh" | "signIn", durationMs: number, ok: boolean, code?: string): void;
|
|
231
|
+
/** Task #126: emit a session timing event to debug log + onTimingEvent hook. */
|
|
232
|
+
private emitTiming;
|
|
160
233
|
bootstrap(): Promise<void>;
|
|
234
|
+
private bootstrapInner;
|
|
235
|
+
private probePeers;
|
|
161
236
|
/**
|
|
162
237
|
* Single-flight token refresh, coordinated across tabs via BroadcastChannel.
|
|
163
238
|
*
|
|
@@ -485,4 +560,4 @@ declare function handleAuthCallback(manager: SessionManager, options?: {
|
|
|
485
560
|
*/
|
|
486
561
|
declare function signOut(manager: SessionManager, opts?: SignOutOptions): Promise<void>;
|
|
487
562
|
|
|
488
|
-
export { AccountRegistry as A, clearCookie as B, type CallbackResult as C, getCookie as D, setCookie as E, type LinkedIdentity as L, type MagicLinkRequestInput as M, type PasswordlessOptions as P, type RefreshTokenStore as R, SessionManager as S, type UnlinkProviderInput as U, type
|
|
563
|
+
export { AccountRegistry as A, clearCookie as B, type CallbackResult as C, getCookie as D, setCookie as E, type LinkedIdentity as L, type MagicLinkRequestInput as M, type PasswordlessOptions as P, type RefreshTokenStore as R, SessionManager as S, type UnlinkProviderInput as U, type SessionSnapshot as a, type SignInOptions as b, type SignOutOptions as c, type LinkProviderInput as d, type SessionManagerOptions as e, type SessionStatus as f, beginPasskeyAuthentication as g, finishPasskeyAuthentication as h, beginPasskeyRegistration as i, finishPasskeyRegistration as j, enrollPasskey as k, listLinkedIdentities as l, linkProvider as m, type PasskeyAuthInput as n, MultiAccountTokenStore as o, type AccountRecord as p, buildSignInUrl as q, requestMagicLink as r, signInWithPasskey as s, handleAuthCallback as t, unlinkProvider as u, verifyMagicLink as v, redirectToSignIn as w, signIn as x, signOut as y, REFRESH_COOKIE as z };
|
package/dist/test.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTestIssuer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-WIFG74IK.mjs";
|
|
4
|
+
import "./chunk-HVHNYPDC.mjs";
|
|
5
|
+
import "./chunk-6PJRLRB4.mjs";
|
|
6
6
|
import "./chunk-Y6FXYEAI.mjs";
|
|
7
7
|
export {
|
|
8
8
|
createTestIssuer
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JwtClaims } from './types-
|
|
1
|
+
import { h as IQAuthClaims, J as JwtClaims } from './types-XOV9XPVi.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SOURCE REFS:
|
|
@@ -45,7 +45,7 @@ declare class TokensModule {
|
|
|
45
45
|
* Node, browser, and edge runtimes alike — no `node:crypto` dependency.
|
|
46
46
|
* Caches JWKS for 1 hour and refetches once on unknown `kid`.
|
|
47
47
|
*/
|
|
48
|
-
verify(token: string, options?: TokenVerifyOptions): Promise<JwtClaims>;
|
|
48
|
+
verify<T extends object = {}>(token: string, options?: TokenVerifyOptions): Promise<IQAuthClaims<T> & JwtClaims>;
|
|
49
49
|
/**
|
|
50
50
|
* Decode a JWT without verification. Returns null if malformed.
|
|
51
51
|
*/
|
|
@@ -58,6 +58,13 @@ declare class TokensModule {
|
|
|
58
58
|
private refreshJwks;
|
|
59
59
|
/** @internal Exposed for testing — clears JWKS cache */
|
|
60
60
|
clearCache(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Task #126: Eagerly populate the JWKS cache so the first verify() call
|
|
63
|
+
* doesn't pay a network round-trip. Safe to call repeatedly — single-flight
|
|
64
|
+
* behavior is shared with the lazy refresh path. Errors are swallowed so
|
|
65
|
+
* callers (e.g. `attachHelpers` auto-prewarm) can fire-and-forget.
|
|
66
|
+
*/
|
|
67
|
+
prewarm(): Promise<void>;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
export { DEFAULT_TOKEN_ISSUER as D, TokensModule as T, DEFAULT_TOKEN_AUDIENCE as a, DEFAULT_CLOCK_TOLERANCE_SECONDS as b, type TokenVerifyOptions as c, type TokensModuleOptions as d };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JwtClaims } from './types-
|
|
1
|
+
import { h as IQAuthClaims, J as JwtClaims } from './types-XOV9XPVi.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SOURCE REFS:
|
|
@@ -45,7 +45,7 @@ declare class TokensModule {
|
|
|
45
45
|
* Node, browser, and edge runtimes alike — no `node:crypto` dependency.
|
|
46
46
|
* Caches JWKS for 1 hour and refetches once on unknown `kid`.
|
|
47
47
|
*/
|
|
48
|
-
verify(token: string, options?: TokenVerifyOptions): Promise<JwtClaims>;
|
|
48
|
+
verify<T extends object = {}>(token: string, options?: TokenVerifyOptions): Promise<IQAuthClaims<T> & JwtClaims>;
|
|
49
49
|
/**
|
|
50
50
|
* Decode a JWT without verification. Returns null if malformed.
|
|
51
51
|
*/
|
|
@@ -58,6 +58,13 @@ declare class TokensModule {
|
|
|
58
58
|
private refreshJwks;
|
|
59
59
|
/** @internal Exposed for testing — clears JWKS cache */
|
|
60
60
|
clearCache(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Task #126: Eagerly populate the JWKS cache so the first verify() call
|
|
63
|
+
* doesn't pay a network round-trip. Safe to call repeatedly — single-flight
|
|
64
|
+
* behavior is shared with the lazy refresh path. Errors are swallowed so
|
|
65
|
+
* callers (e.g. `attachHelpers` auto-prewarm) can fire-and-forget.
|
|
66
|
+
*/
|
|
67
|
+
prewarm(): Promise<void>;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
export { DEFAULT_TOKEN_ISSUER as D, TokensModule as T, DEFAULT_TOKEN_AUDIENCE as a, DEFAULT_CLOCK_TOLERANCE_SECONDS as b, type TokenVerifyOptions as c, type TokensModuleOptions as d };
|
|
@@ -193,4 +193,4 @@ type IQAuthLocaleKey = keyof Omit<IQAuthLocaleBundle, "locale">;
|
|
|
193
193
|
*/
|
|
194
194
|
type IQAuthLocaleOverride = Partial<IQAuthLocaleBundle>;
|
|
195
195
|
|
|
196
|
-
export type { IQAuthLocaleBundle as I,
|
|
196
|
+
export type { IQAuthLocaleBundle as I, IQAuthLocaleKey as a, IQAuthLocaleOverride as b };
|
|
@@ -193,4 +193,4 @@ type IQAuthLocaleKey = keyof Omit<IQAuthLocaleBundle, "locale">;
|
|
|
193
193
|
*/
|
|
194
194
|
type IQAuthLocaleOverride = Partial<IQAuthLocaleBundle>;
|
|
195
195
|
|
|
196
|
-
export type { IQAuthLocaleBundle as I,
|
|
196
|
+
export type { IQAuthLocaleBundle as I, IQAuthLocaleKey as a, IQAuthLocaleOverride as b };
|
|
@@ -36,7 +36,17 @@ interface IQAuthTokenClientConfig extends IQAuthClientConfigBase {
|
|
|
36
36
|
apiKey?: string;
|
|
37
37
|
accessToken?: string;
|
|
38
38
|
refreshToken?: string;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Token auto-refresh strategy.
|
|
41
|
+
* - `true` (default): proactively refresh when the access token is within 60s of expiry,
|
|
42
|
+
* AND retry once on a TOKEN_EXPIRED 401 response.
|
|
43
|
+
* - `false`: never auto-refresh — caller drives `tokens.refresh()` manually.
|
|
44
|
+
* - `'app-state'` (mobile only): skip the per-request expiring-soon proactive refresh
|
|
45
|
+
* (which fights with React Native's app-suspension lifecycle) and instead refresh on
|
|
46
|
+
* AppState `active` transitions. Reactive 401 retry stays enabled. Recognized only by
|
|
47
|
+
* `createMobileClient`; passing it to other constructors falls back to `true`.
|
|
48
|
+
*/
|
|
49
|
+
autoRefresh?: boolean | "app-state";
|
|
40
50
|
onTokenRefresh?: (tokens: TokenPair) => void;
|
|
41
51
|
}
|
|
42
52
|
interface IQAuthBrowserSessionClientConfig extends IQAuthClientConfigBase {
|
|
@@ -75,7 +85,66 @@ interface JwtClaims {
|
|
|
75
85
|
email?: string;
|
|
76
86
|
name?: string;
|
|
77
87
|
};
|
|
88
|
+
picture?: string;
|
|
89
|
+
email_verified?: boolean;
|
|
90
|
+
given_name?: string;
|
|
91
|
+
family_name?: string;
|
|
92
|
+
locale?: string;
|
|
78
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Task #127 — Base claims shape (OIDC standard + IQAuth tenant/role).
|
|
96
|
+
*
|
|
97
|
+
* Required fields mirror what the IQAuth issuer always emits today; if a
|
|
98
|
+
* token is missing one of them it would fail `tokens.verify()` against the
|
|
99
|
+
* expected issuer/audience first, so this type trades runtime checks for
|
|
100
|
+
* compile-time ergonomics.
|
|
101
|
+
*/
|
|
102
|
+
interface IQAuthBaseClaims {
|
|
103
|
+
/** Subject — opaque IQAuth user id. */
|
|
104
|
+
sub: string;
|
|
105
|
+
/** OIDC issuer URL (e.g. `https://auth.dispositioniq.com`). */
|
|
106
|
+
iss: string;
|
|
107
|
+
/** Audience(s) the token was minted for. */
|
|
108
|
+
aud: string | string[];
|
|
109
|
+
/** Expiry in seconds since epoch. */
|
|
110
|
+
exp: number;
|
|
111
|
+
/** Issued-at in seconds since epoch. */
|
|
112
|
+
iat: number;
|
|
113
|
+
email?: string;
|
|
114
|
+
email_verified?: boolean;
|
|
115
|
+
name?: string;
|
|
116
|
+
picture?: string;
|
|
117
|
+
locale?: string;
|
|
118
|
+
tenantId?: string;
|
|
119
|
+
tenantName?: string;
|
|
120
|
+
tenantSlug?: string;
|
|
121
|
+
vendorId?: string | null;
|
|
122
|
+
roles?: string[];
|
|
123
|
+
entitlements?: string[];
|
|
124
|
+
sessionId?: string;
|
|
125
|
+
jti?: string;
|
|
126
|
+
scopeContext?: ScopeContext;
|
|
127
|
+
loginMethod?: string;
|
|
128
|
+
/** RFC 8693 §4.1 actor — present on impersonation tokens. */
|
|
129
|
+
purpose?: string;
|
|
130
|
+
act?: {
|
|
131
|
+
sub: string;
|
|
132
|
+
email?: string;
|
|
133
|
+
name?: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Generic typed claims envelope. The type parameter `T` is structurally
|
|
138
|
+
* intersected with the base claims so app-specific fields minted via JWT
|
|
139
|
+
* templates surface with full IntelliSense:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* type MyClaims = { plan: "free" | "pro"; orgId: string };
|
|
143
|
+
* const claims = await client.tokens.verify<MyClaims>(token);
|
|
144
|
+
* if (claims.plan === "pro" && claims.orgId) { … } // both fields typed
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
type IQAuthClaims<T extends object = {}> = IQAuthBaseClaims & T;
|
|
79
148
|
interface UserProfile {
|
|
80
149
|
id: string;
|
|
81
150
|
email: string;
|
|
@@ -102,6 +171,11 @@ interface SessionUser {
|
|
|
102
171
|
vendorId?: string | null;
|
|
103
172
|
roles: string[];
|
|
104
173
|
entitlements: string[];
|
|
174
|
+
picture?: string;
|
|
175
|
+
emailVerified?: boolean;
|
|
176
|
+
givenName?: string;
|
|
177
|
+
familyName?: string;
|
|
178
|
+
locale?: string;
|
|
105
179
|
}
|
|
106
180
|
interface Tenant {
|
|
107
181
|
tenantId: string;
|
|
@@ -407,6 +481,13 @@ interface PermissionNodeManifest {
|
|
|
407
481
|
metadata?: Record<string, unknown>;
|
|
408
482
|
children?: PermissionNodeManifest[];
|
|
409
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* Task #130 — every manifest write must declare its origin environment so a
|
|
486
|
+
* dev workstation can never silently overwrite a production app's permission
|
|
487
|
+
* tree. The Admin API rejects writes whose `environment` is missing or not
|
|
488
|
+
* one of these three values with `{code: "ENVIRONMENT_REQUIRED"}`.
|
|
489
|
+
*/
|
|
490
|
+
type AppManifestEnvironment = "production" | "staging" | "development";
|
|
410
491
|
interface AppManifest {
|
|
411
492
|
key: string;
|
|
412
493
|
name: string;
|
|
@@ -415,6 +496,8 @@ interface AppManifest {
|
|
|
415
496
|
tenantId?: string | null;
|
|
416
497
|
metadata?: Record<string, unknown>;
|
|
417
498
|
permissions: PermissionNodeManifest[];
|
|
499
|
+
/** Required by `POST /api/v1/apps/sync`. See {@link AppManifestEnvironment}. */
|
|
500
|
+
environment: AppManifestEnvironment;
|
|
418
501
|
}
|
|
419
502
|
interface AppInfo {
|
|
420
503
|
id: string;
|
|
@@ -545,13 +628,17 @@ interface GroupPermission {
|
|
|
545
628
|
nodeKey?: string | null;
|
|
546
629
|
createdAt?: string;
|
|
547
630
|
}
|
|
631
|
+
/**
|
|
632
|
+
* Task #130 — `appKey` and `nodeKey` are REQUIRED on this app-scoped admin
|
|
633
|
+
* call. The legacy `product` / `scope` shape is rejected at the SDK boundary
|
|
634
|
+
* to prevent the silent-fallback failure mode where a misconfigured value
|
|
635
|
+
* led to an empty/wrong permission set without any error.
|
|
636
|
+
*/
|
|
548
637
|
interface AddGroupPermissionRequest {
|
|
549
|
-
|
|
550
|
-
|
|
638
|
+
appKey: string;
|
|
639
|
+
nodeKey: string;
|
|
551
640
|
effect: string;
|
|
552
641
|
weight?: number;
|
|
553
|
-
appKey?: string;
|
|
554
|
-
nodeKey?: string;
|
|
555
642
|
}
|
|
556
643
|
interface InheritanceRelation {
|
|
557
644
|
id: string;
|
|
@@ -569,14 +656,16 @@ interface UserPermissionOverride {
|
|
|
569
656
|
expiresAt?: string | null;
|
|
570
657
|
createdAt?: string;
|
|
571
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Task #130 — `appKey` and `nodeKey` are REQUIRED. See `AddGroupPermissionRequest`
|
|
661
|
+
* for rationale.
|
|
662
|
+
*/
|
|
572
663
|
interface AddUserOverrideRequest {
|
|
573
|
-
|
|
574
|
-
|
|
664
|
+
appKey: string;
|
|
665
|
+
nodeKey: string;
|
|
575
666
|
effect: string;
|
|
576
667
|
weight?: number;
|
|
577
668
|
expiresAt?: string;
|
|
578
|
-
appKey?: string;
|
|
579
|
-
nodeKey?: string;
|
|
580
669
|
}
|
|
581
670
|
interface EffectivePermission {
|
|
582
671
|
scope: string;
|
|
@@ -903,4 +992,4 @@ interface BackupCodeCountResult {
|
|
|
903
992
|
remainingBackupCodes: number;
|
|
904
993
|
}
|
|
905
994
|
|
|
906
|
-
export type {
|
|
995
|
+
export type { AppManifest as $, ApiSuccessResponse as A, BrandingConfig as B, CreateTenantRequest as C, ApiErrorResponse as D, ApiResponse as E, MfaMethod as F, MfaEnrollment as G, TotpEnrollmentResult as H, IQAuthBrowserSessionClientConfig as I, JwtClaims as J, MfaVerifyResult as K, LoginResult as L, MigrateUserRequest as M, PasswordPolicy as N, OidcDiscovery as O, PromoteToVendorRequest as P, MfaPolicy as Q, UserPermissions as R, SessionUser as S, TokenPair as T, UserProfile as U, ProvisionUserRequest as V, ProvisionUserResponse as W, ExpressMiddlewareOptions as X, IQAuthRetryConfig as Y, IQAuthVerifyConfig as Z, PermissionNodeManifest as _, IQAuthRequestLike as a, BackupCodesResult as a$, AppInfo as a0, PermissionNodeInfo as a1, AppSyncResult as a2, Role as a3, CreateRoleRequest as a4, UpdateRoleRequest as a5, AssignRoleRequest as a6, UserRoleAssignment as a7, UserGroupAssignment as a8, TenantUser as a9, Source as aA, CreateSourceRequest as aB, UpdateSourceRequest as aC, Client as aD, CreateClientRequest as aE, UpdateClientRequest as aF, HierarchyVendor as aG, HierarchySource as aH, HierarchyClient as aI, HierarchyLink as aJ, Membership as aK, CreateMembershipRequest as aL, UpdateMembershipRequest as aM, MembershipWithDetails as aN, AvailableScopesTree as aO, ScopeTreeClient as aP, ScopeTreeSource as aQ, ScopeTreeVendor as aR, ScopeSwitchResult as aS, GdprExportData as aT, PinStatus as aU, PinLoginResult as aV, MfaAvailableMethods as aW, TotpEnrollResult as aX, TotpVerifyResult as aY, SmsEnrollResult as aZ, EmailEnrollResult as a_, PermissionGroup as aa, GroupPermission as ab, AddGroupPermissionRequest as ac, InheritanceRelation as ad, UserPermissionOverride as ae, AddUserOverrideRequest as af, EffectivePermission as ag, PermissionCheckResult as ah, ApiKeyInfo as ai, CreateApiKeyRequest as aj, CreateApiKeyResult as ak, ApiKeyIntrospection as al, Invitation as am, CreateInviteRequest as an, InviteValidation as ao, AcceptInviteRequest as ap, WebhookEndpoint as aq, CreateWebhookRequest as ar, CreateWebhookResult as as, WebhookDelivery as at, WebhookTestResult as au, Entitlement as av, GrantEntitlementRequest as aw, Vendor as ax, CreateVendorRequest as ay, UpdateVendorRequest as az, IQAuthResponseLike as b, BackupCodeCountResult as b0, SignupRequest as b1, HostedClientContext as b2, IQAuthNextFunction as c, IQAuthEnvironment as d, IQAuthClientConfig as e, IQAuthTokenClientConfig as f, ScopeContext as g, IQAuthClaims as h, IQAuthBaseClaims as i, Tenant as j, TokenAuthenticatedLoginResult as k, SessionAuthenticatedLoginResult as l, Session as m, TenantInfo as n, UpdateTenantRequest as o, PromoteToVendorResult as p, InviteTenantUserRequest as q, InviteTenantUserResult as r, TenantUserRoleUpdate as s, UpdateBrandingRequest as t, BrandingAsset as u, UploadAssetRequest as v, BrandingDomainMapping as w, JwksKey as x, JwksResponse as y, OidcTokenResponse as z };
|