@trustvc/trustvc 1.0.0-alpha.1 → 1.0.0-alpha.10
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/README.md +138 -0
- package/dist/config.d.mts +3 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +5 -0
- package/dist/core/decrypt.d.mts +3 -0
- package/dist/core/decrypt.d.ts +3 -0
- package/dist/core/decrypt.js +22 -0
- package/dist/core/encrypt.d.mts +3 -0
- package/dist/core/encrypt.d.ts +3 -0
- package/dist/core/encrypt.js +22 -0
- package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.mts +5 -0
- package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.ts +5 -0
- package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.js +48 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.d.mts +7 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.d.ts +7 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.js +128 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.mts +30 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.ts +30 -0
- package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js +2 -0
- package/dist/core/fragments/document-status/transferableRecords/utils.d.mts +18 -0
- package/dist/core/fragments/document-status/transferableRecords/utils.d.ts +18 -0
- package/dist/core/fragments/document-status/transferableRecords/utils.js +75 -0
- package/dist/core/fragments/document-status/w3cCredentialStatus.d.mts +5 -0
- package/dist/core/fragments/document-status/w3cCredentialStatus.d.ts +5 -0
- package/dist/core/fragments/document-status/w3cCredentialStatus.js +54 -0
- package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.mts +5 -0
- package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.ts +5 -0
- package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.js +74 -0
- package/dist/core/index.d.mts +5 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +26 -0
- package/dist/core/verify.d.mts +6 -0
- package/dist/core/verify.d.ts +6 -0
- package/dist/core/verify.js +40 -0
- package/dist/esm/config.js +3 -0
- package/dist/esm/core/decrypt.js +20 -0
- package/dist/esm/core/encrypt.js +20 -0
- package/dist/esm/core/fragments/document-integrity/w3cSignatureIntegrity.js +46 -0
- package/dist/esm/core/fragments/document-status/transferableRecords/transferableRecordVerifier.js +105 -0
- package/dist/esm/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js +1 -0
- package/dist/esm/core/fragments/document-status/transferableRecords/utils.js +72 -0
- package/dist/esm/core/fragments/document-status/w3cCredentialStatus.js +52 -0
- package/dist/esm/core/fragments/issuer-identity/w3cIssuerIdentity.js +72 -0
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/verify.js +38 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/open-attestation/index.js +5 -0
- package/dist/esm/open-attestation/sign.js +15 -0
- package/dist/esm/open-attestation/types.js +1 -0
- package/dist/esm/open-attestation/utils.js +1 -0
- package/dist/esm/open-attestation/verify.js +13 -0
- package/dist/esm/open-attestation/wrap.js +33 -0
- package/dist/esm/utils/stringUtils.js +20 -0
- package/dist/esm/w3c/index.js +3 -0
- package/dist/esm/w3c/sign.js +9 -0
- package/dist/esm/w3c/types.js +2 -0
- package/dist/esm/w3c/verify.js +9 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +26 -0
- package/dist/open-attestation/index.d.mts +6 -0
- package/dist/open-attestation/index.d.ts +6 -0
- package/dist/open-attestation/index.js +40 -0
- package/dist/open-attestation/sign.d.mts +8 -0
- package/dist/open-attestation/sign.d.ts +8 -0
- package/dist/open-attestation/sign.js +17 -0
- package/dist/open-attestation/types.d.mts +8 -0
- package/dist/open-attestation/types.d.ts +8 -0
- package/dist/open-attestation/types.js +18 -0
- package/dist/open-attestation/utils.d.mts +3 -0
- package/dist/open-attestation/utils.d.ts +3 -0
- package/dist/open-attestation/utils.js +10 -0
- package/dist/open-attestation/verify.d.mts +5 -0
- package/dist/open-attestation/verify.d.ts +5 -0
- package/dist/open-attestation/verify.js +15 -0
- package/dist/open-attestation/wrap.d.mts +9 -0
- package/dist/open-attestation/wrap.d.ts +9 -0
- package/dist/open-attestation/wrap.js +45 -0
- package/dist/utils/stringUtils.d.mts +5 -0
- package/dist/utils/stringUtils.d.ts +5 -0
- package/dist/utils/stringUtils.js +24 -0
- package/dist/w3c/index.d.mts +4 -0
- package/dist/w3c/index.d.ts +4 -0
- package/dist/w3c/index.js +26 -0
- package/dist/w3c/sign.d.mts +6 -0
- package/dist/w3c/sign.d.ts +6 -0
- package/dist/w3c/sign.js +11 -0
- package/dist/w3c/types.d.mts +2 -0
- package/dist/w3c/types.d.ts +2 -0
- package/dist/w3c/types.js +27 -0
- package/dist/w3c/verify.d.mts +5 -0
- package/dist/w3c/verify.d.ts +5 -0
- package/dist/w3c/verify.js +11 -0
- package/package.json +13 -7
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { utils } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
import { verificationBuilder, openAttestationVerifiers, openAttestationDidIdentityProof } from '@tradetrust-tt/tt-verify';
|
|
3
|
+
import { ethers } from 'ethers';
|
|
4
|
+
import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
|
|
5
|
+
import { credentialStatusTransferableRecordVerifier } from './fragments/document-status/transferableRecords/transferableRecordVerifier';
|
|
6
|
+
import { w3cCredentialStatus } from './fragments/document-status/w3cCredentialStatus';
|
|
7
|
+
import { w3cIssuerIdentity } from './fragments/issuer-identity/w3cIssuerIdentity';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
|
|
12
|
+
if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
|
|
13
|
+
const verify = verificationBuilder(
|
|
14
|
+
[...openAttestationVerifiers, openAttestationDidIdentityProof],
|
|
15
|
+
{
|
|
16
|
+
provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
17
|
+
// Use user-provided provider URL
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
return verify(document);
|
|
21
|
+
} else {
|
|
22
|
+
const verify = verificationBuilder(
|
|
23
|
+
[
|
|
24
|
+
w3cSignatureIntegrity,
|
|
25
|
+
w3cCredentialStatus,
|
|
26
|
+
w3cIssuerIdentity,
|
|
27
|
+
credentialStatusTransferableRecordVerifier
|
|
28
|
+
],
|
|
29
|
+
{
|
|
30
|
+
provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
31
|
+
// Use user-provided provider URL
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
return verify(document);
|
|
35
|
+
}
|
|
36
|
+
}, "verifyDocument");
|
|
37
|
+
|
|
38
|
+
export { verifyDocument };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { signDocument, SUPPORTED_SIGNING_ALGORITHM } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
async function signOA(document, keyPair) {
|
|
6
|
+
return signDocument(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
document,
|
|
9
|
+
SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018,
|
|
10
|
+
keyPair
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
__name(signOA, "signOA");
|
|
14
|
+
|
|
15
|
+
export { signOA };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { utils } from '@tradetrust-tt/tradetrust';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { utils, verifySignature } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const verifyOASignature = /* @__PURE__ */ __name(async (document) => {
|
|
6
|
+
if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
|
|
7
|
+
return verifySignature(document);
|
|
8
|
+
} else {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}, "verifyOASignature");
|
|
12
|
+
|
|
13
|
+
export { verifyOASignature };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { wrapDocument as wrapDocument$1, wrapDocuments as wrapDocuments$1, utils, __unsafe__use__it__at__your__own__risks__wrapDocument, __unsafe__use__it__at__your__own__risks__wrapDocuments } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
export { __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
const wrapDocumentv2 = /* @__PURE__ */ __name(async (document) => {
|
|
7
|
+
return wrapDocument$1(document);
|
|
8
|
+
}, "wrapDocumentv2");
|
|
9
|
+
const wrapDocumentsv2 = /* @__PURE__ */ __name(async (documents) => {
|
|
10
|
+
return wrapDocuments$1(documents);
|
|
11
|
+
}, "wrapDocumentsv2");
|
|
12
|
+
async function wrapDocument(document) {
|
|
13
|
+
if (utils.isRawV2Document(document)) {
|
|
14
|
+
return wrapDocumentv2(document);
|
|
15
|
+
} else if (utils.isRawV3Document(document)) {
|
|
16
|
+
return __unsafe__use__it__at__your__own__risks__wrapDocument(document);
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error("Unsupported document version");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__name(wrapDocument, "wrapDocument");
|
|
22
|
+
async function wrapDocuments(documents) {
|
|
23
|
+
if (documents.every((s) => utils.isRawV2Document(s))) {
|
|
24
|
+
return wrapDocumentsv2(documents);
|
|
25
|
+
} else if (documents.every((s) => utils.isRawV3Document(s))) {
|
|
26
|
+
return __unsafe__use__it__at__your__own__risks__wrapDocuments(documents);
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error("Unsupported documents version");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
__name(wrapDocuments, "wrapDocuments");
|
|
32
|
+
|
|
33
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { shake256 } from 'js-sha3';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function stringToUint8Array(str) {
|
|
6
|
+
return new Uint8Array(Buffer.from(str, "utf-8"));
|
|
7
|
+
}
|
|
8
|
+
__name(stringToUint8Array, "stringToUint8Array");
|
|
9
|
+
function generate32ByteKey(input) {
|
|
10
|
+
const hash = shake256(input, 128);
|
|
11
|
+
return hash;
|
|
12
|
+
}
|
|
13
|
+
__name(generate32ByteKey, "generate32ByteKey");
|
|
14
|
+
function generate12ByteNonce(input) {
|
|
15
|
+
const nonce = shake256(input, 48);
|
|
16
|
+
return nonce;
|
|
17
|
+
}
|
|
18
|
+
__name(generate12ByteNonce, "generate12ByteNonce");
|
|
19
|
+
|
|
20
|
+
export { generate12ByteNonce, generate32ByteKey, stringToUint8Array };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { signCredential } from '@trustvc/w3c-vc';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "BbsBlsSignature2020") => {
|
|
6
|
+
return signCredential(credential, keyPair, cryptoSuite);
|
|
7
|
+
}, "signW3C");
|
|
8
|
+
|
|
9
|
+
export { signW3C };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { verifyCredential } from '@trustvc/w3c-vc';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const verifyW3CSignature = /* @__PURE__ */ __name(async (credential) => {
|
|
6
|
+
return verifyCredential(credential);
|
|
7
|
+
}, "verifyW3CSignature");
|
|
8
|
+
|
|
9
|
+
export { verifyW3CSignature };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { signOA } from './open-attestation/sign.mjs';
|
|
2
|
+
export { KeyPair } from './open-attestation/types.mjs';
|
|
3
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
4
|
+
export { verifyOASignature } from './open-attestation/verify.mjs';
|
|
5
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './open-attestation/wrap.mjs';
|
|
6
|
+
export { verifyDocument } from './core/verify.mjs';
|
|
7
|
+
export { encrypt } from './core/encrypt.mjs';
|
|
8
|
+
export { decrypt } from './core/decrypt.mjs';
|
|
9
|
+
export { signW3C } from './w3c/sign.mjs';
|
|
10
|
+
export { verifyW3CSignature } from './w3c/verify.mjs';
|
|
11
|
+
export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
|
|
12
|
+
export { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
13
|
+
import '@ethersproject/abstract-signer';
|
|
14
|
+
import '@tradetrust-tt/tt-verify';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { signOA } from './open-attestation/sign.js';
|
|
2
|
+
export { KeyPair } from './open-attestation/types.js';
|
|
3
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
4
|
+
export { verifyOASignature } from './open-attestation/verify.js';
|
|
5
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './open-attestation/wrap.js';
|
|
6
|
+
export { verifyDocument } from './core/verify.js';
|
|
7
|
+
export { encrypt } from './core/encrypt.js';
|
|
8
|
+
export { decrypt } from './core/decrypt.js';
|
|
9
|
+
export { signW3C } from './w3c/sign.js';
|
|
10
|
+
export { verifyW3CSignature } from './w3c/verify.js';
|
|
11
|
+
export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
|
|
12
|
+
export { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
13
|
+
import '@ethersproject/abstract-signer';
|
|
14
|
+
import '@tradetrust-tt/tt-verify';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var openAttestation = require('./open-attestation');
|
|
4
|
+
var core = require('./core');
|
|
5
|
+
var w3c = require('./w3c');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(openAttestation).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return openAttestation[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(core).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return core[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(w3c).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return w3c[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { signOA } from './sign.mjs';
|
|
2
|
+
export { KeyPair } from './types.mjs';
|
|
3
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
4
|
+
export { verifyOASignature } from './verify.mjs';
|
|
5
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './wrap.mjs';
|
|
6
|
+
import '@ethersproject/abstract-signer';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { signOA } from './sign.js';
|
|
2
|
+
export { KeyPair } from './types.js';
|
|
3
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
4
|
+
export { verifyOASignature } from './verify.js';
|
|
5
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './wrap.js';
|
|
6
|
+
import '@ethersproject/abstract-signer';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sign = require('./sign');
|
|
4
|
+
var types = require('./types');
|
|
5
|
+
var utils = require('./utils');
|
|
6
|
+
var verify = require('./verify');
|
|
7
|
+
var wrap = require('./wrap');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Object.keys(sign).forEach(function (k) {
|
|
12
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return sign[k]; }
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
Object.keys(types).forEach(function (k) {
|
|
18
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return types[k]; }
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
Object.keys(utils).forEach(function (k) {
|
|
24
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return utils[k]; }
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
Object.keys(verify).forEach(function (k) {
|
|
30
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return verify[k]; }
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
Object.keys(wrap).forEach(function (k) {
|
|
36
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return wrap[k]; }
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
2
|
+
import { v2, v3 } from '@tradetrust-tt/tradetrust';
|
|
3
|
+
import { KeyPair } from './types.mjs';
|
|
4
|
+
|
|
5
|
+
declare function signOA<T extends v2.WrappedDocument | v2.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v2.SignedWrappedDocument>;
|
|
6
|
+
declare function signOA<T extends v3.WrappedDocument | v3.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v3.SignedWrappedDocument>;
|
|
7
|
+
|
|
8
|
+
export { signOA };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
2
|
+
import { v2, v3 } from '@tradetrust-tt/tradetrust';
|
|
3
|
+
import { KeyPair } from './types.js';
|
|
4
|
+
|
|
5
|
+
declare function signOA<T extends v2.WrappedDocument | v2.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v2.SignedWrappedDocument>;
|
|
6
|
+
declare function signOA<T extends v3.WrappedDocument | v3.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v3.SignedWrappedDocument>;
|
|
7
|
+
|
|
8
|
+
export { signOA };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tradetrust = require('@tradetrust-tt/tradetrust');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
async function signOA(document, keyPair) {
|
|
8
|
+
return tradetrust.signDocument(
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
document,
|
|
11
|
+
tradetrust.SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018,
|
|
12
|
+
keyPair
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
__name(signOA, "signOA");
|
|
16
|
+
|
|
17
|
+
exports.signOA = signOA;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tradetrust = require('@tradetrust-tt/tradetrust');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "OpenAttestationDocument", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return tradetrust.OpenAttestationDocument; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "SignedWrappedDocument", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return tradetrust.SignedWrappedDocument; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "WrappedDocument", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return tradetrust.WrappedDocument; }
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tradetrust = require('@tradetrust-tt/tradetrust');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const verifyOASignature = /* @__PURE__ */ __name(async (document) => {
|
|
8
|
+
if (tradetrust.utils.isWrappedV2Document(document) || tradetrust.utils.isWrappedV3Document(document)) {
|
|
9
|
+
return tradetrust.verifySignature(document);
|
|
10
|
+
} else {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}, "verifyOASignature");
|
|
14
|
+
|
|
15
|
+
exports.verifyOASignature = verifyOASignature;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { v2, OpenAttestationDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
export { __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
3
|
+
|
|
4
|
+
declare const wrapDocumentv2: <T extends v2.OpenAttestationDocument>(document: T) => Promise<v2.WrappedDocument<T>>;
|
|
5
|
+
declare const wrapDocumentsv2: <T extends v2.OpenAttestationDocument>(documents: T[]) => Promise<v2.WrappedDocument<T>[]>;
|
|
6
|
+
declare function wrapDocument<T extends OpenAttestationDocument>(document: T): Promise<WrappedDocument<T>>;
|
|
7
|
+
declare function wrapDocuments<T extends OpenAttestationDocument>(documents: T[]): Promise<WrappedDocument<T>[]>;
|
|
8
|
+
|
|
9
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { v2, OpenAttestationDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
|
|
2
|
+
export { __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
|
|
3
|
+
|
|
4
|
+
declare const wrapDocumentv2: <T extends v2.OpenAttestationDocument>(document: T) => Promise<v2.WrappedDocument<T>>;
|
|
5
|
+
declare const wrapDocumentsv2: <T extends v2.OpenAttestationDocument>(documents: T[]) => Promise<v2.WrappedDocument<T>[]>;
|
|
6
|
+
declare function wrapDocument<T extends OpenAttestationDocument>(document: T): Promise<WrappedDocument<T>>;
|
|
7
|
+
declare function wrapDocuments<T extends OpenAttestationDocument>(documents: T[]): Promise<WrappedDocument<T>[]>;
|
|
8
|
+
|
|
9
|
+
export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tradetrust = require('@tradetrust-tt/tradetrust');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const wrapDocumentv2 = /* @__PURE__ */ __name(async (document) => {
|
|
8
|
+
return tradetrust.wrapDocument(document);
|
|
9
|
+
}, "wrapDocumentv2");
|
|
10
|
+
const wrapDocumentsv2 = /* @__PURE__ */ __name(async (documents) => {
|
|
11
|
+
return tradetrust.wrapDocuments(documents);
|
|
12
|
+
}, "wrapDocumentsv2");
|
|
13
|
+
async function wrapDocument(document) {
|
|
14
|
+
if (tradetrust.utils.isRawV2Document(document)) {
|
|
15
|
+
return wrapDocumentv2(document);
|
|
16
|
+
} else if (tradetrust.utils.isRawV3Document(document)) {
|
|
17
|
+
return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocument(document);
|
|
18
|
+
} else {
|
|
19
|
+
throw new Error("Unsupported document version");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
__name(wrapDocument, "wrapDocument");
|
|
23
|
+
async function wrapDocuments(documents) {
|
|
24
|
+
if (documents.every((s) => tradetrust.utils.isRawV2Document(s))) {
|
|
25
|
+
return wrapDocumentsv2(documents);
|
|
26
|
+
} else if (documents.every((s) => tradetrust.utils.isRawV3Document(s))) {
|
|
27
|
+
return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocuments(documents);
|
|
28
|
+
} else {
|
|
29
|
+
throw new Error("Unsupported documents version");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
__name(wrapDocuments, "wrapDocuments");
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(exports, "wrapDocumentsv3", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocuments; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "wrapDocumentv3", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocument; }
|
|
41
|
+
});
|
|
42
|
+
exports.wrapDocument = wrapDocument;
|
|
43
|
+
exports.wrapDocuments = wrapDocuments;
|
|
44
|
+
exports.wrapDocumentsv2 = wrapDocumentsv2;
|
|
45
|
+
exports.wrapDocumentv2 = wrapDocumentv2;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsSha3 = require('js-sha3');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function stringToUint8Array(str) {
|
|
8
|
+
return new Uint8Array(Buffer.from(str, "utf-8"));
|
|
9
|
+
}
|
|
10
|
+
__name(stringToUint8Array, "stringToUint8Array");
|
|
11
|
+
function generate32ByteKey(input) {
|
|
12
|
+
const hash = jsSha3.shake256(input, 128);
|
|
13
|
+
return hash;
|
|
14
|
+
}
|
|
15
|
+
__name(generate32ByteKey, "generate32ByteKey");
|
|
16
|
+
function generate12ByteNonce(input) {
|
|
17
|
+
const nonce = jsSha3.shake256(input, 48);
|
|
18
|
+
return nonce;
|
|
19
|
+
}
|
|
20
|
+
__name(generate12ByteNonce, "generate12ByteNonce");
|
|
21
|
+
|
|
22
|
+
exports.generate12ByteNonce = generate12ByteNonce;
|
|
23
|
+
exports.generate32ByteKey = generate32ByteKey;
|
|
24
|
+
exports.stringToUint8Array = stringToUint8Array;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sign = require('./sign');
|
|
4
|
+
var verify = require('./verify');
|
|
5
|
+
var types = require('./types');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(sign).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return sign[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(verify).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return verify[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(types).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return types[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RawVerifiableCredential, SigningResult } from '@trustvc/w3c-vc';
|
|
2
|
+
import { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
3
|
+
|
|
4
|
+
declare const signW3C: (credential: RawVerifiableCredential, keyPair: PrivateKeyPair, cryptoSuite?: string) => Promise<SigningResult>;
|
|
5
|
+
|
|
6
|
+
export { signW3C };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RawVerifiableCredential, SigningResult } from '@trustvc/w3c-vc';
|
|
2
|
+
import { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
3
|
+
|
|
4
|
+
declare const signW3C: (credential: RawVerifiableCredential, keyPair: PrivateKeyPair, cryptoSuite?: string) => Promise<SigningResult>;
|
|
5
|
+
|
|
6
|
+
export { signW3C };
|
package/dist/w3c/sign.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var w3cVc = require('@trustvc/w3c-vc');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "BbsBlsSignature2020") => {
|
|
8
|
+
return w3cVc.signCredential(credential, keyPair, cryptoSuite);
|
|
9
|
+
}, "signW3C");
|
|
10
|
+
|
|
11
|
+
exports.signW3C = signW3C;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var w3cVc = require('@trustvc/w3c-vc');
|
|
4
|
+
var w3cIssuer = require('@trustvc/w3c-issuer');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "RawVerifiableCredential", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return w3cVc.RawVerifiableCredential; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SignedVerifiableCredential", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return w3cVc.SignedVerifiableCredential; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "SigningResult", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return w3cVc.SigningResult; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "VerificationResult", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return w3cVc.VerificationResult; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PrivateKeyPair", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return w3cIssuer.PrivateKeyPair; }
|
|
27
|
+
});
|