@sphereon/ssi-sdk-ext.identifier-resolution 0.25.0 → 0.25.1-feature.OIDF.69.40

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 (40) hide show
  1. package/dist/agent/IdentifierResolution.d.ts +1 -0
  2. package/dist/agent/IdentifierResolution.d.ts.map +1 -1
  3. package/dist/agent/IdentifierResolution.js +6 -0
  4. package/dist/agent/IdentifierResolution.js.map +1 -1
  5. package/dist/functions/LegacySupport.js +4 -4
  6. package/dist/functions/LegacySupport.js.map +1 -1
  7. package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -1
  8. package/dist/functions/externalIdentifierFunctions.js +4 -0
  9. package/dist/functions/externalIdentifierFunctions.js.map +1 -1
  10. package/dist/functions/externalOIDFIdentifier.d.ts +19 -0
  11. package/dist/functions/externalOIDFIdentifier.d.ts.map +1 -0
  12. package/dist/functions/externalOIDFIdentifier.js +79 -0
  13. package/dist/functions/externalOIDFIdentifier.js.map +1 -0
  14. package/dist/functions/index.d.ts +1 -0
  15. package/dist/functions/index.d.ts.map +1 -1
  16. package/dist/functions/index.js +1 -0
  17. package/dist/functions/index.js.map +1 -1
  18. package/dist/types/IIdentifierResolution.d.ts +3 -2
  19. package/dist/types/IIdentifierResolution.d.ts.map +1 -1
  20. package/dist/types/IIdentifierResolution.js +1 -0
  21. package/dist/types/IIdentifierResolution.js.map +1 -1
  22. package/dist/types/common.d.ts +1 -0
  23. package/dist/types/common.d.ts.map +1 -1
  24. package/dist/types/common.js +4 -0
  25. package/dist/types/common.js.map +1 -1
  26. package/dist/types/externalIdentifierTypes.d.ts +18 -3
  27. package/dist/types/externalIdentifierTypes.d.ts.map +1 -1
  28. package/dist/types/externalIdentifierTypes.js +5 -0
  29. package/dist/types/externalIdentifierTypes.js.map +1 -1
  30. package/package.json +13 -12
  31. package/plugin.schema.json +130 -1
  32. package/src/agent/IdentifierResolution.ts +9 -1
  33. package/src/functions/LegacySupport.ts +1 -1
  34. package/src/functions/externalIdentifierFunctions.ts +6 -1
  35. package/src/functions/externalOIDFIdentifier.ts +93 -0
  36. package/src/functions/index.ts +1 -0
  37. package/src/types/IIdentifierResolution.ts +7 -2
  38. package/src/types/IJwtService.d.ts +225 -0
  39. package/src/types/common.ts +4 -0
  40. package/src/types/externalIdentifierTypes.ts +26 -3
@@ -136,6 +136,27 @@
136
136
  "required": [
137
137
  "identifier"
138
138
  ]
139
+ },
140
+ {
141
+ "type": "object",
142
+ "properties": {
143
+ "method": {
144
+ "type": "string",
145
+ "const": "entity_id"
146
+ },
147
+ "identifier": {
148
+ "$ref": "#/components/schemas/ExternalIdentifierType"
149
+ },
150
+ "trustAnchors": {
151
+ "type": "array",
152
+ "items": {
153
+ "type": "string"
154
+ }
155
+ }
156
+ },
157
+ "required": [
158
+ "identifier"
159
+ ]
139
160
  }
140
161
  ]
141
162
  },
@@ -606,6 +627,41 @@
606
627
  "method"
607
628
  ]
608
629
  },
