@iqauth/sdk 2.3.0 → 2.6.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 +3006 -568
- package/dist/react.mjs +1540 -97
- 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/dist/test.js
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/test.ts
|
|
31
|
+
var test_exports = {};
|
|
32
|
+
__export(test_exports, {
|
|
33
|
+
createTestIssuer: () => createTestIssuer
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(test_exports);
|
|
36
|
+
var import_http = require("http");
|
|
37
|
+
var import_crypto = require("crypto");
|
|
38
|
+
var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
39
|
+
|
|
40
|
+
// src/publishableKey.ts
|
|
41
|
+
function b64urlEncode(input) {
|
|
42
|
+
if (typeof btoa === "function") {
|
|
43
|
+
const bytes = new TextEncoder().encode(input);
|
|
44
|
+
let bin = "";
|
|
45
|
+
for (let i = 0; i < bytes.byteLength; i++) bin += String.fromCharCode(bytes[i]);
|
|
46
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
47
|
+
}
|
|
48
|
+
const { Buffer: Buffer2 } = require("buffer");
|
|
49
|
+
return Buffer2.from(input, "utf8").toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
50
|
+
}
|
|
51
|
+
function encodePublishableKey(mode, payload) {
|
|
52
|
+
if (mode !== "test" && mode !== "live") throw new Error(`Invalid mode: ${mode}`);
|
|
53
|
+
return `pk_${mode}_${b64urlEncode(JSON.stringify(payload))}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/test.ts
|
|
57
|
+
function jwkFromPublicKey(publicKey, kid) {
|
|
58
|
+
const jwk = publicKey.export({ format: "jwk" });
|
|
59
|
+
return { kty: "RSA", use: "sig", alg: "RS256", kid, n: jwk.n, e: jwk.e };
|
|
60
|
+
}
|
|
61
|
+
function readBody(req) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const chunks = [];
|
|
64
|
+
req.on("data", (c) => chunks.push(c));
|
|
65
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
66
|
+
req.on("error", reject);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function parseFormOrJson(raw, contentType) {
|
|
70
|
+
if (!raw) return {};
|
|
71
|
+
if (contentType && contentType.includes("application/json")) {
|
|
72
|
+
try {
|
|
73
|
+
const obj = JSON.parse(raw);
|
|
74
|
+
const out2 = {};
|
|
75
|
+
for (const [k, v] of Object.entries(obj || {})) {
|
|
76
|
+
if (typeof v === "string") out2[k] = v;
|
|
77
|
+
else if (v != null) out2[k] = String(v);
|
|
78
|
+
}
|
|
79
|
+
return out2;
|
|
80
|
+
} catch {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const out = {};
|
|
85
|
+
for (const part of raw.split("&")) {
|
|
86
|
+
if (!part) continue;
|
|
87
|
+
const eq = part.indexOf("=");
|
|
88
|
+
const k = decodeURIComponent(eq === -1 ? part : part.slice(0, eq)).replace(/\+/g, " ");
|
|
89
|
+
const v = eq === -1 ? "" : decodeURIComponent(part.slice(eq + 1)).replace(/\+/g, " ");
|
|
90
|
+
out[k] = v;
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
function send(res, status, body, headers = {}) {
|
|
95
|
+
const payload = typeof body === "string" ? body : JSON.stringify(body);
|
|
96
|
+
res.writeHead(status, {
|
|
97
|
+
"Content-Type": typeof body === "string" ? "text/plain; charset=utf-8" : "application/json; charset=utf-8",
|
|
98
|
+
"Content-Length": Buffer.byteLength(payload),
|
|
99
|
+
...headers
|
|
100
|
+
});
|
|
101
|
+
res.end(payload);
|
|
102
|
+
}
|
|
103
|
+
async function createTestIssuer(options = {}) {
|
|
104
|
+
const host = options.host ?? "127.0.0.1";
|
|
105
|
+
const port = options.port ?? 0;
|
|
106
|
+
const tenantId = options.tenantId ?? "tenant-test";
|
|
107
|
+
const appId = options.appId ?? "app-test";
|
|
108
|
+
const kid = options.kid ?? `test-${(0, import_crypto.randomBytes)(6).toString("hex")}`;
|
|
109
|
+
const defaultAudience = options.defaultAudience ?? ["dispositioniq"];
|
|
110
|
+
const { privateKey, publicKey } = (0, import_crypto.generateKeyPairSync)("rsa", {
|
|
111
|
+
modulusLength: 2048,
|
|
112
|
+
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
113
|
+
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
114
|
+
});
|
|
115
|
+
const publicKeyObj = (0, import_crypto.createPublicKey)(publicKey);
|
|
116
|
+
const jwk = jwkFromPublicKey(publicKeyObj, kid);
|
|
117
|
+
const pendingCodes = /* @__PURE__ */ new Map();
|
|
118
|
+
let baseUrl = "";
|
|
119
|
+
const buildToken = (opts) => {
|
|
120
|
+
const payload = {
|
|
121
|
+
sub: opts.sub ?? "test-user",
|
|
122
|
+
email: opts.email ?? "test@example.com",
|
|
123
|
+
name: opts.name ?? "Test User",
|
|
124
|
+
tenantId: opts.tenantId ?? tenantId,
|
|
125
|
+
vendorId: opts.vendorId ?? null,
|
|
126
|
+
roles: opts.roles ?? [],
|
|
127
|
+
entitlements: opts.entitlements ?? [],
|
|
128
|
+
sessionId: opts.sessionId ?? `sess-${(0, import_crypto.randomBytes)(4).toString("hex")}`,
|
|
129
|
+
jti: opts.jti ?? `jti-${(0, import_crypto.randomBytes)(4).toString("hex")}`
|
|
130
|
+
};
|
|
131
|
+
if (opts.scopeContext !== void 0) payload.scopeContext = opts.scopeContext;
|
|
132
|
+
if (opts.loginMethod !== void 0) payload.loginMethod = opts.loginMethod;
|
|
133
|
+
for (const [k, v] of Object.entries(opts)) {
|
|
134
|
+
if (["sub", "email", "name", "tenantId", "vendorId", "roles", "entitlements", "sessionId", "jti", "scopeContext", "loginMethod", "audience", "issuer", "expiresInSeconds", "iat"].includes(k))
|
|
135
|
+
continue;
|
|
136
|
+
payload[k] = v;
|
|
137
|
+
}
|
|
138
|
+
const audience = opts.audience ?? defaultAudience;
|
|
139
|
+
const issuer = opts.issuer ?? baseUrl;
|
|
140
|
+
const expiresIn = opts.expiresInSeconds ?? 900;
|
|
141
|
+
const signOpts = {
|
|
142
|
+
algorithm: "RS256",
|
|
143
|
+
keyid: kid,
|
|
144
|
+
issuer,
|
|
145
|
+
audience
|
|
146
|
+
};
|
|
147
|
+
if (opts.iat !== void 0) {
|
|
148
|
+
payload.iat = opts.iat;
|
|
149
|
+
payload.exp = opts.iat + expiresIn;
|
|
150
|
+
} else {
|
|
151
|
+
signOpts.expiresIn = expiresIn;
|
|
152
|
+
}
|
|
153
|
+
return import_jsonwebtoken.default.sign(payload, privateKey, signOpts);
|
|
154
|
+
};
|
|
155
|
+
const handler = async (req, res) => {
|
|
156
|
+
try {
|
|
157
|
+
const url = new URL(req.url || "/", baseUrl || `http://${host}`);
|
|
158
|
+
const path = url.pathname;
|
|
159
|
+
if (req.method === "OPTIONS") {
|
|
160
|
+
res.writeHead(204, {
|
|
161
|
+
"Access-Control-Allow-Origin": "*",
|
|
162
|
+
"Access-Control-Allow-Methods": "GET,POST,OPTIONS",
|
|
163
|
+
"Access-Control-Allow-Headers": "Authorization,Content-Type"
|
|
164
|
+
});
|
|
165
|
+
return res.end();
|
|
166
|
+
}
|
|
167
|
+
const cors = { "Access-Control-Allow-Origin": "*" };
|
|
168
|
+
if (req.method === "GET" && path === "/.well-known/openid-configuration") {
|
|
169
|
+
return send(res, 200, {
|
|
170
|
+
issuer: baseUrl,
|
|
171
|
+
jwks_uri: `${baseUrl}/.well-known/jwks.json`,
|
|
172
|
+
authorization_endpoint: `${baseUrl}/oidc/authorize`,
|
|
173
|
+
token_endpoint: `${baseUrl}/oidc/token`,
|
|
174
|
+
userinfo_endpoint: `${baseUrl}/api/v1/auth/me`,
|
|
175
|
+
response_types_supported: ["code"],
|
|
176
|
+
grant_types_supported: ["authorization_code", "refresh_token"],
|
|
177
|
+
subject_types_supported: ["public"],
|
|
178
|
+
id_token_signing_alg_values_supported: ["RS256"],
|
|
179
|
+
code_challenge_methods_supported: ["S256"]
|
|
180
|
+
}, cors);
|
|
181
|
+
}
|
|
182
|
+
if (req.method === "GET" && path === "/.well-known/jwks.json") {
|
|
183
|
+
return send(res, 200, { keys: [jwk] }, { ...cors, "Cache-Control": "public, max-age=3600" });
|
|
184
|
+
}
|
|
185
|
+
if (req.method === "POST" && path === "/oidc/token") {
|
|
186
|
+
const raw = await readBody(req);
|
|
187
|
+
const params = parseFormOrJson(raw, req.headers["content-type"]);
|
|
188
|
+
const grant = params.grant_type;
|
|
189
|
+
if (grant === "authorization_code") {
|
|
190
|
+
const code = params.code;
|
|
191
|
+
const pending = code ? pendingCodes.get(code) : void 0;
|
|
192
|
+
if (!pending) {
|
|
193
|
+
return send(res, 400, { error: "invalid_grant", error_description: "Unknown or expired code" }, cors);
|
|
194
|
+
}
|
|
195
|
+
pendingCodes.delete(code);
|
|
196
|
+
const accessToken = buildToken(pending.claims);
|
|
197
|
+
return send(res, 200, {
|
|
198
|
+
access_token: accessToken,
|
|
199
|
+
refresh_token: pending.refreshToken,
|
|
200
|
+
id_token: accessToken,
|
|
201
|
+
token_type: "Bearer",
|
|
202
|
+
expires_in: pending.claims.expiresInSeconds ?? 900
|
|
203
|
+
}, cors);
|
|
204
|
+
}
|
|
205
|
+
if (grant === "refresh_token") {
|
|
206
|
+
const accessToken = buildToken({ sub: "test-user" });
|
|
207
|
+
return send(res, 200, {
|
|
208
|
+
access_token: accessToken,
|
|
209
|
+
refresh_token: params.refresh_token || `rt-${(0, import_crypto.randomBytes)(8).toString("hex")}`,
|
|
210
|
+
token_type: "Bearer",
|
|
211
|
+
expires_in: 900
|
|
212
|
+
}, cors);
|
|
213
|
+
}
|
|
214
|
+
return send(res, 400, { error: "unsupported_grant_type" }, cors);
|
|
215
|
+
}
|
|
216
|
+
if (req.method === "GET" && path === "/api/v1/auth/me") {
|
|
217
|
+
const auth = req.headers.authorization || "";
|
|
218
|
+
if (!/^Bearer /i.test(auth)) {
|
|
219
|
+
return send(res, 401, { success: false, error: { code: "TOKEN_INVALID", message: "Missing bearer" } }, cors);
|
|
220
|
+
}
|
|
221
|
+
const token = auth.slice(7).trim();
|
|
222
|
+
try {
|
|
223
|
+
const decoded = import_jsonwebtoken.default.verify(token, publicKey, {
|
|
224
|
+
algorithms: ["RS256"],
|
|
225
|
+
issuer: baseUrl,
|
|
226
|
+
audience: defaultAudience
|
|
227
|
+
});
|
|
228
|
+
return send(res, 200, {
|
|
229
|
+
success: true,
|
|
230
|
+
data: {
|
|
231
|
+
id: decoded.sub,
|
|
232
|
+
email: decoded.email,
|
|
233
|
+
name: decoded.name,
|
|
234
|
+
tenantId: decoded.tenantId,
|
|
235
|
+
roles: decoded.roles,
|
|
236
|
+
entitlements: decoded.entitlements
|
|
237
|
+
}
|
|
238
|
+
}, cors);
|
|
239
|
+
} catch (err) {
|
|
240
|
+
const msg = err instanceof Error ? err.message : "verify failed";
|
|
241
|
+
return send(res, 401, { success: false, error: { code: "TOKEN_INVALID", message: msg } }, cors);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
send(res, 404, { error: "not_found", path }, cors);
|
|
245
|
+
} catch (err) {
|
|
246
|
+
const msg = err instanceof Error ? err.message : "internal error";
|
|
247
|
+
send(res, 500, { error: "internal", message: msg });
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const server = (0, import_http.createServer)((req, res) => {
|
|
251
|
+
void handler(req, res);
|
|
252
|
+
});
|
|
253
|
+
await new Promise((resolve, reject) => {
|
|
254
|
+
server.once("error", reject);
|
|
255
|
+
server.listen(port, host, () => {
|
|
256
|
+
server.off("error", reject);
|
|
257
|
+
resolve();
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
const addr = server.address();
|
|
261
|
+
const boundPort = typeof addr === "object" && addr ? addr.port : port;
|
|
262
|
+
baseUrl = `http://${host}:${boundPort}`;
|
|
263
|
+
const publishableKey = encodePublishableKey("test", {
|
|
264
|
+
iss: baseUrl,
|
|
265
|
+
appId,
|
|
266
|
+
tenantId,
|
|
267
|
+
kid
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
baseUrl,
|
|
271
|
+
publishableKey,
|
|
272
|
+
kid,
|
|
273
|
+
publicKey,
|
|
274
|
+
mintToken: (opts = {}) => buildToken(opts),
|
|
275
|
+
mintAuthCode: (opts = {}) => {
|
|
276
|
+
const code = `code-${(0, import_crypto.randomBytes)(12).toString("hex")}`;
|
|
277
|
+
const refreshToken = opts.refreshToken ?? `rt-${(0, import_crypto.randomBytes)(12).toString("hex")}`;
|
|
278
|
+
pendingCodes.set(code, { claims: opts, refreshToken });
|
|
279
|
+
return code;
|
|
280
|
+
},
|
|
281
|
+
close: () => new Promise((resolve, reject) => {
|
|
282
|
+
server.close((err) => err ? reject(err) : resolve());
|
|
283
|
+
})
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
287
|
+
0 && (module.exports = {
|
|
288
|
+
createTestIssuer
|
|
289
|
+
});
|
package/dist/test.mjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { J as JwtClaims } from './types-DZAflmmq.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SOURCE REFS:
|
|
5
|
+
* - Route file: src/services/token.service.ts (RS256, issuer "auth.dispositioniq.com", audience array)
|
|
6
|
+
* - Route file: src/routes/wellknown.routes.ts (JWKS endpoint /.well-known/jwks.json)
|
|
7
|
+
* - Route file: src/lib/crypto.ts (key rotation with kid)
|
|
8
|
+
* - Verified claims: sub, email, name, tenantId, vendorId, roles, entitlements, sessionId, jti, iss, aud, exp, iat, scopeContext, loginMethod
|
|
9
|
+
* - Last verified: Phase 0 Research Summary
|
|
10
|
+
*
|
|
11
|
+
* 2.3.0: Verify path swapped from `jsonwebtoken` (which depends on
|
|
12
|
+
* `node:crypto`) to `jose` so the SDK works on Next.js / Vercel / Cloudflare
|
|
13
|
+
* edge runtimes. Edge has only Web Crypto, so every call from a Next
|
|
14
|
+
* middleware previously threw and was wrapped as `TOKEN_INVALID`,
|
|
15
|
+
* indistinguishable from a real bad token. We keep our own JWKS fetch +
|
|
16
|
+
* cache to preserve INTERNAL_ERROR mapping for malformed JWKS payloads and
|
|
17
|
+
* to keep the kid-aware "Unknown key ID" diagnostic.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const DEFAULT_TOKEN_ISSUER: string[];
|
|
21
|
+
declare const DEFAULT_TOKEN_AUDIENCE: string[];
|
|
22
|
+
declare const DEFAULT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
23
|
+
interface TokenVerifyOptions {
|
|
24
|
+
issuer?: string | string[];
|
|
25
|
+
audience?: string | string[];
|
|
26
|
+
clockTolerance?: number;
|
|
27
|
+
algorithms?: string[];
|
|
28
|
+
}
|
|
29
|
+
interface TokensModuleOptions {
|
|
30
|
+
issuer?: string | string[];
|
|
31
|
+
audience?: string | string[];
|
|
32
|
+
clockTolerance?: number;
|
|
33
|
+
}
|
|
34
|
+
declare class TokensModule {
|
|
35
|
+
private baseUrl;
|
|
36
|
+
private jwksCache;
|
|
37
|
+
private inFlightRefresh;
|
|
38
|
+
private defaultIssuer;
|
|
39
|
+
private defaultAudience;
|
|
40
|
+
private defaultClockTolerance;
|
|
41
|
+
constructor(baseUrl: string, options?: TokensModuleOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Verify a JWT access token using RS256/ES256 via JWKS from
|
|
44
|
+
* `/.well-known/jwks.json`. Backed by `jose` (Web Crypto) so it runs on
|
|
45
|
+
* Node, browser, and edge runtimes alike — no `node:crypto` dependency.
|
|
46
|
+
* Caches JWKS for 1 hour and refetches once on unknown `kid`.
|
|
47
|
+
*/
|
|
48
|
+
verify(token: string, options?: TokenVerifyOptions): Promise<JwtClaims>;
|
|
49
|
+
/**
|
|
50
|
+
* Decode a JWT without verification. Returns null if malformed.
|
|
51
|
+
*/
|
|
52
|
+
decode(token: string): JwtClaims | null;
|
|
53
|
+
/** Check if a token is expired based on the `exp` claim. */
|
|
54
|
+
isExpired(token: string): boolean;
|
|
55
|
+
/** Get the claims from a token without verification. */
|
|
56
|
+
getClaims(token: string): JwtClaims;
|
|
57
|
+
private ensureCache;
|
|
58
|
+
private refreshJwks;
|
|
59
|
+
/** @internal Exposed for testing — clears JWKS cache */
|
|
60
|
+
clearCache(): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { DEFAULT_TOKEN_ISSUER as D, TokensModule as T, DEFAULT_TOKEN_AUDIENCE as a, DEFAULT_CLOCK_TOLERANCE_SECONDS as b, type TokenVerifyOptions as c, type TokensModuleOptions as d };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { J as JwtClaims } from './types-DZAflmmq.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SOURCE REFS:
|
|
5
|
+
* - Route file: src/services/token.service.ts (RS256, issuer "auth.dispositioniq.com", audience array)
|
|
6
|
+
* - Route file: src/routes/wellknown.routes.ts (JWKS endpoint /.well-known/jwks.json)
|
|
7
|
+
* - Route file: src/lib/crypto.ts (key rotation with kid)
|
|
8
|
+
* - Verified claims: sub, email, name, tenantId, vendorId, roles, entitlements, sessionId, jti, iss, aud, exp, iat, scopeContext, loginMethod
|
|
9
|
+
* - Last verified: Phase 0 Research Summary
|
|
10
|
+
*
|
|
11
|
+
* 2.3.0: Verify path swapped from `jsonwebtoken` (which depends on
|
|
12
|
+
* `node:crypto`) to `jose` so the SDK works on Next.js / Vercel / Cloudflare
|
|
13
|
+
* edge runtimes. Edge has only Web Crypto, so every call from a Next
|
|
14
|
+
* middleware previously threw and was wrapped as `TOKEN_INVALID`,
|
|
15
|
+
* indistinguishable from a real bad token. We keep our own JWKS fetch +
|
|
16
|
+
* cache to preserve INTERNAL_ERROR mapping for malformed JWKS payloads and
|
|
17
|
+
* to keep the kid-aware "Unknown key ID" diagnostic.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const DEFAULT_TOKEN_ISSUER: string[];
|
|
21
|
+
declare const DEFAULT_TOKEN_AUDIENCE: string[];
|
|
22
|
+
declare const DEFAULT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
23
|
+
interface TokenVerifyOptions {
|
|
24
|
+
issuer?: string | string[];
|
|
25
|
+
audience?: string | string[];
|
|
26
|
+
clockTolerance?: number;
|
|
27
|
+
algorithms?: string[];
|
|
28
|
+
}
|
|
29
|
+
interface TokensModuleOptions {
|
|
30
|
+
issuer?: string | string[];
|
|
31
|
+
audience?: string | string[];
|
|
32
|
+
clockTolerance?: number;
|
|
33
|
+
}
|
|
34
|
+
declare class TokensModule {
|
|
35
|
+
private baseUrl;
|
|
36
|
+
private jwksCache;
|
|
37
|
+
private inFlightRefresh;
|
|
38
|
+
private defaultIssuer;
|
|
39
|
+
private defaultAudience;
|
|
40
|
+
private defaultClockTolerance;
|
|
41
|
+
constructor(baseUrl: string, options?: TokensModuleOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Verify a JWT access token using RS256/ES256 via JWKS from
|
|
44
|
+
* `/.well-known/jwks.json`. Backed by `jose` (Web Crypto) so it runs on
|
|
45
|
+
* Node, browser, and edge runtimes alike — no `node:crypto` dependency.
|
|
46
|
+
* Caches JWKS for 1 hour and refetches once on unknown `kid`.
|
|
47
|
+
*/
|
|
48
|
+
verify(token: string, options?: TokenVerifyOptions): Promise<JwtClaims>;
|
|
49
|
+
/**
|
|
50
|
+
* Decode a JWT without verification. Returns null if malformed.
|
|
51
|
+
*/
|
|
52
|
+
decode(token: string): JwtClaims | null;
|
|
53
|
+
/** Check if a token is expired based on the `exp` claim. */
|
|
54
|
+
isExpired(token: string): boolean;
|
|
55
|
+
/** Get the claims from a token without verification. */
|
|
56
|
+
getClaims(token: string): JwtClaims;
|
|
57
|
+
private ensureCache;
|
|
58
|
+
private refreshJwks;
|
|
59
|
+
/** @internal Exposed for testing — clears JWKS cache */
|
|
60
|
+
clearCache(): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { DEFAULT_TOKEN_ISSUER as D, TokensModule as T, DEFAULT_TOKEN_AUDIENCE as a, DEFAULT_CLOCK_TOLERANCE_SECONDS as b, type TokenVerifyOptions as c, type TokensModuleOptions as d };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog of all localizable strings used by the IQAuth SDK UI components and
|
|
3
|
+
* hosted auth pages. The shape is defined as a strict interface so missing
|
|
4
|
+
* keys in a contributed locale produce a TypeScript compile error.
|
|
5
|
+
*
|
|
6
|
+
* Strings may contain `{placeholder}` tokens that are interpolated at render
|
|
7
|
+
* time via `t(bundle, key, vars)`.
|
|
8
|
+
*/
|
|
9
|
+
interface IQAuthLocaleBundle {
|
|
10
|
+
/** BCP-47 tag for this bundle (e.g. "en-US", "fr-FR"). */
|
|
11
|
+
locale: string;
|
|
12
|
+
"common.loading": string;
|
|
13
|
+
"common.submitting": string;
|
|
14
|
+
"common.cancel": string;
|
|
15
|
+
"common.continue": string;
|
|
16
|
+
"common.back": string;
|
|
17
|
+
"common.close": string;
|
|
18
|
+
"common.save": string;
|
|
19
|
+
"common.saving": string;
|
|
20
|
+
"common.delete": string;
|
|
21
|
+
"common.confirm": string;
|
|
22
|
+
"common.email": string;
|
|
23
|
+
"common.password": string;
|
|
24
|
+
"common.name": string;
|
|
25
|
+
"common.or": string;
|
|
26
|
+
"common.required": string;
|
|
27
|
+
"common.optional": string;
|
|
28
|
+
"common.retry": string;
|
|
29
|
+
"signIn.title": string;
|
|
30
|
+
"signIn.subtitle": string;
|
|
31
|
+
"signIn.titleWithApp": string;
|
|
32
|
+
"signIn.emailLabel": string;
|
|
33
|
+
"signIn.emailPlaceholder": string;
|
|
34
|
+
"signIn.passwordLabel": string;
|
|
35
|
+
"signIn.passwordPlaceholder": string;
|
|
36
|
+
"signIn.submit": string;
|
|
37
|
+
"signIn.submitting": string;
|
|
38
|
+
"signIn.continueWithGoogle": string;
|
|
39
|
+
"signIn.continueWithMagicLink": string;
|
|
40
|
+
"signIn.continueWithPasskey": string;
|
|
41
|
+
"signIn.forgotPassword": string;
|
|
42
|
+
"signIn.noAccount": string;
|
|
43
|
+
"signIn.signUp": string;
|
|
44
|
+
"signIn.resumingSession": string;
|
|
45
|
+
"signIn.useDifferentAccount": string;
|
|
46
|
+
"signIn.selectTenant": string;
|
|
47
|
+
"signIn.selectTenantSubtitle": string;
|
|
48
|
+
"signIn.dividerOr": string;
|
|
49
|
+
"signIn.preparingExperience": string;
|
|
50
|
+
"signIn.applicationUnavailable": string;
|
|
51
|
+
"signIn.applicationNotFound": string;
|
|
52
|
+
"signIn.invalidRedirect": string;
|
|
53
|
+
"signIn.returnUrlNotRegistered": string;
|
|
54
|
+
"signIn.welcomeBackName": string;
|
|
55
|
+
"signIn.oneMomentResume": string;
|
|
56
|
+
"signIn.notYouUseDifferent": string;
|
|
57
|
+
"signIn.chooseWorkspace": string;
|
|
58
|
+
"signIn.pickTenantToSignIn": string;
|
|
59
|
+
"signIn.subtitleHosted": string;
|
|
60
|
+
"signIn.createAccount": string;
|
|
61
|
+
"signIn.couldntResume": string;
|
|
62
|
+
"signUp.title": string;
|
|
63
|
+
"signUp.subtitle": string;
|
|
64
|
+
"signUp.nameLabel": string;
|
|
65
|
+
"signUp.namePlaceholder": string;
|
|
66
|
+
"signUp.emailLabel": string;
|
|
67
|
+
"signUp.passwordLabel": string;
|
|
68
|
+
"signUp.passwordHint": string;
|
|
69
|
+
"signUp.submit": string;
|
|
70
|
+
"signUp.submitting": string;
|
|
71
|
+
"signUp.haveAccount": string;
|
|
72
|
+
"signUp.signIn": string;
|
|
73
|
+
"signUp.tenantNameLabel": string;
|
|
74
|
+
"signUp.tenantNamePlaceholder": string;
|
|
75
|
+
"signUp.legal": string;
|
|
76
|
+
"forgotPassword.title": string;
|
|
77
|
+
"forgotPassword.subtitle": string;
|
|
78
|
+
"forgotPassword.submit": string;
|
|
79
|
+
"forgotPassword.submitting": string;
|
|
80
|
+
"forgotPassword.sent": string;
|
|
81
|
+
"forgotPassword.backToSignIn": string;
|
|
82
|
+
"resetPassword.title": string;
|
|
83
|
+
"resetPassword.newPasswordLabel": string;
|
|
84
|
+
"resetPassword.confirmPasswordLabel": string;
|
|
85
|
+
"resetPassword.submit": string;
|
|
86
|
+
"resetPassword.submitting": string;
|
|
87
|
+
"resetPassword.success": string;
|
|
88
|
+
"resetPassword.mismatch": string;
|
|
89
|
+
"mfa.title": string;
|
|
90
|
+
"mfa.subtitle": string;
|
|
91
|
+
"mfa.totpLabel": string;
|
|
92
|
+
"mfa.totpPlaceholder": string;
|
|
93
|
+
"mfa.smsLabel": string;
|
|
94
|
+
"mfa.emailLabel": string;
|
|
95
|
+
"mfa.submit": string;
|
|
96
|
+
"mfa.submitting": string;
|
|
97
|
+
"mfa.useBackupCode": string;
|
|
98
|
+
"mfa.useAuthenticator": string;
|
|
99
|
+
"mfa.useSms": string;
|
|
100
|
+
"mfa.useEmail": string;
|
|
101
|
+
"mfa.resend": string;
|
|
102
|
+
"mfa.resent": string;
|
|
103
|
+
"mfa.backupCodeLabel": string;
|
|
104
|
+
"userButton.signedInAs": string;
|
|
105
|
+
"userButton.manageAccount": string;
|
|
106
|
+
"userButton.switchOrg": string;
|
|
107
|
+
"userButton.signOut": string;
|
|
108
|
+
"userProfile.title": string;
|
|
109
|
+
"userProfile.profileTab": string;
|
|
110
|
+
"userProfile.securityTab": string;
|
|
111
|
+
"userProfile.sessionsTab": string;
|
|
112
|
+
"userProfile.linkedAccountsTab": string;
|
|
113
|
+
"userProfile.changeName": string;
|
|
114
|
+
"userProfile.changeEmail": string;
|
|
115
|
+
"userProfile.changePassword": string;
|
|
116
|
+
"userProfile.currentPassword": string;
|
|
117
|
+
"userProfile.newPassword": string;
|
|
118
|
+
"userProfile.confirmPassword": string;
|
|
119
|
+
"userProfile.passwordUpdated": string;
|
|
120
|
+
"userProfile.mfaSection": string;
|
|
121
|
+
"userProfile.mfaEnable": string;
|
|
122
|
+
"userProfile.mfaDisable": string;
|
|
123
|
+
"userProfile.sessionsSection": string;
|
|
124
|
+
"userProfile.revokeSession": string;
|
|
125
|
+
"userProfile.revokeAllOthers": string;
|
|
126
|
+
"userProfile.thisDevice": string;
|
|
127
|
+
"userProfile.sessionsEmpty": string;
|
|
128
|
+
"userProfile.linkedAccountsEmpty": string;
|
|
129
|
+
"userProfile.connectGoogle": string;
|
|
130
|
+
"userProfile.disconnect": string;
|
|
131
|
+
"orgSwitcher.label": string;
|
|
132
|
+
"orgSwitcher.personal": string;
|
|
133
|
+
"orgSwitcher.createNew": string;
|
|
134
|
+
"orgSwitcher.manage": string;
|
|
135
|
+
"orgSwitcher.noOrgs": string;
|
|
136
|
+
"orgProfile.title": string;
|
|
137
|
+
"orgProfile.generalTab": string;
|
|
138
|
+
"orgProfile.membersTab": string;
|
|
139
|
+
"orgProfile.invitationsTab": string;
|
|
140
|
+
"orgProfile.dangerTab": string;
|
|
141
|
+
"orgProfile.invite": string;
|
|
142
|
+
"orgProfile.inviteEmailLabel": string;
|
|
143
|
+
"orgProfile.inviteRoleLabel": string;
|
|
144
|
+
"orgProfile.inviteSend": string;
|
|
145
|
+
"orgProfile.inviteSent": string;
|
|
146
|
+
"orgProfile.removeMember": string;
|
|
147
|
+
"orgProfile.deleteOrg": string;
|
|
148
|
+
"orgProfile.deleteOrgConfirm": string;
|
|
149
|
+
"createOrg.title": string;
|
|
150
|
+
"createOrg.nameLabel": string;
|
|
151
|
+
"createOrg.submit": string;
|
|
152
|
+
"createOrg.submitting": string;
|
|
153
|
+
"waitlist.title": string;
|
|
154
|
+
"waitlist.subtitle": string;
|
|
155
|
+
"waitlist.submit": string;
|
|
156
|
+
"waitlist.submitting": string;
|
|
157
|
+
"waitlist.success": string;
|
|
158
|
+
"impersonation.banner": string;
|
|
159
|
+
"impersonation.exit": string;
|
|
160
|
+
"magicLink.title": string;
|
|
161
|
+
"magicLink.subtitle": string;
|
|
162
|
+
"magicLink.resend": string;
|
|
163
|
+
"magicLink.changeEmail": string;
|
|
164
|
+
"errors.generic": string;
|
|
165
|
+
"errors.network": string;
|
|
166
|
+
"errors.invalidCredentials": string;
|
|
167
|
+
"errors.userNotFound": string;
|
|
168
|
+
"errors.emailInUse": string;
|
|
169
|
+
"errors.weakPassword": string;
|
|
170
|
+
"errors.mfaInvalid": string;
|
|
171
|
+
"errors.mfaExpired": string;
|
|
172
|
+
"errors.tooManyAttempts": string;
|
|
173
|
+
"errors.sessionExpired": string;
|
|
174
|
+
"errors.permissionDenied": string;
|
|
175
|
+
"errors.notFound": string;
|
|
176
|
+
"errors.serverError": string;
|
|
177
|
+
"errors.invalidEmail": string;
|
|
178
|
+
"errors.passwordTooShort": string;
|
|
179
|
+
"errors.required": string;
|
|
180
|
+
"errors.invitationInvalid": string;
|
|
181
|
+
"validation.emailRequired": string;
|
|
182
|
+
"validation.emailInvalid": string;
|
|
183
|
+
"validation.passwordRequired": string;
|
|
184
|
+
"validation.nameRequired": string;
|
|
185
|
+
"validation.codeRequired": string;
|
|
186
|
+
"validation.codeInvalid": string;
|
|
187
|
+
}
|
|
188
|
+
type IQAuthLocaleKey = keyof Omit<IQAuthLocaleBundle, "locale">;
|
|
189
|
+
/**
|
|
190
|
+
* A partial bundle (used for the `localization` prop on IQAuthProvider) that
|
|
191
|
+
* may override a subset of keys; missing keys fall back to the default
|
|
192
|
+
* (en-US) bundle.
|
|
193
|
+
*/
|
|
194
|
+
type IQAuthLocaleOverride = Partial<IQAuthLocaleBundle>;
|
|
195
|
+
|
|
196
|
+
export type { IQAuthLocaleBundle as I, IQAuthLocaleOverride as a, IQAuthLocaleKey as b };
|