@iqauth/sdk 2.2.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.
Files changed (96) hide show
  1. package/README.md +134 -0
  2. package/dist/browser-session.d.mts +3 -3
  3. package/dist/browser-session.d.ts +3 -3
  4. package/dist/browser-session.js +89 -68
  5. package/dist/browser-session.mjs +2 -1
  6. package/dist/browser.d.mts +64 -29
  7. package/dist/browser.d.ts +64 -29
  8. package/dist/browser.js +794 -39
  9. package/dist/browser.mjs +44 -4
  10. package/dist/bundle-LUKDQYVQ.mjs +374 -0
  11. package/dist/chunk-3JULWS6F.mjs +106 -0
  12. package/dist/chunk-5T7GHBX6.mjs +1165 -0
  13. package/dist/{chunk-M4J6BPK7.mjs → chunk-6TDJJER7.mjs} +12 -3
  14. package/dist/{chunk-QZB745C2.mjs → chunk-76W5TLQQ.mjs} +264 -211
  15. package/dist/{chunk-D72UL5HL.mjs → chunk-BVV54LPI.mjs} +36 -4
  16. package/dist/chunk-LIZYFXH7.mjs +90 -0
  17. package/dist/chunk-MKKZULZR.mjs +241 -0
  18. package/dist/chunk-SL3KRS4W.mjs +54 -0
  19. package/dist/chunk-TKZTCPEK.mjs +232 -0
  20. package/dist/chunk-UKZLOHZG.mjs +83 -0
  21. package/dist/chunk-UNYDG2L4.mjs +209 -0
  22. package/dist/{chunk-MDUHPQMM.mjs → chunk-W3F4JYGP.mjs} +8 -180
  23. package/dist/{chunk-QEJB7WEQ.mjs → chunk-WQWBJSSS.mjs} +1 -1
  24. package/dist/cli/index.js +144 -36
  25. package/dist/cli/index.mjs +1 -1
  26. package/dist/{client-DXbHb2ul.d.ts → client-BNQe3AgF.d.ts} +3 -67
  27. package/dist/{client-Dv4v92Mj.d.mts → client-kYlJFgPv.d.mts} +3 -67
  28. package/dist/doctor-YYNHNMLD.mjs +198 -0
  29. package/dist/{express-BZmF1llh.d.mts → express-B6_1vBYZ.d.mts} +23 -2
  30. package/dist/{express-B4o3P8vK.d.ts → express-CHpfa7D_.d.ts} +23 -2
  31. package/dist/express.d.mts +77 -6
  32. package/dist/express.d.ts +77 -6
  33. package/dist/express.js +336 -74
  34. package/dist/express.mjs +209 -8
  35. package/dist/fastify.js +103 -72
  36. package/dist/fastify.mjs +6 -4
  37. package/dist/hono.js +102 -72
  38. package/dist/hono.mjs +5 -4
  39. package/dist/index.d.mts +8 -4
  40. package/dist/index.d.ts +8 -4
  41. package/dist/index.js +590 -73
  42. package/dist/index.mjs +30 -8
  43. package/dist/locales.d.mts +53 -0
  44. package/dist/locales.d.ts +53 -0
  45. package/dist/locales.js +1202 -0
  46. package/dist/locales.mjs +29 -0
  47. package/dist/mobile.d.mts +3 -3
  48. package/dist/mobile.d.ts +3 -3
  49. package/dist/mobile.js +89 -68
  50. package/dist/mobile.mjs +2 -1
  51. package/dist/next.d.mts +10 -1
  52. package/dist/next.d.ts +10 -1
  53. package/dist/next.js +101 -1618
  54. package/dist/next.mjs +9 -9
  55. package/dist/provisioningBridge-88xjOS2n.d.mts +86 -0
  56. package/dist/provisioningBridge-DnTfzdZK.d.ts +86 -0
  57. package/dist/react.d.mts +1349 -10
  58. package/dist/react.d.ts +1349 -10
  59. package/dist/react.js +2998 -569
  60. package/dist/react.mjs +1518 -95
  61. package/dist/reverify-4UEJXUS6.mjs +16 -0
  62. package/dist/server/handlers.d.mts +12 -1
  63. package/dist/server/handlers.d.ts +12 -1
  64. package/dist/server/handlers.js +12 -3
  65. package/dist/server/handlers.mjs +2 -2
  66. package/dist/server.d.mts +5 -4
  67. package/dist/server.d.ts +5 -4
  68. package/dist/server.js +188 -73
  69. package/dist/server.mjs +13 -8
  70. package/dist/service.d.mts +3 -3
  71. package/dist/service.d.ts +3 -3
  72. package/dist/service.js +89 -68
  73. package/dist/service.mjs +2 -1
  74. package/dist/signIn-CCY4JE5G.mjs +15 -0
  75. package/dist/{signIn-D_kP3v-c.d.mts → signIn-CiIBTJIh.d.mts} +232 -4
  76. package/dist/{signIn-BVDTIA_t.d.ts → signIn-OCr88Zf8.d.ts} +232 -4
  77. package/dist/test.d.mts +86 -0
  78. package/dist/test.d.ts +86 -0
  79. package/dist/test.js +289 -0
  80. package/dist/test.mjs +9 -0
  81. package/dist/tokens-DCyzzn8L.d.mts +63 -0
  82. package/dist/tokens-aHiGFr_E.d.ts +63 -0
  83. package/dist/types-6bNdxesb.d.mts +196 -0
  84. package/dist/types-6bNdxesb.d.ts +196 -0
  85. package/dist/{types-Cxl3bQHt.d.ts → types-DZAflmmq.d.mts} +6 -0
  86. package/dist/{types-Cxl3bQHt.d.mts → types-DZAflmmq.d.ts} +6 -0
  87. package/dist/webhooks.d.mts +61 -0
  88. package/dist/webhooks.d.ts +61 -0
  89. package/dist/webhooks.js +119 -0
  90. package/dist/webhooks.mjs +11 -0
  91. package/dist/ws.d.mts +73 -0
  92. package/dist/ws.d.ts +73 -0
  93. package/dist/ws.js +397 -0
  94. package/dist/ws.mjs +12 -0
  95. package/package.json +24 -3
  96. package/dist/doctor-XCI77BQS.mjs +0 -90
