@trustvc/trustvc 0.0.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +201 -0
  2. package/dist/__tests__/fixtures/fixtures.d.mts +436 -0
  3. package/dist/__tests__/fixtures/fixtures.d.ts +436 -0
  4. package/dist/__tests__/fixtures/fixtures.js +715 -0
  5. package/dist/core/decrypt.d.mts +3 -0
  6. package/dist/core/decrypt.d.ts +3 -0
  7. package/dist/core/decrypt.js +23 -0
  8. package/dist/core/encrypt.d.mts +3 -0
  9. package/dist/core/encrypt.d.ts +3 -0
  10. package/dist/core/encrypt.js +23 -0
  11. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.mts +5 -0
  12. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.ts +5 -0
  13. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.js +48 -0
  14. package/dist/core/fragments/document-status/w3cCredentialStatus.d.mts +5 -0
  15. package/dist/core/fragments/document-status/w3cCredentialStatus.d.ts +5 -0
  16. package/dist/core/fragments/document-status/w3cCredentialStatus.js +54 -0
  17. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.mts +5 -0
  18. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.ts +5 -0
  19. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.js +74 -0
  20. package/dist/core/index.d.mts +5 -0
  21. package/dist/core/index.d.ts +5 -0
  22. package/dist/core/index.js +26 -0
  23. package/dist/core/verify.d.mts +6 -0
  24. package/dist/core/verify.d.ts +6 -0
  25. package/dist/core/verify.js +34 -0
  26. package/dist/esm/__tests__/fixtures/fixtures.js +701 -0
  27. package/dist/esm/core/decrypt.js +21 -0
  28. package/dist/esm/core/encrypt.js +21 -0
  29. package/dist/esm/core/fragments/document-integrity/w3cSignatureIntegrity.js +46 -0
  30. package/dist/esm/core/fragments/document-status/w3cCredentialStatus.js +52 -0
  31. package/dist/esm/core/fragments/issuer-identity/w3cIssuerIdentity.js +72 -0
  32. package/dist/esm/core/index.js +3 -0
  33. package/dist/esm/core/verify.js +32 -0
  34. package/dist/esm/index.js +3 -1
  35. package/dist/esm/open-attestation/index.js +4 -0
  36. package/dist/esm/open-attestation/sign.js +10 -0
  37. package/dist/esm/open-attestation/types.js +1 -0
  38. package/dist/esm/open-attestation/verify.js +13 -0
  39. package/dist/esm/open-attestation/wrap.js +10 -0
  40. package/dist/esm/utils/stringUtils.js +21 -0
  41. package/dist/esm/w3c/index.js +3 -0
  42. package/dist/esm/w3c/sign.js +9 -0
  43. package/dist/esm/w3c/types.js +2 -0
  44. package/dist/esm/w3c/verify.js +9 -0
  45. package/dist/index.d.mts +14 -2
  46. package/dist/index.d.ts +14 -2
  47. package/dist/index.js +24 -0
  48. package/dist/open-attestation/index.d.mts +6 -0
  49. package/dist/open-attestation/index.d.ts +6 -0
  50. package/dist/open-attestation/index.js +33 -0
  51. package/dist/open-attestation/sign.d.mts +7 -0
  52. package/dist/open-attestation/sign.d.ts +7 -0
  53. package/dist/open-attestation/sign.js +12 -0
  54. package/dist/open-attestation/types.d.mts +8 -0
  55. package/dist/open-attestation/types.d.ts +8 -0
  56. package/dist/open-attestation/types.js +18 -0
  57. package/dist/open-attestation/verify.d.mts +5 -0
  58. package/dist/open-attestation/verify.d.ts +5 -0
  59. package/dist/open-attestation/verify.js +15 -0
  60. package/dist/open-attestation/wrap.d.mts +5 -0
  61. package/dist/open-attestation/wrap.d.ts +5 -0
  62. package/dist/open-attestation/wrap.js +12 -0
  63. package/dist/utils/stringUtils.d.mts +5 -0
  64. package/dist/utils/stringUtils.d.ts +5 -0
  65. package/dist/utils/stringUtils.js +25 -0
  66. package/dist/w3c/index.d.mts +4 -0
  67. package/dist/w3c/index.d.ts +4 -0
  68. package/dist/w3c/index.js +26 -0
  69. package/dist/w3c/sign.d.mts +6 -0
  70. package/dist/w3c/sign.d.ts +6 -0
  71. package/dist/w3c/sign.js +11 -0
  72. package/dist/w3c/types.d.mts +2 -0
  73. package/dist/w3c/types.d.ts +2 -0
  74. package/dist/w3c/types.js +27 -0
  75. package/dist/w3c/verify.d.mts +5 -0
  76. package/dist/w3c/verify.d.ts +5 -0
  77. package/dist/w3c/verify.js +11 -0
  78. package/package.json +16 -2
  79. package/dist/.coverage/.tmp/coverage-0.json +0 -1
  80. package/dist/esm/.coverage/.tmp/coverage-0.json +0 -1
  81. package/dist/esm/node_modules/.vitest/vitest/results.json +0 -1
  82. package/dist/esm/types.js +0 -1
  83. package/dist/node_modules/.vitest/vitest/results.json +0 -1
  84. package/dist/types.d.mts +0 -2
  85. package/dist/types.d.ts +0 -2
  86. package/dist/types.js +0 -2
