@suveren/gateway 0.7.3 → 0.7.6

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 (206) hide show
  1. package/content/integrations/gmail.json +3 -6
  2. package/dist/control-plane/index.mjs +294 -62
  3. package/dist/mcp-server/http.mjs +467 -73
  4. package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
  5. package/dist/ui/assets/index-CsrM6RQr.js +110 -0
  6. package/dist/ui/index.html +2 -2
  7. package/node_modules/@hap/core/dist/index.d.mts +258 -9
  8. package/node_modules/@hap/core/dist/index.d.ts +258 -9
  9. package/node_modules/@hap/core/dist/index.js +227 -5
  10. package/node_modules/@hap/core/dist/index.mjs +213 -4
  11. package/node_modules/@hap/core/package.json +3 -2
  12. package/node_modules/@hap/core/src/did-key.ts +126 -0
  13. package/node_modules/@hap/core/src/identity.ts +21 -5
  14. package/node_modules/@hap/core/src/index.ts +3 -0
  15. package/node_modules/@hap/core/src/mandate.ts +207 -0
  16. package/node_modules/@hap/core/src/receipt.ts +74 -0
  17. package/node_modules/@hap/core/src/types.ts +81 -5
  18. package/node_modules/@hono/node-server/dist/index.cjs +151 -9
  19. package/node_modules/@hono/node-server/dist/index.mjs +151 -9
  20. package/node_modules/@hono/node-server/package.json +1 -1
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
  29. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
  30. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
  31. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  32. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  33. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  34. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  35. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  36. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  37. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
  38. package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/README.md +2 -0
  39. package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  40. package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  41. package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  42. package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/package.json +1 -1
  43. package/node_modules/@types/node/README.md +1 -1
  44. package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
  45. package/node_modules/@types/node/crypto.d.ts +2 -2
  46. package/node_modules/@types/node/http.d.ts +16 -0
  47. package/node_modules/@types/node/http2.d.ts +10 -2
  48. package/node_modules/@types/node/package.json +2 -2
  49. package/node_modules/@types/node/process.d.ts +52 -0
  50. package/node_modules/@types/node/quic.d.ts +210 -28
  51. package/node_modules/@types/node/sqlite.d.ts +6 -2
  52. package/node_modules/@types/node/test.d.ts +36 -0
  53. package/node_modules/eventsource-parser/dist/index.cjs +2 -2
  54. package/node_modules/eventsource-parser/dist/index.cjs.map +1 -1
  55. package/node_modules/eventsource-parser/dist/index.js +2 -2
  56. package/node_modules/eventsource-parser/dist/index.js.map +1 -1
  57. package/node_modules/eventsource-parser/package.json +1 -1
  58. package/node_modules/eventsource-parser/src/parse.ts +4 -2
  59. package/node_modules/fast-uri/index.js +201 -48
  60. package/node_modules/fast-uri/lib/schemes.js +9 -4
  61. package/node_modules/fast-uri/lib/utils.js +388 -91
  62. package/node_modules/fast-uri/package.json +1 -1
  63. package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
  64. package/node_modules/fast-uri/test/equal.test.js +31 -3
  65. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  66. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  67. package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
  68. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  69. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  70. package/node_modules/fast-uri/test/parse.test.js +7 -3
  71. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  72. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  73. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  74. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  75. package/node_modules/fast-uri/test/security.test.js +75 -3
  76. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  77. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  78. package/node_modules/hono/dist/cjs/client/client.js +27 -13
  79. package/node_modules/hono/dist/cjs/client/utils.js +4 -1
  80. package/node_modules/hono/dist/cjs/context.js +4 -0
  81. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
  82. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
  83. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
  84. package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
  85. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
  86. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  87. package/node_modules/hono/dist/cjs/middleware/cors/index.js +16 -13
  88. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  89. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
  90. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
  91. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  92. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
  93. package/node_modules/hono/dist/cjs/request.js +8 -4
  94. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  95. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  96. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
  97. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
  98. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
  99. package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
  100. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  101. package/node_modules/hono/dist/cjs/router/utils.js +27 -0
  102. package/node_modules/hono/dist/cjs/utils/body.js +15 -3
  103. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  104. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  105. package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
  106. package/node_modules/hono/dist/cjs/utils/url.js +11 -3
  107. package/node_modules/hono/dist/client/client.js +27 -13
  108. package/node_modules/hono/dist/client/utils.js +4 -1
  109. package/node_modules/hono/dist/context.js +4 -0
  110. package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
  111. package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
  112. package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
  113. package/node_modules/hono/dist/jsx/dom/render.js +2 -0
  114. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
  115. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  116. package/node_modules/hono/dist/middleware/cors/index.js +16 -13
  117. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  118. package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
  119. package/node_modules/hono/dist/middleware/etag/index.js +3 -3
  120. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  121. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
  122. package/node_modules/hono/dist/request.js +8 -4
  123. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  124. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  125. package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
  126. package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
  127. package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
  128. package/node_modules/hono/dist/router/trie-router/node.js +46 -69
  129. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  130. package/node_modules/hono/dist/router/utils.js +5 -0
  131. package/node_modules/hono/dist/types/context.d.ts +4 -0
  132. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  133. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
  134. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  135. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  136. package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
  137. package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
  138. package/node_modules/hono/dist/utils/body.js +15 -3
  139. package/node_modules/hono/dist/utils/cookie.js +1 -1
  140. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  141. package/node_modules/hono/dist/utils/stream.js +7 -1
  142. package/node_modules/hono/dist/utils/url.js +11 -3
  143. package/node_modules/hono/package.json +1 -1
  144. package/node_modules/ip-address/README.md +134 -134
  145. package/node_modules/ip-address/dist/address-error.d.ts +11 -0
  146. package/node_modules/ip-address/dist/address-error.js.map +1 -1
  147. package/node_modules/ip-address/dist/ipv4.d.ts +22 -6
  148. package/node_modules/ip-address/dist/ipv4.js +22 -6
  149. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  150. package/node_modules/ip-address/dist/ipv6.d.ts +10 -3
  151. package/node_modules/ip-address/dist/ipv6.js +26 -17
  152. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  153. package/node_modules/ip-address/package.json +1 -1
  154. package/node_modules/is-plain-object/README.md +39 -95
  155. package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
  156. package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
  157. package/node_modules/is-plain-object/package.json +8 -34
  158. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  159. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  160. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  161. package/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
  162. package/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
  163. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +12 -17
  164. package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
  165. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
  166. package/node_modules/jose/dist/types/types.d.ts +4 -2
  167. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
  168. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
  169. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
  170. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
  171. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +32 -21
  172. package/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
  173. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
  174. package/node_modules/jose/dist/webapi/jwks/local.js +45 -53
  175. package/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
  176. package/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
  177. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
  178. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
  179. package/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
  180. package/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
  181. package/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
  182. package/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
  183. package/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
  184. package/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
  185. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
  186. package/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
  187. package/node_modules/jose/dist/webapi/key/import.js +16 -12
  188. package/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
  189. package/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
  190. package/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
  191. package/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
  192. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
  193. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +45 -13
  194. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
  195. package/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
  196. package/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
  197. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
  198. package/node_modules/jose/dist/webapi/lib/key.js +24 -9
  199. package/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
  200. package/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
  201. package/node_modules/jose/dist/webapi/lib/options.js +26 -0
  202. package/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
  203. package/node_modules/jose/package.json +1 -1
  204. package/package.json +2 -2
  205. package/dist/ui/assets/index-DdJeSfV9.js +0 -110
  206. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "is-plain-object",