630
+ {
631
+ "type": "object",
632
+ "properties": {
633
+ "method": {
634
+ "$ref": "#/components/schemas/ExternalIdentifierMethod"
635
+ },
636
+ "jwks": {
637
+ "type": "array",
638
+ "items": {
639
+ "$ref": "#/components/schemas/ExternalJwkInfo"
640
+ }
641
+ },
642
+ "trustedAnchors": {
643
+ "type": "array",
644
+ "items": {
645
+ "$ref": "#/components/schemas/TrustedAnchor"
646
+ }
647
+ },
648
+ "errorList": {
649
+ "type": "object",
650
+ "additionalProperties": {
651
+ "$ref": "#/components/schemas/ErrorMessage"
652
+ }
653
+ },
654
+ "trustEstablished": {
655
+ "type": "boolean"
656
+ }
657
+ },
658
+ "required": [
659
+ "jwks",
660
+ "method",
661
+ "trustEstablished",
662
+ "trustedAnchors"
663
+ ]
664
+ },
609
665
  {
610
666
  "type": "object",
611
667
  "properties": {
@@ -643,7 +699,8 @@
643
699
  "cose_key",
644
700
  "oidc-discovery",
645
701
  "jwks-url",
646
- "oid4vci-issuer"
702
+ "oid4vci-issuer",
703
+ "entity_id"
647
704
  ]
648
705
  },
649
706
  "ExternalJwkInfo": {
@@ -1295,6 +1352,12 @@
1295
1352
  "x5c"
1296
1353
  ]
1297
1354
  },
1355
+ "TrustedAnchor": {
1356
+ "type": "string"
1357
+ },
1358
+ "ErrorMessage": {
1359
+ "type": "string"
1360
+ },
1298
1361
  "ICoseKeyJson": {
1299
1362
  "type": "object",
1300
1363
  "properties": {
@@ -1577,6 +1640,63 @@
1577
1640
  "method"
1578
1641
  ]
1579
1642
  },
