@sphereon/ssi-sdk-ext.jwt-service 0.26.1-next.3 → 0.26.1-next.31

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.
@@ -10,7 +10,7 @@ import {
10
10
  ManagedIdentifierResult,
11
11
  resolveExternalJwkIdentifier,
12
12
  } from '@sphereon/ssi-sdk-ext.identifier-resolution'
13
- import { keyTypeFromCryptographicSuite, verifySignatureWithSubtle } from '@sphereon/ssi-sdk-ext.key-utils'
13
+ import { keyTypeFromCryptographicSuite, verifyRawSignature } from '@sphereon/ssi-sdk-ext.key-utils'
14
14
  import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
15
15
  import { JWK } from '@sphereon/ssi-types'
16
16
  import { IAgentContext } from '@veramo/core'
@@ -32,11 +32,13 @@ import {
32
32
  JwsJsonFlattened,
33
33
  JwsJsonGeneral,
34
34
  JwsJsonGeneralWithIdentifiers,
35
- JwsJsonSignature, JwsJsonSignatureWithIdentifier,
35
+ JwsJsonSignature,
36
+ JwsJsonSignatureWithIdentifier,
36
37
  JwsHeader,
37
38
  JwsPayload,
38
39
  PreparedJwsObject,
39
- VerifyJwsArgs, JweHeader,
40
+ VerifyJwsArgs,
41
+ JweHeader,
40
42
  } from '../types/IJwtService'
41
43
 
42
44
  const payloadToBytes = (payload: string | JwsPayload | Uint8Array): Uint8Array => {
@@ -321,12 +323,12 @@ export const verifyJws = async (args: VerifyJwsArgs, context: IAgentContext<IIde
321
323
  signature: sigWithId.signature,
322
324
  data,
323
325
  publicKeyHex,
324
- type: keyTypeFromCryptographicSuite({ suite: jwkInfo.jwk.crv ?? 'ES256' }),
326
+ type: keyTypeFromCryptographicSuite({ crv: jwkInfo.jwk.crv ?? 'ES256' }),
325
327
  // no kms arg, as the current key manager needs a bit more work
326
328
  })
327
329
  } else {
328
330
  const signature = base64ToBytes(sigWithId.signature)
329
- valid = await verifySignatureWithSubtle({ data, signature, key: jwkInfo.jwk })
331
+ valid = await verifyRawSignature({ data, signature, key: jwkInfo.jwk })
330
332
  }
331
333
  if (!valid) {
332
334
  errorMessages.push(`Signature ${index} was not valid`)
@@ -412,11 +414,7 @@ async function resolveExternalIdentifierFromJwsHeader(
412
414
  }
413
415
  }
414
416
 
