@sphereon/ssi-sdk-ext.identifier-resolution 0.27.1-next.6 → 0.28.1-feature.esm.cjs.11
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 +5336 -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 +679 -710
- package/src/agent/IdentifierResolution.ts +36 -35
- package/src/functions/externalIdentifierFunctions.ts +21 -14
- package/src/functions/externalOIDFIdentifier.ts +7 -2
- package/src/functions/managedIdentifierFunctions.ts +22 -8
- 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 +2 -0
- 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 -80
- 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 -346
- 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 -112
- 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,26 @@ 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
|
+
readonly _crypto: webcrypto.Crypto
|
|
42
44
|
|
|
43
45
|
readonly schema = schema.IMnemonicInfoGenerator
|
|
44
46
|
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.
|
|
47
|
+
identifierManagedGet: this.identifierManagedGet.bind(this),
|
|
48
|
+
identifierManagedGetByDid: this.identifierManagedGetByDid.bind(this),
|
|
49
|
+
identifierManagedGetByKid: this.identifierManagedGetByKid.bind(this),
|
|
50
|
+
identifierManagedGetByJwk: this.identifierManagedGetByJwk.bind(this),
|
|
51
|
+
identifierManagedGetByX5c: this.identifierManagedGetByX5c.bind(this),
|
|
52
|
+
identifierManagedGetByKey: this.identifierManagedGetByKey.bind(this),
|
|
53
|
+
identifierManagedGetByCoseKey: this.identifierManagedGetByCoseKey.bind(this),
|
|
54
|
+
identifierManagedGetByOID4VCIssuer: this.identifierManagedGetByOID4VCIssuer.bind(this),
|
|
55
|
+
|
|
56
|
+
identifierExternalResolve: this.identifierExternalResolve.bind(this),
|
|
55
57
|
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
56
58
|
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
57
59
|
identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
|
|
@@ -64,7 +66,7 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
64
66
|
/**
|
|
65
67
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
66
68
|
*/
|
|
67
|
-
constructor(opts?: { crypto?: Crypto }) {
|
|
69
|
+
constructor(opts?: { crypto?: webcrypto.Crypto }) {
|
|
68
70
|
this._crypto = globalCrypto(false, opts?.crypto)
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -73,65 +75,64 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
73
75
|
* integrate a plugin for anomaly detection. Having a single method helps
|
|
74
76
|
* @param args
|
|
75
77
|
* @param context
|
|
76
|
-
* @private
|
|
77
78
|
*/
|
|
78
|
-
private async
|
|
79
|
+
private async identifierManagedGet(
|
|
79
80
|
args: ManagedIdentifierOptsOrResult,
|
|
80
81
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
81
82
|
): Promise<ManagedIdentifierResult> {
|
|
82
83
|
return await ensureManagedIdentifierResult({ ...args, crypto: this._crypto }, context)
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
private async
|
|
86
|
+
private async identifierManagedGetByDid(
|
|
86
87
|
args: ManagedIdentifierDidOpts,
|
|
87
88
|
context: IAgentContext<IKeyManager & IDIDManager & IIdentifierResolution>
|
|
88
89
|
): Promise<ManagedIdentifierDidResult> {
|
|
89
|
-
return (await this.
|
|
90
|
+
return (await this.identifierManagedGet({ ...args, method: 'did' }, context)) as ManagedIdentifierDidResult
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
private async
|
|
93
|
+
private async identifierManagedGetByKid(
|
|
93
94
|
args: ManagedIdentifierKidOpts,
|
|
94
95
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
95
96
|
): Promise<ManagedIdentifierKidResult> {
|
|
96
|
-
return (await this.
|
|
97
|
+
return (await this.identifierManagedGet({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
private async
|
|
100
|
+
private async identifierManagedGetByKey(
|
|
100
101
|
args: ManagedIdentifierKeyOpts,
|
|
101
102
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
102
103
|
): Promise<ManagedIdentifierKeyResult> {
|
|
103
|
-
return (await this.
|
|
104
|
+
return (await this.identifierManagedGet({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
private async
|
|
107
|
+
private async identifierManagedGetByCoseKey(
|
|
107
108
|
args: ManagedIdentifierCoseKeyOpts,
|
|
108
109
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
109
110
|
): Promise<ManagedIdentifierCoseKeyResult> {
|
|
110
|
-
return (await this.
|
|
111
|
+
return (await this.identifierManagedGet({ ...args, method: 'cose_key' }, context)) as ManagedIdentifierCoseKeyResult
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
private async
|
|
114
|
+
private async identifierManagedGetByOID4VCIssuer(
|
|
114
115
|
args: ManagedIdentifierOID4VCIssuerOpts,
|
|
115
116
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
116
117
|
): Promise<ManagedIdentifierOID4VCIssuerResult> {
|
|
117
|
-
return (await this.
|
|
118
|
+
return (await this.identifierManagedGet({ ...args, method: 'oid4vci-issuer' }, context)) as ManagedIdentifierOID4VCIssuerResult
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
private async
|
|
121
|
+
private async identifierManagedGetByJwk(
|
|
121
122
|
args: ManagedIdentifierJwkOpts,
|
|
122
123
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
123
124
|
): Promise<ManagedIdentifierJwkResult> {
|
|
124
|
-
return (await this.
|
|
125
|
+
return (await this.identifierManagedGet({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
private async
|
|
128
|
+
private async identifierManagedGetByX5c(
|
|
128
129
|
args: ManagedIdentifierX5cOpts,
|
|
129
130
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
130
131
|
): Promise<ManagedIdentifierX5cResult> {
|
|
131
|
-
return (await this.
|
|
132
|
+
return (await this.identifierManagedGet({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
private async
|
|
135
|
+
private async identifierExternalResolve(
|
|
135
136
|
args: ExternalIdentifierOpts,
|
|
136
137
|
context: IAgentContext<IKeyManager | IOIDFClient>
|
|
137
138
|
): Promise<ExternalIdentifierResult> {
|
|
@@ -139,28 +140,28 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
private async identifierExternalResolveByDid(args: ExternalIdentifierDidOpts, context: IAgentContext<any>): Promise<ExternalIdentifierDidResult> {
|
|
142
|
-
return (await this.
|
|
143
|
+
return (await this.identifierExternalResolve({ ...args, method: 'did' }, context)) as ExternalIdentifierDidResult
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
private async identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult> {
|
|
146
|
-
return (await this.
|
|
147
|
+
return (await this.identifierExternalResolve({ ...args, method: 'x5c' }, context)) as ExternalIdentifierX5cResult
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
private async identifierExternalResolveByCoseKey(
|
|
150
151
|
args: ExternalIdentifierCoseKeyOpts,
|
|
151
152
|
context: IAgentContext<any>
|
|
152
153
|
): Promise<ExternalIdentifierCoseKeyResult> {
|
|
153
|
-
return (await this.
|
|
154
|
+
return (await this.identifierExternalResolve({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
private async identifierExternalResolveByJwk(args: ExternalIdentifierJwkOpts, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult> {
|
|
157
|
-
return (await this.
|
|
158
|
+
return (await this.identifierExternalResolve({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
private async identifierExternalResolveByOIDFEntityId(
|
|
161
162
|
args: ExternalIdentifierOIDFEntityIdOpts,
|
|
162
163
|
context: IAgentContext<any>
|
|
163
164
|
): Promise<ExternalIdentifierOIDFEntityIdResult> {
|
|
164
|
-
return (await this.
|
|
165
|
+
return (await this.identifierExternalResolve({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
|
|
165
166
|
}
|
|
166
167
|
}
|
|
@@ -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,10 @@ 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 } from '../types/IJwtService'
|
|
6
|
-
|
|
5
|
+
import { IJwsValidationResult, JwsPayload } from '../types/IJwtService'
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import * as u8a from 'uint8arrays'
|
|
8
|
+
const { fromString, toString } = u8a
|
|
7
9
|
/**
|
|
8
10
|
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
9
11
|
*
|
|
@@ -36,6 +38,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
36
38
|
const errorList: Record<TrustedAnchor, ErrorMessage> = {}
|
|
37
39
|
const jwkInfos: Array<ExternalJwkInfo> = []
|
|
38
40
|
|
|
41
|
+
let payload: JwsPayload | undefined
|
|
39
42
|
for (const trustAnchor of trustAnchors) {
|
|
40
43
|
const resolveResult = await context.agent.resolveTrustChain({
|
|
41
44
|
entityIdentifier: identifier,
|
|
@@ -64,6 +67,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
64
67
|
continue
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
payload = JSON.parse(toString(fromString(jwtVerifyResult.jws.payload, 'base64url')))
|
|
67
71
|
const signature = jwtVerifyResult.jws.signatures[0]
|
|
68
72
|
if (signature.identifier.jwks.length === 0) {
|
|
69
73
|
errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
|
|
@@ -83,6 +87,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
83
87
|
trustedAnchors: Array.from(trustedAnchors),
|
|
84
88
|
...(Object.keys(errorList).length > 0 && { errorList }),
|
|
85
89
|
jwks: jwkInfos,
|
|
90
|
+
jwtPayload: payload,
|
|
86
91
|
trustEstablished: trustedAnchors.size > 0,
|
|
87
92
|
}
|
|
88
93
|
}
|
|
@@ -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,
|
|
@@ -40,16 +41,29 @@ export async function getManagedKidIdentifier(
|
|
|
40
41
|
context: IAgentContext<IKeyManager>
|
|
41
42
|
): Promise<ManagedIdentifierKidResult> {
|
|
42
43
|
const method = 'kid'
|
|
44
|
+
let key: IKey | undefined = undefined
|
|
45
|
+
let issuer: string | undefined = undefined
|
|
46
|
+
let kid: string | undefined = undefined
|
|
43
47
|
if (!contextHasKeyManager(context)) {
|
|
44
48
|
return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
|
|
45
49
|
} else if (opts.identifier.startsWith('did:')) {
|
|
46
|
-
|
|
50
|
+
const did = opts.identifier.split('#')[0]
|
|
51
|
+
const didIdentifier = await getManagedDidIdentifier({ ...opts, method: 'did', identifier: did }, context)
|
|
52
|
+
key = didIdentifier.key
|
|
53
|
+
issuer = didIdentifier.issuer
|
|
54
|
+
kid = opts?.kid ?? (key.meta?.verificationMethod?.id as string) ?? didIdentifier.kid
|
|
55
|
+
}
|
|
56
|
+
if (!key) {
|
|
57
|
+
key = await context.agent.keyManagerGet({ kid: opts.kmsKeyRef ?? opts.identifier })
|
|
47
58
|
}
|
|
48
|
-
const key = await context.agent.keyManagerGet({ kid: opts.kmsKeyRef ?? opts.identifier })
|
|
49
59
|
const jwk = toJwk(key.publicKeyHex, key.type, { key })
|
|
50
60
|
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({ jwk })
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
if (!kid) {
|
|
62
|
+
kid = opts.kid ?? (key.meta?.verificationMethod?.id as string) ?? key.kid ?? jwkThumbprint
|
|
63
|
+
}
|
|
64
|
+
if (!issuer) {
|
|
65
|
+
issuer = opts.issuer ?? kid // The different identifiers should set the value. Defaults to the kid
|
|
66
|
+
}
|
|
53
67
|
return {
|
|
54
68
|
method,
|
|
55
69
|
key,
|
|
@@ -67,7 +81,7 @@ export async function getManagedKidIdentifier(
|
|
|
67
81
|
|
|
68
82
|
export function isManagedIdentifierResult(
|
|
69
83
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
70
|
-
crypto?: Crypto
|
|
84
|
+
crypto?: webcrypto.Crypto
|
|
71
85
|
}
|
|
72
86
|
): identifier is ManagedIdentifierResult {
|
|
73
87
|
return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && 'opts' in identifier && 'jwkThumbprint' in identifier
|
|
@@ -80,7 +94,7 @@ export function isManagedIdentifierResult(
|
|
|
80
94
|
*/
|
|
81
95
|
export async function ensureManagedIdentifierResult(
|
|
82
96
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
83
|
-
crypto?: Crypto
|
|
97
|
+
crypto?: webcrypto.Crypto
|
|
84
98
|
},
|
|
85
99
|
context: IAgentContext<IKeyManager>
|
|
86
100
|
): Promise<ManagedIdentifierResult> {
|
|
@@ -234,7 +248,7 @@ export async function getManagedJwkIdentifier(
|
|
|
234
248
|
|
|
235
249
|
export async function getManagedX5cIdentifier(
|
|
236
250
|
opts: ManagedIdentifierX5cOpts & {
|
|
237
|
-
crypto?: Crypto
|
|
251
|
+
crypto?: webcrypto.Crypto
|
|
238
252
|
},
|
|
239
253
|
context: IAgentContext<IKeyManager>
|
|
240
254
|
): Promise<ManagedIdentifierX5cResult> {
|
|
@@ -318,7 +332,7 @@ export async function getManagedOID4VCIssuerIdentifier(
|
|
|
318
332
|
|
|
319
333
|
export async function getManagedIdentifier(
|
|
320
334
|
opts: ManagedIdentifierOptsOrResult & {
|
|
321
|
-
crypto?: Crypto
|
|
335
|
+
crypto?: webcrypto.Crypto
|
|
322
336
|
},
|
|
323
337
|
context: IAgentContext<IKeyManager>
|
|
324
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,6 +14,7 @@ import {
|
|
|
14
14
|
isX5cIdentifier,
|
|
15
15
|
JwkInfo,
|
|
16
16
|
} from './common'
|
|
17
|
+
import { JwsPayload } from './IJwtService'
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
|
|
@@ -172,6 +173,7 @@ export interface ExternalIdentifierOIDFEntityIdResult extends IExternalIdentifie
|
|
|
172
173
|
method: 'entity_id'
|
|
173
174
|
trustedAnchors: Array<TrustedAnchor>
|
|
174
175
|
errorList?: Record<TrustedAnchor, ErrorMessage>
|
|
176
|
+
jwtPayload?: JwsPayload
|
|
175
177
|
trustEstablished: boolean
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -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,IAAI,CAAC;YAC9E,8BAA8B,EAAE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9E,kCAAkC,EAAE,IA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AC,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,IAAI,CAAC,OAAO,0CAAE,MAAM,0CAAE,SAAS,mCAC/B,MAAA,IAAI,CAAC,OAAO,0CAAE,GAAG,mCACjB,MAAA,M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