@iqauth/sdk 2.7.0 → 2.8.1

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.
Files changed (88) hide show
  1. package/dist/browser-session.d.mts +3 -3
  2. package/dist/browser-session.d.ts +3 -3
  3. package/dist/browser-session.js +31 -5
  4. package/dist/browser-session.mjs +1 -1
  5. package/dist/browser.d.mts +3 -3
  6. package/dist/browser.d.ts +3 -3
  7. package/dist/browser.js +23 -3
  8. package/dist/browser.mjs +1 -1
  9. package/dist/{chunk-YVALAG3B.mjs → chunk-25SSYDIP.mjs} +1 -1
  10. package/dist/{chunk-RTJAIBXY.mjs → chunk-4V7FKOTG.mjs} +23 -3
  11. package/dist/{chunk-SL3KRS4W.mjs → chunk-CIJORODR.mjs} +23 -1
  12. package/dist/chunk-JRDVUWAL.mjs +46 -0
  13. package/dist/{chunk-5T7GHBX6.mjs → chunk-TLET552H.mjs} +36 -0
  14. package/dist/{chunk-PMAFENVI.mjs → chunk-VYQ3ETCK.mjs} +27 -12
  15. package/dist/{chunk-RR2MGPTK.mjs → chunk-WHT6WKTY.mjs} +539 -83
  16. package/dist/{chunk-RUJXRTEW.mjs → chunk-WSH4SW7F.mjs} +122 -8
  17. package/dist/{chunk-JXQI62A7.mjs → chunk-ZLJPABB7.mjs} +31 -5
  18. package/dist/{client-BGFnBpfc.d.mts → client-D8L-PaWr.d.mts} +14 -4
  19. package/dist/{client-CDQ21LvW.d.ts → client-DkPL0EPZ.d.ts} +14 -4
  20. package/dist/{express-Piv2WhWM.d.ts → express-Budysq4h.d.ts} +2 -2
  21. package/dist/{express-CVNQEkOr.d.mts → express-DDTA3qV1.d.mts} +2 -2
  22. package/dist/express.d.mts +5 -5
  23. package/dist/express.d.ts +5 -5
  24. package/dist/express.js +217 -36
  25. package/dist/express.mjs +38 -26
  26. package/dist/fastify.d.mts +10 -2
  27. package/dist/fastify.d.ts +10 -2
  28. package/dist/fastify.js +260 -16
  29. package/dist/fastify.mjs +80 -5
  30. package/dist/hono.d.mts +10 -2
  31. package/dist/hono.d.ts +10 -2
  32. package/dist/hono.js +240 -16
  33. package/dist/hono.mjs +60 -5
  34. package/dist/{index-5KSZEnDe.d.ts → index-Cko-d5po.d.mts} +227 -5
  35. package/dist/{index-CKoZHAoc.d.mts → index-RNqwEcmY.d.ts} +227 -5
  36. package/dist/index.d.mts +5 -5
  37. package/dist/index.d.ts +5 -5
  38. package/dist/index.js +149 -26
  39. package/dist/index.mjs +5 -5
  40. package/dist/locales.d.mts +1 -1
  41. package/dist/locales.d.ts +1 -1
  42. package/dist/locales.js +36 -0
  43. package/dist/locales.mjs +1 -1
  44. package/dist/mobile.d.mts +3 -3
  45. package/dist/mobile.d.ts +3 -3
  46. package/dist/mobile.js +31 -5
  47. package/dist/mobile.mjs +1 -1
  48. package/dist/next.d.mts +10 -2
  49. package/dist/next.d.ts +10 -2
  50. package/dist/next.js +212 -11
  51. package/dist/next.mjs +62 -4
  52. package/dist/{provisioningBridge-M5G47LWO.d.mts → provisioningBridge-BXPMZCLe.d.ts} +30 -2
  53. package/dist/{provisioningBridge-CGpMRie4.d.ts → provisioningBridge-IEycmsgb.d.mts} +30 -2
  54. package/dist/react-permissions.d.mts +4 -4
  55. package/dist/react-permissions.d.ts +4 -4
  56. package/dist/react-permissions.mjs +4 -3
  57. package/dist/react.d.mts +4 -4
  58. package/dist/react.d.ts +4 -4
  59. package/dist/react.js +570 -41
  60. package/dist/react.mjs +19 -5
  61. package/dist/server/handlers.d.mts +56 -5
  62. package/dist/server/handlers.d.ts +56 -5
  63. package/dist/server/handlers.js +123 -8
  64. package/dist/server/handlers.mjs +3 -1
  65. package/dist/server.d.mts +28 -8
  66. package/dist/server.d.ts +28 -8
  67. package/dist/server.js +176 -14
  68. package/dist/server.mjs +9 -4
  69. package/dist/service.d.mts +3 -3
  70. package/dist/service.d.ts +3 -3
  71. package/dist/service.js +31 -5
  72. package/dist/service.mjs +1 -1
  73. package/dist/{signIn-T-CZ6t6r.d.mts → signIn-CReqfXsh.d.mts} +18 -1
  74. package/dist/{signIn-BLFnz8SV.d.ts → signIn-Cfa1GTpO.d.ts} +18 -1
  75. package/dist/{tokens-Bqhmqq_R.d.ts → tokens-9F6ETrzk.d.ts} +1 -1
  76. package/dist/{tokens-CITeoG6P.d.mts → tokens-B06VtvUi.d.mts} +1 -1
  77. package/dist/{types-XOV9XPVi.d.mts → types-Bn8O-OEd.d.mts} +66 -2
  78. package/dist/{types-XOV9XPVi.d.ts → types-Bn8O-OEd.d.ts} +66 -2
  79. package/dist/{types-BdQ2lqfT.d.mts → types-DnU2LhXR.d.mts} +6 -0
  80. package/dist/{types-BdQ2lqfT.d.ts → types-DnU2LhXR.d.ts} +6 -0
  81. package/dist/webhooks.d.mts +22 -9
  82. package/dist/webhooks.d.ts +22 -9
  83. package/dist/webhooks.js +27 -12
  84. package/dist/webhooks.mjs +1 -1
  85. package/dist/ws.d.mts +2 -2
  86. package/dist/ws.d.ts +2 -2
  87. package/docs/guides/invitations.md +65 -0
  88. package/package.json +7 -2