3
3
  "description": "Returns true if an object was created by the `Object` constructor, or Object.create(null).",
4
- "version": "5.0.0",
4
+ "version": "5.1.0",
5
5
  "homepage": "https://github.com/jonschlinkert/is-plain-object",
6
6
  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
7
  "contributors": [
@@ -26,7 +26,8 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "import": "./dist/is-plain-object.mjs",
29
- "require": "./dist/is-plain-object.js"
29
+ "require": "./dist/is-plain-object.js",
30
+ "types": "./is-plain-object.d.ts"
30
31
  },
31
32
  "./package.json": "./package.json"
32
33
  },
@@ -34,19 +35,12 @@
34
35
  "node": ">=0.10.0"
35
36
  },
36
37
  "scripts": {
37
- "build": "rollup -c",
38
- "test_browser": "mocha-headless-chrome --args=disable-web-security -f test/browser.html",
39
- "test_node": "mocha -r esm",
40
- "test": "npm run test_node && npm run build && npm run test_browser",
41
- "prepare": "rollup -c"
38
+ "build": "rollup is-plain-object.js --format cjs --file dist/is-plain-object.js && rollup is-plain-object.js --format esm --file dist/is-plain-object.mjs",
39
+ "test": "node test.js",
40
+ "prepare": "npm run build"
42
41
  },
