@sphereon/ssi-sdk-ext.identifier-resolution 0.26.1-feature.SPRIND.116.8 → 0.26.1-feature.SPRIND.124.esim.28

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 (28) hide show
  1. package/dist/agent/IdentifierResolution.d.ts.map +1 -1
  2. package/dist/agent/IdentifierResolution.js +2 -2
  3. package/dist/agent/IdentifierResolution.js.map +1 -1
  4. package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -1
  5. package/dist/functions/externalIdentifierFunctions.js +2 -2
  6. package/dist/functions/externalIdentifierFunctions.js.map +1 -1
  7. package/dist/functions/externalOIDFIdentifier.d.ts.map +1 -1
  8. package/dist/functions/externalOIDFIdentifier.js +4 -6
  9. package/dist/functions/externalOIDFIdentifier.js.map +1 -1
  10. package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
  11. package/dist/functions/managedIdentifierFunctions.js +18 -17
  12. package/dist/functions/managedIdentifierFunctions.js.map +1 -1
  13. package/dist/types/IIdentifierResolution.d.ts.map +1 -1
  14. package/dist/types/externalIdentifierTypes.d.ts +0 -2
  15. package/dist/types/externalIdentifierTypes.d.ts.map +1 -1
  16. package/dist/types/externalIdentifierTypes.js +1 -1
  17. package/dist/types/externalIdentifierTypes.js.map +1 -1
  18. package/package.json +9 -9
  19. package/plugin.schema.json +12 -43
  20. package/src/agent/IdentifierResolution.ts +17 -10
  21. package/src/functions/externalIdentifierFunctions.ts +2 -3
  22. package/src/functions/externalOIDFIdentifier.ts +9 -18
  23. package/src/functions/managedIdentifierFunctions.ts +21 -18
  24. package/src/types/IIdentifierResolution.ts +9 -3
  25. package/src/types/IJwtService.d.ts +189 -165
  26. package/src/types/common.ts +1 -1
  27. package/src/types/externalIdentifierTypes.ts +10 -5
  28. package/src/types/managedIdentifierTypes.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import { didDocumentToJwks, getAgentResolver, jwkTtoPublicKeyHex } from '@sphereon/ssi-sdk-ext.did-utils'
