@fluixi/oauth2 1.0.0-alpha.11 → 1.0.0-alpha.111
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/dist/api-guard.cjs +8 -3
- package/dist/api-guard.mjs +9 -135
- package/dist/backchannel.cjs +467 -0
- package/dist/backchannel.d.ts +39 -0
- package/dist/backchannel.d.ts.map +1 -0
- package/dist/backchannel.js +97 -0
- package/dist/backchannel.mjs +19 -0
- package/dist/browser.cjs +6 -1
- package/dist/browser.mjs +10 -702
- package/dist/callback.cjs +2 -2
- package/dist/callback.d.ts +2 -2
- package/dist/callback.js +3 -3
- package/dist/callback.mjs +17 -24
- package/dist/{dpop-YPGCGL7S.mjs → chunk-27BGFJIY.mjs} +6 -6
- package/dist/chunk-2GLWT7XH.mjs +143 -0
- package/dist/chunk-3EICMAF7.mjs +22 -0
- package/dist/chunk-4OHJTTX7.mjs +398 -0
- package/dist/chunk-4QRYJ4TN.mjs +86 -0
- package/dist/chunk-5WX3EV2W.mjs +78 -0
- package/dist/chunk-7AMC336S.mjs +52 -0
- package/dist/chunk-AAN3YN4S.mjs +63 -0
- package/dist/chunk-AWVECOG7.mjs +404 -0
- package/dist/chunk-GN5SERAQ.mjs +189 -0
- package/dist/chunk-KIXTZEEW.mjs +80 -0
- package/dist/chunk-KVW2S6VY.mjs +36 -0
- package/dist/chunk-MHWZTXZZ.mjs +9 -0
- package/dist/chunk-QC2FFASM.mjs +67 -0
- package/dist/chunk-SJOBQPG6.mjs +77 -0
- package/dist/chunk-VCNXQCIH.mjs +26 -0
- package/dist/chunk-XQJTQV3C.mjs +91 -0
- package/dist/client-auth.mjs +6 -78
- package/dist/discovery.cjs +6 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +6 -1
- package/dist/discovery.mjs +6 -59
- package/dist/dpop-store.mjs +6 -118
- package/dist/dpop.mjs +11 -95
- package/dist/env-config.cjs +1 -1
- package/dist/env-config.mjs +5 -214
- package/dist/env-credentials.mjs +5 -47
- package/dist/index.cjs +108 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +50 -912
- package/dist/module.cjs +1 -1
- package/dist/module.mjs +5 -20
- package/dist/pkce.mjs +11 -56
- package/dist/presets.cjs +1 -1
- package/dist/presets.mjs +5 -214
- package/dist/return-to.mjs +4 -22
- package/dist/roles.cjs +1 -1
- package/dist/roles.d.ts +1 -1
- package/dist/roles.js +1 -1
- package/dist/roles.mjs +4 -32
- package/dist/server-client.mjs +7 -107
- package/dist/server.cjs +795 -153
- package/dist/server.d.ts +85 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +577 -75
- package/dist/server.mjs +442 -310
- package/dist/service-client.cjs +7 -2
- package/dist/service-client.mjs +16 -133
- package/dist/service.cjs +104 -5
- package/dist/service.d.ts +1 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +38 -6
- package/dist/service.mjs +14 -879
- package/dist/session-monitor.cjs +98 -0
- package/dist/session-monitor.d.ts +32 -0
- package/dist/session-monitor.d.ts.map +1 -0
- package/dist/session-monitor.js +104 -0
- package/dist/session-monitor.mjs +7 -0
- package/dist/tokens.cjs +1 -1
- package/dist/tokens.d.ts +2 -2
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +1 -1
- package/dist/tokens.mjs +5 -4
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.mjs +4 -9
- package/dist/verify.cjs +15 -5
- package/dist/verify.d.ts +2 -2
- package/dist/verify.js +2 -2
- package/dist/verify.mjs +17 -580
- package/package.json +23 -17
- package/dist/browser-N432SMC3.mjs +0 -3545
- package/dist/chunk-4TPZVJSR.mjs +0 -10
- package/dist/chunk-ZVDC3JW7.mjs +0 -15
- package/dist/dpop-DYUR2CH2.mjs +0 -100
- /package/dist/{chunk-OGSFNTKA.mjs → chunk-AXPSPTNP.mjs} +0 -0
package/dist/chunk-4TPZVJSR.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*! @fluixi/oauth2 v1.0.0-alpha.11 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
for (var name in all)
|
|
5
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
__export
|
|
10
|
-
};
|
package/dist/chunk-ZVDC3JW7.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*! @fluixi/oauth2 v1.0.0-alpha.11 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
-
|
|
3
|
-
// src/types.ts
|
|
4
|
-
var OAuthError = class extends Error {
|
|
5
|
-
constructor(message, code, description) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.code = code;
|
|
8
|
-
this.description = description;
|
|
9
|
-
this.name = "OAuthError";
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
OAuthError
|
|
15
|
-
};
|
package/dist/dpop-DYUR2CH2.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/*! @fluixi/oauth2 v1.0.0-alpha.11 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
-
import {
|
|
3
|
-
OAuthError
|
|
4
|
-
} from "./chunk-ZVDC3JW7.mjs";
|
|
5
|
-
import "./chunk-4TPZVJSR.mjs";
|
|
6
|
-
|
|
7
|
-
// src/dpop.ts
|
|
8
|
-
async function loadJose() {
|
|
9
|
-
try {
|
|
10
|
-
return await import("./browser-N432SMC3.mjs");
|
|
11
|
-
} catch {
|
|
12
|
-
throw new OAuthError(
|
|
13
|
-
"DPoP needs `jose`. Install it: npm i jose. It is an optional peer, so a client not using DPoP does not carry it.",
|
|
14
|
-
"jose_missing"
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async function createDpopKey(alg = "ES256", options = {}) {
|
|
19
|
-
const jose = await loadJose();
|
|
20
|
-
const { privateKey, publicKey } = await jose.generateKeyPair(alg, {
|
|
21
|
-
extractable: options.extractable ?? false
|
|
22
|
-
});
|
|
23
|
-
const publicJwk = { ...await jose.exportJWK(publicKey) };
|
|
24
|
-
return {
|
|
25
|
-
privateKey,
|
|
26
|
-
publicJwk,
|
|
27
|
-
thumbprint: await jose.calculateJwkThumbprint(publicJwk, "sha256"),
|
|
28
|
-
alg
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
async function exportDpopKey(key) {
|
|
32
|
-
const jose = await loadJose();
|
|
33
|
-
return { jwk: { ...await jose.exportJWK(key.privateKey) }, alg: key.alg };
|
|
34
|
-
}
|
|
35
|
-
var PRIVATE_MEMBERS = /* @__PURE__ */ new Set(["d", "p", "q", "dp", "dq", "qi", "oth"]);
|
|
36
|
-
async function importDpopKey(stored) {
|
|
37
|
-
const jose = await loadJose();
|
|
38
|
-
const privateKey = await jose.importJWK(stored.jwk, stored.alg);
|
|
39
|
-
const publicJwk = Object.fromEntries(Object.entries(stored.jwk).filter(([k]) => !PRIVATE_MEMBERS.has(k)));
|
|
40
|
-
return {
|
|
41
|
-
privateKey,
|
|
42
|
-
publicJwk,
|
|
43
|
-
thumbprint: await jose.calculateJwkThumbprint(publicJwk, "sha256"),
|
|
44
|
-
alg: stored.alg
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
async function thumbprintOf(jwk) {
|
|
48
|
-
const jose = await loadJose();
|
|
49
|
-
return jose.calculateJwkThumbprint(jwk, "sha256");
|
|
50
|
-
}
|
|
51
|
-
async function proofFor(key, options) {
|
|
52
|
-
const jose = await loadJose();
|
|
53
|
-
const htu = (() => {
|
|
54
|
-
try {
|
|
55
|
-
const url = new URL(options.url);
|
|
56
|
-
url.search = "";
|
|
57
|
-
url.hash = "";
|
|
58
|
-
return url.toString();
|
|
59
|
-
} catch {
|
|
60
|
-
return options.url;
|
|
61
|
-
}
|
|
62
|
-
})();
|
|
63
|
-
const claims = {
|
|
64
|
-
htm: options.method.toUpperCase(),
|
|
65
|
-
htu,
|
|
66
|
-
jti: crypto.randomUUID()
|
|
67
|
-
};
|
|
68
|
-
if (options.accessToken) {
|
|
69
|
-
const digest = await crypto.subtle.digest(
|
|
70
|
-
"SHA-256",
|
|
71
|
-
new TextEncoder().encode(options.accessToken)
|
|
72
|
-
);
|
|
73
|
-
let binary = "";
|
|
74
|
-
for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
|
|
75
|
-
claims.ath = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
76
|
-
}
|
|
77
|
-
if (options.nonce) claims.nonce = options.nonce;
|
|
78
|
-
return new jose.SignJWT(claims).setProtectedHeader({ typ: "dpop+jwt", alg: key.alg, jwk: key.publicJwk }).setIssuedAt().sign(key.privateKey);
|
|
79
|
-
}
|
|
80
|
-
function nonceFrom(response) {
|
|
81
|
-
return response.headers.get("dpop-nonce");
|
|
82
|
-
}
|
|
83
|
-
function wantsNonce(error, response) {
|
|
84
|
-
const code = typeof error === "string" ? error : error?.error;
|
|
85
|
-
return code === "use_dpop_nonce" || !!response && !!nonceFrom(response);
|
|
86
|
-
}
|
|
87
|
-
function boundKeyOf(claims) {
|
|
88
|
-
const cnf = claims.cnf;
|
|
89
|
-
return typeof cnf?.jkt === "string" ? cnf.jkt : null;
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
boundKeyOf,
|
|
93
|
-
createDpopKey,
|
|
94
|
-
exportDpopKey,
|
|
95
|
-
importDpopKey,
|
|
96
|
-
nonceFrom,
|
|
97
|
-
proofFor,
|
|
98
|
-
thumbprintOf,
|
|
99
|
-
wantsNonce
|
|
100
|
-
};
|
|
File without changes
|