@iqauth/sdk 2.6.3 → 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 +10 -8
- package/dist/{chunk-6I6RM4MN.mjs → chunk-6PJRLRB4.mjs} +33 -3
- package/dist/chunk-C2ZTBOAC.mjs +36 -0
- package/dist/{chunk-LIZYFXH7.mjs → chunk-DFWHSDYQ.mjs} +1 -1
- package/dist/chunk-GLXSIGVS.mjs +66 -0
- package/dist/{chunk-TKZTCPEK.mjs → chunk-GN37E64I.mjs} +32 -40
- 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-76W5TLQQ.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/pkce-7WKV4OIN.mjs +11 -0
- 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 +343 -36
- package/dist/react.mjs +59 -2611
- 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-CiIBTJIh.d.mts → signIn-BLFnz8SV.d.ts} +78 -3
- package/dist/{signIn-CCY4JE5G.mjs → signIn-SHBW6Z4T.mjs} +2 -1
- package/dist/{signIn-OCr88Zf8.d.ts → 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
package/dist/fastify.mjs
CHANGED
|
@@ -2,18 +2,19 @@ import {
|
|
|
2
2
|
handleCallback,
|
|
3
3
|
handleRefresh,
|
|
4
4
|
handleSignout,
|
|
5
|
+
handleUserinfo,
|
|
5
6
|
serializeCookie
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RUJXRTEW.mjs";
|
|
7
8
|
import {
|
|
8
9
|
assertPublishableKey
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HVHNYPDC.mjs";
|
|
10
11
|
import {
|
|
11
12
|
IQAuthClient
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-JXQI62A7.mjs";
|
|
14
|
+
import "./chunk-NUO2I65G.mjs";
|
|
14
15
|
import {
|
|
15
16
|
IQAuthError
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6PJRLRB4.mjs";
|
|
17
18
|
import "./chunk-Y6FXYEAI.mjs";
|
|
18
19
|
|
|
19
20
|
// src/fastify.ts
|
|
@@ -23,7 +24,10 @@ var KNOWN_AUTH_ERRORS = /* @__PURE__ */ new Set([
|
|
|
23
24
|
"TOKEN_REVOKED",
|
|
24
25
|
"SESSION_EXPIRED",
|
|
25
26
|
"SESSION_INVALID",
|
|
26
|
-
"AUTH_REQUIRED"
|
|
27
|
+
"AUTH_REQUIRED",
|
|
28
|
+
// Task #127 — typed `IQAuthErrorCode` taxonomy.
|
|
29
|
+
"token_invalid",
|
|
30
|
+
"token_expired"
|
|
27
31
|
]);
|
|
28
32
|
function applyResponse(reply, hr) {
|
|
29
33
|
for (const c of hr.cookies) {
|
|
@@ -72,6 +76,7 @@ async function iqAuth(fastify, options) {
|
|
|
72
76
|
const mountHelpers = options.mountHelperRoutes !== false;
|
|
73
77
|
const isPublic = (p) => {
|
|
74
78
|
if (mountHelpers && p.startsWith(mount + "/")) return true;
|
|
79
|
+
if (options.mountUserinfo && p === `${mount}/me`) return true;
|
|
75
80
|
if (Array.isArray(options.publicPaths)) return options.publicPaths.includes(p);
|
|
76
81
|
if (typeof options.publicPaths === "function") return options.publicPaths(p);
|
|
77
82
|
return false;
|
|
@@ -110,13 +115,23 @@ async function iqAuth(fastify, options) {
|
|
|
110
115
|
fastify.post(`${mount}/refresh`, async (req, reply) => {
|
|
111
116
|
const body = req.body || {};
|
|
112
117
|
const refreshToken = body.refreshToken || readCookie(req, refreshCookie);
|
|
113
|
-
|
|
118
|
+
const idempotencyToken = req.headers?.["x-iqauth-idempotency"] || body.idempotencyToken;
|
|
119
|
+
applyResponse(reply, await handleRefresh(helperConfig, { refreshToken, idempotencyToken }));
|
|
114
120
|
});
|
|
115
121
|
fastify.post(`${mount}/signout`, async (req, reply) => {
|
|
116
122
|
const auth = req.headers?.authorization;
|
|
117
123
|
const accessToken = (typeof auth === "string" ? auth.replace(/^Bearer /i, "") : void 0) || readCookie(req, accessCookie);
|
|
124
|
+
const refreshToken = readCookie(req, refreshCookie);
|
|
118
125
|
const ssoCookieHeader = typeof req.headers?.cookie === "string" ? req.headers.cookie : void 0;
|
|
119
|
-
|
|
126
|
+
const idempotencyToken = req.headers?.["x-iqauth-idempotency"];
|
|
127
|
+
applyResponse(reply, await handleSignout(helperConfig, { accessToken, refreshToken, idempotencyToken, ssoCookieHeader }));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (options.mountUserinfo) {
|
|
131
|
+
fastify.get(`${mount}/me`, async (req, reply) => {
|
|
132
|
+
const auth = req.headers?.authorization;
|
|
133
|
+
const accessToken = (typeof auth === "string" ? auth.replace(/^Bearer /i, "") : void 0) || readCookie(req, accessCookie);
|
|
134
|
+
applyResponse(reply, await handleUserinfo(helperConfig, { accessToken, req }));
|
|
120
135
|
});
|
|
121
136
|
}
|
|
122
137
|
fastify.decorate("iqauth", { client, issuer });
|
package/dist/hono.d.mts
CHANGED