2
- import { calculateJwkThumbprint, coseKeyToJwk } from '@sphereon/ssi-sdk-ext.key-utils'
2
+ import {calculateJwkThumbprint, coseKeyToJwk, globalCrypto} from '@sphereon/ssi-sdk-ext.key-utils'
3
3
  import {
4
4
  getSubjectDN,
5
5
  pemOrDerToX509Certificate,
@@ -36,7 +36,6 @@ import {
36
36
  } from '../types'
37
37
  import { resolveExternalOIDFEntityIdIdentifier } from '.'
38
38
 
39
-
40
39
  export async function resolveExternalIdentifier(
41
40
  opts: ExternalIdentifierOpts & {
42
41
  crypto?: Crypto
@@ -114,7 +113,7 @@ export async function resolveExternalX5cIdentifier(
114
113
  if (!jwks || jwks.length === 0) {
115
114
  const cryptoEngine = new CryptoEngine({
116
115
  name: 'identifier_resolver_external',
117
- crypto: opts.crypto ?? global.crypto,
116
+ crypto: globalCrypto(false, opts.crypto),
118
117
  })
119
118
  setEngine(cryptoEngine.name, cryptoEngine)
120
119
  jwks = await Promise.all(
@@ -1,15 +1,8 @@
1
- import {
2
- ErrorMessage,
3
- ExternalIdentifierOIDFEntityIdOpts,
4
- ExternalIdentifierOIDFEntityIdResult,
5
- ExternalJwkInfo,
6
- TrustedAnchor,
7
- } from '../types'
8
- import {IAgentContext} from '@veramo/core'
9
- import {IOIDFClient} from '@sphereon/ssi-sdk.oidf-client'
10
- import {contextHasPlugin} from '@sphereon/ssi-sdk.agent-config'
11
- import {IJwsValidationResult, JwsPayload} from '../types/IJwtService'
12
- import {decodeBase64url} from "@veramo/utils";
1
+ import { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
2
+ import { IAgentContext } from '@veramo/core'
3
+ import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
4
+ import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
5
+ import { IJwsValidationResult } from '../types/IJwtService'
13
6
 
14
7
  /**
15
8
  * Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
@@ -43,11 +36,10 @@ export async function resolveExternalOIDFEntityIdIdentifier(
43
36
  const errorList: Record<TrustedAnchor, ErrorMessage> = {}
44
37
  const jwkInfos: Array<ExternalJwkInfo> = []
45
38
 
46
- let payload: JwsPayload | undefined
47
39
  for (const trustAnchor of trustAnchors) {
48
40
  const resolveResult = await context.agent.resolveTrustChain({
49
41
  entityIdentifier: identifier,
50
- trustAnchors: [trustAnchor]
42
+ trustAnchors: [trustAnchor],
51
43
  })
52
44
 
53
45
  if (resolveResult.error || !resolveResult.trustChain) {
@@ -58,7 +50,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
58
50
  errorList[trustAnchor] = 'Trust chain is empty'
59
51
  continue
60
52
  }
61
-
53
+
62
54
  const jwt = trustChain[0]
63
55
  const jwtVerifyResult: IJwsValidationResult = await context.agent.jwtVerifyJwsSignature({ jws: jwt })
64
56
 
@@ -72,14 +64,14 @@ export async function resolveExternalOIDFEntityIdIdentifier(
72
64
  continue
73
65
  }
74
66
 
75
- payload = JSON.parse(decodeBase64url(jwtVerifyResult.jws.payload))
76
67
  const signature = jwtVerifyResult.jws.signatures[0]
77
68
  if (signature.identifier.jwks.length === 0) {
78
69
  errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
79
70
  continue
80
71
  }
81
72
 
82
- if(jwkInfos.length === 0) { // We need the entity JWK only once
73
+ if (jwkInfos.length === 0) {
74
+ // We need the entity JWK only once
83
75
  jwkInfos.push(...signature.identifier.jwks)
84
76
  }
85
77
  trustedAnchors.add(trustAnchor)
@@ -91,7 +83,6 @@ export async function resolveExternalOIDFEntityIdIdentifier(
91
83
  trustedAnchors: Array.from(trustedAnchors),
92
84
  ...(Object.keys(errorList).length > 0 && { errorList }),
93
85
  jwks: jwkInfos,
94
- jwtPayload: payload,
95
86
  trustEstablished: trustedAnchors.size > 0,
96
87
  }
97
88
  }
@@ -1,5 +1,5 @@
1
1
  import { getFirstKeyWithRelation } from '@sphereon/ssi-sdk-ext.did-utils'
2
- import { calculateJwkThumbprint, coseKeyToJwk, toJwk } from '@sphereon/ssi-sdk-ext.key-utils'
2
+ import {calculateJwkThumbprint, coseKeyToJwk, globalCrypto, toJwk} from '@sphereon/ssi-sdk-ext.key-utils'
3
3
  import { pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils'
4
4
  import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.agent-config'
5
5
  import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
@@ -246,7 +246,7 @@ export async function getManagedX5cIdentifier(
246
246
  } else if (!contextHasKeyManager(context)) {
247
247
  return Promise.reject(Error(`Cannot get X5c identifier if KeyManager plugin is not enabled!`))
248
248
  }
249
- const cryptoImpl = opts.crypto ?? crypto
249
+ const cryptoImpl = globalCrypto(false, opts.crypto)
250
250
  const certificate = pemOrDerToX509Certificate(x5c[0])
251
251
  const cryptoEngine = new CryptoEngine({ name: 'identifier_resolver_managed', crypto: cryptoImpl })
252
252
  setEngine(cryptoEngine.name, cryptoEngine)
@@ -274,32 +274,32 @@ export async function getManagedX5cIdentifier(
274
274
  }
275
275
 
276
276
  export async function getManagedOID4VCIssuerIdentifier(
277
- opts: ManagedIdentifierOID4VCIssuerOpts,
278
- context: IAgentContext<IKeyManager>
277
+ opts: ManagedIdentifierOID4VCIssuerOpts,
278
+ context: IAgentContext<IKeyManager>
279
279
  ): Promise<ManagedIdentifierOID4VCIssuerResult> {
280
280
  const { identifier } = opts
281
281
  const method = 'oid4vci-issuer'
282
282
  // FIXME: We need to eventually determine the JWK based on the issuer. Using a dummy JWK for now
283
283
  const jwk = {
284
- "kty" : "RSA",
285
- "kid" : "dummy-jwk-for-vci-issuer-signing",
286
- "use" : "sig",
287
- "n" : "pjdss8ZaDfEH6K6U7GeW2nxDqR4IP049fk1fK0lndimbMMVBdPv_hSpm8T8EtBDxrUdi1OHZfMhUixGaut-3nQ4GG9nM249oxhCtxqqNvEXrmQRGqczyLxuh-fKn9Fg--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Thumbprint({ jwk })
297
297
 
298
298
  const key = {
299
299
  kid: 'dummy-key-for-vci-issuer-signing',
300
300
  kms: 'local',
301
- type: "RSA",
302
- publicKeyHex: '9a3f75b2e4d8b91128fc6e9a8f6782e5a4f1cba3718e58b5d0a789d6e5f52b3a'
301
+ type: 'RSA',
302
+ publicKeyHex: '9a3f75b2e4d8b91128fc6e9a8f6782e5a4f1cba3718e58b5d0a789d6e5f52b3a',
303
303
  } as IKey
304
304
 
305
305
  return {
@@ -344,7 +344,10 @@ export async function getManagedIdentifier(
344
344
  return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`))
345
345
  }
346
346
  const { key } = resolutionResult
347
- if ((!key && !isManagedIdentifierOID4VCIssuerOpts(opts)) || (isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)) {
347
+ if (
348
+ (!key && !isManagedIdentifierOID4VCIssuerOpts(opts)) ||
349
+ (isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)
350
+ ) {
348
351
  console.log(`Cannot find identifier`, opts.identifier)
349
352
  return Promise.reject(`Cannot find identifier ${opts.identifier}`)
350
353
  }
@@ -83,7 +83,10 @@ export interface IIdentifierResolution extends IPluginMethodMap {
83
83
  context: IAgentContext<IKeyManager & IIdentifierResolution>
84
84
  ): Promise<ManagedIdentifierCoseKeyResult>
85
85
 
86
- identifierManagedGetByOID4VCIssuer(args: ManagedIdentifierOID4VCIssuerOpts, context: IAgentContext<any>): Promise<ManagedIdentifierOID4VCIssuerResult>
86
+ identifierManagedGetByOID4VCIssuer(
87
+ args: ManagedIdentifierOID4VCIssuerOpts,
88
+ context: IAgentContext<any>
89
+ ): Promise<ManagedIdentifierOID4VCIssuerResult>
87
90
 
88
91
  // TODO: We can create a custom managed identifier method allowing developers to register a callback function to get their implementation hooked up. Needs more investigation as it would also impact the KMS
89
92
 
@@ -102,6 +105,9 @@ export interface IIdentifierResolution extends IPluginMethodMap {
102
105
  identifierExternalResolveByCoseKey(args: ExternalIdentifierCoseKeyOpts, context: IAgentContext<any>): Promise<ExternalIdentifierCoseKeyResult>
103
106
 
104
107
  identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult>
105
-
106
- identifierExternalResolveByOIDFEntityId(args: ExternalIdentifierOIDFEntityIdOpts, context: IAgentContext<any>): Promise<ExternalIdentifierOIDFEntityIdResult>
108
+
109
+ identifierExternalResolveByOIDFEntityId(
110
+ args: ExternalIdentifierOIDFEntityIdOpts,
111
+ context: IAgentContext<any>
112
+ ): Promise<ExternalIdentifierOIDFEntityIdResult>
107
113
  }
@@ -1,225 +1,249 @@
1
-
2
1
  // Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
3
2
 
4
- import { ExternalIdentifierDidOpts, ExternalIdentifierResult, ExternalIdentifierX5cOpts, IIdentifierResolution, ManagedIdentifierOptsOrResult, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
5
- import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils';
6
- import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types';
7
- import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core';
8
- export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>;
9
- export declare const jwtServiceContextMethods: Array<string>;
3
+ import {
4
+ ExternalIdentifierDidOpts,
5
+ ExternalIdentifierResult,
6
+ ExternalIdentifierX5cOpts,
7
+ IIdentifierResolution,
8
+ ManagedIdentifierOptsOrResult,
9
+ ManagedIdentifierResult,
10
+ } from '@sphereon/ssi-sdk-ext.identifier-resolution'
11
+ import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
12
+ import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
13
+ import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
14
+ export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>
15
+ export declare const jwtServiceContextMethods: Array<string>
10
16
  export interface IJwtService extends IPluginMethodMap {
11
- jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>;
12
- jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>;
13
- jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>;
14
- jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>;
15
- jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>;
16
- jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
17
- jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
17
+ jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>
18
+ jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>
19
+ jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>
20
+ jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>
21
+ jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>
22
+ jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
23
+ jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
18
24
  }
19
25
  export type IJwsValidationResult = IValidationResult & {
20
- jws: JwsJsonGeneralWithIdentifiers;
21
- };
26
+ jws: JwsJsonGeneralWithIdentifiers
27
+ }
22
28
  export interface PreparedJws {
23
- protectedHeader: JwsHeader;
24
- payload: Uint8Array;
25
- unprotectedHeader?: JwsHeader;
26
- existingSignatures?: Array<JwsJsonSignature>;
29
+ protectedHeader: JwsHeader
30
+ payload: Uint8Array
31
+ unprotectedHeader?: JwsHeader
32
+ existingSignatures?: Array<JwsJsonSignature>
27
33
  }
28
34
  export interface JwsJsonSignature {
29
- protected: string;
30
- header?: JwsHeader;
31
- signature: string;
35
+ protected: string
36
+ header?: JwsHeader
37
+ signature: string
32
38
  }
33
39
  /**
34
40
  * The JWK representation of an ephemeral public key.
35
41
  * See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
36
42
  */
37
- export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>;
43
+ export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>
38
44
  export interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
39
- alg: string;
40
- enc: string;
41
- jku?: string;
42
- jwk?: BaseJWK;
43
- epk?: EphemeralPublicKey;
44
- x5u?: string;
45
- x5c?: string[];
46
- x5t?: string;
47
- cty?: string;
48
- crit?: string[];
49
- [k: string]: any;
45
+ alg: string
46
+ enc: string
47
+ jku?: string
48
+ jwk?: BaseJWK
49
+ epk?: EphemeralPublicKey
50
+ x5u?: string
51
+ x5c?: string[]
52
+ x5t?: string
53
+ cty?: string
54
+ crit?: string[]
55
+ [k: string]: any
50
56
  }
51
57
  export interface JweRecipientUnprotectedHeader {
52
- alg: string;
53
- iv: string;
54
- tag: string;
55
- epk?: EphemeralPublicKey;
56
- kid?: string;
57
- apv?: string;
58
- apu?: string;
58
+ alg: string
59
+ iv: string
60
+ tag: string
61
+ epk?: EphemeralPublicKey
62
+ kid?: string
63
+ apv?: string
64
+ apu?: string
59
65
  }
60
66
  export interface JweProtectedHeader extends Partial<JweHeader> {
61
- zip?: 'DEF' | string;
67
+ zip?: 'DEF' | string
62
68
  }
63
- export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral;
64
- export type JwsCompact = string;
69
+ export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral
70
+ export type JwsCompact = string
65
71
  export interface JwsJsonFlattened {
66
- payload: string;
67
- protected: string;
68
- header?: JwsHeader;
69
- signature: string;
72
+ payload: string
73
+ protected: string
74
+ header?: JwsHeader
75
+ signature: string
70
76
  }
71
77
  export interface JwsJsonGeneral {
72
- payload: string;
73
- signatures: Array<JwsJsonSignature>;
78
+ payload: string
79
+ signatures: Array<JwsJsonSignature>
74
80
  }
75
81
  export interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
76
- signatures: Array<JwsJsonSignatureWithIdentifier>;
82
+ signatures: Array<JwsJsonSignatureWithIdentifier>
77
83
  }
78
84
  export interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
79
- identifier: ExternalIdentifierResult;
85
+ identifier: ExternalIdentifierResult
80
86
  }
81
- export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral;
82
- export type JweCompact = string;
87
+ export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral
88
+ export type JweCompact = string
83
89
  export interface JweJsonFlattened {
84
- protected: string;
85
- unprotected: JweHeader;
86
- header: JweHeader | JweRecipientUnprotectedHeader;
87
- encrypted_key?: string;
88
- aad?: string;
89
- iv: string;
90
- ciphertext: string;
91
- tag?: string;
90
+ protected: string
91
+ unprotected: JweHeader
92
+ header: JweHeader | JweRecipientUnprotectedHeader
93
+ encrypted_key?: string
94
+ aad?: string
95
+ iv: string
96
+ ciphertext: string
97
+ tag?: string
92
98
  }
93
99
  export interface JweRecipient {
94
- header?: JweRecipientUnprotectedHeader;
95
- encrypted_key?: string;
100
+ header?: JweRecipientUnprotectedHeader
101
+ encrypted_key?: string
96
102
  }
97
103
  export interface JweJsonGeneral {
98
- protected: string;
99
- unprotected?: JweHeader;
100
- recipients: Array<JweRecipient>;
101
- aad?: string;
102
- iv: string;
103
- ciphertext: string;
104
- tag?: string;
104
+ protected: string
105
+ unprotected?: JweHeader
106
+ recipients: Array<JweRecipient>
107
+ aad?: string
108
+ iv: string
109
+ ciphertext: string
110
+ tag?: string
105
111
  }
106
112
  export interface PreparedJwsObject {
107
- jws: PreparedJws;
108
- b64: {
109
- payload: string;
110
- protectedHeader: string;
111
- };
112
- identifier: ManagedIdentifierResult;
113
+ jws: PreparedJws
114
+ b64: {
115
+ payload: string
116
+ protectedHeader: string
117
+ }
118
+ identifier: ManagedIdentifierResult
113
119
  }
114
120
  export interface BaseJwtHeader {
115
- typ?: string;
116
- alg?: string;
117
- kid?: string;
121
+ typ?: string
122
+ alg?: string
123
+ kid?: string
118
124
  }
119
125
  export interface BaseJwtPayload {
120
- iss?: string;
121
- sub?: string;
122
- aud?: string[] | string;
123
- exp?: number;
124
- nbf?: number;
125
- iat?: number;
126
- jti?: string;
126
+ iss?: string
127
+ sub?: string
128
+ aud?: string[] | string
129
+ exp?: number
130
+ nbf?: number
131
+ iat?: number
132
+ jti?: string
127
133
  }
128
134
  export interface JwsHeader extends BaseJwtHeader {
129
- kid?: string;
130
- jwk?: JWK;
131
- x5c?: string[];
132
- [key: string]: unknown;
135
+ kid?: string
136
+ jwk?: JWK
137
+ x5c?: string[]
138
+ [key: string]: unknown
133
139
  }
134
140
  export interface JwsPayload extends BaseJwtPayload {
135
- [key: string]: unknown;
141
+ [key: string]: unknown
136
142
  }
137
143
  export interface JwsHeaderOpts {
138
- alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString;
144
+ alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString
139
145
  }
140
- export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto';
146
+ export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
141
147
  export type EncryptJweCompactJwtArgs = {
142
- payload: JwsPayload;
143
- protectedHeader?: JweProtectedHeader | undefined;
144
- aad?: Uint8Array | undefined;
145
- recipientKey: ExternalIdentifierResult & {
146
- kid?: string;
147
- };
148
- alg?: JweAlg;
149
- enc?: JweEnc;
150
- apu?: string;
151
- apv?: string;
152
- expirationTime?: number | string | Date;
153
- issuer?: string;
154
- audience?: string | string[];
155
- };
148
+ payload: JwsPayload
149
+ protectedHeader?: JweProtectedHeader | undefined
150
+ aad?: Uint8Array | undefined
151
+ recipientKey: ExternalIdentifierResult & {
152
+ kid?: string
153
+ }
154
+ alg?: JweAlg
155
+ enc?: JweEnc
156
+ apu?: string
157
+ apv?: string
158
+ expirationTime?: number | string | Date
159
+ issuer?: string
160
+ audience?: string | string[]
161
+ }
156
162
  export type DecryptJweCompactJwtArgs = {
157
- jwe: JweCompact;
158
- idOpts: ManagedIdentifierOptsOrResult;
159
- };
163
+ jwe: JweCompact
164
+ idOpts: ManagedIdentifierOptsOrResult
165
+ }
160
166
  export type CreateJwsArgs = {
161
- mode?: JwsIdentifierMode;
162
- issuer: ManagedIdentifierOptsOrResult & {
163
- noIssPayloadUpdate?: boolean;
164
- noIdentifierInHeader?: boolean;
165
- };
166
- clientId?: string;
167
- clientIdScheme?: ClientIdScheme | 'did' | string;
168
- protectedHeader: JwsHeader;
169
- payload: JwsPayload | Uint8Array | string;
170
- };
167
+ mode?: JwsIdentifierMode
168
+ issuer: ManagedIdentifierOptsOrResult & {
169
+ noIssPayloadUpdate?: boolean
170
+ noIdentifierInHeader?: boolean
171
+ }
172
+ clientId?: string
173
+ clientIdScheme?: ClientIdScheme | 'did' | string
174
+ protectedHeader: JwsHeader
175
+ payload: JwsPayload | Uint8Array | string
176
+ }
171
177
  export type CreateJweArgs = {
172
- mode?: JwsIdentifierMode;
173
- issuer: ManagedIdentifierOptsOrResult & {
174
- noIssPayloadUpdate?: boolean;
175
- noIdentifierInHeader?: boolean;
176
- };
177
- protectedHeader: JweProtectedHeader;
178
- encryptedKey: string | EphemeralPublicKey;
179
- iv: string;
180
- ciphertext: string;
181
- tag: string;
182
- };
183
- export type CreateJwsCompactArgs = CreateJwsArgs;
184
- export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>;
178
+ mode?: JwsIdentifierMode
179
+ issuer: ManagedIdentifierOptsOrResult & {
180
+ noIssPayloadUpdate?: boolean
181
+ noIdentifierInHeader?: boolean
182
+ }
183
+ protectedHeader: JweProtectedHeader
184
+ encryptedKey: string | EphemeralPublicKey
185
+ iv: string
186
+ ciphertext: string
187
+ tag: string
188
+ }
189
+ export type CreateJwsCompactArgs = CreateJwsArgs
190
+ export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>
185
191
  export type VerifyJwsArgs = {
186
- jws: Jws;
187
- jwk?: JWK;
188
- opts?: {
189
- x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>;
190
- did?: Omit<ExternalIdentifierDidOpts, 'identifier'>;
191
- };
192
- };
192
+ jws: Jws
193
+ jwk?: JWK
194
+ opts?: {
195
+ x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>
196
+ did?: Omit<ExternalIdentifierDidOpts, 'identifier'>
197
+ }
198
+ }
193
199
  /**
194
200
  * @public
195
201
  */
