@iqauth/sdk 2.3.0 → 2.5.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 +110 -0
- package/dist/browser-session.d.mts +3 -2
- package/dist/browser-session.d.ts +3 -2
- package/dist/browser.d.mts +64 -29
- package/dist/browser.d.ts +64 -29
- package/dist/browser.js +782 -38
- package/dist/browser.mjs +43 -3
- package/dist/bundle-LUKDQYVQ.mjs +374 -0
- package/dist/chunk-3JULWS6F.mjs +106 -0
- package/dist/chunk-5T7GHBX6.mjs +1165 -0
- package/dist/{chunk-KGEPDXHU.mjs → chunk-6TDJJER7.mjs} +2 -2
- package/dist/{chunk-RACIPVLD.mjs → chunk-76W5TLQQ.mjs} +262 -220
- package/dist/{chunk-EKTNEZIH.mjs → chunk-BVV54LPI.mjs} +37 -5
- package/dist/chunk-LIZYFXH7.mjs +90 -0
- package/dist/chunk-MKKZULZR.mjs +241 -0
- package/dist/chunk-SL3KRS4W.mjs +54 -0
- package/dist/chunk-TKZTCPEK.mjs +232 -0
- package/dist/chunk-UKZLOHZG.mjs +83 -0
- package/dist/cli/index.js +144 -36
- package/dist/cli/index.mjs +1 -1
- package/dist/{client-DTX4hNdS.d.ts → client-BNQe3AgF.d.ts} +3 -62
- package/dist/{client-vdh2a9fJ.d.mts → client-kYlJFgPv.d.mts} +3 -62
- package/dist/doctor-YYNHNMLD.mjs +198 -0
- package/dist/{express-A0-dWEMy.d.mts → express-B6_1vBYZ.d.mts} +23 -2
- package/dist/{express-Bo_pJKHN.d.ts → express-CHpfa7D_.d.ts} +23 -2
- package/dist/express.d.mts +5 -4
- package/dist/express.d.ts +5 -4
- package/dist/express.js +36 -4
- package/dist/express.mjs +8 -8
- package/dist/fastify.js +2 -2
- package/dist/fastify.mjs +4 -4
- package/dist/hono.js +2 -2
- package/dist/hono.mjs +4 -4
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +500 -4
- package/dist/index.mjs +29 -9
- package/dist/locales.d.mts +53 -0
- package/dist/locales.d.ts +53 -0
- package/dist/locales.js +1202 -0
- package/dist/locales.mjs +29 -0
- package/dist/mobile.d.mts +3 -2
- package/dist/mobile.d.ts +3 -2
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/provisioningBridge-88xjOS2n.d.mts +86 -0
- package/dist/provisioningBridge-DnTfzdZK.d.ts +86 -0
- package/dist/react.d.mts +1349 -10
- package/dist/react.d.ts +1349 -10
- package/dist/react.js +2985 -567
- package/dist/react.mjs +1517 -94
- package/dist/reverify-4UEJXUS6.mjs +16 -0
- package/dist/server/handlers.d.mts +10 -1
- package/dist/server/handlers.d.ts +10 -1
- package/dist/server/handlers.js +2 -2
- package/dist/server/handlers.mjs +1 -1
- package/dist/server.d.mts +5 -3
- package/dist/server.d.ts +5 -3
- package/dist/server.js +89 -4
- package/dist/server.mjs +12 -8
- package/dist/service.d.mts +3 -2
- package/dist/service.d.ts +3 -2
- package/dist/signIn-CCY4JE5G.mjs +15 -0
- package/dist/{signIn-Cd0P4y9d.d.mts → signIn-CiIBTJIh.d.mts} +224 -4
- package/dist/{signIn-DKakyzeu.d.ts → signIn-OCr88Zf8.d.ts} +224 -4
- package/dist/test.d.mts +86 -0
- package/dist/test.d.ts +86 -0
- package/dist/test.js +289 -0
- package/dist/test.mjs +9 -0
- package/dist/tokens-DCyzzn8L.d.mts +63 -0
- package/dist/tokens-aHiGFr_E.d.ts +63 -0
- package/dist/types-6bNdxesb.d.mts +196 -0
- package/dist/types-6bNdxesb.d.ts +196 -0
- package/dist/{types-Cxl3bQHt.d.mts → types-DZAflmmq.d.mts} +6 -0
- package/dist/{types-Cxl3bQHt.d.ts → types-DZAflmmq.d.ts} +6 -0
- package/dist/webhooks.d.mts +61 -0
- package/dist/webhooks.d.ts +61 -0
- package/dist/webhooks.js +119 -0
- package/dist/webhooks.mjs +11 -0
- package/dist/ws.d.mts +73 -0
- package/dist/ws.d.ts +73 -0
- package/dist/ws.js +397 -0
- package/dist/ws.mjs +12 -0
- package/package.json +22 -2
- package/dist/doctor-A5E7LSFW.mjs +0 -90
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ The canonical TypeScript SDK for **IQAuthService** — DispositionIQ's multi-ten
|
|
|
23
23
|
- [Token verification without a framework adapter](#token-verification-without-a-framework-adapter)
|
|
24
24
|
- [Native mobile (PKCE)](#native-mobile-pkce)
|
|
25
25
|
- [Service automation / API keys](#service-automation--api-keys)
|
|
26
|
+
- [Realtime: WebSocket upgrade verification](#realtime-websocket-upgrade-verification)
|
|
27
|
+
- [Integration testing with `createTestIssuer`](#integration-testing-with-createtestissuer)
|
|
26
28
|
- [Hosted auth pages and branding](#hosted-auth-pages-and-branding)
|
|
27
29
|
- [CLI](#cli)
|
|
28
30
|
- [Error handling](#error-handling)
|
|
@@ -388,6 +390,77 @@ API-key calls are scoped to the permissions granted at creation time and are sub
|
|
|
388
390
|
|
|
389
391
|
---
|
|
390
392
|
|
|
393
|
+
## Realtime: WebSocket upgrade verification
|
|
394
|
+
|
|
395
|
+
`@iqauth/sdk/ws` exposes a single `verifyWsUpgrade(req, options)` helper for Node WebSocket servers. Same option shape as the framework middlewares — `publishableKey`, `audience`, `issuer`, `clockTolerance`, cookie name. Returns `{ claims }` on success or `null` on missing/invalid/expired tokens.
|
|
396
|
+
|
|
397
|
+
It accepts a token from any of:
|
|
398
|
+
|
|
399
|
+
1. `Authorization: Bearer <jwt>` header.
|
|
400
|
+
2. The `iqauth_at` cookie on the upgrade request (override with `cookieName`).
|
|
401
|
+
3. The `Sec-WebSocket-Protocol` subprotocol value `iqauth.bearer.<jwt>` — browser `WebSocket` can't set custom headers, so the convention is to publish the token as a subprotocol value alongside the real one (e.g. `new WebSocket(url, ["iqauth.bearer." + token, "graphql-transport-ws"])`).
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
import { WebSocketServer } from "ws";
|
|
405
|
+
import { verifyWsUpgrade } from "@iqauth/sdk/ws";
|
|
406
|
+
|
|
407
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
408
|
+
|
|
409
|
+
httpServer.on("upgrade", async (req, socket, head) => {
|
|
410
|
+
const result = await verifyWsUpgrade(req, {
|
|
411
|
+
publishableKey: process.env.IQAUTH_PUBLISHABLE_KEY!,
|
|
412
|
+
audience: "dispositioniq",
|
|
413
|
+
});
|
|
414
|
+
if (!result) {
|
|
415
|
+
socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
|
|
416
|
+
socket.destroy();
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
420
|
+
wss.emit("connection", ws, req, result.claims);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
A consumer can replace IQValidate's hand-rolled `packages/shared/src/websocket-server.ts authenticateUser()` with one import and one call.
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Integration testing with `createTestIssuer`
|
|
430
|
+
|
|
431
|
+
`@iqauth/sdk/test` spawns an in-process HTTP server that exposes a JWKS endpoint, an OIDC discovery doc, a token endpoint that accepts code-exchange calls, and a `/api/v1/auth/me` userinfo endpoint. It mints valid RS256 JWTs against a freshly generated keypair, so integration tests don't need a live IQAuth.
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
import { createTestIssuer } from "@iqauth/sdk/test";
|
|
435
|
+
|
|
436
|
+
let issuer;
|
|
437
|
+
beforeAll(async () => { issuer = await createTestIssuer({ port: 0 }); });
|
|
438
|
+
afterAll(async () => { await issuer.close(); });
|
|
439
|
+
|
|
440
|
+
it("admin can list users", async () => {
|
|
441
|
+
const token = issuer.mintToken({ sub: "u1", roles: ["tenant_admin"] });
|
|
442
|
+
const r = await fetch("http://localhost:3000/api/users", {
|
|
443
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
444
|
+
});
|
|
445
|
+
expect(r.status).toBe(200);
|
|
446
|
+
});
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Point your SDK / React provider at `issuer.baseUrl` — or pass `issuer.publishableKey`, which already encodes the right `iss`. To exercise the full code-exchange flow:
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
const code = issuer.mintAuthCode({ sub: "u1", roles: ["tenant_admin"] });
|
|
453
|
+
const tokens = await fetch(`${issuer.baseUrl}/oidc/token`, {
|
|
454
|
+
method: "POST",
|
|
455
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
456
|
+
body: new URLSearchParams({ grant_type: "authorization_code", code }),
|
|
457
|
+
}).then((r) => r.json());
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Out of scope: the test issuer does not mock SSO providers (Google, Microsoft) and does not replicate the full DispositionIQ admin/permissions API surface — it implements exactly enough to satisfy the SDK's verify path and the common code-exchange flow.
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
391
464
|
## Hosted auth pages and branding
|
|
392
465
|
|
|
393
466
|
Sign-in, sign-up, forgot-password, and account pages are hosted at `auth.dispositioniq.com`. They render with your app's brand once you set CSS variables in the admin dashboard:
|
|
@@ -501,6 +574,24 @@ This is the single most common bug we see when teams add IQAuth to an app that a
|
|
|
501
574
|
|
|
502
575
|
---
|
|
503
576
|
|
|
577
|
+
## Migrating from Clerk's backend SDK
|
|
578
|
+
|
|
579
|
+
If you're moving from `@clerk/backend` to `@iqauth/sdk`, the surface is intentionally close but not identical. The full audit lives at [`docs/backend-sdk-parity.md`](../../docs/backend-sdk-parity.md); the high-leverage deltas:
|
|
580
|
+
|
|
581
|
+
- **Vocabulary.** Clerk's `organization` is IQAuth's `tenant`. `Clerk.users.banUser(id)` ↔ `iqauth.users.deactivate(id)`; `unbanUser` ↔ `reactivate`. The IQAuth modules are `tenants`, `memberships`, `roles`, `invites` — together they cover what Clerk packs into `organizations`.
|
|
582
|
+
- **Tenant scoping is explicit.** `users.create` takes `(tenantId, data)` rather than implying it from the API key. List endpoints (`users.list`, `tenants.list`, `memberships.listForTenant`) accept tenant filters.
|
|
583
|
+
- **Pagination + filters are still partial.** `users.list({ email, tenantId })` and `tenants.list({ vendorId })` work today, but Clerk-style `{ limit, offset, query, orderBy }` is on the near-term roadmap. Bulk-import scripts that page through tens of thousands of users should call the REST API directly until the helpers ship.
|
|
584
|
+
- **Admin-side user mutations.** `users.update(...)` in this SDK currently updates **only the calling user** (name, picture). Admin-on-behalf-of `update` / `delete` / `verifyPassword` and a `passwordDigest` import path for `users.create` are tracked as follow-ups; until then, use the REST API or the admin console.
|
|
585
|
+
- **Invitations.** `invites.create / validate / accept` are present. `invites.list` (pending) and `invites.revoke` are not in the SDK yet — same for the equivalent organization-invitation calls; tracked as follow-ups.
|
|
586
|
+
- **Sessions.** `sessions.list / revoke / revokeAll` are scoped to the **current user**. There is no admin-side `sessions.getSessionList({ userId })` yet; tracked as a follow-up.
|
|
587
|
+
- **Webhook signature verification.** Clerk wraps Svix's `Webhook.verify(payload, headers)`. IQAuth ships endpoint CRUD + delivery history + secret rotation, but receivers must verify HMAC signatures by hand today. A `webhooks.verifySignature(...)` helper is in flight under the existing rotation task.
|
|
588
|
+
- **Actor / impersonation tokens.** Tracked separately (see internal task F23 / #86). Not yet in the SDK.
|
|
589
|
+
- **Won't do.** JWT templates and per-instance domain CRUD are Clerk-specific and don't map to IQAuth's product surface. See the audit doc for documented alternatives.
|
|
590
|
+
|
|
591
|
+
For anything in the "won't do" / "different shape" rows of the audit, prefer the linked alternative over reaching back into REST — those alternatives are the supported path.
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
504
595
|
## Bundled docs
|
|
505
596
|
|
|
506
597
|
Long-form integration guides ship **inside the npm tarball** at `node_modules/@iqauth/sdk/docs/`. List them with:
|
|
@@ -528,3 +619,22 @@ These are also kept on the IQAuth admin dashboard's documentation tab.
|
|
|
528
619
|
## License
|
|
529
620
|
|
|
530
621
|
Proprietary — DispositionIQ internal use. See the LICENSE/usage terms in the bundled docs.
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## Deploying with Docker / Next.js (read this before you ship)
|
|
627
|
+
|
|
628
|
+
The publishable key is baked into your build. NEXT_PUBLIC_* and VITE_* variables are inlined at build time, not run time. A docker image built against your staging issuer will continue to point at staging even when you later run it with -e NEXT_PUBLIC_IQAUTH_PUBLISHABLE_KEY=pk_live_xyz — Next.js / Vite have no way to re-resolve the constant after the bundle is emitted.
|
|
629
|
+
|
|
630
|
+
Two safe patterns:
|
|
631
|
+
|
|
632
|
+
1. Build the image per-environment (recommended for separate prod/stage stacks). Use ARG and ENV in the Dockerfile and pass --build-arg NEXT_PUBLIC_IQAUTH_PUBLISHABLE_KEY=pk_live_xyz at docker build time.
|
|
633
|
+
|
|
634
|
+
2. Read the key at request time on the server (single image, multi-env): fetch the publishable key in getServerSideProps / a Next.js Route Handler / your Express bootstrap and pass it to <IQAuthProvider publishableKey={...}> as a runtime prop. Server-side env vars ARE re-read on every container start, so the same image deploys to any environment.
|
|
635
|
+
|
|
636
|
+
Verify the build before you push: the iqauth doctor CLI compares the issuer encoded in your publishable key against the issuers discovery document and warns when they disagree:
|
|
637
|
+
|
|
638
|
+
npx iqauth doctor --issuer https://auth.example.com --publishable-key $NEXT_PUBLIC_IQAUTH_PUBLISHABLE_KEY
|
|
639
|
+
|
|
640
|
+
Wire this into CI right after next build and youll catch a wrong-environment publishable key before the image ships.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as IQAuthBrowserSessionClientConfig, d as SessionUser } from './types-
|
|
2
|
-
import { I as IQAuthClient } from './client-
|
|
1
|
+
import { c as IQAuthBrowserSessionClientConfig, d as SessionUser } from './types-DZAflmmq.mjs';
|
|
2
|
+
import { I as IQAuthClient } from './client-kYlJFgPv.mjs';
|
|
3
3
|
export { E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.mjs';
|
|
4
|
+
import './tokens-DCyzzn8L.mjs';
|
|
4
5
|
|
|
5
6
|
declare class BrowserSessionIQAuthClient extends IQAuthClient {
|
|
6
7
|
constructor(config: Omit<IQAuthBrowserSessionClientConfig, "environment">);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as IQAuthBrowserSessionClientConfig, d as SessionUser } from './types-
|
|
2
|
-
import { I as IQAuthClient } from './client-
|
|
1
|
+
import { c as IQAuthBrowserSessionClientConfig, d as SessionUser } from './types-DZAflmmq.js';
|
|
2
|
+
import { I as IQAuthClient } from './client-BNQe3AgF.js';
|
|
3
3
|
export { E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.js';
|
|
4
|
+
import './tokens-aHiGFr_E.js';
|
|
4
5
|
|
|
5
6
|
declare class BrowserSessionIQAuthClient extends IQAuthClient {
|
|
6
7
|
constructor(config: Omit<IQAuthBrowserSessionClientConfig, "environment">);
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as SessionManager } from './signIn-CiIBTJIh.mjs';
|
|
2
|
+
export { n as AccountRecord, A as AccountRegistry, C as CallbackResult, k as LinkProviderInput, L as LinkedIdentity, M as MagicLinkRequestInput, m as MultiAccountTokenStore, j as PasskeyAuthInput, P as PasswordlessOptions, z as REFRESH_COOKIE, R as RefreshTokenStore, a as SessionManagerOptions, b as SessionSnapshot, c as SessionStatus, x as SignInOptions, y as SignOutOptions, U as UnlinkProviderInput, d as beginPasskeyAuthentication, e as beginPasskeyRegistration, o as buildSignInUrl, B as clearCookie, h as enrollPasskey, f as finishPasskeyAuthentication, g as finishPasskeyRegistration, D as getCookie, p as handleAuthCallback, i as linkProvider, l as listLinkedIdentities, q as redirectToSignIn, r as requestMagicLink, E as setCookie, t as signIn, s as signInWithPasskey, w as signOut, u as unlinkProvider, v as verifyMagicLink } from './signIn-CiIBTJIh.mjs';
|
|
2
3
|
export { K as KeyMode, c as ParsedPublishableKey, P as PublishableKeyPayload, e as encodePublishableKey, i as isPublishableKey, b as isSecretKey, p as parsePublishableKey } from './publishableKey-BaR0HoAH.mjs';
|
|
3
4
|
export { a as ErrorCode, E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.mjs';
|
|
4
|
-
import './types-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Browser-only storage helpers used by the SessionManager.
|
|
8
|
-
*
|
|
9
|
-
* Storage strategy (Phase B):
|
|
10
|
-
* - Access token: in memory only (held by SessionManager).
|
|
11
|
-
* - Refresh token: first-party cookie on the app's own domain. The cookie
|
|
12
|
-
* is set by the SDK callback handler and cleared on signOut.
|
|
13
|
-
*
|
|
14
|
-
* NOTE: Cookies set from JS cannot be httpOnly. Phase D (cookie-aware
|
|
15
|
-
* middleware) will move refresh-token cookie management into the app's
|
|
16
|
-
* backend so it can be httpOnly. Until then, the SDK uses a `Secure`,
|
|
17
|
-
* `SameSite=Lax` first-party cookie as a pragmatic stopgap. Nothing
|
|
18
|
-
* privileged ever lives in localStorage.
|
|
19
|
-
*/
|
|
20
|
-
declare const REFRESH_COOKIE = "iqauth_rt";
|
|
21
|
-
interface CookieOptions {
|
|
22
|
-
maxAgeSeconds?: number;
|
|
23
|
-
path?: string;
|
|
24
|
-
domain?: string;
|
|
25
|
-
secure?: boolean;
|
|
26
|
-
sameSite?: "lax" | "strict" | "none";
|
|
27
|
-
}
|
|
28
|
-
declare function setCookie(name: string, value: string, opts?: CookieOptions): void;
|
|
29
|
-
declare function getCookie(name: string): string | null;
|
|
30
|
-
declare function clearCookie(name: string, opts?: CookieOptions): void;
|
|
5
|
+
import './types-DZAflmmq.mjs';
|
|
31
6
|
|
|
32
7
|
/**
|
|
33
8
|
* Browser-safe PKCE + state/nonce generation using WebCrypto.
|
|
@@ -43,4 +18,64 @@ interface PkcePair {
|
|
|
43
18
|
}
|
|
44
19
|
declare function createPkcePair(): Promise<PkcePair>;
|
|
45
20
|
|
|
46
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Step-up reverification helper — Task #90 (F27, SDK side).
|
|
23
|
+
*
|
|
24
|
+
* Calls `POST {issuer}/api/v1/auth/reverify` with the user's password or
|
|
25
|
+
* MFA code, and returns a short-lived single-use token the caller
|
|
26
|
+
* should attach to subsequent sensitive requests as
|
|
27
|
+
* `X-Reverification-Token`.
|
|
28
|
+
*
|
|
29
|
+
* Designed to pair with `auth.fetch()` — see README:
|
|
30
|
+
*
|
|
31
|
+
* const { token } = await reverify(manager, { level: "password", password });
|
|
32
|
+
* await manager.fetch("/api/billing/payouts", {
|
|
33
|
+
* method: "POST",
|
|
34
|
+
* headers: { "X-Reverification-Token": token },
|
|
35
|
+
* body: JSON.stringify({...}),
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sessionstorage key under which we stash the admin's pre-impersonation
|
|
41
|
+
* access token so `<ImpersonationBanner/>` can restore it on Exit.
|
|
42
|
+
* Tab-scoped (sessionStorage) by design — impersonation must not survive
|
|
43
|
+
* tab close, and we never want the admin's token to leak into other tabs.
|
|
44
|
+
*/
|
|
45
|
+
declare const PRIOR_SESSION_STORAGE_KEY = "iqauth_prior_admin_session";
|
|
46
|
+
/**
|
|
47
|
+
* Stash the current admin session token, then swap to an impersonation
|
|
48
|
+
* access token minted by `POST /api/v1/admin/users/:id/actor-token`.
|
|
49
|
+
* The banner's "Exit" restores the prior session via `exitImpersonation`.
|
|
50
|
+
*/
|
|
51
|
+
declare function enterImpersonation(manager: SessionManager, actorAccessToken: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Restore the admin's pre-impersonation access token (if any) and clear
|
|
54
|
+
* the stash. Returns `true` when a prior session was restored, `false`
|
|
55
|
+
* when none was found (caller should then `signOut` instead).
|
|
56
|
+
*/
|
|
57
|
+
declare function exitImpersonation(manager: SessionManager): boolean;
|
|
58
|
+
type ReverificationLevel = "password" | "mfa";
|
|
59
|
+
interface ReverifyInput {
|
|
60
|
+
level: ReverificationLevel;
|
|
61
|
+
password?: string;
|
|
62
|
+
totp?: string;
|
|
63
|
+
method?: "totp" | "sms" | "email";
|
|
64
|
+
ttlSeconds?: number;
|
|
65
|
+
}
|
|
66
|
+
interface ReverifyResult {
|
|
67
|
+
token: string;
|
|
68
|
+
level: ReverificationLevel;
|
|
69
|
+
expiresAt: Date;
|
|
70
|
+
}
|
|
71
|
+
declare function reverify(manager: SessionManager, input: ReverifyInput, options?: {
|
|
72
|
+
path?: string;
|
|
73
|
+
}): Promise<ReverifyResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Convenience wrapper: returns a `fetch`-compatible function that
|
|
76
|
+
* automatically attaches `X-Reverification-Token` on the next call,
|
|
77
|
+
* then forgets it (single-use mirror of the server semantics).
|
|
78
|
+
*/
|
|
79
|
+
declare function withReverification(manager: SessionManager, token: string): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
80
|
+
|
|
81
|
+
export { PRIOR_SESSION_STORAGE_KEY, type ReverificationLevel, type ReverifyInput, type ReverifyResult, SessionManager, createPkcePair, enterImpersonation, exitImpersonation, randomUrlSafe, reverify, s256Challenge, withReverification };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as SessionManager } from './signIn-OCr88Zf8.js';
|
|
2
|
+
export { n as AccountRecord, A as AccountRegistry, C as CallbackResult, k as LinkProviderInput, L as LinkedIdentity, M as MagicLinkRequestInput, m as MultiAccountTokenStore, j as PasskeyAuthInput, P as PasswordlessOptions, z as REFRESH_COOKIE, R as RefreshTokenStore, a as SessionManagerOptions, b as SessionSnapshot, c as SessionStatus, x as SignInOptions, y as SignOutOptions, U as UnlinkProviderInput, d as beginPasskeyAuthentication, e as beginPasskeyRegistration, o as buildSignInUrl, B as clearCookie, h as enrollPasskey, f as finishPasskeyAuthentication, g as finishPasskeyRegistration, D as getCookie, p as handleAuthCallback, i as linkProvider, l as listLinkedIdentities, q as redirectToSignIn, r as requestMagicLink, E as setCookie, t as signIn, s as signInWithPasskey, w as signOut, u as unlinkProvider, v as verifyMagicLink } from './signIn-OCr88Zf8.js';
|
|
2
3
|
export { K as KeyMode, c as ParsedPublishableKey, P as PublishableKeyPayload, e as encodePublishableKey, i as isPublishableKey, b as isSecretKey, p as parsePublishableKey } from './publishableKey-BaR0HoAH.js';
|
|
3
4
|
export { a as ErrorCode, E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.js';
|
|
4
|
-
import './types-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Browser-only storage helpers used by the SessionManager.
|
|
8
|
-
*
|
|
9
|
-
* Storage strategy (Phase B):
|
|
10
|
-
* - Access token: in memory only (held by SessionManager).
|
|
11
|
-
* - Refresh token: first-party cookie on the app's own domain. The cookie
|
|
12
|
-
* is set by the SDK callback handler and cleared on signOut.
|
|
13
|
-
*
|
|
14
|
-
* NOTE: Cookies set from JS cannot be httpOnly. Phase D (cookie-aware
|
|
15
|
-
* middleware) will move refresh-token cookie management into the app's
|
|
16
|
-
* backend so it can be httpOnly. Until then, the SDK uses a `Secure`,
|
|
17
|
-
* `SameSite=Lax` first-party cookie as a pragmatic stopgap. Nothing
|
|
18
|
-
* privileged ever lives in localStorage.
|
|
19
|
-
*/
|
|
20
|
-
declare const REFRESH_COOKIE = "iqauth_rt";
|
|
21
|
-
interface CookieOptions {
|
|
22
|
-
maxAgeSeconds?: number;
|
|
23
|
-
path?: string;
|
|
24
|
-
domain?: string;
|
|
25
|
-
secure?: boolean;
|
|
26
|
-
sameSite?: "lax" | "strict" | "none";
|
|
27
|
-
}
|
|
28
|
-
declare function setCookie(name: string, value: string, opts?: CookieOptions): void;
|
|
29
|
-
declare function getCookie(name: string): string | null;
|
|
30
|
-
declare function clearCookie(name: string, opts?: CookieOptions): void;
|
|
5
|
+
import './types-DZAflmmq.js';
|
|
31
6
|
|
|
32
7
|
/**
|
|
33
8
|
* Browser-safe PKCE + state/nonce generation using WebCrypto.
|
|
@@ -43,4 +18,64 @@ interface PkcePair {
|
|
|
43
18
|
}
|
|
44
19
|
declare function createPkcePair(): Promise<PkcePair>;
|
|
45
20
|
|
|
46
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Step-up reverification helper — Task #90 (F27, SDK side).
|
|
23
|
+
*
|
|
24
|
+
* Calls `POST {issuer}/api/v1/auth/reverify` with the user's password or
|
|
25
|
+
* MFA code, and returns a short-lived single-use token the caller
|
|
26
|
+
* should attach to subsequent sensitive requests as
|
|
27
|
+
* `X-Reverification-Token`.
|
|
28
|
+
*
|
|
29
|
+
* Designed to pair with `auth.fetch()` — see README:
|
|
30
|
+
*
|
|
31
|
+
* const { token } = await reverify(manager, { level: "password", password });
|
|
32
|
+
* await manager.fetch("/api/billing/payouts", {
|
|
33
|
+
* method: "POST",
|
|
34
|
+
* headers: { "X-Reverification-Token": token },
|
|
35
|
+
* body: JSON.stringify({...}),
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sessionstorage key under which we stash the admin's pre-impersonation
|
|
41
|
+
* access token so `<ImpersonationBanner/>` can restore it on Exit.
|
|
42
|
+
* Tab-scoped (sessionStorage) by design — impersonation must not survive
|
|
43
|
+
* tab close, and we never want the admin's token to leak into other tabs.
|
|
44
|
+
*/
|
|
45
|
+
declare const PRIOR_SESSION_STORAGE_KEY = "iqauth_prior_admin_session";
|
|
46
|
+
/**
|
|
47
|
+
* Stash the current admin session token, then swap to an impersonation
|
|
48
|
+
* access token minted by `POST /api/v1/admin/users/:id/actor-token`.
|
|
49
|
+
* The banner's "Exit" restores the prior session via `exitImpersonation`.
|
|
50
|
+
*/
|
|
51
|
+
declare function enterImpersonation(manager: SessionManager, actorAccessToken: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Restore the admin's pre-impersonation access token (if any) and clear
|
|
54
|
+
* the stash. Returns `true` when a prior session was restored, `false`
|
|
55
|
+
* when none was found (caller should then `signOut` instead).
|
|
56
|
+
*/
|
|
57
|
+
declare function exitImpersonation(manager: SessionManager): boolean;
|
|
58
|
+
type ReverificationLevel = "password" | "mfa";
|
|
59
|
+
interface ReverifyInput {
|
|
60
|
+
level: ReverificationLevel;
|
|
61
|
+
password?: string;
|
|
62
|
+
totp?: string;
|
|
63
|
+
method?: "totp" | "sms" | "email";
|
|
64
|
+
ttlSeconds?: number;
|
|
65
|
+
}
|
|
66
|
+
interface ReverifyResult {
|
|
67
|
+
token: string;
|
|
68
|
+
level: ReverificationLevel;
|
|
69
|
+
expiresAt: Date;
|
|
70
|
+
}
|
|
71
|
+
declare function reverify(manager: SessionManager, input: ReverifyInput, options?: {
|
|
72
|
+
path?: string;
|
|
73
|
+
}): Promise<ReverifyResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Convenience wrapper: returns a `fetch`-compatible function that
|
|
76
|
+
* automatically attaches `X-Reverification-Token` on the next call,
|
|
77
|
+
* then forgets it (single-use mirror of the server semantics).
|
|
78
|
+
*/
|
|
79
|
+
declare function withReverification(manager: SessionManager, token: string): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
80
|
+
|
|
81
|
+
export { PRIOR_SESSION_STORAGE_KEY, type ReverificationLevel, type ReverifyInput, type ReverifyResult, SessionManager, createPkcePair, enterImpersonation, exitImpersonation, randomUrlSafe, reverify, s256Challenge, withReverification };
|