@trustvc/trustvc 1.0.0-alpha.1 → 1.0.0-alpha.3
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/dist/core/decrypt.d.mts +3 -0
- package/dist/core/decrypt.d.ts +3 -0
- package/dist/core/decrypt.js +23 -0
- package/dist/core/encrypt.d.mts +3 -0
- package/dist/core/encrypt.d.ts +3 -0
- package/dist/core/encrypt.js +23 -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/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 +34 -0
- package/dist/esm/core/decrypt.js +21 -0
- package/dist/esm/core/encrypt.js +21 -0
- package/dist/esm/core/fragments/document-integrity/w3cSignatureIntegrity.js +46 -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 +32 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/open-attestation/index.js +4 -0
- package/dist/esm/open-attestation/sign.js +10 -0
- package/dist/esm/open-attestation/types.js +1 -0
- package/dist/esm/open-attestation/verify.js +13 -0
- package/dist/esm/open-attestation/wrap.js +10 -0
- package/dist/esm/utils/stringUtils.js +21 -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 +33 -0
- package/dist/open-attestation/sign.d.mts +7 -0
- package/dist/open-attestation/sign.d.ts +7 -0
- package/dist/open-attestation/sign.js +12 -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/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 +5 -0
- package/dist/open-attestation/wrap.d.ts +5 -0
- package/dist/open-attestation/wrap.js +12 -0
- package/dist/utils/stringUtils.d.mts +5 -0
- package/dist/utils/stringUtils.d.ts +5 -0
- package/dist/utils/stringUtils.js +25 -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 +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stringUtils = require('src/utils/stringUtils');
|
|
4
|
+
var tsChacha20 = require('ts-chacha20');
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
function decrypt(encryptedMessage, key, nonce) {
|
|
9
|
+
if (key.length === 0) {
|
|
10
|
+
throw new Error("Key length must not be 0");
|
|
11
|
+
}
|
|
12
|
+
key = stringUtils.generate32ByteKey(key ?? "");
|
|
13
|
+
nonce = stringUtils.generate12ByteNonce(nonce ?? "");
|
|
14
|
+
const keyBuffer = stringUtils.stringToUint8Array(key);
|
|
15
|
+
const nonceBuffer = stringUtils.stringToUint8Array(nonce);
|
|
16
|
+
const chacha20 = new tsChacha20.Chacha20(keyBuffer, nonceBuffer);
|
|
17
|
+
const encryptedBuffer = Buffer.from(encryptedMessage, "hex");
|
|
18
|
+
const decrypted = chacha20.decrypt(encryptedBuffer);
|
|
19
|
+
return Buffer.from(decrypted).toString("utf-8");
|
|
20
|
+
}
|
|
21
|
+
__name(decrypt, "decrypt");
|
|
22
|
+
|
|
23
|
+
exports.decrypt = decrypt;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stringUtils = require('src/utils/stringUtils');
|
|
4
|
+
var tsChacha20 = require('ts-chacha20');
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
function encrypt(message, key, nonce) {
|
|
9
|
+
if (key.length === 0) {
|
|
10
|
+
throw new Error("Key length must not be 0");
|
|
11
|
+
}
|
|
12
|
+
key = stringUtils.generate32ByteKey(key);
|
|
13
|
+
nonce = stringUtils.generate12ByteNonce(nonce ?? "");
|
|
14
|
+
const keyBuffer = stringUtils.stringToUint8Array(key);
|
|
15
|
+
const nonceBuffer = stringUtils.stringToUint8Array(nonce);
|
|
16
|
+
const chacha20 = new tsChacha20.Chacha20(keyBuffer, nonceBuffer);
|
|
17
|
+
const messageBuffer = Buffer.from(message, "utf-8");
|
|
18
|
+
const encrypted = chacha20.encrypt(messageBuffer);
|
|
19
|
+
return Buffer.from(encrypted).toString("hex");
|
|
20
|
+
}
|
|
21
|
+
__name(encrypt, "encrypt");
|
|
22
|
+
|
|
23
|
+
exports.encrypt = encrypt;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __ = require('../../..');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const w3cSignatureIntegrity = {
|
|
8
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
9
|
+
return {
|
|
10
|
+
type: "DOCUMENT_INTEGRITY",
|
|
11
|
+
name: "W3CSignatureIntegrity",
|
|
12
|
+
reason: {
|
|
13
|
+
code: 0,
|
|
14
|
+
codeString: "SKIPPED",
|
|
15
|
+
message: `Document either has no proof or proof.type is not 'BbsBlsSignature2020'.`
|
|
16
|
+
},
|
|
17
|
+
status: "SKIPPED"
|
|
18
|
+
};
|
|
19
|
+
}, "skip"),
|
|
20
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
21
|
+
const doc = document;
|
|
22
|
+
return doc.proof?.type === "BbsBlsSignature2020";
|
|
23
|
+
}, "test"),
|
|
24
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
25
|
+
const doc = document;
|
|
26
|
+
const verificationResult = await __.verifyW3CSignature(doc);
|
|
27
|
+
if (verificationResult.verified) {
|
|
28
|
+
return {
|
|
29
|
+
type: "DOCUMENT_INTEGRITY",
|
|
30
|
+
name: "W3CSignatureIntegrity",
|
|
31
|
+
data: true,
|
|
32
|
+
status: "VALID"
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
35
|
+
return {
|
|
36
|
+
type: "DOCUMENT_INTEGRITY",
|
|
37
|
+
name: "W3CSignatureIntegrity",
|
|
38
|
+
data: false,
|
|
39
|
+
reason: {
|
|
40
|
+
message: verificationResult.error
|
|
41
|
+
},
|
|
42
|
+
status: "INVALID"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, "verify")
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.w3cSignatureIntegrity = w3cSignatureIntegrity;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 w3cCredentialStatus = {
|
|
8
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
9
|
+
return {
|
|
10
|
+
type: "DOCUMENT_STATUS",
|
|
11
|
+
name: "W3CCredentialStatus",
|
|
12
|
+
reason: {
|
|
13
|
+
code: 0,
|
|
14
|
+
codeString: "SKIPPED",
|
|
15
|
+
message: `Document does not have a valid credentialStatus or type.`
|
|
16
|
+
},
|
|
17
|
+
status: "SKIPPED"
|
|
18
|
+
};
|
|
19
|
+
}, "skip"),
|
|
20
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
21
|
+
const doc = document;
|
|
22
|
+
return doc.credentialStatus?.type === "StatusList2021Entry";
|
|
23
|
+
}, "test"),
|
|
24
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
25
|
+
const doc = document;
|
|
26
|
+
const verificationResult = await w3cVc.verifyCredentialStatus(doc.credentialStatus);
|
|
27
|
+
if (verificationResult.error) {
|
|
28
|
+
return {
|
|
29
|
+
type: "DOCUMENT_STATUS",
|
|
30
|
+
name: "W3CCredentialStatus",
|
|
31
|
+
reason: {
|
|
32
|
+
message: verificationResult.error
|
|
33
|
+
},
|
|
34
|
+
status: "ERROR"
|
|
35
|
+
};
|
|
36
|
+
} else if (verificationResult.status === true) {
|
|
37
|
+
return {
|
|
38
|
+
type: "DOCUMENT_STATUS",
|
|
39
|
+
name: "W3CCredentialStatus",
|
|
40
|
+
data: false,
|
|
41
|
+
status: "INVALID"
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
return {
|
|
45
|
+
type: "DOCUMENT_STATUS",
|
|
46
|
+
name: "W3CCredentialStatus",
|
|
47
|
+
data: true,
|
|
48
|
+
status: "VALID"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}, "verify")
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.w3cCredentialStatus = w3cCredentialStatus;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var didResolver = require('did-resolver');
|
|
4
|
+
var webDidResolver = require('web-did-resolver');
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
|
|
9
|
+
try {
|
|
10
|
+
const resolver = new didResolver.Resolver({
|
|
11
|
+
...webDidResolver.getResolver()
|
|
12
|
+
});
|
|
13
|
+
const didDocument = await resolver.resolve(did);
|
|
14
|
+
if (!didDocument || !didDocument.didDocument) {
|
|
15
|
+
throw new Error(`Failed to resolve DID: ${did}`);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}, "checkDidWebResolve");
|
|
22
|
+
const w3cIssuerIdentity = {
|
|
23
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
24
|
+
return {
|
|
25
|
+
type: "ISSUER_IDENTITY",
|
|
26
|
+
name: "W3CIssuerIdentity",
|
|
27
|
+
reason: {
|
|
28
|
+
code: 0,
|
|
29
|
+
codeString: "SKIPPED",
|
|
30
|
+
message: `Document has no issuer field.`
|
|
31
|
+
},
|
|
32
|
+
status: "SKIPPED"
|
|
33
|
+
};
|
|
34
|
+
}, "skip"),
|
|
35
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
36
|
+
const doc = document;
|
|
37
|
+
return Boolean(doc.issuer);
|
|
38
|
+
}, "test"),
|
|
39
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
40
|
+
const doc = document;
|
|
41
|
+
if (doc.proof?.verificationMethod?.split("#")[0] !== doc.issuer) {
|
|
42
|
+
return {
|
|
43
|
+
type: "ISSUER_IDENTITY",
|
|
44
|
+
name: "W3CIssuerIdentity",
|
|
45
|
+
data: false,
|
|
46
|
+
reason: {
|
|
47
|
+
message: `Issuer and verification method do not match.`
|
|
48
|
+
},
|
|
49
|
+
status: "INVALID"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const resolutionResult = await checkDidWebResolve(doc.issuer);
|
|
53
|
+
if (resolutionResult) {
|
|
54
|
+
return {
|
|
55
|
+
type: "ISSUER_IDENTITY",
|
|
56
|
+
name: "W3CIssuerIdentity",
|
|
57
|
+
data: true,
|
|
58
|
+
status: "VALID"
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
return {
|
|
62
|
+
type: "ISSUER_IDENTITY",
|
|
63
|
+
name: "W3CIssuerIdentity",
|
|
64
|
+
data: false,
|
|
65
|
+
reason: {
|
|
66
|
+
message: `The DID cannot be resolved.`
|
|
67
|
+
},
|
|
68
|
+
status: "INVALID"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}, "verify")
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.w3cIssuerIdentity = w3cIssuerIdentity;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var verify = require('./verify');
|
|
4
|
+
var encrypt = require('./encrypt');
|
|
5
|
+
var decrypt = require('./decrypt');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(verify).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return verify[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(encrypt).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return encrypt[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(decrypt).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return decrypt[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DocumentsToVerify, VerificationFragment } from '@govtechsg/oa-verify';
|
|
2
|
+
import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
|
|
3
|
+
|
|
4
|
+
declare const verifyDocument: (document: DocumentsToVerify | SignedVerifiableCredential, rpcProviderUrl: string) => Promise<VerificationFragment[]>;
|
|
5
|
+
|
|
6
|
+
export { verifyDocument };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DocumentsToVerify, VerificationFragment } from '@govtechsg/oa-verify';
|
|
2
|
+
import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
|
|
3
|
+
|
|
4
|
+
declare const verifyDocument: (document: DocumentsToVerify | SignedVerifiableCredential, rpcProviderUrl: string) => Promise<VerificationFragment[]>;
|
|
5
|
+
|
|
6
|
+
export { verifyDocument };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var oaVerify = require('@govtechsg/oa-verify');
|
|
4
|
+
var ethers = require('ethers');
|
|
5
|
+
var w3cSignatureIntegrity = require('./fragments/document-integrity/w3cSignatureIntegrity');
|
|
6
|
+
var w3cCredentialStatus = require('./fragments/document-status/w3cCredentialStatus');
|
|
7
|
+
var w3cIssuerIdentity = require('./fragments/issuer-identity/w3cIssuerIdentity');
|
|
8
|
+
var openAttestation = require('@govtechsg/open-attestation');
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
+
const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
|
|
13
|
+
if (openAttestation.utils.isWrappedV2Document(document) || openAttestation.utils.isWrappedV3Document(document) || openAttestation.utils.isWrappedV4Document(document)) {
|
|
14
|
+
const verify = oaVerify.verificationBuilder(
|
|
15
|
+
[...oaVerify.openAttestationVerifiers, oaVerify.openAttestationDidIdentityProof],
|
|
16
|
+
{
|
|
17
|
+
provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
18
|
+
// Use user-provided provider URL
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
return verify(document);
|
|
22
|
+
} else {
|
|
23
|
+
const verify = oaVerify.verificationBuilder(
|
|
24
|
+
[w3cSignatureIntegrity.w3cSignatureIntegrity, w3cCredentialStatus.w3cCredentialStatus, w3cIssuerIdentity.w3cIssuerIdentity],
|
|
25
|
+
{
|
|
26
|
+
provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
27
|
+
// Use user-provided provider URL
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
return verify(document);
|
|
31
|
+
}
|
|
32
|
+
}, "verifyDocument");
|
|
33
|
+
|
|
34
|
+
exports.verifyDocument = verifyDocument;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from 'src/utils/stringUtils';
|
|
2
|
+
import { Chacha20 } from 'ts-chacha20';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
function decrypt(encryptedMessage, key, nonce) {
|
|
7
|
+
if (key.length === 0) {
|
|
8
|
+
throw new Error("Key length must not be 0");
|
|
9
|
+
}
|
|
10
|
+
key = generate32ByteKey(key ?? "");
|
|
11
|
+
nonce = generate12ByteNonce(nonce ?? "");
|
|
12
|
+
const keyBuffer = stringToUint8Array(key);
|
|
13
|
+
const nonceBuffer = stringToUint8Array(nonce);
|
|
14
|
+
const chacha20 = new Chacha20(keyBuffer, nonceBuffer);
|
|
15
|
+
const encryptedBuffer = Buffer.from(encryptedMessage, "hex");
|
|
16
|
+
const decrypted = chacha20.decrypt(encryptedBuffer);
|
|
17
|
+
return Buffer.from(decrypted).toString("utf-8");
|
|
18
|
+
}
|
|
19
|
+
__name(decrypt, "decrypt");
|
|
20
|
+
|
|
21
|
+
export { decrypt };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from 'src/utils/stringUtils';
|
|
2
|
+
import { Chacha20 } from 'ts-chacha20';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
function encrypt(message, key, nonce) {
|
|
7
|
+
if (key.length === 0) {
|
|
8
|
+
throw new Error("Key length must not be 0");
|
|
9
|
+
}
|
|
10
|
+
key = generate32ByteKey(key);
|
|
11
|
+
nonce = generate12ByteNonce(nonce ?? "");
|
|
12
|
+
const keyBuffer = stringToUint8Array(key);
|
|
13
|
+
const nonceBuffer = stringToUint8Array(nonce);
|
|
14
|
+
const chacha20 = new Chacha20(keyBuffer, nonceBuffer);
|
|
15
|
+
const messageBuffer = Buffer.from(message, "utf-8");
|
|
16
|
+
const encrypted = chacha20.encrypt(messageBuffer);
|
|
17
|
+
return Buffer.from(encrypted).toString("hex");
|
|
18
|
+
}
|
|
19
|
+
__name(encrypt, "encrypt");
|
|
20
|
+
|
|
21
|
+
export { encrypt };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { verifyW3CSignature } from '../../..';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const w3cSignatureIntegrity = {
|
|
6
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
7
|
+
return {
|
|
8
|
+
type: "DOCUMENT_INTEGRITY",
|
|
9
|
+
name: "W3CSignatureIntegrity",
|
|
10
|
+
reason: {
|
|
11
|
+
code: 0,
|
|
12
|
+
codeString: "SKIPPED",
|
|
13
|
+
message: `Document either has no proof or proof.type is not 'BbsBlsSignature2020'.`
|
|
14
|
+
},
|
|
15
|
+
status: "SKIPPED"
|
|
16
|
+
};
|
|
17
|
+
}, "skip"),
|
|
18
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
19
|
+
const doc = document;
|
|
20
|
+
return doc.proof?.type === "BbsBlsSignature2020";
|
|
21
|
+
}, "test"),
|
|
22
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
23
|
+
const doc = document;
|
|
24
|
+
const verificationResult = await verifyW3CSignature(doc);
|
|
25
|
+
if (verificationResult.verified) {
|
|
26
|
+
return {
|
|
27
|
+
type: "DOCUMENT_INTEGRITY",
|
|
28
|
+
name: "W3CSignatureIntegrity",
|
|
29
|
+
data: true,
|
|
30
|
+
status: "VALID"
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return {
|
|
34
|
+
type: "DOCUMENT_INTEGRITY",
|
|
35
|
+
name: "W3CSignatureIntegrity",
|
|
36
|
+
data: false,
|
|
37
|
+
reason: {
|
|
38
|
+
message: verificationResult.error
|
|
39
|
+
},
|
|
40
|
+
status: "INVALID"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}, "verify")
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { w3cSignatureIntegrity };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { verifyCredentialStatus } from '@trustvc/w3c-vc';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const w3cCredentialStatus = {
|
|
6
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
7
|
+
return {
|
|
8
|
+
type: "DOCUMENT_STATUS",
|
|
9
|
+
name: "W3CCredentialStatus",
|
|
10
|
+
reason: {
|
|
11
|
+
code: 0,
|
|
12
|
+
codeString: "SKIPPED",
|
|
13
|
+
message: `Document does not have a valid credentialStatus or type.`
|
|
14
|
+
},
|
|
15
|
+
status: "SKIPPED"
|
|
16
|
+
};
|
|
17
|
+
}, "skip"),
|
|
18
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
19
|
+
const doc = document;
|
|
20
|
+
return doc.credentialStatus?.type === "StatusList2021Entry";
|
|
21
|
+
}, "test"),
|
|
22
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
23
|
+
const doc = document;
|
|
24
|
+
const verificationResult = await verifyCredentialStatus(doc.credentialStatus);
|
|
25
|
+
if (verificationResult.error) {
|
|
26
|
+
return {
|
|
27
|
+
type: "DOCUMENT_STATUS",
|
|
28
|
+
name: "W3CCredentialStatus",
|
|
29
|
+
reason: {
|
|
30
|
+
message: verificationResult.error
|
|
31
|
+
},
|
|
32
|
+
status: "ERROR"
|
|
33
|
+
};
|
|
34
|
+
} else if (verificationResult.status === true) {
|
|
35
|
+
return {
|
|
36
|
+
type: "DOCUMENT_STATUS",
|
|
37
|
+
name: "W3CCredentialStatus",
|
|
38
|
+
data: false,
|
|
39
|
+
status: "INVALID"
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
return {
|
|
43
|
+
type: "DOCUMENT_STATUS",
|
|
44
|
+
name: "W3CCredentialStatus",
|
|
45
|
+
data: true,
|
|
46
|
+
status: "VALID"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}, "verify")
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { w3cCredentialStatus };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Resolver } from 'did-resolver';
|
|
2
|
+
import { getResolver } from 'web-did-resolver';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
|
|
7
|
+
try {
|
|
8
|
+
const resolver = new Resolver({
|
|
9
|
+
...getResolver()
|
|
10
|
+
});
|
|
11
|
+
const didDocument = await resolver.resolve(did);
|
|
12
|
+
if (!didDocument || !didDocument.didDocument) {
|
|
13
|
+
throw new Error(`Failed to resolve DID: ${did}`);
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}, "checkDidWebResolve");
|
|
20
|
+
const w3cIssuerIdentity = {
|
|
21
|
+
skip: /* @__PURE__ */ __name(async () => {
|
|
22
|
+
return {
|
|
23
|
+
type: "ISSUER_IDENTITY",
|
|
24
|
+
name: "W3CIssuerIdentity",
|
|
25
|
+
reason: {
|
|
26
|
+
code: 0,
|
|
27
|
+
codeString: "SKIPPED",
|
|
28
|
+
message: `Document has no issuer field.`
|
|
29
|
+
},
|
|
30
|
+
status: "SKIPPED"
|
|
31
|
+
};
|
|
32
|
+
}, "skip"),
|
|
33
|
+
test: /* @__PURE__ */ __name((document) => {
|
|
34
|
+
const doc = document;
|
|
35
|
+
return Boolean(doc.issuer);
|
|
36
|
+
}, "test"),
|
|
37
|
+
verify: /* @__PURE__ */ __name(async (document) => {
|
|
38
|
+
const doc = document;
|
|
39
|
+
if (doc.proof?.verificationMethod?.split("#")[0] !== doc.issuer) {
|
|
40
|
+
return {
|
|
41
|
+
type: "ISSUER_IDENTITY",
|
|
42
|
+
name: "W3CIssuerIdentity",
|
|
43
|
+
data: false,
|
|
44
|
+
reason: {
|
|
45
|
+
message: `Issuer and verification method do not match.`
|
|
46
|
+
},
|
|
47
|
+
status: "INVALID"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const resolutionResult = await checkDidWebResolve(doc.issuer);
|
|
51
|
+
if (resolutionResult) {
|
|
52
|
+
return {
|
|
53
|
+
type: "ISSUER_IDENTITY",
|
|
54
|
+
name: "W3CIssuerIdentity",
|
|
55
|
+
data: true,
|
|
56
|
+
status: "VALID"
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
return {
|
|
60
|
+
type: "ISSUER_IDENTITY",
|
|
61
|
+
name: "W3CIssuerIdentity",
|
|
62
|
+
data: false,
|
|
63
|
+
reason: {
|
|
64
|
+
message: `The DID cannot be resolved.`
|
|
65
|
+
},
|
|
66
|
+
status: "INVALID"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}, "verify")
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { w3cIssuerIdentity };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { verificationBuilder, openAttestationVerifiers, openAttestationDidIdentityProof } from '@govtechsg/oa-verify';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
|
|
4
|
+
import { w3cCredentialStatus } from './fragments/document-status/w3cCredentialStatus';
|
|
5
|
+
import { w3cIssuerIdentity } from './fragments/issuer-identity/w3cIssuerIdentity';
|
|
6
|
+
import { utils } from '@govtechsg/open-attestation';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
|
|
11
|
+
if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document) || utils.isWrappedV4Document(document)) {
|
|
12
|
+
const verify = verificationBuilder(
|
|
13
|
+
[...openAttestationVerifiers, openAttestationDidIdentityProof],
|
|
14
|
+
{
|
|
15
|
+
provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
16
|
+
// Use user-provided provider URL
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
return verify(document);
|
|
20
|
+
} else {
|
|
21
|
+
const verify = verificationBuilder(
|
|
22
|
+
[w3cSignatureIntegrity, w3cCredentialStatus, w3cIssuerIdentity],
|
|
23
|
+
{
|
|
24
|
+
provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
|
|
25
|
+
// Use user-provided provider URL
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
return verify(document);
|
|
29
|
+
}
|
|
30
|
+
}, "verifyDocument");
|
|
31
|
+
|
|
32
|
+
export { verifyDocument };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SUPPORTED_SIGNING_ALGORITHM, v4 } from '@govtechsg/open-attestation';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const { signDocument } = v4;
|
|
6
|
+
const signOA = /* @__PURE__ */ __name(async (document, keyPair) => {
|
|
7
|
+
return signDocument(document, SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018, keyPair);
|
|
8
|
+
}, "signOA");
|
|
9
|
+
|
|
10
|
+
export { signOA };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { utils, verifySignature } from '@govtechsg/open-attestation';
|
|
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) || utils.isWrappedV4Document(document)) {
|
|
7
|
+
return verifySignature(document);
|
|
8
|
+
} else {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}, "verifyOASignature");
|
|
12
|
+
|
|
13
|
+
export { verifyOASignature };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { v4 } from '@govtechsg/open-attestation';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const { wrapDocument } = v4;
|
|
6
|
+
const wrapOA = /* @__PURE__ */ __name(async (document) => {
|
|
7
|
+
return wrapDocument(document);
|
|
8
|
+
}, "wrapOA");
|
|
9
|
+
|
|
10
|
+
export { wrapOA };
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const encoder = new TextEncoder();
|
|
7
|
+
return encoder.encode(str);
|
|
8
|
+
}
|
|
9
|
+
__name(stringToUint8Array, "stringToUint8Array");
|
|
10
|
+
function generate32ByteKey(input) {
|
|
11
|
+
const hash = shake256(input, 128);
|
|
12
|
+
return hash;
|
|
13
|
+
}
|
|
14
|
+
__name(generate32ByteKey, "generate32ByteKey");
|
|
15
|
+
function generate12ByteNonce(input) {
|
|
16
|
+
const nonce = shake256(input, 48);
|
|
17
|
+
return nonce;
|
|
18
|
+
}
|
|
19
|
+
__name(generate12ByteNonce, "generate12ByteNonce");
|
|
20
|
+
|
|
21
|
+
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 { wrapOA } from './open-attestation/wrap.mjs';
|
|
2
|
+
export { signOA } from './open-attestation/sign.mjs';
|
|
3
|
+
export { verifyOASignature } from './open-attestation/verify.mjs';
|
|
4
|
+
export { KeyPair } from './open-attestation/types.mjs';
|
|
5
|
+
export { verifyDocument } from './core/verify.mjs';
|
|
6
|
+
export { encrypt } from './core/encrypt.mjs';
|
|
7
|
+
export { decrypt } from './core/decrypt.mjs';
|
|
8
|
+
export { signW3C } from './w3c/sign.mjs';
|
|
9
|
+
export { verifyW3CSignature } from './w3c/verify.mjs';
|
|
10
|
+
export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
|
|
11
|
+
export { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
12
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
|
|
13
|
+
import '@ethersproject/abstract-signer';
|
|
14
|
+
import '@govtechsg/oa-verify';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { wrapOA } from './open-attestation/wrap.js';
|
|
2
|
+
export { signOA } from './open-attestation/sign.js';
|
|
3
|
+
export { verifyOASignature } from './open-attestation/verify.js';
|
|
4
|
+
export { KeyPair } from './open-attestation/types.js';
|
|
5
|
+
export { verifyDocument } from './core/verify.js';
|
|
6
|
+
export { encrypt } from './core/encrypt.js';
|
|
7
|
+
export { decrypt } from './core/decrypt.js';
|
|
8
|
+
export { signW3C } from './w3c/sign.js';
|
|
9
|
+
export { verifyW3CSignature } from './w3c/verify.js';
|
|
10
|
+
export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
|
|
11
|
+
export { PrivateKeyPair } from '@trustvc/w3c-issuer';
|
|
12
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
|
|
13
|
+
import '@ethersproject/abstract-signer';
|
|
14
|
+
import '@govtechsg/oa-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 { wrapOA } from './wrap.mjs';
|
|
2
|
+
export { signOA } from './sign.mjs';
|
|
3
|
+
export { verifyOASignature } from './verify.mjs';
|
|
4
|
+
export { KeyPair } from './types.mjs';
|
|
5
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
|
|
6
|
+
import '@ethersproject/abstract-signer';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { wrapOA } from './wrap.js';
|
|
2
|
+
export { signOA } from './sign.js';
|
|
3
|
+
export { verifyOASignature } from './verify.js';
|
|
4
|
+
export { KeyPair } from './types.js';
|
|
5
|
+
export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
|
|
6
|
+
import '@ethersproject/abstract-signer';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var wrap = require('./wrap');
|
|
4
|
+
var sign = require('./sign');
|
|
5
|
+
var verify = require('./verify');
|
|
6
|
+
var types = require('./types');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.keys(wrap).forEach(function (k) {
|
|
11
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return wrap[k]; }
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
Object.keys(sign).forEach(function (k) {
|
|
17
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return sign[k]; }
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
Object.keys(verify).forEach(function (k) {
|
|
23
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return verify[k]; }
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
Object.keys(types).forEach(function (k) {
|
|
29
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return types[k]; }
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { v4 } from '@govtechsg/open-attestation';
|
|
2
|
+
import { KeyPair } from './types.mjs';
|
|
3
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
4
|
+
|
|
5
|
+
declare const signOA: (document: v4.WrappedDocument, keyPair: KeyPair | Signer) => Promise<v4.SignedWrappedDocument>;
|
|
6
|
+
|
|
7
|
+
export { signOA };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { v4 } from '@govtechsg/open-attestation';
|
|
2
|
+
import { KeyPair } from './types.js';
|
|
3
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
4
|
+
|
|
5
|
+
declare const signOA: (document: v4.WrappedDocument, keyPair: KeyPair | Signer) => Promise<v4.SignedWrappedDocument>;
|
|
6
|
+
|
|
7
|
+
export { signOA };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var openAttestation = require('@govtechsg/open-attestation');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const { signDocument } = openAttestation.v4;
|
|
8
|
+
const signOA = /* @__PURE__ */ __name(async (document, keyPair) => {
|
|
9
|
+
return signDocument(document, openAttestation.SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018, keyPair);
|
|
10
|
+
}, "signOA");
|
|
11
|
+
|
|
12
|
+
exports.signOA = signOA;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var openAttestation = require('@govtechsg/open-attestation');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "OpenAttestationDocument", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return openAttestation.OpenAttestationDocument; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "SignedWrappedDocument", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return openAttestation.SignedWrappedDocument; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "WrappedDocument", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return openAttestation.WrappedDocument; }
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var openAttestation = require('@govtechsg/open-attestation');
|
|
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 (openAttestation.utils.isWrappedV2Document(document) || openAttestation.utils.isWrappedV3Document(document) || openAttestation.utils.isWrappedV4Document(document)) {
|
|
9
|
+
return openAttestation.verifySignature(document);
|
|
10
|
+
} else {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}, "verifyOASignature");
|
|
14
|
+
|
|
15
|
+
exports.verifyOASignature = verifyOASignature;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var openAttestation = require('@govtechsg/open-attestation');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
const { wrapDocument } = openAttestation.v4;
|
|
8
|
+
const wrapOA = /* @__PURE__ */ __name(async (document) => {
|
|
9
|
+
return wrapDocument(document);
|
|
10
|
+
}, "wrapOA");
|
|
11
|
+
|
|
12
|
+
exports.wrapOA = wrapOA;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
const encoder = new TextEncoder();
|
|
9
|
+
return encoder.encode(str);
|
|
10
|
+
}
|
|
11
|
+
__name(stringToUint8Array, "stringToUint8Array");
|
|
12
|
+
function generate32ByteKey(input) {
|
|
13
|
+
const hash = jsSha3.shake256(input, 128);
|
|
14
|
+
return hash;
|
|
15
|
+
}
|
|
16
|
+
__name(generate32ByteKey, "generate32ByteKey");
|
|
17
|
+
function generate12ByteNonce(input) {
|
|
18
|
+
const nonce = jsSha3.shake256(input, 48);
|
|
19
|
+
return nonce;
|
|
20
|
+
}
|
|
21
|
+
__name(generate12ByteNonce, "generate12ByteNonce");
|
|
22
|
+
|
|
23
|
+
exports.generate12ByteNonce = generate12ByteNonce;
|
|
24
|
+
exports.generate32ByteKey = generate32ByteKey;
|
|
25
|
+
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
|
+
});
|
|
@@ -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 verifyW3CSignature = /* @__PURE__ */ __name(async (credential) => {
|
|
8
|
+
return w3cVc.verifyCredential(credential);
|
|
9
|
+
}, "verifyW3CSignature");
|
|
10
|
+
|
|
11
|
+
exports.verifyW3CSignature = verifyW3CSignature;
|