@@ -1,5 +1,5 @@
1
- import { I as IQAuthClient } from './client-DXbHb2ul.js';
2
- import { J as JwtClaims, N as ExpressMiddlewareOptions, Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-Cxl3bQHt.js';
1
+ import { I as IQAuthClient } from './client-BNQe3AgF.js';
2
+ import { J as JwtClaims, N as ExpressMiddlewareOptions, Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-DZAflmmq.js';
3
3
 
4
4
  /**
5
5
  * SOURCE REFS:
@@ -34,6 +34,27 @@ interface CookieAwareMiddlewareOptions extends ExpressMiddlewareOptions {
34
34
  * configured access cookie. When false, only the bearer header is checked.
35
35
  */
36
36
  cookieAware?: boolean;
37
+ /**
38
+ * F14 — Umbrella shorthand for `accessCookieName` / `refreshCookieName`.
39
+ * When both forms are supplied the individual fields win for back-compat.
40
+ */
41
+ cookieNames?: {
42
+ access?: string;
43
+ refresh?: string;
44
+ };
45
+ /**
46
+ * F33 — Declarative protect/public route configuration. When `protect` is
47
+ * given, only requests whose path matches one of the patterns are
48
+ * verified; everything else is allowed through (`req.auth` left unset).
49
+ * When `publicRoutes` is given, those paths are always allowed through
50
+ * even if `protect` would have matched. Each entry is either a glob-like
51
+ * string (`*` = single segment, `**` = any path remainder) or a `RegExp`.
52
+ *
53
+ * If neither is given, the middleware behaves as before — every request
54
+ * goes through the verifier.
55
+ */
56
+ protect?: Array<string | RegExp>;
57
+ publicRoutes?: Array<string | RegExp>;
37
58
  }
38
59
  /**
39
60
  * Express middleware that verifies access tokens via the SDK's token verifier.
@@ -1,10 +1,10 @@
1
- import { I as IQAuthClient } from './client-Dv4v92Mj.mjs';
2
- import { C as CookieAwareMiddlewareOptions } from './express-BZmF1llh.mjs';
3
- export { i as iqAuthMiddleware } from './express-BZmF1llh.mjs';
1
+ import { I as IQAuthClient } from './client-kYlJFgPv.mjs';
2
+ import { C as CookieAwareMiddlewareOptions } from './express-B6_1vBYZ.mjs';
3
+ export { i as iqAuthMiddleware } from './express-B6_1vBYZ.mjs';
4
4
  import { IQAuthHelperConfig } from './server/handlers.mjs';
5
- import { Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-Cxl3bQHt.mjs';
5
+ import { Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-DZAflmmq.mjs';
6
6
  export { E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.mjs';
7
- import 'jsonwebtoken';
7
+ import './tokens-DCyzzn8L.mjs';
8
8
 
9
9
  /**
10
10
  * @iqauth/sdk/express — drop-in Express adapter.
@@ -22,18 +22,89 @@ import 'jsonwebtoken';
22
22
  * app.use(iqAuth({ publishableKey: process.env.IQAUTH_PUBLISHABLE_KEY!, secretKey: process.env.IQAUTH_SECRET_KEY! }));
23
23
  */
24
24
 
25
+ interface InlineCallbackBrandedRenderArgs {
26
+ /** Issuer URL the SDK will use to mint the authorization code (publishable key origin). */
27
+ issuer: string;
28
+ /** Path of the JSON exchange endpoint to POST to (e.g. `/api/iqauth/callback/exchange`). */
29
+ exchangePath: string;
30
+ /** The raw `?code=` value from the OAuth redirect (already escaped for HTML). */
31
+ code: string;
32
+ /** The raw `?state=` value from the OAuth redirect (already escaped for HTML). */
33
+ state: string;
34
+ /** If `errorPath` is configured on the inline-callback options, it's threaded
35
+ * here so a custom render function can reuse it for its own catch handler.
36
+ * `""` when unset. */
37
+ errorPath?: string;
38
+ }
39
+ interface InlineCallbackBrandedConfig {
40
+ /**
41
+ * Optional override for the spinner page HTML. Receives the issuer URL, the
42
+ * exchange endpoint path, and the (HTML-escaped) `code` + `state` from the
43
+ * OAuth redirect. Returns a full HTML document. When omitted, a minimal
44
+ * neutral spinner is rendered.
45
+ */
46
+ render?: (args: InlineCallbackBrandedRenderArgs) => string;
47
+ }
48
+ interface InlineCallbackConfig {
49
+ /**
50
+ * When truthy, mount a GET-method handler on the same path as the POST
51
+ * callback so the OAuth redirect lands on a server-rendered page (no
52
+ * blank-tab while waiting for client JS). When `false`, only `POST` is
53
+ * mounted (the browser SDK posts the code + verifier itself).
54
+ *
55
+ * - `inlineCallback: true` — GET exchanges the code synchronously
56
+ * (PKCE verifier read from the `iqauth_pkce` first-party cookie set by
57
+ * the browser SDK before redirect) and 302s to the final URL.
58
+ *
59
+ * - `inlineCallback: { branded: true }` — GET returns a small spinner HTML
60
+ * document; the exchange happens via a sibling JSON endpoint at
61
+ * `${callbackPath}/exchange`.
62
+ *
63
+ * - `inlineCallback: { branded: { render } }` — same as above but lets
64
+ * you supply your own HTML (logo, copy, theme).
65
+ */
66
+ branded?: boolean | InlineCallbackBrandedConfig;
67
+ /**
68
+ * Where to redirect on a failed inline callback (state mismatch, missing
69
+ * code, code-exchange error from the issuer, etc). When omitted, the
70
+ * plain inline flow returns a JSON error body and the branded flow
71
+ * surfaces the failure via the spinner script's catch handler. When set,
72
+ * the GET handler 302s to this path with `?error=<code>` appended.
73
+ */
74
+ errorPath?: string;
75
+ /**
76
+ * Cookie name the browser SDK uses to publish the OAuth `state` value
77
+ * before redirect. Validated against the `?state=` query param on the
78
+ * return trip. Defaults to `iqauth_state`.
79
+ */
80
+ stateCookieName?: string;
81
+ /**
82
+ * Cookie name the browser SDK uses to publish the post-login destination
83
+ * before redirect. The inline GET handler reads it and 302s the user
84
+ * there after a successful exchange. Defaults to `iqauth_return_to`.
85
+ */
86
+ returnToCookieName?: string;
87
+ }
25
88
  interface IQAuthExpressOptions extends IQAuthHelperConfig, CookieAwareMiddlewareOptions {
26
89
  /** Mount path prefix for the auto-mounted helper routes. */
27
90
  mountPath?: string;
28
91
  /** Set to false to skip mounting helper routes (verify-only mode). */
29
92
  mountHelperRoutes?: boolean;
93
+ /**
94
+ * Mount a GET handler on the callback path so the OAuth redirect lands
95
+ * on a server-rendered page. Off by default (browser SDK posts the code
96
+ * itself). See {@link InlineCallbackConfig}.
97
+ */
98
+ inlineCallback?: boolean | InlineCallbackConfig;
30
99
  }
31
100
  interface ExpressLikeApp {
32
101
  post(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
102
+ get?(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
33
103
  use?: (...args: unknown[]) => unknown;
34
104
  }
35
105
  interface ExpressLikeRouter {
36
106
  post(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
107
+ get?(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
37
108
  }
38
109
  declare function iqAuth(options: IQAuthExpressOptions): {
39
110
  (req: IQAuthRequestLike, res: IQAuthResponseLike, next: IQAuthNextFunction): unknown;
@@ -42,4 +113,4 @@ declare function iqAuth(options: IQAuthExpressOptions): {
42
113
  client: IQAuthClient;
43
114
  };
44
115
 
45
- export { CookieAwareMiddlewareOptions, type IQAuthExpressOptions, iqAuth };
116
+ export { CookieAwareMiddlewareOptions, type IQAuthExpressOptions, type InlineCallbackBrandedConfig, type InlineCallbackBrandedRenderArgs, type InlineCallbackConfig, iqAuth };
package/dist/express.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { I as IQAuthClient } from './client-DXbHb2ul.js';
2
- import { C as CookieAwareMiddlewareOptions } from './express-B4o3P8vK.js';
3
- export { i as iqAuthMiddleware } from './express-B4o3P8vK.js';
1
+ import { I as IQAuthClient } from './client-BNQe3AgF.js';
2
+ import { C as CookieAwareMiddlewareOptions } from './express-CHpfa7D_.js';
3
+ export { i as iqAuthMiddleware } from './express-CHpfa7D_.js';
4
4
  import { IQAuthHelperConfig } from './server/handlers.js';
5
- import { Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-Cxl3bQHt.js';
5
+ import { Q as IQAuthRequestLike, R as IQAuthResponseLike, V as IQAuthNextFunction } from './types-DZAflmmq.js';
6
6
  export { E as ErrorCodes, I as IQAuthError } from './errors-CDdl24MP.js';
7
- import 'jsonwebtoken';
7
+ import './tokens-aHiGFr_E.js';
8
8
 
9
9
  /**
10
10
  * @iqauth/sdk/express — drop-in Express adapter.
@@ -22,18 +22,89 @@ import 'jsonwebtoken';
22
22
  * app.use(iqAuth({ publishableKey: process.env.IQAUTH_PUBLISHABLE_KEY!, secretKey: process.env.IQAUTH_SECRET_KEY! }));
23
23
  */
24
24
 
25
+ interface InlineCallbackBrandedRenderArgs {
26
+ /** Issuer URL the SDK will use to mint the authorization code (publishable key origin). */
27
+ issuer: string;
28
+ /** Path of the JSON exchange endpoint to POST to (e.g. `/api/iqauth/callback/exchange`). */
29
+ exchangePath: string;
30
+ /** The raw `?code=` value from the OAuth redirect (already escaped for HTML). */
31
+ code: string;
32
+ /** The raw `?state=` value from the OAuth redirect (already escaped for HTML). */
33
+ state: string;
34
+ /** If `errorPath` is configured on the inline-callback options, it's threaded
35
+ * here so a custom render function can reuse it for its own catch handler.
36
+ * `""` when unset. */
37
+ errorPath?: string;
38
+ }
39
+ interface InlineCallbackBrandedConfig {
40
+ /**
41
+ * Optional override for the spinner page HTML. Receives the issuer URL, the
42
+ * exchange endpoint path, and the (HTML-escaped) `code` + `state` from the
43
+ * OAuth redirect. Returns a full HTML document. When omitted, a minimal
44
+ * neutral spinner is rendered.
45
+ */
46
+ render?: (args: InlineCallbackBrandedRenderArgs) => string;
47
+ }
48
+ interface InlineCallbackConfig {
49
+ /**
50
+ * When truthy, mount a GET-method handler on the same path as the POST
51
+ * callback so the OAuth redirect lands on a server-rendered page (no
52
+ * blank-tab while waiting for client JS). When `false`, only `POST` is
53
+ * mounted (the browser SDK posts the code + verifier itself).
54
+ *
55
+ * - `inlineCallback: true` — GET exchanges the code synchronously
56
+ * (PKCE verifier read from the `iqauth_pkce` first-party cookie set by
57
+ * the browser SDK before redirect) and 302s to the final URL.
58
+ *
59
+ * - `inlineCallback: { branded: true }` — GET returns a small spinner HTML
60
+ * document; the exchange happens via a sibling JSON endpoint at
61
+ * `${callbackPath}/exchange`.
62
+ *
63
+ * - `inlineCallback: { branded: { render } }` — same as above but lets
64
+ * you supply your own HTML (logo, copy, theme).
65
+ */
66
+ branded?: boolean | InlineCallbackBrandedConfig;
67
+ /**
68
+ * Where to redirect on a failed inline callback (state mismatch, missing
69
+ * code, code-exchange error from the issuer, etc). When omitted, the
70
+ * plain inline flow returns a JSON error body and the branded flow
71
+ * surfaces the failure via the spinner script's catch handler. When set,
72
+ * the GET handler 302s to this path with `?error=<code>` appended.
73
+ */
74
+ errorPath?: string;
75
+ /**
76
+ * Cookie name the browser SDK uses to publish the OAuth `state` value
77
+ * before redirect. Validated against the `?state=` query param on the
78
+ * return trip. Defaults to `iqauth_state`.
79
+ */
80
+ stateCookieName?: string;
81
+ /**
82
+ * Cookie name the browser SDK uses to publish the post-login destination
83
+ * before redirect. The inline GET handler reads it and 302s the user
84
+ * there after a successful exchange. Defaults to `iqauth_return_to`.
85
+ */
86
+ returnToCookieName?: string;
87
+ }
25
88
  interface IQAuthExpressOptions extends IQAuthHelperConfig, CookieAwareMiddlewareOptions {
26
89
  /** Mount path prefix for the auto-mounted helper routes. */
27
90
  mountPath?: string;
28
91
  /** Set to false to skip mounting helper routes (verify-only mode). */
29
92
  mountHelperRoutes?: boolean;
93
+ /**
94
+ * Mount a GET handler on the callback path so the OAuth redirect lands
95
+ * on a server-rendered page. Off by default (browser SDK posts the code
96
+ * itself). See {@link InlineCallbackConfig}.
97
+ */
98
+ inlineCallback?: boolean | InlineCallbackConfig;
30
99
  }
31
100
  interface ExpressLikeApp {
32
101
  post(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
102
+ get?(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
33
103
  use?: (...args: unknown[]) => unknown;
34
104
  }
35
105
  interface ExpressLikeRouter {
36
106
  post(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
107
+ get?(path: string, handler: (req: any, res: any) => unknown | Promise<unknown>): unknown;
37
108
  }
38
109
  declare function iqAuth(options: IQAuthExpressOptions): {
39
110
  (req: IQAuthRequestLike, res: IQAuthResponseLike, next: IQAuthNextFunction): unknown;
@@ -42,4 +113,4 @@ declare function iqAuth(options: IQAuthExpressOptions): {
42
113
  client: IQAuthClient;
43
114
  };
44
115
 
45
- export { CookieAwareMiddlewareOptions, type IQAuthExpressOptions, iqAuth };
116
+ export { CookieAwareMiddlewareOptions, type IQAuthExpressOptions, type InlineCallbackBrandedConfig, type InlineCallbackBrandedRenderArgs, type InlineCallbackConfig, iqAuth };