415
- function loadJWK(
416
- providedJwk: JWK | undefined,
417
- protectedHeader: JwsHeader,
418
- jws: JwsJsonGeneral,
419
- ): JWK | undefined {
417
+ function loadJWK(providedJwk: JWK | undefined, protectedHeader: JwsHeader, jws: JwsJsonGeneral): JWK | undefined {
420
418
  if (providedJwk) {
421
419
  return providedJwk
422
420
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {Loggers} from "@sphereon/ssi-types";
1
+ import { Loggers } from '@sphereon/ssi-types'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -1,67 +1,60 @@
1
1
  import {
2
- ExternalIdentifierDidOpts,
3
- ExternalIdentifierResult,
4
- ExternalIdentifierX5cOpts,
5
- IIdentifierResolution,
6
- ManagedIdentifierOptsOrResult,
7
- ManagedIdentifierResult,
2
+ ExternalIdentifierDidOpts,
3
+ ExternalIdentifierResult,
4
+ ExternalIdentifierX5cOpts,
5
+ IIdentifierResolution,
6
+ ManagedIdentifierOptsOrResult,
7
+ ManagedIdentifierResult,
8
8
  } from '@sphereon/ssi-sdk-ext.identifier-resolution'
9
- import {ClientIdScheme} from '@sphereon/ssi-sdk-ext.x509-utils'
10
- import {
11
- BaseJWK,
12
- IValidationResult,
13
- JoseSignatureAlgorithm,
14
- JoseSignatureAlgorithmString,
15
- JWK
16
- } from '@sphereon/ssi-types'
17
- import {IAgentContext, IKeyManager, IPluginMethodMap} from '@veramo/core'
9
+ import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
10
+ import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
11
+ import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
18
12
 
19
13
  export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager> // could we still interop with Veramo?
20
14
 
21
15
  export const jwtServiceContextMethods: Array<string> = [
22
- 'jwtPrepareJws',
23
- 'jwtCreateJwsJsonGeneralSignature',
24
- 'jwtCreateJwsJsonFlattenedSignature',
25
- 'jwtCreateJwsCompactSignature',
26
- 'jwtVerifyJwsSignature',
27
- 'jwtEncryptJweCompactJwt',
28
- 'jwtDecryptJweCompactJwt'
16
+ 'jwtPrepareJws',
17
+ 'jwtCreateJwsJsonGeneralSignature',
18
+ 'jwtCreateJwsJsonFlattenedSignature',
19
+ 'jwtCreateJwsCompactSignature',
20
+ 'jwtVerifyJwsSignature',
21
+ 'jwtEncryptJweCompactJwt',
22
+ 'jwtDecryptJweCompactJwt',
29
23
  ]
30
24
 
31
25
  export interface IJwtService extends IPluginMethodMap {
32
- jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>
26
+ jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>
33
27
 
34
- jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>
28
+ jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>
35
29
 
36
- jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>
30
+ jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>
37
31
 
38
- jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>
32
+ jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>
39
33
 
40
- jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>
34
+ jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>
41
35
 
42
- jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
36
+ jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
43
37
 
44
- jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
38
+ jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
45
39
 
46
- // TODO: JWE/encryption general methods
40
+ // TODO: JWE/encryption general methods
47
41
  }
48
42
 
49
43
  export type IJwsValidationResult = IValidationResult & {
50
- jws: JwsJsonGeneralWithIdentifiers // We always translate to general as that is the most flexible format allowing multiple sigs
51
-
44
+ jws: JwsJsonGeneralWithIdentifiers // We always translate to general as that is the most flexible format allowing multiple sigs
52
45
  }
53
46
 
54
47
  export interface PreparedJws {
55
- protectedHeader: JwsHeader
56
- payload: Uint8Array
57
- unprotectedHeader?: JwsHeader // only for jws json and also then optional
58
- existingSignatures?: Array<JwsJsonSignature> // only for jws json and also then optional
48
+ protectedHeader: JwsHeader
49
+ payload: Uint8Array
50
+ unprotectedHeader?: JwsHeader // only for jws json and also then optional
51
+ existingSignatures?: Array<JwsJsonSignature> // only for jws json and also then optional
59
52
  }
60
53
 
61
54
  export interface JwsJsonSignature {
62
- protected: string
63
- header?: JwsHeader
64
- signature: string
55
+ protected: string
56
+ header?: JwsHeader
57
+ signature: string
65
58
  }
66
59
 
67
60
  /**
@@ -74,258 +67,261 @@ export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>
74
67
  // export function isEcJWK(v)
75
68
 
76
69
  export interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
77
- alg: string,
78
- enc: string,
79
- jku?: string,
80
- jwk?: BaseJWK,
81
- epk?: EphemeralPublicKey,
82
- x5u?: string
83
- x5c?: string[]
84
- x5t?: string,
85
- cty?: string,
86
- crit?: string[]
87
-
88
- [k: string]: any
70
+ alg: string
71
+ enc: string
72
+ jku?: string
73
+ jwk?: BaseJWK
74
+ epk?: EphemeralPublicKey
75
+ x5u?: string
76
+ x5c?: string[]
77
+ x5t?: string
78
+ cty?: string
79
+ crit?: string[]
89
80
 
81
+ [k: string]: any
90
82
  }
91
83
 
92
-
93
84
  export interface JweRecipientUnprotectedHeader {
94
- alg: string
95
- iv: string
96
- tag: string
97
- epk?: EphemeralPublicKey
98
- kid?: string
99
- apv?: string
100
- apu?: string
85
+ alg: string
86
+ iv: string
87
+ tag: string
88
+ epk?: EphemeralPublicKey
89
+ kid?: string
90
+ apv?: string
91
+ apu?: string
101
92
  }
102
93
 
103
94
  export interface JweProtectedHeader extends Partial<JweHeader> {
104
- zip?: 'DEF' | string
95
+ zip?: 'DEF' | string
105
96
  }
106
97
 
107
-
108
98
  export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral
109
99
 
110
100
  export type JwsCompact = string
111
101
 
112
102
  export interface JwsJsonFlattened {
113
- payload: string
114
- protected: string
115
- header?: JwsHeader
116
- signature: string
103
+ payload: string
104
+ protected: string
105
+ header?: JwsHeader
106
+ signature: string
117
107
  }
118
108
 
119
109
  export interface JwsJsonGeneral {
120
- payload: string
121
- signatures: Array<JwsJsonSignature>
110
+ payload: string
111
+ signatures: Array<JwsJsonSignature>
122
112
  }
123
113
 
124
114
  export interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
125
- signatures: Array<JwsJsonSignatureWithIdentifier>
115
+ signatures: Array<JwsJsonSignatureWithIdentifier>
126
116
  }
127
117
 
128
118
  export interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
129
- identifier: ExternalIdentifierResult
119
+ identifier: ExternalIdentifierResult
130
120
  }
131
121
 
132
-
133
122
  export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral
134
123
  export type JweCompact = string
135
124
 
136
125
  export interface JweJsonFlattened {
137
- protected: string
138
- unprotected: JweHeader
139
- header: JweHeader | JweRecipientUnprotectedHeader
140
- encrypted_key?: string
141
- aad?: string
142
- iv: string
143
- ciphertext: string
144
- tag?: string
126
+ protected: string
127
+ unprotected: JweHeader
128
+ header: JweHeader | JweRecipientUnprotectedHeader
129
+ encrypted_key?: string
130
+ aad?: string
131
+ iv: string
132
+ ciphertext: string
133
+ tag?: string
145
134
  }
146
135
 
147
-
148
136
  export interface JweRecipient {
149
- header?: JweRecipientUnprotectedHeader
150
- encrypted_key?: string
137
+ header?: JweRecipientUnprotectedHeader
138
+ encrypted_key?: string
151
139
  }
152
140
 
153
141
  export interface JweJsonGeneral {
154
- protected: string
155
- unprotected?: JweHeader
156
- recipients: Array<JweRecipient>
157
- aad?: string
158
- iv: string
159
- ciphertext: string
160
- tag?: string
142
+ protected: string
143
+ unprotected?: JweHeader
144
+ recipients: Array<JweRecipient>
145
+ aad?: string
146
+ iv: string
147
+ ciphertext: string
148
+ tag?: string
161
149
  }
162
150
 
163
-
164
151
  export interface PreparedJwsObject {
165
- jws: PreparedJws
166
- b64: { payload: string; protectedHeader: string } // header is always json, as it can only be used in JwsJson
167
- identifier: ManagedIdentifierResult
152
+ jws: PreparedJws
153
+ b64: { payload: string; protectedHeader: string } // header is always json, as it can only be used in JwsJson
154
+ identifier: ManagedIdentifierResult
168
155
  }
169
156
 
170
157
  export interface BaseJwtHeader {
171
- typ?: string
172
- alg?: string
173
- kid?: string
158
+ typ?: string
159
+ alg?: string
160
+ kid?: string
174
161
  }
175
162
 
176
163
  export interface BaseJwtPayload {
177
- iss?: string
178
- sub?: string
179
- aud?: string[] | string
180
- exp?: number
181
- nbf?: number
182
- iat?: number
183
- jti?: string
164
+ iss?: string
165
+ sub?: string
166
+ aud?: string[] | string
167
+ exp?: number
168
+ nbf?: number
169
+ iat?: number
170
+ jti?: string
184
171
  }
185
172
 
186
173
  export interface JwsHeader extends BaseJwtHeader {
187
- kid?: string
188
- jwk?: JWK
189
- x5c?: string[]
174
+ kid?: string
175
+ jwk?: JWK
176
+ x5c?: string[]
190
177
 
191
- [key: string]: unknown
178
+ [key: string]: unknown
192
179
  }
193
180
 
194
181
  export interface JwsPayload extends BaseJwtPayload {
195
- [key: string]: unknown
182
+ [key: string]: unknown
196
183
  }
197
184
 
198
185
  export interface JwsHeaderOpts {
199
- alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString
186
+ alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString
200
187
  }
201
188
 
202
189
  export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
203
190
 
204
191
  export type EncryptJweCompactJwtArgs = {
205
- payload: JwsPayload,
206
- protectedHeader?: JweProtectedHeader | undefined,
207
- aad?: Uint8Array | undefined
208
- recipientKey: ExternalIdentifierResult & { kid?: string}
209
- alg?: JweAlg
210
- enc?: JweEnc
211
- apu?: string // base64url
212
- apv?: string // base64url
213
- expirationTime?: number | string | Date
214
- issuer?: string
215
- audience?: string | string[]
192
+ payload: JwsPayload
193
+ protectedHeader?: JweProtectedHeader | undefined
194
+ aad?: Uint8Array | undefined
195
+ recipientKey: ExternalIdentifierResult & { kid?: string }
196
+ alg?: JweAlg
197
+ enc?: JweEnc
198
+ apu?: string // base64url
199
+ apv?: string // base64url
200
+ expirationTime?: number | string | Date
201
+ issuer?: string
202
+ audience?: string | string[]
216
203
  }
217
204
 
218
205
  export type DecryptJweCompactJwtArgs = {
219
- jwe: JweCompact
220
- idOpts: ManagedIdentifierOptsOrResult
206
+ jwe: JweCompact
207
+ idOpts: ManagedIdentifierOptsOrResult
221
208
  }
222
209
 
223
210
  export type CreateJwsArgs = {
224
- mode?: JwsIdentifierMode
225
- issuer: ManagedIdentifierOptsOrResult & {
226
- noIssPayloadUpdate?: boolean
227
- noIdentifierInHeader?: boolean
228
- }
229
- clientId?: string
230
- clientIdScheme?: ClientIdScheme | 'did' | string
231
- protectedHeader: JwsHeader
232
- payload: JwsPayload | Uint8Array | string
211
+ mode?: JwsIdentifierMode
212
+ issuer: ManagedIdentifierOptsOrResult & {
213
+ noIssPayloadUpdate?: boolean
214
+ noIdentifierInHeader?: boolean
215
+ }
216
+ clientId?: string
217
+ clientIdScheme?: ClientIdScheme | 'did' | string
218
+ protectedHeader: JwsHeader
219
+ payload: JwsPayload | Uint8Array | string
233
220
  }
234
221
 
235
-
236
222
  export type CreateJweArgs = {
237
- mode?: JwsIdentifierMode
238
- issuer: ManagedIdentifierOptsOrResult & {
239
- noIssPayloadUpdate?: boolean
240
- noIdentifierInHeader?: boolean
241
- }
242
- protectedHeader: JweProtectedHeader
243
- encryptedKey: string | EphemeralPublicKey // In case it is a string it is already encrypted; otherwise encrypt //TODO ??
244
- iv: string
245
- ciphertext: string
246
- tag: string
223
+ mode?: JwsIdentifierMode
224
+ issuer: ManagedIdentifierOptsOrResult & {
225
+ noIssPayloadUpdate?: boolean
226
+ noIdentifierInHeader?: boolean
227
+ }
228
+ protectedHeader: JweProtectedHeader
229
+ encryptedKey: string | EphemeralPublicKey // In case it is a string it is already encrypted; otherwise encrypt //TODO ??
230
+ iv: string
231
+ ciphertext: string
232
+ tag: string
247
233
  }
248
234
  export type CreateJwsCompactArgs = CreateJwsArgs
249
235
 
250
236
  export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>
251
237
 
252
-
253
-
254
-
255
238
  export type VerifyJwsArgs = {
256
- jws: Jws
257
- jwk?: JWK // Jwk will be resolved from jws, but you can also provide one
258
- opts?: { x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>; did?: Omit<ExternalIdentifierDidOpts, 'identifier'> }
239
+ jws: Jws
240
+ jwk?: JWK // Jwk will be resolved from jws, but you can also provide one
241
+ opts?: { x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>; did?: Omit<ExternalIdentifierDidOpts, 'identifier'> }
259
242
  }
260
243
 
261
244
  /**
262
245
  * @public
263
246
  */
264
247
  export type CreateJwsJsonArgs = CreateJwsArgs & {
265
- unprotectedHeader?: JwsHeader // only for jws json
266
- existingSignatures?: Array<JwsJsonSignature> // Only for jws json
248
+ unprotectedHeader?: JwsHeader // only for jws json
249
+ existingSignatures?: Array<JwsJsonSignature> // Only for jws json
267
250
  }
268
251
 
269
252
  export type CreateJweJsonArgs = CreateJweArgs & {
270
- unprotectedHeader?: JweHeader
253
+ unprotectedHeader?: JweHeader
271
254
  }
272
255
 
273
256
  /**
274
257
  * @public
275
258
  */
276
259
  export interface JwtCompactResult {
277
- jwt: JwsCompact | JweCompact
260
+ jwt: JwsCompact | JweCompact
278
261
  }
279
262
 
280
263
  export function isJwsCompact(jws: Jws): jws is JwsCompact {
281
- return typeof jws === 'string' && jws.split('~')[0].match(COMPACT_JWS_REGEX) !== null
264
+ return typeof jws === 'string' && jws.split('~')[0].match(COMPACT_JWS_REGEX) !== null
282
265
  }
283
266
 
284
267
  export function isJweCompact(jwe: Jwe): jwe is JweCompact {
285
- return typeof jwe === 'string' && jwe.split('~')[0].match(COMPACT_JWE_REGEX) !== null
268
+ return typeof jwe === 'string' && jwe.split('~')[0].match(COMPACT_JWE_REGEX) !== null
286
269
  }
287
270
 
288
-
289
271
  export function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened {
290
- return typeof jws === 'object' && 'signature' in jws && 'protected' in jws && !('ciphertext' in jws)
272
+ return typeof jws === 'object' && 'signature' in jws && 'protected' in jws && !('ciphertext' in jws)
291
273
  }
292
274
 
293
275
  export function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral {
294
- return typeof jws === 'object' && 'signatures' in jws && !('ciphertext' in jws)
276
+ return typeof jws === 'object' && 'signatures' in jws && !('ciphertext' in jws)
295
277
  }
296
278
 
297
-
298
279
  export function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened {
299
- return typeof jwe === 'object' && 'signature' in jwe && 'ciphertext' in jwe && !('payload' in jwe)
280
+ return typeof jwe === 'object' && 'signature' in jwe && 'ciphertext' in jwe && !('payload' in jwe)
300
281
  }
301
282
 
302
283
  export function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral {
303
- return typeof jwe === 'object' && 'signatures' in jwe && 'ciphertext' in jwe && !('payload' in jwe)
284
+ return typeof jwe === 'object' && 'signatures' in jwe && 'ciphertext' in jwe && !('payload' in jwe)
304
285
  }
305
286
 
306
-
307
287
  export function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader {
308
- return header && !isJweHeader(header)
288
+ return header && !isJweHeader(header)
309
289
  }
310
290
 
311
291
  export function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader {
312
- return ('enc' in header && header.enc && jweEnc(header.enc)) || (header.alg && jweAlg(header.alg))
292
+ return ('enc' in header && header.enc && jweEnc(header.enc)) || (header.alg && jweAlg(header.alg))
313
293
  }
314
294
 
315
295
  export const COMPACT_JWS_REGEX = /^([a-zA-Z0-9_=-]+).([a-zA-Z0-9_=-]+)?.([a-zA-Z0-9_=-]+)?$/
316
296
  export const COMPACT_JWE_REGEX = /^([a-zA-Z0-9_=-]+)\.([a-zA-Z0-9_=-]+)?\.([a-zA-Z0-9_=-]+)\.([a-zA-Z0-9_=-]+)?\.([a-zA-Z0-9_=-]+)?$/
317
297
 
318
- export const JweAlgs = ['RSA1_5', 'RSA-OAEP', 'RSA-OAEP-256', 'A128KW', 'A192KW', 'A256KW', 'dir', 'ECDH-ES'/*interop value*/, 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW', 'A128GCMKW', 'A192GCMKW', 'A256GCMKW', 'PBES2-HS256+A128KW', 'PBES2-HS384+A192KW', 'PBES2-HS512+A256KW'] as const;
319
- export type JweAlg = typeof JweAlgs[number]
298
+ export const JweAlgs = [
299
+ 'RSA1_5',
300
+ 'RSA-OAEP',
301
+ 'RSA-OAEP-256',
302
+ 'A128KW',
303
+ 'A192KW',
304
+ 'A256KW',
305
+ 'dir',
306
+ 'ECDH-ES' /*interop value*/,
307
+ 'ECDH-ES+A128KW',
308
+ 'ECDH-ES+A192KW',
309
+ 'ECDH-ES+A256KW',
310
+ 'A128GCMKW',
311
+ 'A192GCMKW',
312
+ 'A256GCMKW',
313
+ 'PBES2-HS256+A128KW',
314
+ 'PBES2-HS384+A192KW',
315
+ 'PBES2-HS512+A256KW',
316
+ ] as const
317
+ export type JweAlg = (typeof JweAlgs)[number]
320
318
  export function jweAlg(alg?: string | JweAlg): JweAlg | undefined {
321
- return JweAlgs.find((supportedVal) => supportedVal === alg);
319
+ return JweAlgs.find((supportedVal) => supportedVal === alg)
322
320
  }
323
321
 
324
-
325
- export const JweEncs = ['A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512', 'A128GCM', 'A192GCM', 'A256GCM'/*interop value*/] as const
326
- export type JweEnc = typeof JweEncs[number]
322
+ export const JweEncs = ['A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512', 'A128GCM', 'A192GCM', 'A256GCM' /*interop value*/] as const
323
+ export type JweEnc = (typeof JweEncs)[number]
327
324
 
328
325
  export function jweEnc(alg?: string | JweEnc): JweEnc | undefined {
329
- return JweEncs.find((supportedVal) => supportedVal === alg);
326
+ return JweEncs.find((supportedVal) => supportedVal === alg)
330
327
  }
331
-