@cef-ebsi/cli 1.3.1 → 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.
Files changed (187) hide show
  1. package/bin/cli.js +1 -1
  2. package/dist/abi/pilot/DidRegistry.js +568 -0
  3. package/dist/abi/pilot/DidRegistry.js.map +1 -0
  4. package/dist/abi/pilot/SchemaSCRegistry.js +264 -0
  5. package/dist/abi/pilot/SchemaSCRegistry.js.map +1 -0
  6. package/dist/abi/pilot/Timestamp.js +658 -0
  7. package/dist/abi/pilot/Timestamp.js.map +1 -0
  8. package/dist/abi/pilot/Tir.js +428 -0
  9. package/dist/abi/pilot/Tir.js.map +1 -0
  10. package/dist/abi/pilot/TnT.js +842 -0
  11. package/dist/abi/pilot/TnT.js.map +1 -0
  12. package/dist/abi/pilot/Tpr.js +492 -0
  13. package/dist/abi/pilot/Tpr.js.map +1 -0
  14. package/dist/abi/test/DidRegistry.js +144 -658
  15. package/dist/abi/test/DidRegistry.js.map +1 -1
  16. package/dist/abi/test/SchemaSCRegistry.js +101 -810
  17. package/dist/abi/test/SchemaSCRegistry.js.map +1 -1
  18. package/dist/abi/test/Timestamp.js +239 -673
  19. package/dist/abi/test/Timestamp.js.map +1 -1
  20. package/dist/abi/test/Tir.js +167 -636
  21. package/dist/abi/test/Tir.js.map +1 -1
  22. package/dist/abi/test/TnT.js +842 -0
  23. package/dist/abi/test/TnT.js.map +1 -0
  24. package/dist/abi/test/Tpr.js +166 -942
  25. package/dist/abi/test/Tpr.js.map +1 -1
  26. package/dist/app.js +444 -443
  27. package/dist/app.js.map +1 -1
  28. package/dist/buildParam/{didV3.js → didr.js} +182 -204
  29. package/dist/buildParam/didr.js.map +1 -0
  30. package/dist/buildParam/index.js +32 -48
  31. package/dist/buildParam/index.js.map +1 -1
  32. package/dist/buildParam/{timestampV2.js → timestamp.js} +137 -136
  33. package/dist/buildParam/timestamp.js.map +1 -0
  34. package/dist/buildParam/{tirV3.js → tir.js} +57 -59
  35. package/dist/buildParam/tir.js.map +1 -0
  36. package/dist/buildParam/{tntV2.js → tnt.js} +62 -61
  37. package/dist/buildParam/tnt.js.map +1 -0
  38. package/dist/buildParam/{tprV2.js → tpr.js} +34 -33
  39. package/dist/buildParam/tpr.js.map +1 -0
  40. package/dist/buildParam/{tsrV2.js → tsr.js} +39 -38
  41. package/dist/buildParam/tsr.js.map +1 -0
  42. package/dist/cli.js +1 -0
  43. package/dist/cli.js.map +1 -1
  44. package/dist/commands/{authorisation-v4.js → authorisation.js} +78 -71
  45. package/dist/commands/authorisation.js.map +1 -0
  46. package/dist/commands/compute.js +389 -389
  47. package/dist/commands/compute.js.map +1 -1
  48. package/dist/commands/{conformance-v3.js → conformance.js} +236 -248
  49. package/dist/commands/conformance.js.map +1 -0
  50. package/dist/commands/hardwarewallet.js +5 -5
  51. package/dist/commands/hardwarewallet.js.map +1 -1
  52. package/dist/commands/index.js +4 -4
  53. package/dist/commands/index.js.map +1 -1
  54. package/dist/commands/{ledger-v4.js → ledger.js} +141 -128
  55. package/dist/commands/ledger.js.map +1 -0
  56. package/dist/commands/tnl.js +10 -9
  57. package/dist/commands/tnl.js.map +1 -1
  58. package/dist/commands/tsr.js +46 -0
  59. package/dist/commands/tsr.js.map +1 -0
  60. package/dist/commands/view.js +8 -8
  61. package/dist/commands/view.js.map +1 -1
  62. package/dist/config.js +280 -279
  63. package/dist/config.js.map +1 -1
  64. package/dist/index.js +3 -3
  65. package/dist/index.js.map +1 -1
  66. package/dist/interfaces/index.js +1 -1
  67. package/dist/interfaces/index.js.map +1 -1
  68. package/dist/programs/migrateDid.js +33 -33
  69. package/dist/programs/migrateDid.js.map +1 -1
  70. package/dist/programs/migrateDids.js +39 -42
  71. package/dist/programs/migrateDids.js.map +1 -1
  72. package/dist/programs/migrateTsr.js +109 -113
  73. package/dist/programs/migrateTsr.js.map +1 -1
  74. package/dist/scripts/accreditAndAuthorize/conformance/step1 +1 -1
  75. package/dist/scripts/accreditAndAuthorize/test/step1 +1 -1
  76. package/dist/scripts/accreditTI +1 -1
  77. package/dist/scripts/assets/CTRevocableCredential.json +1 -1
  78. package/dist/scripts/assets/CredentialToAttestVerifiableAuthorisationForTrustChain.json +2 -2
  79. package/dist/scripts/assets/TrustedNodesList.json +1 -1
  80. package/dist/scripts/assets/VerifiableAccreditationToAccredit.json +2 -2
  81. package/dist/scripts/assets/VerifiableAccreditationToAttest.json +2 -2
  82. package/dist/scripts/assets/VerifiableAuthorisationForTrustChain.json +1 -1
  83. package/dist/scripts/assets/VerifiableAuthorisationToOnboard.json +1 -1
  84. package/dist/scripts/bootstrap/6-setupConformanceIssuer +1 -1
  85. package/dist/scripts/issueVcOnboard +1 -1
  86. package/dist/scripts/issueVcRootTAO +1 -1
  87. package/dist/scripts/issueVcTAO +2 -2
  88. package/dist/scripts/issueVcTI +2 -2
  89. package/dist/scripts/issueVcTnl +1 -1
  90. package/dist/scripts/issue_CTRevocableCredential +1 -1
  91. package/dist/scripts/issue_SelfAttestationSupportOffice +2 -2
  92. package/dist/scripts/issue_VerifiableAccreditationToAccredit +2 -2
  93. package/dist/scripts/issue_VerifiableAccreditationToAttest +2 -2
  94. package/dist/scripts/issue_VerifiableAuthorisationForTrustChain +1 -1
  95. package/dist/scripts/issue_VerifiableAuthorisationToOnboard +1 -1
  96. package/dist/scripts/updateVcRootTAO +1 -1
  97. package/dist/scripts/updateVcTAO +2 -2
  98. package/dist/scripts/updateVcTI +2 -2
  99. package/dist/scripts/{wctv3 → wct}/accreditAndAuthorize +1 -1
  100. package/dist/tsconfig.build.tsbuildinfo +1 -0
  101. package/dist/utils/Client.js +81 -68
  102. package/dist/utils/Client.js.map +1 -1
  103. package/dist/utils/HardwareWallet.js +169 -165
  104. package/dist/utils/HardwareWallet.js.map +1 -1
  105. package/dist/utils/http.js +24 -27
  106. package/dist/utils/http.js.map +1 -1
  107. package/dist/utils/index.js +3 -3
  108. package/dist/utils/index.js.map +1 -1
  109. package/dist/utils/jsonrpc.js +14 -14
  110. package/dist/utils/jsonrpc.js.map +1 -1
  111. package/dist/utils/print.js +19 -19
  112. package/dist/utils/print.js.map +1 -1
  113. package/dist/utils/utils.js +180 -173
  114. package/dist/utils/utils.js.map +1 -1
  115. package/package.json +70 -46
  116. package/dist/abi/pilot/DidRegistryV3.js +0 -1082
  117. package/dist/abi/pilot/DidRegistryV3.js.map +0 -1
  118. package/dist/abi/pilot/DidRegistryV4.js +0 -942
  119. package/dist/abi/pilot/DidRegistryV4.js.map +0 -1
  120. package/dist/abi/pilot/SchemaSCRegistryV2.js +0 -474
  121. package/dist/abi/pilot/SchemaSCRegistryV2.js.map +0 -1
  122. package/dist/abi/pilot/TimestampV2.js +0 -1128
  123. package/dist/abi/pilot/TimestampV2.js.map +0 -1
  124. package/dist/abi/pilot/TimestampV3.js +0 -995
  125. package/dist/abi/pilot/TimestampV3.js.map +0 -1
  126. package/dist/abi/pilot/TirV3.js +0 -496
  127. package/dist/abi/pilot/TirV3.js.map +0 -1
  128. package/dist/abi/pilot/TirV4.js +0 -710
  129. package/dist/abi/pilot/TirV4.js.map +0 -1
  130. package/dist/abi/pilot/TnTV1.js +0 -1375
  131. package/dist/abi/pilot/TnTV1.js.map +0 -1
  132. package/dist/abi/pilot/TprV2.js +0 -889
  133. package/dist/abi/pilot/TprV2.js.map +0 -1
  134. package/dist/abi/pilot/TprV3.js +0 -707
  135. package/dist/abi/pilot/TprV3.js.map +0 -1
  136. package/dist/abi/pilot/TsrV3.js +0 -571
  137. package/dist/abi/pilot/TsrV3.js.map +0 -1
  138. package/dist/abi/test/DidRegistryV3.js +0 -1089
  139. package/dist/abi/test/DidRegistryV3.js.map +0 -1
  140. package/dist/abi/test/DidRegistryV4.js +0 -960
  141. package/dist/abi/test/DidRegistryV4.js.map +0 -1
  142. package/dist/abi/test/SchemaSCRegistryV2.js +0 -474
  143. package/dist/abi/test/SchemaSCRegistryV2.js.map +0 -1
  144. package/dist/abi/test/TimestampV2.js +0 -1128
  145. package/dist/abi/test/TimestampV2.js.map +0 -1
  146. package/dist/abi/test/TimestampV3.js +0 -995
  147. package/dist/abi/test/TimestampV3.js.map +0 -1
  148. package/dist/abi/test/TirV3.js +0 -496
  149. package/dist/abi/test/TirV3.js.map +0 -1
  150. package/dist/abi/test/TirV4.js +0 -710
  151. package/dist/abi/test/TirV4.js.map +0 -1
  152. package/dist/abi/test/TnTV1.js +0 -1375
  153. package/dist/abi/test/TnTV1.js.map +0 -1
  154. package/dist/abi/test/TprV2.js +0 -889
  155. package/dist/abi/test/TprV2.js.map +0 -1
  156. package/dist/abi/test/TprV3.js +0 -707
  157. package/dist/abi/test/TprV3.js.map +0 -1
  158. package/dist/abi/test/TsrV3.js +0 -571
  159. package/dist/abi/test/TsrV3.js.map +0 -1
  160. package/dist/buildParam/didV3.js.map +0 -1
  161. package/dist/buildParam/didV4.js +0 -326
  162. package/dist/buildParam/didV4.js.map +0 -1
  163. package/dist/buildParam/timestampV2.js.map +0 -1
  164. package/dist/buildParam/timestampV3.js +0 -317
  165. package/dist/buildParam/timestampV3.js.map +0 -1
  166. package/dist/buildParam/tirV3.js.map +0 -1
  167. package/dist/buildParam/tirV4.js +0 -119
  168. package/dist/buildParam/tirV4.js.map +0 -1
  169. package/dist/buildParam/tntV1.js +0 -185
  170. package/dist/buildParam/tntV1.js.map +0 -1
  171. package/dist/buildParam/tntV2.js.map +0 -1
  172. package/dist/buildParam/tprV2.js.map +0 -1
  173. package/dist/buildParam/tprV3.js +0 -82
  174. package/dist/buildParam/tprV3.js.map +0 -1
  175. package/dist/buildParam/tsrV2.js.map +0 -1
  176. package/dist/buildParam/tsrV3.js +0 -110
  177. package/dist/buildParam/tsrV3.js.map +0 -1
  178. package/dist/commands/authorisation-v4.js.map +0 -1
  179. package/dist/commands/authorisation-v5.js +0 -119
  180. package/dist/commands/authorisation-v5.js.map +0 -1
  181. package/dist/commands/conformance-v3.js.map +0 -1
  182. package/dist/commands/ledger-v4.js.map +0 -1
  183. package/dist/tsconfig.tsbuildinfo +0 -1
  184. /package/dist/scripts/{wctv3 → wct}/holderWallet +0 -0
  185. /package/dist/scripts/{wctv3 → wct}/issueToHolder +0 -0
  186. /package/dist/scripts/{wctv3 → wct}/pda1 +0 -0
  187. /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 { compute, getUserPin } from "./compute.js";
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
- function stringify(obj, fields) {
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
- client_metadata: clientMetadata,
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.substring(1));
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 { state, nonce } = issuerRequest;
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.substring(1));
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.substring(1));
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
- let queryParams;
285
- if (type === "preAuthorised") {
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 issuerMockCredential(inputs, context) {
330
- const [openIdCredentialIssuer, nonce, requestedTypes, inputAlg] = inputs;
331
- const alg = inputAlg || "ES256";
332
- const clientId = context.client.didVersion === 1
333
- ? context.client.clientId
334
- : context.client.did;
335
- const iat = Math.floor(Date.now() / 1000);
336
- const exp = iat + 5 * 60;
337
- const jwtPayload = {
338
- nonce,
339
- iss: clientId,
340
- aud: openIdCredentialIssuer.credential_issuer,
341
- iat,
342
- exp,
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
- }, context.httpOpts);
355
- return responseCredential.data;
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 issuerMockDeferred(inputs) {
358
- const [openIdCredentialIssuer, acceptanceToken] = inputs;
359
- const response = await httpCall.post(openIdCredentialIssuer.deferred_credential_endpoint, undefined, {
360
- headers: {
361
- authorization: `Bearer ${acceptanceToken}`,
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 issuerMockInitiateCredentialOffer(inputs, context) {
367
- const [initiateCredentialOfferEndpoint, credentialType] = inputs;
368
- const requestParams = {
369
- credential_type: credentialType,
370
- credential_offer_endpoint: "openid-credential-offer://",
371
- client_id: context.client.did,
372
- };
373
- let response = await httpCall.get(`${initiateCredentialOfferEndpoint}?${qs.stringify(requestParams)}`);
374
- let search;
375
- if (credentialType.startsWith("CTWalletSame")) {
376
- search = new URL(response.headers.location)
377
- .search;
378
- }
379
- else {
380
- search = new URL(response.data).search;
381
- }
382
- const parsedCredentialOffer = qs.parse(search.slice(1));
383
- if (parsedCredentialOffer.credential_offer_uri) {
384
- response = await httpCall.get(parsedCredentialOffer.credential_offer_uri);
385
- return response.data;
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
- return qs.parse(parsedCredentialOffer.credential_offer);
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
- if (inputIssuer.startsWith("http")) {
397
- openIdCredentialIssuerUrl = `${inputIssuer}/.well-known/openid-credential-issuer`;
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 "onboard": {
403
+ case "ctrevocable": {
410
404
  requestedTypes = [
411
405
  "VerifiableCredential",
412
406
  "VerifiableAttestation",
413
- "VerifiableAuthorisationToOnboard",
407
+ "CTRevocable",
414
408
  ];
415
409
  break;
416
410
  }
417
- case "ti": {
411
+ case "onboard": {
418
412
  requestedTypes = [
419
413
  "VerifiableCredential",
420
414
  "VerifiableAttestation",
421
- "VerifiableAccreditation",
422
- "VerifiableAccreditationToAttest",
415
+ "VerifiableAuthorisationToOnboard",
423
416
  ];
424
417
  break;
425
418
  }
426
- case "tao": {
419
+ case "qualification": {
427
420
  requestedTypes = [
428
421
  "VerifiableCredential",
429
422
  "VerifiableAttestation",
430
- "VerifiableAccreditation",
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 "ctrevocable": {
435
+ case "tao": {
444
436
  requestedTypes = [
445
437
  "VerifiableCredential",
446
438
  "VerifiableAttestation",
447
- "CTRevocable",
439
+ "VerifiableAccreditation",
440
+ "VerifiableAccreditationToAccredit",
448
441
  ];
449
442
  break;
450
443
  }
451
- case "qualification": {
444
+ case "ti": {
452
445
  requestedTypes = [
453
446
  "VerifiableCredential",
454
447
  "VerifiableAttestation",
455
- "CTAAQualificationCredential",
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 (!useCredentialOffer) {
598
- if (isPreauthorised)
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
- credentialOffer = await issuerMockInitiateCredentialOffer([initiateCredentialOfferEndpoint, credentialType], context);
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 check(inputs, context) {
702
- const [intent, preAuthorizedCode, userPin] = inputs;
703
- const apiUrl = context.config.api.conformance.url;
704
- const response = await httpCall.post(`${apiUrl}/check`, {
705
- data: {
706
- clientId: context.client.clientId,
707
- did: context.client.did,
708
- credentialIssuer: context.client.clientId,
709
- credentialIssuerDid: context.client.did,
710
- issuerState: context.client.issuerState,
711
- ...(preAuthorizedCode && {
712
- preAuthorizedCode,
713
- userPin,
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 conformanceV3(method, inputs, context) {
727
- switch (method) {
728
- case "get": {
729
- return conformanceGet(inputs, context);
730
- }
731
- case "clientMockInitiate": {
732
- return clientMockInitiate(context);
733
- }
734
- case "clientMockUpdateList": {
735
- return clientMockUpdateList(inputs, context);
736
- }
737
- case "authMockAuthorize": {
738
- return authMockAuthorize(inputs, context);
739
- }
740
- case "authMockDirectPostIdToken": {
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 conformanceV3;
772
- //# sourceMappingURL=conformance-v3.js.map
759
+ export default conformance;
760
+ //# sourceMappingURL=conformance.js.map