@suveren/gateway 0.7.4 → 0.8.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.
Files changed (264) hide show
  1. package/content/integrations/mollie.json +103 -28
  2. package/dist/control-plane/index.mjs +248 -58
  3. package/dist/mcp-server/http.mjs +577 -124
  4. package/dist/ui/assets/index-BFnSVa9N.js +110 -0
  5. package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
  6. package/dist/ui/index.html +2 -2
  7. package/node_modules/@hap/core/dist/index.d.mts +285 -13
  8. package/node_modules/@hap/core/dist/index.d.ts +285 -13
  9. package/node_modules/@hap/core/dist/index.js +281 -13
  10. package/node_modules/@hap/core/dist/index.mjs +266 -12
  11. package/node_modules/@hap/core/package.json +4 -2
  12. package/node_modules/@hap/core/src/did-key.ts +126 -0
  13. package/node_modules/@hap/core/src/frame.ts +115 -14
  14. package/node_modules/@hap/core/src/gatekeeper.ts +26 -0
  15. package/node_modules/@hap/core/src/identity.ts +21 -5
  16. package/node_modules/@hap/core/src/index.ts +3 -0
  17. package/node_modules/@hap/core/src/mandate.ts +207 -0
  18. package/node_modules/@hap/core/src/receipt.ts +74 -0
  19. package/node_modules/@hap/core/src/types.ts +87 -5
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  29. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  30. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  31. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
  32. package/node_modules/@types/node/README.md +1 -1
  33. package/node_modules/@types/node/buffer.buffer.d.ts +10 -5
  34. package/node_modules/@types/node/crypto.d.ts +2 -4
  35. package/node_modules/@types/node/dgram.d.ts +119 -4
  36. package/node_modules/@types/node/ffi.d.ts +1 -1
  37. package/node_modules/@types/node/fs/promises.d.ts +61 -65
  38. package/node_modules/@types/node/fs.d.ts +86 -76
  39. package/node_modules/@types/node/http.d.ts +17 -1
  40. package/node_modules/@types/node/http2.d.ts +12 -4
  41. package/node_modules/@types/node/index.d.ts +1 -0
  42. package/node_modules/@types/node/inspector.d.ts +2 -1
  43. package/node_modules/@types/node/net.d.ts +108 -16
  44. package/node_modules/@types/node/package.json +2 -2
  45. package/node_modules/@types/node/process.d.ts +52 -0
  46. package/node_modules/@types/node/quic.d.ts +246 -38
  47. package/node_modules/@types/node/sqlite.d.ts +6 -2
  48. package/node_modules/@types/node/stream/iter.d.ts +4 -4
  49. package/node_modules/@types/node/test.d.ts +36 -0
  50. package/node_modules/@types/node/tls.d.ts +24 -0
  51. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +5 -0
  52. package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
  53. package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
  54. package/node_modules/@types/node/tty.d.ts +4 -3
  55. package/node_modules/@types/node/vfs.d.ts +210 -0
  56. package/node_modules/@types/node/vm.d.ts +1 -1
  57. package/node_modules/express-rate-limit/dist/index.cjs +6 -3
  58. package/node_modules/express-rate-limit/dist/index.d.cts +11 -0
  59. package/node_modules/express-rate-limit/dist/index.d.mts +11 -0
  60. package/node_modules/express-rate-limit/dist/index.d.ts +11 -0
  61. package/node_modules/express-rate-limit/dist/index.mjs +6 -3
  62. package/node_modules/express-rate-limit/{license.md → license} +7 -6
  63. package/node_modules/express-rate-limit/package.json +5 -5
  64. package/node_modules/express-rate-limit/readme.md +1 -0
  65. package/node_modules/fast-uri/index.js +215 -47
  66. package/node_modules/fast-uri/lib/schemes.js +9 -4
  67. package/node_modules/fast-uri/lib/utils.js +396 -92
  68. package/node_modules/fast-uri/package.json +1 -1
  69. package/node_modules/fast-uri/test/component-safe-serialization.test.js +163 -0
  70. package/node_modules/fast-uri/test/equal.test.js +31 -3
  71. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  72. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  73. package/node_modules/fast-uri/test/ipv6-validation.test.js +124 -0
  74. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  75. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  76. package/node_modules/fast-uri/test/parse.test.js +7 -3
  77. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  78. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  79. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  80. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  81. package/node_modules/fast-uri/test/security.test.js +75 -3
  82. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  83. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  84. package/node_modules/hono/dist/cjs/client/client.js +25 -11
  85. package/node_modules/hono/dist/cjs/client/utils.js +4 -1
  86. package/node_modules/hono/dist/cjs/context.js +4 -0
  87. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
  88. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
  89. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
  90. package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
  91. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  92. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  93. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  94. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  95. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
  96. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  97. package/node_modules/hono/dist/cjs/request.js +8 -4
  98. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  99. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  100. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
  101. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
  102. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
  103. package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
  104. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  105. package/node_modules/hono/dist/cjs/router/utils.js +27 -0
  106. package/node_modules/hono/dist/cjs/utils/body.js +15 -3
  107. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  108. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  109. package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
  110. package/node_modules/hono/dist/cjs/utils/url.js +9 -1
  111. package/node_modules/hono/dist/client/client.js +25 -11
  112. package/node_modules/hono/dist/client/utils.js +4 -1
  113. package/node_modules/hono/dist/context.js +4 -0
  114. package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
  115. package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
  116. package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
  117. package/node_modules/hono/dist/jsx/dom/render.js +2 -0
  118. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  119. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  120. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  121. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  122. package/node_modules/hono/dist/middleware/etag/index.js +3 -3
  123. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  124. package/node_modules/hono/dist/request.js +8 -4
  125. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  126. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  127. package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
  128. package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
  129. package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
  130. package/node_modules/hono/dist/router/trie-router/node.js +46 -69
  131. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  132. package/node_modules/hono/dist/router/utils.js +5 -0
  133. package/node_modules/hono/dist/types/context.d.ts +4 -0
  134. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
  135. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  136. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  137. package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
  138. package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
  139. package/node_modules/hono/dist/utils/body.js +15 -3
  140. package/node_modules/hono/dist/utils/cookie.js +1 -1
  141. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  142. package/node_modules/hono/dist/utils/stream.js +7 -1
  143. package/node_modules/hono/dist/utils/url.js +9 -1
  144. package/node_modules/hono/package.json +1 -1
  145. package/node_modules/ip-address/README.md +92 -82
  146. package/node_modules/ip-address/dist/common.d.ts +20 -0
  147. package/node_modules/ip-address/dist/common.js +36 -0
  148. package/node_modules/ip-address/dist/common.js.map +1 -1
  149. package/node_modules/ip-address/dist/ipv4.d.ts +50 -0
  150. package/node_modules/ip-address/dist/ipv4.js +75 -0
  151. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  152. package/node_modules/ip-address/dist/ipv6.d.ts +79 -10
  153. package/node_modules/ip-address/dist/ipv6.js +120 -30
  154. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  155. package/node_modules/ip-address/dist/v4/constants.d.ts +12 -0
  156. package/node_modules/ip-address/dist/v4/constants.js +40 -1
  157. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  158. package/node_modules/ip-address/dist/v6/constants.d.ts +14 -0
  159. package/node_modules/ip-address/dist/v6/constants.js +47 -1
  160. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  161. package/node_modules/ip-address/package.json +1 -1
  162. package/node_modules/is-plain-object/README.md +39 -95
  163. package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
  164. package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
  165. package/node_modules/is-plain-object/package.json +8 -34
  166. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +7 -16
  167. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +10 -20
  168. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +7 -16
  169. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +16 -38
  170. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +7 -16
  171. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +19 -38
  172. package/node_modules/jose/dist/types/jwk/embedded.d.ts +3 -8
  173. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +5 -5
  174. package/node_modules/jose/dist/types/jwks/local.d.ts +6 -10
  175. package/node_modules/jose/dist/types/jwks/remote.d.ts +17 -28
  176. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -10
  177. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +9 -18
  178. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +7 -16
  179. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +9 -18
  180. package/node_modules/jose/dist/types/jws/general/sign.d.ts +11 -21
  181. package/node_modules/jose/dist/types/jws/general/verify.d.ts +12 -21
  182. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +10 -20
  183. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +17 -29
  184. package/node_modules/jose/dist/types/jwt/sign.d.ts +12 -19
  185. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +17 -28
  186. package/node_modules/jose/dist/types/jwt/verify.d.ts +9 -19
  187. package/node_modules/jose/dist/types/key/export.d.ts +4 -4
  188. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +6 -8
  189. package/node_modules/jose/dist/types/key/generate_secret.d.ts +4 -11
  190. package/node_modules/jose/dist/types/key/import.d.ts +10 -17
  191. package/node_modules/jose/dist/types/types.d.ts +48 -86
  192. package/node_modules/jose/dist/types/util/base64url.d.ts +2 -2
  193. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +3 -10
  194. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +4 -4
  195. package/node_modules/jose/dist/types/util/errors.d.ts +26 -53
  196. package/node_modules/jose/dist/webapi/index.js +70 -32
  197. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +7 -8
  198. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +42 -26
  199. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +14 -10
  200. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +53 -71
  201. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +38 -49
  202. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +121 -158
  203. package/node_modules/jose/dist/webapi/jwk/embedded.js +30 -18
  204. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +54 -64
  205. package/node_modules/jose/dist/webapi/jwks/local.js +49 -74
  206. package/node_modules/jose/dist/webapi/jwks/remote.js +91 -160
  207. package/node_modules/jose/dist/webapi/jws/compact/sign.js +21 -20
  208. package/node_modules/jose/dist/webapi/jws/compact/verify.js +7 -8
  209. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +29 -30
  210. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +21 -23
  211. package/node_modules/jose/dist/webapi/jws/general/sign.js +61 -70
  212. package/node_modules/jose/dist/webapi/jws/general/verify.js +47 -41
  213. package/node_modules/jose/dist/webapi/jwt/decrypt.js +13 -22
  214. package/node_modules/jose/dist/webapi/jwt/encrypt.js +58 -100
  215. package/node_modules/jose/dist/webapi/jwt/sign.js +18 -50
  216. package/node_modules/jose/dist/webapi/jwt/unsecured.js +34 -63
  217. package/node_modules/jose/dist/webapi/jwt/verify.js +12 -14
  218. package/node_modules/jose/dist/webapi/key/export.js +32 -37
  219. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +40 -44
  220. package/node_modules/jose/dist/webapi/key/generate_secret.js +35 -39
  221. package/node_modules/jose/dist/webapi/key/import.js +52 -52
  222. package/node_modules/jose/dist/webapi/lib/asn1.js +130 -164
  223. package/node_modules/jose/dist/webapi/lib/base64.js +18 -20
  224. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +34 -38
  225. package/node_modules/jose/dist/webapi/lib/content_encryption.js +79 -123
  226. package/node_modules/jose/dist/webapi/lib/crypto_key.js +24 -25
  227. package/node_modules/jose/dist/webapi/lib/deflate.js +46 -40
  228. package/node_modules/jose/dist/webapi/lib/helpers.js +40 -37
  229. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +10 -24
  230. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -15
  231. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +106 -93
  232. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +210 -176
  233. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +105 -107
  234. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +19 -0
  235. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +9 -16
  236. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +62 -61
  237. package/node_modules/jose/dist/webapi/lib/jws_sign.js +58 -72
  238. package/node_modules/jose/dist/webapi/lib/jws_verify.js +90 -103
  239. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +134 -185
  240. package/node_modules/jose/dist/webapi/lib/key.js +84 -121
  241. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +13 -8
  242. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +8 -6
  243. package/node_modules/jose/dist/webapi/lib/key_management.js +200 -225
  244. package/node_modules/jose/dist/webapi/lib/key_options.js +8 -0
  245. package/node_modules/jose/dist/webapi/lib/options.js +57 -44
  246. package/node_modules/jose/dist/webapi/lib/signing.js +18 -22
  247. package/node_modules/jose/dist/webapi/lib/type_checks.js +28 -33
  248. package/node_modules/jose/dist/webapi/util/base64url.js +26 -35
  249. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -31
  250. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +18 -23
  251. package/node_modules/jose/dist/webapi/util/errors.js +94 -84
  252. package/node_modules/jose/package.json +17 -81
  253. package/package.json +2 -2
  254. package/profiles/calendar/0.5.profile.json +190 -0
  255. package/profiles/charge/0.5.profile.json +210 -0
  256. package/profiles/customers/0.7.profile.json +157 -0
  257. package/profiles/deploy/0.9.profile.json +176 -0
  258. package/profiles/email/0.6.profile.json +208 -0
  259. package/profiles/index.json +9 -1
  260. package/profiles/publish/0.5.profile.json +186 -0
  261. package/profiles/purchase/0.5.profile.json +231 -0
  262. package/profiles/records/0.5.profile.json +117 -0
  263. package/dist/ui/assets/index-0Q2eNytX.js +0 -110
  264. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
