@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.FIDES.1.274 → 0.34.1-feature.IDK.11.48
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 +432 -481
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -739
- package/dist/index.d.ts +69 -739
- package/dist/index.js +424 -472
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/RPInstance.ts +29 -14
- package/src/agent/SIOPv2RP.ts +67 -138
- package/src/functions.ts +52 -49
- package/src/index.ts +1 -1
- package/src/types/ISIOPv2RP.ts +62 -32
package/dist/index.js
CHANGED
|
@@ -1,359 +1,363 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
5
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
6
|
+
};
|
|
3
7
|
|
|
4
8
|
// plugin.schema.json
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var require_plugin_schema = __commonJS({
|
|
10
|
+
"plugin.schema.json"(exports, module) {
|
|
11
|
+
module.exports = {
|
|
12
|
+
IDidAuthSiopOpAuthenticator: {
|
|
13
|
+
components: {
|
|
14
|
+
schemas: {
|
|
15
|
+
IGetSiopSessionArgs: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
sessionId: {
|
|
19
|
+
type: "string"
|
|
20
|
+
},
|
|
21
|
+
additionalProperties: false
|
|
22
|
+
},
|
|
23
|
+
required: ["sessionId"],
|
|
24
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSessionForSiop } "
|
|
14
25
|
},
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
required: ["sessionId"],
|
|
18
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSessionForSiop } "
|
|
19
|
-
},
|
|
20
|
-
IRegisterSiopSessionArgs: {
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
identifier: {
|
|
26
|
+
IRegisterSiopSessionArgs: {
|
|
24
27
|
type: "object",
|
|
25
28
|
properties: {
|
|
26
|
-
|
|
29
|
+
identifier: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
did: {
|
|
33
|
+
type: "string"
|
|
34
|
+
},
|
|
35
|
+
alias: {
|
|
36
|
+
type: "string"
|
|
37
|
+
},
|
|
38
|
+
provider: {
|
|
39
|
+
type: "string"
|
|
40
|
+
},
|
|
41
|
+
controllerKeyId: {
|
|
42
|
+
type: "string"
|
|
43
|
+
},
|
|
44
|
+
keys: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
additionalProperties: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
services: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
additionalProperties: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
required: ["did", "provider", "keys", "services"]
|
|
65
|
+
},
|
|
66
|
+
sessionId: {
|
|
27
67
|
type: "string"
|
|
28
68
|
},
|
|
29
|
-
|
|
69
|
+
expiresIn: {
|
|
70
|
+
type: "number"
|
|
71
|
+
},
|
|
72
|
+
additionalProperties: false
|
|
73
|
+
},
|
|
74
|
+
required: ["identifier"],
|
|
75
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.registerSessionForSiop } "
|
|
76
|
+
},
|
|
77
|
+
IRemoveSiopSessionArgs: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
sessionId: {
|
|
30
81
|
type: "string"
|
|
31
82
|
},
|
|
32
|
-
|
|
83
|
+
additionalProperties: false
|
|
84
|
+
},
|
|
85
|
+
required: ["sessionId"],
|
|
86
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.removeSessionForSiop } "
|
|
87
|
+
},
|
|
88
|
+
IAuthenticateWithSiopArgs: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
sessionId: {
|
|
33
92
|
type: "string"
|
|
34
93
|
},
|
|
35
|
-
|
|
94
|
+
stateId: {
|
|
36
95
|
type: "string"
|
|
37
96
|
},
|
|
38
|
-
|
|
39
|
-
type: "
|
|
40
|
-
items: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
additionalProperties: true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
97
|
+
redirectUrl: {
|
|
98
|
+
type: "string"
|
|
46
99
|
},
|
|
47
|
-
|
|
48
|
-
type: "array",
|
|
49
|
-
items: {
|
|
50
|
-
type: "object",
|
|
51
|
-
properties: {
|
|
52
|
-
additionalProperties: true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
100
|
+
additionalProperties: false
|
|
56
101
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
sessionId: {
|
|
61
|
-
type: "string"
|
|
102
|
+
required: ["sessionId", "stateId", "redirectUrl"],
|
|
103
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.authenticateWithSiop } "
|
|
62
104
|
},
|
|
63
|
-
|
|
64
|
-
type: "number"
|
|
65
|
-
},
|
|
66
|
-
additionalProperties: false
|
|
67
|
-
},
|
|
68
|
-
required: ["identifier"],
|
|
69
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.registerSessionForSiop } "
|
|
70
|
-
},
|
|
71
|
-
IRemoveSiopSessionArgs: {
|
|
72
|
-
type: "object",
|
|
73
|
-
properties: {
|
|
74
|
-
sessionId: {
|
|
75
|
-
type: "string"
|
|
76
|
-
},
|
|
77
|
-
additionalProperties: false
|
|
78
|
-
},
|
|
79
|
-
required: ["sessionId"],
|
|
80
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.removeSessionForSiop } "
|
|
81
|
-
},
|
|
82
|
-
IAuthenticateWithSiopArgs: {
|
|
83
|
-
type: "object",
|
|
84
|
-
properties: {
|
|
85
|
-
sessionId: {
|
|
86
|
-
type: "string"
|
|
87
|
-
},
|
|
88
|
-
stateId: {
|
|
89
|
-
type: "string"
|
|
90
|
-
},
|
|
91
|
-
redirectUrl: {
|
|
92
|
-
type: "string"
|
|
93
|
-
},
|
|
94
|
-
additionalProperties: false
|
|
95
|
-
},
|
|
96
|
-
required: ["sessionId", "stateId", "redirectUrl"],
|
|
97
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.authenticateWithSiop } "
|
|
98
|
-
},
|
|
99
|
-
IResponse: {
|
|
100
|
-
type: "object",
|
|
101
|
-
properties: {
|
|
102
|
-
status: {
|
|
103
|
-
type: "number"
|
|
104
|
-
},
|
|
105
|
-
additionalProperties: true
|
|
106
|
-
},
|
|
107
|
-
required: ["status"],
|
|
108
|
-
description: "Result of {@link DidAuthSiopOpAuthenticator.authenticateWithSiop & DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
109
|
-
},
|
|
110
|
-
IGetSiopAuthenticationRequestFromRpArgs: {
|
|
111
|
-
type: "object",
|
|
112
|
-
properties: {
|
|
113
|
-
sessionId: {
|
|
114
|
-
type: "string"
|
|
115
|
-
},
|
|
116
|
-
stateId: {
|
|
117
|
-
type: "string"
|
|
118
|
-
},
|
|
119
|
-
redirectUrl: {
|
|
120
|
-
type: "string"
|
|
121
|
-
},
|
|
122
|
-
additionalProperties: false
|
|
123
|
-
},
|
|
124
|
-
required: ["sessionId", "stateId", "redirectUrl"],
|
|
125
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
126
|
-
},
|
|
127
|
-
ParsedAuthenticationRequestURI: {
|
|
128
|
-
type: "object",
|
|
129
|
-
properties: {
|
|
130
|
-
jwt: {
|
|
131
|
-
type: "string"
|
|
132
|
-
},
|
|
133
|
-
requestPayload: {
|
|
105
|
+
IResponse: {
|
|
134
106
|
type: "object",
|
|
135
107
|
properties: {
|
|
108
|
+
status: {
|
|
109
|
+
type: "number"
|
|
110
|
+
},
|
|
136
111
|
additionalProperties: true
|
|
137
|
-
}
|
|
112
|
+
},
|
|
113
|
+
required: ["status"],
|
|
114
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.authenticateWithSiop & DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
138
115
|
},
|
|
139
|
-
|
|
116
|
+
IGetSiopAuthenticationRequestFromRpArgs: {
|
|
140
117
|
type: "object",
|
|
141
118
|
properties: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
119
|
+
sessionId: {
|
|
120
|
+
type: "string"
|
|
121
|
+
},
|
|
122
|
+
stateId: {
|
|
123
|
+
type: "string"
|
|
124
|
+
},
|
|
125
|
+
redirectUrl: {
|
|
126
|
+
type: "string"
|
|
127
|
+
},
|
|
128
|
+
additionalProperties: false
|
|
129
|
+
},
|
|
130
|
+
required: ["sessionId", "stateId", "redirectUrl"],
|
|
131
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
155
132
|
},
|
|
156
|
-
|
|
133
|
+
ParsedAuthenticationRequestURI: {
|
|
157
134
|
type: "object",
|
|
158
135
|
properties: {
|
|
159
|
-
|
|
160
|
-
|
|
136
|
+
jwt: {
|
|
137
|
+
type: "string"
|
|
138
|
+
},
|
|
139
|
+
requestPayload: {
|
|
140
|
+
type: "object",
|
|
141
|
+
properties: {
|
|
142
|
+
additionalProperties: true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
registration: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
additionalProperties: true
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
additionalProperties: false
|
|
152
|
+
},
|
|
153
|
+
required: ["jwt", "requestPayload", "registration"],
|
|
154
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
|
|
161
155
|
},
|
|
162
|
-
|
|
156
|
+
IGetSiopAuthenticationRequestDetailsArgs: {
|
|
163
157
|
type: "object",
|
|
164
158
|
properties: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
159
|
+
sessionId: {
|
|
160
|
+
type: "string"
|
|
161
|
+
},
|
|
162
|
+
verifiedAuthenticationRequest: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
additionalProperties: true
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
credentialFilter: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
additionalProperties: true
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
additionalProperties: false
|
|
175
|
+
},
|
|
176
|
+
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
177
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
184
178
|
},
|
|
185
|
-
|
|
179
|
+
IAuthRequestDetails: {
|
|
186
180
|
type: "object",
|
|
187
181
|
properties: {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
182
|
+
id: {
|
|
183
|
+
type: "string"
|
|
184
|
+
},
|
|
185
|
+
alsoKnownAs: {
|
|
186
|
+
type: "array",
|
|
187
|
+
items: {
|
|
188
|
+
type: "string"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
vpResponseOpts: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
additionalProperties: true
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
additionalProperties: false
|
|
198
|
+
},
|
|
199
|
+
required: ["id", "vpResponseOpts"],
|
|
200
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
|
|
201
201
|
},
|
|
202
|
-
|
|
202
|
+
IVerifySiopAuthenticationRequestUriArgs: {
|
|
203
203
|
type: "object",
|
|
204
204
|
properties: {
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
sessionId: {
|
|
206
|
+
type: "string"
|
|
207
|
+
},
|
|
208
|
+
ParsedAuthenticationRequestURI: {
|
|
209
|
+
type: "object",
|
|
210
|
+
properties: {
|
|
211
|
+
additionalProperties: true
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
additionalProperties: false
|
|
215
|
+
},
|
|
216
|
+
required: ["sessionId", "ParsedAuthenticationRequestURI"],
|
|
217
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
207
218
|
},
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
required: ["sessionId", "ParsedAuthenticationRequestURI"],
|
|
211
|
-
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
212
|
-
},
|
|
213
|
-
VerifiedAuthorizationRequest: {
|
|
214
|
-
type: "object",
|
|
215
|
-
properties: {
|
|
216
|
-
payload: {
|
|
219
|
+
VerifiedAuthorizationRequest: {
|
|
217
220
|
type: "object",
|
|
218
221
|
properties: {
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
payload: {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {
|
|
225
|
+
additionalProperties: true
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
presentationDefinitions: {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
additionalProperties: true
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
verifyOpts: {
|
|
235
|
+
type: "object",
|
|
236
|
+
properties: {
|
|
237
|
+
additionalProperties: true
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
additionalProperties: false
|
|
241
|
+
},
|
|
242
|
+
required: ["payload", "verifyOpts"],
|
|
243
|
+
description: "Result of {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
|
|
221
244
|
},
|
|
222
|
-
|
|
245
|
+
ISendSiopAuthenticationResponseArgs: {
|
|
223
246
|
type: "object",
|
|
224
247
|
properties: {
|
|
225
|
-
|
|
226
|
-
|
|
248
|
+
sessionId: {
|
|
249
|
+
type: "string"
|
|
250
|
+
},
|
|
251
|
+
verifiedAuthenticationRequest: {
|
|
252
|
+
type: "object",
|
|
253
|
+
properties: {
|
|
254
|
+
additionalProperties: true
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
verifiablePresentationResponse: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {
|
|
260
|
+
additionalProperties: true
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
additionalProperties: false
|
|
264
|
+
},
|
|
265
|
+
required: ["sessionId", "verifiedAuthenticationRequest"],
|
|
266
|
+
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
methods: {
|
|
270
|
+
getSessionForSiop: {
|
|
271
|
+
description: "Get SIOP session",
|
|
272
|
+
arguments: {
|
|
273
|
+
$ref: "#/components/schemas/IGetSiopSessionArgs"
|
|
274
|
+
},
|
|
275
|
+
returnType: "object"
|
|
227
276
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
277
|
+
registerSessionForSiop: {
|
|
278
|
+
description: "Register SIOP session",
|
|
279
|
+
arguments: {
|
|
280
|
+
$ref: "#/components/schemas/IRegisterSiopSessionArgs"
|
|
281
|
+
},
|
|
282
|
+
returnType: "object"
|
|
283
|
+
},
|
|
284
|
+
removeSessionForSiop: {
|
|
285
|
+
description: "Remove SIOP session",
|
|
286
|
+
arguments: {
|
|
287
|
+
$ref: "#/components/schemas/IRemoveSiopSessionArgs"
|
|
288
|
+
},
|
|
289
|
+
returnType: "boolean"
|
|
290
|
+
},
|
|
291
|
+
authenticateWithSiop: {
|
|
292
|
+
description: "Authenticate using DID Auth SIOP",
|
|
293
|
+
arguments: {
|
|
294
|
+
$ref: "#/components/schemas/IAuthenticateWithSiopArgs"
|
|
295
|
+
},
|
|
296
|
+
returnType: {
|
|
297
|
+
$ref: "#/components/schemas/Response"
|
|
232
298
|
}
|
|
233
299
|
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
sessionId: {
|
|
243
|
-
type: "string"
|
|
300
|
+
getSiopAuthenticationRequestFromRP: {
|
|
301
|
+
description: "Get authentication request from RP",
|
|
302
|
+
arguments: {
|
|
303
|
+
$ref: "#/components/schemas/IGetSiopAuthenticationRequestFromRpArgs"
|
|
304
|
+
},
|
|
305
|
+
returnType: {
|
|
306
|
+
$ref: "#/components/schemas/ParsedAuthenticationRequestURI"
|
|
307
|
+
}
|
|
244
308
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
309
|
+
getSiopAuthenticationRequestDetails: {
|
|
310
|
+
description: "Get authentication request details",
|
|
311
|
+
arguments: {
|
|
312
|
+
$ref: "#/components/schemas/IGetSiopAuthenticationRequestDetailsArgs"
|
|
313
|
+
},
|
|
314
|
+
returnType: {
|
|
315
|
+
$ref: "#/components/schemas/IAuthRequestDetails"
|
|
249
316
|
}
|
|
250
317
|
},
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
318
|
+
verifySiopAuthenticationRequestURI: {
|
|
319
|
+
description: "Verify authentication request URI",
|
|
320
|
+
arguments: {
|
|
321
|
+
$ref: "#/components/schemas/IVerifySiopAuthenticationRequestUriArgs"
|
|
322
|
+
},
|
|
323
|
+
returnType: {
|
|
324
|
+
$ref: "#/components/schemas/VerifiedAuthorizationRequest"
|
|
255
325
|
}
|
|
256
326
|
},
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
arguments: {
|
|
267
|
-
$ref: "#/components/schemas/IGetSiopSessionArgs"
|
|
268
|
-
},
|
|
269
|
-
returnType: "object"
|
|
270
|
-
},
|
|
271
|
-
registerSessionForSiop: {
|
|
272
|
-
description: "Register SIOP session",
|
|
273
|
-
arguments: {
|
|
274
|
-
$ref: "#/components/schemas/IRegisterSiopSessionArgs"
|
|
275
|
-
},
|
|
276
|
-
returnType: "object"
|
|
277
|
-
},
|
|
278
|
-
removeSessionForSiop: {
|
|
279
|
-
description: "Remove SIOP session",
|
|
280
|
-
arguments: {
|
|
281
|
-
$ref: "#/components/schemas/IRemoveSiopSessionArgs"
|
|
282
|
-
},
|
|
283
|
-
returnType: "boolean"
|
|
284
|
-
},
|
|
285
|
-
authenticateWithSiop: {
|
|
286
|
-
description: "Authenticate using DID Auth SIOP",
|
|
287
|
-
arguments: {
|
|
288
|
-
$ref: "#/components/schemas/IAuthenticateWithSiopArgs"
|
|
289
|
-
},
|
|
290
|
-
returnType: {
|
|
291
|
-
$ref: "#/components/schemas/Response"
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
getSiopAuthenticationRequestFromRP: {
|
|
295
|
-
description: "Get authentication request from RP",
|
|
296
|
-
arguments: {
|
|
297
|
-
$ref: "#/components/schemas/IGetSiopAuthenticationRequestFromRpArgs"
|
|
298
|
-
},
|
|
299
|
-
returnType: {
|
|
300
|
-
$ref: "#/components/schemas/ParsedAuthenticationRequestURI"
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
getSiopAuthenticationRequestDetails: {
|
|
304
|
-
description: "Get authentication request details",
|
|
305
|
-
arguments: {
|
|
306
|
-
$ref: "#/components/schemas/IGetSiopAuthenticationRequestDetailsArgs"
|
|
307
|
-
},
|
|
308
|
-
returnType: {
|
|
309
|
-
$ref: "#/components/schemas/IAuthRequestDetails"
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
verifySiopAuthenticationRequestURI: {
|
|
313
|
-
description: "Verify authentication request URI",
|
|
314
|
-
arguments: {
|
|
315
|
-
$ref: "#/components/schemas/IVerifySiopAuthenticationRequestUriArgs"
|
|
316
|
-
},
|
|
317
|
-
returnType: {
|
|
318
|
-
$ref: "#/components/schemas/VerifiedAuthorizationRequest"
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
sendSiopAuthenticationResponse: {
|
|
322
|
-
description: "Send authentication response",
|
|
323
|
-
arguments: {
|
|
324
|
-
$ref: "#/components/schemas/ISendSiopAuthenticationResponseArgs"
|
|
325
|
-
},
|
|
326
|
-
returnType: {
|
|
327
|
-
$ref: "#/components/schemas/IRequiredContext"
|
|
327
|
+
sendSiopAuthenticationResponse: {
|
|
328
|
+
description: "Send authentication response",
|
|
329
|
+
arguments: {
|
|
330
|
+
$ref: "#/components/schemas/ISendSiopAuthenticationResponseArgs"
|
|
331
|
+
},
|
|
332
|
+
returnType: {
|
|
333
|
+
$ref: "#/components/schemas/IRequiredContext"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
328
336
|
}
|
|
329
337
|
}
|
|
330
338
|
}
|
|
331
|
-
}
|
|
339
|
+
};
|
|
332
340
|
}
|
|
333
|
-
};
|
|
341
|
+
});
|
|
334
342
|
|
|
335
343
|
// src/agent/SIOPv2RP.ts
|
|
336
344
|
import { AuthorizationResponseStateStatus, decodeUriAsJson } from "@sphereon/did-auth-siop";
|
|
337
345
|
import { getAgentResolver as getAgentResolver2 } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
338
|
-
import { shaHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
339
|
-
import { validate as isValidUUID2 } from "uuid";
|
|
340
346
|
import { CredentialMapper as CredentialMapper2 } from "@sphereon/ssi-types";
|
|
341
|
-
import { DcqlQuery } from "dcql";
|
|
342
347
|
|
|
343
348
|
// src/functions.ts
|
|
344
|
-
import {
|
|
349
|
+
import { InMemoryRPSessionManager, PassBy, PropertyTarget, ResponseMode, ResponseType, RevocationVerification, RP, Scope, SubjectType, SupportedVersion } from "@sphereon/did-auth-siop";
|
|
345
350
|
import { SigningAlgo } from "@sphereon/oid4vc-common";
|
|
346
351
|
import { getAgentDIDMethods, getAgentResolver } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
347
352
|
import { isExternalIdentifierOIDFEntityIdOpts, isManagedIdentifierDidOpts, isManagedIdentifierDidResult, isManagedIdentifierX5cOpts } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
348
353
|
import { CredentialMapper } from "@sphereon/ssi-types";
|
|
349
354
|
import { EventEmitter } from "events";
|
|
350
|
-
import { validate as isValidUUID } from "uuid";
|
|
351
355
|
import { defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
352
356
|
function getRequestVersion(rpOptions) {
|
|
353
357
|
if (Array.isArray(rpOptions.supportedVersions) && rpOptions.supportedVersions.length > 0) {
|
|
354
358
|
return rpOptions.supportedVersions[0];
|
|
355
359
|
}
|
|
356
|
-
return SupportedVersion.
|
|
360
|
+
return SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1;
|
|
357
361
|
}
|
|
358
362
|
__name(getRequestVersion, "getRequestVersion");
|
|
359
363
|
function getWellKnownDIDVerifyCallback(siopIdentifierOpts, context) {
|
|
@@ -368,40 +372,12 @@ function getWellKnownDIDVerifyCallback(siopIdentifierOpts, context) {
|
|
|
368
372
|
};
|
|
369
373
|
}
|
|
370
374
|
__name(getWellKnownDIDVerifyCallback, "getWellKnownDIDVerifyCallback");
|
|
371
|
-
function getDcqlQueryLookupCallback(context) {
|
|
372
|
-
async function dcqlQueryLookup(queryId, version, tenantId) {
|
|
373
|
-
const result = await context.agent.pdmGetDefinitions({
|
|
374
|
-
filter: [
|
|
375
|
-
{
|
|
376
|
-
queryId,
|
|
377
|
-
...tenantId && {
|
|
378
|
-
tenantId
|
|
379
|
-
},
|
|
380
|
-
...version && {
|
|
381
|
-
version
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
...isValidUUID(queryId) ? [
|
|
385
|
-
{
|
|
386
|
-
id: queryId
|
|
387
|
-
}
|
|
388
|
-
] : []
|
|
389
|
-
]
|
|
390
|
-
});
|
|
391
|
-
if (result && result.length > 0) {
|
|
392
|
-
return result[0].query;
|
|
393
|
-
}
|
|
394
|
-
return Promise.reject(Error(`No dcql query found for queryId ${queryId}`));
|
|
395
|
-
}
|
|
396
|
-
__name(dcqlQueryLookup, "dcqlQueryLookup");
|
|
397
|
-
return dcqlQueryLookup;
|
|
398
|
-
}
|
|
399
|
-
__name(getDcqlQueryLookupCallback, "getDcqlQueryLookupCallback");
|
|
400
375
|
function getPresentationVerificationCallback(idOpts, context) {
|
|
401
376
|
async function presentationVerificationCallback(args, presentationSubmission) {
|
|
402
377
|
if (CredentialMapper.isSdJwtEncoded(args)) {
|
|
403
378
|
const result2 = await context.agent.verifySdJwtPresentation({
|
|
404
|
-
presentation: args
|
|
379
|
+
presentation: args,
|
|
380
|
+
kb: true
|
|
405
381
|
});
|
|
406
382
|
return {
|
|
407
383
|
verified: !!result2.payload
|
|
@@ -436,8 +412,28 @@ function getPresentationVerificationCallback(idOpts, context) {
|
|
|
436
412
|
}
|
|
437
413
|
__name(getPresentationVerificationCallback, "getPresentationVerificationCallback");
|
|
438
414
|
async function createRPBuilder(args) {
|
|
439
|
-
const { rpOpts, context } = args;
|
|
415
|
+
const { rpOpts, pexOpts, context } = args;
|
|
440
416
|
const { identifierOpts } = rpOpts;
|
|
417
|
+
let definition = args.definition;
|
|
418
|
+
let dcqlQuery = args.dcql;
|
|
419
|
+
if (!definition && pexOpts && pexOpts.definitionId) {
|
|
420
|
+
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
421
|
+
filter: [
|
|
422
|
+
{
|
|
423
|
+
definitionId: pexOpts.definitionId,
|
|
424
|
+
version: pexOpts.version,
|
|
425
|
+
tenantId: pexOpts.tenantId
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
});
|
|
429
|
+
if (presentationDefinitionItems.length > 0) {
|
|
430
|
+
const presentationDefinitionItem = presentationDefinitionItems[0];
|
|
431
|
+
definition = presentationDefinitionItem.definitionPayload;
|
|
432
|
+
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
433
|
+
dcqlQuery = presentationDefinitionItem.dcqlPayload;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
441
437
|
const didMethods = identifierOpts.supportedDIDMethods ?? await getAgentDIDMethods(context);
|
|
442
438
|
const eventEmitter = rpOpts.eventEmitter ?? new EventEmitter();
|
|
443
439
|
const defaultClientMetadata = {
|
|
@@ -492,27 +488,34 @@ async function createRPBuilder(args) {
|
|
|
492
488
|
const builder = RP.builder({
|
|
493
489
|
requestVersion: getRequestVersion(rpOpts)
|
|
494
490
|
}).withScope("openid", PropertyTarget.REQUEST_OBJECT).withResponseMode(rpOpts.responseMode ?? ResponseMode.POST).withResponseType(ResponseType.VP_TOKEN, PropertyTarget.REQUEST_OBJECT).withSupportedVersions(rpOpts.supportedVersions ?? [
|
|
495
|
-
SupportedVersion.
|
|
496
|
-
SupportedVersion.
|
|
491
|
+
SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1,
|
|
492
|
+
SupportedVersion.SIOPv2_ID1,
|
|
493
|
+
SupportedVersion.SIOPv2_D11
|
|
497
494
|
]).withEventEmitter(eventEmitter).withSessionManager(rpOpts.sessionManager ?? new InMemoryRPSessionManager(eventEmitter)).withClientMetadata(rpOpts.clientMetadataOpts ?? defaultClientMetadata, PropertyTarget.REQUEST_OBJECT).withVerifyJwtCallback(rpOpts.verifyJwtCallback ? rpOpts.verifyJwtCallback : getVerifyJwtCallback({
|
|
498
495
|
resolver,
|
|
499
496
|
verifyOpts: {
|
|
500
497
|
wellknownDIDVerifyCallback: getWellKnownDIDVerifyCallback(rpOpts.identifierOpts, context),
|
|
501
498
|
checkLinkedDomain: "if_present"
|
|
502
499
|
}
|
|
503
|
-
}, context)).
|
|
500
|
+
}, context)).withRevocationVerification(RevocationVerification.NEVER).withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
|
|
504
501
|
const oidfOpts = identifierOpts.oidfOpts;
|
|
505
502
|
if (oidfOpts && isExternalIdentifierOIDFEntityIdOpts(oidfOpts)) {
|
|
506
|
-
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT);
|
|
503
|
+
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT).withClientIdScheme("entity_id", PropertyTarget.REQUEST_OBJECT);
|
|
507
504
|
} else {
|
|
508
505
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts);
|
|
509
|
-
|
|
510
|
-
const clientIdPrefixed = prefixClientId(clientId);
|
|
511
|
-
builder.withClientId(clientIdPrefixed, PropertyTarget.REQUEST_OBJECT);
|
|
506
|
+
builder.withClientId(resolution.issuer ?? (isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint), PropertyTarget.REQUEST_OBJECT).withClientIdScheme(resolution.clientIdScheme ?? identifierOpts.idOpts.clientIdScheme, PropertyTarget.REQUEST_OBJECT);
|
|
512
507
|
}
|
|
513
508
|
if (hasher) {
|
|
514
509
|
builder.withHasher(hasher);
|
|
515
510
|
}
|
|
511
|
+
if (definition) {
|
|
512
|
+
builder.withPresentationDefinition({
|
|
513
|
+
definition
|
|
514
|
+
}, PropertyTarget.REQUEST_OBJECT);
|
|
515
|
+
}
|
|
516
|
+
if (dcqlQuery) {
|
|
517
|
+
builder.withDcqlQuery(dcqlQuery);
|
|
518
|
+
}
|
|
516
519
|
if (rpOpts.responseRedirectUri) {
|
|
517
520
|
builder.withResponseRedirectUri(rpOpts.responseRedirectUri);
|
|
518
521
|
}
|
|
@@ -569,13 +572,6 @@ function getSigningAlgo(type) {
|
|
|
569
572
|
}
|
|
570
573
|
}
|
|
571
574
|
__name(getSigningAlgo, "getSigningAlgo");
|
|
572
|
-
function prefixClientId(clientId) {
|
|
573
|
-
if (clientId.startsWith("did:")) {
|
|
574
|
-
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`;
|
|
575
|
-
}
|
|
576
|
-
return clientId;
|
|
577
|
-
}
|
|
578
|
-
__name(prefixClientId, "prefixClientId");
|
|
579
575
|
|
|
580
576
|
// src/RPInstance.ts
|
|
581
577
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -585,16 +581,17 @@ var RPInstance = class {
|
|
|
585
581
|
__name(this, "RPInstance");
|
|
586
582
|
}
|
|
587
583
|
_rp;
|
|
588
|
-
|
|
584
|
+
_pexOptions;
|
|
589
585
|
_rpOptions;
|
|
590
586
|
constructor({ rpOpts, pexOpts }) {
|
|
591
587
|
this._rpOptions = rpOpts;
|
|
592
|
-
this.
|
|
588
|
+
this._pexOptions = pexOpts;
|
|
593
589
|
}
|
|
594
590
|
async get(context) {
|
|
595
591
|
if (!this._rp) {
|
|
596
592
|
const builder = await createRPBuilder({
|
|
597
593
|
rpOpts: this._rpOptions,
|
|
594
|
+
pexOpts: this._pexOptions,
|
|
598
595
|
context
|
|
599
596
|
});
|
|
600
597
|
this._rp = builder.build();
|
|
@@ -604,11 +601,23 @@ var RPInstance = class {
|
|
|
604
601
|
get rpOptions() {
|
|
605
602
|
return this._rpOptions;
|
|
606
603
|
}
|
|
607
|
-
get
|
|
608
|
-
return this.
|
|
604
|
+
get pexOptions() {
|
|
605
|
+
return this._pexOptions;
|
|
606
|
+
}
|
|
607
|
+
hasDefinition() {
|
|
608
|
+
return this.definitionId !== void 0;
|
|
609
|
+
}
|
|
610
|
+
get definitionId() {
|
|
611
|
+
return this.pexOptions?.definitionId;
|
|
612
|
+
}
|
|
613
|
+
async getPresentationDefinition(context) {
|
|
614
|
+
return this.definitionId ? await context.agent.pexStoreGetDefinition({
|
|
615
|
+
definitionId: this.definitionId,
|
|
616
|
+
tenantId: this.pexOptions?.tenantId
|
|
617
|
+
}) : void 0;
|
|
609
618
|
}
|
|
610
619
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
611
|
-
const { correlationId,
|
|
620
|
+
const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
|
|
612
621
|
const nonce = createArgs.nonce ?? uuidv4();
|
|
613
622
|
const state = createArgs.state ?? correlationId;
|
|
614
623
|
let jwtIssuer;
|
|
@@ -636,20 +645,17 @@ var RPInstance = class {
|
|
|
636
645
|
return await this.get(context).then((rp) => rp.createAuthorizationRequestURI({
|
|
637
646
|
version: getRequestVersion(this.rpOptions),
|
|
638
647
|
correlationId,
|
|
639
|
-
queryId,
|
|
640
648
|
nonce,
|
|
641
649
|
state,
|
|
642
650
|
claims,
|
|
643
651
|
requestByReferenceURI,
|
|
644
652
|
responseURI,
|
|
645
653
|
responseURIType,
|
|
646
|
-
jwtIssuer
|
|
647
|
-
callback,
|
|
648
|
-
responseRedirectURI
|
|
654
|
+
jwtIssuer
|
|
649
655
|
}));
|
|
650
656
|
}
|
|
651
657
|
async createAuthorizationRequest(createArgs, context) {
|
|
652
|
-
const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType
|
|
658
|
+
const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
|
|
653
659
|
const nonce = createArgs.nonce ?? uuidv4();
|
|
654
660
|
const state = createArgs.state ?? correlationId;
|
|
655
661
|
const idOpts = this.rpOptions.identifierOpts.idOpts;
|
|
@@ -680,13 +686,13 @@ var RPInstance = class {
|
|
|
680
686
|
requestByReferenceURI,
|
|
681
687
|
responseURIType,
|
|
682
688
|
responseURI,
|
|
683
|
-
jwtIssuer
|
|
684
|
-
responseRedirectURI
|
|
689
|
+
jwtIssuer
|
|
685
690
|
}));
|
|
686
691
|
}
|
|
687
692
|
};
|
|
688
693
|
|
|
689
694
|
// src/agent/SIOPv2RP.ts
|
|
695
|
+
import { shaHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
690
696
|
var SIOPv2RP = class _SIOPv2RP {
|
|
691
697
|
static {
|
|
692
698
|
__name(this, "SIOPv2RP");
|
|
@@ -694,7 +700,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
694
700
|
opts;
|
|
695
701
|
static _DEFAULT_OPTS_KEY = "_default";
|
|
696
702
|
instances = /* @__PURE__ */ new Map();
|
|
697
|
-
schema =
|
|
703
|
+
schema = schema.IDidAuthSiopOpAuthenticator;
|
|
698
704
|
methods = {
|
|
699
705
|
siopCreateAuthRequestURI: this.createAuthorizationRequestURI.bind(this),
|
|
700
706
|
siopCreateAuthRequestPayloads: this.createAuthorizationRequestPayloads.bind(this),
|
|
@@ -724,72 +730,53 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
724
730
|
}
|
|
725
731
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
726
732
|
return await this.getRPInstance({
|
|
727
|
-
|
|
728
|
-
responseRedirectURI: createArgs.responseRedirectURI
|
|
729
|
-
...createArgs.useQueryIdInstance === true && {
|
|
730
|
-
queryId: createArgs.queryId
|
|
731
|
-
}
|
|
733
|
+
definitionId: createArgs.definitionId,
|
|
734
|
+
responseRedirectURI: createArgs.responseRedirectURI
|
|
732
735
|
}, context).then((rp) => rp.createAuthorizationRequestURI(createArgs, context)).then((URI) => URI.encodedUri);
|
|
733
736
|
}
|
|
734
737
|
async createAuthorizationRequestPayloads(createArgs, context) {
|
|
735
738
|
return await this.getRPInstance({
|
|
736
|
-
|
|
737
|
-
queryId: createArgs.queryId
|
|
739
|
+
definitionId: createArgs.definitionId
|
|
738
740
|
}, context).then((rp) => rp.createAuthorizationRequest(createArgs, context)).then(async (request) => {
|
|
739
741
|
const authRequest = {
|
|
740
742
|
authorizationRequest: request.payload,
|
|
741
743
|
requestObject: await request.requestObjectJwt(),
|
|
742
|
-
requestObjectDecoded: request.requestObject?.getPayload()
|
|
744
|
+
requestObjectDecoded: await request.requestObject?.getPayload()
|
|
743
745
|
};
|
|
744
746
|
return authRequest;
|
|
745
747
|
});
|
|
746
748
|
}
|
|
747
749
|
async siopGetRequestState(args, context) {
|
|
748
750
|
return await this.getRPInstance({
|
|
749
|
-
|
|
750
|
-
queryId: args.queryId
|
|
751
|
+
definitionId: args.definitionId
|
|
751
752
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)));
|
|
752
753
|
}
|
|
753
754
|
async siopGetResponseState(args, context) {
|
|
754
755
|
const rpInstance = await this.getRPInstance({
|
|
755
|
-
|
|
756
|
-
queryId: args.queryId
|
|
756
|
+
definitionId: args.definitionId
|
|
757
757
|
}, context);
|
|
758
758
|
const authorizationResponseState = await rpInstance.get(context).then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound));
|
|
759
759
|
if (authorizationResponseState === void 0) {
|
|
760
760
|
return void 0;
|
|
761
761
|
}
|
|
762
762
|
const responseState = authorizationResponseState;
|
|
763
|
-
if (responseState.status === AuthorizationResponseStateStatus.VERIFIED) {
|
|
763
|
+
if (responseState.status === AuthorizationResponseStateStatus.VERIFIED && args.includeVerifiedData && args.includeVerifiedData !== VerifiedDataMode.NONE) {
|
|
764
764
|
let hasher;
|
|
765
765
|
if (CredentialMapper2.isSdJwtEncoded(responseState.response.payload.vp_token) && (!rpInstance.rpOptions.credentialOpts?.hasher || typeof rpInstance.rpOptions.credentialOpts?.hasher !== "function")) {
|
|
766
766
|
hasher = defaultHasher2;
|
|
767
767
|
}
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
} else {
|
|
781
|
-
singleVP = presentationValue;
|
|
782
|
-
}
|
|
783
|
-
const presentationDecoded = CredentialMapper2.decodeVerifiablePresentation(
|
|
784
|
-
singleVP,
|
|
785
|
-
//todo: later we want to conditionally pass in options for mdl-mdoc here
|
|
786
|
-
hasher
|
|
787
|
-
);
|
|
788
|
-
console.log(`presentationDecoded: ${JSON.stringify(presentationDecoded)}`);
|
|
789
|
-
const allClaims = {};
|
|
790
|
-
const presentationOrClaims = this.presentationOrClaimsFrom(presentationDecoded);
|
|
791
|
-
if ("verifiableCredential" in presentationOrClaims) {
|
|
792
|
-
for (const credential of presentationOrClaims.verifiableCredential) {
|
|
768
|
+
const presentationDecoded = CredentialMapper2.decodeVerifiablePresentation(
|
|
769
|
+
responseState.response.payload.vp_token,
|
|
770
|
+
//todo: later we want to conditionally pass in options for mdl-mdoc here
|
|
771
|
+
hasher
|
|
772
|
+
);
|
|
773
|
+
switch (args.includeVerifiedData) {
|
|
774
|
+
case VerifiedDataMode.VERIFIED_PRESENTATION:
|
|
775
|
+
responseState.response.payload.verifiedData = this.presentationOrClaimsFrom(presentationDecoded);
|
|
776
|
+
break;
|
|
777
|
+
case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED:
|
|
778
|
+
const allClaims = {};
|
|
779
|
+
for (const credential of this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []) {
|
|
793
780
|
const vc = credential;
|
|
794
781
|
const schemaValidationResult = await context.agent.cvVerifySchema({
|
|
795
782
|
credential,
|
|
@@ -810,43 +797,20 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
810
797
|
allClaims[key] = value;
|
|
811
798
|
}
|
|
812
799
|
});
|
|
813
|
-
claims.push({
|
|
814
|
-
id: credentialQueryId,
|
|
815
|
-
type: vc.type[0],
|
|
816
|
-
claims: allClaims
|
|
817
|
-
});
|
|
818
800
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
id: credentialQueryId,
|
|
822
|
-
type: presentationDecoded.decodedPayload.vct,
|
|
823
|
-
claims: presentationOrClaims
|
|
824
|
-
});
|
|
825
|
-
}
|
|
801
|
+
responseState.verifiedData = allClaims;
|
|
802
|
+
break;
|
|
826
803
|
}
|
|
827
|
-
responseState.verifiedData = {
|
|
828
|
-
...responseState.response.payload.vp_token && {
|
|
829
|
-
authorization_response: {
|
|
830
|
-
vp_token: typeof responseState.response.payload.vp_token === "string" ? JSON.parse(responseState.response.payload.vp_token) : responseState.response.payload.vp_token
|
|
831
|
-
}
|
|
832
|
-
},
|
|
833
|
-
...claims.length > 0 && {
|
|
834
|
-
credential_claims: claims
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
804
|
}
|
|
838
805
|
return responseState;
|
|
839
806
|
}
|
|
840
|
-
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) =>
|
|
841
|
-
return CredentialMapper2.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : CredentialMapper2.toUniformPresentation(presentationDecoded);
|
|
842
|
-
}, "presentationOrClaimsFrom");
|
|
807
|
+
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => CredentialMapper2.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : CredentialMapper2.toUniformPresentation(presentationDecoded), "presentationOrClaimsFrom");
|
|
843
808
|
async siopUpdateRequestState(args, context) {
|
|
844
|
-
if (args.state !== "
|
|
845
|
-
throw Error(`Only '
|
|
809
|
+
if (args.state !== "sent") {
|
|
810
|
+
throw Error(`Only 'sent' status is supported for this method at this point`);
|
|
846
811
|
}
|
|
847
812
|
return await this.getRPInstance({
|
|
848
|
-
|
|
849
|
-
queryId: args.queryId
|
|
813
|
+
definitionId: args.definitionId
|
|
850
814
|
}, context).then((rp) => rp.get(context).then(async (rp2) => {
|
|
851
815
|
await rp2.signalAuthRequestRetrieved({
|
|
852
816
|
correlationId: args.correlationId,
|
|
@@ -857,8 +821,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
857
821
|
}
|
|
858
822
|
async siopDeleteState(args, context) {
|
|
859
823
|
return await this.getRPInstance({
|
|
860
|
-
|
|
861
|
-
queryId: args.queryId
|
|
824
|
+
definitionId: args.definitionId
|
|
862
825
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.deleteStateForCorrelationId(args.correlationId))).then(() => true);
|
|
863
826
|
}
|
|
864
827
|
async siopVerifyAuthResponse(args, context) {
|
|
@@ -867,27 +830,32 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
867
830
|
}
|
|
868
831
|
const authResponse = typeof args.authorizationResponse === "string" ? decodeUriAsJson(args.authorizationResponse) : args.authorizationResponse;
|
|
869
832
|
return await this.getRPInstance({
|
|
870
|
-
|
|
871
|
-
queryId: args.queryId
|
|
833
|
+
definitionId: args.definitionId
|
|
872
834
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
873
835
|
correlationId: args.correlationId,
|
|
874
|
-
...args.
|
|
836
|
+
...args.presentationDefinitions && !args.dcqlQuery ? {
|
|
837
|
+
presentationDefinitions: args.presentationDefinitions
|
|
838
|
+
} : {},
|
|
839
|
+
...args.dcqlQuery ? {
|
|
875
840
|
dcqlQuery: args.dcqlQuery
|
|
876
|
-
},
|
|
841
|
+
} : {},
|
|
877
842
|
audience: args.audience
|
|
878
843
|
})));
|
|
879
844
|
}
|
|
880
845
|
async siopImportDefinitions(args, context) {
|
|
881
|
-
const {
|
|
882
|
-
await Promise.all(
|
|
883
|
-
|
|
884
|
-
|
|
846
|
+
const { definitions, tenantId, version, versionControlMode } = args;
|
|
847
|
+
await Promise.all(definitions.map(async (definitionPair) => {
|
|
848
|
+
const definitionPayload = definitionPair.definitionPayload;
|
|
849
|
+
await context.agent.pexValidateDefinition({
|
|
850
|
+
definition: definitionPayload
|
|
851
|
+
});
|
|
852
|
+
console.log(`persisting definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
885
853
|
return context.agent.pdmPersistDefinition({
|
|
886
854
|
definitionItem: {
|
|
887
|
-
queryId: importItem.queryId,
|
|
888
855
|
tenantId,
|
|
889
856
|
version,
|
|
890
|
-
|
|
857
|
+
definitionPayload,
|
|
858
|
+
dcqlPayload: definitionPair.dcqlPayload
|
|
891
859
|
},
|
|
892
860
|
opts: {
|
|
893
861
|
versionControlMode
|
|
@@ -896,12 +864,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
896
864
|
}));
|
|
897
865
|
}
|
|
898
866
|
async siopGetRedirectURI(args, context) {
|
|
899
|
-
const instanceId = args.
|
|
867
|
+
const instanceId = args.definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
900
868
|
if (this.instances.has(instanceId)) {
|
|
901
869
|
const rpInstance = this.instances.get(instanceId);
|
|
902
870
|
if (rpInstance !== void 0) {
|
|
903
871
|
const rp = await rpInstance.get(context);
|
|
904
|
-
return
|
|
872
|
+
return rp.getResponseRedirectUri({
|
|
905
873
|
correlation_id: args.correlationId,
|
|
906
874
|
correlationId: args.correlationId,
|
|
907
875
|
...args.state && {
|
|
@@ -912,40 +880,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
912
880
|
}
|
|
913
881
|
return void 0;
|
|
914
882
|
}
|
|
915
|
-
async getRPInstance({
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
if (this.instances.has(queryId)) {
|
|
920
|
-
rpInstanceId = queryId;
|
|
921
|
-
rpInstance = this.instances.get(rpInstanceId);
|
|
922
|
-
} else if (isValidUUID2(queryId)) {
|
|
923
|
-
try {
|
|
924
|
-
const pd = await context.agent.pdmGetDefinition({
|
|
925
|
-
itemId: queryId
|
|
926
|
-
});
|
|
927
|
-
if (this.instances.has(pd.queryId)) {
|
|
928
|
-
rpInstanceId = pd.queryId;
|
|
929
|
-
rpInstance = this.instances.get(rpInstanceId);
|
|
930
|
-
}
|
|
931
|
-
} catch (ignore) {
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
if (createWhenNotPresent) {
|
|
935
|
-
rpInstanceId = queryId;
|
|
936
|
-
} else {
|
|
937
|
-
rpInstance = this.instances.get(rpInstanceId);
|
|
938
|
-
}
|
|
939
|
-
} else {
|
|
940
|
-
rpInstance = this.instances.get(rpInstanceId);
|
|
941
|
-
}
|
|
942
|
-
if (!rpInstance) {
|
|
943
|
-
if (!createWhenNotPresent) {
|
|
944
|
-
return Promise.reject(`No RP instance found for key ${rpInstanceId}`);
|
|
945
|
-
}
|
|
946
|
-
const instanceOpts = this.getInstanceOpts(queryId);
|
|
883
|
+
async getRPInstance({ definitionId, responseRedirectURI }, context) {
|
|
884
|
+
const instanceId = definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
885
|
+
if (!this.instances.has(instanceId)) {
|
|
886
|
+
const instanceOpts = this.getInstanceOpts(definitionId);
|
|
947
887
|
const rpOpts = await this.getRPOptions(context, {
|
|
948
|
-
|
|
888
|
+
definitionId,
|
|
949
889
|
responseRedirectURI
|
|
950
890
|
});
|
|
951
891
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== "function") {
|
|
@@ -957,29 +897,29 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
957
897
|
...rpOpts.identifierOpts.resolveOpts
|
|
958
898
|
};
|
|
959
899
|
}
|
|
960
|
-
console.log("Using agent DID resolver for RP instance with definition id " +
|
|
900
|
+
console.log("Using agent DID resolver for RP instance with definition id " + definitionId);
|
|
961
901
|
rpOpts.identifierOpts.resolveOpts.resolver = getAgentResolver2(context, {
|
|
962
902
|
uniresolverResolution: true,
|
|
963
903
|
localResolution: true,
|
|
964
904
|
resolverResolution: true
|
|
965
905
|
});
|
|
966
906
|
}
|
|
967
|
-
|
|
907
|
+
this.instances.set(instanceId, new RPInstance({
|
|
968
908
|
rpOpts,
|
|
969
909
|
pexOpts: instanceOpts
|
|
970
|
-
});
|
|
971
|
-
this.instances.set(rpInstanceId, rpInstance);
|
|
910
|
+
}));
|
|
972
911
|
}
|
|
912
|
+
const rpInstance = this.instances.get(instanceId);
|
|
973
913
|
if (responseRedirectURI) {
|
|
974
914
|
rpInstance.rpOptions.responseRedirectUri = responseRedirectURI;
|
|
975
915
|
}
|
|
976
916
|
return rpInstance;
|
|
977
917
|
}
|
|
978
918
|
async getRPOptions(context, opts) {
|
|
979
|
-
const {
|
|
980
|
-
const options = this.getInstanceOpts(
|
|
919
|
+
const { definitionId, responseRedirectURI } = opts;
|
|
920
|
+
const options = this.getInstanceOpts(definitionId)?.rpOpts ?? this.opts.defaultOpts;
|
|
981
921
|
if (!options) {
|
|
982
|
-
throw Error(`Could not get specific nor default options for definition ${
|
|
922
|
+
throw Error(`Could not get specific nor default options for definition ${definitionId}`);
|
|
983
923
|
}
|
|
984
924
|
if (this.opts.defaultOpts) {
|
|
985
925
|
if (!options.identifierOpts) {
|
|
@@ -1011,28 +951,40 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
1011
951
|
}
|
|
1012
952
|
return options;
|
|
1013
953
|
}
|
|
1014
|
-
getInstanceOpts(
|
|
954
|
+
getInstanceOpts(definitionId) {
|
|
1015
955
|
if (!this.opts.instanceOpts) return void 0;
|
|
1016
|
-
const instanceOpt =
|
|
1017
|
-
return instanceOpt ?? this.getDefaultOptions(
|
|
956
|
+
const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.definitionId === definitionId) : void 0;
|
|
957
|
+
return instanceOpt ?? this.getDefaultOptions(definitionId);
|
|
1018
958
|
}
|
|
1019
|
-
getDefaultOptions(
|
|
959
|
+
getDefaultOptions(definitionId) {
|
|
1020
960
|
if (!this.opts.instanceOpts) return void 0;
|
|
1021
|
-
const defaultOptions = this.opts.instanceOpts.find((i) => i.
|
|
961
|
+
const defaultOptions = this.opts.instanceOpts.find((i) => i.definitionId === "default");
|
|
1022
962
|
if (defaultOptions) {
|
|
1023
963
|
const clonedOptions = {
|
|
1024
964
|
...defaultOptions
|
|
1025
965
|
};
|
|
1026
|
-
if (
|
|
1027
|
-
clonedOptions.
|
|
966
|
+
if (definitionId !== void 0) {
|
|
967
|
+
clonedOptions.definitionId = definitionId;
|
|
1028
968
|
}
|
|
1029
969
|
return clonedOptions;
|
|
1030
970
|
}
|
|
1031
971
|
return void 0;
|
|
1032
972
|
}
|
|
1033
973
|
};
|
|
974
|
+
|
|
975
|
+
// src/types/ISIOPv2RP.ts
|
|
976
|
+
var VerifiedDataMode = /* @__PURE__ */ (function(VerifiedDataMode2) {
|
|
977
|
+
VerifiedDataMode2["NONE"] = "none";
|
|
978
|
+
VerifiedDataMode2["VERIFIED_PRESENTATION"] = "vp";
|
|
979
|
+
VerifiedDataMode2["CREDENTIAL_SUBJECT_FLATTENED"] = "cs-flat";
|
|
980
|
+
return VerifiedDataMode2;
|
|
981
|
+
})({});
|
|
982
|
+
|
|
983
|
+
// src/index.ts
|
|
984
|
+
var schema = require_plugin_schema();
|
|
1034
985
|
export {
|
|
1035
986
|
SIOPv2RP,
|
|
1036
|
-
|
|
987
|
+
VerifiedDataMode,
|
|
988
|
+
schema
|
|
1037
989
|
};
|
|
1038
990
|
//# sourceMappingURL=index.js.map
|