@cef-ebsi/cli 1.3.2 → 1.4.0
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/bin/cli.js +1 -1
- package/dist/abi/pilot/DidRegistry.js +568 -0
- package/dist/abi/pilot/DidRegistry.js.map +1 -0
- package/dist/abi/pilot/SchemaSCRegistry.js +264 -0
- package/dist/abi/pilot/SchemaSCRegistry.js.map +1 -0
- package/dist/abi/pilot/Timestamp.js +658 -0
- package/dist/abi/pilot/Timestamp.js.map +1 -0
- package/dist/abi/pilot/Tir.js +428 -0
- package/dist/abi/pilot/Tir.js.map +1 -0
- package/dist/abi/pilot/TnT.js +842 -0
- package/dist/abi/pilot/TnT.js.map +1 -0
- package/dist/abi/pilot/Tpr.js +492 -0
- package/dist/abi/pilot/Tpr.js.map +1 -0
- package/dist/abi/test/DidRegistry.js +144 -658
- package/dist/abi/test/DidRegistry.js.map +1 -1
- package/dist/abi/test/SchemaSCRegistry.js +101 -810
- package/dist/abi/test/SchemaSCRegistry.js.map +1 -1
- package/dist/abi/test/Timestamp.js +239 -673
- package/dist/abi/test/Timestamp.js.map +1 -1
- package/dist/abi/test/Tir.js +167 -636
- package/dist/abi/test/Tir.js.map +1 -1
- package/dist/abi/test/TnT.js +842 -0
- package/dist/abi/test/TnT.js.map +1 -0
- package/dist/abi/test/Tpr.js +166 -942
- package/dist/abi/test/Tpr.js.map +1 -1
- package/dist/app.js +444 -443
- package/dist/app.js.map +1 -1
- package/dist/buildParam/{didV3.js → didr.js} +182 -204
- package/dist/buildParam/didr.js.map +1 -0
- package/dist/buildParam/index.js +32 -48
- package/dist/buildParam/index.js.map +1 -1
- package/dist/buildParam/{timestampV2.js → timestamp.js} +137 -136
- package/dist/buildParam/timestamp.js.map +1 -0
- package/dist/buildParam/{tirV3.js → tir.js} +57 -59
- package/dist/buildParam/tir.js.map +1 -0
- package/dist/buildParam/{tntV2.js → tnt.js} +62 -61
- package/dist/buildParam/tnt.js.map +1 -0
- package/dist/buildParam/{tprV2.js → tpr.js} +34 -33
- package/dist/buildParam/tpr.js.map +1 -0
- package/dist/buildParam/{tsrV2.js → tsr.js} +39 -38
- package/dist/buildParam/tsr.js.map +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/{authorisation-v4.js → authorisation.js} +78 -71
- package/dist/commands/authorisation.js.map +1 -0
- package/dist/commands/compute.js +389 -389
- package/dist/commands/compute.js.map +1 -1
- package/dist/commands/{conformance-v3.js → conformance.js} +236 -248
- package/dist/commands/conformance.js.map +1 -0
- package/dist/commands/hardwarewallet.js +5 -5
- package/dist/commands/hardwarewallet.js.map +1 -1
- package/dist/commands/index.js +4 -4
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/{ledger-v4.js → ledger.js} +141 -128
- package/dist/commands/ledger.js.map +1 -0
- package/dist/commands/tnl.js +10 -9
- package/dist/commands/tnl.js.map +1 -1
- package/dist/commands/tsr.js +46 -0
- package/dist/commands/tsr.js.map +1 -0
- package/dist/commands/view.js +8 -8
- package/dist/commands/view.js.map +1 -1
- package/dist/config.js +280 -279
- package/dist/config.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.js +1 -1
- package/dist/interfaces/index.js.map +1 -1
- package/dist/programs/migrateDid.js +33 -33
- package/dist/programs/migrateDid.js.map +1 -1
- package/dist/programs/migrateDids.js +39 -42
- package/dist/programs/migrateDids.js.map +1 -1
- package/dist/programs/migrateTsr.js +109 -113
- package/dist/programs/migrateTsr.js.map +1 -1
- package/dist/scripts/accreditAndAuthorize/conformance/step1 +1 -1
- package/dist/scripts/accreditAndAuthorize/test/step1 +1 -1
- package/dist/scripts/accreditTI +1 -1
- package/dist/scripts/assets/CTRevocableCredential.json +1 -1
- package/dist/scripts/assets/CredentialToAttestVerifiableAuthorisationForTrustChain.json +2 -2
- package/dist/scripts/assets/TrustedNodesList.json +1 -1
- package/dist/scripts/assets/VerifiableAccreditationToAccredit.json +2 -2
- package/dist/scripts/assets/VerifiableAccreditationToAttest.json +2 -2
- package/dist/scripts/assets/VerifiableAuthorisationForTrustChain.json +1 -1
- package/dist/scripts/assets/VerifiableAuthorisationToOnboard.json +1 -1
- package/dist/scripts/bootstrap/6-setupConformanceIssuer +1 -1
- package/dist/scripts/issueVcOnboard +1 -1
- package/dist/scripts/issueVcRootTAO +1 -1
- package/dist/scripts/issueVcTAO +2 -2
- package/dist/scripts/issueVcTI +2 -2
- package/dist/scripts/issueVcTnl +1 -1
- package/dist/scripts/issue_CTRevocableCredential +1 -1
- package/dist/scripts/issue_SelfAttestationSupportOffice +2 -2
- package/dist/scripts/issue_VerifiableAccreditationToAccredit +2 -2
- package/dist/scripts/issue_VerifiableAccreditationToAttest +2 -2
- package/dist/scripts/issue_VerifiableAuthorisationForTrustChain +1 -1
- package/dist/scripts/issue_VerifiableAuthorisationToOnboard +1 -1
- package/dist/scripts/updateVcRootTAO +1 -1
- package/dist/scripts/updateVcTAO +2 -2
- package/dist/scripts/updateVcTI +2 -2
- package/dist/scripts/{wctv3 → wct}/accreditAndAuthorize +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/Client.js +81 -68
- package/dist/utils/Client.js.map +1 -1
- package/dist/utils/HardwareWallet.js +169 -165
- package/dist/utils/HardwareWallet.js.map +1 -1
- package/dist/utils/http.js +24 -27
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jsonrpc.js +14 -14
- package/dist/utils/jsonrpc.js.map +1 -1
- package/dist/utils/print.js +19 -19
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/utils.js +180 -173
- package/dist/utils/utils.js.map +1 -1
- package/package.json +70 -46
- package/dist/abi/pilot/DidRegistryV3.js +0 -1082
- package/dist/abi/pilot/DidRegistryV3.js.map +0 -1
- package/dist/abi/pilot/DidRegistryV4.js +0 -942
- package/dist/abi/pilot/DidRegistryV4.js.map +0 -1
- package/dist/abi/pilot/SchemaSCRegistryV2.js +0 -474
- package/dist/abi/pilot/SchemaSCRegistryV2.js.map +0 -1
- package/dist/abi/pilot/TimestampV2.js +0 -1128
- package/dist/abi/pilot/TimestampV2.js.map +0 -1
- package/dist/abi/pilot/TimestampV3.js +0 -995
- package/dist/abi/pilot/TimestampV3.js.map +0 -1
- package/dist/abi/pilot/TirV3.js +0 -496
- package/dist/abi/pilot/TirV3.js.map +0 -1
- package/dist/abi/pilot/TirV4.js +0 -710
- package/dist/abi/pilot/TirV4.js.map +0 -1
- package/dist/abi/pilot/TnTV1.js +0 -1375
- package/dist/abi/pilot/TnTV1.js.map +0 -1
- package/dist/abi/pilot/TprV2.js +0 -889
- package/dist/abi/pilot/TprV2.js.map +0 -1
- package/dist/abi/pilot/TprV3.js +0 -707
- package/dist/abi/pilot/TprV3.js.map +0 -1
- package/dist/abi/pilot/TsrV3.js +0 -571
- package/dist/abi/pilot/TsrV3.js.map +0 -1
- package/dist/abi/test/DidRegistryV3.js +0 -1089
- package/dist/abi/test/DidRegistryV3.js.map +0 -1
- package/dist/abi/test/DidRegistryV4.js +0 -960
- package/dist/abi/test/DidRegistryV4.js.map +0 -1
- package/dist/abi/test/SchemaSCRegistryV2.js +0 -474
- package/dist/abi/test/SchemaSCRegistryV2.js.map +0 -1
- package/dist/abi/test/TimestampV2.js +0 -1128
- package/dist/abi/test/TimestampV2.js.map +0 -1
- package/dist/abi/test/TimestampV3.js +0 -995
- package/dist/abi/test/TimestampV3.js.map +0 -1
- package/dist/abi/test/TirV3.js +0 -496
- package/dist/abi/test/TirV3.js.map +0 -1
- package/dist/abi/test/TirV4.js +0 -710
- package/dist/abi/test/TirV4.js.map +0 -1
- package/dist/abi/test/TnTV1.js +0 -1375
- package/dist/abi/test/TnTV1.js.map +0 -1
- package/dist/abi/test/TprV2.js +0 -889
- package/dist/abi/test/TprV2.js.map +0 -1
- package/dist/abi/test/TprV3.js +0 -707
- package/dist/abi/test/TprV3.js.map +0 -1
- package/dist/abi/test/TsrV3.js +0 -571
- package/dist/abi/test/TsrV3.js.map +0 -1
- package/dist/buildParam/didV3.js.map +0 -1
- package/dist/buildParam/didV4.js +0 -326
- package/dist/buildParam/didV4.js.map +0 -1
- package/dist/buildParam/timestampV2.js.map +0 -1
- package/dist/buildParam/timestampV3.js +0 -317
- package/dist/buildParam/timestampV3.js.map +0 -1
- package/dist/buildParam/tirV3.js.map +0 -1
- package/dist/buildParam/tirV4.js +0 -119
- package/dist/buildParam/tirV4.js.map +0 -1
- package/dist/buildParam/tntV1.js +0 -185
- package/dist/buildParam/tntV1.js.map +0 -1
- package/dist/buildParam/tntV2.js.map +0 -1
- package/dist/buildParam/tprV2.js.map +0 -1
- package/dist/buildParam/tprV3.js +0 -82
- package/dist/buildParam/tprV3.js.map +0 -1
- package/dist/buildParam/tsrV2.js.map +0 -1
- package/dist/buildParam/tsrV3.js +0 -110
- package/dist/buildParam/tsrV3.js.map +0 -1
- package/dist/commands/authorisation-v4.js.map +0 -1
- package/dist/commands/authorisation-v5.js +0 -119
- package/dist/commands/authorisation-v5.js.map +0 -1
- package/dist/commands/conformance-v3.js.map +0 -1
- package/dist/commands/ledger-v4.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/scripts/{wctv3 → wct}/holderWallet +0 -0
- /package/dist/scripts/{wctv3 → wct}/issueToHolder +0 -0
- /package/dist/scripts/{wctv3 → wct}/pda1 +0 -0
- /package/dist/scripts/{wctv3 → wct}/verifier +0 -0
|
@@ -1,59 +1,10 @@
|
|
|
1
|
-
import { randomUUID, randomBytes, createHash } from "node:crypto";
|
|
2
|
-
import { URLSearchParams } from "node:url";
|
|
3
1
|
import Joi from "joi";
|
|
4
|
-
import qs from "qs";
|
|
5
2
|
import { base64url } from "multiformats/bases/base64";
|
|
6
|
-
import {
|
|
3
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
4
|
+
import { URLSearchParams } from "node:url";
|
|
5
|
+
import qs from "qs";
|
|
7
6
|
import { httpCall, red } from "../utils/index.js";
|
|
8
|
-
|
|
9
|
-
if (typeof obj !== "object")
|
|
10
|
-
throw new Error("not an object");
|
|
11
|
-
const newObj = {};
|
|
12
|
-
fields.forEach((f) => {
|
|
13
|
-
if (obj[f])
|
|
14
|
-
newObj[f] = obj[f];
|
|
15
|
-
});
|
|
16
|
-
return JSON.stringify(newObj);
|
|
17
|
-
}
|
|
18
|
-
export async function conformanceGet(inputs, context) {
|
|
19
|
-
const apiUrl = context.config.api.conformance.url;
|
|
20
|
-
const urlPath = inputs.join("");
|
|
21
|
-
const url = urlPath.startsWith("http") ? urlPath : `${apiUrl}${urlPath}`;
|
|
22
|
-
const response = await httpCall.get(url, context.httpOpts);
|
|
23
|
-
return response.data;
|
|
24
|
-
}
|
|
25
|
-
export async function clientMockInitiate(context) {
|
|
26
|
-
const apiUrl = context.config.api.conformance.url;
|
|
27
|
-
const { accreditationUrl, proxyId, issuerState } = context.rtVars.user;
|
|
28
|
-
const response = await httpCall.post(`${apiUrl}/client-mock/initiate`, {
|
|
29
|
-
did: context.client.did,
|
|
30
|
-
keys: Object.keys(context.client.keys).map((keyName) => {
|
|
31
|
-
const key = context.client.keys[keyName];
|
|
32
|
-
return {
|
|
33
|
-
...key.privateKeyJwk,
|
|
34
|
-
kid: key.kid,
|
|
35
|
-
};
|
|
36
|
-
}),
|
|
37
|
-
...(accreditationUrl && { attributeUrl: accreditationUrl }),
|
|
38
|
-
...(proxyId && { proxyId }),
|
|
39
|
-
...(issuerState && { issuerState }),
|
|
40
|
-
});
|
|
41
|
-
context.client.clientId = `${apiUrl}/client-mock/${context.client.did}`;
|
|
42
|
-
context.rtVars.user.clientId =
|
|
43
|
-
context.client.clientId;
|
|
44
|
-
return response.data;
|
|
45
|
-
}
|
|
46
|
-
export async function clientMockUpdateList(inputs, context) {
|
|
47
|
-
const [statusIndex, statusListIndex, value] = inputs;
|
|
48
|
-
const apiUrl = context.config.api.conformance.url;
|
|
49
|
-
const response = await httpCall.post(`${apiUrl}/client-mock/updateList`, {
|
|
50
|
-
did: context.client.did,
|
|
51
|
-
id: statusIndex.toString(),
|
|
52
|
-
position: Number(statusListIndex),
|
|
53
|
-
value: Number(value),
|
|
54
|
-
});
|
|
55
|
-
return response.data;
|
|
56
|
-
}
|
|
7
|
+
import { compute, getUserPin } from "./compute.js";
|
|
57
8
|
export async function authMockAuthorize(inputs, context) {
|
|
58
9
|
const [openIdCredentialIssuer, openIdConfiguration, requestedTypes, inputAlg, codeVerifier, issuerState,] = inputs;
|
|
59
10
|
const alg = inputAlg || "ES256";
|
|
@@ -74,26 +25,26 @@ export async function authMockAuthorize(inputs, context) {
|
|
|
74
25
|
authorization_endpoint: "openid:",
|
|
75
26
|
}
|
|
76
27
|
: {
|
|
77
|
-
redirect_uris: [`${context.client.clientId}/code-cb`],
|
|
78
|
-
jwks_uri: `${context.client.clientId}/jwks`,
|
|
79
28
|
authorization_endpoint: `${context.client.clientId}/authorize`,
|
|
29
|
+
jwks_uri: `${context.client.clientId}/jwks`,
|
|
30
|
+
redirect_uris: [`${context.client.clientId}/code-cb`],
|
|
80
31
|
};
|
|
81
32
|
const authorizationDetails = [
|
|
82
33
|
{
|
|
83
|
-
type: "openid_credential",
|
|
84
34
|
format: "jwt_vc",
|
|
85
35
|
locations: [openIdCredentialIssuer.credential_issuer],
|
|
36
|
+
type: "openid_credential",
|
|
86
37
|
types: requestedTypes,
|
|
87
38
|
},
|
|
88
39
|
];
|
|
89
40
|
const queryParams = {
|
|
90
|
-
scope: "openid",
|
|
91
41
|
client_id: clientId,
|
|
92
42
|
client_metadata: JSON.stringify(clientMetadata),
|
|
93
43
|
redirect_uri: isPKCEChallenge
|
|
94
44
|
? "openid://callback"
|
|
95
45
|
: `${context.client.clientId}/code-cb`,
|
|
96
46
|
response_type: "code",
|
|
47
|
+
scope: "openid",
|
|
97
48
|
state: randomUUID(),
|
|
98
49
|
...(isPKCEChallenge && {
|
|
99
50
|
code_challenge: codeChallenge,
|
|
@@ -104,10 +55,10 @@ export async function authMockAuthorize(inputs, context) {
|
|
|
104
55
|
};
|
|
105
56
|
const jwtPayload = {
|
|
106
57
|
...queryParams,
|
|
107
|
-
|
|
58
|
+
aud: authorizationServer,
|
|
108
59
|
authorization_details: authorizationDetails,
|
|
60
|
+
client_metadata: clientMetadata,
|
|
109
61
|
iss: clientId,
|
|
110
|
-
aud: authorizationServer,
|
|
111
62
|
};
|
|
112
63
|
const requestParam = await context.client.signJWT(jwtPayload, {}, alg);
|
|
113
64
|
const responseAuthorize = await httpCall.get(`${openIdConfiguration.authorization_endpoint}?${new URLSearchParams({
|
|
@@ -118,7 +69,7 @@ export async function authMockAuthorize(inputs, context) {
|
|
|
118
69
|
const locationUrl = new URL(location);
|
|
119
70
|
if (locationUrl.searchParams.get("error"))
|
|
120
71
|
throw new Error(locationUrl.searchParams.toString());
|
|
121
|
-
const responseQueryParams = qs.parse(locationUrl.search.
|
|
72
|
+
const responseQueryParams = qs.parse(locationUrl.search.slice(1));
|
|
122
73
|
return responseQueryParams;
|
|
123
74
|
}
|
|
124
75
|
export async function authMockDirectPostIdToken(inputs, context) {
|
|
@@ -127,16 +78,16 @@ export async function authMockDirectPostIdToken(inputs, context) {
|
|
|
127
78
|
Joi.assert(alg, Joi.string().valid("ES256K", "ES256", "EdDSA", "RS256"));
|
|
128
79
|
const authorizationServer = openIdCredentialIssuer.authorization_server ??
|
|
129
80
|
openIdCredentialIssuer.credential_issuer;
|
|
130
|
-
const {
|
|
81
|
+
const { nonce, state } = issuerRequest;
|
|
131
82
|
const iat = Math.floor(Date.now() / 1000);
|
|
132
83
|
const exp = iat + 5 * 60;
|
|
133
84
|
const idTokenDirectPost = await context.client.signJWT({
|
|
134
|
-
nonce,
|
|
135
|
-
iss: context.client.did,
|
|
136
|
-
sub: context.client.did,
|
|
137
85
|
aud: authorizationServer,
|
|
138
|
-
iat,
|
|
139
86
|
exp,
|
|
87
|
+
iat,
|
|
88
|
+
iss: context.client.did,
|
|
89
|
+
nonce,
|
|
90
|
+
sub: context.client.did,
|
|
140
91
|
}, {}, alg);
|
|
141
92
|
const responseDirectPost = await httpCall.post(issuerRequest.redirect_uri, new URLSearchParams({
|
|
142
93
|
id_token: idTokenDirectPost,
|
|
@@ -150,7 +101,7 @@ export async function authMockDirectPostIdToken(inputs, context) {
|
|
|
150
101
|
const locationUrl = new URL(location);
|
|
151
102
|
if (locationUrl.searchParams.get("error"))
|
|
152
103
|
throw new Error(locationUrl.searchParams.toString());
|
|
153
|
-
const responseQueryParams = qs.parse(locationUrl.search.
|
|
104
|
+
const responseQueryParams = qs.parse(locationUrl.search.slice(1));
|
|
154
105
|
return responseQueryParams;
|
|
155
106
|
}
|
|
156
107
|
export async function authMockDirectPostVpToken(inputs) {
|
|
@@ -158,111 +109,111 @@ export async function authMockDirectPostVpToken(inputs) {
|
|
|
158
109
|
const { state } = issuerRequest;
|
|
159
110
|
const presentationSubmission = type === "holder"
|
|
160
111
|
? {
|
|
161
|
-
id: randomUUID(),
|
|
162
112
|
definition_id: "holder-wallet-qualification-presentation",
|
|
163
113
|
descriptor_map: [
|
|
164
114
|
{
|
|
115
|
+
format: "jwt_vp",
|
|
165
116
|
id: "same-device-authorised-in-time-credential",
|
|
166
117
|
path: "$",
|
|
167
|
-
format: "jwt_vp",
|
|
168
118
|
path_nested: {
|
|
169
|
-
id: "same-device-authorised-in-time-credential",
|
|
170
119
|
format: "jwt_vc",
|
|
120
|
+
id: "same-device-authorised-in-time-credential",
|
|
171
121
|
path: "$.vp.verifiableCredential[0]",
|
|
172
122
|
},
|
|
173
123
|
},
|
|
174
124
|
{
|
|
125
|
+
format: "jwt_vp",
|
|
175
126
|
id: "cross-device-authorised-in-time-credential",
|
|
176
127
|
path: "$",
|
|
177
|
-
format: "jwt_vp",
|
|
178
128
|
path_nested: {
|
|
179
|
-
id: "cross-device-authorised-in-time-credential",
|
|
180
129
|
format: "jwt_vc",
|
|
130
|
+
id: "cross-device-authorised-in-time-credential",
|
|
181
131
|
path: "$.vp.verifiableCredential[1]",
|
|
182
132
|
},
|
|
183
133
|
},
|
|
184
134
|
{
|
|
135
|
+
format: "jwt_vp",
|
|
185
136
|
id: "same-device-authorised-deferred-credential",
|
|
186
137
|
path: "$",
|
|
187
|
-
format: "jwt_vp",
|
|
188
138
|
path_nested: {
|
|
189
|
-
id: "same-device-authorised-deferred-credential",
|
|
190
139
|
format: "jwt_vc",
|
|
140
|
+
id: "same-device-authorised-deferred-credential",
|
|
191
141
|
path: "$.vp.verifiableCredential[2]",
|
|
192
142
|
},
|
|
193
143
|
},
|
|
194
144
|
{
|
|
145
|
+
format: "jwt_vp",
|
|
195
146
|
id: "cross-device-authorised-deferred-credential",
|
|
196
147
|
path: "$",
|
|
197
|
-
format: "jwt_vp",
|
|
198
148
|
path_nested: {
|
|
199
|
-
id: "cross-device-authorised-deferred-credential",
|
|
200
149
|
format: "jwt_vc",
|
|
150
|
+
id: "cross-device-authorised-deferred-credential",
|
|
201
151
|
path: "$.vp.verifiableCredential[3]",
|
|
202
152
|
},
|
|
203
153
|
},
|
|
204
154
|
{
|
|
155
|
+
format: "jwt_vp",
|
|
205
156
|
id: "same-device-pre-authorised-in-time-credential",
|
|
206
157
|
path: "$",
|
|
207
|
-
format: "jwt_vp",
|
|
208
158
|
path_nested: {
|
|
209
|
-
id: "same-device-pre-authorised-in-time-credential",
|
|
210
159
|
format: "jwt_vc",
|
|
160
|
+
id: "same-device-pre-authorised-in-time-credential",
|
|
211
161
|
path: "$.vp.verifiableCredential[4]",
|
|
212
162
|
},
|
|
213
163
|
},
|
|
214
164
|
{
|
|
165
|
+
format: "jwt_vp",
|
|
215
166
|
id: "cross-device-pre-authorised-in-time-credential",
|
|
216
167
|
path: "$",
|
|
217
|
-
format: "jwt_vp",
|
|
218
168
|
path_nested: {
|
|
219
|
-
id: "cross-device-pre-authorised-in-time-credential",
|
|
220
169
|
format: "jwt_vc",
|
|
170
|
+
id: "cross-device-pre-authorised-in-time-credential",
|
|
221
171
|
path: "$.vp.verifiableCredential[5]",
|
|
222
172
|
},
|
|
223
173
|
},
|
|
224
174
|
{
|
|
175
|
+
format: "jwt_vp",
|
|
225
176
|
id: "same-device-pre-authorised-deferred-credential",
|
|
226
177
|
path: "$",
|
|
227
|
-
format: "jwt_vp",
|
|
228
178
|
path_nested: {
|
|
229
|
-
id: "same-device-pre-authorised-deferred-credential",
|
|
230
179
|
format: "jwt_vc",
|
|
180
|
+
id: "same-device-pre-authorised-deferred-credential",
|
|
231
181
|
path: "$.vp.verifiableCredential[6]",
|
|
232
182
|
},
|
|
233
183
|
},
|
|
234
184
|
{
|
|
185
|
+
format: "jwt_vp",
|
|
235
186
|
id: "cross-device-pre-authorised-deferred-credential",
|
|
236
187
|
path: "$",
|
|
237
|
-
format: "jwt_vp",
|
|
238
188
|
path_nested: {
|
|
239
|
-
id: "cross-device-pre-authorised-deferred-credential",
|
|
240
189
|
format: "jwt_vc",
|
|
190
|
+
id: "cross-device-pre-authorised-deferred-credential",
|
|
241
191
|
path: "$.vp.verifiableCredential[7]",
|
|
242
192
|
},
|
|
243
193
|
},
|
|
244
194
|
],
|
|
195
|
+
id: randomUUID(),
|
|
245
196
|
}
|
|
246
197
|
: {
|
|
247
|
-
id: randomUUID(),
|
|
248
198
|
definition_id: "va-to-onboard-presentation",
|
|
249
199
|
descriptor_map: [
|
|
250
200
|
{
|
|
251
|
-
id: "verifiable-authorisation-to-onboard",
|
|
252
201
|
format: "jwt_vp",
|
|
202
|
+
id: "verifiable-authorisation-to-onboard",
|
|
253
203
|
path: "$",
|
|
254
204
|
path_nested: {
|
|
255
|
-
id: "verifiable-authorisation-to-onboard",
|
|
256
205
|
format: "jwt_vc",
|
|
206
|
+
id: "verifiable-authorisation-to-onboard",
|
|
257
207
|
path: "$.vp.verifiableCredential[0]",
|
|
258
208
|
},
|
|
259
209
|
},
|
|
260
210
|
],
|
|
211
|
+
id: randomUUID(),
|
|
261
212
|
};
|
|
262
213
|
const responseDirectPost = await httpCall.post(issuerRequest.redirect_uri, new URLSearchParams({
|
|
263
|
-
vp_token: vpJwt,
|
|
264
|
-
state,
|
|
265
214
|
presentation_submission: JSON.stringify(presentationSubmission),
|
|
215
|
+
state,
|
|
216
|
+
vp_token: vpJwt,
|
|
266
217
|
}).toString(), {
|
|
267
218
|
headers: {
|
|
268
219
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -272,7 +223,7 @@ export async function authMockDirectPostVpToken(inputs) {
|
|
|
272
223
|
const locationUrl = new URL(location);
|
|
273
224
|
if (locationUrl.searchParams.get("error"))
|
|
274
225
|
throw new Error(locationUrl.searchParams.toString());
|
|
275
|
-
const responseQueryParams = qs.parse(locationUrl.search.
|
|
226
|
+
const responseQueryParams = qs.parse(locationUrl.search.slice(1));
|
|
276
227
|
return responseQueryParams;
|
|
277
228
|
}
|
|
278
229
|
export async function authMockToken(inputs, context) {
|
|
@@ -281,21 +232,18 @@ export async function authMockToken(inputs, context) {
|
|
|
281
232
|
const isPKCEChallenge = !!codeVerifier;
|
|
282
233
|
const authorizationServer = openIdCredentialIssuer.authorization_server ??
|
|
283
234
|
openIdCredentialIssuer.credential_issuer;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
queryParams = {
|
|
235
|
+
const queryParams = type === "preAuthorised"
|
|
236
|
+
? {
|
|
287
237
|
grant_type: "urn:ietf:params:oauth:grant-type:pre-authorized_code",
|
|
288
238
|
"pre-authorized_code": code,
|
|
289
239
|
user_pin: getUserPin(context.client.did),
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
else {
|
|
293
|
-
queryParams = {
|
|
294
|
-
grant_type: "authorization_code",
|
|
240
|
+
}
|
|
241
|
+
: {
|
|
295
242
|
code,
|
|
243
|
+
grant_type: "authorization_code",
|
|
296
244
|
...(!isPKCEChallenge && {
|
|
297
|
-
client_id: context.client.clientId,
|
|
298
245
|
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
246
|
+
client_id: context.client.clientId,
|
|
299
247
|
redirect_uri: `${context.client.clientId}/code-cb`,
|
|
300
248
|
}),
|
|
301
249
|
...(isPKCEChallenge && {
|
|
@@ -304,16 +252,15 @@ export async function authMockToken(inputs, context) {
|
|
|
304
252
|
redirect_uri: "openid://callback",
|
|
305
253
|
}),
|
|
306
254
|
};
|
|
307
|
-
}
|
|
308
255
|
const iat = Math.floor(Date.now() / 1000);
|
|
309
256
|
const exp = iat + 5 * 60;
|
|
310
257
|
const jwtPayload = {
|
|
311
258
|
...queryParams,
|
|
312
|
-
iss: context.client.clientId,
|
|
313
259
|
aud: authorizationServer,
|
|
314
|
-
sub: context.client.clientId,
|
|
315
|
-
iat,
|
|
316
260
|
exp,
|
|
261
|
+
iat,
|
|
262
|
+
iss: context.client.clientId,
|
|
263
|
+
sub: context.client.clientId,
|
|
317
264
|
};
|
|
318
265
|
const clientAssertion = await context.client.signJWT(jwtPayload, {}, alg);
|
|
319
266
|
const responseToken = await httpCall.post(openIdConfiguration.token_endpoint, new URLSearchParams({
|
|
@@ -326,65 +273,115 @@ export async function authMockToken(inputs, context) {
|
|
|
326
273
|
});
|
|
327
274
|
return responseToken.data;
|
|
328
275
|
}
|
|
329
|
-
export async function
|
|
330
|
-
const [
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
};
|
|
344
|
-
const proofJwt = await context.client.signJWT(jwtPayload, {
|
|
345
|
-
typ: "openid4vci-proof+jwt",
|
|
346
|
-
}, alg);
|
|
347
|
-
const responseCredential = await httpCall.post(`${openIdCredentialIssuer.credential_issuer}/credential`, {
|
|
348
|
-
types: requestedTypes,
|
|
349
|
-
format: "jwt_vc",
|
|
350
|
-
proof: {
|
|
351
|
-
proof_type: "jwt",
|
|
352
|
-
jwt: proofJwt,
|
|
276
|
+
export async function check(inputs, context) {
|
|
277
|
+
const [intent, preAuthorizedCode, userPin] = inputs;
|
|
278
|
+
const apiUrl = context.config.api.conformance.url;
|
|
279
|
+
const response = await httpCall.post(`${apiUrl}/check`, {
|
|
280
|
+
data: {
|
|
281
|
+
clientId: context.client.clientId,
|
|
282
|
+
credentialIssuer: context.client.clientId,
|
|
283
|
+
credentialIssuerDid: context.client.did,
|
|
284
|
+
did: context.client.did,
|
|
285
|
+
issuerState: context.client.issuerState,
|
|
286
|
+
...(preAuthorizedCode && {
|
|
287
|
+
preAuthorizedCode,
|
|
288
|
+
userPin,
|
|
289
|
+
}),
|
|
353
290
|
},
|
|
354
|
-
|
|
355
|
-
|
|
291
|
+
intent,
|
|
292
|
+
});
|
|
293
|
+
if (!response.data.success) {
|
|
294
|
+
red(response.data.errors);
|
|
295
|
+
throw new Error(`check ${intent} failed: ${response.data.errors
|
|
296
|
+
? JSON.stringify(response.data.errors)
|
|
297
|
+
: "unknown error"}`);
|
|
298
|
+
}
|
|
299
|
+
return response.data;
|
|
356
300
|
}
|
|
357
|
-
export async function
|
|
358
|
-
const
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
301
|
+
export async function clientMockInitiate(context) {
|
|
302
|
+
const apiUrl = context.config.api.conformance.url;
|
|
303
|
+
const { accreditationUrl, issuerState, proxyId } = context.rtVars.user;
|
|
304
|
+
const response = await httpCall.post(`${apiUrl}/client-mock/initiate`, {
|
|
305
|
+
did: context.client.did,
|
|
306
|
+
keys: Object.keys(context.client.keys).map((keyName) => {
|
|
307
|
+
const key = context.client.keys[keyName];
|
|
308
|
+
return {
|
|
309
|
+
...key.privateKeyJwk,
|
|
310
|
+
kid: key.kid,
|
|
311
|
+
};
|
|
312
|
+
}),
|
|
313
|
+
...(accreditationUrl && { attributeUrl: accreditationUrl }),
|
|
314
|
+
...(proxyId && { proxyId }),
|
|
315
|
+
...(issuerState && { issuerState }),
|
|
363
316
|
});
|
|
317
|
+
context.client.clientId = `${apiUrl}/client-mock/${context.client.did}`;
|
|
318
|
+
context.rtVars.user.clientId =
|
|
319
|
+
context.client.clientId;
|
|
364
320
|
return response.data;
|
|
365
321
|
}
|
|
366
|
-
export async function
|
|
367
|
-
const [
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
322
|
+
export async function clientMockUpdateList(inputs, context) {
|
|
323
|
+
const [statusIndex, statusListIndex, value] = inputs;
|
|
324
|
+
const apiUrl = context.config.api.conformance.url;
|
|
325
|
+
const response = await httpCall.post(`${apiUrl}/client-mock/updateList`, {
|
|
326
|
+
did: context.client.did,
|
|
327
|
+
id: statusIndex.toString(),
|
|
328
|
+
position: Number(statusListIndex),
|
|
329
|
+
value: Number(value),
|
|
330
|
+
});
|
|
331
|
+
return response.data;
|
|
332
|
+
}
|
|
333
|
+
export async function conformance(method, inputs, context) {
|
|
334
|
+
switch (method) {
|
|
335
|
+
case "authMockAuthorize": {
|
|
336
|
+
return authMockAuthorize(inputs, context);
|
|
337
|
+
}
|
|
338
|
+
case "authMockDirectPostIdToken": {
|
|
339
|
+
return authMockDirectPostIdToken(inputs, context);
|
|
340
|
+
}
|
|
341
|
+
case "authMockDirectPostVpToken": {
|
|
342
|
+
return authMockDirectPostVpToken(inputs);
|
|
343
|
+
}
|
|
344
|
+
case "authMockToken": {
|
|
345
|
+
return authMockToken(inputs, context);
|
|
346
|
+
}
|
|
347
|
+
case "check": {
|
|
348
|
+
return check(inputs, context);
|
|
349
|
+
}
|
|
350
|
+
case "clientMockInitiate": {
|
|
351
|
+
return clientMockInitiate(context);
|
|
352
|
+
}
|
|
353
|
+
case "clientMockUpdateList": {
|
|
354
|
+
return clientMockUpdateList(inputs, context);
|
|
355
|
+
}
|
|
356
|
+
case "get": {
|
|
357
|
+
return conformanceGet(inputs, context);
|
|
358
|
+
}
|
|
359
|
+
case "getCredential": {
|
|
360
|
+
return getCredential(inputs, context);
|
|
361
|
+
}
|
|
362
|
+
case "holder": {
|
|
363
|
+
return holder(inputs, context);
|
|
364
|
+
}
|
|
365
|
+
case "issuerMockCredential": {
|
|
366
|
+
return issuerMockCredential(inputs, context);
|
|
367
|
+
}
|
|
368
|
+
case "issuerMockDeferred": {
|
|
369
|
+
return issuerMockDeferred(inputs);
|
|
370
|
+
}
|
|
371
|
+
case "issuerMockInitiateCredentialOffer": {
|
|
372
|
+
return issuerMockInitiateCredentialOffer(inputs, context);
|
|
373
|
+
}
|
|
374
|
+
default: {
|
|
375
|
+
throw new Error(`Invalid method '${method}'`);
|
|
376
|
+
}
|
|
386
377
|
}
|
|
387
|
-
|
|
378
|
+
}
|
|
379
|
+
export async function conformanceGet(inputs, context) {
|
|
380
|
+
const apiUrl = context.config.api.conformance.url;
|
|
381
|
+
const urlPath = inputs.join("");
|
|
382
|
+
const url = urlPath.startsWith("http") ? urlPath : `${apiUrl}${urlPath}`;
|
|
383
|
+
const response = await httpCall.get(url, context.httpOpts);
|
|
384
|
+
return response.data;
|
|
388
385
|
}
|
|
389
386
|
export async function getCredential(inputs, context) {
|
|
390
387
|
const [type, inputAlg, inputVc, inputIssuer] = inputs;
|
|
@@ -393,12 +390,9 @@ export async function getCredential(inputs, context) {
|
|
|
393
390
|
const vcString = typeof vc === "string" ? vc : JSON.stringify(vc);
|
|
394
391
|
let openIdCredentialIssuerUrl;
|
|
395
392
|
if (inputIssuer) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
else {
|
|
400
|
-
openIdCredentialIssuerUrl = `/client-mock/${inputIssuer}/.well-known/openid-credential-issuer`;
|
|
401
|
-
}
|
|
393
|
+
openIdCredentialIssuerUrl = inputIssuer.startsWith("http")
|
|
394
|
+
? `${inputIssuer}/.well-known/openid-credential-issuer`
|
|
395
|
+
: `/client-mock/${inputIssuer}/.well-known/openid-credential-issuer`;
|
|
402
396
|
}
|
|
403
397
|
else {
|
|
404
398
|
openIdCredentialIssuerUrl =
|
|
@@ -406,29 +400,27 @@ export async function getCredential(inputs, context) {
|
|
|
406
400
|
}
|
|
407
401
|
let requestedTypes;
|
|
408
402
|
switch (type) {
|
|
409
|
-
case "
|
|
403
|
+
case "ctrevocable": {
|
|
410
404
|
requestedTypes = [
|
|
411
405
|
"VerifiableCredential",
|
|
412
406
|
"VerifiableAttestation",
|
|
413
|
-
"
|
|
407
|
+
"CTRevocable",
|
|
414
408
|
];
|
|
415
409
|
break;
|
|
416
410
|
}
|
|
417
|
-
case "
|
|
411
|
+
case "onboard": {
|
|
418
412
|
requestedTypes = [
|
|
419
413
|
"VerifiableCredential",
|
|
420
414
|
"VerifiableAttestation",
|
|
421
|
-
"
|
|
422
|
-
"VerifiableAccreditationToAttest",
|
|
415
|
+
"VerifiableAuthorisationToOnboard",
|
|
423
416
|
];
|
|
424
417
|
break;
|
|
425
418
|
}
|
|
426
|
-
case "
|
|
419
|
+
case "qualification": {
|
|
427
420
|
requestedTypes = [
|
|
428
421
|
"VerifiableCredential",
|
|
429
422
|
"VerifiableAttestation",
|
|
430
|
-
"
|
|
431
|
-
"VerifiableAccreditationToAccredit",
|
|
423
|
+
"CTAAQualificationCredential",
|
|
432
424
|
];
|
|
433
425
|
break;
|
|
434
426
|
}
|
|
@@ -440,24 +432,27 @@ export async function getCredential(inputs, context) {
|
|
|
440
432
|
];
|
|
441
433
|
break;
|
|
442
434
|
}
|
|
443
|
-
case "
|
|
435
|
+
case "tao": {
|
|
444
436
|
requestedTypes = [
|
|
445
437
|
"VerifiableCredential",
|
|
446
438
|
"VerifiableAttestation",
|
|
447
|
-
"
|
|
439
|
+
"VerifiableAccreditation",
|
|
440
|
+
"VerifiableAccreditationToAccredit",
|
|
448
441
|
];
|
|
449
442
|
break;
|
|
450
443
|
}
|
|
451
|
-
case "
|
|
444
|
+
case "ti": {
|
|
452
445
|
requestedTypes = [
|
|
453
446
|
"VerifiableCredential",
|
|
454
447
|
"VerifiableAttestation",
|
|
455
|
-
"
|
|
448
|
+
"VerifiableAccreditation",
|
|
449
|
+
"VerifiableAccreditationToAttest",
|
|
456
450
|
];
|
|
457
451
|
break;
|
|
458
452
|
}
|
|
459
|
-
default:
|
|
453
|
+
default: {
|
|
460
454
|
throw new Error(`type ${type} is not supported`);
|
|
455
|
+
}
|
|
461
456
|
}
|
|
462
457
|
// conformance clientMockInitiate
|
|
463
458
|
console.log("==> conformance clientMockInitiate");
|
|
@@ -539,15 +534,13 @@ export async function getCredential(inputs, context) {
|
|
|
539
534
|
console.log(`==> compute decodeJWT ${credential}`);
|
|
540
535
|
const decodedCredential = (await compute("decodeJWT", [credential], context));
|
|
541
536
|
let reservedAttributeId = "";
|
|
542
|
-
if (decodedCredential.payload.vc
|
|
543
|
-
decodedCredential.payload.vc.credentialSubject &&
|
|
544
|
-
decodedCredential.payload.vc.credentialSubject.reservedAttributeId) {
|
|
537
|
+
if (decodedCredential.payload.vc?.credentialSubject?.reservedAttributeId) {
|
|
545
538
|
reservedAttributeId =
|
|
546
539
|
decodedCredential.payload.vc.credentialSubject.reservedAttributeId;
|
|
547
540
|
}
|
|
548
541
|
return {
|
|
549
|
-
vc: credential,
|
|
550
542
|
reservedAttributeId,
|
|
543
|
+
vc: credential,
|
|
551
544
|
};
|
|
552
545
|
}
|
|
553
546
|
export async function holder(inputs, context) {
|
|
@@ -594,12 +587,12 @@ export async function holder(inputs, context) {
|
|
|
594
587
|
const isPreauthorised = communicationType
|
|
595
588
|
.toLowerCase()
|
|
596
589
|
.startsWith("preauthorised");
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
throw new Error("For preauthorised credentials set use-credential-offer");
|
|
590
|
+
if (useCredentialOffer) {
|
|
591
|
+
credentialOffer = await issuerMockInitiateCredentialOffer([initiateCredentialOfferEndpoint, credentialType], context);
|
|
600
592
|
}
|
|
601
593
|
else {
|
|
602
|
-
|
|
594
|
+
if (isPreauthorised)
|
|
595
|
+
throw new Error("For preauthorised credentials set use-credential-offer");
|
|
603
596
|
}
|
|
604
597
|
// opIssuer: conformance get /issuer-mock/.well-known/openid-credential-issuer
|
|
605
598
|
console.log(`==> conformance get ${openIdCredentialIssuerUrl}`);
|
|
@@ -698,75 +691,70 @@ export async function holder(inputs, context) {
|
|
|
698
691
|
}
|
|
699
692
|
return credential;
|
|
700
693
|
}
|
|
701
|
-
export async function
|
|
702
|
-
const [
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
694
|
+
export async function issuerMockCredential(inputs, context) {
|
|
695
|
+
const [openIdCredentialIssuer, nonce, requestedTypes, inputAlg] = inputs;
|
|
696
|
+
const alg = inputAlg || "ES256";
|
|
697
|
+
const clientId = context.client.didVersion === 1
|
|
698
|
+
? context.client.clientId
|
|
699
|
+
: context.client.did;
|
|
700
|
+
const iat = Math.floor(Date.now() / 1000);
|
|
701
|
+
const exp = iat + 5 * 60;
|
|
702
|
+
const jwtPayload = {
|
|
703
|
+
aud: openIdCredentialIssuer.credential_issuer,
|
|
704
|
+
exp,
|
|
705
|
+
iat,
|
|
706
|
+
iss: clientId,
|
|
707
|
+
nonce,
|
|
708
|
+
};
|
|
709
|
+
const proofJwt = await context.client.signJWT(jwtPayload, {
|
|
710
|
+
typ: "openid4vci-proof+jwt",
|
|
711
|
+
}, alg);
|
|
712
|
+
const responseCredential = await httpCall.post(`${openIdCredentialIssuer.credential_issuer}/credential`, {
|
|
713
|
+
format: "jwt_vc",
|
|
714
|
+
proof: {
|
|
715
|
+
jwt: proofJwt,
|
|
716
|
+
proof_type: "jwt",
|
|
717
|
+
},
|
|
718
|
+
types: requestedTypes,
|
|
719
|
+
}, context.httpOpts);
|
|
720
|
+
return responseCredential.data;
|
|
721
|
+
}
|
|
722
|
+
export async function issuerMockDeferred(inputs) {
|
|
723
|
+
const [openIdCredentialIssuer, acceptanceToken] = inputs;
|
|
724
|
+
const response = await httpCall.post(openIdCredentialIssuer.deferred_credential_endpoint, undefined, {
|
|
725
|
+
headers: {
|
|
726
|
+
authorization: `Bearer ${acceptanceToken}`,
|
|
715
727
|
},
|
|
716
|
-
intent,
|
|
717
728
|
});
|
|
718
|
-
if (!response.data.success) {
|
|
719
|
-
red(response.data.errors);
|
|
720
|
-
throw new Error(`check ${intent} failed: ${response.data.errors
|
|
721
|
-
? JSON.stringify(response.data.errors)
|
|
722
|
-
: "unknown error"}`);
|
|
723
|
-
}
|
|
724
729
|
return response.data;
|
|
725
730
|
}
|
|
726
|
-
export async function
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
return authMockDirectPostIdToken(inputs, context);
|
|
742
|
-
}
|
|
743
|
-
case "authMockDirectPostVpToken": {
|
|
744
|
-
return authMockDirectPostVpToken(inputs);
|
|
745
|
-
}
|
|
746
|
-
case "authMockToken": {
|
|
747
|
-
return authMockToken(inputs, context);
|
|
748
|
-
}
|
|
749
|
-
case "issuerMockCredential": {
|
|
750
|
-
return issuerMockCredential(inputs, context);
|
|
751
|
-
}
|
|
752
|
-
case "issuerMockDeferred": {
|
|
753
|
-
return issuerMockDeferred(inputs);
|
|
754
|
-
}
|
|
755
|
-
case "issuerMockInitiateCredentialOffer": {
|
|
756
|
-
return issuerMockInitiateCredentialOffer(inputs, context);
|
|
757
|
-
}
|
|
758
|
-
case "getCredential": {
|
|
759
|
-
return getCredential(inputs, context);
|
|
760
|
-
}
|
|
761
|
-
case "holder": {
|
|
762
|
-
return holder(inputs, context);
|
|
763
|
-
}
|
|
764
|
-
case "check": {
|
|
765
|
-
return check(inputs, context);
|
|
766
|
-
}
|
|
767
|
-
default:
|
|
768
|
-
throw new Error(`Invalid method '${method}'`);
|
|
731
|
+
export async function issuerMockInitiateCredentialOffer(inputs, context) {
|
|
732
|
+
const [initiateCredentialOfferEndpoint, credentialType] = inputs;
|
|
733
|
+
const requestParams = {
|
|
734
|
+
client_id: context.client.did,
|
|
735
|
+
credential_offer_endpoint: "openid-credential-offer://",
|
|
736
|
+
credential_type: credentialType,
|
|
737
|
+
};
|
|
738
|
+
let response = await httpCall.get(`${initiateCredentialOfferEndpoint}?${qs.stringify(requestParams)}`);
|
|
739
|
+
const search = credentialType.startsWith("CTWalletSame")
|
|
740
|
+
? new URL(response.headers.location).search
|
|
741
|
+
: new URL(response.data).search;
|
|
742
|
+
const parsedCredentialOffer = qs.parse(search.slice(1));
|
|
743
|
+
if (parsedCredentialOffer.credential_offer_uri) {
|
|
744
|
+
response = await httpCall.get(parsedCredentialOffer.credential_offer_uri);
|
|
745
|
+
return response.data;
|
|
769
746
|
}
|
|
747
|
+
return qs.parse(parsedCredentialOffer.credential_offer);
|
|
748
|
+
}
|
|
749
|
+
function stringify(obj, fields) {
|
|
750
|
+
if (typeof obj !== "object")
|
|
751
|
+
throw new Error("not an object");
|
|
752
|
+
const newObj = {};
|
|
753
|
+
for (const f of fields) {
|
|
754
|
+
if (obj[f])
|
|
755
|
+
newObj[f] = obj[f];
|
|
756
|
+
}
|
|
757
|
+
return JSON.stringify(newObj);
|
|
770
758
|
}
|
|
771
|
-
export default
|
|
772
|
-
//# sourceMappingURL=conformance
|
|
759
|
+
export default conformance;
|
|
760
|
+
//# sourceMappingURL=conformance.js.map
|