@fluixi/oauth2 1.0.0-alpha.107 → 1.0.0-alpha.109

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