@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.
Files changed (110) hide show
  1. package/README.md +173 -1
  2. package/dist/browser-session.d.mts +4 -4
  3. package/dist/browser-session.d.ts +4 -4
  4. package/dist/browser-session.js +181 -41
  5. package/dist/browser-session.mjs +3 -3
  6. package/dist/browser.d.mts +5 -5
  7. package/dist/browser.d.ts +5 -5
  8. package/dist/browser.js +271 -32
  9. package/dist/browser.mjs +5 -5
  10. package/dist/{chunk-6I6RM4MN.mjs → chunk-6PJRLRB4.mjs} +33 -3
  11. package/dist/{chunk-LIZYFXH7.mjs → chunk-DFWHSDYQ.mjs} +1 -1
  12. package/dist/chunk-GLXSIGVS.mjs +66 -0
  13. package/dist/{chunk-DJIBN2N7.mjs → chunk-GN37E64I.mjs} +29 -7
  14. package/dist/{chunk-WQWBJSSS.mjs → chunk-HVHNYPDC.mjs} +6 -6
  15. package/dist/{chunk-W3F4JYGP.mjs → chunk-JXQI62A7.mjs} +108 -18
  16. package/dist/{chunk-UNYDG2L4.mjs → chunk-NUO2I65G.mjs} +56 -23
  17. package/dist/chunk-PMAFENVI.mjs +229 -0
  18. package/dist/chunk-RR2MGPTK.mjs +2724 -0
  19. package/dist/{chunk-XAWYUPMO.mjs → chunk-RTJAIBXY.mjs} +220 -20
  20. package/dist/{chunk-6TDJJER7.mjs → chunk-RUJXRTEW.mjs} +164 -5
  21. package/dist/{chunk-3JULWS6F.mjs → chunk-WCELYTJ3.mjs} +3 -3
  22. package/dist/{chunk-MKKZULZR.mjs → chunk-WIFG74IK.mjs} +1 -1
  23. package/dist/{chunk-BVV54LPI.mjs → chunk-YVALAG3B.mjs} +10 -4
  24. package/dist/cli/index.js +2 -2
  25. package/dist/cli/index.mjs +2 -2
  26. package/dist/{client-kYlJFgPv.d.mts → client-BGFnBpfc.d.mts} +47 -4
  27. package/dist/{client-BNQe3AgF.d.ts → client-CDQ21LvW.d.ts} +47 -4
  28. package/dist/{doctor-YYNHNMLD.mjs → doctor-JAFXWU3X.mjs} +2 -2
  29. package/dist/errors-Jl1Jtm-6.d.mts +107 -0
  30. package/dist/errors-Jl1Jtm-6.d.ts +107 -0
  31. package/dist/{express-B6_1vBYZ.d.mts → express-CVNQEkOr.d.mts} +2 -2
  32. package/dist/{express-CHpfa7D_.d.ts → express-Piv2WhWM.d.ts} +2 -2
  33. package/dist/express.d.mts +7 -6
  34. package/dist/express.d.ts +7 -6
  35. package/dist/express.js +349 -52
  36. package/dist/express.mjs +39 -12
  37. package/dist/fastify.d.mts +2 -0
  38. package/dist/fastify.d.ts +2 -0
  39. package/dist/fastify.js +332 -52
  40. package/dist/fastify.mjs +23 -8
  41. package/dist/hono.d.mts +2 -0
  42. package/dist/hono.d.ts +2 -0
  43. package/dist/hono.js +329 -52
  44. package/dist/hono.mjs +20 -8
  45. package/dist/index-5KSZEnDe.d.ts +1626 -0
  46. package/dist/index-CKoZHAoc.d.mts +1626 -0
  47. package/dist/index.d.mts +56 -8
  48. package/dist/index.d.ts +56 -8
  49. package/dist/index.js +565 -69
  50. package/dist/index.mjs +29 -9
  51. package/dist/{keys-NLWFAOEM.mjs → keys-6Y776TG2.mjs} +2 -2
  52. package/dist/locales.d.mts +1 -1
  53. package/dist/locales.d.ts +1 -1
  54. package/dist/mobile.d.mts +77 -7
  55. package/dist/mobile.d.ts +77 -7
  56. package/dist/mobile.js +276 -41
  57. package/dist/mobile.mjs +98 -3
  58. package/dist/next.d.mts +2 -1
  59. package/dist/next.d.ts +2 -1
  60. package/dist/next.js +391 -201
  61. package/dist/next.mjs +22 -7
  62. package/dist/{provisioningBridge-DnTfzdZK.d.ts → provisioningBridge-CGpMRie4.d.ts} +1 -1
  63. package/dist/{provisioningBridge-88xjOS2n.d.mts → provisioningBridge-M5G47LWO.d.mts} +1 -1
  64. package/dist/{publishableKey-BaR0HoAH.d.ts → publishableKey-f2kq-rKw.d.mts} +1 -1
  65. package/dist/{publishableKey-BaR0HoAH.d.mts → publishableKey-f2kq-rKw.d.ts} +1 -1
  66. package/dist/react-permissions.d.mts +52 -0
  67. package/dist/react-permissions.d.ts +52 -0
  68. package/dist/react-permissions.js +239 -0
  69. package/dist/react-permissions.mjs +97 -0
  70. package/dist/react.d.mts +9 -1624
  71. package/dist/react.d.ts +9 -1624
  72. package/dist/react.js +313 -33
  73. package/dist/react.mjs +58 -2632
  74. package/dist/{reverify-4UEJXUS6.mjs → reverify-C64QXKJO.mjs} +2 -2
  75. package/dist/server/handlers.d.mts +148 -3
  76. package/dist/server/handlers.d.ts +148 -3
  77. package/dist/server/handlers.js +410 -11
  78. package/dist/server/handlers.mjs +12 -3
  79. package/dist/server.d.mts +151 -8
  80. package/dist/server.d.ts +151 -8
  81. package/dist/server.js +406 -50
  82. package/dist/server.mjs +93 -11
  83. package/dist/service.d.mts +4 -4
  84. package/dist/service.d.ts +4 -4
  85. package/dist/service.js +181 -41
  86. package/dist/service.mjs +3 -3
  87. package/dist/{signIn-OCr88Zf8.d.ts → signIn-BLFnz8SV.d.ts} +78 -3
  88. package/dist/{signIn-4OKLDEIH.mjs → signIn-SHBW6Z4T.mjs} +1 -1
  89. package/dist/{signIn-CiIBTJIh.d.mts → signIn-T-CZ6t6r.d.mts} +78 -3
  90. package/dist/test.mjs +3 -3
  91. package/dist/{tokens-DCyzzn8L.d.mts → tokens-Bqhmqq_R.d.ts} +9 -2
  92. package/dist/{tokens-aHiGFr_E.d.ts → tokens-CITeoG6P.d.mts} +9 -2
  93. package/dist/{types-6bNdxesb.d.ts → types-BdQ2lqfT.d.mts} +1 -1
  94. package/dist/{types-6bNdxesb.d.mts → types-BdQ2lqfT.d.ts} +1 -1
  95. package/dist/{types-DZAflmmq.d.mts → types-XOV9XPVi.d.mts} +99 -10
  96. package/dist/{types-DZAflmmq.d.ts → types-XOV9XPVi.d.ts} +99 -10
  97. package/dist/webhooks.d.mts +100 -17
  98. package/dist/webhooks.d.ts +100 -17
  99. package/dist/webhooks.js +164 -15
  100. package/dist/webhooks.mjs +7 -1
  101. package/dist/ws.d.mts +2 -2
  102. package/dist/ws.d.ts +2 -2
  103. package/dist/ws.js +80 -30
  104. package/dist/ws.mjs +4 -4
  105. package/docs/error-handling.md +101 -0
  106. package/docs/guides/effective-permissions.md +171 -0
  107. package/package.json +13 -3
  108. package/dist/chunk-UKZLOHZG.mjs +0 -83
  109. package/dist/errors-CDdl24MP.d.mts +0 -52
  110. package/dist/errors-CDdl24MP.d.ts +0 -52
