@veramo/credential-ld 3.1.1-next.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.
Files changed (67) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +6 -0
  3. package/build/action-handler.d.ts +28 -0
  4. package/build/action-handler.d.ts.map +1 -0
  5. package/build/action-handler.js +155 -0
  6. package/build/action-handler.js.map +1 -0
  7. package/build/index.d.ts +15 -0
  8. package/build/index.d.ts.map +1 -0
  9. package/build/index.js +31 -0
  10. package/build/index.js.map +1 -0
  11. package/build/ld-context-loader.d.ts +16 -0
  12. package/build/ld-context-loader.d.ts.map +1 -0
  13. package/build/ld-context-loader.js +40 -0
  14. package/build/ld-context-loader.js.map +1 -0
  15. package/build/ld-credential-module.d.ts +25 -0
  16. package/build/ld-credential-module.d.ts.map +1 -0
  17. package/build/ld-credential-module.js +148 -0
  18. package/build/ld-credential-module.js.map +1 -0
  19. package/build/ld-default-contexts.d.ts +6 -0
  20. package/build/ld-default-contexts.d.ts.map +1 -0
  21. package/build/ld-default-contexts.js +60 -0
  22. package/build/ld-default-contexts.js.map +1 -0
  23. package/build/ld-suite-loader.d.ts +15 -0
  24. package/build/ld-suite-loader.d.ts.map +1 -0
  25. package/build/ld-suite-loader.js +28 -0
  26. package/build/ld-suite-loader.js.map +1 -0
  27. package/build/ld-suites.d.ts +13 -0
  28. package/build/ld-suites.d.ts.map +1 -0
  29. package/build/ld-suites.js +15 -0
  30. package/build/ld-suites.js.map +1 -0
  31. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts +11 -0
  32. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts.map +1 -0
  33. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js +100 -0
  34. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js.map +1 -0
  35. package/build/suites/Ed25519Signature2018.d.ts +11 -0
  36. package/build/suites/Ed25519Signature2018.d.ts.map +1 -0
  37. package/build/suites/Ed25519Signature2018.js +92 -0
  38. package/build/suites/Ed25519Signature2018.js.map +1 -0
  39. package/build/tsdoc-metadata.json +11 -0
  40. package/build/types.d.ts +174 -0
  41. package/build/types.d.ts.map +1 -0
  42. package/build/types.js +3 -0
  43. package/build/types.js.map +1 -0
  44. package/contexts/X25519KeyAgreementKey2019.jsonld +26 -0
  45. package/contexts/did_v0.11.jsonld +58 -0
  46. package/contexts/ed25519-signature-2018-v1.jsonld +91 -0
  47. package/contexts/kyc-v1.jsonld +8 -0
  48. package/contexts/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld +60 -0
  49. package/contexts/profile-v1.jsonld +8 -0
  50. package/contexts/security_context_v1.jsonld +58 -0
  51. package/contexts/socialmedia-v1.jsonld +7 -0
  52. package/contexts/transmute_v1.jsonld +21 -0
  53. package/contexts/w3_2018_credentials_v1.jsonld +237 -0
  54. package/package.json +51 -0
  55. package/plugin.schema.json +398 -0
  56. package/src/__tests__/context.loader.test.ts +39 -0
  57. package/src/__tests__/issue-verify-flow.test.ts +84 -0
  58. package/src/action-handler.ts +229 -0
  59. package/src/index.ts +14 -0
  60. package/src/ld-context-loader.ts +30 -0
  61. package/src/ld-credential-module.ts +170 -0
  62. package/src/ld-default-contexts.ts +30 -0
  63. package/src/ld-suite-loader.ts +29 -0
  64. package/src/ld-suites.ts +45 -0
  65. package/src/suites/EcdsaSecp256k1RecoverySignature2020.ts +83 -0
  66. package/src/suites/Ed25519Signature2018.ts +75 -0
  67. package/src/types.ts +208 -0
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.LdCredentialModule = void 0;
35
+ const debug_1 = __importDefault(require("debug"));
36
+ const jsonld_signatures_1 = require("jsonld-signatures");
37
+ const vc = __importStar(require("vc-js"));
38
+ const AssertionProofPurpose = jsonld_signatures_1.purposes.AssertionProofPurpose;
39
+ const debug = (0, debug_1.default)('veramo:w3c:ld-credential-module');
40
+ class LdCredentialModule {
41
+ constructor(options) {
42
+ this.ldContextLoader = options.ldContextLoader;
43
+ this.ldSuiteLoader = options.ldSuiteLoader;
44
+ }
45
+ getDocumentLoader(context) {
46
+ return (0, jsonld_signatures_1.extendContextLoader)((url) => __awaiter(this, void 0, void 0, function* () {
47
+ // console.log(`resolving context for: ${url}`)
48
+ // did resolution
49
+ if (url.toLowerCase().startsWith('did:')) {
50
+ const resolutionResult = yield context.agent.resolveDid({ didUrl: url });
51
+ const didDoc = resolutionResult.didDocument;
52
+ if (!didDoc)
53
+ return;
54
+ // currently Veramo LD suites can modify the resolution response for DIDs from
55
+ // the document Loader. This allows to fix incompatibilities between DID Documents
56
+ // and LD suites to be fixed specifically within the Veramo LD Suites definition
57
+ this.ldSuiteLoader.getAllSignatureSuites().forEach((x) => x.preDidResolutionModification(url, didDoc));
58
+ // console.log(`Returning from Documentloader: ${JSON.stringify(returnDocument)}`)
59
+ return {
60
+ contextUrl: null,
61
+ documentUrl: url,
62
+ document: didDoc,
63
+ };
64
+ }
65
+ if (this.ldContextLoader.has(url)) {
66
+ const contextDoc = yield this.ldContextLoader.get(url);
67
+ return {
68
+ contextUrl: null,
69
+ documentUrl: url,
70
+ document: contextDoc,
71
+ };
72
+ }
73
+ debug('WARNING: Possible unknown context/identifier for', url);
74
+ console.log(`WARNING: Possible unknown context/identifier for: ${url}`);
75
+ return vc.defaultDocumentLoader(url);
76
+ }));
77
+ }
78
+ issueLDVerifiableCredential(credential, issuerDid, key, verificationMethodId, context) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type);
81
+ const documentLoader = this.getDocumentLoader(context);
82
+ // some suites can modify the incoming credential (e.g. add required contexts)W
83
+ suite.preSigningCredModification(credential);
84
+ return yield vc.issue({
85
+ credential,
86
+ suite: suite.getSuiteForSigning(key, issuerDid, verificationMethodId, context),
87
+ documentLoader,
88
+ compactProof: false,
89
+ });
90
+ });
91
+ }
92
+ signLDVerifiablePresentation(presentation, holderDid, key, verificationMethodId, challenge, domain, context) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const suite = this.ldSuiteLoader.getSignatureSuiteForKeyType(key.type);
95
+ const documentLoader = this.getDocumentLoader(context);
96
+ suite.preSigningPresModification(presentation);
97
+ return yield vc.signPresentation({
98
+ presentation,
99
+ suite: suite.getSuiteForSigning(key, holderDid, verificationMethodId, context),
100
+ challenge,
101
+ domain,
102
+ documentLoader,
103
+ purpose: new AssertionProofPurpose(),
104
+ compactProof: false,
105
+ });
106
+ });
107
+ }
108
+ verifyCredential(credential, context) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const result = yield vc.verifyCredential({
111
+ credential,
112
+ suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
113
+ documentLoader: this.getDocumentLoader(context),
114
+ purpose: new AssertionProofPurpose(),
115
+ compactProof: false,
116
+ });
117
+ if (result.verified)
118
+ return true;
119
+ // NOT verified.
120
+ // result can include raw Error
121
+ debug(`Error verifying LD Verifiable Credential: ${JSON.stringify(result, null, 2)}`);
122
+ // console.log(JSON.stringify(result, null, 2));
123
+ throw Error('Error verifying LD Verifiable Credential');
124
+ });
125
+ }
126
+ verifyPresentation(presentation, challenge, domain, context) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const result = yield vc.verify({
129
+ presentation,
130
+ suite: this.ldSuiteLoader.getAllSignatureSuites().map((x) => x.getSuiteForVerification()),
131
+ documentLoader: this.getDocumentLoader(context),
132
+ challenge,
133
+ domain,
134
+ purpose: new AssertionProofPurpose(),
135
+ compactProof: false,
136
+ });
137
+ if (result.verified)
138
+ return true;
139
+ // NOT verified.
140
+ // result can include raw Error
141
+ console.log(`Error verifying LD Verifiable Presentation`);
142
+ console.log(JSON.stringify(result, null, 2));
143
+ throw Error('Error verifying LD Verifiable Presentation');
144
+ });
145
+ }
146
+ }
147
+ exports.LdCredentialModule = LdCredentialModule;
148
+ //# sourceMappingURL=ld-credential-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-credential-module.js","sourceRoot":"","sources":["../src/ld-credential-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,kDAAyB;AACzB,yDAAiE;AACjE,0CAA2B;AAK3B,MAAM,qBAAqB,GAAG,4BAAQ,CAAC,qBAAqB,CAAA;AAE5D,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iCAAiC,CAAC,CAAA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YAEhB,+BAA+B;YAC/B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;YAC5C,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAA;QAC3D,CAAC;KAAA;CACF;AArJD,gDAqJC"}
@@ -0,0 +1,6 @@
1
+ import { ContextDoc } from './types';
2
+ /**
3
+ * Provides a hardcoded map of common context definitions
4
+ */
5
+ export declare const LdDefaultContexts: Map<string, Promise<ContextDoc>>;
6
+ //# sourceMappingURL=ld-default-contexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-default-contexts.d.ts","sourceRoot":"","sources":["../src/ld-default-contexts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AASpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,kCAe5B,CAAA"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.LdDefaultContexts = void 0;
32
+ const fs = __importStar(require("fs"));
33
+ const path = __importStar(require("path"));
34
+ function _read(_path) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const contextDefinition = yield fs.promises.readFile(path.join(__dirname, '../contexts', _path), {
37
+ encoding: 'utf8',
38
+ });
39
+ return JSON.parse(contextDefinition);
40
+ });
41
+ }
42
+ /**
43
+ * Provides a hardcoded map of common context definitions
44
+ */
45
+ exports.LdDefaultContexts = new Map([
46
+ ['https://www.w3.org/2018/credentials/v1', _read('w3_2018_credentials_v1.jsonld')],
47
+ ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
48
+ ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
49
+ ['https://veramo.io/contexts/socialmedia/v1', _read('socialmedia-v1.jsonld')],
50
+ ['https://veramo.io/contexts/kyc/v1', _read('kyc-v1.jsonld')],
51
+ ['https://veramo.io/contexts/profile/v1', _read('profile-v1.jsonld')],
52
+ ['https://ns.did.ai/transmute/v1', _read('transmute_v1.jsonld')],
53
+ [
54
+ 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
55
+ _read('lds-ecdsa-secp256k1-recovery2020-0.0.jsonld'),
56
+ ],
57
+ ['https://w3id.org/security/suites/ed25519-2018/v1', _read('ed25519-signature-2018-v1.jsonld')],
58
+ ['https://w3id.org/security/suites/x25519-2019/v1', _read('X25519KeyAgreementKey2019.jsonld')],
59
+ ]);
60
+ //# sourceMappingURL=ld-default-contexts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-default-contexts.js","sourceRoot":"","sources":["../src/ld-default-contexts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAG5B,SAAe,KAAK,CAAC,KAAa;;QAChC,MAAM,iBAAiB,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE;YAC/F,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACtC,CAAC;CAAA;AAED;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACvC,CAAC,wCAAwC,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAClF,CAAC,8BAA8B,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACrE,CAAC,4BAA4B,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEzD,CAAC,2CAA2C,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7E,CAAC,mCAAmC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7D,CAAC,uCAAuC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACrE,CAAC,gCAAgC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAChE;QACE,6GAA6G;QAC7G,KAAK,CAAC,6CAA6C,CAAC;KACrD;IACD,CAAC,kDAAkD,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC/F,CAAC,iDAAiD,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;CAC/F,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { VeramoLdSignature } from './ld-suites';
2
+ import { TKeyType } from '@veramo/core';
3
+ /**
4
+ * Initializes a list of Veramo-wrapped LD Signature suites and exposes those to the Agent Module
5
+ */
6
+ export declare class LdSuiteLoader {
7
+ constructor(options: {
8
+ veramoLdSignatures: VeramoLdSignature[];
9
+ });
10
+ private signatureMap;
11
+ getSignatureSuiteForKeyType(type: TKeyType): VeramoLdSignature;
12
+ getAllSignatureSuites(): VeramoLdSignature[];
13
+ getAllSignatureSuiteTypes(): string[];
14
+ }
15
+ //# sourceMappingURL=ld-suite-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-suite-loader.d.ts","sourceRoot":"","sources":["../src/ld-suite-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC;;GAEG;AACH,qBAAa,aAAa;gBACZ,OAAO,EAAE;QAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAA;KAAE;IAKhE,OAAO,CAAC,YAAY,CAAwC;IAE5D,2BAA2B,CAAC,IAAI,EAAE,QAAQ;IAO1C,qBAAqB;IAIrB,yBAAyB;CAG1B"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LdSuiteLoader = void 0;
4
+ /**
5
+ * Initializes a list of Veramo-wrapped LD Signature suites and exposes those to the Agent Module
6
+ */
7
+ class LdSuiteLoader {
8
+ constructor(options) {
9
+ this.signatureMap = {};
10
+ options.veramoLdSignatures.forEach((obj) => {
11
+ this.signatureMap[obj.getSupportedVeramoKeyType()] = obj;
12
+ });
13
+ }
14
+ getSignatureSuiteForKeyType(type) {
15
+ const suite = this.signatureMap[type];
16
+ if (suite)
17
+ return suite;
18
+ throw new Error('No Veramo LD Signature Suite for ' + type);
19
+ }
20
+ getAllSignatureSuites() {
21
+ return Object.values(this.signatureMap);
22
+ }
23
+ getAllSignatureSuiteTypes() {
24
+ return Object.values(this.signatureMap).map((x) => x.getSupportedVerificationType());
25
+ }
26
+ }
27
+ exports.LdSuiteLoader = LdSuiteLoader;
28
+ //# sourceMappingURL=ld-suite-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-suite-loader.js","sourceRoot":"","sources":["../src/ld-suite-loader.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,aAAa;IACxB,YAAY,OAAoD;QAKxD,iBAAY,GAAsC,EAAE,CAAA;QAJ1D,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACzC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,yBAAyB,EAAE,CAAC,GAAG,GAAG,CAAA;QAC1D,CAAC,CAAC,CAAA;IACJ,CAAC;IAGD,2BAA2B,CAAC,IAAc;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACrC,IAAI,KAAK;YAAE,OAAO,KAAK,CAAA;QAEvB,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAAA;IAC7D,CAAC;IAED,qBAAqB;QACnB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACzC,CAAC;IAED,yBAAyB;QACvB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,4BAA4B,EAAE,CAAC,CAAA;IACtF,CAAC;CACF;AAtBD,sCAsBC"}
@@ -0,0 +1,13 @@
1
+ import { CredentialPayload, IAgentContext, IKey, IKeyManager, IResolver, PresentationPayload, TKeyType } from '@veramo/core';
2
+ import { DIDDocument } from 'did-resolver/src/resolver';
3
+ export declare type RequiredAgentMethods = IResolver & Pick<IKeyManager, 'keyManagerGet' | 'keyManagerSign'>;
4
+ export declare abstract class VeramoLdSignature {
5
+ abstract getSupportedVerificationType(): string;
6
+ abstract getSupportedVeramoKeyType(): TKeyType;
7
+ abstract getSuiteForSigning(key: IKey, issuerDid: string, verificationMethodId: string, context: IAgentContext<RequiredAgentMethods>): any;
8
+ abstract getSuiteForVerification(): any;
9
+ abstract preDidResolutionModification(didUrl: string, didDoc: DIDDocument): void;
10
+ abstract preSigningCredModification(credential: CredentialPayload): void;
11
+ preSigningPresModification(presentation: PresentationPayload): void;
12
+ }
13
+ //# sourceMappingURL=ld-suites.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-suites.d.ts","sourceRoot":"","sources":["../src/ld-suites.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACT,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,oBAAY,oBAAoB,GAAG,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,gBAAgB,CAAC,CAAA;AAEpG,8BAAsB,iBAAiB;IAMrC,QAAQ,CAAC,4BAA4B,IAAI,MAAM;IAE/C,QAAQ,CAAC,yBAAyB,IAAI,QAAQ;IAE9C,QAAQ,CAAC,kBAAkB,CACzB,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAC3C,GAAG;IAEN,QAAQ,CAAC,uBAAuB,IAAI,GAAG;IAEvC,QAAQ,CAAC,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAEhF,QAAQ,CAAC,0BAA0B,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAExE,0BAA0B,CAAC,YAAY,EAAE,mBAAmB,GAAG,IAAI;CAQpE"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VeramoLdSignature = void 0;
4
+ class VeramoLdSignature {
5
+ preSigningPresModification(presentation) {
6
+ // TODO: Remove invalid field 'verifiers' from Presentation. Needs to be adapted for LD credentials
7
+ // Only remove empty array (vc.signPresentation will throw then)
8
+ const sanitizedPresentation = presentation;
9
+ if (sanitizedPresentation.verifier.length == 0) {
10
+ delete sanitizedPresentation.verifier;
11
+ }
12
+ }
13
+ }
14
+ exports.VeramoLdSignature = VeramoLdSignature;
15
+ //# sourceMappingURL=ld-suites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ld-suites.js","sourceRoot":"","sources":["../src/ld-suites.ts"],"names":[],"mappings":";;;AAaA,MAAsB,iBAAiB;IAuBrC,0BAA0B,CAAC,YAAiC;QAC1D,mGAAmG;QACnG,gEAAgE;QAChE,MAAM,qBAAqB,GAAG,YAAmB,CAAA;QACjD,IAAI,qBAAqB,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;YAC9C,OAAO,qBAAqB,CAAC,QAAQ,CAAA;SACtC;IACH,CAAC;CACF;AA/BD,8CA+BC"}
@@ -0,0 +1,11 @@
1
+ import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites';
2
+ import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@veramo/core';
3
+ export declare class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature {
4
+ getSupportedVerificationType(): string;
5
+ getSupportedVeramoKeyType(): TKeyType;
6
+ getSuiteForSigning(key: IKey, did: string, verifiableMethodId: string, context: IAgentContext<RequiredAgentMethods>): any;
7
+ getSuiteForVerification(): any;
8
+ preSigningCredModification(credential: CredentialPayload): void;
9
+ preDidResolutionModification(didUrl: string, didDoc: DIDDocument): void;
10
+ }
11
+ //# sourceMappingURL=EcdsaSecp256k1RecoverySignature2020.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EcdsaSecp256k1RecoverySignature2020.d.ts","sourceRoot":"","sources":["../../src/suites/EcdsaSecp256k1RecoverySignature2020.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAS5F,qBAAa,yCAA0C,SAAQ,iBAAiB;IAC9E,4BAA4B,IAAI,MAAM;IAItC,yBAAyB,IAAI,QAAQ;IAIrC,kBAAkB,CAChB,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAC3C,GAAG;IAmCN,uBAAuB,IAAI,GAAG;IAI9B,0BAA0B,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAO/D,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;CAYxE"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.VeramoEcdsaSecp256k1RecoverySignature2020 = void 0;
32
+ const ld_suites_1 = require("../ld-suites");
33
+ const lds_ecdsa_secp256k1_recovery2020_1 = require("@transmute/lds-ecdsa-secp256k1-recovery2020");
34
+ const u8a = __importStar(require("uint8arrays"));
35
+ const utils_1 = require("@veramo/utils");
36
+ class VeramoEcdsaSecp256k1RecoverySignature2020 extends ld_suites_1.VeramoLdSignature {
37
+ getSupportedVerificationType() {
38
+ return 'EcdsaSecp256k1RecoveryMethod2020';
39
+ }
40
+ getSupportedVeramoKeyType() {
41
+ return 'Secp256k1';
42
+ }
43
+ getSuiteForSigning(key, did, verifiableMethodId, context) {
44
+ const controller = did;
45
+ const signer = {
46
+ //returns a JWS detached
47
+ sign: (args) => __awaiter(this, void 0, void 0, function* () {
48
+ const header = {
49
+ alg: 'ES256K-R',
50
+ b64: false,
51
+ crit: ['b64'],
52
+ };
53
+ const headerString = (0, utils_1.encodeJoseBlob)(header);
54
+ const messageBuffer = u8a.concat([u8a.fromString(`${headerString}.`, 'utf-8'), args.data]);
55
+ const messageString = u8a.toString(messageBuffer, 'base64');
56
+ const signature = yield context.agent.keyManagerSign({
57
+ keyRef: key.kid,
58
+ algorithm: 'ES256K-R',
59
+ data: messageString,
60
+ encoding: 'base64',
61
+ });
62
+ return `${headerString}..${signature}`;
63
+ }),
64
+ };
65
+ return new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoverySignature2020({
66
+ // signer,
67
+ key: new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoveryMethod2020({
68
+ publicKeyHex: key.publicKeyHex,
69
+ signer: () => signer,
70
+ type: this.getSupportedVerificationType(),
71
+ controller,
72
+ id: verifiableMethodId,
73
+ }),
74
+ });
75
+ }
76
+ getSuiteForVerification() {
77
+ return new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoverySignature2020();
78
+ }
79
+ preSigningCredModification(credential) {
80
+ credential['@context'] = [
81
+ ...(0, utils_1.asArray)(credential['@context'] || []),
82
+ 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
83
+ ];
84
+ }
85
+ preDidResolutionModification(didUrl, didDoc) {
86
+ var _a;
87
+ // did:ethr
88
+ if (didUrl.toLowerCase().startsWith('did:ethr')) {
89
+ // TODO: EcdsaSecp256k1RecoveryMethod2020 does not support blockchainAccountId
90
+ // blockchainAccountId to ethereumAddress
91
+ (_a = didDoc.verificationMethod) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
92
+ if (x.blockchainAccountId) {
93
+ x.ethereumAddress = x.blockchainAccountId.substring(0, x.blockchainAccountId.lastIndexOf('@'));
94
+ }
95
+ });
96
+ }
97
+ }
98
+ }
99
+ exports.VeramoEcdsaSecp256k1RecoverySignature2020 = VeramoEcdsaSecp256k1RecoverySignature2020;
100
+ //# sourceMappingURL=EcdsaSecp256k1RecoverySignature2020.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EcdsaSecp256k1RecoverySignature2020.js","sourceRoot":"","sources":["../../src/suites/EcdsaSecp256k1RecoverySignature2020.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAsE;AAEtE,kGAGoD;AAEpD,iDAAkC;AAClC,yCAAuD;AAEvD,MAAa,yCAA0C,SAAQ,6BAAiB;IAC9E,4BAA4B;QAC1B,OAAO,kCA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,CAAA;IACJ,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,sEAAmC,EAAE,CAAA;IAClD,CAAC;IAED,0BAA0B,CAAC,UAA6B;QACtD,UAAU,CAAC,UAAU,CAAC,GAAG;YACvB,GAAG,IAAA,eAAO,EAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACxC,6GAA6G;SAC9G,CAAA;IACH,CAAC;IAED,4BAA4B,CAAC,MAAc,EAAE,MAAmB;;QAC9D,WAAW;QACX,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAC/C,8EAA8E;YAC9E,yCAAyC;YACzC,MAAA,MAAM,CAAC,kBAAkB,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACvC,IAAI,CAAC,CAAC,mBAAmB,EAAE;oBACzB,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;iBAC/F;YACH,CAAC,CAAC,CAAA;SACH;IACH,CAAC;CACF;AAxED,8FAwEC"}
@@ -0,0 +1,11 @@
1
+ import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites';
2
+ import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@veramo/core';
3
+ export declare class VeramoEd25519Signature2018 extends VeramoLdSignature {
4
+ getSupportedVerificationType(): string;
5
+ getSupportedVeramoKeyType(): TKeyType;
6
+ getSuiteForSigning(key: IKey, issuerDid: string, verificationMethodId: string, context: IAgentContext<RequiredAgentMethods>): any;
7
+ getSuiteForVerification(): any;
8
+ preSigningCredModification(credential: CredentialPayload): void;
9
+ preDidResolutionModification(didUrl: string, didDoc: DIDDocument): void;
10
+ }
11
+ //# sourceMappingURL=Ed25519Signature2018.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519Signature2018.d.ts","sourceRoot":"","sources":["../../src/suites/Ed25519Signature2018.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5F,qBAAa,0BAA2B,SAAQ,iBAAiB;IAC/D,4BAA4B,IAAI,MAAM;IAItC,yBAAyB,IAAI,QAAQ;IAIrC,kBAAkB,CAChB,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAC3C,GAAG;IA2CN,uBAAuB,IAAI,GAAG;IAI9B,0BAA0B,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAI/D,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;CAGxE"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.VeramoEd25519Signature2018 = void 0;
32
+ const utils_1 = require("@veramo/utils");
33
+ const ld_suites_1 = require("../ld-suites");
34
+ const u8a = __importStar(require("uint8arrays"));
35
+ const ed25519_signature_2018_1 = require("@transmute/ed25519-signature-2018");
36
+ class VeramoEd25519Signature2018 extends ld_suites_1.VeramoLdSignature {
37
+ getSupportedVerificationType() {
38
+ return 'Ed25519VerificationKey2018';
39
+ }
40
+ getSupportedVeramoKeyType() {
41
+ return 'Ed25519';
42
+ }
43
+ getSuiteForSigning(key, issuerDid, verificationMethodId, context) {
44
+ const controller = issuerDid;
45
+ // DID Key ID
46
+ let id = verificationMethodId;
47
+ const signer = {
48
+ // returns a JWS detached
49
+ sign: (args) => __awaiter(this, void 0, void 0, function* () {
50
+ const header = {
51
+ alg: 'EdDSA',
52
+ b64: false,
53
+ crit: ['b64'],
54
+ };
55
+ const headerString = (0, utils_1.encodeJoseBlob)(header);
56
+ const messageBuffer = u8a.concat([u8a.fromString(`${headerString}.`, 'utf-8'), args.data]);
57
+ const messageString = u8a.toString(messageBuffer, 'base64');
58
+ const signature = yield context.agent.keyManagerSign({
59
+ keyRef: key.kid,
60
+ algorithm: 'EdDSA',
61
+ data: messageString,
62
+ encoding: 'base64',
63
+ });
64
+ return `${headerString}..${signature}`;
65
+ }),
66
+ };
67
+ const verificationKey = new ed25519_signature_2018_1.Ed25519VerificationKey2018({
68
+ id,
69
+ controller,
70
+ publicKey: u8a.fromString(key.publicKeyHex, 'base16'),
71
+ signer: () => signer,
72
+ type: this.getSupportedVerificationType(),
73
+ });
74
+ // overwrite the signer since we're not passing the private key and transmute doesn't support that behavior
75
+ verificationKey.signer = () => signer;
76
+ return new ed25519_signature_2018_1.Ed25519Signature2018({
77
+ key: verificationKey,
78
+ signer: signer,
79
+ });
80
+ }
81
+ getSuiteForVerification() {
82
+ return new ed25519_signature_2018_1.Ed25519Signature2018();
83
+ }
84
+ preSigningCredModification(credential) {
85
+ // nothing to do here
86
+ }
87
+ preDidResolutionModification(didUrl, didDoc) {
88
+ // nothing to do here
89
+ }
90
+ }
91
+ exports.VeramoEd25519Signature2018 = VeramoEd25519Signature2018;
92
+ //# sourceMappingURL=Ed25519Signature2018.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519Signature2018.js","sourceRoot":"","sources":["../../src/suites/Ed25519Signature2018.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA8C;AAC9C,4CAAsE;AAEtE,iDAAkC;AAClC,8EAAoG;AAEpG,MAAa,0BAA2B,SAAQ,6BAAiB;IAC/D,4BAA4B;QAC1B,OAAO,4BAA4B,CAAA;IACrC,CAAC;IAED,yBAAyB;QACvB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,kBAAkB,CAChB,GAAS,EACT,SAAiB,EACjB,oBAA4B,EAC5B,OAA4C;QAE5C,MAAM,UAAU,GAAG,SAAS,CAAA;QAE5B,aAAa;QACb,IAAI,EAAE,GAAG,oBAAoB,CAAA;QAE7B,MAAM,MAAM,GAAG;YACb,yBAAyB;YACzB,IAAI,EAAE,CAAO,IAA0B,EAAmB,EAAE;gBAC1D,MAAM,MAAM,GAAG;oBACb,GAAG,EAAE,OAAO;oBACZ,GAAG,EAAE,KAAK;oBACV,IAAI,EAAE,CAAC,KAAK,CAAC;iBACd,CAAA;gBACD,MAAM,YAAY,GAAG,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAA;gBAC3C,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;gBAC1F,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;gBAC3D,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;oBACnD,MAAM,EAAE,GAAG,CAAC,GAAG;oBACf,SAAS,EAAE,OAAO;oBAClB,IAAI,EAAE,aAAa;oBACnB,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CAAA;gBACF,OAAO,GAAG,YAAY,KAAK,SAAS,EAAE,CAAA;YACxC,CAAC,CAAA;SACF,CAAA;QAED,MAAM,eAAe,GAAG,IAAI,mDAA0B,CAAC;YACrD,EAAE;YACF,UAAU;YACV,SAAS,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC;YACrD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM;YACpB,IAAI,EAAE,IAAI,CAAC,4BAA4B,EAAE;SAC1C,CAAC,CAAA;QACF,2GAA2G;QAC3G,eAAe,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAa,CAAA;QAE5C,OAAO,IAAI,6CAAoB,CAAC;YAC9B,GAAG,EAAE,eAAe;YACpB,MAAM,EAAE,MAAM;SACf,CAAC,CAAA;IACJ,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,6CAAoB,EAAE,CAAA;IACnC,CAAC;IAED,0BAA0B,CAAC,UAA6B;QACtD,qBAAqB;IACvB,CAAC;IAED,4BAA4B,CAAC,MAAc,EAAE,MAAmB;QAC9D,qBAAqB;IACvB,CAAC;CACF;AApED,gEAoEC"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.18.19"
9
+ }
10
+ ]
11
+ }