@bhutan-ndi/ethr-credo-module 0.0.0-20251226085115

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 (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -0
  3. package/build/EthereumApi.d.ts +13 -0
  4. package/build/EthereumApi.js +34 -0
  5. package/build/EthereumApi.js.map +1 -0
  6. package/build/EthereumModule.d.ts +10 -0
  7. package/build/EthereumModule.js +31 -0
  8. package/build/EthereumModule.js.map +1 -0
  9. package/build/EthereumModuleConfig.d.ts +19 -0
  10. package/build/EthereumModuleConfig.js +14 -0
  11. package/build/EthereumModuleConfig.js.map +1 -0
  12. package/build/abi/SchemaRegistry.json +136 -0
  13. package/build/dids/EthrDidRegistrar.d.ts +28 -0
  14. package/build/dids/EthrDidRegistrar.js +69 -0
  15. package/build/dids/EthrDidRegistrar.js.map +1 -0
  16. package/build/dids/EthrDidResolver.d.ts +6 -0
  17. package/build/dids/EthrDidResolver.js +36 -0
  18. package/build/dids/EthrDidResolver.js.map +1 -0
  19. package/build/dids/didEthrUtil.d.ts +5 -0
  20. package/build/dids/didEthrUtil.js +52 -0
  21. package/build/dids/didEthrUtil.js.map +1 -0
  22. package/build/dids/index.d.ts +3 -0
  23. package/build/dids/index.js +20 -0
  24. package/build/dids/index.js.map +1 -0
  25. package/build/index.d.ts +5 -0
  26. package/build/index.js +28 -0
  27. package/build/index.js.map +1 -0
  28. package/build/ledger/EthereumLedgerService.d.ts +42 -0
  29. package/build/ledger/EthereumLedgerService.js +250 -0
  30. package/build/ledger/EthereumLedgerService.js.map +1 -0
  31. package/build/ledger/index.d.ts +1 -0
  32. package/build/ledger/index.js +18 -0
  33. package/build/ledger/index.js.map +1 -0
  34. package/build/schema/EthereumSchemaRegistry.d.ts +37 -0
  35. package/build/schema/EthereumSchemaRegistry.js +174 -0
  36. package/build/schema/EthereumSchemaRegistry.js.map +1 -0
  37. package/build/schema/types/EthereumSchemaRegistry.types.d.ts +33 -0
  38. package/build/schema/types/EthereumSchemaRegistry.types.js +36 -0
  39. package/build/schema/types/EthereumSchemaRegistry.types.js.map +1 -0
  40. package/build/signature-suites/EcdsaSecp256k1RecoveryMethod2020.d.ts +60 -0
  41. package/build/signature-suites/EcdsaSecp256k1RecoveryMethod2020.js +126 -0
  42. package/build/signature-suites/EcdsaSecp256k1RecoveryMethod2020.js.map +1 -0
  43. package/build/signature-suites/EcdsaSecp256k1Signature2019.d.ts +60 -0
  44. package/build/signature-suites/EcdsaSecp256k1Signature2019.js +126 -0
  45. package/build/signature-suites/EcdsaSecp256k1Signature2019.js.map +1 -0
  46. package/build/signature-suites/index.d.ts +2 -0
  47. package/build/signature-suites/index.js +19 -0
  48. package/build/signature-suites/index.js.map +1 -0
  49. package/build/utils/index.d.ts +1 -0
  50. package/build/utils/index.js +18 -0
  51. package/build/utils/index.js.map +1 -0
  52. package/build/utils/schemaHelper.d.ts +20 -0
  53. package/build/utils/schemaHelper.js +64 -0
  54. package/build/utils/schemaHelper.js.map +1 -0
  55. package/build/utils/utils.d.ts +11 -0
  56. package/build/utils/utils.js +69 -0
  57. package/build/utils/utils.js.map +1 -0
  58. package/package.json +66 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthrDidResolver.js","sourceRoot":"","sources":["../../src/dids/EthrDidResolver.ts"],"names":[],"mappings":";;;AAAA,yCAMuB;AAEvB,2EAAuE;AAEvE,MAAa,mBAAmB;IAAhC;QACkB,kBAAa,GAAG,IAAI,CAAA;QAEpB,qBAAgB,GAAG,CAAC,MAAM,CAAC,CAAA;IA0B7C,CAAC;IAxBQ,KAAK,CAAC,OAAO,CAAC,YAA0B,EAAE,GAAW;QAC1D,MAAM,qBAAqB,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,6CAAqB,CAAC,CAAA;QAC3F,MAAM,mBAAmB,GAAG,EAAE,CAAA;QAC9B,IAAI;YACF,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;YAE/G,MAAM,MAAM,GAAG,sBAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAW,CAAC,CAAA;YAEjE,OAAO;gBACL,WAAW,EAAE,MAAM;gBACnB,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;AA7BD,kDA6BC"}
@@ -0,0 +1,5 @@
1
+ import type { DidCreateResult, DidDocument, Key } from '@credo-ts/core';
2
+ export declare const ethereumDidRegex: RegExp;
3
+ export declare const isValidEthereumDid: (did: string) => boolean;
4
+ export declare function failedResult(reason: string): DidCreateResult;
5
+ export declare function getSecp256k1DidDoc(did: string, key: Key, serviceEndpoint?: string): DidDocument;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSecp256k1DidDoc = exports.failedResult = exports.isValidEthereumDid = exports.ethereumDidRegex = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const EcdsaSecp256k1RecoveryMethod2020_1 = require("../signature-suites/EcdsaSecp256k1RecoveryMethod2020");
6
+ exports.ethereumDidRegex = new RegExp(/^did:ethr(:[0-9a-fA-F])?:0x[0-9a-fA-F]{40}$/);
7
+ const isValidEthereumDid = (did) => exports.ethereumDidRegex.test(did);
8
+ exports.isValidEthereumDid = isValidEthereumDid;
9
+ function failedResult(reason) {
10
+ return {
11
+ didDocumentMetadata: {},
12
+ didRegistrationMetadata: {},
13
+ didState: {
14
+ state: 'failed',
15
+ reason: reason,
16
+ },
17
+ };
18
+ }
19
+ exports.failedResult = failedResult;
20
+ function getSecp256k1DidDoc(did, key, serviceEndpoint) {
21
+ const verificationMethod = (0, core_1.getEd25519VerificationKey2020)({
22
+ id: `${did}#key-1`,
23
+ key,
24
+ controller: did,
25
+ });
26
+ const didDocumentBuilder = new core_1.DidDocumentBuilder(did);
27
+ didDocumentBuilder.addContext(EcdsaSecp256k1RecoveryMethod2020_1.SECURITY_CONTEXT_SECP256k1_RECOVERY_URL).addVerificationMethod(verificationMethod);
28
+ if (serviceEndpoint) {
29
+ const service = new core_1.DidDocumentService({
30
+ id: `${did}#linked-domain`,
31
+ serviceEndpoint,
32
+ type: 'LinkedDomains',
33
+ });
34
+ didDocumentBuilder.addService(service);
35
+ }
36
+ if (!key.supportsEncrypting && !key.supportsSigning) {
37
+ throw new core_1.CredoError('Key must support at least signing or encrypting');
38
+ }
39
+ if (key.supportsSigning) {
40
+ didDocumentBuilder
41
+ .addAuthentication(verificationMethod.id)
42
+ .addAssertionMethod(verificationMethod.id)
43
+ .addCapabilityDelegation(verificationMethod.id)
44
+ .addCapabilityInvocation(verificationMethod.id);
45
+ }
46
+ if (key.supportsEncrypting) {
47
+ didDocumentBuilder.addKeyAgreement(verificationMethod.id);
48
+ }
49
+ return didDocumentBuilder.build();
50
+ }
51
+ exports.getSecp256k1DidDoc = getSecp256k1DidDoc;
52
+ //# sourceMappingURL=didEthrUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didEthrUtil.js","sourceRoot":"","sources":["../../src/dids/didEthrUtil.ts"],"names":[],"mappings":";;;AAEA,yCAAkH;AAElH,2GAA8G;AAEjG,QAAA,gBAAgB,GAAG,IAAI,MAAM,CAAC,6CAA6C,CAAC,CAAA;AAElF,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,wBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAAhE,QAAA,kBAAkB,sBAA8C;AAE7E,SAAgB,YAAY,CAAC,MAAc;IACzC,OAAO;QACL,mBAAmB,EAAE,EAAE;Q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AACnC,CAAC;AArCD,gDAqCC"}
@@ -0,0 +1,3 @@
1
+ export * from './EthrDidResolver';
2
+ export * from './EthrDidRegistrar';
3
+ export * from './didEthrUtil';
@@ -0,0 +1,20 @@
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("./EthrDidResolver"), exports);
18
+ __exportStar(require("./EthrDidRegistrar"), exports);
19
+ __exportStar(require("./didEthrUtil"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dids/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,qDAAkC;AAClC,gDAA6B"}
@@ -0,0 +1,5 @@
1
+ export { EthereumDidRegistrar, EthereumDidResolver } from './dids';
2
+ export { EthereumLedgerService } from './ledger';
3
+ export { EthereumModule } from './EthereumModule';
4
+ export { EthereumModuleConfig, EthereumModuleConfigOptions } from './EthereumModuleConfig';
5
+ export * from './utils';
package/build/index.js ADDED
@@ -0,0 +1,28 @@
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.EthereumModuleConfig = exports.EthereumModule = exports.EthereumLedgerService = exports.EthereumDidResolver = exports.EthereumDidRegistrar = void 0;
18
+ var dids_1 = require("./dids");
19
+ Object.defineProperty(exports, "EthereumDidRegistrar", { enumerable: true, get: function () { return dids_1.EthereumDidRegistrar; } });
20
+ Object.defineProperty(exports, "EthereumDidResolver", { enumerable: true, get: function () { return dids_1.EthereumDidResolver; } });
21
+ var ledger_1 = require("./ledger");
22
+ Object.defineProperty(exports, "EthereumLedgerService", { enumerable: true, get: function () { return ledger_1.EthereumLedgerService; } });
23
+ var EthereumModule_1 = require("./EthereumModule");
24
+ Object.defineProperty(exports, "EthereumModule", { enumerable: true, get: function () { return EthereumModule_1.EthereumModule; } });
25
+ var EthereumModuleConfig_1 = require("./EthereumModuleConfig");
26
+ Object.defineProperty(exports, "EthereumModuleConfig", { enumerable: true, get: function () { return EthereumModuleConfig_1.EthereumModuleConfig; } });
27
+ __exportStar(require("./utils"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAAkE;AAAzD,4GAAA,oBAAoB,OAAA;AAAE,2GAAA,mBAAmB,OAAA;AAElD,mCAAgD;AAAvC,+GAAA,qBAAqB,OAAA;AAE9B,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AAEvB,+DAA0F;AAAjF,4HAAA,oBAAoB,OAAA;AAE7B,0CAAuB"}
@@ -0,0 +1,42 @@
1
+ import type { AgentContext } from '@credo-ts/core';
2
+ import { CredoError } from '@credo-ts/core';
3
+ import { Resolver } from 'did-resolver';
4
+ import { EthereumModuleConfig } from '../EthereumModuleConfig';
5
+ /**
6
+ * Custom error classes for better error handling
7
+ */
8
+ export declare class EthereumLedgerError extends CredoError {
9
+ constructor(message: string, cause?: Error);
10
+ }
11
+ export declare class SchemaCreationError extends EthereumLedgerError {
12
+ constructor(reason: string, cause?: Error);
13
+ }
14
+ export declare class SchemaRetrievalError extends EthereumLedgerError {
15
+ constructor(schemaId: string, reason: string, cause?: Error);
16
+ }
17
+ export interface SchemaCreationResult {
18
+ did: string;
19
+ schemaId: string;
20
+ schemaTxnHash?: string;
21
+ }
22
+ export interface SchemaCreateOptions {
23
+ did: string;
24
+ schemaName: string;
25
+ schema: object;
26
+ }
27
+ export declare class EthereumLedgerService {
28
+ readonly rpcUrl: string | undefined;
29
+ private readonly schemaManagerContractAddress;
30
+ private readonly fileServerToken;
31
+ private readonly fileServerUrl;
32
+ readonly resolver: Resolver;
33
+ constructor(config: EthereumModuleConfig);
34
+ /**
35
+ * Creates a schema on the Ethereum ledger
36
+ */
37
+ createSchema(agentContext: AgentContext, { did, schemaName, schema }: SchemaCreateOptions): Promise<SchemaCreationResult>;
38
+ getSchemaByDidAndSchemaId(agentContext: AgentContext, did: string, schemaId: string): Promise<string>;
39
+ private getSigningKey;
40
+ private getPublicKeyFromDid;
41
+ resolveDID(did: string): Promise<import("did-resolver").DIDResolutionResult>;
42
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.EthereumLedgerService = exports.SchemaRetrievalError = exports.SchemaCreationError = exports.EthereumLedgerError = void 0;
24
+ const askar_1 = require("@credo-ts/askar");
25
+ const core_1 = require("@credo-ts/core");
26
+ const did_resolver_1 = require("did-resolver");
27
+ const ethers_1 = require("ethers");
28
+ const ethr_did_resolver_1 = require("ethr-did-resolver");
29
+ const EthereumModuleConfig_1 = require("../EthereumModuleConfig");
30
+ const EthereumSchemaRegistry_1 = require("../schema/EthereumSchemaRegistry");
31
+ const schemaHelper_1 = require("../utils/schemaHelper");
32
+ const utils_1 = require("../utils/utils");
33
+ /**
34
+ * Custom error classes for better error handling
35
+ */
36
+ class EthereumLedgerError extends core_1.CredoError {
37
+ constructor(message, cause) {
38
+ super(message, { cause });
39
+ this.name = 'EthereumLedgerError';
40
+ }
41
+ }
42
+ exports.EthereumLedgerError = EthereumLedgerError;
43
+ class SchemaCreationError extends EthereumLedgerError {
44
+ constructor(reason, cause) {
45
+ super(`Schema creation failed. Reason: ${reason}`, cause);
46
+ this.name = 'SchemaCreationError';
47
+ }
48
+ }
49
+ exports.SchemaCreationError = SchemaCreationError;
50
+ class SchemaRetrievalError extends EthereumLedgerError {
51
+ constructor(schemaId, reason, cause) {
52
+ super(`Schema retrieval failed for Schema ID: ${schemaId}. Reason: ${reason}`, cause);
53
+ this.name = 'SchemaRetrievalError';
54
+ }
55
+ }
56
+ exports.SchemaRetrievalError = SchemaRetrievalError;
57
+ let EthereumLedgerService = class EthereumLedgerService {
58
+ constructor(config) {
59
+ this.resolver = new did_resolver_1.Resolver((0, ethr_did_resolver_1.getResolver)(config.config));
60
+ this.rpcUrl = config.rpcUrl;
61
+ this.schemaManagerContractAddress = config.schemaManagerContractAddress;
62
+ this.fileServerToken = config.fileServerToken;
63
+ this.fileServerUrl = config.serverUrl;
64
+ }
65
+ /**
66
+ * Creates a schema on the Ethereum ledger
67
+ */
68
+ async createSchema(agentContext, { did, schemaName, schema }) {
69
+ var _a;
70
+ if (!this.schemaManagerContractAddress || !this.rpcUrl || !this.fileServerUrl || !this.fileServerToken) {
71
+ throw new SchemaCreationError('schemaManagerContractAddress, rpcUrl, fileServeUrl and fileServerToken must be defined and not empty');
72
+ }
73
+ // Validate inputs
74
+ if (!(did === null || did === void 0 ? void 0 : did.trim())) {
75
+ throw new SchemaCreationError('DID is required and cannot be empty');
76
+ }
77
+ if (!(schemaName === null || schemaName === void 0 ? void 0 : schemaName.trim())) {
78
+ throw new SchemaCreationError('Schema name is required and cannot be empty');
79
+ }
80
+ if (!schema || Object.keys(schema).length === 0) {
81
+ throw new SchemaCreationError('Schema must be a valid object and not empty');
82
+ }
83
+ agentContext.config.logger.info(`Creating schema on ledger: ${did}`);
84
+ try {
85
+ const keyResult = await this.getPublicKeyFromDid(agentContext, did);
86
+ if (!keyResult.publicKeyBase58) {
87
+ throw new core_1.CredoError('Public Key not found in wallet');
88
+ }
89
+ const signingKey = await this.getSigningKey(agentContext.wallet, keyResult.publicKeyBase58);
90
+ const ethSchemaRegistry = new EthereumSchemaRegistry_1.EthereumSchemaRegistry({
91
+ contractAddress: this.schemaManagerContractAddress,
92
+ rpcUrl: this.rpcUrl,
93
+ signingKey: signingKey,
94
+ });
95
+ const schemaId = core_1.utils.uuid();
96
+ const address = (0, utils_1.parseAddress)(keyResult.blockchainAccountId);
97
+ const schemaResource = await (0, schemaHelper_1.buildSchemaResource)(did, schemaId, schemaName, schema, address);
98
+ // Create schema on blockchain and upload to file server in parallel
99
+ const [blockchainResponse, uploadResponse] = await Promise.allSettled([
100
+ ethSchemaRegistry.createSchema(schemaId, JSON.stringify(schemaResource)),
101
+ (0, schemaHelper_1.uploadSchemaFile)(schemaId, schema, this.fileServerUrl, this.fileServerToken),
102
+ ]);
103
+ // Handle blockchain response
104
+ if (blockchainResponse.status === 'rejected') {
105
+ // Detect insufficient funds error
106
+ const reason = blockchainResponse.reason;
107
+ const errMsg = ((reason === null || reason === void 0 ? void 0 : reason.message) || (reason === null || reason === void 0 ? void 0 : reason.toString()) || '').toLowerCase();
108
+ if (errMsg.includes('insufficient funds') || errMsg.includes('insufficient balance')) {
109
+ throw new SchemaCreationError('Insufficient funds to pay for gas fees', reason);
110
+ }
111
+ throw new SchemaCreationError('Blockchain transaction failed', blockchainResponse.reason);
112
+ }
113
+ // Handle file server response
114
+ if (uploadResponse.status === 'rejected') {
115
+ agentContext.config.logger.warn(`File server upload failed for schema ${schemaId}: ${((_a = uploadResponse.reason) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
116
+ // Continue execution as file server upload is not critical
117
+ }
118
+ const result = blockchainResponse.value;
119
+ if (!result.hash) {
120
+ throw new SchemaCreationError('Invalid response from blockchain');
121
+ }
122
+ const response = {
123
+ did,
124
+ schemaId,
125
+ schemaTxnHash: result.hash,
126
+ };
127
+ agentContext.config.logger.info(`Successfully created schema on ledger for DID: ${did}`);
128
+ return response;
129
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
+ }
131
+ catch (error) {
132
+ if (error instanceof EthereumLedgerError) {
133
+ throw error;
134
+ }
135
+ // Wrap other errors
136
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
137
+ agentContext.config.logger.error(`Schema creation failed for DID: ${did}`, error);
138
+ throw new SchemaCreationError(errorMessage, error instanceof Error ? error : undefined);
139
+ }
140
+ }
141
+ async getSchemaByDidAndSchemaId(agentContext, did, schemaId) {
142
+ // Validate inputs
143
+ if (!(did === null || did === void 0 ? void 0 : did.trim())) {
144
+ throw new SchemaRetrievalError(schemaId, 'DID is required and cannot be empty');
145
+ }
146
+ if (!(schemaId === null || schemaId === void 0 ? void 0 : schemaId.trim())) {
147
+ throw new SchemaRetrievalError(schemaId, 'Schema ID is required and cannot be empty');
148
+ }
149
+ agentContext.config.logger.info(`Getting schema from ledger: ${did} and schemaId: ${schemaId}`);
150
+ try {
151
+ if (!this.schemaManagerContractAddress || !this.rpcUrl) {
152
+ throw new SchemaCreationError('schemaManagerContractAddress and rpcUrl must be defined and not empty');
153
+ }
154
+ const ethSchemaRegistry = new EthereumSchemaRegistry_1.EthereumSchemaRegistry({
155
+ contractAddress: this.schemaManagerContractAddress,
156
+ rpcUrl: this.rpcUrl,
157
+ });
158
+ const keyResult = await this.getPublicKeyFromDid(agentContext, did);
159
+ const address = (0, utils_1.parseAddress)(keyResult.blockchainAccountId);
160
+ const response = await ethSchemaRegistry.getSchemaById(address, schemaId);
161
+ if (!response) {
162
+ throw new SchemaRetrievalError(schemaId, 'Schema not found on ledger');
163
+ }
164
+ return response;
165
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
+ }
167
+ catch (error) {
168
+ if (error instanceof EthereumLedgerError) {
169
+ throw error;
170
+ }
171
+ // Wrap other errors
172
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
173
+ agentContext.config.logger.error(`Schema retrieval failed for DID: ${did}, Schema ID: ${schemaId}`, error);
174
+ throw new SchemaRetrievalError(schemaId, errorMessage, error instanceof Error ? error : undefined);
175
+ }
176
+ }
177
+ async getSigningKey(wallet, publicKeyBase58) {
178
+ if (!(wallet instanceof askar_1.AskarWallet) && !(wallet instanceof askar_1.AskarProfileWallet)) {
179
+ throw new core_1.CredoError('Incorrect wallet type: Ethereum Module currently only supports Askar wallet');
180
+ }
181
+ const keyEntry = await wallet.withSession(async (session) => await session.fetchKey({ name: publicKeyBase58 }));
182
+ if (!keyEntry) {
183
+ throw new core_1.WalletError('Key not found in wallet');
184
+ }
185
+ const signingKey = new ethers_1.SigningKey(keyEntry.key.secretBytes);
186
+ keyEntry.key.handle.free();
187
+ return signingKey;
188
+ }
189
+ async getPublicKeyFromDid(agentContext, did) {
190
+ var _a;
191
+ const didRepository = agentContext.dependencyManager.resolve(core_1.DidRepository);
192
+ const didRecord = await didRepository.findCreatedDid(agentContext, did);
193
+ if (!didRecord) {
194
+ throw new core_1.CredoError('DidRecord not found');
195
+ }
196
+ if (!((_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.verificationMethod)) {
197
+ throw new core_1.CredoError('VerificationMethod not found cannot get public key');
198
+ }
199
+ const blockchainAccountId = (0, utils_1.getPreferredKey)(didRecord.didDocument.verificationMethod);
200
+ // Look for publicKeyBase58 (new format) or fallback to publicKeyHex (legacy)
201
+ const keyObj = didRecord.didDocument.verificationMethod.find((obj) => obj.publicKeyBase58 || obj.publicKeyHex);
202
+ if (!keyObj) {
203
+ throw new core_1.CredoError('Public Key not found in wallet for did: ' + did);
204
+ }
205
+ let publicKeyBase58;
206
+ if (keyObj.publicKeyBase58) {
207
+ publicKeyBase58 = keyObj.publicKeyBase58;
208
+ }
209
+ else if (keyObj.publicKeyHex) {
210
+ // Legacy support: convert hex to base58
211
+ const publicKey = core_1.TypedArrayEncoder.fromHex(keyObj.publicKeyHex);
212
+ publicKeyBase58 = core_1.TypedArrayEncoder.toBase58(publicKey);
213
+ }
214
+ else {
215
+ throw new core_1.CredoError('Public Key not found in wallet for did: ' + did);
216
+ }
217
+ return { publicKeyBase58, blockchainAccountId };
218
+ }
219
+ async resolveDID(did) {
220
+ const result = await this.resolver.resolve(did);
221
+ // Update context to include secp256k1-2019/v1
222
+ if (result.didDocument) {
223
+ result.didDocument['@context'] = [
224
+ 'https://www.w3.org/ns/did/v1',
225
+ 'https://w3id.org/security/suites/secp256k1recovery-2020/v2',
226
+ 'https://w3id.org/security/suites/secp256k1-2019/v1',
227
+ ];
228
+ // Transform verification methods from publicKeyHex to publicKeyBase58
229
+ if (result.didDocument.verificationMethod) {
230
+ result.didDocument.verificationMethod = result.didDocument.verificationMethod.map((vm) => {
231
+ if (vm.publicKeyHex) {
232
+ const publicKey = core_1.TypedArrayEncoder.fromHex(vm.publicKeyHex);
233
+ const publicKeyBase58 = core_1.TypedArrayEncoder.toBase58(publicKey);
234
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
235
+ const { publicKeyHex } = vm, rest = __rest(vm, ["publicKeyHex"]);
236
+ return Object.assign(Object.assign({}, rest), { publicKeyBase58 });
237
+ }
238
+ return vm;
239
+ });
240
+ }
241
+ }
242
+ return result;
243
+ }
244
+ };
245
+ EthereumLedgerService = __decorate([
246
+ (0, core_1.injectable)(),
247
+ __metadata("design:paramtypes", [EthereumModuleConfig_1.EthereumModuleConfig])
248
+ ], EthereumLedgerService);
249
+ exports.EthereumLedgerService = EthereumLedgerService;
250
+ //# sourceMappingURL=EthereumLedgerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthereumLedgerService.js","sourceRoot":"","sources":["../../src/ledger/EthereumLedgerService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,2CAAiE;AACjE,yCAA6G;AAC7G,+CAAuC;AACvC,mCAAmC;AACnC,yDAA+C;AAE/C,kEAA8D;AAC9D,6EAAyE;AACzE,wDAA6E;AAC7E,0CAA8D;AAE9D;;GAEG;AACH,MAAa,mBAAoB,SAAQ,iBAAU;IACjD,YAAmB,OAAe,EAAE,KAAa;QAC/C,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG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B,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;wBAC7D,6DAA6D;wBAC7D,MAAM,EAAE,YAAY,KAAc,EAAE,EAAX,IAAI,UAAK,EAAE,EAA9B,gBAAyB,CAAK,CAAA;wBACpC,uCACK,IAAI,KACP,eAAe,IAChB;qBACF;oBACD,OAAO,EAAE,CAAA;gBACX,CAAC,CAAC,CAAA;aACH;SACF;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AA1OY,qBAAqB;IADjC,IAAA,iBAAU,GAAE;qCAOgB,2CAAoB;GANpC,qBAAqB,CA0OjC;AA1OY,sDAAqB"}
@@ -0,0 +1 @@
1
+ export * from './EthereumLedgerService';
@@ -0,0 +1,18 @@
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("./EthereumLedgerService"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ledger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC"}
@@ -0,0 +1,37 @@
1
+ import type { SchemaRegistryConfig } from './types/EthereumSchemaRegistry.types';
2
+ import type { ContractTransactionReceipt } from 'ethers';
3
+ export declare class EthereumSchemaRegistry {
4
+ private provider;
5
+ private wallet?;
6
+ private schemaRegistryContract;
7
+ constructor(config: SchemaRegistryConfig);
8
+ private validateConfig;
9
+ /**
10
+ * Create a new schema (requires wallet)
11
+ */
12
+ createSchema(schemaId: string, json: string): Promise<ContractTransactionReceipt>;
13
+ /**
14
+ * Create a schema for another address (admin only, requires wallet)
15
+ */
16
+ adminCreateSchema(address: string, schemaId: string, json: string): Promise<ContractTransactionReceipt>;
17
+ /**
18
+ * Get a schema by owner address and schema ID
19
+ */
20
+ getSchemaById(address: string, schemaId: string): Promise<string | null>;
21
+ /**
22
+ * Get list of schema Id by address
23
+ */
24
+ getSchemaIds(address: string): Promise<string[]>;
25
+ /**
26
+ * Get the current contract owner
27
+ */
28
+ getOwner(): Promise<string>;
29
+ /**
30
+ * Transfer contract ownership (admin only, requires wallet)
31
+ */
32
+ transferOwnership(newOwner: string): Promise<ContractTransactionReceipt>;
33
+ private validateSchemaId;
34
+ private validateJson;
35
+ private validateAddress;
36
+ private handleContractError;
37
+ }