43
42
  "devDependencies": {
44
- "chai": "^4.2.0",
45
- "esm": "^3.2.22",
46
- "gulp-format-md": "^1.0.0",
47
- "mocha": "^6.1.4",
48
- "mocha-headless-chrome": "^3.1.0",
49
- "rollup": "^2.22.1"
43
+ "rollup": "^4.62.5"
50
44
  },
51
45
  "keywords": [
52
46
  "check",
@@ -61,25 +55,5 @@
61
55
  "type",
62
56
  "typeof",
63
57
  "value"
64
- ],
65
- "verb": {
66
- "toc": false,
67
- "layout": "default",
68
- "tasks": [
69
- "readme"
70
- ],
71
- "plugins": [
72
- "gulp-format-md"
73
- ],
74
- "related": {
75
- "list": [
76
- "is-number",
77
- "isobject",
78
- "kind-of"
79
- ]
80
- },
81
- "lint": {
82
- "reflinks": true
83
- }
84
- }
58
+ ]
85
59
  }
@@ -35,9 +35,10 @@ export declare class CompactEncrypt {
35
35
  */
36
36
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
37
37
  /**
38
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
39
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
40
- * parameters.
38
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
39
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
40
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
41
+ * appropriate JOSE Header.
41
42
  *
42
43
  * @param parameters JWE Key Management parameters.
43
44
  */
@@ -9,9 +9,10 @@ export declare class FlattenedEncrypt {
9
9
  */
10
10
  constructor(plaintext: Uint8Array);
11
11
  /**
12
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
13
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
14
- * parameters.
12
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
13
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
14
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
15
+ * appropriate JOSE Header.
15
16
  *
16
17
  * @param parameters JWE Key Management parameters.
17
18
  */
@@ -8,9 +8,10 @@ export interface Recipient {
8
8
  */
9
9
  setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
10
10
  /**
11
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
12
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
13
- * parameters.
11
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
12
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
13
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
14
+ * appropriate JOSE Header.
14
15
  *
15
16
  * @param parameters JWE Key Management parameters.
16
17
  */
@@ -36,17 +36,17 @@ export declare const jwksCache: unique symbol;
36
36
  export interface RemoteJWKSetOptions {
37
37
  /**
38
38
  * Timeout (in milliseconds) for the HTTP request. When reached the request will be aborted and
39
- * the verification will fail. Default is 5000 (5 seconds).
39
+ * the verification will fail. Must be a non-negative integer. Default is 5000 (5 seconds).
40
40
  */
41
41
  timeoutDuration?: number;
42
42
  /**
43
43
  * Duration (in milliseconds) for which no more HTTP requests will be triggered after a previous
44
- * successful fetch. Default is 30000 (30 seconds).
44
+ * successful fetch. Must not be `NaN`. Default is 30000 (30 seconds).
45
45
  */
46
46
  cooldownDuration?: number;
47
47
  /**
48
48
  * Maximum time (in milliseconds) between successful HTTP requests. Default is 600000 (10
49
- * minutes).
49
+ * minutes). Must not be `NaN`.
50
50
  */
51
51
  cacheMaxAge?: number | typeof Infinity;
52
52
  /** Headers to be sent with the HTTP request. */
@@ -60,7 +60,7 @@ export interface RemoteJWKSetOptions {
60
60
  export interface ExportedJWKSCache {
61
61
  /** Current cached JSON Web Key Set */
62
62
  jwks: types.JSONWebKeySet;
63
- /** Last updated at timestamp (seconds since epoch) */
63
+ /** Last updated at timestamp (milliseconds since epoch) */
64
64
  uat: number;
65
65
  }
66
66
  /** See {@link jwksCache}. */
@@ -11,9 +11,9 @@ export interface GeneralVerifyGetKey<KeyType extends types.CryptoKey | Uint8Arra
11
11
  * > Note: The function iterates over the `signatures` array in the General JWS and returns the verification
12
12
  * > result of the first signature entry that can be successfully verified. The result only contains
13
13
  * > the payload, protected header, and unprotected header of that successfully verified signature
14
- * > entry. Other signature entries in the General JWS are not validated, and their headers are not
15
- * > included in the returned result. Recipients of a General JWS should only rely on the returned
16
- * > (verified) data.
14
+ * > entry. Other signature entries' headers may be inspected solely to reject inconsistent use of the
15
+ * > JWS Unencoded Payload Option, and their headers are not included in the returned result.
16
+ * > Recipients of a General JWS should only rely on the returned (verified) data.
17
17
  *
18
18
  * @param jws General JWS.
19
19
  * @param key Key to verify the JWS with. See
@@ -1,20 +1,13 @@
1
1
  import type * as types from '../types.d.ts';
2
+ /**
3
+ * EncryptJWT constructor
4
+ *
5
+ * @param payload The JWT Claims Set object. Defaults to an empty object.
6
+ */
7
+ declare const EncryptJWT_base: new (payload?: types.JWTPayload) => types.ProduceJWT;
2
8
  /** The EncryptJWT class is used to build and encrypt Compact JWE formatted JSON Web Tokens. */
3
- export declare class EncryptJWT implements types.ProduceJWT {
9
+ export declare class EncryptJWT extends EncryptJWT_base {
4
10
  #private;
5
- /**
6
- * {@link EncryptJWT} constructor
7
- *
8
- * @param payload The JWT Claims Set object. Defaults to an empty object.
9
- */
10
- constructor(payload?: types.JWTPayload);
11
- setIssuer(issuer: string): this;
12
- setSubject(subject: string): this;
13
- setAudience(audience: string | string[]): this;
14
- setJti(jwtId: string): this;
15
- setNotBefore(input: number | string | Date): this;
16
- setExpirationTime(input: number | string | Date): this;
17
- setIssuedAt(input?: number | string | Date): this;
18
11
  /**
19
12
  * Sets the JWE Protected Header on the EncryptJWT object.
20
13
  *
@@ -23,9 +16,10 @@ export declare class EncryptJWT implements types.ProduceJWT {
23
16
  */
24
17
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
25
18
  /**
26
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
27
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
28
- * parameters.
19
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
20
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
21
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
22
+ * appropriate JOSE Header.
29
23
  *
30
24
  * @param parameters JWE Key Management parameters.
31
25
  */
@@ -65,3 +59,4 @@ export declare class EncryptJWT implements types.ProduceJWT {
65
59
  */
66
60
  encrypt(key: types.KeyInput, options?: types.EncryptOptions): Promise<string>;
67
61
  }
62
+ export {};
@@ -1,20 +1,13 @@
1
1
  import type * as types from '../types.d.ts';
2
+ /**
3
+ * SignJWT constructor
4
+ *
5
+ * @param payload The JWT Claims Set object. Defaults to an empty object.
6
+ */
7
+ declare const SignJWT_base: new (payload?: types.JWTPayload) => types.ProduceJWT;
2
8
  /** The SignJWT class is used to build and sign Compact JWS formatted JSON Web Tokens. */
3
- export declare class SignJWT implements types.ProduceJWT {
9
+ export declare class SignJWT extends SignJWT_base {
4
10
  #private;
5
- /**
6
- * {@link SignJWT} constructor
7
- *
8
- * @param payload The JWT Claims Set object. Defaults to an empty object.
9
- */
10
- constructor(payload?: types.JWTPayload);
11
- setIssuer(issuer: string): this;
12
- setSubject(subject: string): this;
13
- setAudience(audience: string | string[]): this;
14
- setJti(jwtId: string): this;
15
- setNotBefore(input: number | string | Date): this;
16
- setExpirationTime(input: number | string | Date): this;
17
- setIssuedAt(input?: number | string | Date): this;
18
11
  /**
19
12
  * Sets the JWS Protected Header on the SignJWT object.
20
13
  *
@@ -30,3 +23,4 @@ export declare class SignJWT implements types.ProduceJWT {
30
23
  */
31
24
  sign(key: types.KeyInput, options?: types.SignOptions): Promise<string>;
32
25
  }
26
+ export {};
@@ -6,24 +6,17 @@ export interface UnsecuredResult<PayloadType = types.JWTPayload> {
6
6
  /** The decoded JOSE Header; always `{ "alg": "none" }` for an Unsecured JWT. */
7
7
  header: types.JWSHeaderParameters;
8
8
  }
9
+ /**
10
+ * UnsecuredJWT constructor
11
+ *
12
+ * @param payload The JWT Claims Set object. Defaults to an empty object.
13
+ */
14
+ declare const UnsecuredJWT_base: new (payload?: types.JWTPayload) => types.ProduceJWT;
9
15
  /** The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecured JWTs. */
10
- export declare class UnsecuredJWT implements types.ProduceJWT {
11
- #private;
12
- /**
13
- * {@link UnsecuredJWT} constructor
14
- *
15
- * @param payload The JWT Claims Set object. Defaults to an empty object.
16
- */
17
- constructor(payload?: types.JWTPayload);
16
+ export declare class UnsecuredJWT extends UnsecuredJWT_base {
17
+ private jwt;
18
18
  /** Encodes the Unsecured JWT. */
19
19
  encode(): string;
20
- setIssuer(issuer: string): this;
21
- setSubject(subject: string): this;
22
- setAudience(audience: string | string[]): this;
23
- setJti(jwtId: string): this;
24
- setNotBefore(input: number | string | Date): this;
25
- setExpirationTime(input: number | string | Date): this;
26
- setIssuedAt(input?: number | string | Date): this;
27
20
  /**
28
21
  * Decodes an unsecured JWT.
29
22
  *
@@ -32,3 +25,4 @@ export declare class UnsecuredJWT implements types.ProduceJWT {
32
25
  */
33
26
  static decode<PayloadType = types.JWTPayload>(jwt: string, options?: types.JWTClaimVerificationOptions): UnsecuredResult<PayloadType>;
34
27
  }
28
+ export {};
@@ -417,11 +417,13 @@ export interface JWEKeyManagementHeaderParameters {
417
417
  * used in ECDH's ConcatKDF.
418
418
  */
419
419
  apv?: Uint8Array
420
+
420
421
  /**
421
- * @deprecated You should not use this parameter. It is only intended for testing and vector
422
- * validation purposes.
422
+ * PBES2 "p2c" (PBES2 Count). This will be used as a JOSE Header Parameter and as the PBKDF2
423
+ * iteration count.
423
424
  */
424
425
  p2c?: number
426
+
425
427
  /**
426
428
  * @deprecated You should not use this parameter. It is only intended for testing and vector
427
429
  * validation purposes.
@@ -1,27 +1,49 @@
1
- import { FlattenedEncrypt } from '../flattened/encrypt.js';
1
+ import { assertNotSet } from '../../lib/helpers.js';
2
+ import { assertUint8Array } from '../../lib/type_checks.js';
3
+ import { createJWE } from '../../lib/jwe_encrypt.js';
2
4
  export class CompactEncrypt {
3
- #flattened;
5
+ #plaintext;
6
+ #protectedHeader;
7
+ #cek;
8
+ #iv;
9
+ #keyManagementParameters;
4
10
  constructor(plaintext) {
5
- this.#flattened = new FlattenedEncrypt(plaintext);
11
+ assertUint8Array(plaintext, 'plaintext');
12
+ this.#plaintext = plaintext;
6
13
  }
7
14
  setContentEncryptionKey(cek) {
8
- this.#flattened.setContentEncryptionKey(cek);
15
+ assertNotSet(this.#cek, 'setContentEncryptionKey');
16
+ this.#cek = cek;
9
17
  return this;
10
18
  }
11
19
  setInitializationVector(iv) {
12
- this.#flattened.setInitializationVector(iv);
20
+ assertNotSet(this.#iv, 'setInitializationVector');
21
+ this.#iv = iv;
13
22
  return this;
14
23
  }
15
24
  setProtectedHeader(protectedHeader) {
16
- this.#flattened.setProtectedHeader(protectedHeader);
25
+ assertNotSet(this.#protectedHeader, 'setProtectedHeader');
26
+ this.#protectedHeader = protectedHeader;
17
27
  return this;
18
28
  }
19
29
  setKeyManagementParameters(parameters) {
20
- this.#flattened.setKeyManagementParameters(parameters);
30
+ assertNotSet(this.#keyManagementParameters, 'setKeyManagementParameters');
31
+ this.#keyManagementParameters = parameters;
21
32
  return this;
22
33
  }
23
34
  async encrypt(key, options) {
24
- const jwe = await this.#flattened.encrypt(key, options);
35
+ const jwe = await createJWE([
36
+ this.#plaintext,
37
+ this.#protectedHeader,
38
+ undefined,
39
+ undefined,
40
+ undefined,
41
+ this.#cek,
42
+ this.#iv,
43
+ this.#keyManagementParameters,
44
+ undefined,
45
+ false,
46
+ ], key, options);
25
47
  return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
26
48
  }
27
49
  }
@@ -1,11 +1,15 @@
1
1
  import { JWEInvalid } from '../../util/errors.js';
2
2
  import { isObject } from '../../lib/type_checks.js';
3
- import { prepareDecrypt, decryptJWE, decryptResult, checkShared, checkRecipient, } from '../../lib/jwe_decrypt.js';
3
+ import { prepareDecrypt, decryptJWE, decryptResult, checkRecipient, snapshotSharedJWE, snapshotRecipientJWE, } from '../../lib/jwe_decrypt.js';
4
4
  export async function flattenedDecrypt(jwe, key, options) {
5
5
  if (!isObject(jwe)) {
6
6
  throw new JWEInvalid('Flattened JWE must be an object');
7
7
  }
8
- checkShared(jwe);
9
- checkRecipient(jwe);
10
- return decryptResult(jwe, await decryptJWE(jwe, prepareDecrypt(options), key));
8
+ const shared = snapshotSharedJWE(jwe);
9
+ const [recipient, , error] = snapshotRecipientJWE(jwe);
10
+ if (!recipient)
11
+ throw error;
12
+ const snapshot = { ...shared, ...recipient };
13
+ checkRecipient(snapshot);
14
+ return decryptResult(snapshot, await decryptJWE(snapshot, prepareDecrypt(options), key));
11
15
  }
@@ -1,7 +1,6 @@
1
- import { unprotected, assertNotSet } from '../../lib/helpers.js';
2
- import { JWEInvalid } from '../../util/errors.js';
1
+ import { assertNotSet } from '../../lib/helpers.js';
3
2
  import { createJWE } from '../../lib/jwe_encrypt.js';
4
- import { validateCritDuplicates } from '../../lib/options.js';
3
+ import { assertUint8Array } from '../../lib/type_checks.js';
5
4
  export class FlattenedEncrypt {
6
5
  #plaintext;
7
6
  #protectedHeader;
@@ -12,9 +11,7 @@ export class FlattenedEncrypt {
12
11
  #iv;
13
12
  #keyManagementParameters;
14
13
  constructor(plaintext) {
15
- if (!(plaintext instanceof Uint8Array)) {
16
- throw new TypeError('plaintext must be an instance of Uint8Array');
17
- }
14
+ assertUint8Array(plaintext, 'plaintext');
18
15
  this.#plaintext = plaintext;
19
16
  }
20
17
  setKeyManagementParameters(parameters) {
@@ -52,10 +49,6 @@ export class FlattenedEncrypt {
52
49
  return this;
53
50
  }
54
51
  async encrypt(key, options) {
55
- if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
56
- throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');
57
- }
58
- validateCritDuplicates(JWEInvalid, this.#protectedHeader);
59
52
  return createJWE([
60
53
  this.#plaintext,
61
54
  this.#protectedHeader,
@@ -65,8 +58,8 @@ export class FlattenedEncrypt {
65
58
  this.#cek,
66
59
  this.#iv,
67
60
  this.#keyManagementParameters,
68
- options?.crit,
69
- options ? unprotected in options : false,
70
- ], key);
61
+ undefined,
62
+ false,
63
+ ], key, options);
71
64
  }
72
65
  }
@@ -1,46 +1,46 @@
1
- import { prepareDecrypt, shareJWE, decryptRecipient, decryptResult, checkShared, checkRecipient, } from '../../lib/jwe_decrypt.js';
1
+ import { prepareDecrypt, shareJWE, decryptRecipient, decryptResult, checkRecipient, snapshotSharedJWE, snapshotRecipientJWE, } from '../../lib/jwe_decrypt.js';
2
2
  import { JWEDecryptionFailed, JWEInvalid } from '../../util/errors.js';
3
3
  import { isObject } from '../../lib/type_checks.js';
4
4
  export async function generalDecrypt(jwe, key, options) {
5
5
  if (!isObject(jwe)) {
6
6
  throw new JWEInvalid('General JWE must be an object');
7
7
  }
8
- if (!Array.isArray(jwe.recipients) || !jwe.recipients.every(isObject)) {
8
+ const inputRecipients = jwe.recipients;
9
+ if (!Array.isArray(inputRecipients)) {
9
10
  throw new JWEInvalid('JWE Recipients missing or incorrect type');
10
11
  }
11
- if (!jwe.recipients.length) {
12
+ const recipients = Array.from(inputRecipients);
13
+ if (!recipients.every(isObject)) {
14
+ throw new JWEInvalid('JWE Recipients missing or incorrect type');
15
+ }
16
+ if (!recipients.length) {
12
17
  throw new JWEInvalid('JWE Recipients has no members');
13
18
  }
14
19
  let shared;
20
+ let sharedJwe;
15
21
  let token;
16
22
  try {
17
- checkShared(jwe);
18
23
  shared = prepareDecrypt(options);
19
- token = shareJWE(jwe);
24
+ sharedJwe = snapshotSharedJWE(jwe);
25
+ token = shareJWE(sharedJwe);
20
26
  }
21
27
  catch {
22
28
  throw new JWEDecryptionFailed();
23
29
  }
24
- if (jwe.recipients.length > 1) {
25
- for (const { header } of jwe.recipients) {
26
- const alg = token[0]?.alg ?? header?.alg ?? jwe.unprotected?.alg;
30
+ const recipientSnapshots = recipients.map((recipient) => snapshotRecipientJWE(recipient));
31
+ if (recipients.length > 1) {
32
+ for (const [, headerAlg] of recipientSnapshots) {
33
+ const alg = token[0]?.alg ?? headerAlg ?? sharedJwe.unprotected?.alg;
27
34
  if (alg === 'dir' || alg === 'ECDH-ES') {
28
35
  throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
29
36
  }
30
37
  }
31
38
  }
32
- for (const recipient of jwe.recipients) {
39
+ for (const [recipient] of recipientSnapshots) {
40
+ if (!recipient)
41
+ continue;
33
42
  try {
34
- const flattened = {
35
- aad: jwe.aad,
36
- ciphertext: jwe.ciphertext,
37
- encrypted_key: recipient.encrypted_key,
38
- header: recipient.header,
39
- iv: jwe.iv,
40
- protected: jwe.protected,
41
- tag: jwe.tag,
42
- unprotected: jwe.unprotected,
43
- };
43
+ const flattened = { ...sharedJwe, ...recipient };
44
44
  checkRecipient(flattened);
45
45
  return decryptResult(flattened, await decryptRecipient(flattened, token, shared, key));
46
46
  }
@@ -1,13 +1,12 @@
1
- import { FlattenedEncrypt } from '../flattened/encrypt.js';
2
1
  import { assertNotSet } from '../../lib/helpers.js';
3
2
  import { JWEInvalid } from '../../util/errors.js';
4
3
  import { generateCek } from '../../lib/content_encryption.js';
5
4
  import { encryptKeyManagement } from '../../lib/key_management.js';
6
5
  import { encode as b64u } from '../../util/base64url.js';
7
- import { validateCritDuplicates } from '../../lib/options.js';
8
- import { checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
6
+ import { checkDisjoint, checkEncryptHeaders, createJWE, encryptJWE } from '../../lib/jwe_encrypt.js';
9
7
  import { prepareKey } from '../../lib/key.js';
10
8
  import { jweAlgorithm } from '../../lib/jwe_algorithms.js';
9
+ import { assertUint8Array } from '../../lib/type_checks.js';
11
10
  class IndividualRecipient {
12
11
  #parent;
13
12
  state;
@@ -78,19 +77,21 @@ export class GeneralEncrypt {
78
77
  if (!this.#recipients.length) {
79
78
  throw new JWEInvalid('at least one recipient must be added');
80
79
  }
81
- if (!(this.#plaintext instanceof Uint8Array)) {
82
- throw new TypeError('plaintext must be an instance of Uint8Array');
83
- }
80
+ assertUint8Array(this.#plaintext, 'plaintext');
84
81
  if (this.#recipients.length === 1) {
85
- const [recipient] = this.#recipients;
86
- const [unprotectedHeader, keyManagementParameters, key, crit] = recipient.state;
87
- const flattened = await new FlattenedEncrypt(this.#plaintext)
88
- .setAdditionalAuthenticatedData(this.#aad)
89
- .setProtectedHeader(this.#protectedHeader)
90
- .setSharedUnprotectedHeader(this.#unprotectedHeader)
91
- .setUnprotectedHeader(unprotectedHeader)
92
- .setKeyManagementParameters(keyManagementParameters)
93
- .encrypt(key, { crit });
82
+ const [unprotectedHeader, keyManagementParameters, key, crit] = this.#recipients[0].state;
83
+ const flattened = await createJWE([
84
+ this.#plaintext,
85
+ this.#protectedHeader,
86
+ unprotectedHeader,
87
+ this.#unprotectedHeader,
88
+ this.#aad,
89
+ undefined,
90
+ undefined,
91
+ keyManagementParameters,
92
+ crit,
93
+ false,
94
+ ], key);
94
95
  const jwe = {
95
96
  ciphertext: flattened.ciphertext,
96
97
  iv: flattened.iv,
@@ -102,8 +103,9 @@ export class GeneralEncrypt {
102
103
  copyOptionalMembers(flattened, jwe, jwe.recipients[0]);
103
104
  return jwe;
104
105
  }
105
- validateCritDuplicates(JWEInvalid, this.#protectedHeader);
106
106
  let enc;
107
+ let protectedHeader = this.#protectedHeader;
108
+ let sharedUnprotectedHeader = this.#unprotectedHeader;
107
109
  const inputs = [];
108
110
  const checked = [];
109
111
  for (let i = 0; i < this.#recipients.length; i++) {
@@ -111,9 +113,9 @@ export class GeneralEncrypt {
111
113
  const [unprotectedHeader, keyManagementParameters, , crit] = recipient.state;
112
114
  const input = [
113
115
  this.#plaintext,
114
- this.#protectedHeader,
116
+ protectedHeader,
115
117
  unprotectedHeader,
116
- this.#unprotectedHeader,
118
+ sharedUnprotectedHeader,
117
119
  this.#aad,
118
120
  undefined,
119
121
  undefined,
@@ -124,6 +126,10 @@ export class GeneralEncrypt {
124
126
  const headers = checkEncryptHeaders(input);
125
127
  inputs.push(input);
126
128
  checked.push(headers);
129
+ if (i === 0) {
130
+ protectedHeader = input[1];
131
+ sharedUnprotectedHeader = input[3];
132
+ }
127
133
  if (headers[1] === 'dir' || headers[1] === 'ECDH-ES') {
128
134
  throw new JWEInvalid(`"${headers[1]}" alg may only have a single recipient`);
129
135
  }
@@ -141,7 +147,7 @@ export class GeneralEncrypt {
141
147
  };
142
148
  for (let i = 0; i < this.#recipients.length; i++) {
143
149
  const recipient = this.#recipients[i];
144
- const [unprotectedHeader, keyManagementParameters, key] = recipient.state;
150
+ const [, keyManagementParameters, key] = recipient.state;
145
151
  const target = {};
146
152
  jwe.recipients.push(target);
147
153
  if (i === 0) {
@@ -155,11 +161,16 @@ export class GeneralEncrypt {
155
161
  continue;
156
162
  }
157
163
  const [, alg, , encEntry] = checked[i];
164
+ const unprotectedHeader = inputs[i][2];
158
165
  const k = await prepareKey(jweAlgorithm(alg), key, 'encrypt');
159
166
  const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
160
167
  target.encrypted_key = b64u(encryptedKey);
161
- if (unprotectedHeader || parameters)
162
- target.header = { ...unprotectedHeader, ...parameters };
168
+ if (unprotectedHeader || parameters) {
169
+ const header = { ...unprotectedHeader, ...parameters };
170
+ if (parameters)
171
+ checkDisjoint(inputs[i][1], header, inputs[i][3]);
172
+ target.header = header;
173
+ }
163
174
  }
164
175
  return jwe;
165
176
  }
@@ -2,6 +2,7 @@ import { jwkToKey } from '../lib/jwk_to_key.js';
2
2
  import { jwsAlgorithm } from '../lib/jws_algorithms.js';
3
3
  import { isObject } from '../lib/type_checks.js';
4
4
  import { JWSInvalid } from '../util/errors.js';
5
+ import { normalizeJwk } from '../lib/jwk_metadata.js';
5
6
  export async function EmbeddedJWK(protectedHeader, token) {
6
7
  const joseHeader = {
7
8
  ...protectedHeader,
@@ -10,8 +11,21 @@ export async function EmbeddedJWK(protectedHeader, token) {
10
11
  if (!isObject(joseHeader.jwk)) {
11
12
  throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
12
13
  }
14
+ let jwk;
15
+ try {
16
+ jwk = normalizeJwk(joseHeader.jwk);
17
+ }
18
+ catch (cause) {
19
+ throw new JWSInvalid('Invalid Embedded JWK', { cause });
20
+ }
13
21
  const entry = jwsAlgorithm(joseHeader.alg);
14
- const key = await jwkToKey(entry, { ...joseHeader.jwk, ext: true });
22
+ if (jwk.use !== undefined && jwk.use !== 'sig') {
23
+ throw new JWSInvalid('Invalid Embedded JWK, its "use" must be "sig" when present');
24
+ }
25
+ if (jwk.alg !== undefined && jwk.alg !== entry.alg) {
26
+ throw new JWSInvalid(`Invalid Embedded JWK, its "alg" must be "${entry.alg}" when present`);
27
+ }
28
+ const key = await jwkToKey(entry, { ...jwk, ext: true });
15
29
  if (key.type !== 'public') {
16
30
  throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
17
31
  }