@@ -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,3 @@
1
+ export * from './verify';
2
+ export * from './encrypt';
3
+ export * from './decrypt';
@@ -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 };
package/dist/esm/index.js CHANGED
@@ -1 +1,3 @@
1
-
1
+ export * from './open-attestation';
2
+ export * from './core';
3
+ export * from './w3c';
@@ -0,0 +1,4 @@
1
+ export * from './wrap';
2
+ export * from './sign';
3
+ export * from './verify';
4
+ export * from './types';
@@ -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,3 @@
1
+ export * from './sign';
2
+ export * from './verify';
3
+ export * from './types';
@@ -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,2 @@
1
+ export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
2
+ export { PrivateKeyPair } from '@trustvc/w3c-issuer';
@@ -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 CHANGED
@@ -1,2 +1,14 @@
1
-
2
- export { }
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 CHANGED
@@ -1,2 +1,14 @@
1
-
2
- export { }
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 CHANGED
@@ -1,2 +1,26 @@
1
1
  'use strict';
2
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,8 @@
1
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
2
+
3
+ type KeyPair = {
4
+ public: string;
5
+ private: string;
6
+ };
7
+
8
+ export type { KeyPair };
@@ -0,0 +1,8 @@
1
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@govtechsg/open-attestation';
2
+
3
+ type KeyPair = {
4
+ public: string;
5
+ private: string;
6
+ };
7
+
8
+ export type { KeyPair };
@@ -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,5 @@
1
+ import { v2, v3, v4 } from '@govtechsg/open-attestation';
2
+
3
+ declare const verifyOASignature: (document: v2.WrappedDocument | v3.WrappedDocument | v4.WrappedDocument) => Promise<boolean>;
4
+
5
+ export { verifyOASignature };
@@ -0,0 +1,5 @@
1
+ import { v2, v3, v4 } from '@govtechsg/open-attestation';
2
+
3
+ declare const verifyOASignature: (document: v2.WrappedDocument | v3.WrappedDocument | v4.WrappedDocument) => Promise<boolean>;
4
+
5
+ export { verifyOASignature };
@@ -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,5 @@
1
+ import { v4 } from '@govtechsg/open-attestation';
2
+
3
+ declare const wrapOA: (document: v4.OpenAttestationDocument) => Promise<v4.WrappedDocument>;
4
+
5
+ export { wrapOA };
@@ -0,0 +1,5 @@
1
+ import { v4 } from '@govtechsg/open-attestation';
2
+
3
+ declare const wrapOA: (document: v4.OpenAttestationDocument) => Promise<v4.WrappedDocument>;
4
+
5
+ export { wrapOA };
@@ -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,5 @@
1
+ declare function stringToUint8Array(str: string): Uint8Array;
2
+ declare function generate32ByteKey(input: string): string;
3
+ declare function generate12ByteNonce(input: string): string;
4
+
5
+ export { generate12ByteNonce, generate32ByteKey, stringToUint8Array };
@@ -0,0 +1,5 @@
1
+ declare function stringToUint8Array(str: string): Uint8Array;
2
+ declare function generate32ByteKey(input: string): string;
3
+ declare function generate12ByteNonce(input: string): string;
4
+
5
+ export { generate12ByteNonce, generate32ByteKey, stringToUint8Array };
@@ -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,4 @@
1
+ export { signW3C } from './sign.mjs';
2
+ export { verifyW3CSignature } from './verify.mjs';
3
+ export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
4
+ export { PrivateKeyPair } from '@trustvc/w3c-issuer';