1643
+ "ExternalIdentifierOIDFEntityIdOpts": {
1644
+ "type": "object",
1645
+ "properties": {
1646
+ "method": {
1647
+ "type": "string",
1648
+ "const": "entity_id"
1649
+ },
1650
+ "identifier": {
1651
+ "$ref": "#/components/schemas/ExternalIdentifierType"
1652
+ },
1653
+ "trustAnchors": {
1654
+ "type": "array",
1655
+ "items": {
1656
+ "type": "string"
1657
+ }
1658
+ }
1659
+ },
1660
+ "required": [
1661
+ "identifier"
1662
+ ]
1663
+ },
1664
+ "ExternalIdentifierOIDFEntityIdResult": {
1665
+ "type": "object",
1666
+ "properties": {
1667
+ "method": {
1668
+ "type": "string",
1669
+ "const": "entity_id"
1670
+ },
1671
+ "jwks": {
1672
+ "type": "array",
1673
+ "items": {
1674
+ "$ref": "#/components/schemas/ExternalJwkInfo"
1675
+ }
1676
+ },
1677
+ "trustedAnchors": {
1678
+ "type": "array",
1679
+ "items": {
1680
+ "$ref": "#/components/schemas/TrustedAnchor"
1681
+ }
1682
+ },
1683
+ "errorList": {
1684
+ "type": "object",
1685
+ "additionalProperties": {
1686
+ "$ref": "#/components/schemas/ErrorMessage"
1687
+ }
1688
+ },
1689
+ "trustEstablished": {
1690
+ "type": "boolean"
1691
+ }
1692
+ },
1693
+ "required": [
1694
+ "jwks",
1695
+ "method",
1696
+ "trustEstablished",
1697
+ "trustedAnchors"
1698
+ ]
1699
+ },
1580
1700
  "ManagedIdentifierOptsOrResult": {
1581
1701
  "anyOf": [
1582
1702
  {
@@ -4116,6 +4236,15 @@
4116
4236
  "$ref": "#/components/schemas/ExternalIdentifierJwkResult"
4117
4237
  }
4118
4238
  },
4239
+ "identifierExternalResolveByOIDFEntityId": {
4240
+ "description": "",
4241
+ "arguments": {
4242
+ "$ref": "#/components/schemas/ExternalIdentifierOIDFEntityIdOpts"
4243
+ },
4244
+ "returnType": {
4245
+ "$ref": "#/components/schemas/ExternalIdentifierOIDFEntityIdResult"
4246
+ }
4247
+ },
4119
4248
  "identifierExternalResolveByX5c": {
4120
4249
  "description": "",
4121
4250
  "arguments": {
@@ -1,4 +1,5 @@
1
1
  import { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
2
+ import { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
2
3
  import { schema } from '..'
3
4
  import { resolveExternalIdentifier, ensureManagedIdentifierResult } from '../functions'
4
5
  import {
@@ -30,6 +31,7 @@ import {
30
31
  ManagedIdentifierOptsOrResult,
31
32
  ManagedIdentifierOID4VCIssuerOpts
32
33
  } from '../types'
34
+ import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
33
35
 
34
36
  /**
35
37
  * @public
@@ -53,6 +55,7 @@ export class IdentifierResolution implements IAgentPlugin {
53
55
  identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
54
56
  identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
55
57
  identifierExternalResolveByCoseKey: this.identifierExternalResolveByCoseKey.bind(this),
58
+ identifierExternalResolveByOIDFEntityId: this.identifierExternalResolveByOIDFEntityId.bind(this),
56
59
 
57
60
  // todo: JWKSet, oidc-discovery, oid4vci-issuer etc. Anything we already can resolve and need keys of
58
61
  }
@@ -127,7 +130,7 @@ export class IdentifierResolution implements IAgentPlugin {
127
130
  return (await this.identifierGetManaged({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
128
131
  }
129
132
 
130
- private async identifierResolveExternal(args: ExternalIdentifierOpts, context: IAgentContext<IKeyManager>): Promise<ExternalIdentifierResult> {
133
+ private async identifierResolveExternal(args: ExternalIdentifierOpts, context: IAgentContext<IKeyManager | IOIDFClient>): Promise<ExternalIdentifierResult> {
131
134
  return await resolveExternalIdentifier({ ...args, crypto: this._crypto }, context)
132
135
  }
133
136
 
@@ -145,7 +148,12 @@ export class IdentifierResolution implements IAgentPlugin {
145
148
  ): Promise<ExternalIdentifierCoseKeyResult> {
146
149
  return (await this.identifierResolveExternal({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
147
150
  }
151
+
148
152
  private async identifierExternalResolveByJwk(args: ExternalIdentifierJwkOpts, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult> {
149
153
  return (await this.identifierResolveExternal({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
150
154
  }
155
+
156
+ private async identifierExternalResolveByOIDFEntityId(args: ExternalIdentifierOIDFEntityIdOpts, context: IAgentContext<any>): Promise<ExternalIdentifierOIDFEntityIdResult> {
157
+ return (await this.identifierResolveExternal({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
158
+ }
151
159
  }
@@ -20,7 +20,7 @@ export function legacyKeyRefsToIdentifierOpts(opts: {
20
20
  opts.keyRef ??
21
21
  opts.didOpts?.idOpts?.kmsKeyRef ??
22
22
  opts.didOpts?.kid ??
23
- opts.didOpts.idOpts?.kid ??
23
+ opts.didOpts?.idOpts?.kid ??
24
24
  (typeof opts.didOpts?.idOpts.identifier === 'object' ? (opts.didOpts?.idOpts.identifier as IIdentifier).keys[0].kid : undefined)
25
25
  if (!kmsKeyRef) {
26
26
  throw Error('Key ref is needed for access token signer')
@@ -31,8 +31,11 @@ import {
31
31
  isExternalIdentifierJwksUrlOpts,
32
32
  isExternalIdentifierKidOpts,
33
33
  isExternalIdentifierOidcDiscoveryOpts,
34
+ isExternalIdentifierOIDFEntityIdOpts,
34
35
  isExternalIdentifierX5cOpts,
35
36
  } from '../types'
37
+ import { resolveExternalOIDFEntityIdIdentifier } from '.'
38
+
36
39
 
37
40
  export async function resolveExternalIdentifier(
38
41
  opts: ExternalIdentifierOpts & {
@@ -49,13 +52,15 @@ export async function resolveExternalIdentifier(
49
52
  return resolveExternalJwkIdentifier(opts, context)
50
53
  } else if (isExternalIdentifierCoseKeyOpts(opts)) {
51
54
  return resolveExternalCoseKeyIdentifier(opts, context)
55
+ } else if (isExternalIdentifierOIDFEntityIdOpts(opts)) {
56
+ return resolveExternalOIDFEntityIdIdentifier(opts, context)
52
57
  } else if (isExternalIdentifierKidOpts(opts)) {
53
58
  method = 'kid'
54
59
  } else if (isExternalIdentifierJwksUrlOpts(opts)) {
55
60
  method = 'jwks-url'
56
61
  } else if (isExternalIdentifierOidcDiscoveryOpts(opts)) {
57
62
  method = 'oidc-discovery'
58
- }
63
+ }
59
64
  throw Error(`External resolution method ${method} is not yet implemented`)
60
65
  }
61
66
 
@@ -0,0 +1,93 @@
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 } from '../types/IJwtService'
12
+
13
+ /**
14
+ * Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
15
+ *
16
+ * @param opts Configuration options containing the identifier to resolve and trust anchors to validate against
17
+ * @param context Agent context that must include the OIDF client plugin and JWT verification capabilities
18
+ *
19
+ * @returns Promise resolving to an ExternalIdentifierOIDFEntityIdResult containing:
20
+ * - trustedAnchors: Record mapping trust anchors to their public key hexes
21
+ * - errorList: Optional record of errors encountered per trust anchor
22
+ * - jwks: Array of JWK information from the trust chain
23
+ * - trustEstablished: Boolean indicating if any trust relationships were established
24
+ *
25
+ * @throws Error if trust anchors are missing or JWT verification plugin is not enabled
26
+ */
27
+ export async function resolveExternalOIDFEntityIdIdentifier(
28
+ opts: ExternalIdentifierOIDFEntityIdOpts,
29
+ context: IAgentContext<IOIDFClient>
30
+ ): Promise<ExternalIdentifierOIDFEntityIdResult> {
31
+ let { trustAnchors, identifier } = opts
32
+
33
+ if (!trustAnchors || trustAnchors.length === 0) {
34
+ return Promise.reject(Error('ExternalIdentifierOIDFEntityIdOpts is missing the trustAnchors'))
35
+ }
36
+
37
+ if (!contextHasPlugin(context, 'jwtVerifyJwsSignature')) {
38
+ return Promise.reject(Error('For OIDFEntityId resolving the agent needs to have the JwtService plugin enabled'))
39
+ }
40
+
41
+ const trustedAnchors: Set<TrustedAnchor> = new Set<TrustedAnchor>()
42
+ const errorList: Record<TrustedAnchor, ErrorMessage> = {}
43
+ const jwkInfos: Array<ExternalJwkInfo> = []
44
+
45
+ for (const trustAnchor of trustAnchors) {
46
+ const resolveResult = await context.agent.resolveTrustChain({
47
+ entityIdentifier: identifier,
48
+ trustAnchors: [trustAnchor]
49
+ })
50
+
51
+ if (resolveResult.error || !resolveResult.trustChain) {
52
+ errorList[trustAnchor] = resolveResult.errorMessage ?? 'unspecified'
53
+ } else {
54
+ const trustChain: ReadonlyArray<string> = resolveResult.trustChain.asJsReadonlyArrayView()
55
+ if (trustChain.length === 0) {
56
+ errorList[trustAnchor] = 'Trust chain is empty'
57
+ continue
58
+ }
59
+
60
+ const jwt = trustChain[0]
61
+ const jwtVerifyResult: IJwsValidationResult = await context.agent.jwtVerifyJwsSignature({ jws: jwt })
62
+
63
+ if (jwtVerifyResult.error || jwtVerifyResult.critical) {
64
+ errorList[trustAnchor] = jwtVerifyResult.message
65
+ continue
66
+ }
67
+
68
+ if (jwtVerifyResult.jws.signatures.length === 0) {
69
+ errorList[trustAnchor] = 'No signature was present in the trust anchor JWS'
70
+ continue
71
+ }
72
+
73
+ const signature = jwtVerifyResult.jws.signatures[0]
74
+ if (signature.identifier.jwks.length === 0) {
75
+ errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
76
+ continue
77
+ }
78
+
79
+ if(jwkInfos.length === 0) { // We need the entity JWK only once
80
+ jwkInfos.push(...signature.identifier.jwks)
81
+ }
82
+ trustedAnchors.add(trustAnchor)
83
+ }
84
+ }
85
+
86
+ return {
87
+ method: 'entity_id',
88
+ trustedAnchors: Array.from(trustedAnchors),
89
+ ...(Object.keys(errorList).length > 0 && { errorList }),
90
+ jwks: jwkInfos,
91
+ trustEstablished: trustedAnchors.size > 0
92
+ }
93
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './managedIdentifierFunctions'
2
2
  export * from './externalIdentifierFunctions'
3
+ export * from './externalOIDFIdentifier'
3
4
  export * from './LegacySupport'
@@ -6,6 +6,8 @@ import {
6
6
  ExternalIdentifierDidResult,
7
7
  ExternalIdentifierJwkOpts,
8
8
  ExternalIdentifierJwkResult,
9
+ ExternalIdentifierOIDFEntityIdOpts,
10
+ ExternalIdentifierOIDFEntityIdResult,
9
11
  ExternalIdentifierOpts,
10
12
  ExternalIdentifierResult,
11
13
  ExternalIdentifierX5cOpts,
@@ -16,14 +18,14 @@ import {
16
18
  ManagedIdentifierCoseKeyResult,
17
19
  ManagedIdentifierDidOpts,
18
20
  ManagedIdentifierDidResult,
19
- ManagedIdentifierOID4VCIssuerOpts,
20
- ManagedIdentifierOID4VCIssuerResult,
21
21
  ManagedIdentifierJwkOpts,
22
22
  ManagedIdentifierJwkResult,
23
23
  ManagedIdentifierKeyOpts,
24
24
  ManagedIdentifierKeyResult,
25
25
  ManagedIdentifierKidOpts,
26
26
  ManagedIdentifierKidResult,
27
+ ManagedIdentifierOID4VCIssuerOpts,
28
+ ManagedIdentifierOID4VCIssuerResult,
27
29
  ManagedIdentifierOptsOrResult,
28
30
  ManagedIdentifierResult,
29
31
  ManagedIdentifierX5cOpts,
@@ -45,6 +47,7 @@ export const identifierResolutionContextMethods: Array<string> = [
45
47
  'identifierExternalResolveByX5c',
46
48
  'identifierExternalResolveByJwk',
47
49
  'identifierExternalResolveByCoseKey',
50
+ 'identifierExternalResolveByOIDFEntityId',
48
51
  ]
49
52
 
50
53
  /**
@@ -99,4 +102,6 @@ export interface IIdentifierResolution extends IPluginMethodMap {
99
102
  identifierExternalResolveByCoseKey(args: ExternalIdentifierCoseKeyOpts, context: IAgentContext<any>): Promise<ExternalIdentifierCoseKeyResult>
100
103
 
101
104
  identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult>
105
+
106
+ identifierExternalResolveByOIDFEntityId(args: ExternalIdentifierOIDFEntityIdOpts, context: IAgentContext<any>): Promise<ExternalIdentifierOIDFEntityIdResult>
102
107
  }
@@ -0,0 +1,225 @@
1
+
2
+ // Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
3
+
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>;
10
+ 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>;
18
+ }
19
+ export type IJwsValidationResult = IValidationResult & {
20
+ jws: JwsJsonGeneralWithIdentifiers;
21
+ };
22
+ export interface PreparedJws {
23
+ protectedHeader: JwsHeader;
24
+ payload: Uint8Array;
25
+ unprotectedHeader?: JwsHeader;
26
+ existingSignatures?: Array<JwsJsonSignature>;
27
+ }
28
+ export interface JwsJsonSignature {
29
+ protected: string;
30
+ header?: JwsHeader;
31
+ signature: string;
32
+ }
33
+ /**
34
+ * The JWK representation of an ephemeral public key.
35
+ * See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
36
+ */
37
+ export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>;
38
+ 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;
50
+ }
51
+ export interface JweRecipientUnprotectedHeader {
52
+ alg: string;
53
+ iv: string;
54
+ tag: string;
55
+ epk?: EphemeralPublicKey;
56
+ kid?: string;
57
+ apv?: string;
58
+ apu?: string;
59
+ }
60
+ export interface JweProtectedHeader extends Partial<JweHeader> {
61
+ zip?: 'DEF' | string;
62
+ }
63
+ export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral;
64
+ export type JwsCompact = string;
65
+ export interface JwsJsonFlattened {
66
+ payload: string;
67
+ protected: string;
68
+ header?: JwsHeader;
69
+ signature: string;
70
+ }
71
+ export interface JwsJsonGeneral {
72
+ payload: string;
73
+ signatures: Array<JwsJsonSignature>;
74
+ }
75
+ export interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
76
+ signatures: Array<JwsJsonSignatureWithIdentifier>;
77
+ }
78
+ export interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
79
+ identifier: ExternalIdentifierResult;
80
+ }
81
+ export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral;
82
+ export type JweCompact = string;
83
+ 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;
92
+ }
93
+ export interface JweRecipient {
94
+ header?: JweRecipientUnprotectedHeader;
95
+ encrypted_key?: string;
96
+ }
97
+ 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;
105
+ }
106
+ export interface PreparedJwsObject {
107
+ jws: PreparedJws;
108
+ b64: {
109
+ payload: string;
110
+ protectedHeader: string;
111
+ };
112
+ identifier: ManagedIdentifierResult;
113
+ }
114
+ export interface BaseJwtHeader {
115
+ typ?: string;
116
+ alg?: string;
117
+ kid?: string;
118
+ }
119
+ 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;
127
+ }
128
+ export interface JwsHeader extends BaseJwtHeader {
129
+ kid?: string;
130
+ jwk?: JWK;
131
+ x5c?: string[];
132
+ [key: string]: unknown;
133
+ }
134
+ export interface JwsPayload extends BaseJwtPayload {
135
+ [key: string]: unknown;
136
+ }
137
+ export interface JwsHeaderOpts {
138
+ alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString;
139
+ }
140
+ export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto';
141
+ 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
+ };
156
+ export type DecryptJweCompactJwtArgs = {
157
+ jwe: JweCompact;
158
+ idOpts: ManagedIdentifierOptsOrResult;
159
+ };
160
+ 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
+ };
171
+ 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'>;
185
+ export type VerifyJwsArgs = {
186
+ jws: Jws;
187
+ jwk?: JWK;
188
+ opts?: {
189
+ x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>;
190
+ did?: Omit<ExternalIdentifierDidOpts, 'identifier'>;
191
+ };
192
+ };
193
+ /**
194
+ * @public
195
+ */
196
+ export type CreateJwsJsonArgs = CreateJwsArgs & {
197
+ unprotectedHeader?: JwsHeader;
198
+ existingSignatures?: Array<JwsJsonSignature>;
199
+ };
200
+ export type CreateJweJsonArgs = CreateJweArgs & {
201
+ unprotectedHeader?: JweHeader;
202
+ };
203
+ /**
204
+ * @public
205
+ */
206
+ 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;
225
+ //# sourceMappingURL=IJwtService.d.ts.map
@@ -50,6 +50,10 @@ export function isCoseKeyIdentifier(identifier: ManagedIdentifierType): identifi
50
50
  return typeof identifier === 'object' && `kty` in identifier && ('baseIV' in identifier || 'x5chain' in identifier) && !('x5c' in identifier)
51
51
  }
52
52
 
53
+ export function isOIDFEntityIdIdentifier(identifier: ManagedIdentifierType): identifier is string {
54
+ return typeof identifier === 'string' && identifier.startsWith('https://')
55
+ }
56
+
53
57
  export function isX5cIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string[] {
54
58
  return Array.isArray(identifier) && identifier.length > 0 // todo: Do we want to do additional validation? We know it must be DER and thus hex for instance
55
59
  }