@twin.org/identity-cli 0.0.1-next.13 → 0.0.1-next.14

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.
@@ -14,8 +14,8 @@ var commander = require('commander');
14
14
  var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
15
15
  var entityStorageModels = require('@twin.org/entity-storage-models');
16
16
  var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
17
- var identityModels = require('@twin.org/identity-models');
18
17
  var standardsW3cDid = require('@twin.org/standards-w3c-did');
18
+ var identityModels = require('@twin.org/identity-models');
19
19
 
20
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
21
21
  // Copyright 2024 IOTA Stiftung.
@@ -264,18 +264,16 @@ async function actionCommandProofCreate(opts) {
264
264
  cliCore.CLIDisplay.break();
265
265
  cliCore.CLIDisplay.spinnerStart();
266
266
  const proof = await iotaIdentityConnector.createProof(localIdentity, id, data);
267
- const proofValue = core.Converter.bytesToBase64(proof.value);
268
267
  cliCore.CLIDisplay.spinnerStop();
269
268
  if (opts.console) {
270
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.type"), proof.type);
271
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.value"), proofValue);
269
+ cliCore.CLIDisplay.json(proof);
272
270
  cliCore.CLIDisplay.break();
273
271
  }
274
272
  if (core.Is.stringValue(opts?.json)) {
275
- await cliCore.CLIUtils.writeJsonFile(opts.json, { type: proof.type, value: proofValue }, opts.mergeJson);
273
+ await cliCore.CLIUtils.writeJsonFile(opts.json, { cryptosuite: proof.cryptosuite, value: proof.proofValue }, opts.mergeJson);
276
274
  }
277
275
  if (core.Is.stringValue(opts?.env)) {
278
- await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID_PROOF_TYPE="${proof.type}"`, `DID_PROOF_VALUE="${proofValue}"`], opts.mergeEnv);
276
+ await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID_CRYPTOSUITE="${proof.cryptosuite}"`, `DID_PROOF_VALUE="${proof.proofValue}"`], opts.mergeEnv);
279
277
  }
280
278
  cliCore.CLIDisplay.done();
281
279
  }
