@sphereon/ssi-sdk-ext.identifier-resolution 0.28.0 → 0.28.1-feature.esm.cjs.8
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.
- package/dist/index.cjs +5356 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +439 -0
- package/dist/index.d.ts +434 -7
- package/dist/index.js +5333 -27
- package/dist/index.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +34 -22
- package/plugin.schema.json +636 -710
- package/src/agent/IdentifierResolution.ts +39 -35
- package/src/functions/externalIdentifierFunctions.ts +21 -14
- package/src/functions/externalOIDFIdentifier.ts +6 -3
- package/src/functions/managedIdentifierFunctions.ts +7 -6
- package/src/index.ts +1 -1
- package/src/types/IIdentifierResolution.ts +1 -1
- package/src/types/IJwtService.d.ts +3 -2
- package/src/types/externalIdentifierTypes.ts +1 -1
- package/dist/agent/IdentifierResolution.d.ts +0 -38
- package/dist/agent/IdentifierResolution.d.ts.map +0 -1
- package/dist/agent/IdentifierResolution.js +0 -123
- package/dist/agent/IdentifierResolution.js.map +0 -1
- package/dist/functions/LegacySupport.d.ts +0 -12
- package/dist/functions/LegacySupport.d.ts.map +0 -1
- package/dist/functions/LegacySupport.js +0 -39
- package/dist/functions/LegacySupport.js.map +0 -1
- package/dist/functions/externalIdentifierFunctions.d.ts +0 -26
- package/dist/functions/externalIdentifierFunctions.d.ts.map +0 -1
- package/dist/functions/externalIdentifierFunctions.js +0 -250
- package/dist/functions/externalIdentifierFunctions.js.map +0 -1
- package/dist/functions/externalOIDFIdentifier.d.ts +0 -19
- package/dist/functions/externalOIDFIdentifier.d.ts.map +0 -1
- package/dist/functions/externalOIDFIdentifier.js +0 -106
- package/dist/functions/externalOIDFIdentifier.js.map +0 -1
- package/dist/functions/index.d.ts +0 -5
- package/dist/functions/index.d.ts.map +0 -1
- package/dist/functions/index.js +0 -21
- package/dist/functions/index.js.map +0 -1
- package/dist/functions/managedIdentifierFunctions.d.ts +0 -38
- package/dist/functions/managedIdentifierFunctions.d.ts.map +0 -1
- package/dist/functions/managedIdentifierFunctions.js +0 -359
- package/dist/functions/managedIdentifierFunctions.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types/IIdentifierResolution.d.ts +0 -42
- package/dist/types/IIdentifierResolution.d.ts.map +0 -1
- package/dist/types/IIdentifierResolution.js +0 -21
- package/dist/types/IIdentifierResolution.js.map +0 -1
- package/dist/types/common.d.ts +0 -20
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/common.js +0 -51
- package/dist/types/common.js.map +0 -1
- package/dist/types/externalIdentifierTypes.d.ts +0 -114
- package/dist/types/externalIdentifierTypes.d.ts.map +0 -1
- package/dist/types/externalIdentifierTypes.js +0 -44
- package/dist/types/externalIdentifierTypes.js.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -21
- package/dist/types/index.js.map +0 -1
- package/dist/types/managedIdentifierTypes.d.ts +0 -122
- package/dist/types/managedIdentifierTypes.d.ts.map +0 -1
- package/dist/types/managedIdentifierTypes.js +0 -63
- package/dist/types/managedIdentifierTypes.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { globalCrypto } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
2
2
|
import { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
|
|
3
3
|
import { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
|
|
4
|
-
import { schema } from '
|
|
4
|
+
import { schema } from '../index'
|
|
5
5
|
import { resolveExternalIdentifier, ensureManagedIdentifierResult } from '../functions'
|
|
6
6
|
import {
|
|
7
7
|
ExternalIdentifierDidOpts,
|
|
@@ -34,24 +34,27 @@ import {
|
|
|
34
34
|
} from '../types'
|
|
35
35
|
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
|
|
36
36
|
|
|
37
|
+
import { webcrypto } from 'node:crypto'
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* @public
|
|
39
41
|
*/
|
|
40
42
|
export class IdentifierResolution implements IAgentPlugin {
|
|
41
|
-
|
|
43
|
+
|
|
44
|
+
readonly _crypto: webcrypto.Crypto
|
|
42
45
|
|
|
43
46
|
readonly schema = schema.IMnemonicInfoGenerator
|
|
44
47
|
readonly methods: IIdentifierResolution = {
|
|
45
|
-
identifierManagedGet: this.
|
|
46
|
-
identifierManagedGetByDid: this.
|
|
47
|
-
identifierManagedGetByKid: this.
|
|
48
|
-
identifierManagedGetByJwk: this.
|
|
49
|
-
identifierManagedGetByX5c: this.
|
|
50
|
-
identifierManagedGetByKey: this.
|
|
51
|
-
identifierManagedGetByCoseKey: this.
|
|
52
|
-
identifierManagedGetByOID4VCIssuer: this.
|
|
53
|
-
|
|
54
|
-
identifierExternalResolve: this.
|
|
48
|
+
identifierManagedGet: this.identifierManagedGet.bind(this),
|
|
49
|
+
identifierManagedGetByDid: this.identifierManagedGetByDid.bind(this),
|
|
50
|
+
identifierManagedGetByKid: this.identifierManagedGetByKid.bind(this),
|
|
51
|
+
identifierManagedGetByJwk: this.identifierManagedGetByJwk.bind(this),
|
|
52
|
+
identifierManagedGetByX5c: this.identifierManagedGetByX5c.bind(this),
|
|
53
|
+
identifierManagedGetByKey: this.identifierManagedGetByKey.bind(this),
|
|
54
|
+
identifierManagedGetByCoseKey: this.identifierManagedGetByCoseKey.bind(this),
|
|
55
|
+
identifierManagedGetByOID4VCIssuer: this.identifierManagedGetByOID4VCIssuer.bind(this),
|
|
56
|
+
|
|
57
|
+
identifierExternalResolve: this.identifierExternalResolve.bind(this),
|
|
55
58
|
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
56
59
|
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
57
60
|
identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
|
|
@@ -64,7 +67,9 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
64
67
|
/**
|
|
65
68
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
66
69
|
*/
|
|
67
|
-
constructor(opts?: {
|
|
70
|
+
constructor(opts?: {
|
|
71
|
+
crypto?: webcrypto.Crypto
|
|
72
|
+
}) {
|
|
68
73
|
this._crypto = globalCrypto(false, opts?.crypto)
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -73,65 +78,64 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
73
78
|
* integrate a plugin for anomaly detection. Having a single method helps
|
|
74
79
|
* @param args
|
|
75
80
|
* @param context
|
|
76
|
-
* @private
|
|
77
81
|
*/
|
|
78
|
-
private async
|
|
82
|
+
private async identifierManagedGet(
|
|
79
83
|
args: ManagedIdentifierOptsOrResult,
|
|
80
84
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
81
85
|
): Promise<ManagedIdentifierResult> {
|
|
82
86
|
return await ensureManagedIdentifierResult({ ...args, crypto: this._crypto }, context)
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
private async
|
|
89
|
+
private async identifierManagedGetByDid(
|
|
86
90
|
args: ManagedIdentifierDidOpts,
|
|
87
91
|
context: IAgentContext<IKeyManager & IDIDManager & IIdentifierResolution>
|
|
88
92
|
): Promise<ManagedIdentifierDidResult> {
|
|
89
|
-
return (await this.
|
|
93
|
+
return (await this.identifierManagedGet({ ...args, method: 'did' }, context)) as ManagedIdentifierDidResult
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
private async
|
|
96
|
+
private async identifierManagedGetByKid(
|
|
93
97
|
args: ManagedIdentifierKidOpts,
|
|
94
98
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
95
99
|
): Promise<ManagedIdentifierKidResult> {
|
|
96
|
-
return (await this.
|
|
100
|
+
return (await this.identifierManagedGet({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
private async
|
|
103
|
+
private async identifierManagedGetByKey(
|
|
100
104
|
args: ManagedIdentifierKeyOpts,
|
|
101
105
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
102
106
|
): Promise<ManagedIdentifierKeyResult> {
|
|
103
|
-
return (await this.
|
|
107
|
+
return (await this.identifierManagedGet({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
private async
|
|
110
|
+
private async identifierManagedGetByCoseKey(
|
|
107
111
|
args: ManagedIdentifierCoseKeyOpts,
|
|
108
112
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
109
113
|
): Promise<ManagedIdentifierCoseKeyResult> {
|
|
110
|
-
return (await this.
|
|
114
|
+
return (await this.identifierManagedGet({ ...args, method: 'cose_key' }, context)) as ManagedIdentifierCoseKeyResult
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
private async
|
|
117
|
+
private async identifierManagedGetByOID4VCIssuer(
|
|
114
118
|
args: ManagedIdentifierOID4VCIssuerOpts,
|
|
115
119
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
116
120
|
): Promise<ManagedIdentifierOID4VCIssuerResult> {
|
|
117
|
-
return (await this.
|
|
121
|
+
return (await this.identifierManagedGet({ ...args, method: 'oid4vci-issuer' }, context)) as ManagedIdentifierOID4VCIssuerResult
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
private async
|
|
124
|
+
private async identifierManagedGetByJwk(
|
|
121
125
|
args: ManagedIdentifierJwkOpts,
|
|
122
126
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
123
127
|
): Promise<ManagedIdentifierJwkResult> {
|
|
124
|
-
return (await this.
|
|
128
|
+
return (await this.identifierManagedGet({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
private async
|
|
131
|
+
private async identifierManagedGetByX5c(
|
|
128
132
|
args: ManagedIdentifierX5cOpts,
|
|
129
133
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
130
134
|
): Promise<ManagedIdentifierX5cResult> {
|
|
131
|
-
return (await this.
|
|
135
|
+
return (await this.identifierManagedGet({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
private async
|
|
138
|
+
private async identifierExternalResolve(
|
|
135
139
|
args: ExternalIdentifierOpts,
|
|
136
140
|
context: IAgentContext<IKeyManager | IOIDFClient>
|
|
137
141
|
): Promise<ExternalIdentifierResult> {
|
|
@@ -139,28 +143,28 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
private async identifierExternalResolveByDid(args: ExternalIdentifierDidOpts, context: IAgentContext<any>): Promise<ExternalIdentifierDidResult> {
|
|
142
|
-
return (await this.
|
|
146
|
+
return (await this.identifierExternalResolve({ ...args, method: 'did' }, context)) as ExternalIdentifierDidResult
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
private async identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult> {
|
|
146
|
-
return (await this.
|
|
150
|
+
return (await this.identifierExternalResolve({ ...args, method: 'x5c' }, context)) as ExternalIdentifierX5cResult
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
private async identifierExternalResolveByCoseKey(
|
|
150
154
|
args: ExternalIdentifierCoseKeyOpts,
|
|
151
155
|
context: IAgentContext<any>
|
|
152
156
|
): Promise<ExternalIdentifierCoseKeyResult> {
|
|
153
|
-
return (await this.
|
|
157
|
+
return (await this.identifierExternalResolve({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
private async identifierExternalResolveByJwk(args: ExternalIdentifierJwkOpts, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult> {
|
|
157
|
-
return (await this.
|
|
161
|
+
return (await this.identifierExternalResolve({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
private async identifierExternalResolveByOIDFEntityId(
|
|
161
165
|
args: ExternalIdentifierOIDFEntityIdOpts,
|
|
162
166
|
context: IAgentContext<any>
|
|
163
167
|
): Promise<ExternalIdentifierOIDFEntityIdResult> {
|
|
164
|
-
return (await this.
|
|
168
|
+
return (await this.identifierExternalResolve({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
|
|
165
169
|
}
|
|
166
170
|
}
|
|
@@ -36,9 +36,10 @@ import {
|
|
|
36
36
|
} from '../types'
|
|
37
37
|
import { resolveExternalOIDFEntityIdIdentifier } from '.'
|
|
38
38
|
|
|
39
|
+
import { webcrypto } from 'node:crypto'
|
|
39
40
|
export async function resolveExternalIdentifier(
|
|
40
41
|
opts: ExternalIdentifierOpts & {
|
|
41
|
-
crypto?: Crypto
|
|
42
|
+
crypto?: webcrypto.Crypto
|
|
42
43
|
},
|
|
43
44
|
context: IAgentContext<any>
|
|
44
45
|
): Promise<ExternalIdentifierResult> {
|
|
@@ -65,7 +66,7 @@ export async function resolveExternalIdentifier(
|
|
|
65
66
|
|
|
66
67
|
export async function resolveExternalX5cIdentifier(
|
|
67
68
|
opts: ExternalIdentifierX5cOpts & {
|
|
68
|
-
crypto?: Crypto
|
|
69
|
+
crypto?: webcrypto.Crypto
|
|
69
70
|
},
|
|
70
71
|
context: IAgentContext<IResolver & IDIDManager>
|
|
71
72
|
): Promise<ExternalIdentifierX5cResult> {
|
|
@@ -245,18 +246,24 @@ export async function resolveExternalDidIdentifier(
|
|
|
245
246
|
const didDocument = didResolutionResult.didDocument ?? undefined
|
|
246
247
|
const didJwks = didDocument ? didDocumentToJwks(didDocument) : undefined
|
|
247
248
|
const jwks = didJwks
|
|
248
|
-
? Array.from(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
249
|
+
? Array.from(
|
|
250
|
+
new Set(
|
|
251
|
+
Array.from(
|
|
252
|
+
Object.values(didJwks)
|
|
253
|
+
.filter((jwks) => isDefined(jwks) && jwks.length > 0)
|
|
254
|
+
.flatMap((jwks) => jwks)
|
|
255
|
+
)
|
|
256
|
+
.flatMap((jwk) => {
|
|
257
|
+
return {
|
|
258
|
+
jwk,
|
|
259
|
+
jwkThumbprint: calculateJwkThumbprint({ jwk }),
|
|
260
|
+
kid: jwk.kid,
|
|
261
|
+
publicKeyHex: jwkTtoPublicKeyHex(jwk),
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
.map((jwk) => JSON.stringify(jwk))
|
|
265
|
+
)
|
|
266
|
+
).map((jwks) => JSON.parse(jwks))
|
|
260
267
|
: []
|
|
261
268
|
|
|
262
269
|
if (didResolutionResult?.didDocument) {
|
|
@@ -2,8 +2,11 @@ import { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOID
|
|
|
2
2
|
import { IAgentContext } from '@veramo/core'
|
|
3
3
|
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
|
|
4
4
|
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import {IJwsValidationResult, JwsPayload} from '../types/IJwtService'
|
|
6
|
-
|
|
5
|
+
import { IJwsValidationResult, JwsPayload } from '../types/IJwtService'
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import { fromString } from 'uint8arrays/from-string'
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { toString } from 'uint8arrays/to-string'
|
|
7
10
|
/**
|
|
8
11
|
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
9
12
|
*
|
|
@@ -65,7 +68,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
65
68
|
continue
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
payload = JSON.parse(
|
|
71
|
+
payload = JSON.parse(toString(fromString(jwtVerifyResult.jws.payload, 'base64url')))
|
|
69
72
|
const signature = jwtVerifyResult.jws.signatures[0]
|
|
70
73
|
if (signature.identifier.jwks.length === 0) {
|
|
71
74
|
errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
|
|
@@ -5,6 +5,7 @@ import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.ag
|
|
|
5
5
|
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
6
6
|
import { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
|
|
7
7
|
import { CryptoEngine, setEngine } from 'pkijs'
|
|
8
|
+
import { webcrypto } from 'node:crypto'
|
|
8
9
|
import {
|
|
9
10
|
IIdentifierResolution,
|
|
10
11
|
isManagedIdentifierCoseKeyOpts,
|
|
@@ -47,13 +48,13 @@ export async function getManagedKidIdentifier(
|
|
|
47
48
|
return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
|
|
48
49
|
} else if (opts.identifier.startsWith('did:')) {
|
|
49
50
|
const did = opts.identifier.split('#')[0]
|
|
50
|
-
const didIdentifier = await getManagedDidIdentifier({...opts, method: 'did', identifier: did}, context)
|
|
51
|
+
const didIdentifier = await getManagedDidIdentifier({ ...opts, method: 'did', identifier: did }, context)
|
|
51
52
|
key = didIdentifier.key
|
|
52
53
|
issuer = didIdentifier.issuer
|
|
53
54
|
kid = opts?.kid ?? (key.meta?.verificationMethod?.id as string) ?? didIdentifier.kid
|
|
54
55
|
}
|
|
55
56
|
if (!key) {
|
|
56
|
-
key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? opts.identifier})
|
|
57
|
+
key = await context.agent.keyManagerGet({ kid: opts.kmsKeyRef ?? opts.identifier })
|
|
57
58
|
}
|
|
58
59
|
const jwk = toJwk(key.publicKeyHex, key.type, { key })
|
|
59
60
|
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({ jwk })
|
|
@@ -80,7 +81,7 @@ export async function getManagedKidIdentifier(
|
|
|
80
81
|
|
|
81
82
|
export function isManagedIdentifierResult(
|
|
82
83
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
83
|
-
crypto?: Crypto
|
|
84
|
+
crypto?: webcrypto.Crypto
|
|
84
85
|
}
|
|
85
86
|
): identifier is ManagedIdentifierResult {
|
|
86
87
|
return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && 'opts' in identifier && 'jwkThumbprint' in identifier
|
|
@@ -93,7 +94,7 @@ export function isManagedIdentifierResult(
|
|
|
93
94
|
*/
|
|
94
95
|
export async function ensureManagedIdentifierResult(
|
|
95
96
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
96
|
-
crypto?: Crypto
|
|
97
|
+
crypto?: webcrypto.Crypto
|
|
97
98
|
},
|
|
98
99
|
context: IAgentContext<IKeyManager>
|
|
99
100
|
): Promise<ManagedIdentifierResult> {
|
|
@@ -247,7 +248,7 @@ export async function getManagedJwkIdentifier(
|
|
|
247
248
|
|
|
248
249
|
export async function getManagedX5cIdentifier(
|
|
249
250
|
opts: ManagedIdentifierX5cOpts & {
|
|
250
|
-
crypto?: Crypto
|
|
251
|
+
crypto?: webcrypto.Crypto
|
|
251
252
|
},
|
|
252
253
|
context: IAgentContext<IKeyManager>
|
|
253
254
|
): Promise<ManagedIdentifierX5cResult> {
|
|
@@ -331,7 +332,7 @@ export async function getManagedOID4VCIssuerIdentifier(
|
|
|
331
332
|
|
|
332
333
|
export async function getManagedIdentifier(
|
|
333
334
|
opts: ManagedIdentifierOptsOrResult & {
|
|
334
|
-
crypto?: Crypto
|
|
335
|
+
crypto?: webcrypto.Crypto
|
|
335
336
|
},
|
|
336
337
|
context: IAgentContext<IKeyManager>
|
|
337
338
|
): Promise<ManagedIdentifierResult> {
|
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export const identifierResolutionContextMethods: Array<string> = [
|
|
|
41
41
|
'identifierManagedGetByX5c',
|
|
42
42
|
'identifierManagedGetByKey',
|
|
43
43
|
'identifierManagedGetByOID4VCIssuer',
|
|
44
|
-
'
|
|
44
|
+
'identifierManagedGetByCoseKey',
|
|
45
45
|
'identifierExternalResolve',
|
|
46
46
|
'identifierExternalResolveByDid',
|
|
47
47
|
'identifierExternalResolveByX5c',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
3
|
import {
|
|
4
4
|
ExternalIdentifierDidOpts,
|
|
5
5
|
ExternalIdentifierResult,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
IIdentifierResolution,
|
|
8
8
|
ManagedIdentifierOptsOrResult,
|
|
9
9
|
ManagedIdentifierResult,
|
|
10
|
-
} from '
|
|
10
|
+
} from '../types'*/
|
|
11
11
|
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
12
12
|
import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
|
|
13
13
|
import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
@@ -25,6 +25,7 @@ export interface IJwtService extends IPluginMethodMap {
|
|
|
25
25
|
export type IJwsValidationResult = IValidationResult & {
|
|
26
26
|
jws: JwsJsonGeneralWithIdentifiers
|
|
27
27
|
}
|
|
28
|
+
|
|
28
29
|
export interface PreparedJws {
|
|
29
30
|
protectedHeader: JwsHeader
|
|
30
31
|
payload: Uint8Array
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
isX5cIdentifier,
|
|
15
15
|
JwkInfo,
|
|
16
16
|
} from './common'
|
|
17
|
-
import {JwsPayload} from
|
|
17
|
+
import { JwsPayload } from './IJwtService'
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { IAgentPlugin } from '@veramo/core';
|
|
2
|
-
import { IIdentifierResolution } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export declare class IdentifierResolution implements IAgentPlugin {
|
|
7
|
-
private readonly _crypto;
|
|
8
|
-
readonly schema: any;
|
|
9
|
-
readonly methods: IIdentifierResolution;
|
|
10
|
-
/**
|
|
11
|
-
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
12
|
-
*/
|
|
13
|
-
constructor(opts?: {
|
|
14
|
-
crypto?: Crypto;
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
18
|
-
* integrate a plugin for anomaly detection. Having a single method helps
|
|
19
|
-
* @param args
|
|
20
|
-
* @param context
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
private identifierGetManaged;
|
|
24
|
-
private identifierGetManagedByDid;
|
|
25
|
-
private identifierGetManagedByKid;
|
|
26
|
-
private identifierGetManagedByKey;
|
|
27
|
-
private identifierGetManagedByCoseKey;
|
|
28
|
-
private identifierGetManagedByOID4VCIssuer;
|
|
29
|
-
private identifierGetManagedByJwk;
|
|
30
|
-
private identifierGetManagedByX5c;
|
|
31
|
-
private identifierResolveExternal;
|
|
32
|
-
private identifierExternalResolveByDid;
|
|
33
|
-
private identifierExternalResolveByX5c;
|
|
34
|
-
private identifierExternalResolveByCoseKey;
|
|
35
|
-
private identifierExternalResolveByJwk;
|
|
36
|
-
private identifierExternalResolveByOIDFEntityId;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=IdentifierResolution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,YAAY,EAA4B,MAAM,cAAc,CAAA;AAIpF,OAAO,EAWL,qBAAqB,EAiBtB,MAAM,UAAU,CAAA;AAGjB;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC,QAAQ,CAAC,MAAM,MAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAkBtC;IAED;;OAEG;gBACS,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC;;;;;;OAMG;YACW,oBAAoB;YAOpB,yBAAyB;YAOzB,yBAAyB;YAOzB,yBAAyB;YAOzB,6BAA6B;YAO7B,kCAAkC;YAOlC,yBAAyB;YAOzB,yBAAyB;YAOzB,yBAAyB;YAOzB,8BAA8B;YAI9B,8BAA8B;YAI9B,kCAAkC;YAOlC,8BAA8B;YAI9B,uCAAuC;CAMtD"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.IdentifierResolution = void 0;
|
|
13
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
14
|
-
const __1 = require("..");
|
|
15
|
-
const functions_1 = require("../functions");
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
class IdentifierResolution {
|
|
20
|
-
/**
|
|
21
|
-
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
22
|
-
*/
|
|
23
|
-
constructor(opts) {
|
|
24
|
-
this.schema = __1.schema.IMnemonicInfoGenerator;
|
|
25
|
-
this.methods = {
|
|
26
|
-
identifierManagedGet: this.identifierGetManaged.bind(this),
|
|
27
|
-
identifierManagedGetByDid: this.identifierGetManagedByDid.bind(this),
|
|
28
|
-
identifierManagedGetByKid: this.identifierGetManagedByKid.bind(this),
|
|
29
|
-
identifierManagedGetByJwk: this.identifierGetManagedByJwk.bind(this),
|
|
30
|
-
identifierManagedGetByX5c: this.identifierGetManagedByX5c.bind(this),
|
|
31
|
-
identifierManagedGetByKey: this.identifierGetManagedByKey.bind(this),
|
|
32
|
-
identifierManagedGetByCoseKey: this.identifierGetManagedByCoseKey.bind(this),
|
|
33
|
-
identifierManagedGetByOID4VCIssuer: this.identifierGetManagedByOID4VCIssuer.bind(this),
|
|
34
|
-
identifierExternalResolve: this.identifierResolveExternal.bind(this),
|
|
35
|
-
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
36
|
-
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
37
|
-
identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
|
|
38
|
-
identifierExternalResolveByCoseKey: this.identifierExternalResolveByCoseKey.bind(this),
|
|
39
|
-
identifierExternalResolveByOIDFEntityId: this.identifierExternalResolveByOIDFEntityId.bind(this),
|
|
40
|
-
// todo: JWKSet, oidc-discovery, oid4vci-issuer etc. Anything we already can resolve and need keys of
|
|
41
|
-
};
|
|
42
|
-
this._crypto = (0, ssi_sdk_ext_key_utils_1.globalCrypto)(false, opts === null || opts === void 0 ? void 0 : opts.crypto);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
46
|
-
* integrate a plugin for anomaly detection. Having a single method helps
|
|
47
|
-
* @param args
|
|
48
|
-
* @param context
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
identifierGetManaged(args, context) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return yield (0, functions_1.ensureManagedIdentifierResult)(Object.assign(Object.assign({}, args), { crypto: this._crypto }), context);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
identifierGetManagedByDid(args, context) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'did' }), context));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
identifierGetManagedByKid(args, context) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'kid' }), context));
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
identifierGetManagedByKey(args, context) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'key' }), context));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
identifierGetManagedByCoseKey(args, context) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'cose_key' }), context));
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
identifierGetManagedByOID4VCIssuer(args, context) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'oid4vci-issuer' }), context));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
identifierGetManagedByJwk(args, context) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'jwk' }), context));
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
identifierGetManagedByX5c(args, context) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'x5c' }), context));
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
identifierResolveExternal(args, context) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return yield (0, functions_1.resolveExternalIdentifier)(Object.assign(Object.assign({}, args), { crypto: this._crypto }), context);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
identifierExternalResolveByDid(args, context) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'did' }), context));
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
identifierExternalResolveByX5c(args, context) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'x5c' }), context));
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
identifierExternalResolveByCoseKey(args, context) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'cose_key' }), context));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
identifierExternalResolveByJwk(args, context) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'jwk' }), context));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
identifierExternalResolveByOIDFEntityId(args, context) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'entity_id' }), context));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.IdentifierResolution = IdentifierResolution;
|
|
123
|
-
//# sourceMappingURL=IdentifierResolution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierResolution.js","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA8D;AAG9D,0BAA2B;AAC3B,4CAAuF;AAgCvF;;GAEG;AACH,MAAa,oBAAoB;IAwB/B;;OAEG;IACH,YAAY,IAA0B;QAxB7B,WAAM,GAAG,UAAM,CAAC,sBAAsB,CAAA;QACtC,YAAO,GAA0B;YACxC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,6BAA6B,EAAE,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5E,kCAAkC,EAAE,IAAI,CAAC,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC;YAEtF,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9E,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IA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AAoC,CAAA;QAC5H,CAAC;KAAA;IAEa,8BAA8B,CAAC,IAA+B,EAAE,OAA2B;;YACvG,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,KAAK,KAAI,OAAO,CAAC,CAAgC,CAAA;QACnH,CAAC;KAAA;IAEa,uCAAuC,CACnD,IAAwC,EACxC,OAA2B;;YAE3B,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,WAAW,KAAI,OAAO,CAAC,CAAyC,CAAA;QAClI,CAAC;KAAA;CACF;AA9HD,oDA8HC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ManagedIdentifierOptsOrResult } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Converts legacy id opts key refs to the new ManagedIdentifierOpts
|
|
4
|
-
* @param opts
|
|
5
|
-
*/
|
|
6
|
-
export declare function legacyKeyRefsToIdentifierOpts(opts: {
|
|
7
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
8
|
-
iss?: string;
|
|
9
|
-
keyRef?: string;
|
|
10
|
-
didOpts?: any;
|
|
11
|
-
}): ManagedIdentifierOptsOrResult;
|
|
12
|
-
//# sourceMappingURL=LegacySupport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacySupport.d.ts","sourceRoot":"","sources":["../../src/functions/LegacySupport.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAElF;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,MAAM,CAAC,EAAE,6BAA6B,CAAA;IACtC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,GAAG,CAAA;CACd,GAAG,6BAA6B,CAyChC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.legacyKeyRefsToIdentifierOpts = legacyKeyRefsToIdentifierOpts;
|
|
4
|
-
/**
|
|
5
|
-
* Converts legacy id opts key refs to the new ManagedIdentifierOpts
|
|
6
|
-
* @param opts
|
|
7
|
-
*/
|
|
8
|
-
function legacyKeyRefsToIdentifierOpts(opts) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
10
|
-
if (!opts.idOpts) {
|
|
11
|
-
console.warn(`Legacy idOpts being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
12
|
-
// legacy way
|
|
13
|
-
let kmsKeyRef = (_j = (_f = (_d = (_a = opts.keyRef) !== null && _a !== void 0 ? _a : (_c = (_b = opts.didOpts) === null || _b === void 0 ? void 0 : _b.idOpts) === null || _c === void 0 ? void 0 : _c.kmsKeyRef) !== null && _d !== void 0 ? _d : (_e = opts.didOpts) === null || _e === void 0 ? void 0 : _e.kid) !== null && _f !== void 0 ? _f : (_h = (_g = opts.didOpts) === null || _g === void 0 ? void 0 : _g.idOpts) === null || _h === void 0 ? void 0 : _h.kid) !== null && _j !== void 0 ? _j : (typeof ((_l = (_k = opts.didOpts) === null || _k === void 0 ? void 0 : _k.idOpts) === null || _l === void 0 ? void 0 : _l.identifier) === 'object' ? opts.didOpts.idOpts.identifier.keys[0].kid : undefined);
|
|
14
|
-
if (!kmsKeyRef) {
|
|
15
|
-
throw Error('Key ref is needed for access token signer');
|
|
16
|
-
}
|
|
17
|
-
let identifier = ((_o = (_m = opts.didOpts) === null || _m === void 0 ? void 0 : _m.identifier) !== null && _o !== void 0 ? _o : (_q = (_p = opts.didOpts) === null || _p === void 0 ? void 0 : _p.idOpts) === null || _q === void 0 ? void 0 : _q.identifier);
|
|
18
|
-
return {
|
|
19
|
-
kmsKeyRef: (_r = opts.keyRef) !== null && _r !== void 0 ? _r : kmsKeyRef,
|
|
20
|
-
identifier: identifier !== null && identifier !== void 0 ? identifier : kmsKeyRef,
|
|
21
|
-
issuer: opts.iss,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const idOpts = opts.idOpts;
|
|
26
|
-
if (opts.keyRef && !idOpts.kmsKeyRef) {
|
|
27
|
-
// legacy way
|
|
28
|
-
console.warn(`Legacy keyRef being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
29
|
-
idOpts.kmsKeyRef = opts.keyRef;
|
|
30
|
-
}
|
|
31
|
-
if (opts.iss && !idOpts.issuer) {
|
|
32
|
-
// legacy way
|
|
33
|
-
console.warn(`Legacy iss being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
34
|
-
idOpts.issuer = opts.iss;
|
|
35
|
-
}
|
|
36
|
-
return idOpts;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=LegacySupport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacySupport.js","sourceRoot":"","sources":["../../src/functions/LegacySupport.ts"],"names":[],"mappings":";;AAOA,sEA8CC;AAlDD;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,IAK7C;;IACC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,uRAAuR,CACxR,CAAA;QACD,aAAa;QACb,IAAI,SAAS,GACX,MAAA,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,mCACX,MAAA,MAAA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MAAM,GAAG,IAAI,CAAC,GAAG,CAAA;QAC1B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { IAgentContext, IDIDManager, IResolver } from '@veramo/core';
|
|
2
|
-
import { ExternalIdentifierCoseKeyOpts, ExternalIdentifierCoseKeyResult, ExternalIdentifierDidOpts, ExternalIdentifierDidResult, ExternalIdentifierJwkOpts, ExternalIdentifierJwkResult, ExternalIdentifierOpts, ExternalIdentifierResult, ExternalIdentifierX5cOpts, ExternalIdentifierX5cResult } from '../types';
|
|
3
|
-
export declare function resolveExternalIdentifier(opts: ExternalIdentifierOpts & {
|
|
4
|
-
crypto?: Crypto;
|
|
5
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierResult>;
|
|
6
|
-
export declare function resolveExternalX5cIdentifier(opts: ExternalIdentifierX5cOpts & {
|
|
7
|
-
crypto?: Crypto;
|
|
8
|
-
}, context: IAgentContext<IResolver & IDIDManager>): Promise<ExternalIdentifierX5cResult>;
|
|
9
|
-
/**
|
|
10
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
11
|
-
* @param opts
|
|
12
|
-
* @param context
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveExternalJwkIdentifier(opts: ExternalIdentifierJwkOpts & {
|
|
15
|
-
x5c?: ExternalIdentifierX5cOpts;
|
|
16
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult>;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
19
|
-
* @param opts
|
|
20
|
-
* @param context
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveExternalCoseKeyIdentifier(opts: ExternalIdentifierCoseKeyOpts & {
|
|
23
|
-
x5c?: ExternalIdentifierX5cOpts;
|
|
24
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierCoseKeyResult>;
|
|
25
|
-
export declare function resolveExternalDidIdentifier(opts: ExternalIdentifierDidOpts, context: IAgentContext<IResolver & IDIDManager>): Promise<ExternalIdentifierDidResult>;
|
|
26
|
-
//# sourceMappingURL=externalIdentifierFunctions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/externalIdentifierFunctions.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGpE,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAE3B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAU5B,MAAM,UAAU,CAAA;AAGjB,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,sBAAsB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,wBAAwB,CAAC,CAoBnC;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,SAAS,GAAG,WAAW,CAAC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,CA4EtC;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,GAAG;IAChC,GAAG,CAAC,EAAE,yBAAyB,CAAA;CAChC,EACD,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,2BAA2B,CAAC,CAuBtC;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CACpD,IAAI,EAAE,6BAA6B,GAAG;IACpC,GAAG,CAAC,EAAE,yBAAyB,CAAA;CAChC,EAC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