@@ -1,170 +1,101 @@
1
- import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from '../util/errors.js';
2
- import { createLocalJWKSet } from './local.js';
3
- import { isObject } from '../lib/type_checks.js';
1
+ import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from "../util/errors.js";
2
+ import { createLocalJWKSet } from "./local.js";
3
+ import { isJwkSet } from "../lib/type_checks.js";
4
4
  function isCloudflareWorkers() {
5
- return (typeof WebSocketPair !== 'undefined' ||
6
- (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
7
- (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
5
+ return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
8
6
  }
9
7
  let USER_AGENT;
10
- if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
11
- const NAME = 'jose';
12
- const VERSION = 'v6.2.8';
13
- USER_AGENT = `${NAME}/${VERSION}`;
14
- }
15
- export const customFetch = Symbol();
8
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.11");
9
+ const customFetch = /* @__PURE__ */ Symbol();
16
10
  async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
17
- const response = await fetchImpl(url, {
18
- method: 'GET',
19
- signal,
20
- redirect: 'manual',
21
- headers,
22
- }).catch((err) => {
23
- if (err.name === 'TimeoutError') {
24
- throw new JWKSTimeout();
25
- }
26
- throw err;
27
- });
28
- if (response.status !== 200) {
29
- throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');
30
- }
31
- try {
32
- return await response.json();
33
- }
34
- catch {
35
- throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');
36
- }
11
+ const response = await fetchImpl(url, {
12
+ method: "GET",
13
+ signal,
14
+ redirect: "manual",
15
+ headers
16
+ }).catch((err) => {
17
+ throw err.name === "TimeoutError" ? new JWKSTimeout() : err;
18
+ });
19
+ if (response.status !== 200)
20
+ throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
21
+ try {
22
+ return await response.json();
23
+ } catch {
24
+ throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
25
+ }
37
26
  }
38
- export const jwksCache = Symbol();
39
- function isFreshJwksCache(input, cacheMaxAge) {
40
- if (typeof input !== 'object' || input === null) {
41
- return false;
42
- }
43
- if (!('uat' in input) || typeof input.uat !== 'number' || Date.now() - input.uat >= cacheMaxAge) {
44
- return false;
45
- }
46
- if (!('jwks' in input) ||
47
- !isObject(input.jwks) ||
48
- !Array.isArray(input.jwks.keys) ||
49
- !Array.prototype.every.call(input.jwks.keys, isObject)) {
50
- return false;
51
- }
52
- return true;
27
+ const jwksCache = /* @__PURE__ */ Symbol();
28
+ function isFreshFor(timestamp, duration) {
29
+ return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
53
30
  }
54
- class RemoteJWKSetImpl {
55
- #url;
56
- #timeoutDuration;
57
- #cooldownDuration;
58
- #cacheMaxAge;
59
- #jwksTimestamp;
60
- #pendingFetch;
61
- #headers;
62
- #customFetch;
63
- #local;
64
- #cache;
65
- constructor(url, options) {
66
- if (!(url instanceof URL)) {
67
- throw new TypeError('url must be an instance of URL');
68
- }
69
- this.#url = new URL(url.href);
70
- const opts = options ?? {};
71
- this.#timeoutDuration = typeof opts.timeoutDuration === 'number' ? opts.timeoutDuration : 5000;
72
- this.#cooldownDuration =
73
- typeof opts.cooldownDuration === 'number' ? opts.cooldownDuration : 30000;
74
- this.#cacheMaxAge = typeof opts.cacheMaxAge === 'number' ? opts.cacheMaxAge : 600000;
75
- this.#headers = new Headers(opts.headers);
76
- if (USER_AGENT && !this.#headers.has('User-Agent')) {
77
- this.#headers.set('User-Agent', USER_AGENT);
78
- }
79
- if (!this.#headers.has('accept')) {
80
- this.#headers.set('accept', 'application/json');
81
- this.#headers.append('accept', 'application/jwk-set+json');
82
- }
83
- this.#customFetch = opts[customFetch];
84
- const cache = opts[jwksCache];
85
- if (cache !== undefined) {
86
- this.#cache = cache;
87
- if (isFreshJwksCache(cache, this.#cacheMaxAge)) {
88
- this.#jwksTimestamp = this.#cache.uat;
89
- this.#local = createLocalJWKSet(this.#cache.jwks);
90
- }
91
- }
92
- }
93
- pendingFetch() {
94
- return !!this.#pendingFetch;
95
- }
96
- #validFor(duration) {
97
- return typeof this.#jwksTimestamp === 'number' && Date.now() < this.#jwksTimestamp + duration;
98
- }
99
- coolingDown() {
100
- return this.#validFor(this.#cooldownDuration);
101
- }
102
- fresh() {
103
- return this.#validFor(this.#cacheMaxAge);
104
- }
105
- jwks() {
106
- return this.#local?.jwks();
31
+ function validateDuration(value, fallback, option) {
32
+ if (Number.isNaN(value))
33
+ throw new TypeError(`"${option}" option must not be NaN`);
34
+ return typeof value == "number" ? value : fallback;
35
+ }
36
+ function createRemoteJWKSet(url, options) {
37
+ if (!(url instanceof URL))
38
+ throw new TypeError("url must be an instance of URL");
39
+ const href = new URL(url.href).href, opts = options ?? {}, timeoutOption = opts.timeoutDuration;
40
+ if (typeof timeoutOption == "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0))
41
+ throw new TypeError('"timeoutDuration" option must be a non-negative integer');
42
+ const timeoutDuration = typeof timeoutOption == "number" ? timeoutOption : 5e3, cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration"), cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge"), headers = new Headers(opts.headers);
43
+ USER_AGENT && !headers.has("User-Agent") && headers.set("User-Agent", USER_AGENT), headers.has("accept") || headers.set("accept", "application/json, application/jwk-set+json");
44
+ const fetchImpl = opts[customFetch], cache = opts[jwksCache];
45
+ let jwksTimestamp, pendingFetch, reloadSequence = 0, appliedSequence = 0, local;
46
+ if (cache && typeof cache == "object") {
47
+ const { uat, jwks } = cache;
48
+ isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks) && (jwksTimestamp = uat, local = createLocalJWKSet(jwks));
49
+ }
50
+ const reload = async () => {
51
+ if (pendingFetch && isCloudflareWorkers() && (pendingFetch = void 0), !pendingFetch) {
52
+ const sequence = ++reloadSequence, current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
53
+ const next = createLocalJWKSet(json);
54
+ if (sequence <= appliedSequence)
55
+ return;
56
+ local = next;
57
+ const updatedAt = Date.now();
58
+ cache && (cache.uat = updatedAt, cache.jwks = json), jwksTimestamp = updatedAt, appliedSequence = sequence;
59
+ }).finally(() => {
60
+ pendingFetch === current && (pendingFetch = void 0);
61
+ });
107
62
  }
108
- async getKey(protectedHeader, token) {
109
- if (!this.#local || !this.fresh()) {
110
- await this.reload();
111
- }
112
- try {
113
- return await this.#local(protectedHeader, token);
114
- }
115
- catch (err) {
116
- if (err instanceof JWKSNoMatchingKey) {
117
- if (this.coolingDown() === false) {
118
- await this.reload();
119
- return this.#local(protectedHeader, token);
120
- }
121
- }
122
- throw err;
123
- }
63
+ await pendingFetch;
64
+ };
65
+ return Object.defineProperties(async (protectedHeader, token) => {
66
+ (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) && await reload();
67
+ try {
68
+ return await local(protectedHeader, token);
69
+ } catch (err) {
70
+ if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration))
71
+ return await reload(), local(protectedHeader, token);
72
+ throw err;
124
73
  }
125
- async reload() {
126
- if (this.#pendingFetch && isCloudflareWorkers()) {
127
- this.#pendingFetch = undefined;
128
- }
129
- this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch)
130
- .then((json) => {
131
- this.#local = createLocalJWKSet(json);
132
- if (this.#cache) {
133
- this.#cache.uat = Date.now();
134
- this.#cache.jwks = json;
135
- }
136
- this.#jwksTimestamp = Date.now();
137
- })
138
- .finally(() => {
139
- this.#pendingFetch = undefined;
140
- });
141
- await this.#pendingFetch;
74
+ }, {
75
+ coolingDown: {
76
+ get: () => isFreshFor(jwksTimestamp, cooldownDuration),
77
+ enumerable: !0
78
+ },
79
+ fresh: {
80
+ get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
81
+ enumerable: !0
82
+ },
83
+ reload: {
84
+ value: reload,
85
+ enumerable: !0
86
+ },
87
+ reloading: {
88
+ get: () => !!pendingFetch,
89
+ enumerable: !0
90
+ },
91
+ jwks: {
92
+ value: () => local?.jwks(),
93
+ enumerable: !0
142
94
  }
95
+ });
143
96
  }