package/dist/express.mjs CHANGED
@@ -1,27 +1,29 @@
1
- import {
2
- handleCallback,
3
- handleRefresh,
4
- handleSignout
5
- } from "./chunk-6TDJJER7.mjs";
6
1
  import {
7
2
  DEFAULT_REFRESH_COOKIE,
8
3
  iqAuthMiddleware
9
- } from "./chunk-BVV54LPI.mjs";
4
+ } from "./chunk-YVALAG3B.mjs";
5
+ import {
6
+ handleCallback,
7
+ handleRefresh,
8
+ handleSignout,
9
+ handleUserinfo
10
+ } from "./chunk-RUJXRTEW.mjs";
10
11
  import {
11
12
  assertPublishableKey
12
- } from "./chunk-WQWBJSSS.mjs";
13
+ } from "./chunk-HVHNYPDC.mjs";
13
14
  import {
14
15
  IQAuthClient
15
- } from "./chunk-W3F4JYGP.mjs";
16
- import "./chunk-UNYDG2L4.mjs";
16
+ } from "./chunk-JXQI62A7.mjs";
17
+ import "./chunk-NUO2I65G.mjs";
17
18
  import {
18
19
  ErrorCodes,
19
20
  IQAuthError
20
- } from "./chunk-6I6RM4MN.mjs";
21
+ } from "./chunk-6PJRLRB4.mjs";
21
22
  import "./chunk-Y6FXYEAI.mjs";
22
23
 
23
24
  // src/express.ts
24
25
  var PKCE_COOKIE = "iqauth_pkce";