@@ -294,7 +292,7 @@ function buildCommandProofVerify() {
294
292
  .description(core.I18n.formatMessage("commands.proof-verify.description"))
295
293
  .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.id.param"), core.I18n.formatMessage("commands.proof-verify.options.id.description"))
296
294
  .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.data.param"), core.I18n.formatMessage("commands.proof-verify.options.data.description"))
297
- .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.type.param"), core.I18n.formatMessage("commands.proof-verify.options.type.description"))
295
+ .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.cryptosuite.param"), core.I18n.formatMessage("commands.proof-verify.options.cryptosuite.description"))
298
296
  .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.value.param"), core.I18n.formatMessage("commands.proof-verify.options.value.description"));
299
297
  cliCore.CLIOptions.output(command, {
300
298
  noConsole: true,
@@ -313,19 +311,19 @@ function buildCommandProofVerify() {
313
311
  * @param opts The options for the command.
314
312
  * @param opts.id The id of the verification method to use for the credential.
315
313
  * @param opts.data The data to verify the proof for.
316
- * @param opts.type The type of the proof.
314
+ * @param opts.cryptosuite The cryptosuite of the proof.
317
315
  * @param opts.value The proof value.
318
316
  * @param opts.node The node URL.
319
317
  */
320
318
  async function actionCommandProofVerify(opts) {
321
319
  const id = cliCore.CLIParam.stringValue("id", opts.id);
322
320
  const data = cliCore.CLIParam.hexBase64("data", opts.data);
323
- const type = cliCore.CLIParam.stringValue("type", opts.type);
324
- const value = cliCore.CLIParam.hexBase64("value", opts.value);
321
+ const cryptosuite = cliCore.CLIParam.stringValue("cryptosuite", opts.cryptosuite);
322
+ const value = cliCore.CLIParam.stringValue("value", opts.value);
325
323
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
326
324
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
327
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.type"), type);
328
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.value"), core.Converter.bytesToBase64(value));
325
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.cryptosuite"), cryptosuite);
326
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.value"), value);
329
327
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
330
328
  cliCore.CLIDisplay.break();
331
329
  setupVault();
@@ -349,7 +347,15 @@ async function actionCommandProofVerify(opts) {
349
347
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.proof-verify.progress.verifyingProof"));
350
348
  cliCore.CLIDisplay.break();
351
349
  cliCore.CLIDisplay.spinnerStart();
352
- const isVerified = await iotaIdentityConnector.verifyProof(id, data, type, value);
350
+ const proof = {
351
+ "@context": standardsW3cDid.DidContexts.ContextVCDataIntegrity,
352
+ type: standardsW3cDid.DidTypes.DataIntegrityProof,
353
+ verificationMethod: id,
354
+ cryptosuite,
355
+ proofPurpose: "assertionMethod",
356
+ proofValue: value
357
+ };
358
+ const isVerified = await iotaIdentityConnector.verifyProof(data, proof);
353
359
  cliCore.CLIDisplay.spinnerStop();
354
360
  if (opts.console) {
355
361
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.isVerified"), isVerified);
@@ -12,8 +12,8 @@ import { Command, Option } from 'commander';
12
12
  import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
13
13
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
14
14
  import { initSchema, EntityStorageVaultConnector } from '@twin.org/vault-connector-entity-storage';
15
+ import { DidContexts, DidTypes, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
15
16
  import { DocumentHelper } from '@twin.org/identity-models';
16
- import { DidVerificationMethodType } from '@twin.org/standards-w3c-did';
17
17
 
18
18
  // Copyright 2024 IOTA Stiftung.
19
19
  // SPDX-License-Identifier: Apache-2.0.
@@ -261,18 +261,16 @@ async function actionCommandProofCreate(opts) {
261
261
  CLIDisplay.break();
262
262
  CLIDisplay.spinnerStart();
263
263
  const proof = await iotaIdentityConnector.createProof(localIdentity, id, data);
264
- const proofValue = Converter.bytesToBase64(proof.value);
265
264
  CLIDisplay.spinnerStop();
266
265
  if (opts.console) {
267
- CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.type"), proof.type);
268
- CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.value"), proofValue);
266
+ CLIDisplay.json(proof);
269
267
  CLIDisplay.break();
270
268
  }
271
269
  if (Is.stringValue(opts?.json)) {
272
- await CLIUtils.writeJsonFile(opts.json, { type: proof.type, value: proofValue }, opts.mergeJson);
270
+ await CLIUtils.writeJsonFile(opts.json, { cryptosuite: proof.cryptosuite, value: proof.proofValue }, opts.mergeJson);
273
271
  }
274
272
  if (Is.stringValue(opts?.env)) {
275
- await CLIUtils.writeEnvFile(opts.env, [`DID_PROOF_TYPE="${proof.type}"`, `DID_PROOF_VALUE="${proofValue}"`], opts.mergeEnv);
273
+ await CLIUtils.writeEnvFile(opts.env, [`DID_CRYPTOSUITE="${proof.cryptosuite}"`, `DID_PROOF_VALUE="${proof.proofValue}"`], opts.mergeEnv);
276
274
  }
277
275
  CLIDisplay.done();
278
276
  }
@@ -291,7 +289,7 @@ function buildCommandProofVerify() {
291
289
  .description(I18n.formatMessage("commands.proof-verify.description"))
292
290
  .requiredOption(I18n.formatMessage("commands.proof-verify.options.id.param"), I18n.formatMessage("commands.proof-verify.options.id.description"))
293
291
  .requiredOption(I18n.formatMessage("commands.proof-verify.options.data.param"), I18n.formatMessage("commands.proof-verify.options.data.description"))
294
- .requiredOption(I18n.formatMessage("commands.proof-verify.options.type.param"), I18n.formatMessage("commands.proof-verify.options.type.description"))
292
+ .requiredOption(I18n.formatMessage("commands.proof-verify.options.cryptosuite.param"), I18n.formatMessage("commands.proof-verify.options.cryptosuite.description"))
295
293
  .requiredOption(I18n.formatMessage("commands.proof-verify.options.value.param"), I18n.formatMessage("commands.proof-verify.options.value.description"));
296
294
  CLIOptions.output(command, {
297
295
  noConsole: true,
@@ -310,19 +308,19 @@ function buildCommandProofVerify() {
310
308
  * @param opts The options for the command.
311
309
  * @param opts.id The id of the verification method to use for the credential.
312
310
  * @param opts.data The data to verify the proof for.
313
- * @param opts.type The type of the proof.
311
+ * @param opts.cryptosuite The cryptosuite of the proof.
314
312
  * @param opts.value The proof value.
315
313
  * @param opts.node The node URL.
316
314
  */
317
315
  async function actionCommandProofVerify(opts) {
318
316
  const id = CLIParam.stringValue("id", opts.id);
319
317
  const data = CLIParam.hexBase64("data", opts.data);
320
- const type = CLIParam.stringValue("type", opts.type);
321
- const value = CLIParam.hexBase64("value", opts.value);
318
+ const cryptosuite = CLIParam.stringValue("cryptosuite", opts.cryptosuite);
319
+ const value = CLIParam.stringValue("value", opts.value);
322
320
  const nodeEndpoint = CLIParam.url("node", opts.node);
323
321
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
324
- CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.type"), type);
325
- CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.value"), Converter.bytesToBase64(value));
322
+ CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.cryptosuite"), cryptosuite);
323
+ CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.value"), value);
326
324
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
327
325
  CLIDisplay.break();
328
326
  setupVault();
@@ -346,7 +344,15 @@ async function actionCommandProofVerify(opts) {
346
344
  CLIDisplay.task(I18n.formatMessage("commands.proof-verify.progress.verifyingProof"));
347
345
  CLIDisplay.break();
348
346
  CLIDisplay.spinnerStart();
349
- const isVerified = await iotaIdentityConnector.verifyProof(id, data, type, value);
347
+ const proof = {
348
+ "@context": DidContexts.ContextVCDataIntegrity,
349
+ type: DidTypes.DataIntegrityProof,
350
+ verificationMethod: id,
351
+ cryptosuite,
352
+ proofPurpose: "assertionMethod",
353
+ proofValue: value
354
+ };
355
+ const isVerified = await iotaIdentityConnector.verifyProof(data, proof);
350
356
  CLIDisplay.spinnerStop();
351
357
  if (opts.console) {
352
358
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.isVerified"), isVerified);
@@ -8,6 +8,10 @@
8
8
  "beTextMinMax": "{fieldName} must be longer than {minLength} and shorter than {maxLength} characters",
9
9
  "beTextMin": "{fieldName} must be longer than {minLength} characters",
10
10
  "beTextMax": "{fieldName} must be shorter than {maxLength} characters",
11
+ "beTextBase58": "{fieldName} must be text formatted using Base58 characters",
12
+ "beTextBase64": "{fieldName} must be text formatted using Base64 characters",
13
+ "beTextHex": "{fieldName} must be text formatted using Hex characters",
14
+ "beTextRegExp": "{fieldName} must be text formatted using the matching pattern {format}",
11
15
  "beNumber": "{fieldName} must be a number",
12
16
  "beNumberMinMax": "{fieldName} must be >= {minValue} and <= {maxValue}",
13
17
  "beNumberMin": "{fieldName} must be >= {minValue}",
@@ -50,6 +54,7 @@
50
54
  "stringEmpty": "Property \"{property}\" must have a value, it is empty",
51
55
  "stringBase64": "Property \"{property}\" must be a base64 encoded string, it is \"{value}\"",
52
56
  "stringBase64Url": "Property \"{property}\" must be a base64 url encoded string, it is \"{value}\"",
57
+ "stringBase58": "Property \"{property}\" must be a base58 encoded string, it is \"{value}\"",
53
58
  "stringHex": "Property \"{property}\" must be a hex string, it is \"{value}\"",
54
59
  "stringHexLength": "Property \"{property}\" must be a hex string of length \"{options}\", it is \"{value}\"",
55
60
  "number": "Property \"{property}\" must be a number, it is \"{value}\"",
@@ -89,6 +94,15 @@
89
94
  "bitString": {
90
95
  "outOfRange": "The index should be >= 0 and less than the length of the bit string"
91
96
  },
97
+ "base32": {
98
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
99
+ },
100
+ "base64": {
101
+ "length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
102
+ },
103
+ "base58": {
104
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
105
+ },
92
106
  "bip39": {
93
107
  "missingMnemonicWord": "The mnemonic contains a word not in the wordlist, \"{value}\"",
94
108
  "checksumMismatch": "The checksum does not match \"{newChecksum}\" != \"{checksumBits}\""
@@ -114,18 +128,15 @@
114
128
  "sha256": {
115
129
  "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
116
130
  },
131
+ "sha3": {
132
+ "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
133
+ },
117
134
  "hmacSha256": {
118
135
  "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
119
136
  },
120
137
  "hmacSha512": {
121
138
  "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
122
139
  },
123
- "base32": {
124
- "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
125
- },
126
- "base64": {
127
- "length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
128
- },
129
140
  "bech32": {
130
141
  "decodeFailed": "The address contains decoding failed for address \"{bech32}\"",
131
142
  "invalidChecksum": "The address contains an invalid checksum in address, \"{bech32}\"",
@@ -210,7 +221,9 @@
210
221
  "unrevokeVerifiableCredentialsFailed": "Unrevoking verifiable credentials failed",
211
222
  "inclusionFailed": "The transaction generated for the identity was not included in a reasonable amount of time",
212
223
  "insufficientFunds": "There were insufficient funds to complete the operation",
213
- "walletConnectorMissing": "The wallet connector must be available to perform this operation"
224
+ "walletConnectorMissing": "The wallet connector must be available to perform this operation",
225
+ "proofType": "The proof type must be DataIntegrityProof, it is currently {proofType}",
226
+ "cryptosuite": "The proof cryptosuite must be eddsa-jcs-2022, it is currently {cryptosuite}"
214
227
  },
215
228
  "iota": {
216
229
  "inclusionFailed": "The transaction generated was not included in a reasonable amount of time",
@@ -721,9 +734,7 @@
721
734
  "creatingProof": "Creating Proof"
722
735
  },
723
736
  "labels": {
724
- "verificationMethodId": "Verification Method Id",
725
- "type": "Proof Type",
726
- "value": "Proof Value"
737
+ "verificationMethodId": "Verification Method Id"
727
738
  }
728
739
  },
729
740
  "proof-verify": {
@@ -738,9 +749,9 @@
738
749
  "param": "--data '<'data'>'",
739
750
  "description": "The base64 or hex encoded data to verify the proof for, or start with ! to read environment variable."
740
751
  },
741
- "type": {
742
- "param": "--type '<'type'>'",
743
- "description": "The type of the proof, or start with ! to read environment variable."
752
+ "cryptosuite": {
753
+ "param": "--cryptosuite '<'cryptosuite'>'",
754
+ "description": "The cryptosuite of the proof, or start with ! to read environment variable."
744
755
  },
745
756
  "value": {
746
757
  "param": "--value '<'value'>'",
@@ -752,7 +763,7 @@
752
763
  },
753
764
  "labels": {
754
765
  "verificationMethodId": "Verification Method Id",
755
- "type": "Proof Type",
766
+ "cryptosuite": "Proof Cryptosuite",
756
767
  "value": "Proof Value",
757
768
  "isVerified": "Is Verified"
758
769
  }
@@ -10,14 +10,14 @@ export declare function buildCommandProofVerify(): Command;
10
10
  * @param opts The options for the command.
11
11
  * @param opts.id The id of the verification method to use for the credential.
12
12
  * @param opts.data The data to verify the proof for.
13
- * @param opts.type The type of the proof.
13
+ * @param opts.cryptosuite The cryptosuite of the proof.
14
14
  * @param opts.value The proof value.
15
15
  * @param opts.node The node URL.
16
16
  */
17
17
  export declare function actionCommandProofVerify(opts: {
18
18
  id: string;
19
19
  data: string;
20
- type: string;
20
+ cryptosuite: string;
21
21
  value: string;
22
22
  node: string;
23
23
  } & CliOutputOptions): Promise<void>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/identity-cli - Changelog
2
2
 
3
- ## v0.0.1-next.13
3
+ ## v0.0.1-next.14
4
4
 
5
5
  - Initial Release
package/docs/examples.md CHANGED
@@ -207,5 +207,5 @@ This will output the proof as a set of data containing the type and a value in b
207
207
  This command will verify a proof using the specified verification method.
208
208
 
209
209
  ```shell
210
- twin-identity proof-verify --load-env config.env verification-method.env --id !DID_VERIFICATION_METHOD_ID --data aGVsbG8gd29ybGQ= --type Ed25519 --value lrPdZ+Gfgc8w/ha2YU7hil8s+gykFHAdmIEdJdraWeRkkb8nHHF1PLKs4gGPXCT1mqBIwiwOgz5V0JKIg00UDg==
210
+ twin-identity proof-verify --load-env config.env verification-method.env --id !DID_VERIFICATION_METHOD_ID --data aGVsbG8gd29ybGQ= --cryptosuite eddsa-jcs-2022 --value 5LVrNuqQzQxnLMxwwpkE1smcD9Zpygg3gvJ6xvwdcLGrhk4yXFW8jewGY5Z3kRMKL1dasqw6ABBCcNgUv1pngnzA
211
211
  ```
package/locales/en.json CHANGED
@@ -272,9 +272,7 @@
272
272
  "creatingProof": "Creating Proof"
273
273
  },
274
274
  "labels": {
275
- "verificationMethodId": "Verification Method Id",
276
- "type": "Proof Type",
277
- "value": "Proof Value"
275
+ "verificationMethodId": "Verification Method Id"
278
276
  }
279
277
  },
280
278
  "proof-verify": {
@@ -289,9 +287,9 @@
289
287
  "param": "--data '<'data'>'",
290
288
  "description": "The base64 or hex encoded data to verify the proof for, or start with ! to read environment variable."
291
289
  },
292
- "type": {
293
- "param": "--type '<'type'>'",
294
- "description": "The type of the proof, or start with ! to read environment variable."
290
+ "cryptosuite": {
291
+ "param": "--cryptosuite '<'cryptosuite'>'",
292
+ "description": "The cryptosuite of the proof, or start with ! to read environment variable."
295
293
  },
296
294
  "value": {
297
295
  "param": "--value '<'value'>'",
@@ -303,7 +301,7 @@
303
301
  },
304
302
  "labels": {
305
303
  "verificationMethodId": "Verification Method Id",
306
- "type": "Proof Type",
304
+ "cryptosuite": "Proof Cryptosuite",
307
305
  "value": "Proof Value",
308
306
  "isVerified": "Is Verified"
309
307
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-cli",
3
- "version": "0.0.1-next.13",
3
+ "version": "0.0.1-next.14",
4
4
  "description": "A command line interface for interacting with the identity connectors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "@twin.org/data-json-ld": "next",
23
23
  "@twin.org/entity": "next",
24
24
  "@twin.org/entity-storage-connector-memory": "next",
25
- "@twin.org/identity-connector-iota": "0.0.1-next.13",
26
- "@twin.org/identity-models": "0.0.1-next.13",
25
+ "@twin.org/identity-connector-iota": "0.0.1-next.14",
26
+ "@twin.org/identity-models": "0.0.1-next.14",
27
27
  "@twin.org/nameof": "next",
28
28
  "@twin.org/standards-w3c-did": "next",
29
29
  "@twin.org/vault-connector-entity-storage": "next",