@ayanworks/credo-polygon-w3c-module 2.0.0-alpha.1 → 2.0.0

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 (89) hide show
  1. package/build/PolygonApi.d.mts +53 -0
  2. package/build/PolygonApi.d.mts.map +1 -0
  3. package/build/PolygonApi.mjs +41 -0
  4. package/build/PolygonApi.mjs.map +1 -0
  5. package/build/PolygonModule.d.mts +14 -0
  6. package/build/PolygonModule.d.mts.map +1 -0
  7. package/build/PolygonModule.mjs +31 -0
  8. package/build/PolygonModule.mjs.map +1 -0
  9. package/build/PolygonModuleConfig.d.mts +28 -0
  10. package/build/PolygonModuleConfig.d.mts.map +1 -0
  11. package/build/PolygonModuleConfig.mjs +14 -0
  12. package/build/PolygonModuleConfig.mjs.map +1 -0
  13. package/build/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs +10 -0
  14. package/build/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorateMetadata.mjs +7 -0
  15. package/build/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorateParam.mjs +9 -0
  16. package/build/dids/PolygonDidRegistrar.d.mts +39 -0
  17. package/build/dids/PolygonDidRegistrar.d.mts.map +1 -0
  18. package/build/dids/PolygonDidRegistrar.mjs +260 -0
  19. package/build/dids/PolygonDidRegistrar.mjs.map +1 -0
  20. package/build/dids/PolygonDidResolver.d.mts +14 -0
  21. package/build/dids/PolygonDidResolver.d.mts.map +1 -0
  22. package/build/dids/PolygonDidResolver.mjs +38 -0
  23. package/build/dids/PolygonDidResolver.mjs.map +1 -0
  24. package/build/dids/didPolygonUtil.d.mts +2 -0
  25. package/build/dids/didPolygonUtil.mjs +64 -0
  26. package/build/dids/didPolygonUtil.mjs.map +1 -0
  27. package/build/dids/index.d.mts +3 -0
  28. package/build/dids/index.mjs +3 -0
  29. package/build/index.d.mts +10 -0
  30. package/build/index.mjs +11 -0
  31. package/build/ledger/PolygonLedgerService.d.mts +116 -0
  32. package/build/ledger/PolygonLedgerService.d.mts.map +1 -0
  33. package/build/ledger/PolygonLedgerService.mjs +172 -0
  34. package/build/ledger/PolygonLedgerService.mjs.map +1 -0
  35. package/build/ledger/index.d.mts +1 -0
  36. package/build/ledger/index.mjs +1 -0
  37. package/build/signature-suites/EcdsaSecp256k1Signature2019.mjs +117 -0
  38. package/build/signature-suites/EcdsaSecp256k1Signature2019.mjs.map +1 -0
  39. package/build/signature-suites/index.mjs +1 -0
  40. package/build/utils/index.d.mts +1 -0
  41. package/build/utils/index.mjs +1 -0
  42. package/build/utils/utils.d.mts +12 -0
  43. package/build/utils/utils.d.mts.map +1 -0
  44. package/build/utils/utils.mjs +39 -0
  45. package/build/utils/utils.mjs.map +1 -0
  46. package/package.json +26 -47
  47. package/README.md +0 -30
  48. package/build/PolygonApi.d.ts +0 -35
  49. package/build/PolygonApi.js +0 -42
  50. package/build/PolygonApi.js.map +0 -1
  51. package/build/PolygonModule.d.ts +0 -10
  52. package/build/PolygonModule.js +0 -31
  53. package/build/PolygonModule.js.map +0 -1
  54. package/build/PolygonModuleConfig.d.ts +0 -18
  55. package/build/PolygonModuleConfig.js +0 -14
  56. package/build/PolygonModuleConfig.js.map +0 -1
  57. package/build/dids/PolygonDidRegistrar.d.ts +0 -30
  58. package/build/dids/PolygonDidRegistrar.js +0 -267
  59. package/build/dids/PolygonDidRegistrar.js.map +0 -1
  60. package/build/dids/PolygonDidResolver.d.ts +0 -9
  61. package/build/dids/PolygonDidResolver.js +0 -40
  62. package/build/dids/PolygonDidResolver.js.map +0 -1
  63. package/build/dids/didPolygonUtil.d.ts +0 -7
  64. package/build/dids/didPolygonUtil.js +0 -98
  65. package/build/dids/didPolygonUtil.js.map +0 -1
  66. package/build/dids/index.d.ts +0 -3
  67. package/build/dids/index.js +0 -20
  68. package/build/dids/index.js.map +0 -1
  69. package/build/index.d.ts +0 -5
  70. package/build/index.js +0 -28
  71. package/build/index.js.map +0 -1
  72. package/build/ledger/PolygonLedgerService.d.ts +0 -87
  73. package/build/ledger/PolygonLedgerService.js +0 -210
  74. package/build/ledger/PolygonLedgerService.js.map +0 -1
  75. package/build/ledger/index.d.ts +0 -1
  76. package/build/ledger/index.js +0 -18
  77. package/build/ledger/index.js.map +0 -1
  78. package/build/signature-suites/EcdsaSecp256k1Signature2019.d.ts +0 -60
  79. package/build/signature-suites/EcdsaSecp256k1Signature2019.js +0 -126
  80. package/build/signature-suites/EcdsaSecp256k1Signature2019.js.map +0 -1
  81. package/build/signature-suites/index.d.ts +0 -1
  82. package/build/signature-suites/index.js +0 -18
  83. package/build/signature-suites/index.js.map +0 -1
  84. package/build/utils/index.d.ts +0 -1
  85. package/build/utils/index.js +0 -18
  86. package/build/utils/index.js.map +0 -1
  87. package/build/utils/utils.d.ts +0 -7
  88. package/build/utils/utils.js +0 -38
  89. package/build/utils/utils.js.map +0 -1
