@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-next.98 → 0.24.1-unstable.111
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/agent/IdentifierResolution.d.ts +3 -1
- package/dist/agent/IdentifierResolution.d.ts.map +1 -1
- package/dist/agent/IdentifierResolution.js +19 -7
- package/dist/agent/IdentifierResolution.js.map +1 -1
- package/dist/functions/LegacySupport.d.ts.map +1 -1
- package/dist/functions/LegacySupport.js +5 -4
- package/dist/functions/LegacySupport.js.map +1 -1
- package/dist/functions/externalIdentifierFunctions.d.ts +17 -1
- package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/externalIdentifierFunctions.js +82 -2
- package/dist/functions/externalIdentifierFunctions.js.map +1 -1
- package/dist/functions/managedIdentifierFunctions.d.ts +16 -5
- package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/managedIdentifierFunctions.js +66 -6
- package/dist/functions/managedIdentifierFunctions.js.map +1 -1
- package/dist/types/IIdentifierResolution.d.ts +10 -12
- package/dist/types/IIdentifierResolution.d.ts.map +1 -1
- package/dist/types/IIdentifierResolution.js +3 -1
- package/dist/types/IIdentifierResolution.js.map +1 -1
- package/dist/types/common.d.ts +2 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +5 -1
- package/dist/types/common.js.map +1 -1
- package/dist/types/externalIdentifierTypes.d.ts +23 -6
- package/dist/types/externalIdentifierTypes.d.ts.map +1 -1
- package/dist/types/externalIdentifierTypes.js +6 -1
- package/dist/types/externalIdentifierTypes.js.map +1 -1
- package/dist/types/managedIdentifierTypes.d.ts +29 -7
- package/dist/types/managedIdentifierTypes.d.ts.map +1 -1
- package/dist/types/managedIdentifierTypes.js +10 -1
- package/dist/types/managedIdentifierTypes.js.map +1 -1
- package/package.json +12 -12
- package/plugin.schema.json +2149 -264
- package/src/agent/IdentifierResolution.ts +56 -18
- package/src/functions/LegacySupport.ts +5 -1
- package/src/functions/externalIdentifierFunctions.ts +94 -4
- package/src/functions/managedIdentifierFunctions.ts +79 -10
- package/src/types/IIdentifierResolution.ts +22 -12
- package/src/types/common.ts +5 -1
- package/src/types/externalIdentifierTypes.ts +54 -13
- package/src/types/managedIdentifierTypes.ts +47 -8
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { DidDocumentJwks } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
|
-
import { JWK } from '@sphereon/ssi-
|
|
3
|
-
import { X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
2
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
3
|
+
import { X509CertificateChainValidationOpts, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
4
4
|
import { IParsedDID } from '@sphereon/ssi-types'
|
|
5
5
|
import { DIDDocument, DIDDocumentSection, DIDResolutionResult } from '@veramo/core'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
isCoseKeyIdentifier,
|
|
8
|
+
isDidIdentifier,
|
|
9
|
+
isJwkIdentifier,
|
|
10
|
+
isJwksUrlIdentifier,
|
|
11
|
+
isKidIdentifier,
|
|
12
|
+
isOidcDiscoveryIdentifier,
|
|
13
|
+
isX5cIdentifier,
|
|
14
|
+
JwkInfo,
|
|
15
|
+
} from './common'
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
18
|
* Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
|
|
@@ -32,7 +41,13 @@ export function isExternalIdentifierDidOpts(opts: ExternalIdentifierOptsBase): o
|
|
|
32
41
|
return ('method' in opts && opts.method === 'did') || isDidIdentifier(identifier)
|
|
33
42
|
}
|
|
34
43
|
|
|
35
|
-
export type ExternalIdentifierOpts = (
|
|
44
|
+
export type ExternalIdentifierOpts = (
|
|
45
|
+
| ExternalIdentifierJwkOpts
|
|
46
|
+
| ExternalIdentifierX5cOpts
|
|
47
|
+
| ExternalIdentifierDidOpts
|
|
48
|
+
| ExternalIdentifierKidOpts
|
|
49
|
+
| ExternalIdentifierCoseKeyOpts
|
|
50
|
+
) &
|
|
36
51
|
ExternalIdentifierOptsBase
|
|
37
52
|
|
|
38
53
|
export type ExternalIdentifierKidOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
|
|
@@ -48,6 +63,7 @@ export function isExternalIdentifierKidOpts(opts: ExternalIdentifierOptsBase): o
|
|
|
48
63
|
export type ExternalIdentifierJwkOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
|
|
49
64
|
method?: 'jwk'
|
|
50
65
|
identifier: JWK
|
|
66
|
+
x5c?: ExternalIdentifierX5cOpts
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
export function isExternalIdentifierJwkOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierJwkOpts {
|
|
@@ -55,6 +71,16 @@ export function isExternalIdentifierJwkOpts(opts: ExternalIdentifierOptsBase): o
|
|
|
55
71
|
return ('method' in opts && opts.method === 'jwk') || isJwkIdentifier(identifier)
|
|
56
72
|
}
|
|
57
73
|
|
|
74
|
+
export type ExternalIdentifierCoseKeyOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
|
|
75
|
+
method?: 'cose_key'
|
|
76
|
+
identifier: ICoseKeyJson
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function isExternalIdentifierCoseKeyOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierCoseKeyOpts {
|
|
80
|
+
const { identifier } = opts
|
|
81
|
+
return ('method' in opts && opts.method === 'cose_key') || isCoseKeyIdentifier(identifier)
|
|
82
|
+
}
|
|
83
|
+
|
|
58
84
|
export type ExternalIdentifierOidcDiscoveryOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
|
|
59
85
|
method?: 'oidc-discovery'
|
|
60
86
|
identifier: string
|
|
@@ -75,28 +101,42 @@ export function isExternalIdentifierJwksUrlOpts(opts: ExternalIdentifierOptsBase
|
|
|
75
101
|
return ('method' in opts && opts.method === 'oidc-discovery') || isJwksUrlIdentifier(identifier)
|
|
76
102
|
}
|
|
77
103
|
|
|
78
|
-
export type ExternalIdentifierX5cOpts = Omit<ExternalIdentifierOptsBase, 'method'> &
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
export type ExternalIdentifierX5cOpts = Omit<ExternalIdentifierOptsBase, 'method'> &
|
|
105
|
+
X509CertificateChainValidationOpts & {
|
|
106
|
+
method?: 'x5c'
|
|
107
|
+
identifier: string[]
|
|
108
|
+
verify?: boolean // defaults to true
|
|
109
|
+
verificationTime?: Date
|
|
110
|
+
trustAnchors?: string[]
|
|
111
|
+
}
|
|
85
112
|
|
|
86
113
|
export function isExternalIdentifierX5cOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierX5cOpts {
|
|
87
114
|
const { identifier } = opts
|
|
88
115
|
return ('method' in opts && opts.method === 'x5c') || isX5cIdentifier(identifier)
|
|
89
116
|
}
|
|
90
117
|
|
|
91
|
-
export type ExternalIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'oidc-discovery' | 'jwks-url' | 'oid4vci-issuer'
|
|
118
|
+
export type ExternalIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'cose_key' | 'oidc-discovery' | 'jwks-url' | 'oid4vci-issuer'
|
|
92
119
|
|
|
93
|
-
export type ExternalIdentifierResult =
|
|
120
|
+
export type ExternalIdentifierResult = IExternalIdentifierResultBase &
|
|
121
|
+
(ExternalIdentifierDidResult | ExternalIdentifierX5cResult | ExternalIdentifierJwkResult | ExternalIdentifierCoseKeyResult)
|
|
94
122
|
|
|
95
123
|
export interface IExternalIdentifierResultBase {
|
|
96
124
|
method: ExternalIdentifierMethod
|
|
97
125
|
jwks: Array<ExternalJwkInfo>
|
|
98
126
|
}
|
|
99
127
|
|
|
128
|
+
export interface ExternalIdentifierJwkResult extends IExternalIdentifierResultBase {
|
|
129
|
+
method: 'jwk'
|
|
130
|
+
jwk: JWK
|
|
131
|
+
x5c?: ExternalIdentifierX5cResult
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ExternalIdentifierCoseKeyResult extends IExternalIdentifierResultBase {
|
|
135
|
+
method: 'cose_key'
|
|
136
|
+
coseKey: ICoseKeyJson
|
|
137
|
+
x5c?: ExternalIdentifierX5cResult
|
|
138
|
+
}
|
|
139
|
+
|
|
100
140
|
export interface ExternalIdentifierX5cResult extends IExternalIdentifierResultBase {
|
|
101
141
|
method: 'x5c'
|
|
102
142
|
x5c: string[]
|
|
@@ -107,6 +147,7 @@ export interface ExternalIdentifierX5cResult extends IExternalIdentifierResultBa
|
|
|
107
147
|
|
|
108
148
|
export interface ExternalJwkInfo extends JwkInfo {
|
|
109
149
|
kid?: string
|
|
150
|
+
publicKeyHex: string
|
|
110
151
|
}
|
|
111
152
|
|
|
112
153
|
export interface ExternalIdentifierDidResult extends IExternalIdentifierResultBase {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
2
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
2
3
|
import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
|
|
3
|
-
import { isDidIdentifier, isJwkIdentifier, isKeyIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
|
|
4
|
+
import { isCoseKeyIdentifier, isDidIdentifier, isJwkIdentifier, isKeyIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
|
|
7
8
|
*
|
|
8
9
|
* The functions below can be used to check the type, and they also provide the proper 'runtime' types
|
|
9
10
|
*/
|
|
10
|
-
export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK | IKey
|
|
11
|
+
export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK | IKey | ICoseKeyJson
|
|
11
12
|
|
|
12
13
|
export type ManagedIdentifierOpts = (
|
|
13
14
|
| ManagedIdentifierJwkOpts
|
|
@@ -15,6 +16,7 @@ export type ManagedIdentifierOpts = (
|
|
|
15
16
|
| ManagedIdentifierDidOpts
|
|
16
17
|
| ManagedIdentifierKidOpts
|
|
17
18
|
| ManagedIdentifierKeyOpts
|
|
19
|
+
| ManagedIdentifierCoseKeyOpts
|
|
18
20
|
) &
|
|
19
21
|
ManagedIdentifierOptsBase
|
|
20
22
|
|
|
@@ -24,6 +26,8 @@ export type ManagedIdentifierOptsBase = {
|
|
|
24
26
|
kmsKeyRef?: string // The key reference for the KMS system. If provided this value will be used to determine the appropriate key. Otherwise it will be inferred
|
|
25
27
|
issuer?: string // can be used when a specific issuer needs to end up, for instance when signing JWTs. Will be returned or inferred if not provided
|
|
26
28
|
kid?: string // can be used when a specific kid value needs to be used. For instance when signing JWTs. Will be returned or inferred if not provided
|
|
29
|
+
clientId?: string
|
|
30
|
+
clientIdScheme?: ClientIdScheme | 'did' | string
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
@@ -56,11 +60,21 @@ export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'>
|
|
|
56
60
|
identifier: IKey
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is
|
|
63
|
+
export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKeyOpts {
|
|
60
64
|
const { identifier } = opts
|
|
61
65
|
return ('method' in opts && opts.method === 'key') || isKeyIdentifier(identifier)
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
export type ManagedIdentifierCoseKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
69
|
+
method?: 'cose_key'
|
|
70
|
+
identifier: ICoseKeyJson
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isManagedIdentifierCoseKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierCoseKeyOpts {
|
|
74
|
+
const { identifier } = opts
|
|
75
|
+
return ('method' in opts && opts.method === 'cose_key') || isCoseKeyIdentifier(identifier)
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
65
79
|
method?: 'jwk'
|
|
66
80
|
identifier: JWK
|
|
@@ -91,6 +105,9 @@ export interface IManagedIdentifierResultBase extends ManagedJwkInfo {
|
|
|
91
105
|
key: IKey
|
|
92
106
|
kid?: string
|
|
93
107
|
issuer?: string
|
|
108
|
+
clientId?: string
|
|
109
|
+
clientIdScheme?: ClientIdScheme | 'did' | string
|
|
110
|
+
identifier: ManagedIdentifierType
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
export function isManagedIdentifierDidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult {
|
|
@@ -113,6 +130,10 @@ export function isManagedIdentifierKeyResult(object: IManagedIdentifierResultBas
|
|
|
113
130
|
return object!! && typeof object === 'object' && 'method' in object && object.method === 'key'
|
|
114
131
|
}
|
|
115
132
|
|
|
133
|
+
export function isManagedIdentifierCoseKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierCoseKeyResult {
|
|
134
|
+
return object!! && typeof object === 'object' && 'method' in object && object.method === 'cose_key'
|
|
135
|
+
}
|
|
136
|
+
|
|
116
137
|
export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase {
|
|
117
138
|
method: 'did'
|
|
118
139
|
identifier: IIdentifier
|
|
@@ -126,27 +147,45 @@ export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase
|
|
|
126
147
|
}
|
|
127
148
|
|
|
128
149
|
export interface ManagedIdentifierJwkResult extends IManagedIdentifierResultBase {
|
|
150
|
+
identifier: JWK
|
|
129
151
|
method: 'jwk'
|
|
130
152
|
}
|
|
131
153
|
|
|
132
154
|
export interface ManagedIdentifierKidResult extends IManagedIdentifierResultBase {
|
|
133
155
|
method: 'kid'
|
|
156
|
+
identifier: string
|
|
134
157
|
kid: string
|
|
135
158
|
}
|
|
136
159
|
|
|
137
160
|
export interface ManagedIdentifierKeyResult extends IManagedIdentifierResultBase {
|
|
138
161
|
method: 'key'
|
|
162
|
+
identifier: IKey
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface ManagedIdentifierCoseKeyResult extends IManagedIdentifierResultBase {
|
|
166
|
+
method: 'cose_key'
|
|
167
|
+
identifier: ICoseKeyJson
|
|
139
168
|
}
|
|
140
169
|
|
|
141
170
|
export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
|
|
142
171
|
method: 'x5c'
|
|
172
|
+
identifier: string[]
|
|
143
173
|
x5c: string[]
|
|
144
174
|
certificate: any // Certificate(JSON_, but trips schema generator. Probably want to create our own DTO
|
|
145
175
|
}
|
|
146
176
|
|
|
147
|
-
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key'
|
|
177
|
+
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key' | 'cose_key'
|
|
148
178
|
|
|
149
179
|
export type ManagedIdentifierResult = IManagedIdentifierResultBase &
|
|
150
|
-
(
|
|
151
|
-
|
|
152
|
-
|
|
180
|
+
(
|
|
181
|
+
| ManagedIdentifierX5cResult
|
|
182
|
+
| ManagedIdentifierDidResult
|
|
183
|
+
| ManagedIdentifierJwkResult
|
|
184
|
+
| ManagedIdentifierKidResult
|
|
185
|
+
| ManagedIdentifierKeyResult
|
|
186
|
+
| ManagedIdentifierCoseKeyResult
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
export type ManagedIdentifierOptsOrResult = (ManagedIdentifierResult | ManagedIdentifierOpts) & {
|
|
190
|
+
lazyDisabled?: boolean
|
|
191
|
+
}
|