@teammy/server 0.2.23 → 0.2.24

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 (166) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -7
  3. package/dist/main.js +20331 -13329
  4. package/dist/native-pi-entry.js +755 -19
  5. package/dist/project-pi-entry.js +758 -22
  6. package/dist/runtime/en/shared/system.md +9 -0
  7. package/dist/runtime/en/shared/tools.json +22 -0
  8. package/dist/runtime/en/workflows/directory-analysis/prompt.md +11 -0
  9. package/dist/runtime/en/workflows/file-summary/prompt.md +7 -0
  10. package/dist/runtime/en/workflows/session-handoff/prompt.md +31 -0
  11. package/dist/runtime/en/workflows/session-overview/prompt.md +26 -0
  12. package/dist/runtime/en/workflows/task-bootstrap/prompt.md +84 -0
  13. package/dist/runtime/shared/system.md +1 -1
  14. package/dist/runtime/workflows/session-handoff/prompt.md +1 -1
  15. package/dist/runtime/workflows/session-overview/prompt.md +1 -1
  16. package/dist/web/THIRD-PARTY-LICENSES.md +2025 -0
  17. package/dist/web/assets/Assistant-BeWIo88A.js +1 -0
  18. package/dist/web/assets/{Computers-BtcIsnDD.css → Computers-BJKv9oJv.css} +1 -1
  19. package/dist/web/assets/Computers-CEBC9xd4.js +14 -0
  20. package/dist/web/assets/Conversation-BMA0djTl.js +1 -0
  21. package/dist/web/assets/Dashboard-DtNpBYI5.js +1 -0
  22. package/dist/web/assets/Files-C-00txBh.js +1 -0
  23. package/dist/web/assets/Help-C5yLJzSE.js +2392 -0
  24. package/dist/web/assets/MessageComposer-D7ml-LaD.js +1 -0
  25. package/dist/web/assets/MessageComposer-DqcbXBIG.css +1 -0
  26. package/dist/web/assets/ResourceLibrary-Ceon9f0i.js +6 -0
  27. package/dist/web/assets/TerminalPane-CZYb0vIG.js +22 -0
  28. package/dist/web/assets/WorkspaceTree-C2sVptdG.js +1 -0
  29. package/dist/web/assets/file-links-CQ6ShuxD.js +1 -0
  30. package/dist/web/assets/index-B9gF6reY.css +1 -0
  31. package/dist/web/assets/index-BCj5CDtq.js +40 -0
  32. package/dist/web/assets/project-links-BwYckk7L.js +105 -0
  33. package/dist/web/assets/workflow-DR-M8YZx.svg +111 -0
  34. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  35. package/dist/web/downloads/teammy-skill.zip +0 -0
  36. package/dist/web/index.html +4 -4
  37. package/dist/web/notification-worker.js +2 -10
  38. package/node_modules/i18next/LICENSE +21 -0
  39. package/node_modules/i18next/README.md +77 -0
  40. package/node_modules/i18next/dist/cjs/i18next.js +2495 -0
  41. package/node_modules/i18next/dist/esm/i18next.js +2505 -0
  42. package/node_modules/i18next/dist/esm/package.json +1 -0
  43. package/node_modules/i18next/dist/umd/i18next.js +2501 -0
  44. package/node_modules/i18next/dist/umd/i18next.min.js +1 -0
  45. package/node_modules/i18next/i18next.js +2501 -0
  46. package/node_modules/i18next/i18next.min.js +1 -0
  47. package/node_modules/i18next/index.d.mts +71 -0
  48. package/node_modules/i18next/index.d.ts +739 -0
  49. package/node_modules/i18next/package.json +125 -0
  50. package/node_modules/i18next/typescript/helpers.d.ts +73 -0
  51. package/node_modules/i18next/typescript/options.d.ts +871 -0
  52. package/node_modules/i18next/typescript/t.d.ts +1449 -0
  53. package/node_modules/jose/LICENSE.md +21 -0
  54. package/node_modules/jose/README.md +150 -0
  55. package/node_modules/jose/dist/types/index.d.ts +55 -0
  56. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +25 -0
  57. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +40 -0
  58. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +25 -0
  59. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +46 -0
  60. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +29 -0
  61. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +51 -0
  62. package/node_modules/jose/dist/types/jwk/embedded.d.ts +10 -0
  63. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +15 -0
  64. package/node_modules/jose/dist/types/jwks/local.d.ts +17 -0
  65. package/node_modules/jose/dist/types/jwks/remote.d.ts +94 -0
  66. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +21 -0
  67. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +25 -0
  68. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +23 -0
  69. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +26 -0
  70. package/node_modules/jose/dist/types/jws/general/sign.d.ts +41 -0
  71. package/node_modules/jose/dist/types/jws/general/verify.d.ts +31 -0
  72. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +38 -0
  73. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +57 -0
  74. package/node_modules/jose/dist/types/jwt/sign.d.ts +21 -0
  75. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +21 -0
  76. package/node_modules/jose/dist/types/jwt/verify.d.ts +36 -0
  77. package/node_modules/jose/dist/types/key/export.d.ts +19 -0
  78. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +33 -0
  79. package/node_modules/jose/dist/types/key/generate_secret.d.ts +30 -0
  80. package/node_modules/jose/dist/types/key/import.d.ts +67 -0
  81. package/node_modules/jose/dist/types/types.d.ts +802 -0
  82. package/node_modules/jose/dist/types/util/base64url.d.ts +16 -0
  83. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +9 -0
  84. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +10 -0
  85. package/node_modules/jose/dist/types/util/errors.d.ts +182 -0
  86. package/node_modules/jose/dist/webapi/index.js +70 -0
  87. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +7 -0
  88. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +26 -0
  89. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +15 -0
  90. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +35 -0
  91. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +41 -0
  92. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +105 -0
  93. package/node_modules/jose/dist/webapi/jwk/embedded.js +30 -0
  94. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +55 -0
  95. package/node_modules/jose/dist/webapi/jwks/local.js +60 -0
  96. package/node_modules/jose/dist/webapi/jwks/remote.js +103 -0
  97. package/node_modules/jose/dist/webapi/jws/compact/sign.js +20 -0
  98. package/node_modules/jose/dist/webapi/jws/compact/verify.js +8 -0
  99. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +23 -0
  100. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +12 -0
  101. package/node_modules/jose/dist/webapi/jws/general/sign.js +58 -0
  102. package/node_modules/jose/dist/webapi/jws/general/verify.js +42 -0
  103. package/node_modules/jose/dist/webapi/jwt/decrypt.js +13 -0
  104. package/node_modules/jose/dist/webapi/jwt/encrypt.js +42 -0
  105. package/node_modules/jose/dist/webapi/jwt/sign.js +19 -0
  106. package/node_modules/jose/dist/webapi/jwt/unsecured.js +34 -0
  107. package/node_modules/jose/dist/webapi/jwt/verify.js +13 -0
  108. package/node_modules/jose/dist/webapi/key/export.js +35 -0
  109. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +35 -0
  110. package/node_modules/jose/dist/webapi/key/generate_secret.js +36 -0
  111. package/node_modules/jose/dist/webapi/key/import.js +53 -0
  112. package/node_modules/jose/dist/webapi/lib/asn1.js +138 -0
  113. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +75 -0
  114. package/node_modules/jose/dist/webapi/lib/content_encryption.js +90 -0
  115. package/node_modules/jose/dist/webapi/lib/deflate.js +41 -0
  116. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +116 -0
  117. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +190 -0
  118. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +75 -0
  119. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +74 -0
  120. package/node_modules/jose/dist/webapi/lib/jws_sign.js +46 -0
  121. package/node_modules/jose/dist/webapi/lib/jws_verify.js +89 -0
  122. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +150 -0
  123. package/node_modules/jose/dist/webapi/lib/key.js +157 -0
  124. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +15 -0
  125. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +9 -0
  126. package/node_modules/jose/dist/webapi/lib/key_management.js +195 -0
  127. package/node_modules/jose/dist/webapi/lib/validate.js +122 -0
  128. package/node_modules/jose/dist/webapi/util/base64url.js +16 -0
  129. package/node_modules/jose/dist/webapi/util/decode_jwt.js +33 -0
  130. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +19 -0
  131. package/node_modules/jose/dist/webapi/util/errors.js +109 -0
  132. package/node_modules/jose/package.json +134 -0
  133. package/node_modules/oauth4webapi/LICENSE.md +21 -0
  134. package/node_modules/oauth4webapi/README.md +104 -0
  135. package/node_modules/oauth4webapi/build/index.d.ts +3046 -0
  136. package/node_modules/oauth4webapi/build/index.js +2530 -0
  137. package/node_modules/oauth4webapi/build/index.js.map +1 -0
  138. package/node_modules/oauth4webapi/package.json +112 -0
  139. package/node_modules/openid-client/LICENSE.md +21 -0
  140. package/node_modules/openid-client/README.md +258 -0
  141. package/node_modules/openid-client/build/index.d.ts +2478 -0
  142. package/node_modules/openid-client/build/index.js +1347 -0
  143. package/node_modules/openid-client/build/index.js.map +1 -0
  144. package/node_modules/openid-client/build/passport.d.ts +258 -0
  145. package/node_modules/openid-client/build/passport.js +264 -0
  146. package/node_modules/openid-client/build/passport.js.map +1 -0
  147. package/node_modules/openid-client/package.json +130 -0
  148. package/package.json +5 -1
  149. package/dist/web/assets/Assistant-Dks48Y5w.js +0 -1
  150. package/dist/web/assets/Computers-CaCzZeCc.js +0 -13
  151. package/dist/web/assets/Conversation-kAMzKADw.js +0 -1
  152. package/dist/web/assets/Dashboard-ComNJNOg.js +0 -1
  153. package/dist/web/assets/Dropdown-DGFI68Vd.js +0 -55
  154. package/dist/web/assets/Files-Blsq_C-B.js +0 -1
  155. package/dist/web/assets/Help-BM23uS-t.js +0 -1079
  156. package/dist/web/assets/Markdown-CXnZDm5J.js +0 -29
  157. package/dist/web/assets/MessageComposer-BoOgfyPA.js +0 -1
  158. package/dist/web/assets/MessageComposer-hKEluJsT.css +0 -1
  159. package/dist/web/assets/ResourceLibrary-C12_47kE.js +0 -6
  160. package/dist/web/assets/TerminalPane-BTRM-36z.js +0 -22
  161. package/dist/web/assets/WorkspaceTree-Co7XG2RG.js +0 -1
  162. package/dist/web/assets/file-links-CoVqmrXg.js +0 -1
  163. package/dist/web/assets/index-CeKzFsxV.css +0 -1
  164. package/dist/web/assets/index-mhJ33-bH.js +0 -10
  165. package/dist/web/assets/task-links-BE36-8mc.js +0 -1
  166. /package/dist/web/assets/{Dropdown-ktgqMqAD.css → project-links-ktgqMqAD.css} +0 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Decodes base64url text or its UTF-8 bytes.