@@ -1,267 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonDidRegistrar = void 0;
4
- const polygon_did_resolver_1 = require("@ayanworks/polygon-did-resolver");
5
- const askar_1 = require("@credo-ts/askar");
6
- const core_1 = require("@credo-ts/core");
7
- const did_resolver_1 = require("did-resolver");
8
- const ethers_1 = require("ethers");
9
- const ledger_1 = require("../ledger");
10
- const didPolygonUtil_1 = require("./didPolygonUtil");
11
- class PolygonDidRegistrar {
12
- constructor() {
13
- this.supportedMethods = ['polygon'];
14
- this.resolver = new did_resolver_1.Resolver((0, polygon_did_resolver_1.getResolver)());
15
- }
16
- async create(agentContext, options) {
17
- const ledgerService = agentContext.dependencyManager.resolve(ledger_1.PolygonLedgerService);
18
- const didRepository = agentContext.dependencyManager.resolve(core_1.DidRepository);
19
- const privateKey = options.secret.privateKey;
20
- const wallet = new ethers_1.Wallet(new ethers_1.SigningKey(privateKey));
21
- const provider = new ethers_1.JsonRpcProvider(ledgerService.rpcUrl);
22
- const value = await provider.getBalance(wallet.address);
23
- if (Number(value) == 0) {
24
- return {
25
- didDocumentMetadata: {},
26
- didRegistrationMetadata: {},
27
- didState: {
28
- state: 'failed',
29
- reason: 'Insufficient balance in wallet',
30
- },
31
- };
32
- }
33
- const key = await agentContext.wallet.createKey({ keyType: core_1.KeyType.K256, privateKey });
34
- const publicKeyHex = key.publicKey.toString('hex');
35
- const did = (0, didPolygonUtil_1.buildDid)(options.method, options.options.network, publicKeyHex);
36
- agentContext.config.logger.info(`Creating DID on ledger: ${did}`);
37
- try {
38
- const signingKey = await this.getSigningKey(agentContext.wallet, key.publicKeyBase58);
39
- const didRegistry = ledgerService.createDidRegistryInstance(signingKey);
40
- // Create did document
41
- const secpDidDoc = (0, didPolygonUtil_1.getSecp256k1DidDoc)(did, key, options.options.endpoint);
42
- const response = await didRegistry.create(did, secpDidDoc);
43
- agentContext.config.logger.info(`Published did on ledger: ${did}`);
44
- const didDoc = response.didDoc;
45
- const didDocument = core_1.JsonTransformer.fromJSON(didDoc, core_1.DidDocument);
46
- const didRecord = new core_1.DidRecord({
47
- did: didDocument.id,
48
- role: core_1.DidDocumentRole.Created,
49
- didDocument,
50
- });
51
- agentContext.config.logger.info(`Saving DID record to wallet: ${did} and did document: ${didDocument}`);
52
- await didRepository.save(agentContext, didRecord);
53
- return {
54
- didDocumentMetadata: {},
55
- didRegistrationMetadata: {
56
- txn: response.txnHash,
57
- },
58
- didState: {
59
- state: 'finished',
60
- did: didDocument.id,
61
- didDocument: didDocument,
62
- },
63
- };
64
- }
65
- catch (error) {
66
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
67
- agentContext.config.logger.error(`Error registering DID ${did} : ${errorMessage}`);
68
- return {
69
- didDocumentMetadata: {},
70
- didRegistrationMetadata: {},
71
- didState: {
72
- state: 'failed',
73
- reason: `unknownError: ${errorMessage}`,
74
- },
75
- };
76
- }
77
- }
78
- async update(agentContext, options) {
79
- var _a, _b, _c, _d, _e;
80
- const ledgerService = agentContext.dependencyManager.resolve(ledger_1.PolygonLedgerService);
81
- const didRepository = agentContext.dependencyManager.resolve(core_1.DidRepository);
82
- let didDocument;
83
- let didRecord;
84
- try {
85
- const isValidDidDoc = (0, didPolygonUtil_1.validateSpecCompliantPayload)(options.didDocument);
86
- if (options.didDocument && isValidDidDoc === null) {
87
- didDocument = options.didDocument;
88
- const resolvedDocument = await this.resolver.resolve(didDocument.id);
89
- didRecord = await didRepository.findCreatedDid(agentContext, didDocument.id);
90
- if (!resolvedDocument.didDocument || resolvedDocument.didDocumentMetadata.deactivated || !didRecord) {
91
- return {
92
- didDocumentMetadata: {},
93
- didRegistrationMetadata: {},
94
- didState: {
95
- state: 'failed',
96
- reason: 'Did not found',
97
- },
98
- };
99
- }
100
- if ((_a = options === null || options === void 0 ? void 0 : options.secret) === null || _a === void 0 ? void 0 : _a.privateKey) {
101
- const privateKey = (_b = options === null || options === void 0 ? void 0 : options.secret) === null || _b === void 0 ? void 0 : _b.privateKey;
102
- if (privateKey && !(0, core_1.isValidPrivateKey)(privateKey, core_1.KeyType.K256)) {
103
- return {
104
- didDocumentMetadata: {},
105
- didRegistrationMetadata: {},
106
- didState: {
107
- state: 'failed',
108
- reason: 'Invalid private key provided',
109
- },
110
- };
111
- }
112
- const key = await agentContext.wallet.createKey({
113
- keyType: core_1.KeyType.K256,
114
- privateKey: privateKey,
115
- });
116
- const verificationMethodCount = (_d = (_c = didDocument === null || didDocument === void 0 ? void 0 : didDocument.verificationMethod) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
117
- const verificationMethod = (0, core_1.getEcdsaSecp256k1VerificationKey2019)({
118
- id: `${didDocument.id}#key-${verificationMethodCount + 1}`,
119
- key,
120
- controller: didDocument.id,
121
- });
122
- didDocument.verificationMethod = [...((_e = didDocument === null || didDocument === void 0 ? void 0 : didDocument.verificationMethod) !== null && _e !== void 0 ? _e : []), verificationMethod];
123
- }
124
- }
125
- else {
126
- return {
127
- didDocumentMetadata: {},
128
- didRegistrationMetadata: {},
129
- didState: {
130
- state: 'failed',
131
- reason: isValidDidDoc !== null && isValidDidDoc !== void 0 ? isValidDidDoc : 'Provide a valid didDocument',
132
- },
133
- };
134
- }
135
- if (!didRecord) {
136
- return {
137
- didDocumentMetadata: {},
138
- didRegistrationMetadata: {},
139
- didState: {
140
- state: 'failed',
141
- reason: 'DidRecord not found in wallet',
142
- },
143
- };
144
- }
145
- const publicKeyBase58 = await this.getPublicKeyFromDid(agentContext, options.did);
146
- if (!publicKeyBase58) {
147
- throw new core_1.CredoError('Public Key not found in wallet');
148
- }
149
- const signingKey = await this.getSigningKey(agentContext.wallet, publicKeyBase58);
150
- const didRegistry = ledgerService.createDidRegistryInstance(signingKey);
151
- const response = await didRegistry.update(didDocument.id, didDocument);
152
- if (!response) {
153
- throw new Error('Unable to update did document');
154
- }
155
- // Save the did document
156
- didRecord.didDocument = didDocument;
157
- await didRepository.update(agentContext, didRecord);
158
- return {
159
- didDocumentMetadata: {},
160
- didRegistrationMetadata: {
161
- txn: response.txnHash,
162
- },
163
- didState: {
164
- state: 'finished',
165
- did: didDocument.id,
166
- didDocument,
167
- },
168
- };
169
- }
170
- catch (error) {
171
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
172
- agentContext.config.logger.error(`Error Updating DID : ${errorMessage}`);
173
- return {
174
- didDocumentMetadata: {},
175
- didRegistrationMetadata: {},
176
- didState: {
177
- state: 'failed',
178
- reason: `unknownError: ${errorMessage}`,
179
- },
180
- };
181
- }
182
- }
183
- async deactivate(agentContext, options) {
184
- const didRepository = agentContext.dependencyManager.resolve(core_1.DidRepository);
185
- const ledgerService = agentContext.dependencyManager.resolve(ledger_1.PolygonLedgerService);
186
- const did = options.did;
187
- try {
188
- const { didDocument, didDocumentMetadata } = await this.resolver.resolve(did);
189
- const didRecord = await didRepository.findCreatedDid(agentContext, did);
190
- if (!didDocument || didDocumentMetadata.deactivated || !didRecord) {
191
- return {
192
- didDocumentMetadata: {},
193
- didRegistrationMetadata: {},
194
- didState: {
195
- state: 'failed',
196
- reason: 'Did not found',
197
- },
198
- };
199
- }
200
- const publicKeyBase58 = await this.getPublicKeyFromDid(agentContext, options.did);
201
- if (!publicKeyBase58) {
202
- throw new core_1.CredoError('Public Key not found in wallet');
203
- }
204
- const signingKey = await this.getSigningKey(agentContext.wallet, publicKeyBase58);
205
- const didRegistry = ledgerService.createDidRegistryInstance(signingKey);
206
- const updatedDidDocument = new core_1.DidDocumentBuilder(options.did).addContext('https://www.w3.org/ns/did/v1').build();
207
- const response = await didRegistry.update(didDocument.id, updatedDidDocument);
208
- if (!response) {
209
- throw new core_1.CredoError(`Unable to deactivate did document for did : ${did}`);
210
- }
211
- await didRepository.update(agentContext, didRecord);
212
- return {
213
- didDocumentMetadata: {
214
- deactivated: true,
215
- },
216
- didRegistrationMetadata: {
217
- txn: response.txnHash,
218
- },
219
- didState: {
220
- state: 'finished',
221
- did: didDocument.id,
222
- didDocument: core_1.JsonTransformer.fromJSON(didDocument, core_1.DidDocument),
223
- secret: options.secret,
224
- },
225
- };
226
- }
227
- catch (error) {
228
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
229
- agentContext.config.logger.error(`Error deactivating DID ${errorMessage}`);
230
- return {
231
- didDocumentMetadata: {},
232
- didRegistrationMetadata: {},
233
- didState: {
234
- state: 'failed',
235
- reason: `unknownError: ${errorMessage}`,
236
- },
237
- };
238
- }
239
- }
240
- async getSigningKey(wallet, publicKeyBase58) {
241
- if (!(wallet instanceof askar_1.AskarWallet) && !(wallet instanceof askar_1.AskarProfileWallet)) {
242
- throw new core_1.CredoError('Incorrect wallet type: Polygon Module currently only supports Askar wallet');
243
- }
244
- const keyEntry = await wallet.withSession(async (session) => await session.fetchKey({ name: publicKeyBase58 }));
245
- if (!keyEntry) {
246
- throw new core_1.WalletError('Key not found in wallet');
247
- }
248
- const signingKey = new ethers_1.SigningKey(keyEntry.key.secretBytes);
249
- keyEntry.key.handle.free();
250
- return signingKey;
251
- }
252
- async getPublicKeyFromDid(agentContext, did) {
253
- var _a;
254
- const didRepository = agentContext.dependencyManager.resolve(core_1.DidRepository);
255
- const didRecord = await didRepository.findCreatedDid(agentContext, did);
256
- if (!didRecord) {
257
- throw new core_1.CredoError('DidRecord not found');
258
- }
259
- if (!((_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.verificationMethod)) {
260
- throw new core_1.CredoError('VerificationMethod not found cannot get public key');
261
- }
262
- const publicKeyBase58 = didRecord.didDocument.verificationMethod[0].publicKeyBase58;
263
- return publicKeyBase58;
264
- }
265
- }
266
- exports.PolygonDidRegistrar = PolygonDidRegistrar;
267
- //# sourceMappingURL=PolygonDidRegistrar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PolygonDidRegistrar.js","sourceRoot":"","sources":["../../src/dids/PolygonDidRegistrar.ts"],"names":[],"mappings":";;;AAaA,0EAA6D;AAC7D,2CAAiE;AACjE,yCAYuB;AACvB,+CAAuC;AACvC,mCAA2E;AAE3E,sCAAgD;AAEhD,qDAA6F;AAE7F,MAAa,mBAAmB;IAAhC;QACkB,qBAAgB,GAAG,CAAC,SAAS,CAAC,CAAA;QACtC,aAAQ,GAAG,IAAI,uBAAQ,CAAC,IAAA,kCAAW,GAAE,CAAC,CAAA;IA+ShD,CAAC;IA7SQ,KAAK,CAAC,MAAM,CAAC,YAA0B,EAAE,OAAgC;QAC9E,MAAM,aAAa,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,6BAAoB,CAAC,CAAA;QAClF,MAAM,aAAa,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,oBAAa,CAAC,CAAA;QAE3E,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAA;QAE5C,MAAM,MAAM,GAAG,IAAI,eAAW,CAAC,IAAI,mBAAU,CAAC,UAAU,CAAC,CAAC,CAAA;QAC1D,MAAM,QAAQ,GAAG,IAAI,wBAAe,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAC1D,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,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;QAED,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QAE3D,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;QAE1B,OAAO,UAAU,CAAA;IACnB,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,YAA0B,EAAE,GAAW;;QACvE,MAAM,aAAa,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,oBAAa,CAAC,CAAA;QAE3E,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACvE,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,iBAAU,CAAC,qBAAqB,CAAC,CAAA;SAC5C;QAED,IAAI,CAAC,CAAA,MAAA,SAAS,CAAC,WAAW,0CAAE,kBAAkB,CAAA,EAAE;YAC9C,MAAM,IAAI,iBAAU,CAAC,oDAAoD,CAAC,CAAA;SAC3E;QAED,MAAM,eAAe,GAAG,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAA;QAEnF,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAjTD,kDAiTC"}
@@ -1,9 +0,0 @@
1
- import { type AgentContext, type DidResolutionResult, type DidResolver } from '@credo-ts/core';
2
- import { Resolver } from 'did-resolver';
3
- export declare class PolygonDidResolver implements DidResolver {
4
- readonly allowsCaching = true;
5
- readonly supportedMethods: string[];
6
- resolver: Resolver;
7
- constructor();
8
- resolve(agentContext: AgentContext, did: string): Promise<DidResolutionResult>;
9
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonDidResolver = void 0;
4
- const polygon_did_resolver_1 = require("@ayanworks/polygon-did-resolver");
5
- const core_1 = require("@credo-ts/core");
6
- const did_resolver_1 = require("did-resolver");
7
- const didPolygonUtil_1 = require("./didPolygonUtil");
8
- class PolygonDidResolver {
9
- constructor() {
10
- this.allowsCaching = true;
11
- this.supportedMethods = ['polygon'];
12
- this.resolver = new did_resolver_1.Resolver((0, polygon_did_resolver_1.getResolver)());
13
- }
14
- async resolve(agentContext, did) {
15
- const didDocumentMetadata = {};
16
- if (!(0, didPolygonUtil_1.isValidPolygonDid)(did)) {
17
- throw new Error('Invalid DID');
18
- }
19
- try {
20
- const { didDocument, didDocumentMetadata, didResolutionMetadata } = await this.resolver.resolve(did);
21
- return {
22
- didDocument: core_1.JsonTransformer.fromJSON(didDocument, core_1.DidDocument),
23
- didDocumentMetadata,
24
- didResolutionMetadata,
25
- };
26
- }
27
- catch (error) {
28
- return {
29
- didDocument: null,
30
- didDocumentMetadata,
31
- didResolutionMetadata: {
32
- error: 'notFound',
33
- message: `resolver_error: Unable to resolve did '${did}': ${error}`,
34
- },
35
- };
36
- }
37
- }
38
- }
39
- exports.PolygonDidResolver = PolygonDidResolver;
40
- //# sourceMappingURL=PolygonDidResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PolygonDidResolver.js","sourceRoot":"","sources":["../../src/dids/PolygonDidResolver.ts"],"names":[],"mappings":";;;AAEA,0EAA6D;AAC7D,yCAMuB;AACvB,+CAAuC;AAEvC,qDAAoD;AAEpD,MAAa,kBAAkB;IAO7B;QANgB,kBAAa,GAAG,IAAI,CAAA;QAEpB,qBAAgB,GAAG,CAAC,SAAS,CAAC,CAAA;QAK5C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAQ,CAAC,IAAA,kCAAW,GAAsB,CAAC,CAAA;IACjE,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,YAA0B,EAAE,GAAW;QAC1D,MAAM,mBAAmB,GAAG,EAAE,CAAA;QAE9B,IAAI,CAAC,IAAA,kCAAiB,EAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;SAC/B;QACD,IAAI;YACF,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAEpG,OAAO;gBACL,WAAW,EAAE,sBAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAW,CAAC;gBAC/D,mBAAmB;gBACnB,qBAAqB;aACtB,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO;gBACL,WAAW,EAAE,IAAI;gBACjB,mBAAmB;gBACnB,qBAAqB,EAAE;oBACrB,KAAK,EAAE,UAAU;oBACjB,OAAO,EAAE,0CAA0C,GAAG,MAAM,KAAK,EAAE;iBACpE;aACF,CAAA;SACF;IACH,CAAC;CACF;AApCD,gDAoCC"}
@@ -1,7 +0,0 @@
1
- import type { DidCreateResult, DidDocument, Key } from '@credo-ts/core';
2
- export declare const polygonDidRegex: RegExp;
3
- export declare const isValidPolygonDid: (did: string) => boolean;
4
- export declare function buildDid(method: string, network: string, publicKey: string): string;
5
- export declare function failedResult(reason: string): DidCreateResult;
6
- export declare function getSecp256k1DidDoc(did: string, key: Key, serviceEndpoint?: string): DidDocument;
7
- export declare function validateSpecCompliantPayload(didDocument: DidDocument): string | null;
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSpecCompliantPayload = exports.getSecp256k1DidDoc = exports.failedResult = exports.buildDid = exports.isValidPolygonDid = exports.polygonDidRegex = void 0;
4
- const core_1 = require("@credo-ts/core");
5
- const ethers_1 = require("ethers");
6
- const EcdsaSecp256k1Signature2019_1 = require("../signature-suites/EcdsaSecp256k1Signature2019");
7
- exports.polygonDidRegex = new RegExp(/^did:polygon(:testnet)?:0x[0-9a-fA-F]{40}$/);
8
- const isValidPolygonDid = (did) => exports.polygonDidRegex.test(did);
9
- exports.isValidPolygonDid = isValidPolygonDid;
10
- function buildDid(method, network, publicKey) {
11
- const address = (0, ethers_1.computeAddress)('0x' + publicKey);
12
- if (network === 'mainnet') {
13
- return `did:${method}:${address}`;
14
- }
15
- return `did:${method}:${network}:${address}`;
16
- }
17
- exports.buildDid = buildDid;
18
- function failedResult(reason) {
19
- return {
20
- didDocumentMetadata: {},
21
- didRegistrationMetadata: {},
22
- didState: {
23
- state: 'failed',
24
- reason: reason,
25
- },
26
- };
27
- }
28
- exports.failedResult = failedResult;
29
- function getSecp256k1DidDoc(did, key, serviceEndpoint) {
30
- const verificationMethod = (0, core_1.getEcdsaSecp256k1VerificationKey2019)({
31
- id: `${did}#key-1`,
32
- key,
33
- controller: did,
34
- });
35
- const didDocumentBuilder = new core_1.DidDocumentBuilder(did);
36
- didDocumentBuilder.addContext(EcdsaSecp256k1Signature2019_1.SECURITY_CONTEXT_SECP256k1_URL).addVerificationMethod(verificationMethod);
37
- if (serviceEndpoint) {
38
- const service = new core_1.DidDocumentService({
39
- id: `${did}#linked-domain`,
40
- serviceEndpoint,
41
- type: 'LinkedDomains',
42
- });
43
- didDocumentBuilder.addService(service);
44
- }
45
- if (!key.supportsEncrypting && !key.supportsSigning) {
46
- throw new core_1.CredoError('Key must support at least signing or encrypting');
47
- }
48
- if (key.supportsSigning) {
49
- didDocumentBuilder
50
- .addAuthentication(verificationMethod.id)
51
- .addAssertionMethod(verificationMethod.id)
52
- .addCapabilityDelegation(verificationMethod.id)
53
- .addCapabilityInvocation(verificationMethod.id);
54
- }
55
- if (key.supportsEncrypting) {
56
- didDocumentBuilder.addKeyAgreement(verificationMethod.id);
57
- }
58
- return didDocumentBuilder.build();
59
- }
60
- exports.getSecp256k1DidDoc = getSecp256k1DidDoc;
61
- function validateSpecCompliantPayload(didDocument) {
62
- var _a;
63
- // id is required, validated on both compile and runtime
64
- if (!didDocument.id && !didDocument.id.startsWith('did:polygon:'))
65
- return 'id is required';
66
- // verificationMethod is required
67
- if (!didDocument.verificationMethod)
68
- return 'verificationMethod is required';
69
- // verificationMethod must be an array
70
- if (!Array.isArray(didDocument.verificationMethod))
71
- return 'verificationMethod must be an array';
72
- // verificationMethod must be not be empty
73
- if (!didDocument.verificationMethod.length)
74
- return 'verificationMethod must be not be empty';
75
- // verificationMethod types must be supported
76
- const isValidVerificationMethod = didDocument.verificationMethod.every((vm) => {
77
- switch (vm.type) {
78
- case core_1.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019:
79
- return (vm === null || vm === void 0 ? void 0 : vm.publicKeyBase58) && (vm === null || vm === void 0 ? void 0 : vm.controller) && (vm === null || vm === void 0 ? void 0 : vm.id);
80
- default:
81
- return false;
82
- }
83
- });
84
- if (!isValidVerificationMethod)
85
- return 'verificationMethod is Invalid';
86
- if (didDocument.service) {
87
- const isValidService = didDocument.service
88
- ? (_a = didDocument === null || didDocument === void 0 ? void 0 : didDocument.service) === null || _a === void 0 ? void 0 : _a.every((s) => {
89
- return (s === null || s === void 0 ? void 0 : s.serviceEndpoint) && (s === null || s === void 0 ? void 0 : s.id) && (s === null || s === void 0 ? void 0 : s.type);
90
- })
91
- : true;
92
- if (!isValidService)
93
- return 'Service is Invalid';
94
- }
95
- return null;
96
- }
97
- exports.validateSpecCompliantPayload = validateSpecCompliantPayload;
98
- //# sourceMappingURL=didPolygonUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"didPolygonUtil.js","sourceRoot":"","sources":["../../src/dids/didPolygonUtil.ts"],"names":[],"mappings":";;;AAEA,yCAMuB;AACvB,mCAAuC;AAEvC,iGAAgG;AAEnF,QAAA,eAAe,GAAG,IAAI,MAAM,CAAC,4CAA4C,CAAC,CAAA;AAEhF,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,uBAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAA9D,QAAA,iBAAiB,qBAA6C;AAE3E,SAAgB,QAAQ,CAAC,MAAc,EAAE,OAAe,EAAE,SAAiB;IACzE,MAAM,OAAO,GAAG,IAAA,uBAAc,EAAC,IAAI,GAAG,SAAS,CAAC,CAAA;IAEhD,IAAI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WAAW,CAAC,OAAO;YACxC,CAAC,CAAC,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,0CAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAChC,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,eAAe,MAAI,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,EAAE,CAAA,KAAI,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,CAAA,CAAA;YAC/C,CAAC,CAAC;YACJ,CAAC,CAAC,IAAI,CAAA;QAER,IAAI,CAAC,cAAc;YAAE,OAAO,oBAAoB,CAAA;KACjD;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AApCD,oEAoCC"}
@@ -1,3 +0,0 @@
1
- export * from './PolygonDidResolver';
2
- export * from './PolygonDidRegistrar';
3
- export * from './didPolygonUtil';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./PolygonDidResolver"), exports);
18
- __exportStar(require("./PolygonDidRegistrar"), exports);
19
- __exportStar(require("./didPolygonUtil"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dids/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,wDAAqC;AACrC,mDAAgC"}
package/build/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { PolygonDidRegistrar, PolygonDidResolver } from './dids';
2
- export { PolygonLedgerService } from './ledger';
3
- export { PolygonModule } from './PolygonModule';
4
- export { PolygonModuleConfig, PolygonModuleConfigOptions } from './PolygonModuleConfig';
5
- export * from './utils';
package/build/index.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PolygonModuleConfig = exports.PolygonModule = exports.PolygonLedgerService = exports.PolygonDidResolver = exports.PolygonDidRegistrar = void 0;
18
- var dids_1 = require("./dids");
19
- Object.defineProperty(exports, "PolygonDidRegistrar", { enumerable: true, get: function () { return dids_1.PolygonDidRegistrar; } });
20
- Object.defineProperty(exports, "PolygonDidResolver", { enumerable: true, get: function () { return dids_1.PolygonDidResolver; } });
21
- var ledger_1 = require("./ledger");
22
- Object.defineProperty(exports, "PolygonLedgerService", { enumerable: true, get: function () { return ledger_1.PolygonLedgerService; } });
23
- var PolygonModule_1 = require("./PolygonModule");
24
- Object.defineProperty(exports, "PolygonModule", { enumerable: true, get: function () { return PolygonModule_1.PolygonModule; } });
25
- var PolygonModuleConfig_1 = require("./PolygonModuleConfig");
26
- Object.defineProperty(exports, "PolygonModuleConfig", { enumerable: true, get: function () { return PolygonModuleConfig_1.PolygonModuleConfig; } });
27
- __exportStar(require("./utils"), exports);
28
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAAgE;AAAvD,2GAAA,mBAAmB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAEhD,mCAA+C;AAAtC,8GAAA,oBAAoB,OAAA;AAE7B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAEtB,6DAAuF;AAA9E,0HAAA,mBAAmB,OAAA;AAE5B,0CAAuB"}
@@ -1,87 +0,0 @@
1
- import type { AgentContext, DidDocument } from '@credo-ts/core';
2
- import { PolygonDID } from '@ayanworks/polygon-did-registrar';
3
- import { SigningKey } from 'ethers';
4
- import { PolygonModuleConfig } from '../PolygonModuleConfig';
5
- interface SchemaRegistryConfig {
6
- didRegistrarContractAddress: string;
7
- rpcUrl: string;
8
- fileServerToken: string;
9
- privateKey: string;
10
- schemaManagerContractAddress: string;
11
- serverUrl: string;
12
- }
13
- export type CreateDidOperationOptions = {
14
- operation: DidOperation.Create;
15
- serviceEndpoint?: string;
16
- };
17
- export type UpdateDidOperationOptions = {
18
- operation: DidOperation.Update;
19
- didDocument: DidDocument;
20
- did: string;
21
- };
22
- export type DeactivateDidOperationOptions = {
23
- operation: DidOperation.Deactivate;
24
- did: string;
25
- };
26
- export type AddResourceDidOperationOptions = {
27
- operation: DidOperation.AddResource;
28
- resourceId: string;
29
- resource: object;
30
- did: string;
31
- };
32
- export declare enum DidOperation {
33
- Create = "createDID",
34
- Update = "updateDIDDoc",
35
- Deactivate = "deactivate",
36
- AddResource = "addResource"
37
- }
38
- export type DidOperationOptions = CreateDidOperationOptions | UpdateDidOperationOptions | DeactivateDidOperationOptions | AddResourceDidOperationOptions;
39
- export type SchemaOperationOptions = CreateSchemaOperationOptions;
40
- export type CreateSchemaOperationOptions = {
41
- operation: SchemaOperation.CreateSchema;
42
- did: string;
43
- };
44
- export declare enum SchemaOperation {
45
- CreateSchema = "createSchema"
46
- }
47
- export declare class PolygonLedgerService {
48
- rpcUrl: string | undefined;
49
- private didContractAddress;
50
- private schemaManagerContractAddress;
51
- private fileServerToken;
52
- private fileServerUrl;
53
- constructor({ didContractAddress, rpcUrl, fileServerToken, schemaManagerContractAddress, serverUrl, }: PolygonModuleConfig);
54
- createSchema(agentContext: AgentContext, { did, schemaName, schema }: {
55
- did: string;
56
- schemaName: string;
57
- schema: object;
58
- }): Promise<{
59
- did: string;
60
- schemaId: string;
61
- schemaTxnHash: any;
62
- resourceTxnHash: any;
63
- tnxSchemaId?: undefined;
64
- schemaTxhash?: undefined;
65
- schemaState?: undefined;
66
- } | {
67
- tnxSchemaId: string;
68
- schemaTxhash: string;
69
- schemaState: {
70
- state: string;
71
- reason: string;
72
- };
73
- did?: undefined;
74
- schemaId?: undefined;
75
- schemaTxnHash?: undefined;
76
- resourceTxnHash?: undefined;
77
- }>;
78
- getSchemaByDidAndSchemaId(agentContext: AgentContext, did: string, schemaId: string): Promise<any>;
79
- estimateFeeForDidOperation(agentContext: AgentContext, options: DidOperationOptions): Promise<import("@ayanworks/polygon-did-registrar/build/registrar").EstimatedTxDetails | null | undefined>;
80
- estimateFeeForSchemaOperation(agentContext: AgentContext, options: SchemaOperationOptions): Promise<{} | undefined>;
81
- createDidRegistryInstance(signingKey: SigningKey): PolygonDID;
82
- private createSchemaRegistryInstance;
83
- private getSigningKey;
84
- private getPublicKeyFromDid;
85
- updateModuleConfig({ didRegistrarContractAddress, fileServerToken, rpcUrl, schemaManagerContractAddress, serverUrl, }: SchemaRegistryConfig): void;
86
- }
87
- export {};