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