@@ -17,7 +17,11 @@ async function buildUserinfoResponse(claims, opts = {}) {
17
17
  tenantId: claims.tenantId,
18
18
  vendorId: claims.vendorId,
19
19
  roles: claims.roles ?? [],
20
- entitlements: claims.entitlements ?? []
20
+ entitlements: claims.entitlements ?? [],
21
+ // Task #171 — project the active source/client scope onto the userinfo
22
+ // payload so server handlers (`getSessionUser`, `/api/iqauth/userinfo`)
23
+ // expose it without consumers having to re-decode the JWT.
24
+ ...claims.scopeContext !== void 0 ? { scopeContext: claims.scopeContext } : {}
21
25
  };
22
26
  const enriched = opts.enrich ? await opts.enrich(claims) : null;
23
27
  const user = enriched ? { ...baseUser, ...enriched } : baseUser;
@@ -62,19 +66,62 @@ function shouldClearCookiesOnFailure(policy, status, errorCode) {
62
66
  }
63
67
  var ACCESS_TOKEN_TTL_SECONDS = 60 * 15;
64
68
  var REFRESH_TOKEN_TTL_SECONDS = 60 * 60 * 24 * 30;
69
+ function assertCookiePrefixInvariants(name, secure, path, domain) {
70
+ if (name.startsWith("__Host-")) {
71
+ if (!secure) {
72
+ throw new IQAuthError(
73
+ "config_invalid",
74
+ `Cookie "${name}" uses the __Host- prefix, which browsers only accept on a Secure cookie. Set secure:true (and serve over HTTPS).`
75
+ );
76
+ }
77
+ if (path !== "/") {
78
+ throw new IQAuthError(
79
+ "config_invalid",
80
+ `Cookie "${name}" uses the __Host- prefix, which requires Path=/ (got "${path}"). Remove cookiePath or set it to "/".`
81
+ );
82
+ }
83
+ if (domain) {
84
+ throw new IQAuthError(
85
+ "config_invalid",
86
+ `Cookie "${name}" uses the __Host- prefix, which forbids a Domain attribute (the cookie is host-locked). Remove cookieDomain.`
87
+ );
88
+ }
89
+ } else if (name.startsWith("__Secure-") && !secure) {
90
+ throw new IQAuthError(
91
+ "config_invalid",
92
+ `Cookie "${name}" uses the __Secure- prefix, which browsers only accept on a Secure cookie. Set secure:true (and serve over HTTPS).`
93
+ );
94
+ }
95
+ }
65
96
  function resolve(config) {
66
97
  const parsed = assertPublishableKey(config.publishableKey, { context: "@iqauth/sdk helpers" });
67
98
  const inferredIssuer = parsed.iss.startsWith("http") ? parsed.iss : `https://${parsed.iss}`;
99
+ maybeWarnDefaultSignoutRegistry(config);
100
+ const secure = config.secure ?? true;
101
+ if (config.secure === false && config.allowInsecureCookies !== true) {
102
+ throw new IQAuthError(
103
+ "config_invalid",
104
+ "Refusing to issue auth cookies with secure:false \u2014 this exposes session cookies over plaintext HTTP. For local HTTP development, set allowInsecureCookies:true to acknowledge the risk. Production MUST use HTTPS with secure cookies."
105
+ );
106
+ }
107
+ const accessCookieName = config.accessCookieName ?? config.cookieNames?.access ?? "iqauth_at";
108
+ const refreshCookieName = config.refreshCookieName ?? config.cookieNames?.refresh ?? "iqauth_rt";
109
+ const stateCookieName = config.stateCookieName ?? "iqauth_state";
110
+ const cookiePath = config.cookiePath ?? "/";
111
+ const cookieDomain = config.cookieDomain;
112
+ for (const name of [accessCookieName, refreshCookieName, stateCookieName]) {
113
+ assertCookiePrefixInvariants(name, secure, cookiePath, cookieDomain);
114
+ }
68
115
  return {
69
116
  publishableKey: config.publishableKey,
70
117
  secretKey: config.secretKey,
71
118
  issuer: (config.issuer ?? inferredIssuer).replace(/\/+$/, ""),
72
- accessCookieName: config.accessCookieName ?? config.cookieNames?.access ?? "iqauth_at",
73
- refreshCookieName: config.refreshCookieName ?? config.cookieNames?.refresh ?? "iqauth_rt",
74
- cookieDomain: config.cookieDomain,
119
+ accessCookieName,
120
+ refreshCookieName,
121
+ cookieDomain,
75
122
  sameSite: config.sameSite ?? "lax",
76
- secure: config.secure ?? true,
77
- cookiePath: config.cookiePath ?? "/",
123
+ secure,
124
+ cookiePath,
78
125
  tokenPath: config.tokenPath ?? "/oidc/token",
79
126
  refreshPath: config.refreshPath ?? "/api/v1/auth/refresh",
80
127
  logoutPath: config.logoutPath ?? "/api/v1/auth/logout",
@@ -87,9 +134,19 @@ function resolve(config) {
87
134
  debug: config.debug,
88
135
  onTimingEvent: config.onTimingEvent,
89
136
  signoutRegistry: config.signoutRegistry ?? defaultSignoutRegistry,
90
- signoutMarkerTtlMs: config.signoutMarkerTtlMs ?? DEFAULT_SIGNOUT_TTL_MS
137
+ signoutMarkerTtlMs: config.signoutMarkerTtlMs ?? DEFAULT_SIGNOUT_TTL_MS,
138
+ requireOAuthState: config.requireOAuthState ?? true,
139
+ stateCookieName: config.stateCookieName ?? "iqauth_state"
91
140
  };
92
141
  }
142
+ function timingSafeEqualStr(a, b) {
143
+ const len = Math.max(a.length, b.length);
144
+ let diff = a.length ^ b.length;
145
+ for (let i = 0; i < len; i++) {
146
+ diff |= (a.charCodeAt(i) || 0) ^ (b.charCodeAt(i) || 0);
147
+ }
148
+ return diff === 0;
149
+ }
93
150
  function makeCookie(cfg, name, value, maxAge, httpOnly = true) {
94
151
  return {
95
152
  name,
@@ -108,6 +165,9 @@ function clearCookies(cfg) {
108
165
  { ...makeCookie(cfg, cfg.refreshCookieName, "", 0), clear: true }
109
166
  ];
110
167
  }
168
+ function clearStateCookie(cfg) {
169
+ return { ...makeCookie(cfg, cfg.stateCookieName, "", 0, false), clear: true };
170
+ }
111
171
  var DEFAULT_SIGNOUT_TTL_MS = 6e4;
112
172
  var inMemorySignoutMarkers = /* @__PURE__ */ new Map();
113
173
  function pruneInMemoryMarkers(now) {
@@ -133,9 +193,21 @@ var defaultSignoutRegistry = {
133
193
  return true;
134
194
  }
135
195
  };
196
+ var warnedDefaultSignoutRegistry = false;
197
+ function maybeWarnDefaultSignoutRegistry(config) {
198
+ if (warnedDefaultSignoutRegistry) return;
199
+ if (config.signoutRegistry) return;
200
+ warnedDefaultSignoutRegistry = true;
201
+ console.warn(
202
+ "[IQAuth] Using the in-memory signout registry (process-local). Signout idempotency is NOT shared across instances \u2014 in a multi-replica deployment a /refresh racing a /signout on another replica can reissue cookies after sign-out. Plug a shared backend (e.g. Redis) into IQAuthHelperConfig.signoutRegistry to fix this and silence this warning."
203
+ );
204
+ }
136
205
  function __resetSignoutMarkersForTests() {
137
206
  inMemorySignoutMarkers.clear();
138
207
  }
208
+ function __resetSignoutRegistryWarningForTests() {
209
+ warnedDefaultSignoutRegistry = false;
210
+ }
139
211
  function createInMemorySignoutRegistry() {
140
212
  const store = /* @__PURE__ */ new Map();
141
213
  return {
@@ -178,6 +250,23 @@ async function handleCallback(config, input) {
178
250
  cookies: []
179
251
  };
180
252
  }
253
+ const provided = input.state;
254
+ const expected = input.expectedState;
255
+ const stateOk = cfg.requireOAuthState ? !!expected && !!provided && timingSafeEqualStr(provided, expected) : !expected || !!provided && timingSafeEqualStr(provided, expected);
256
+ if (!stateOk) {
257
+ emitTiming(cfg, { phase: "callback", durationMs: Date.now() - t0, ok: false, code: "STATE_MISMATCH" });
258
+ return {
259
+ status: 400,
260
+ body: {
261
+ success: false,
262
+ error: {
263
+ code: "STATE_MISMATCH",
264
+ message: "OAuth state validation failed; the sign-in could not be verified as originating from this browser."
265
+ }
266
+ },
267
+ cookies: [clearStateCookie(cfg)]
268
+ };
269
+ }
181
270
  if (!cfg.secretKey) {
182
271
  emitTiming(cfg, { phase: "callback", durationMs: Date.now() - t0, ok: false, code: "INTERNAL_ERROR" });
183
272
  return {
@@ -216,6 +305,26 @@ async function handleCallback(config, input) {
216
305
  cookies: []
217
306
  };
218
307
  }
308
+ try {
309
+ await getTokensFor(cfg.issuer).verify(json.access_token, {
310
+ issuer: cfg.issuer,
311
+ ...config.verify
312
+ });
313
+ } catch (err) {
314
+ const code = err instanceof IQAuthError ? err.code : err.code || "TOKEN_INVALID";
315
+ emitTiming(cfg, { phase: "callback", durationMs: Date.now() - t0, ok: false, code });
316
+ return {
317
+ status: 502,
318
+ body: {
319
+ success: false,
320
+ error: {
321
+ code: "ACCESS_TOKEN_VERIFICATION_FAILED",
322
+ message: "The issuer returned an access token that failed verification; no session was established."
323
+ }
324
+ },
325
+ cookies: []
326
+ };
327
+ }
219
328
  const cookies = [];
220
329
  cookies.push(
221
330
  makeCookie(cfg, cfg.accessCookieName, json.access_token, json.expires_in ?? ACCESS_TOKEN_TTL_SECONDS)
@@ -223,6 +332,7 @@ async function handleCallback(config, input) {
223
332
  if (json.refresh_token) {
224
333
  cookies.push(makeCookie(cfg, cfg.refreshCookieName, json.refresh_token, REFRESH_TOKEN_TTL_SECONDS));
225
334
  }
335
+ cookies.push(clearStateCookie(cfg));
226
336
  emitTiming(cfg, { phase: "callback", durationMs: Date.now() - t0, ok: true });
227
337
  return {
228
338
  status: 200,
@@ -344,7 +454,10 @@ async function handleUserinfo(config, input) {
344
454
  }
345
455
  let claims;
346
456
  try {
347
- claims = await getTokensFor(cfg.issuer).verify(input.accessToken, config.verify);
457
+ claims = await getTokensFor(cfg.issuer).verify(input.accessToken, {
458
+ issuer: cfg.issuer,
459
+ ...config.verify
460
+ });
348
461
  } catch (err) {
349
462
  const code = err instanceof IQAuthError ? err.code : err.code || "TOKEN_INVALID";
350
463
  const message = err instanceof Error ? err.message : "Access token verification failed";
@@ -367,6 +480,7 @@ async function handleUserinfo(config, input) {
367
480
  export {
368
481
  buildUserinfoResponse,
369
482
  __resetSignoutMarkersForTests,
483
+ __resetSignoutRegistryWarningForTests,
370
484
  createInMemorySignoutRegistry,
371
485
  serializeCookie,
372
486
  handleCallback,
@@ -36,17 +36,27 @@ function parseLoginResponse(data, browserSessionMode) {
36
36
  tenants: data.tenants
37
37
  };
38
38
  }
39
+ if (data.type === "scope_selection" && data.scopeSelectionToken && data.scopes && data.tenantId) {
40
+ return {
41
+ status: "scope_selection",
42
+ scopeSelectionToken: data.scopeSelectionToken,
43
+ tenantId: data.tenantId,
44
+ scopes: data.scopes
45
+ };
46
+ }
39
47
  throw new Error("Unexpected login response shape");
40
48
  }
41
49
  var AuthModule = class {
42
50
  constructor(http) {
43
51
  this.http = http;
44
52
  }
45
- async login(email, password) {
53
+ async login(email, password, opts) {
54
+ const body = { email, password };
55
+ if (opts?.scopeHint) body.scopeHint = opts.scopeHint;
46
56
  const data = await this.http.request(
47
57
  "POST",
48
58
  "/api/v1/auth/login",
49
- { email, password },
59
+ body,
50
60
  { skipAutoRefresh: true }
51
61
  );
52
62
  return parseLoginResponse(data, this.http.isBrowserSession());
@@ -84,13 +94,29 @@ var AuthModule = class {
84
94
  method
85
95
  }, { skipAutoRefresh: true });
86
96
  }
87
- async selectTenant(tenantSelectionToken, tenantId) {
97
+ async selectTenant(tenantSelectionToken, tenantId, opts) {
98
+ const body = { tenantSelectionToken, tenantId };
99
+ if (opts?.scopeHint) body.scopeHint = opts.scopeHint;
88
100
  const data = await this.http.request(
89
101
  "POST",
90
102
  "/api/v1/auth/select-tenant",
103
+ body,
104
+ { skipAutoRefresh: true }
105
+ );
106
+ return parseLoginResponse(data, this.http.isBrowserSession());
107
+ }
108
+ /**
109
+ * Task #171 — redeem a scope-selection token + chosen membership for a
110
+ * real authenticated session. `membershipId` must be one of the scopes
111
+ * returned in the prior `scope_selection` envelope.
112
+ */
113
+ async selectScope(scopeSelectionToken, membershipId) {
114
+ const data = await this.http.request(
115
+ "POST",
116
+ "/api/v1/auth/select-scope",
91
117
  {
92
- tenantSelectionToken,
93
- tenantId
118
+ scopeSelectionToken,
119
+ membershipId
94
120
  },
95
121
  { skipAutoRefresh: true }
96
122
  );
@@ -1,5 +1,5 @@
1
- import { d as IQAuthEnvironment, T as TokenPair, Y as IQAuthRetryConfig, L as LoginResult, b1 as SignupRequest, K as MfaVerifyResult, S as SessionUser, m as Session, U as UserProfile, V as ProvisionUserRequest, W as ProvisionUserResponse, R as UserPermissions, J as JwtClaims, O as OidcDiscovery, y as JwksResponse, z as OidcTokenResponse, b2 as HostedClientContext, n as TenantInfo, C as CreateTenantRequest, o as UpdateTenantRequest, P as PromoteToVendorRequest, p as PromoteToVendorResult, a9 as TenantUser, q as InviteTenantUserRequest, r as InviteTenantUserResult, s as TenantUserRoleUpdate, M as MigrateUserRequest, N as PasswordPolicy, Q as MfaPolicy, B as BrandingConfig, a0 as AppInfo, a1 as PermissionNodeInfo, $ as AppManifest, a2 as AppSyncResult, a3 as Role, a4 as CreateRoleRequest, a5 as UpdateRoleRequest, a6 as AssignRoleRequest, a7 as UserRoleAssignment, aa as PermissionGroup, ab as GroupPermission, ac as AddGroupPermissionRequest, ad as InheritanceRelation, a8 as UserGroupAssignment, ae as UserPermissionOverride, af as AddUserOverrideRequest, ag as EffectivePermission, ah as PermissionCheckResult, aj as CreateApiKeyRequest, ak as CreateApiKeyResult, ai as ApiKeyInfo, al as ApiKeyIntrospection, an as CreateInviteRequest, am as Invitation, ao as InviteValidation, ap as AcceptInviteRequest, ar as CreateWebhookRequest, as as CreateWebhookResult, aq as WebhookEndpoint, at as WebhookDelivery, au as WebhookTestResult, av as Entitlement, aw as GrantEntitlementRequest, ax as Vendor, ay as CreateVendorRequest, az as UpdateVendorRequest, aB as CreateSourceRequest, aA as Source, aC as UpdateSourceRequest, aE as CreateClientRequest, aD as Client, aF as UpdateClientRequest, aG as HierarchyVendor, aJ as HierarchyLink, aN as MembershipWithDetails, aL as CreateMembershipRequest, aK as Membership, aM as UpdateMembershipRequest, aO as AvailableScopesTree, aS as ScopeSwitchResult, aT as GdprExportData, aU as PinStatus, aW as MfaAvailableMethods, aX as TotpEnrollResult, aY as TotpVerifyResult, aZ as SmsEnrollResult, G as MfaEnrollment, a_ as EmailEnrollResult, a$ as BackupCodesResult, b0 as BackupCodeCountResult, t as UpdateBrandingRequest, v as UploadAssetRequest, u as BrandingAsset, w as BrandingDomainMapping, e as IQAuthClientConfig, I as IQAuthBrowserSessionClientConfig, f as IQAuthTokenClientConfig } from './types-XOV9XPVi.mjs';
2
- import { T as TokensModule } from './tokens-CITeoG6P.mjs';
1
+ import { d as IQAuthEnvironment, T as TokenPair, Y as IQAuthRetryConfig, b1 as ScopeHint, L as LoginResult, b2 as SignupRequest, K as MfaVerifyResult, S as SessionUser, m as Session, U as UserProfile, V as ProvisionUserRequest, W as ProvisionUserResponse, R as UserPermissions, J as JwtClaims, O as OidcDiscovery, y as JwksResponse, z as OidcTokenResponse, b3 as HostedClientContext, n as TenantInfo, C as CreateTenantRequest, o as UpdateTenantRequest, P as PromoteToVendorRequest, p as PromoteToVendorResult, a9 as TenantUser, q as InviteTenantUserRequest, r as InviteTenantUserResult, s as TenantUserRoleUpdate, M as MigrateUserRequest, N as PasswordPolicy, Q as MfaPolicy, B as BrandingConfig, a0 as AppInfo, a1 as PermissionNodeInfo, $ as AppManifest, a2 as AppSyncResult, a3 as Role, a4 as CreateRoleRequest, a5 as UpdateRoleRequest, a6 as AssignRoleRequest, a7 as UserRoleAssignment, aa as PermissionGroup, ab as GroupPermission, ac as AddGroupPermissionRequest, ad as InheritanceRelation, a8 as UserGroupAssignment, ae as UserPermissionOverride, af as AddUserOverrideRequest, ag as EffectivePermission, ah as PermissionCheckResult, aj as CreateApiKeyRequest, ak as CreateApiKeyResult, ai as ApiKeyInfo, al as ApiKeyIntrospection, an as CreateInviteRequest, am as Invitation, ao as InviteValidation, ap as AcceptInviteRequest, ar as CreateWebhookRequest, as as CreateWebhookResult, aq as WebhookEndpoint, at as WebhookDelivery, au as WebhookTestResult, av as Entitlement, aw as GrantEntitlementRequest, ax as Vendor, ay as CreateVendorRequest, az as UpdateVendorRequest, aB as CreateSourceRequest, aA as Source, aC as UpdateSourceRequest, aE as CreateClientRequest, aD as Client, aF as UpdateClientRequest, aG as HierarchyVendor, aJ as HierarchyLink, aN as MembershipWithDetails, aL as CreateMembershipRequest, aK as Membership, aM as UpdateMembershipRequest, aO as AvailableScopesTree, aS as ScopeSwitchResult, aT as GdprExportData, aU as PinStatus, aW as MfaAvailableMethods, aX as TotpEnrollResult, aY as TotpVerifyResult, aZ as SmsEnrollResult, G as MfaEnrollment, a_ as EmailEnrollResult, a$ as BackupCodesResult, b0 as BackupCodeCountResult, t as UpdateBrandingRequest, v as UploadAssetRequest, u as BrandingAsset, w as BrandingDomainMapping, e as IQAuthClientConfig, I as IQAuthBrowserSessionClientConfig, f as IQAuthTokenClientConfig } from './types-Bn8O-OEd.mjs';
2
+ import { T as TokensModule } from './tokens-B06VtvUi.mjs';
3
3
 
4
4
  /**
5
5
  * SOURCE REFS:
@@ -56,7 +56,9 @@ declare class HttpClient {
56
56
  declare class AuthModule {
57
57
  private http;
58
58
  constructor(http: HttpClient);
59
- login(email: string, password: string): Promise<LoginResult>;
59
+ login(email: string, password: string, opts?: {
60
+ scopeHint?: ScopeHint;
61
+ }): Promise<LoginResult>;
60
62
  signup(input: SignupRequest): Promise<LoginResult>;
61
63
  completeMfa(mfaChallengeToken: string, code: string, method?: string): Promise<MfaVerifyResult>;
62
64
  completeMfaWithBackup(mfaChallengeToken: string, backupCode: string): Promise<MfaVerifyResult>;
@@ -64,7 +66,15 @@ declare class AuthModule {
64
66
  sent: boolean;
65
67
  method: string;
66
68
  }>;
67
- selectTenant(tenantSelectionToken: string, tenantId: string): Promise<LoginResult>;
69
+ selectTenant(tenantSelectionToken: string, tenantId: string, opts?: {
70
+ scopeHint?: ScopeHint;
71
+ }): Promise<LoginResult>;
72
+ /**
73
+ * Task #171 — redeem a scope-selection token + chosen membership for a
74
+ * real authenticated session. `membershipId` must be one of the scopes
75
+ * returned in the prior `scope_selection` envelope.
76
+ */
77
+ selectScope(scopeSelectionToken: string, membershipId: string): Promise<LoginResult>;
68
78
  logout(): Promise<{
69
79
  message: string;
70
80
  }>;
@@ -1,5 +1,5 @@
1
- import { d as IQAuthEnvironment, T as TokenPair, Y as IQAuthRetryConfig, L as LoginResult, b1 as SignupRequest, K as MfaVerifyResult, S as SessionUser, m as Session, U as UserProfile, V as ProvisionUserRequest, W as ProvisionUserResponse, R as UserPermissions, J as JwtClaims, O as OidcDiscovery, y as JwksResponse, z as OidcTokenResponse, b2 as HostedClientContext, n as TenantInfo, C as CreateTenantRequest, o as UpdateTenantRequest, P as PromoteToVendorRequest, p as PromoteToVendorResult, a9 as TenantUser, q as InviteTenantUserRequest, r as InviteTenantUserResult, s as TenantUserRoleUpdate, M as MigrateUserRequest, N as PasswordPolicy, Q as MfaPolicy, B as BrandingConfig, a0 as AppInfo, a1 as PermissionNodeInfo, $ as AppManifest, a2 as AppSyncResult, a3 as Role, a4 as CreateRoleRequest, a5 as UpdateRoleRequest, a6 as AssignRoleRequest, a7 as UserRoleAssignment, aa as PermissionGroup, ab as GroupPermission, ac as AddGroupPermissionRequest, ad as InheritanceRelation, a8 as UserGroupAssignment, ae as UserPermissionOverride, af as AddUserOverrideRequest, ag as EffectivePermission, ah as PermissionCheckResult, aj as CreateApiKeyRequest, ak as CreateApiKeyResult, ai as ApiKeyInfo, al as ApiKeyIntrospection, an as CreateInviteRequest, am as Invitation, ao as InviteValidation, ap as AcceptInviteRequest, ar as CreateWebhookRequest, as as CreateWebhookResult, aq as WebhookEndpoint, at as WebhookDelivery, au as WebhookTestResult, av as Entitlement, aw as GrantEntitlementRequest, ax as Vendor, ay as CreateVendorRequest, az as UpdateVendorRequest, aB as CreateSourceRequest, aA as Source, aC as UpdateSourceRequest, aE as CreateClientRequest, aD as Client, aF as UpdateClientRequest, aG as HierarchyVendor, aJ as HierarchyLink, aN as MembershipWithDetails, aL as CreateMembershipRequest, aK as Membership, aM as UpdateMembershipRequest, aO as AvailableScopesTree, aS as ScopeSwitchResult, aT as GdprExportData, aU as PinStatus, aW as MfaAvailableMethods, aX as TotpEnrollResult, aY as TotpVerifyResult, aZ as SmsEnrollResult, G as MfaEnrollment, a_ as EmailEnrollResult, a$ as BackupCodesResult, b0 as BackupCodeCountResult, t as UpdateBrandingRequest, v as UploadAssetRequest, u as BrandingAsset, w as BrandingDomainMapping, e as IQAuthClientConfig, I as IQAuthBrowserSessionClientConfig, f as IQAuthTokenClientConfig } from './types-XOV9XPVi.js';
2
- import { T as TokensModule } from './tokens-Bqhmqq_R.js';
1
+ import { d as IQAuthEnvironment, T as TokenPair, Y as IQAuthRetryConfig, b1 as ScopeHint, L as LoginResult, b2 as SignupRequest, K as MfaVerifyResult, S as SessionUser, m as Session, U as UserProfile, V as ProvisionUserRequest, W as ProvisionUserResponse, R as UserPermissions, J as JwtClaims, O as OidcDiscovery, y as JwksResponse, z as OidcTokenResponse, b3 as HostedClientContext, n as TenantInfo, C as CreateTenantRequest, o as UpdateTenantRequest, P as PromoteToVendorRequest, p as PromoteToVendorResult, a9 as TenantUser, q as InviteTenantUserRequest, r as InviteTenantUserResult, s as TenantUserRoleUpdate, M as MigrateUserRequest, N as PasswordPolicy, Q as MfaPolicy, B as BrandingConfig, a0 as AppInfo, a1 as PermissionNodeInfo, $ as AppManifest, a2 as AppSyncResult, a3 as Role, a4 as CreateRoleRequest, a5 as UpdateRoleRequest, a6 as AssignRoleRequest, a7 as UserRoleAssignment, aa as PermissionGroup, ab as GroupPermission, ac as AddGroupPermissionRequest, ad as InheritanceRelation, a8 as UserGroupAssignment, ae as UserPermissionOverride, af as AddUserOverrideRequest, ag as EffectivePermission, ah as PermissionCheckResult, aj as CreateApiKeyRequest, ak as CreateApiKeyResult, ai as ApiKeyInfo, al as ApiKeyIntrospection, an as CreateInviteRequest, am as Invitation, ao as InviteValidation, ap as AcceptInviteRequest, ar as CreateWebhookRequest, as as CreateWebhookResult, aq as WebhookEndpoint, at as WebhookDelivery, au as WebhookTestResult, av as Entitlement, aw as GrantEntitlementRequest, ax as Vendor, ay as CreateVendorRequest, az as UpdateVendorRequest, aB as CreateSourceRequest, aA as Source, aC as UpdateSourceRequest, aE as CreateClientRequest, aD as Client, aF as UpdateClientRequest, aG as HierarchyVendor, aJ as HierarchyLink, aN as MembershipWithDetails, aL as CreateMembershipRequest, aK as Membership, aM as UpdateMembershipRequest, aO as AvailableScopesTree, aS as ScopeSwitchResult, aT as GdprExportData, aU as PinStatus, aW as MfaAvailableMethods, aX as TotpEnrollResult, aY as TotpVerifyResult, aZ as SmsEnrollResult, G as MfaEnrollment, a_ as EmailEnrollResult, a$ as BackupCodesResult, b0 as BackupCodeCountResult, t as UpdateBrandingRequest, v as UploadAssetRequest, u as BrandingAsset, w as BrandingDomainMapping, e as IQAuthClientConfig, I as IQAuthBrowserSessionClientConfig, f as IQAuthTokenClientConfig } from './types-Bn8O-OEd.js';
2
+ import { T as TokensModule } from './tokens-9F6ETrzk.js';
3
3
 
4
4
  /**
5
5
  * SOURCE REFS:
@@ -56,7 +56,9 @@ declare class HttpClient {
56
56
  declare class AuthModule {
57
57
  private http;
58
58
  constructor(http: HttpClient);
59
- login(email: string, password: string): Promise<LoginResult>;
59
+ login(email: string, password: string, opts?: {
60
+ scopeHint?: ScopeHint;
61
+ }): Promise<LoginResult>;
60
62
  signup(input: SignupRequest): Promise<LoginResult>;
61
63
  completeMfa(mfaChallengeToken: string, code: string, method?: string): Promise<MfaVerifyResult>;
62
64
  completeMfaWithBackup(mfaChallengeToken: string, backupCode: string): Promise<MfaVerifyResult>;
@@ -64,7 +66,15 @@ declare class AuthModule {
64
66
  sent: boolean;
65
67
  method: string;
66
68
  }>;
67
- selectTenant(tenantSelectionToken: string, tenantId: string): Promise<LoginResult>;
69
+ selectTenant(tenantSelectionToken: string, tenantId: string, opts?: {
70
+ scopeHint?: ScopeHint;
71
+ }): Promise<LoginResult>;
72
+ /**
73
+ * Task #171 — redeem a scope-selection token + chosen membership for a
74
+ * real authenticated session. `membershipId` must be one of the scopes
75
+ * returned in the prior `scope_selection` envelope.
76
+ */
77
+ selectScope(scopeSelectionToken: string, membershipId: string): Promise<LoginResult>;
68
78
  logout(): Promise<{
69
79
  message: string;
70
80
  }>;
@@ -1,5 +1,5 @@
1
- import { I as IQAuthClient } from './client-CDQ21LvW.js';
2
- import { J as JwtClaims, X as ExpressMiddlewareOptions, a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-XOV9XPVi.js';
1
+ import { I as IQAuthClient } from './client-DkPL0EPZ.js';
2
+ import { J as JwtClaims, X as ExpressMiddlewareOptions, a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-Bn8O-OEd.js';
3
3
 
4
4
  /**
5
5
  * SOURCE REFS:
@@ -1,5 +1,5 @@
1
- import { I as IQAuthClient } from './client-BGFnBpfc.mjs';
2
- import { J as JwtClaims, X as ExpressMiddlewareOptions, a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-XOV9XPVi.mjs';
1
+ import { I as IQAuthClient } from './client-D8L-PaWr.mjs';
2
+ import { J as JwtClaims, X as ExpressMiddlewareOptions, a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-Bn8O-OEd.mjs';
3
3
 
4
4
  /**
5
5
  * SOURCE REFS:
@@ -1,10 +1,10 @@
1
- import { I as IQAuthClient } from './client-BGFnBpfc.mjs';
2
- import { C as CookieAwareMiddlewareOptions } from './express-CVNQEkOr.mjs';
3
- export { i as iqAuthMiddleware } from './express-CVNQEkOr.mjs';
1
+ import { I as IQAuthClient } from './client-D8L-PaWr.mjs';
2
+ import { C as CookieAwareMiddlewareOptions } from './express-DDTA3qV1.mjs';
3
+ export { i as iqAuthMiddleware } from './express-DDTA3qV1.mjs';
4
4
  import { IQAuthHelperConfig } from './server/handlers.mjs';
5
- import { a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-XOV9XPVi.mjs';
5
+ import { a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-Bn8O-OEd.mjs';
6
6
  export { E as ErrorCodes, I as IQAuthError } from './errors-Jl1Jtm-6.mjs';
7
- import './tokens-CITeoG6P.mjs';
7
+ import './tokens-B06VtvUi.mjs';
8
8
 
9
9
  /**
10
10
  * @iqauth/sdk/express — drop-in Express adapter.
package/dist/express.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { I as IQAuthClient } from './client-CDQ21LvW.js';
2
- import { C as CookieAwareMiddlewareOptions } from './express-Piv2WhWM.js';
3
- export { i as iqAuthMiddleware } from './express-Piv2WhWM.js';
1
+ import { I as IQAuthClient } from './client-DkPL0EPZ.js';
2
+ import { C as CookieAwareMiddlewareOptions } from './express-Budysq4h.js';
3
+ export { i as iqAuthMiddleware } from './express-Budysq4h.js';
4
4
  import { IQAuthHelperConfig } from './server/handlers.js';
5
- import { a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-XOV9XPVi.js';
5
+ import { a as IQAuthRequestLike, b as IQAuthResponseLike, c as IQAuthNextFunction } from './types-Bn8O-OEd.js';
6
6
  export { E as ErrorCodes, I as IQAuthError } from './errors-Jl1Jtm-6.js';
7
- import './tokens-Bqhmqq_R.js';
7
+ import './tokens-9F6ETrzk.js';
8
8
 
9
9
  /**
10
10
  * @iqauth/sdk/express — drop-in Express adapter.