196
202
  export type CreateJwsJsonArgs = CreateJwsArgs & {
197
- unprotectedHeader?: JwsHeader;
198
- existingSignatures?: Array<JwsJsonSignature>;
199
- };
203
+ unprotectedHeader?: JwsHeader
204
+ existingSignatures?: Array<JwsJsonSignature>
205
+ }
200
206
  export type CreateJweJsonArgs = CreateJweArgs & {
201
- unprotectedHeader?: JweHeader;
202
- };
207
+ unprotectedHeader?: JweHeader
208
+ }
203
209
  /**
204
210
  * @public
205
211
  */
206
212
  export interface JwtCompactResult {
207
- jwt: JwsCompact | JweCompact;
208
- }
209
- export declare function isJwsCompact(jws: Jws): jws is JwsCompact;
210
- export declare function isJweCompact(jwe: Jwe): jwe is JweCompact;
211
- export declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened;
212
- export declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral;
213
- export declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened;
214
- export declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral;
215
- export declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader;
216
- export declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader;
217
- export declare const COMPACT_JWS_REGEX: RegExp;
218
- export declare const COMPACT_JWE_REGEX: RegExp;
219
- export declare const JweAlgs: readonly ["RSA1_5", "RSA-OAEP", "RSA-OAEP-256", "A128KW", "A192KW", "A256KW", "dir", "ECDH-ES", "ECDH-ES+A128KW", "ECDH-ES+A192KW", "ECDH-ES+A256KW", "A128GCMKW", "A192GCMKW", "A256GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW"];
220
- export type JweAlg = typeof JweAlgs[number];
221
- export declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined;
222
- export declare const JweEncs: readonly ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512", "A128GCM", "A192GCM", "A256GCM"];
223
- export type JweEnc = typeof JweEncs[number];
224
- export declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined;
213
+ jwt: JwsCompact | JweCompact
214
+ }
215
+ export declare function isJwsCompact(jws: Jws): jws is JwsCompact
216
+ export declare function isJweCompact(jwe: Jwe): jwe is JweCompact
217
+ export declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened
218
+ export declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral
219
+ export declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened
220
+ export declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral
221
+ export declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader
222
+ export declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader
223
+ export declare const COMPACT_JWS_REGEX: RegExp
224
+ export declare const COMPACT_JWE_REGEX: RegExp
225
+ export declare const JweAlgs: readonly [
226
+ 'RSA1_5',
227
+ 'RSA-OAEP',
228
+ 'RSA-OAEP-256',
229
+ 'A128KW',
230
+ 'A192KW',
231
+ 'A256KW',
232
+ 'dir',
233
+ 'ECDH-ES',
234
+ 'ECDH-ES+A128KW',
235
+ 'ECDH-ES+A192KW',
236
+ 'ECDH-ES+A256KW',
237
+ 'A128GCMKW',
238
+ 'A192GCMKW',
239
+ 'A256GCMKW',
240
+ 'PBES2-HS256+A128KW',
241
+ 'PBES2-HS384+A192KW',
242
+ 'PBES2-HS512+A256KW'
243
+ ]
244
+ export type JweAlg = (typeof JweAlgs)[number]
245
+ export declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined
246
+ export declare const JweEncs: readonly ['A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512', 'A128GCM', 'A192GCM', 'A256GCM']
247
+ export type JweEnc = (typeof JweEncs)[number]
248
+ export declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined
225
249
  //# sourceMappingURL=IJwtService.d.ts.map
@@ -51,7 +51,7 @@ export function isCoseKeyIdentifier(identifier: ManagedIdentifierType): identifi
51
51
  }
52
52
 
53
53
  export function isOIDFEntityIdIdentifier(identifier: ManagedIdentifierType): identifier is string {
54
- return typeof identifier === 'string' && identifier.startsWith('https://')
54
+ return typeof identifier === 'string' && identifier.startsWith('https://')
55
55
  }
56
56
 
57
57
  export function isX5cIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string[] {