144
- export function createRemoteJWKSet(url, options) {
145
- const set = new RemoteJWKSetImpl(url, options);
146
- const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
147
- Object.defineProperties(remoteJWKSet, {
148
- coolingDown: {
149
- get: () => set.coolingDown(),
150
- enumerable: true,
151
- },
152
- fresh: {
153
- get: () => set.fresh(),
154
- enumerable: true,
155
- },
156
- reload: {
157
- value: () => set.reload(),
158
- enumerable: true,
159
- },
160
- reloading: {
161
- get: () => set.pendingFetch(),
162
- enumerable: true,
163
- },
164
- jwks: {
165
- value: () => set.jwks(),
166
- enumerable: true,
167
- },
168
- });
169
- return remoteJWKSet;
170
- }
97
+ export {
98
+ createRemoteJWKSet,
99
+ customFetch,
100
+ jwksCache
101
+ };
@@ -1,21 +1,22 @@
1
- import { FlattenedSign } from '../flattened/sign.js';
2
- import { unencodedPayload } from '../../lib/jws_sign.js';
3
- export class CompactSign {
4
- #flattened;
5
- #protectedHeader;
6
- constructor(payload) {
7
- this.#flattened = new FlattenedSign(payload);
8
- }
9
- setProtectedHeader(protectedHeader) {
10
- this.#flattened.setProtectedHeader(protectedHeader);
11
- this.#protectedHeader = protectedHeader;
12
- return this;
13
- }
14
- async sign(key, options) {
15
- if (unencodedPayload(this.#protectedHeader)) {
16
- throw new TypeError('use the flattened module for creating JWS with b64: false');
17
- }
18
- const jws = await this.#flattened.sign(key, options);
19
- return `${jws.protected}.${jws.payload}.${jws.signature}`;
20
- }
1
+ import { createCompactSignature } from "../../lib/jws_sign.js";
2
+ import { assertNotSet } from "../../lib/helpers.js";
3
+ class CompactSign {
4
+ #payload;
5
+ #protectedHeader;
6
+ constructor(payload) {
7
+ if (!(payload instanceof Uint8Array))
8
+ throw new TypeError("payload must be an instance of Uint8Array");
9
+ this.#payload = payload;
10
+ }
11
+ setProtectedHeader(protectedHeader) {
12
+ return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
13
+ }
14
+ async sign(key, options) {
15
+ return createCompactSignature(this.#payload, this.#protectedHeader, options?.crit, key, () => {
16
+ throw new TypeError("use the flattened module for creating JWS with b64: false");
17
+ });
18
+ }
21
19
  }
20
+ export {
21
+ CompactSign
22
+ };
@@ -1,9 +1,8 @@
1
- import { prepareVerify, verifyCompact } from '../../lib/jws_verify.js';
2
- export async function compactVerify(jws, key, options) {
3
- const verified = await verifyCompact(jws, prepareVerify(options), key);
4
- const result = { payload: verified[0], protectedHeader: verified[1] };
5
- if (typeof key === 'function') {
6
- return { ...result, key: verified[3] };
7
- }
8
- return result;
1
+ import { prepareVerify, verifyCompact } from "../../lib/jws_verify.js";
2
+ async function compactVerify(jws, key, options) {
3
+ const verified = await verifyCompact(jws, prepareVerify(options), key), result = { payload: verified[0], protectedHeader: verified[1] };
4
+ return typeof key == "function" ? { ...result, key: verified[3] } : result;
9
5
  }
6
+ export {
7
+ compactVerify
8
+ };
@@ -1,31 +1,30 @@
1
- import { createSignature } from '../../lib/jws_sign.js';
2
- import { assertNotSet } from '../../lib/helpers.js';
3
- export class FlattenedSign {
4
- #payload;
5
- #protectedHeader;
6
- #unprotectedHeader;
7
- constructor(payload) {
8
- if (!(payload instanceof Uint8Array)) {
9
- throw new TypeError('payload must be an instance of Uint8Array');
10
- }
11
- this.#payload = payload;
12
- }
13
- setProtectedHeader(protectedHeader) {
14
- assertNotSet(this.#protectedHeader, 'setProtectedHeader');
15
- this.#protectedHeader = protectedHeader;
16
- return this;
17
- }
18
- setUnprotectedHeader(unprotectedHeader) {
19
- assertNotSet(this.#unprotectedHeader, 'setUnprotectedHeader');
20
- this.#unprotectedHeader = unprotectedHeader;
21
- return this;
22
- }
23
- async sign(key, options) {
24
- return createSignature({
25
- payload: this.#payload,
26
- protectedHeader: this.#protectedHeader,
27
- unprotectedHeader: this.#unprotectedHeader,
28
- crit: options?.crit,
29
- }, key);
30
- }
1
+ import { createSignature } from "../../lib/jws_sign.js";
2
+ import { assertNotSet } from "../../lib/helpers.js";
3
+ class FlattenedSign {
4
+ #payload;
5
+ #protectedHeader;
6
+ #unprotectedHeader;
7
+ constructor(payload) {
8
+ if (!(payload instanceof Uint8Array))
9
+ throw new TypeError("payload must be an instance of Uint8Array");
10
+ this.#payload = payload;
11
+ }
12
+ setProtectedHeader(protectedHeader) {
13
+ return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
14
+ }
15
+ setUnprotectedHeader(unprotectedHeader) {
16
+ return assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader"), this.#unprotectedHeader = unprotectedHeader, this;
17
+ }
18
+ async sign(key, options) {
19
+ const [jws] = await createSignature({
20
+ payload: this.#payload,
21
+ protectedHeader: this.#protectedHeader,
22
+ unprotectedHeader: this.#unprotectedHeader,
23
+ crit: options?.crit
24
+ }, key);
25
+ return jws;
26
+ }
31
27
  }
28
+ export {
29
+ FlattenedSign
30
+ };
@@ -1,24 +1,22 @@
1
- import { JWSInvalid } from '../../util/errors.js';
2
- import { isObject } from '../../lib/type_checks.js';
3
- import { prepareVerify, verifySignature, verifyResult } from '../../lib/jws_verify.js';
4
- export async function flattenedVerify(jws, key, options) {
5
- if (!isObject(jws)) {
6
- throw new JWSInvalid('Flattened JWS must be an object');
7
- }
8
- if (jws.protected === undefined && jws.header === undefined) {
9
- throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
10
- }
11
- if (jws.protected !== undefined && typeof jws.protected !== 'string') {
12
- throw new JWSInvalid('JWS Protected Header incorrect type');
13
- }
14
- if (jws.payload === undefined) {
15
- throw new JWSInvalid('JWS Payload missing');
16
- }
17
- if (typeof jws.signature !== 'string') {
18
- throw new JWSInvalid('JWS Signature missing or incorrect type');
19
- }
20
- if (jws.header !== undefined && !isObject(jws.header)) {
21
- throw new JWSInvalid('JWS Unprotected Header incorrect type');
22
- }
23
- return verifyResult(jws, await verifySignature(jws, prepareVerify(options), key));
1
+ import { JWSInvalid } from "../../util/errors.js";
2
+ import { isObject } from "../../lib/type_checks.js";
3
+ import { encodeJsonUnencodedPayload, prepareVerify, snapshotJws, verifySignature, verifyResult } from "../../lib/jws_verify.js";
4
+ async function flattenedVerify(jws, key, options) {
5
+ if (!isObject(jws))
6
+ throw new JWSInvalid("Flattened JWS must be an object");
7
+ const snapshot = snapshotJws(jws);
8
+ if (snapshot.protected === void 0 && snapshot.header === void 0)
9
+ throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
10
+ if (snapshot.protected !== void 0 && typeof snapshot.protected != "string")
11
+ throw new JWSInvalid("JWS Protected Header incorrect type");
12
+ if (snapshot.payload === void 0)
13
+ throw new JWSInvalid("JWS Payload missing");
14
+ if (typeof snapshot.signature != "string")
15
+ throw new JWSInvalid("JWS Signature missing or incorrect type");
16
+ if (snapshot.header !== void 0 && !isObject(snapshot.header))
17
+ throw new JWSInvalid("JWS Unprotected Header incorrect type");
18
+ return verifyResult(snapshot, await verifySignature(snapshot, prepareVerify(options), key, encodeJsonUnencodedPayload));
24
19
  }
20
+ export {
21
+ flattenedVerify
22
+ };
@@ -1,74 +1,65 @@
1
- import { createSignature } from '../../lib/jws_sign.js';
2
- import { JWSInvalid } from '../../util/errors.js';
3
- import { assertNotSet } from '../../lib/helpers.js';
1
+ import { createSignature } from "../../lib/jws_sign.js";
2
+ import { JWSInvalid } from "../../util/errors.js";
3
+ import { assertNotSet } from "../../lib/helpers.js";
4
4
  class IndividualSignature {
5
- #parent;
6
- state;
7
- constructor(sig, key, options) {
8
- this.#parent = sig;
9
- this.state = [undefined, undefined, key, options?.crit];
10
- }
11
- setProtectedHeader(protectedHeader) {
12
- assertNotSet(this.state[0], 'setProtectedHeader');
13
- this.state[0] = protectedHeader;
14
- return this;
15
- }
16
- setUnprotectedHeader(unprotectedHeader) {
17
- assertNotSet(this.state[1], 'setUnprotectedHeader');
18
- this.state[1] = unprotectedHeader;
19
- return this;
20
- }
21
- addSignature(...args) {
22
- return this.#parent.addSignature(...args);
23
- }
24
- sign(...args) {
25
- return this.#parent.sign(...args);
26
- }
27
- done() {
28
- return this.#parent;
29
- }
5
+ #parent;
6
+ state;
7
+ constructor(sig, key, options) {
8
+ this.#parent = sig, this.state = [void 0, void 0, key, options?.crit];
9
+ }
10
+ setProtectedHeader(protectedHeader) {
11
+ return assertNotSet(this.state[0], "setProtectedHeader"), this.state[0] = protectedHeader, this;
12
+ }
13
+ setUnprotectedHeader(unprotectedHeader) {
14
+ return assertNotSet(this.state[1], "setUnprotectedHeader"), this.state[1] = unprotectedHeader, this;
15
+ }
16
+ addSignature(...args) {
17
+ return this.#parent.addSignature(...args);
18
+ }
19
+ sign(...args) {
20
+ return this.#parent.sign(...args);
21
+ }
22
+ done() {
23
+ return this.#parent;
24
+ }
30
25
  }
31
- export class GeneralSign {
32
- #payload;
33
- #signatures = [];
34
- constructor(payload) {
35
- this.#payload = payload;
36
- }
37
- addSignature(key, options) {
38
- const signature = new IndividualSignature(this, key, options);
39
- this.#signatures.push(signature);
40
- return signature;
41
- }
42
- async sign() {
43
- if (!this.#signatures.length) {
44
- throw new JWSInvalid('at least one signature must be added');
45
- }
46
- if (!(this.#payload instanceof Uint8Array)) {
47
- throw new TypeError('payload must be an instance of Uint8Array');
48
- }
49
- const jws = {
50
- signatures: [],
51
- payload: '',
52
- };
53
- const encoded = [];
54
- for (let i = 0; i < this.#signatures.length; i++) {
55
- const signature = this.#signatures[i];
56
- const [protectedHeader, unprotectedHeader, key, crit] = signature.state;
57
- const { payload, ...rest } = await createSignature({
58
- payload: this.#payload,
59
- protectedHeader,
60
- unprotectedHeader,
61
- crit,
62
- encoded,
63
- }, key);
64
- if (i === 0) {
65
- jws.payload = payload;
66
- }
67
- else if (jws.payload !== payload) {
68
- throw new JWSInvalid('inconsistent use of JWS Unencoded Payload (RFC7797)');
69
- }
70
- jws.signatures.push(rest);
71
- }
72
- return jws;
26
+ class GeneralSign {
27
+ #payload;
28
+ #signatures = [];
29
+ constructor(payload) {
30
+ this.#payload = payload;
31
+ }
32
+ addSignature(key, options) {
33
+ const signature = new IndividualSignature(this, key, options);
34
+ return this.#signatures.push(signature), signature;
35
+ }
36
+ async sign() {
37
+ if (!this.#signatures.length)
38
+ throw new JWSInvalid("at least one signature must be added");
39
+ if (!(this.#payload instanceof Uint8Array))
40
+ throw new TypeError("payload must be an instance of Uint8Array");
41
+ const jws = {
42
+ signatures: [],
43
+ payload: ""
44
+ }, encoded = [];
45
+ let b64;
46
+ for (let i = 0; i < this.#signatures.length; i++) {
47
+ const signature = this.#signatures[i], [protectedHeader, unprotectedHeader, key, crit] = signature.state, [{ payload, ...rest }, signatureB64] = await createSignature({
48
+ payload: this.#payload,
49
+ protectedHeader,
50
+ unprotectedHeader,
51
+ crit,
52
+ encoded
53
+ }, key);
54
+ if (b64 === void 0)
55
+ b64 = signatureB64, jws.payload = payload;
56
+ else if (b64 !== signatureB64)
57
+ throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
58
+ jws.signatures.push(rest);
73
59
  }
60
+ return jws;
61
+ }
74
62
  }
63
+ export {
64
+ GeneralSign
65
+ };