26
+ var IDEMPOTENCY_HEADER = "x-iqauth-idempotency";
25
27
  function escapeHtml(s) {
26
28
  return s.replace(/[&<>"']/g, (c) => {
27
29
  switch (c) {
@@ -95,6 +97,17 @@ function defaultBrandedSpinner(args) {
95
97
  }
96
98
  function applyHandlerResponse(res, hr) {
97
99
  for (const c of hr.cookies) {
100
+ if (c.clear && typeof res.clearCookie === "function") {
101
+ const opts = {
102
+ httpOnly: c.httpOnly,
103
+ secure: c.secure,
104
+ sameSite: c.sameSite,
105
+ path: c.path
106
+ };
107
+ if (c.domain) opts.domain = c.domain;
108
+ res.clearCookie(c.name, opts);
109
+ continue;
110
+ }
98
111
  if (typeof res.cookie === "function") {
99
112
  const opts = {
100
113
  httpOnly: c.httpOnly,
@@ -104,11 +117,13 @@ function applyHandlerResponse(res, hr) {
104
117
  maxAge: c.maxAge * 1e3
105
118
  };
106
119
  if (c.domain) opts.domain = c.domain;
120
+ if (c.clear) opts.expires = /* @__PURE__ */ new Date(0);
107
121
  res.cookie(c.name, c.value, opts);
108
122
  } else {
109
123
  const existing = res.getHeader?.("Set-Cookie") || [];
110
124
  const list = Array.isArray(existing) ? existing : [existing];
111
125
  const parts = [`${c.name}=${encodeURIComponent(c.value)}`, `Path=${c.path}`, `Max-Age=${c.maxAge}`, `SameSite=${c.sameSite}`];
126
+ if (c.clear) parts.push("Expires=Thu, 01 Jan 1970 00:00:00 GMT");
112
127
  if (c.secure) parts.push("Secure");
113
128
  if (c.httpOnly) parts.push("HttpOnly");
114
129
  if (c.domain) parts.push(`Domain=${c.domain}`);
@@ -159,6 +174,7 @@ function iqAuth(options) {
159
174
  const inline = options.inlineCallback === true ? {} : options.inlineCallback && typeof options.inlineCallback === "object" ? options.inlineCallback : null;
160
175
  const inlineBranded = inline?.branded === true ? {} : inline?.branded && typeof inline.branded === "object" ? inline.branded : null;
161
176
  const attachHelpers = (app) => {
177
+ void client.prewarm();
162
178
  app.post(`${mount}/callback`, async (req, res) => {
163
179
  const body = readBody(req);
164
180
  const hr = await handleCallback(helperConfig, {
@@ -296,13 +312,23 @@ function iqAuth(options) {
296
312
  app.post(`${mount}/refresh`, async (req, res) => {
297
313
  const body = readBody(req);
298
314
  const refreshToken = body.refreshToken || readCookieFromReq(req, refreshCookie);
299
- const hr = await handleRefresh(helperConfig, { refreshToken });
315
+ const idempotencyToken = req.headers?.[IDEMPOTENCY_HEADER] || body.idempotencyToken;
316
+ const hr = await handleRefresh(helperConfig, { refreshToken, idempotencyToken });
300
317
  applyHandlerResponse(res, hr);
301
318
  });
319
+ if (options.mountUserinfo && typeof app.get === "function") {
320
+ app.get(`${mount}/me`, async (req, res) => {
321
+ const accessToken = req.headers?.authorization?.replace(/^Bearer /i, "") || readCookieFromReq(req, accessCookie);
322
+ const hr = await handleUserinfo(helperConfig, { accessToken, req });
323
+ applyHandlerResponse(res, hr);
324
+ });
325
+ }
302
326
  app.post(`${mount}/signout`, async (req, res) => {
303
327
  const accessToken = req.headers?.authorization?.replace(/^Bearer /i, "") || readCookieFromReq(req, accessCookie);
328
+ const refreshToken = readCookieFromReq(req, refreshCookie);
304
329
  const ssoCookieHeader = req.headers?.cookie;
305
- const hr = await handleSignout(helperConfig, { accessToken, ssoCookieHeader });
330
+ const idempotencyToken = req.headers?.[IDEMPOTENCY_HEADER];
331
+ const hr = await handleSignout(helperConfig, { accessToken, refreshToken, idempotencyToken, ssoCookieHeader });
306
332
  applyHandlerResponse(res, hr);
307
333
  });
308
334
  };
@@ -310,6 +336,7 @@ function iqAuth(options) {
310
336
  composed.middleware = middleware;
311
337
  composed.attachHelpers = attachHelpers;
312
338
  composed.client = client;
339
+ composed.prewarm = () => client.prewarm();
313
340
  return composed;
314
341
  }
315
342
  export {
@@ -1,4 +1,6 @@
1
1
  import { IQAuthHelperConfig } from './server/handlers.mjs';
2
+ import './tokens-CITeoG6P.mjs';
3
+ import './types-XOV9XPVi.mjs';
2
4
 
3
5
  /**
4
6
  * @iqauth/sdk/fastify — Fastify adapter.
package/dist/fastify.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { IQAuthHelperConfig } from './server/handlers.js';
2
+ import './tokens-Bqhmqq_R.js';
3
+ import './types-XOV9XPVi.js';
2
4
 
3
5
  /**
4
6
  * @iqauth/sdk/fastify — Fastify adapter.