@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.
Files changed (92) hide show
  1. package/dist/api-guard.cjs +8 -3
  2. package/dist/api-guard.mjs +9 -135
  3. package/dist/backchannel.cjs +467 -0
  4. package/dist/backchannel.d.ts +39 -0
  5. package/dist/backchannel.d.ts.map +1 -0
  6. package/dist/backchannel.js +97 -0
  7. package/dist/backchannel.mjs +19 -0
  8. package/dist/browser.cjs +6 -1
  9. package/dist/browser.mjs +10 -702
  10. package/dist/callback.cjs +2 -2
  11. package/dist/callback.d.ts +2 -2
  12. package/dist/callback.js +3 -3
  13. package/dist/callback.mjs +17 -24
  14. package/dist/{dpop-YPGCGL7S.mjs → chunk-27BGFJIY.mjs} +6 -6
  15. package/dist/chunk-2GLWT7XH.mjs +143 -0
  16. package/dist/chunk-3EICMAF7.mjs +22 -0
  17. package/dist/chunk-4OHJTTX7.mjs +398 -0
  18. package/dist/chunk-4QRYJ4TN.mjs +86 -0
  19. package/dist/chunk-5WX3EV2W.mjs +78 -0
  20. package/dist/chunk-7AMC336S.mjs +52 -0
  21. package/dist/chunk-AAN3YN4S.mjs +63 -0
  22. package/dist/chunk-AWVECOG7.mjs +404 -0
  23. package/dist/chunk-GN5SERAQ.mjs +189 -0
  24. package/dist/chunk-KIXTZEEW.mjs +80 -0
  25. package/dist/chunk-KVW2S6VY.mjs +36 -0
  26. package/dist/chunk-MHWZTXZZ.mjs +9 -0
  27. package/dist/chunk-QC2FFASM.mjs +67 -0
  28. package/dist/chunk-SJOBQPG6.mjs +77 -0
  29. package/dist/chunk-VCNXQCIH.mjs +26 -0
  30. package/dist/chunk-XQJTQV3C.mjs +91 -0
  31. package/dist/client-auth.mjs +6 -78
  32. package/dist/discovery.cjs +6 -1
  33. package/dist/discovery.d.ts.map +1 -1
  34. package/dist/discovery.js +6 -1
  35. package/dist/discovery.mjs +6 -59
  36. package/dist/dpop-store.mjs +6 -118
  37. package/dist/dpop.mjs +11 -95
  38. package/dist/env-config.cjs +1 -1
  39. package/dist/env-config.mjs +5 -214
  40. package/dist/env-credentials.mjs +5 -47
  41. package/dist/index.cjs +108 -8
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +1 -0
  45. package/dist/index.mjs +50 -912
  46. package/dist/module.cjs +1 -1
  47. package/dist/module.mjs +5 -20
  48. package/dist/pkce.mjs +11 -56
  49. package/dist/presets.cjs +1 -1
  50. package/dist/presets.mjs +5 -214
  51. package/dist/return-to.mjs +4 -22
  52. package/dist/roles.cjs +1 -1
  53. package/dist/roles.d.ts +1 -1
  54. package/dist/roles.js +1 -1
  55. package/dist/roles.mjs +4 -32
  56. package/dist/server-client.mjs +7 -107
  57. package/dist/server.cjs +795 -153
  58. package/dist/server.d.ts +85 -4
  59. package/dist/server.d.ts.map +1 -1
  60. package/dist/server.js +577 -75
  61. package/dist/server.mjs +442 -310
  62. package/dist/service-client.cjs +7 -2
  63. package/dist/service-client.mjs +16 -133
  64. package/dist/service.cjs +104 -5
  65. package/dist/service.d.ts +1 -1
  66. package/dist/service.d.ts.map +1 -1
  67. package/dist/service.js +38 -6
  68. package/dist/service.mjs +14 -879
  69. package/dist/session-monitor.cjs +98 -0
  70. package/dist/session-monitor.d.ts +32 -0
  71. package/dist/session-monitor.d.ts.map +1 -0
  72. package/dist/session-monitor.js +104 -0
  73. package/dist/session-monitor.mjs +7 -0
  74. package/dist/tokens.cjs +1 -1
  75. package/dist/tokens.d.ts +2 -2
  76. package/dist/tokens.d.ts.map +1 -1
  77. package/dist/tokens.js +1 -1
  78. package/dist/tokens.mjs +5 -4
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/types.d.ts +8 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/types.mjs +4 -9
  83. package/dist/verify.cjs +15 -5
  84. package/dist/verify.d.ts +2 -2
  85. package/dist/verify.js +2 -2
  86. package/dist/verify.mjs +17 -580
  87. package/package.json +23 -17
  88. package/dist/browser-N432SMC3.mjs +0 -3545
  89. package/dist/chunk-4TPZVJSR.mjs +0 -10
  90. package/dist/chunk-ZVDC3JW7.mjs +0 -15
  91. package/dist/dpop-DYUR2CH2.mjs +0 -100
  92. /package/dist/{chunk-OGSFNTKA.mjs → chunk-AXPSPTNP.mjs} +0 -0
@@ -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
- };
@@ -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
- };
@@ -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