3
+ *
4
+ * @param input Base64url-encoded string or its UTF-8 bytes.
5
+ * @returns The decoded bytes.
6
+ * @throws {TypeError} If the input is not valid base64url. Standard Base64 `+` and `/` are
7
+ * rejected.
8
+ */
9
+ export declare function decode(input: Uint8Array | string): Uint8Array;
10
+ /**
11
+ * Encodes unpadded base64url; strings are first encoded as UTF-8.
12
+ *
13
+ * @param input Bytes or a string to encode. Strings are first encoded as UTF-8.
14
+ * @returns The unpadded base64url representation of the input.
15
+ */
16
+ export declare function encode(input: Uint8Array | string): string;
@@ -0,0 +1,9 @@
1
+ import type * as t from '../types.d.ts';
2
+ export declare function decodeJwt<PayloadType, InferredPayloadType>(jwt: string): InferredPayloadType & t.JWTPayload & ([PayloadType] extends [object] ? unknown : unknown extends PayloadType ? unknown : never);
3
+ /**
4
+ * Decodes the Claims Set of a JWT in JWS Compact Serialization without validating its JWS Signature
5
+ * (digital signature or MAC) or claim types and values.
6
+ *
7
+ * @returns The parsed JWT Claims Set.
8
+ */
9
+ export declare function decodeJwt<PayloadType = t.JWTPayload>(jwt: string): PayloadType & t.JWTPayload & ([PayloadType] extends [object] ? unknown : unknown extends PayloadType ? unknown : never);
@@ -0,0 +1,10 @@
1
+ import type * as t from '../types.d.ts';
2
+ /** JWE and JWS Header Parameters returned by {@link decodeProtectedHeader}. */
3
+ export type ProtectedHeaderParameters = t.JWSHeaderParameters & t.JWEHeaderParameters;
4
+ /**
5
+ * Decodes the Protected Header of a JWE, JWS, or JWT without authenticating the token.
6
+ *
7
+ * @param token Compact token or JSON serialization object with a `protected` member.
8
+ * @returns The parsed Protected Header.
9
+ */
10
+ export declare function decodeProtectedHeader(token: string | object): ProtectedHeaderParameters;
@@ -0,0 +1,182 @@
1
+ import type * as t from '../types.d.ts';
2
+ /** Stable error codes used by this module. */
3
+ export type JOSEErrorCode = 'ERR_JOSE_ALG_NOT_ALLOWED' | 'ERR_JOSE_GENERIC' | 'ERR_JOSE_NOT_SUPPORTED' | 'ERR_JWE_DECRYPTION_FAILED' | 'ERR_JWE_INVALID' | 'ERR_JWK_INVALID' | 'ERR_JWKS_INVALID' | 'ERR_JWKS_MULTIPLE_MATCHING_KEYS' | 'ERR_JWKS_NO_MATCHING_KEY' | 'ERR_JWKS_TIMEOUT' | 'ERR_JWS_INVALID' | 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED' | 'ERR_JWT_CLAIM_VALIDATION_FAILED' | 'ERR_JWT_EXPIRED' | 'ERR_JWT_INVALID';
4
+ /** Shared details of JWT claim or header validation failures. */
5
+ export interface JWTClaimValidationFailure {
6
+ /** Claim or header that failed validation. */
7
+ claim: string;
8
+ /** Reason code for the validation failure. */
9
+ reason: JWTClaimValidationReason;
10
+ /** The parsed JWT Claims Set; validation of other claims may be incomplete. */
11
+ payload: t.JWTPayload;
12
+ }
13
+ /** Reason codes produced by JWT Claims Set validation. */
14
+ export type JWTClaimValidationReason = 'check_failed' | 'invalid' | 'mismatch' | 'missing' | 'unspecified' | (string & {});
15
+ /** Base class for JOSE errors. */
16
+ export declare class JOSEError extends Error {
17
+ /** Stable code identifying the error class. */
18
+ static code: JOSEErrorCode | (string & {});
19
+ /** Stable code identifying the error class. Use {@link AnyJOSEError} to narrow subclasses by code. */
20
+ code: JOSEErrorCode | (string & {});
21
+ constructor(message?: string, options?: {
22
+ cause?: unknown;
23
+ });
24
+ }
25
+ /**
26
+ * Thrown when JWT claim or header validation fails. Expiration is reported separately as
27
+ * {@link JWTExpired}.
28
+ */
29
+ export declare class JWTClaimValidationFailed extends JOSEError implements JWTClaimValidationFailure {
30
+ static code: JOSEErrorCode | (string & {});
31
+ code: JOSEErrorCode | (string & {});
32
+ /** The {@link JWTClaimValidationFailure} details carried by this error. */
33
+ cause: JWTClaimValidationFailure;
34
+ /** Claim or header that failed validation. */
35
+ claim: string;
36
+ /** Reason code for the validation failure. */
37
+ reason: JWTClaimValidationReason;
38
+ /**
39
+ * The parsed JWT Claims Set; validation of other claims may be incomplete. With
40
+ * {@link jwt/verify.jwtVerify jwtVerify} and {@link jwt/decrypt.jwtDecrypt jwtDecrypt}, token
41
+ * authentication precedes claim validation. {@link jwt/unsecured.UnsecuredJWT.decode} does not
42
+ * authenticate tokens.
43
+ */
44
+ payload: t.JWTPayload;
45
+ constructor(message: string, payload: t.JWTPayload, claim?: string, reason?: JWTClaimValidationReason);
46
+ }
47
+ /** Thrown when a JWT has expired or exceeds the configured maximum token age. */
48
+ export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailure {
49
+ static code: JOSEErrorCode | (string & {});
50
+ code: JOSEErrorCode | (string & {});
51
+ /** The {@link JWTClaimValidationFailure} details carried by this error. */
52
+ cause: JWTClaimValidationFailure;
53
+ /** Claim or header that failed validation. */
54
+ claim: string;
55
+ /** Reason code for the validation failure. */
56
+ reason: JWTClaimValidationReason;
57
+ /**
58
+ * The parsed JWT Claims Set; validation of other claims may be incomplete. With
59
+ * {@link jwt/verify.jwtVerify jwtVerify} and {@link jwt/decrypt.jwtDecrypt jwtDecrypt}, token
60
+ * authentication precedes claim validation. {@link jwt/unsecured.UnsecuredJWT.decode} does not
61
+ * authenticate tokens.
62
+ */
63
+ payload: t.JWTPayload;
64
+ constructor(message: string, payload: t.JWTPayload, claim?: string, reason?: JWTClaimValidationReason);
65
+ }
66
+ /** Thrown when an algorithm is disallowed by configuration. */
67
+ export declare class JOSEAlgNotAllowed extends JOSEError {
68
+ static code: JOSEErrorCode | (string & {});
69
+ code: JOSEErrorCode | (string & {});
70
+ }
71
+ /** Thrown when a feature or algorithm is unsupported. */
72
+ export declare class JOSENotSupported extends JOSEError {
73
+ static code: JOSEErrorCode | (string & {});
74
+ code: JOSEErrorCode | (string & {});
75
+ }
76
+ /** Thrown when JWE ciphertext decryption or authentication fails. */
77
+ export declare class JWEDecryptionFailed extends JOSEError {
78
+ static code: JOSEErrorCode | (string & {});
79
+ code: JOSEErrorCode | (string & {});
80
+ constructor(message?: string, options?: {
81
+ cause?: unknown;
82
+ });
83
+ }
84
+ /** Thrown when a JWE is invalid. */
85
+ export declare class JWEInvalid extends JOSEError {
86
+ static code: JOSEErrorCode | (string & {});
87
+ code: JOSEErrorCode | (string & {});
88
+ }
89
+ /** Thrown when a JWS is invalid. */
90
+ export declare class JWSInvalid extends JOSEError {
91
+ static code: JOSEErrorCode | (string & {});
92
+ code: JOSEErrorCode | (string & {});
93
+ }
94
+ /** Thrown when a JWT is invalid. */
95
+ export declare class JWTInvalid extends JOSEError {
96
+ static code: JOSEErrorCode | (string & {});
97
+ code: JOSEErrorCode | (string & {});
98
+ }
99
+ /** Thrown when a JWK is invalid. */
100
+ export declare class JWKInvalid extends JOSEError {
101
+ static code: JOSEErrorCode | (string & {});
102
+ code: JOSEErrorCode | (string & {});
103
+ }
104
+ /** Thrown when a JWKS is invalid. */
105
+ export declare class JWKSInvalid extends JOSEError {
106
+ static code: JOSEErrorCode | (string & {});
107
+ code: JOSEErrorCode | (string & {});
108
+ }
109
+ /** Thrown when no keys match in a JWKS. */
110
+ export declare class JWKSNoMatchingKey extends JOSEError {
111
+ static code: JOSEErrorCode | (string & {});
112
+ code: JOSEErrorCode | (string & {});
113
+ constructor(message?: string, options?: {
114
+ cause?: unknown;
115
+ });
116
+ }
117
+ /** Thrown when multiple keys match in a JWKS. */
118
+ export declare class JWKSMultipleMatchingKeys extends JOSEError {
119
+ /**
120
+ * Yields public keys matching the JWS Header so verification can be attempted with each. See the
121
+ * {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} and
122
+ * {@link jwks/local.createLocalJWKSet createLocalJWKSet} examples. Empty on manually constructed
123
+ * errors.
124
+ */
125
+ [Symbol.asyncIterator]: () => AsyncIterableIterator<t.CryptoKey>;
126
+ static code: JOSEErrorCode | (string & {});
127
+ code: JOSEErrorCode | (string & {});
128
+ constructor(message?: string, options?: {
129
+ cause?: unknown;
130
+ });
131
+ }
132
+ /** Thrown when fetching a remote JWKS times out. */
133
+ export declare class JWKSTimeout extends JOSEError {
134
+ static code: JOSEErrorCode | (string & {});
135
+ code: JOSEErrorCode | (string & {});
136
+ constructor(message?: string, options?: {
137
+ cause?: unknown;
138
+ });
139
+ }
140
+ /** Thrown when JWS Signature validation (digital signature or MAC) fails. */
141
+ export declare class JWSSignatureVerificationFailed extends JOSEError {
142
+ static code: JOSEErrorCode | (string & {});
143
+ code: JOSEErrorCode | (string & {});
144
+ constructor(message?: string, options?: {
145
+ cause?: unknown;
146
+ });
147
+ }
148
+ /** Errors thrown during JWT Claims Set validation. */
149
+ export type JWTClaimValidationError = JWTClaimValidationFailed | JWTExpired;
150
+ /**
151
+ * Discriminated union of specific {@link JOSEError} subclasses, narrowed by `code`. Excludes base
152
+ * {@link JOSEError} instances; use `instanceof JOSEError` to catch all module errors.
153
+ */
154
+ export type AnyJOSEError = (JOSEAlgNotAllowed & {
155
+ code: 'ERR_JOSE_ALG_NOT_ALLOWED';
156
+ }) | (JOSENotSupported & {
157
+ code: 'ERR_JOSE_NOT_SUPPORTED';
158
+ }) | (JWEDecryptionFailed & {
159
+ code: 'ERR_JWE_DECRYPTION_FAILED';
160
+ }) | (JWEInvalid & {
161
+ code: 'ERR_JWE_INVALID';
162
+ }) | (JWKInvalid & {
163
+ code: 'ERR_JWK_INVALID';
164
+ }) | (JWKSInvalid & {
165
+ code: 'ERR_JWKS_INVALID';
166
+ }) | (JWKSMultipleMatchingKeys & {
167
+ code: 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
168
+ }) | (JWKSNoMatchingKey & {
169
+ code: 'ERR_JWKS_NO_MATCHING_KEY';
170
+ }) | (JWKSTimeout & {
171
+ code: 'ERR_JWKS_TIMEOUT';
172
+ }) | (JWSInvalid & {
173
+ code: 'ERR_JWS_INVALID';
174
+ }) | (JWSSignatureVerificationFailed & {
175
+ code: 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
176
+ }) | (JWTClaimValidationFailed & {
177
+ code: 'ERR_JWT_CLAIM_VALIDATION_FAILED';
178
+ }) | (JWTExpired & {
179
+ code: 'ERR_JWT_EXPIRED';
180
+ }) | (JWTInvalid & {
181
+ code: 'ERR_JWT_INVALID';
182
+ });
@@ -0,0 +1,70 @@
1
+ import { compactDecrypt } from "./jwe/compact/decrypt.js";
2
+ import { flattenedDecrypt } from "./jwe/flattened/decrypt.js";
3
+ import { generalDecrypt } from "./jwe/general/decrypt.js";
4
+ import { GeneralEncrypt } from "./jwe/general/encrypt.js";
5
+ import { compactVerify } from "./jws/compact/verify.js";
6
+ import { flattenedVerify } from "./jws/flattened/verify.js";
7
+ import { generalVerify } from "./jws/general/verify.js";
8
+ import { jwtVerify } from "./jwt/verify.js";
9
+ import { jwtDecrypt } from "./jwt/decrypt.js";
10
+ import { CompactEncrypt } from "./jwe/compact/encrypt.js";
11
+ import { FlattenedEncrypt } from "./jwe/flattened/encrypt.js";
12
+ import { CompactSign } from "./jws/compact/sign.js";
13
+ import { FlattenedSign } from "./jws/flattened/sign.js";
14
+ import { GeneralSign } from "./jws/general/sign.js";
15
+ import { SignJWT } from "./jwt/sign.js";
16
+ import { EncryptJWT } from "./jwt/encrypt.js";
17
+ import { calculateJwkThumbprint, calculateJwkThumbprintUri } from "./jwk/thumbprint.js";
18
+ import { EmbeddedJWK } from "./jwk/embedded.js";
19
+ import { createLocalJWKSet } from "./jwks/local.js";
20
+ import { createRemoteJWKSet, jwksCache, customFetch } from "./jwks/remote.js";
21
+ import { UnsecuredJWT } from "./jwt/unsecured.js";
22
+ import { exportPKCS8, exportSPKI, exportJWK } from "./key/export.js";
23
+ import { importSPKI, importPKCS8, importX509, importJWK } from "./key/import.js";
24
+ import { decodeProtectedHeader } from "./util/decode_protected_header.js";
25
+ import { decodeJwt } from "./util/decode_jwt.js";
26
+ import * as errors from "./util/errors.js";
27
+ import { generateKeyPair } from "./key/generate_key_pair.js";
28
+ import { generateSecret } from "./key/generate_secret.js";
29
+ import * as base64url from "./util/base64url.js";
30
+ const cryptoRuntime = "WebCryptoAPI";
31
+ export {
32
+ CompactEncrypt,
33
+ CompactSign,
34
+ EmbeddedJWK,
35
+ EncryptJWT,
36
+ FlattenedEncrypt,
37
+ FlattenedSign,
38
+ GeneralEncrypt,
39
+ GeneralSign,
40
+ SignJWT,
41
+ UnsecuredJWT,
42
+ base64url,
43
+ calculateJwkThumbprint,
44
+ calculateJwkThumbprintUri,
45
+ compactDecrypt,
46
+ compactVerify,
47
+ createLocalJWKSet,
48
+ createRemoteJWKSet,
49
+ cryptoRuntime,
50
+ customFetch,
51
+ decodeJwt,
52
+ decodeProtectedHeader,
53
+ errors,
54
+ exportJWK,
55
+ exportPKCS8,
56
+ exportSPKI,
57
+ flattenedDecrypt,
58
+ flattenedVerify,
59
+ generalDecrypt,
60
+ generalVerify,
61
+ generateKeyPair,
62
+ generateSecret,
63
+ importJWK,
64
+ importPKCS8,
65
+ importSPKI,
66
+ importX509,
67
+ jwksCache,
68
+ jwtDecrypt,
69
+ jwtVerify
70
+ };
@@ -0,0 +1,7 @@
1
+ import { prepareDecrypt, decryptCompact } from "../../lib/jwe_decrypt.js";
2
+ async function compactDecrypt(jwe, key, options) {
3
+ return decryptCompact(jwe, prepareDecrypt(options), key);
4
+ }
5
+ export {
6
+ compactDecrypt
7
+ };
@@ -0,0 +1,26 @@
1
+ import { assertNotSet, assertUint8Array } from "../../lib/validate.js";
2
+ import { compactJWE, createJWE } from "../../lib/jwe_encrypt.js";
3
+ class CompactEncrypt {
4
+ #input;
5
+ constructor(plaintext) {
6
+ assertUint8Array(plaintext, "plaintext"), this.#input = [plaintext];
7
+ }
8
+ setContentEncryptionKey(cek) {
9
+ return assertNotSet(this.#input[5], "setContentEncryptionKey"), this.#input[5] = cek, this;
10
+ }
11
+ setInitializationVector(iv) {
12
+ return assertNotSet(this.#input[6], "setInitializationVector"), this.#input[6] = iv, this;
13
+ }
14
+ setProtectedHeader(protectedHeader) {
15
+ return assertNotSet(this.#input[1], "setProtectedHeader"), this.#input[1] = protectedHeader, this;
16
+ }
17
+ setKeyManagementParameters(parameters) {
18
+ return assertNotSet(this.#input[7], "setKeyManagementParameters"), this.#input[7] = parameters, this;
19
+ }
20
+ async encrypt(key, options) {
21
+ return compactJWE(await createJWE([...this.#input], key, options));
22
+ }
23
+ }
24
+ export {
25
+ CompactEncrypt
26
+ };
@@ -0,0 +1,15 @@
1
+ import { JWEInvalid } from "../../util/errors.js";
2
+ import { isObject } from "../../lib/validate.js";
3
+ import { prepareDecrypt, decryptJWE, checkRecipient, snapshotSharedJWE, snapshotRecipientJWE } from "../../lib/jwe_decrypt.js";
4
+ async function flattenedDecrypt(jwe, key, options) {
5
+ if (!isObject(jwe))
6
+ throw new JWEInvalid("Flattened JWE must be an object");
7
+ const shared = snapshotSharedJWE(jwe), [recipient, , error] = snapshotRecipientJWE(jwe);
8
+ if (!recipient)
9
+ throw error;
10
+ const snapshot = { ...shared, ...recipient };
11
+ return checkRecipient(snapshot), decryptJWE(snapshot, prepareDecrypt(options), key);
12
+ }
13
+ export {
14
+ flattenedDecrypt
15
+ };
@@ -0,0 +1,35 @@
1
+ import { assertNotSet, assertUint8Array } from "../../lib/validate.js";
2
+ import { createJWE } from "../../lib/jwe_encrypt.js";
3
+ class FlattenedEncrypt {
4
+ #input;
5
+ constructor(plaintext) {
6
+ assertUint8Array(plaintext, "plaintext"), this.#input = [plaintext];
7
+ }
8
+ setKeyManagementParameters(parameters) {
9
+ return assertNotSet(this.#input[7], "setKeyManagementParameters"), this.#input[7] = parameters, this;
10
+ }
11
+ setProtectedHeader(protectedHeader) {
12
+ return assertNotSet(this.#input[1], "setProtectedHeader"), this.#input[1] = protectedHeader, this;
13
+ }
14
+ setSharedUnprotectedHeader(sharedUnprotectedHeader) {
15
+ return assertNotSet(this.#input[3], "setSharedUnprotectedHeader"), this.#input[3] = sharedUnprotectedHeader, this;
16
+ }
17
+ setUnprotectedHeader(unprotectedHeader) {
18
+ return assertNotSet(this.#input[2], "setUnprotectedHeader"), this.#input[2] = unprotectedHeader, this;
19
+ }
20
+ setAdditionalAuthenticatedData(aad) {
21
+ return this.#input[4] = aad, this;
22
+ }
23
+ setContentEncryptionKey(cek) {
24
+ return assertNotSet(this.#input[5], "setContentEncryptionKey"), this.#input[5] = cek, this;
25
+ }
26
+ setInitializationVector(iv) {
27
+ return assertNotSet(this.#input[6], "setInitializationVector"), this.#input[6] = iv, this;
28
+ }
29
+ async encrypt(key, options) {
30
+ return createJWE([...this.#input], key, options);
31
+ }
32
+ }
33
+ export {
34
+ FlattenedEncrypt
35
+ };
@@ -0,0 +1,41 @@
1
+ import { prepareDecrypt, shareJWE, decryptJWE, checkRecipient, snapshotSharedJWE, snapshotRecipientJWE } from "../../lib/jwe_decrypt.js";
2
+ import { JWEDecryptionFailed, JWEInvalid } from "../../util/errors.js";
3
+ import { isObject } from "../../lib/validate.js";
4
+ import { JWE, isJWECEKTransport } from "../../lib/jwe_algorithms.js";
5
+ async function generalDecrypt(jwe, key, options) {
6
+ if (!isObject(jwe))
7
+ throw new JWEInvalid("General JWE must be an object");
8
+ const inputRecipients = jwe.recipients;
9
+ if (!Array.isArray(inputRecipients))
10
+ throw new JWEInvalid("JWE Recipients missing or incorrect type");
11
+ const recipients = Array.from(inputRecipients);
12
+ if (!recipients.every(isObject))
13
+ throw new JWEInvalid("JWE Recipients missing or incorrect type");
14
+ if (!recipients.length)
15
+ throw new JWEInvalid("JWE Recipients has no members");
16
+ const shared = prepareDecrypt(options);
17
+ let sharedJwe, token;
18
+ try {
19
+ sharedJwe = snapshotSharedJWE(jwe), token = shareJWE(sharedJwe);
20
+ } catch {
21
+ throw new JWEDecryptionFailed();
22
+ }
23
+ const recipientSnapshots = recipients.map((recipient) => snapshotRecipientJWE(recipient));
24
+ if (recipients.length > 1)
25
+ for (const [, headerAlg] of recipientSnapshots) {
26
+ const alg = token[0]?.alg ?? headerAlg ?? sharedJwe.unprotected?.alg, algEntry = typeof alg == "string" ? JWE[alg] : void 0;
27
+ if (algEntry && !isJWECEKTransport(algEntry))
28
+ throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
29
+ }
30
+ for (const [recipient] of recipientSnapshots)
31
+ if (recipient)
32
+ try {
33
+ const flattened = { ...sharedJwe, ...recipient };
34
+ return checkRecipient(flattened), await decryptJWE(flattened, shared, key, token);
35
+ } catch {
36
+ }
37
+ throw new JWEDecryptionFailed();
38
+ }
39
+ export {
40
+ generalDecrypt
41
+ };
@@ -0,0 +1,105 @@
1
+ import { assertNotSet, assertUint8Array } from "../../lib/validate.js";
2
+ import { JWEInvalid } from "../../util/errors.js";
3
+ import { generateCek } from "../../lib/content_encryption.js";
4
+ import { encode as b64u } from "../../util/base64url.js";
5
+ import { checkDisjoint, checkEncryptHeaders, encryptJWE } from "../../lib/jwe_encrypt.js";
6
+ import { encryptKeyManagement } from "../../lib/key_management.js";
7
+ import { isJWECEKTransport, jweAlgorithm } from "../../lib/jwe_algorithms.js";
8
+ class IndividualRecipient {
9
+ #parent;
10
+ state;
11
+ constructor(enc, key, crit) {
12
+ this.#parent = enc, this.state = [void 0, void 0, key, crit];
13
+ }
14
+ setUnprotectedHeader(unprotectedHeader) {
15
+ return assertNotSet(this.state[0], "setUnprotectedHeader"), this.state[0] = unprotectedHeader, this;
16
+ }
17
+ setKeyManagementParameters(parameters) {
18
+ return assertNotSet(this.state[1], "setKeyManagementParameters"), this.state[1] = parameters, this;
19
+ }
20
+ addRecipient(...args) {
21
+ return this.#parent.addRecipient(...args);
22
+ }
23
+ encrypt(...args) {
24
+ return this.#parent.encrypt(...args);
25
+ }
26
+ done() {
27
+ return this.#parent;
28
+ }
29
+ }
30
+ class GeneralEncrypt {
31
+ #plaintext;
32
+ #recipients = [];
33
+ #protectedHeader;
34
+ #sharedUnprotectedHeader;
35
+ #aad;
36
+ constructor(plaintext) {
37
+ this.#plaintext = plaintext;
38
+ }
39
+ addRecipient(key, options) {
40
+ const recipient = new IndividualRecipient(this, key, options?.crit);
41
+ return this.#recipients.push(recipient), recipient;
42
+ }
43
+ setProtectedHeader(protectedHeader) {
44
+ return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
45
+ }
46
+ setSharedUnprotectedHeader(sharedUnprotectedHeader) {
47
+ return assertNotSet(this.#sharedUnprotectedHeader, "setSharedUnprotectedHeader"), this.#sharedUnprotectedHeader = sharedUnprotectedHeader, this;
48
+ }
49
+ setAdditionalAuthenticatedData(aad) {
50
+ return this.#aad = aad, this;
51
+ }
52
+ async encrypt() {
53
+ if (!this.#recipients.length)
54
+ throw new JWEInvalid("at least one recipient must be added");
55
+ assertUint8Array(this.#plaintext, "plaintext");
56
+ const multiple = this.#recipients.length > 1;
57
+ let enc, protectedHeader = this.#protectedHeader, sharedUnprotectedHeader = this.#sharedUnprotectedHeader;
58
+ const recipients = [];
59
+ for (const recipient of this.#recipients) {
60
+ const [unprotectedHeader, keyManagementParameters, key, crit] = recipient.state, input = [
61
+ this.#plaintext,
62
+ protectedHeader,
63
+ unprotectedHeader,
64
+ sharedUnprotectedHeader,
65
+ this.#aad,
66
+ void 0,
67
+ void 0,
68
+ keyManagementParameters,
69
+ crit,
70
+ multiple
71
+ ], headers = checkEncryptHeaders(input, void 0, recipients.length > 0);
72
+ recipients.length || (protectedHeader = input[1], sharedUnprotectedHeader = input[3]), recipients.push([input, headers, key]);
73
+ const [{ alg, enc: recipientEnc }, , algEntry] = headers;
74
+ if (multiple && algEntry && !isJWECEKTransport(algEntry))
75
+ throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
76
+ if (!enc)
77
+ enc = recipientEnc;
78
+ else if (enc !== recipientEnc)
79
+ throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');
80
+ }
81
+ for (const [, headers] of recipients)
82
+ headers[2] ??= jweAlgorithm(headers[0].alg);
83
+ const [firstInput, firstHeaders, firstKey] = recipients[0], cek = multiple ? generateCek(firstHeaders[1]) : void 0;
84
+ firstInput[5] = cek;
85
+ const { encrypted_key, header, ...shared } = await encryptJWE(firstInput, firstHeaders, firstKey), jwe = {
86
+ ...shared,
87
+ recipients: [{}]
88
+ };
89
+ encrypted_key && (jwe.recipients[0].encrypted_key = encrypted_key), header && (jwe.recipients[0].header = header);
90
+ for (let i = 1; i < recipients.length; i++) {
91
+ const [input, [joseHeader, encEntry, algEntry], key] = recipients[i], unprotectedHeader = input[2], [, encryptedKey, parameters] = await encryptKeyManagement(algEntry, encEntry, key, joseHeader, cek, input[7]), target = {
92
+ encrypted_key: b64u(encryptedKey)
93
+ };
94
+ if (unprotectedHeader || parameters) {
95
+ const header2 = { ...unprotectedHeader, ...parameters };
96
+ parameters && checkDisjoint(input[1], header2, input[3]), target.header = header2;
97
+ }
98
+ jwe.recipients.push(target);
99
+ }
100
+ return jwe;
101
+ }
102
+ }
103
+ export {
104
+ GeneralEncrypt
105
+ };
@@ -0,0 +1,30 @@
1
+ import { jwkToKey, normalizeJwk } from "../lib/key.js";
2
+ import { jwsAlgorithm } from "../lib/jws_algorithms.js";
3
+ import { isObject } from "../lib/validate.js";
4
+ import { JWSInvalid } from "../util/errors.js";
5
+ async function EmbeddedJWK(protectedHeader, token) {
6
+ const joseHeader = {
7
+ ...protectedHeader,
8
+ ...token?.header
9
+ };
10
+ if (!isObject(joseHeader.jwk))
11
+ throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
12
+ let jwk;
13
+ try {
14
+ jwk = normalizeJwk(joseHeader.jwk);
15
+ } catch (cause) {
16
+ throw new JWSInvalid("Invalid Embedded JWK", { cause });
17
+ }
18
+ const entry = jwsAlgorithm(joseHeader.alg);
19
+ if (jwk.use !== void 0 && jwk.use !== "sig")
20
+ throw new JWSInvalid('Invalid Embedded JWK, its "use" must be "sig" when present');
21
+ if (jwk.alg !== void 0 && jwk.alg !== entry.alg)
22
+ throw new JWSInvalid(`Invalid Embedded JWK, its "alg" must be "${entry.alg}" when present`);
23
+ const key = await jwkToKey(entry, jwk, !0);
24
+ if (key.type !== "public")
25
+ throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
26
+ return key;
27
+ }
28
+ export {
29
+ EmbeddedJWK
30
+ };
@@ -0,0 +1,55 @@
1
+ import { digest, encode } from "../lib/buffer_utils.js";
2
+ import { encode as b64u } from "../util/base64url.js";
3
+ import { JOSENotSupported, JWKInvalid } from "../util/errors.js";
4
+ import { isKeyLike, invalidKeyInput, snapshotJwk } from "../lib/key.js";
5
+ import { isObject } from "../lib/validate.js";
6
+ import { exportJWK } from "../key/export.js";
7
+ const check = (value, description) => {
8
+ if (typeof value != "string" || !value)
9
+ throw new JWKInvalid(`${description} missing or invalid`);
10
+ };
11
+ async function calculateJwkThumbprint(key, digestAlgorithm) {
12
+ let jwk;
13
+ if (isObject(key)) {
14
+ if (jwk = snapshotJwk(key), typeof jwk.kty != "string")
15
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
16
+ } else if (isKeyLike(key))
17
+ jwk = snapshotJwk(await exportJWK(key));
18
+ else
19
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
20
+ if (digestAlgorithm ??= "sha256", digestAlgorithm !== "sha256" && digestAlgorithm !== "sha384" && digestAlgorithm !== "sha512")
21
+ throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');
22
+ let requiredMembers;
23
+ switch (jwk.kty) {
24
+ case "AKP":
25
+ check(jwk.alg, '"alg" (Algorithm) Parameter'), check(jwk.pub, '"pub" (Public key) Parameter'), requiredMembers = { alg: jwk.alg, kty: jwk.kty, pub: jwk.pub };
26
+ break;
27
+ case "EC":
28
+ check(jwk.crv, '"crv" (Curve) Parameter'), check(jwk.x, '"x" (X Coordinate) Parameter'), check(jwk.y, '"y" (Y Coordinate) Parameter'), requiredMembers = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };
29
+ break;
30
+ case "OKP":
31
+ check(jwk.crv, '"crv" (Subtype of Key Pair) Parameter'), check(jwk.x, '"x" (Public Key) Parameter'), requiredMembers = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };
32
+ break;
33
+ case "RSA":
34
+ check(jwk.e, '"e" (Exponent) Parameter'), check(jwk.n, '"n" (Modulus) Parameter'), requiredMembers = { e: jwk.e, kty: jwk.kty, n: jwk.n };
35
+ break;
36
+ case "oct":
37
+ if (typeof jwk.k != "string")
38
+ throw new JWKInvalid('"k" (Key Value) Parameter missing or invalid');
39
+ requiredMembers = { k: jwk.k, kty: jwk.kty };
40
+ break;
41
+ default:
42
+ throw new JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported');
43
+ }
44
+ const thumbprintInput = encode(JSON.stringify(requiredMembers));
45
+ return b64u(await digest(digestAlgorithm, thumbprintInput));
46
+ }
47
+ async function calculateJwkThumbprintUri(key, digestAlgorithm) {
48
+ digestAlgorithm ??= "sha256";
49
+ const thumbprint = await calculateJwkThumbprint(key, digestAlgorithm);
50
+ return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
51
+ }
52
+ export {
53
+ calculateJwkThumbprint,
54
+ calculateJwkThumbprintUri
55
+ };