@trustvc/trustvc 2.2.0 → 2.3.1
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var w3cIssuer = require('@trustvc/w3c-issuer');
|
|
4
3
|
var w3c = require('../w3c');
|
|
5
4
|
var w3cCredentialStatus = require('@trustvc/w3c-credential-status');
|
|
6
5
|
var w3cVc = require('@trustvc/w3c-vc');
|
|
@@ -106,6 +105,11 @@ class DocumentBuilder {
|
|
|
106
105
|
// Sign the document using the provided private key and an optional cryptographic suite.
|
|
107
106
|
async sign(privateKey, cryptoSuite, options) {
|
|
108
107
|
if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
|
|
108
|
+
if (cryptoSuite === "BbsBlsSignature2020") {
|
|
109
|
+
throw new Error(
|
|
110
|
+
"BbsBlsSignature2020 is no longer supported. Please use the latest cryptosuite versions instead"
|
|
111
|
+
);
|
|
112
|
+
}
|
|
109
113
|
if (this.selectedStatusType) {
|
|
110
114
|
this.document.credentialStatus = this.statusConfig;
|
|
111
115
|
}
|
|
@@ -123,11 +127,7 @@ class DocumentBuilder {
|
|
|
123
127
|
}
|
|
124
128
|
this.document.issuer = privateKey.id.split("#")[0];
|
|
125
129
|
this.document.validFrom = this.document.validFrom || (/* @__PURE__ */ new Date()).toISOString();
|
|
126
|
-
|
|
127
|
-
this.addContext(w3cContext.DATA_INTEGRITY_V2_URL);
|
|
128
|
-
} else {
|
|
129
|
-
this.addContext(w3cContext.BBS_V1_URL);
|
|
130
|
-
}
|
|
130
|
+
this.addContext(w3cContext.DATA_INTEGRITY_V2_URL);
|
|
131
131
|
const signedVC = await w3c.signW3C(this.document, privateKey, cryptoSuite, options);
|
|
132
132
|
if (signedVC.error) throw new Error(`Signing Error: ${signedVC.error}`);
|
|
133
133
|
this.isSigned = true;
|
|
@@ -148,8 +148,7 @@ class DocumentBuilder {
|
|
|
148
148
|
// Verify the document.
|
|
149
149
|
async verify() {
|
|
150
150
|
if (!this.isSigned) throw new Error("Verification Error: Document is not signed yet.");
|
|
151
|
-
|
|
152
|
-
if (cryptosuite === w3cIssuer.CryptoSuite.EcdsaSd2023 && !this.isDerived) {
|
|
151
|
+
if (!this.isDerived) {
|
|
153
152
|
throw new Error("Verification Error: Document is not derived yet. Use derive() first.");
|
|
154
153
|
}
|
|
155
154
|
const verificationResult = await w3c.verifyW3CSignature(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CryptoSuite } from '@trustvc/w3c-issuer';
|
|
2
1
|
import { signW3C, deriveW3C, verifyW3CSignature } from '../w3c';
|
|
3
2
|
import { assertCredentialStatus, assertTransferableRecords } from '@trustvc/w3c-credential-status';
|
|
4
3
|
import { verifyCredentialStatus } from '@trustvc/w3c-vc';
|
|
@@ -8,7 +7,7 @@ import { constants as constants$1 } from '@tradetrust-tt/token-registry-v5';
|
|
|
8
7
|
import { v4Contracts } from '../token-registry-v4';
|
|
9
8
|
import { v5Contracts } from '../token-registry-v5';
|
|
10
9
|
import { SUPPORTED_CHAINS } from '../utils';
|
|
11
|
-
import { TR_CONTEXT_URL, RENDER_CONTEXT_V2_URL, QRCODE_CONTEXT_URL, DATA_INTEGRITY_V2_URL,
|
|
10
|
+
import { TR_CONTEXT_URL, RENDER_CONTEXT_V2_URL, QRCODE_CONTEXT_URL, DATA_INTEGRITY_V2_URL, VC_V1_URL, VC_V2_URL } from '@trustvc/w3c-context';
|
|
12
11
|
|
|
13
12
|
var __defProp = Object.defineProperty;
|
|
14
13
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -104,6 +103,11 @@ class DocumentBuilder {
|
|
|
104
103
|
// Sign the document using the provided private key and an optional cryptographic suite.
|
|
105
104
|
async sign(privateKey, cryptoSuite, options) {
|
|
106
105
|
if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
|
|
106
|
+
if (cryptoSuite === "BbsBlsSignature2020") {
|
|
107
|
+
throw new Error(
|
|
108
|
+
"BbsBlsSignature2020 is no longer supported. Please use the latest cryptosuite versions instead"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
107
111
|
if (this.selectedStatusType) {
|
|
108
112
|
this.document.credentialStatus = this.statusConfig;
|
|
109
113
|
}
|
|
@@ -121,11 +125,7 @@ class DocumentBuilder {
|
|
|
121
125
|
}
|
|
122
126
|
this.document.issuer = privateKey.id.split("#")[0];
|
|
123
127
|
this.document.validFrom = this.document.validFrom || (/* @__PURE__ */ new Date()).toISOString();
|
|
124
|
-
|
|
125
|
-
this.addContext(DATA_INTEGRITY_V2_URL);
|
|
126
|
-
} else {
|
|
127
|
-
this.addContext(BBS_V1_URL);
|
|
128
|
-
}
|
|
128
|
+
this.addContext(DATA_INTEGRITY_V2_URL);
|
|
129
129
|
const signedVC = await signW3C(this.document, privateKey, cryptoSuite, options);
|
|
130
130
|
if (signedVC.error) throw new Error(`Signing Error: ${signedVC.error}`);
|
|
131
131
|
this.isSigned = true;
|
|
@@ -146,8 +146,7 @@ class DocumentBuilder {
|
|
|
146
146
|
// Verify the document.
|
|
147
147
|
async verify() {
|
|
148
148
|
if (!this.isSigned) throw new Error("Verification Error: Document is not signed yet.");
|
|
149
|
-
|
|
150
|
-
if (cryptosuite === CryptoSuite.EcdsaSd2023 && !this.isDerived) {
|
|
149
|
+
if (!this.isDerived) {
|
|
151
150
|
throw new Error("Verification Error: Document is not derived yet. Use derive() first.");
|
|
152
151
|
}
|
|
153
152
|
const verificationResult = await verifyW3CSignature(
|
|
@@ -78,7 +78,7 @@ declare class DocumentBuilder {
|
|
|
78
78
|
expirationDate(date: string | Date): this;
|
|
79
79
|
renderMethod(method: RenderMethod): this;
|
|
80
80
|
qrCode(method: qrCode): this;
|
|
81
|
-
sign(privateKey: PrivateKeyPair, cryptoSuite?: CryptoSuiteName, options?: SignOptions): Promise<SignedVerifiableCredential>;
|
|
81
|
+
sign(privateKey: PrivateKeyPair, cryptoSuite?: Exclude<CryptoSuiteName, 'BbsBlsSignature2020'>, options?: SignOptions): Promise<SignedVerifiableCredential>;
|
|
82
82
|
derive(revealedAttributes: string[]): Promise<SignedVerifiableCredential>;
|
|
83
83
|
verify(): Promise<boolean>;
|
|
84
84
|
toString(): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustvc/trustvc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "TrustVC library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
"@tradetrust-tt/token-registry-v4": "npm:@tradetrust-tt/token-registry@^4.16.0",
|
|
121
121
|
"@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.5.0",
|
|
122
122
|
"@tradetrust-tt/tradetrust": "^6.10.2",
|
|
123
|
-
"@tradetrust-tt/tradetrust-utils": "^2.4.
|
|
123
|
+
"@tradetrust-tt/tradetrust-utils": "^2.4.3",
|
|
124
124
|
"@tradetrust-tt/tt-verify": "^9.6.0",
|
|
125
|
-
"@trustvc/w3c": "^1.3.0-alpha.
|
|
125
|
+
"@trustvc/w3c": "^1.3.0-alpha.17",
|
|
126
126
|
"@trustvc/w3c-context": "^1.3.0-alpha.12",
|
|
127
|
-
"@trustvc/w3c-credential-status": "^1.3.0-alpha.
|
|
127
|
+
"@trustvc/w3c-credential-status": "^1.3.0-alpha.13",
|
|
128
128
|
"@trustvc/w3c-issuer": "^1.3.0-alpha.10",
|
|
129
|
-
"@trustvc/w3c-vc": "^1.3.0-alpha.
|
|
129
|
+
"@trustvc/w3c-vc": "^1.3.0-alpha.17",
|
|
130
130
|
"ethers": "^5.8.0",
|
|
131
131
|
"ethersV6": "npm:ethers@^6.14.4",
|
|
132
132
|
"js-sha3": "^0.9.3",
|