@cheqd/did-provider-cheqd 1.3.3 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,34 +1,56 @@
1
- # Veramo plugin template
1
+ # Veramo SDK plugin for cheqd DID method
2
2
 
3
- This template repository provides a bare-bones structure for writing an agent plugin for Veramo and/or for providing
4
- your own implementations for key management and storage, or for DID storage.
3
+ [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cheqd/did-provider-cheqd/Workflow%20Dispatch/main?label=Lint%2C%20Build%2C%20Test&style=flat-square)](https://github.com/cheqd/did-provider-cheqd/actions/workflows/dispatch.yml) [![npm (scoped)](https://img.shields.io/npm/v/@cheqd/did-provider-cheqd?style=flat-square)](https://www.npmjs.com/package/@cheqd/did-provider-cheqd)
5
4
 
6
- ## Quick start
5
+ [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/cheqd/did-provider-cheqd?color=green&label=stable&sort=semver&style=flat-square)](https://github.com/cheqd/did-provider-cheqd/releases/latest) ![GitHub Release Date](https://img.shields.io/github/release-date/cheqd/did-provider-cheqd?style=flat-square)
7
6
 
8
- - Copy this repo
9
- - Rename package in `package.json`
10
- - `yarn`
11
- - `yarn build` or `yarn watch`
12
- - `yarn generate-plugin-schema`
13
- - `yarn start` or VSCode Debugger (CMD + Shift + D) > Run `OpenAPI server`
7
+ [![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/cheqd/did-provider-cheqd?include_prereleases&label=latest%20%28incl.%20pre-release%29&sort=semver&style=flat-square)](https://github.com/cheqd/did-provider-cheqd/releases/) ![GitHub commits since latest release (by date)](https://img.shields.io/github/commits-since/cheqd/did-provider-cheqd/latest?style=flat-square)
14
8
 
15
- ## Structure of this template
9
+ [![GitHub contributors](https://img.shields.io/github/contributors/cheqd/did-provider-cheqd?style=flat-square)](https://github.com/cheqd/did-provider-cheqd/graphs/contributors) ![GitHub repo size](https://img.shields.io/github/repo-size/cheqd/did-provider-cheqd?style=flat-square)
16
10
 
17
- ### Using plugin with @veramo/cli
11
+ ## ℹ️ Overview
18
12
 
19
- See [./agent.yml](./agent.yml) for an example Veramo CLI configuration that uses the plugin and customizations from this
20
- template alongside other Veramo plugins to create a fully functioning agent.
13
+ The purpose of this [`@cheqd/did-provider-cheqd` NPM package](https://www.npmjs.com/package/@cheqd/did-provider-cheqd) is to enable developers to interact with the cheqd ledger using [Veramo SDK](https://veramo.io/), a modular and pluggable client app SDK for decentralised identity and SSI applications.
21
14
 
22
- ## Testing your plugin
15
+ This package includes [Veramo SDK Agent methods](https://veramo.io/docs/veramo_agent/plugins) for use with the [Veramo CLI NPM package](https://www.npmjs.com/package/@veramo/cli). It can also be consumed as an NPM package outside Veramo CLI for building your own applications with NPM.
23
16
 
24
- There are a number of ways to test your plugin.
17
+ The package's core functionality is borrowed from [Veramo Core NPM package](https://www.npmjs.com/package/@veramo/core). and extends this to include cheqd ledger functionality, such as creating and managing DIDs.
25
18
 
26
- ### Integration tests
19
+ ### 🆔 `did:cheqd`-specific functionality
27
20
 
28
- Will be added in the nearest future.
21
+ `did-provider-cheqd` is the first Veramo SDK plug-in that utilises the *DID Manager Update* method to offer a full-body DIDDoc update for a DID on cheqd ledger, rather than individual field update transactions used more commonly in other DID methods such as [`did:ethr`](https://developer.uport.me/ethr-did/docs/index).
29
22
 
30
- ### Call your agent using the Veramo OpenAPI server
23
+ New DID creation can also be done by passing a full-body DIDoc payload in JSON, rather than having to assemble the document field-by-field.
31
24
 
32
- You can also run `yarn veramo server` in your terminal and then go to <http://localhost:3335/api-docs> to see all the
33
- available plugin methods. You can call them after you click Authorize and provide the API key defined
34
- in [agent.yml](./agent.yml#L119). By default, it is `test123`.
25
+ ## 📚 Tutorials
26
+
27
+ Extensive [tutorials on how to use Veramo SDK for cheqd](https://docs.cheqd.io/identity/tutorials/dids/veramo-cli-sdk) are available on the [cheqd Identity Documentation site](https://docs.cheqd.io/identity/).
28
+
29
+ ## 🧑‍💻🛠 Developer Guide
30
+
31
+ ### Setup
32
+
33
+ Dependencies can be installed [using NPM](https://docs.npmjs.com/cli/v8/commands) or similar package package managers using the `package.json` in this repository.
34
+
35
+ ```bash
36
+ npm install
37
+ ```
38
+
39
+ ### Configuration
40
+
41
+ A default Veramo Agent configuration is provided in the [`agent.yml`](https://github.com/cheqd/did-provider-cheqd/blob/main/agent.yml) file in this repository.
42
+
43
+ ⚠️ Here are the values that you are recommended to edit before usage:
44
+
45
+ 1. `dbEncryptionKey`: Encryption key for Veramo KMS local storage [SQLite database](https://www.sqlite.org/index.html). If you don't change this, the default database encryption key present in the file is used.
46
+ 2. `cosmosPayerMnemonic`: Mnemonic for the cheqd Cosmos account from which the fees for any transactions are paid.
47
+
48
+ ## 💬 Community
49
+
50
+ The [**cheqd Community Slack**](http://cheqd.link/join-cheqd-slack) is our primary chat channel for the open-source community, software developers, and node operators.
51
+
52
+ Please reach out to us there for discussions, help, and feedback on the project.
53
+
54
+ ## 🙋 Find us elsewhere
55
+
56
+ [![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\&logo=telegram\&logoColor=white)](https://t.me/cheqd) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge\&logo=discord\&logoColor=white)](http://cheqd.link/discord-github) [![Twitter](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge\&logo=twitter\&logoColor=white)](https://twitter.com/intent/follow?screen\_name=cheqd\_io) [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\&logo=linkedin\&logoColor=white)](http://cheqd.link/linkedin) [![Slack](https://img.shields.io/badge/Slack-4A154B?style=for-the-badge\&logo=slack\&logoColor=white)](http://cheqd.link/join-cheqd-slack) [![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge\&logo=medium\&logoColor=white)](https://blog.cheqd.io) [![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge\&logo=youtube\&logoColor=white)](https://www.youtube.com/channel/UCBUGvvH6t3BAYo5u41hJPzw/)
@@ -1,5 +1,4 @@
1
1
  import { IAgentContext, IKeyManager, IAgentPlugin, IPluginMethodMap, IAgentPluginSchema, IIdentifier } from '@veramo/core';
2
- import { CheqdDIDProvider } from '../did-manager/cheqd-did-provider';
3
2
  declare type IContext = IAgentContext<IKeyManager>;
4
3
  declare const CreateIdentifierMethodName = "cheqdCreateIdentifier";
5
4
  declare const UpdateIdentifierMethodName = "cheqdUpdateIdentifier";
@@ -10,8 +9,8 @@ export interface ICheqd extends IPluginMethodMap {
10
9
  export declare class Cheqd implements IAgentPlugin {
11
10
  readonly methods?: ICheqd;
12
11
  readonly schema?: IAgentPluginSchema;
13
- readonly didProvider: CheqdDIDProvider;
14
- constructor(provider: CheqdDIDProvider);
12
+ readonly didProvider: string;
13
+ constructor(provider: string);
15
14
  private CreateIdentifier;
16
15
  private UpdateIdentifier;
17
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ICheqd.d.ts","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE,aAAK,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;AAE1C,QAAA,MAAM,0BAA0B,0BAA0B,CAAA;AAC1D,QAAA,MAAM,0BAA0B,0BAA0B,CAAA;AAE1D,MAAM,WAAW,MAAO,SAAQ,gBAAgB;IAC5C,CAAC,0BAA0B,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAA;IACtG,CAAC,0BAA0B,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ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29
29
  },
30
- "cheqdUpdateIdentifier": {}
30
+ "cheqdUpdateIdentifier": {
31
+ "description": "Update an identifier",
32
+ "arguments": {
33
+ "type": "object",
34
+ "properties": {
35
+ "args": {
36
+ "type": "object",
37
+ "description": "A cheqdUpdateIdentifierArgs object as any for extensibility"
38
+ }
39
+ },
40
+ "required": [
41
+ "args"
42
+ ]
43
+ },
44
+ "returnType": {
45
+ "type": "object"
46
+ }
47
+ }
31
48
  }
32
49
  }
33
50
  };
@@ -47,17 +64,18 @@ class Cheqd {
47
64
  if (typeof args.document !== 'object') {
48
65
  throw new Error('[cheqd-plugin]: document object is required');
49
66
  }
50
- if (Array.isArray(args === null || args === void 0 ? void 0 : args.keys)) {
67
+ if (typeof args.keys !== 'object') {
51
68
  throw new Error('[cheqd-plugin]: keys array is required');
52
69
  }
53
- return await this.didProvider.createIdentifier({
70
+ return await context.agent.didManagerCreate({
54
71
  kms: args.kms,
55
72
  alias: args.alias,
73
+ provider: this.didProvider,
56
74
  options: {
57
75
  document: args.document,
58
76
  keys: args.keys
59
77
  }
60
- }, context);
78
+ });
61
79
  }
62
80
  async UpdateIdentifier(args, context) {
63
81
  if (typeof args.kms !== 'string') {
@@ -69,10 +87,18 @@ class Cheqd {
69
87
  if (typeof args.document !== 'object') {
70
88
  throw new Error('[cheqd-plugin]: document object is required');
71
89
  }
72
- return await this.didProvider.updateIdentifier({
90
+ if (typeof args.keys !== 'object') {
91
+ throw new Error('[cheqd-plugin]: keys array is required');
92
+ }
93
+ return await context.agent.didManagerUpdate({
73
94
  did: args.did,
74
95
  document: args.document,
75
- }, context);
96
+ provider: this.didProvider,
97
+ options: {
98
+ kms: args.kms,
99
+ keys: args.keys
100
+ }
101
+ });
76
102
  }
77
103
  }
78
104
  exports.Cheqd = Cheqd;
@@ -1 +1 @@
1
- {"version":3,"file":"ICheqd.js","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":";;;AAYA,MAAM,0BAA0B,GAAG,uBAAuB,CAA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ACN,CAAC;CACJ;AA/GD,sBA+GC"}
@@ -50,10 +50,14 @@ export declare class CheqdDIDProvider extends AbstractIdentifierProvider {
50
50
  keys: TImportableEd25519Key[];
51
51
  };
52
52
  }, context: IContext): Promise<Omit<IIdentifier, 'provider'>>;
53
- updateIdentifier({ did, document }: {
53
+ updateIdentifier({ did, document, options }: {
54
54
  did: string;
55
55
  document: Partial<DIDDocument>;
56
- }, context: IContext): Promise<void>;
56
+ options: {
57
+ kms: string;
58
+ keys: TImportableEd25519Key[];
59
+ };
60
+ }, context: IContext): Promise<IIdentifier>;
57
61
  deleteIdentifier(identity: IIdentifier, context: IContext): Promise<boolean>;
58
62
  addKey({ identifier, key, options, }: {
59
63
  identifier: IIdentifier;
@@ -1 +1 @@
1
- {"version":3,"file":"cheqd-did-provider.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtF,OAAO,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,WAAW,EAGX,WAAW,EACX,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAKhE,aAAK,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;AAE1C,oBAAY,aAAa;IACxB,OAAO,0BAA0B;IACjC,OAAO,8BAA8B;CACrC;AAED,oBAAY,WAAW;IACtB,OAAO,YAAY;IACnB,OAAO,YAAY;CACnB;AAED,oBAAY,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAE3F,oBAAY,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC,GAAG;IAAE,GAAG,EAAE,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAAC,IAAI,EAAE,SA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E,GAAG,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,qBAAqB,EAAE,CAAA;SAAE,CAAA;KAAE,EACnI,OAAO,EAAE,QAAQ,GACf,OAAO,CAAC,WAAW,CAAC;IAuCjB,gBAAgB,CACrB,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,QAAQ,GACf,OAAO,CAAC,OAAO,CAAC;IAOb,MAAM,CACX,EAEC,UAAU,EAEV,GAAG,EAEH,OAAO,GAEP,EAAE;QAAE,UAAU,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAExD,OAAO,EAAE,QAAQ,GAEf,OAAO,CAAC,GAAG,CAAC;IAIT,UAAU,CACf,EAEC,UAAU,EAEV,OAAO,EAEP,OAAO,GAEP,EAAE;QAAE,UAAU,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAEhE,OAAO,EAAE,QAAQ,GAEf,OAAO,CAAC,GAAG,CAAC;IAIT,SAAS,CAEd,IAAI,EAAE;QACL,UAAU,EAAE,WAAW,CAAC;QACxB,GAAG,EAAE,MAAM,CAAC;QAEZ,OAAO,CAAC,EAAE,GAAG,CAAA;KACb,EAED,OAAO,EAAE,QAAQ,GAEf,OAAO,CAAC,GAAG,CAAC;IAIT,aAAa,CAElB,IAAI,EAAE;QACL,UAAU,EAAE,WAAW,CAAC;QACxB,EAAE,EAAE,MAAM,CAAC;QAEX,OAAO,CAAC,EAAE,GAAG,CAAA;KACb,EAED,OAAO,EAAE,QAAQ,GAEf,OAAO,CAAC,GAAG,CAAC;CAGf"}
@@ -28,7 +28,7 @@ class CheqdDIDProvider extends did_manager_1.AbstractIdentifierProvider {
28
28
  constructor(options) {
29
29
  super();
30
30
  this.defaultKms = options.defaultKms;
31
- this.cosmosPayerWallet = proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(options.cosmosPayerMnemonic);
31
+ this.cosmosPayerWallet = proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(options.cosmosPayerMnemonic, { prefix: 'cheqd' });
32
32
  this.network = options.networkType ? options.networkType : NetworkType.Testnet;
33
33
  this.rpcUrl = options.rpcUrl ? options.rpcUrl : (this.network === NetworkType.Testnet ? DefaultRPCUrl.Testnet : DefaultRPCUrl.Mainnet);
34
34
  }
@@ -69,7 +69,7 @@ class CheqdDIDProvider extends did_manager_1.AbstractIdentifierProvider {
69
69
  const sdk = await this.getCheqdSDK();
70
70
  const signInputs = options.keys.map(key => { var _a; return (0, sdk_1.createSignInputsFromImportableEd25519Key)(key, (_a = options.document.verificationMethod) !== null && _a !== void 0 ? _a : []); });
71
71
  const tx = await sdk.createDidTx(signInputs, options.document, '', this.fee || 'auto', undefined, { sdk: sdk });
72
- (0, utils_1.assert)(tx.code === 0, 'cosmos_transaction: Failed to create DID');
72
+ (0, utils_1.assert)(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`);
73
73
  //* Currently, only one controller key is supported. This is subject to change in the near future.
74
74
  const controllerKey = await context.agent.keyManagerImport({
75
75
  ...options.keys[0],
@@ -81,18 +81,37 @@ class CheqdDIDProvider extends did_manager_1.AbstractIdentifierProvider {
81
81
  did: options.document.id,
82
82
  controllerKeyId: controllerKey.kid,
83
83
  keys: [controllerKey, ..._keys],
84
- services: [],
85
- provider: 'cheqd',
84
+ services: options.document.service || [],
85
+ provider: `did:cheqd:${this.network}`,
86
86
  };
87
87
  debug('Created DID', identifier.did);
88
88
  return identifier;
89
89
  }
90
+ // TODO: Add client side diff calculation using the resolver & SDK helper functions.
91
+ //* This will allow for better accuracy and predictability of `updateIdentifier` race conditions.
90
92
  async updateIdentifier(
91
93
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
92
- { did, document }, context) {
93
- console.log("document received: " + JSON.stringify(document, null, 2));
94
- // TODO: Handle did update
94
+ { did, document, options }, context) {
95
+ const sdk = await this.getCheqdSDK();
96
+ const signInputs = options.keys.map(key => { var _a; return (0, sdk_1.createSignInputsFromImportableEd25519Key)(key, (_a = document.verificationMethod) !== null && _a !== void 0 ? _a : []); });
97
+ const tx = await sdk.updateDidTx(signInputs, document, '', this.fee || 'auto', undefined, { sdk: sdk });
98
+ (0, utils_1.assert)(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`);
99
+ //* Currently, only one controller key is supported. This is subject to change in the near future.
100
+ const controllerKey = await context.agent.keyManagerImport({
101
+ ...options.keys[0],
102
+ kms: options.kms || this.defaultKms,
103
+ });
104
+ const _keys = await Promise.all(options.keys.slice(1).map(async (key) => await context.agent.keyManagerImport({ ...key, kms: options.kms || this.defaultKms })));
105
+ const identifier = {
106
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
107
+ did: document.id,
108
+ controllerKeyId: controllerKey.kid,
109
+ keys: [controllerKey, ..._keys],
110
+ services: document.service || [],
111
+ provider: `did:cheqd:${this.network}`,
112
+ };
95
113
  debug('Updated DID', did);
114
+ return identifier;
96
115
  }
97
116
  async deleteIdentifier(identity, context) {
98
117
  for (const { kid } of identity.keys) {
@@ -1 +1 @@
1
- {"version":3,"file":"cheqd-did-provider.js","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":";;;;;;AAAA,oCAA4H;AAI5H,yDAA+D;AAC/D,yCAAsC;AAWtC,qDAAgE;AAChE,kDAAyB;AAEzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,2BAA2B,CAAC,CAAA;AAIhD,IAAY,aAGX;AAHD,WAAY,aAAa;IACxB,kDAAiC,CAAA;IACjC,sDAAqC,CAAA;AACtC,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACpB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGt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,OAAiB;QAGjB,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAA;IACjE,CAAC;CACD;AApND,4CAoNC"}
@@ -1,17 +1,21 @@
1
1
  import { DIDResolutionOptions, DIDResolutionResult, DIDResolver, ParsedDID, Resolvable } from 'did-resolver';
2
+ interface Options {
3
+ url: string;
4
+ }
2
5
  /**
3
6
  * Creates a CheqdDIDResolver instance that can be used with `did-resolver`.
4
7
  * @public
5
8
  */
6
- export declare function getResolver(resolverUrl?: string): Record<string, DIDResolver>;
9
+ export declare function getResolver(options?: Options): Record<string, DIDResolver>;
7
10
  /**
8
11
  * CheqdDIDResolver instance that can be used with `did-resolver`.
9
12
  * @public
10
13
  */
11
14
  export declare class CheqdDidResolver {
12
15
  private resolverUrl;
13
- constructor(resolverUrl?: string);
16
+ constructor(options?: Options);
14
17
  resolve(did: string, parsed: ParsedDID, _unused: Resolvable, options: DIDResolutionOptions): Promise<DIDResolutionResult>;
15
18
  build(): Record<string, DIDResolver>;
16
19
  }
20
+ export {};
17
21
  //# sourceMappingURL=cheqd-did-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cheqd-did-resolver.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,UAAU,EACX,MAAM,cAAc,CAAA;AAErB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAI7E;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAC4B;gBAEnC,WAAW,CAAC,EAAE,MAAM;IAI1B,OAAO,CACX,GAAG,EAAE,MAAM,EAEX,MAAM,EAAE,SAAS,EAEjB,OAAO,EAAE,UAAU,EAEnB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;IAY/B,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;CAGrC"}
1
+ {"version":3,"file":"cheqd-did-resolver.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAI1E;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAgD;gBAEvD,OAAO,CAAC,EAAE,OAAO;IAIvB,OAAO,CACX,GAAG,EAAE,MAAM,EAEX,MAAM,EAAE,SAAS,EAEjB,OAAO,EAAE,UAAU,EAEnB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;IAY/B,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;CAGrC"}
@@ -5,9 +5,9 @@ exports.CheqdDidResolver = exports.getResolver = void 0;
5
5
  * Creates a CheqdDIDResolver instance that can be used with `did-resolver`.
6
6
  * @public
7
7
  */
8
- function getResolver(resolverUrl) {
9
- if (resolverUrl)
10
- return new CheqdDidResolver(resolverUrl).build();
8
+ function getResolver(options) {
9
+ if (options === null || options === void 0 ? void 0 : options.url)
10
+ return new CheqdDidResolver(options).build();
11
11
  return new CheqdDidResolver().build();
12
12
  }
13
13
  exports.getResolver = getResolver;
@@ -16,10 +16,10 @@ exports.getResolver = getResolver;
16
16
  * @public
17
17
  */
18
18
  class CheqdDidResolver {
19
- constructor(resolverUrl) {
19
+ constructor(options) {
20
20
  this.resolverUrl = 'https://resolver.cheqd.net/1.0/identifiers/';
21
- if (resolverUrl)
22
- this.resolverUrl = resolverUrl;
21
+ if (options === null || options === void 0 ? void 0 : options.url)
22
+ this.resolverUrl = options.url;
23
23
  }
24
24
  async resolve(did,
25
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1 +1 @@
1
- {"version":3,"file":"cheqd-did-resolver.js","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-resolver.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACH,SAAgB,WAAW,CAAC,WAAoB;IAC9C,IAAI,WAAW;QAAE,OAAO,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAA;IAEjE,OAAO,IAAI,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAA;AACvC,CAAC;AAJD,kCAIC;AAED;;;GAGG;AACH,MAAa,gBAAgB;IAI3B,YAAY,WAAoB;QAHxB,gBAAW,GACjB,6CAA6C,CAAA;QAG7C,IAAI,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,GAAW;IACX,6DAA6D;IAC7D,MAAiB;IACjB,6DAA6D;IAC7D,OAAmB;IACnB,6DAA6D;IAC7D,OAA6B;QAE7B,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE;gBACjD,OAAO,EAAE,EAAE,cAAc,EAAE,sBAAsB,EAAE;aACpD,CAAC,CAAA;YACF,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAwB,CAAA;YACxD,OAAO,GAAG,CAAA;SACX;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;SACzB;IACH,CAAC;IAED,KAAK;QACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IAC3C,CAAC;CACF;AA/BD,4CA+BC"}
1
+ {"version":3,"file":"cheqd-did-resolver.js","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-resolver.ts"],"names":[],"mappings":";;;AAYA;;;GAGG;AACH,SAAgB,WAAW,CAAC,OAAiB;IAC3C,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG;QAAE,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;IAE9D,OAAO,IAAI,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAA;AACvC,CAAC;AAJD,kCAIC;AAED;;;GAGG;AACH,MAAa,gBAAgB;IAG3B,YAAY,OAAiB;QAFrB,gBAAW,GAAG,6CAA6C,CAAA;QAGjE,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG;YAAE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,CAAA;IAClD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,GAAW;IACX,6DAA6D;IAC7D,MAAiB;IACjB,6DAA6D;IAC7D,OAAmB;IACnB,6DAA6D;IAC7D,OAA6B;QAE7B,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE;gBACjD,OAAO,EAAE,EAAE,cAAc,EAAE,sBAAsB,EAAE;aACpD,CAAC,CAAA;YACF,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAwB,CAAA;YACxD,OAAO,GAAG,CAAA;SACX;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;SACzB;IACH,CAAC;IAED,KAAK;QACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IAC3C,CAAC;CACF;AA9BD,4CA8BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheqd/did-provider-cheqd",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
4
4
  "description": "Veramo SDK plugin for the did:cheqd DID method",
5
5
  "license": "Apache-2.0",
6
6
  "source": "src/index.ts",
@@ -45,11 +45,11 @@
45
45
  "@semantic-release/release-notes-generator": "^10.0.3",
46
46
  "@types/debug": "^4.1.7",
47
47
  "@types/jest": "27.5.1",
48
- "@typescript-eslint/eslint-plugin": "^5.31.0",
49
- "@typescript-eslint/parser": "^5.31.0",
48
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
49
+ "@typescript-eslint/parser": "^5.32.0",
50
50
  "@veramo/cli": "^3.1.5",
51
51
  "conventional-changelog-conventionalcommits": "^5.0.0",
52
- "eslint": "^8.20.0",
52
+ "eslint": "^8.21.0",
53
53
  "eslint-config-prettier": "^8.5.0",
54
54
  "eslint-config-typescript": "^3.0.0",
55
55
  "jest": "27.5.1",
@@ -67,14 +67,14 @@
67
67
  "tsconfig.json"
68
68
  ],
69
69
  "dependencies": {
70
- "@cheqd/sdk": "^1.2.3",
70
+ "@cheqd/sdk": "^1.2.4",
71
71
  "@cheqd/ts-proto": "^1.0.11",
72
72
  "@cosmjs/proto-signing": "^0.28.11",
73
73
  "@cosmjs/utils": "^0.28.11",
74
- "@veramo/core": "^3.1.3",
75
- "@veramo/did-manager": "^3.1.3",
74
+ "@veramo/core": "^3.1.6-next.156",
75
+ "@veramo/did-manager": "^3.1.6-next.156",
76
76
  "@veramo/did-provider-key": "^3.1.3",
77
- "@veramo/key-manager": "^3.1.3",
77
+ "@veramo/key-manager": "^3.1.6-next.156",
78
78
  "debug": "^4.3.4",
79
79
  "multibase": "^4.0.6",
80
80
  "multicodec": "^3.2.1"
@@ -6,7 +6,6 @@ import {
6
6
  IAgentPluginSchema,
7
7
  IIdentifier
8
8
  } from '@veramo/core'
9
- import { CheqdDIDProvider } from '../did-manager/cheqd-did-provider'
10
9
 
11
10
  type IContext = IAgentContext<IKeyManager>
12
11
 
@@ -42,14 +41,30 @@ export class Cheqd implements IAgentPlugin {
42
41
  "type": "object"
43
42
  }
44
43
  },
45
- "cheqdUpdateIdentifier": {}
44
+ "cheqdUpdateIdentifier": {
45
+ "description": "Update an identifier",
46
+ "arguments": {
47
+ "type": "object",
48
+ "properties": {
49
+ "args": {
50
+ "type": "object",
51
+ "description": "A cheqdUpdateIdentifierArgs object as any for extensibility"
52
+ }
53
+ },
54
+ "required": [
55
+ "args"
56
+ ]
57
+ },
58
+ "returnType": {
59
+ "type": "object"
60
+ }
61
+ }
46
62
  }
47
63
  }
48
64
  }
65
+ readonly didProvider: string;
49
66
 
50
- readonly didProvider: CheqdDIDProvider;
51
-
52
- constructor(provider: CheqdDIDProvider) {
67
+ constructor(provider: string) {
53
68
  this.didProvider = provider
54
69
 
55
70
  this.methods = {
@@ -71,18 +86,19 @@ export class Cheqd implements IAgentPlugin {
71
86
  throw new Error('[cheqd-plugin]: document object is required')
72
87
  }
73
88
 
74
- if (Array.isArray(args?.keys)) {
89
+ if (typeof args.keys !== 'object') {
75
90
  throw new Error('[cheqd-plugin]: keys array is required')
76
91
  }
77
92
 
78
- return await this.didProvider.createIdentifier({
93
+ return await context.agent.didManagerCreate({
79
94
  kms: args.kms,
80
95
  alias: args.alias,
96
+ provider: this.didProvider,
81
97
  options: {
82
98
  document: args.document,
83
99
  keys: args.keys
84
100
  }
85
- }, context)
101
+ })
86
102
  }
87
103
 
88
104
  private async UpdateIdentifier(args: any, context: IContext) {
@@ -98,9 +114,18 @@ export class Cheqd implements IAgentPlugin {
98
114
  throw new Error('[cheqd-plugin]: document object is required')
99
115
  }
100
116
 
101
- return await this.didProvider.updateIdentifier({
117
+ if (typeof args.keys !== 'object') {
118
+ throw new Error('[cheqd-plugin]: keys array is required')
119
+ }
120
+
121
+ return await context.agent.didManagerUpdate({
102
122
  did: args.did,
103
123
  document: args.document,
104
- }, context)
124
+ provider: this.didProvider,
125
+ options: {
126
+ kms: args.kms,
127
+ keys: args.keys
128
+ }
129
+ })
105
130
  }
106
131
  }
@@ -1,6 +1,7 @@
1
1
  import { CheqdSDK, createCheqdSDK, createSignInputsFromImportableEd25519Key, DIDModule, ICheqdSDKOptions } from '@cheqd/sdk'
2
2
  import { AbstractCheqdSDKModule } from '@cheqd/sdk/src/modules/_'
3
3
  import { DidStdFee } from '@cheqd/sdk/src/types'
4
+ import { Service, VerificationMethod } from '@cheqd/ts-proto/cheqd/v1/did'
4
5
  import { MsgCreateDidPayload, MsgUpdateDidPayload } from '@cheqd/ts-proto/cheqd/v1/tx'
5
6
  import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'
6
7
  import { assert } from '@cosmjs/utils'
@@ -50,7 +51,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
50
51
  constructor(options: { defaultKms: string, cosmosPayerMnemonic: string, networkType?: NetworkType, rpcUrl?: string }) {
51
52
  super()
52
53
  this.defaultKms = options.defaultKms
53
- this.cosmosPayerWallet = DirectSecp256k1HdWallet.fromMnemonic(options.cosmosPayerMnemonic)
54
+ this.cosmosPayerWallet = DirectSecp256k1HdWallet.fromMnemonic(options.cosmosPayerMnemonic, { prefix: 'cheqd' })
54
55
  this.network = options.networkType ? options.networkType : NetworkType.Testnet
55
56
  this.rpcUrl = options.rpcUrl ? options.rpcUrl : (this.network === NetworkType.Testnet ? DefaultRPCUrl.Testnet : DefaultRPCUrl.Mainnet)
56
57
  }
@@ -108,7 +109,7 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
108
109
  { sdk: sdk }
109
110
  )
110
111
 
111
- assert(tx.code === 0, 'cosmos_transaction: Failed to create DID')
112
+ assert(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`)
112
113
 
113
114
  //* Currently, only one controller key is supported. This is subject to change in the near future.
114
115
 
@@ -124,8 +125,8 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
124
125
  did: options.document.id!,
125
126
  controllerKeyId: controllerKey.kid,
126
127
  keys: [controllerKey, ..._keys],
127
- services: [],
128
- provider: 'cheqd',
128
+ services: options.document.service || [],
129
+ provider: `did:cheqd:${this.network}`,
129
130
  }
130
131
 
131
132
  debug('Created DID', identifier.did)
@@ -133,19 +134,49 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
133
134
  return identifier
134
135
  }
135
136
 
137
+ // TODO: Add client side diff calculation using the resolver & SDK helper functions.
138
+ //* This will allow for better accuracy and predictability of `updateIdentifier` race conditions.
136
139
  async updateIdentifier(
137
140
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
138
- { did, document}: {
139
- did: string,
140
- document: Partial<DIDDocument>
141
- },
141
+ { did, document, options}: { did: string, document: Partial<DIDDocument>, options: { kms: string, keys: TImportableEd25519Key[] } },
142
142
  context: IContext,
143
- ): Promise<void> {
144
- console.log("document received: " + JSON.stringify(document, null, 2))
143
+ ): Promise<IIdentifier> {
144
+ const sdk = await this.getCheqdSDK()
145
145
 
146
- // TODO: Handle did update
146
+ const signInputs = options.keys.map(key => createSignInputsFromImportableEd25519Key(key, document.verificationMethod as unknown as VerificationMethod[] ?? []))
147
+
148
+ const tx = await sdk.updateDidTx(
149
+ signInputs,
150
+ document as Partial<IdentifierPayload>,
151
+ '',
152
+ this.fee || 'auto',
153
+ undefined,
154
+ { sdk: sdk }
155
+ )
156
+
157
+ assert(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`)
158
+
159
+ //* Currently, only one controller key is supported. This is subject to change in the near future.
160
+
161
+ const controllerKey: ManagedKeyInfo = await context.agent.keyManagerImport({
162
+ ...options.keys[0],
163
+ kms: options.kms || this.defaultKms,
164
+ } as MinimalImportableKey)
165
+
166
+ const _keys = await Promise.all(options.keys.slice(1).map(async key => await context.agent.keyManagerImport({ ...key, kms: options.kms || this.defaultKms })))
167
+
168
+ const identifier: IIdentifier = {
169
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
170
+ did: document.id!,
171
+ controllerKeyId: controllerKey.kid,
172
+ keys: [controllerKey, ..._keys],
173
+ services: document.service as unknown as Service[] || [],
174
+ provider: `did:cheqd:${this.network}`,
175
+ }
147
176
 
148
177
  debug('Updated DID', did)
178
+
179
+ return identifier
149
180
  }
150
181
 
151
182
  async deleteIdentifier(
@@ -6,12 +6,16 @@ import {
6
6
  Resolvable,
7
7
  } from 'did-resolver'
8
8
 
9
+ interface Options {
10
+ url: string
11
+ }
12
+
9
13
  /**
10
14
  * Creates a CheqdDIDResolver instance that can be used with `did-resolver`.
11
15
  * @public
12
16
  */
13
- export function getResolver(resolverUrl?: string): Record<string, DIDResolver> {
14
- if (resolverUrl) return new CheqdDidResolver(resolverUrl).build()
17
+ export function getResolver(options?: Options): Record<string, DIDResolver> {
18
+ if (options?.url) return new CheqdDidResolver(options).build()
15
19
 
16
20
  return new CheqdDidResolver().build()
17
21
  }
@@ -21,11 +25,10 @@ export function getResolver(resolverUrl?: string): Record<string, DIDResolver> {
21
25
  * @public
22
26
  */
23
27
  export class CheqdDidResolver {
24
- private resolverUrl: undefined | string =
25
- 'https://resolver.cheqd.net/1.0/identifiers/'
28
+ private resolverUrl = 'https://resolver.cheqd.net/1.0/identifiers/'
26
29
 
27
- constructor(resolverUrl?: string) {
28
- if (resolverUrl) this.resolverUrl = resolverUrl
30
+ constructor(options?: Options) {
31
+ if (options?.url) this.resolverUrl = options.url
29
32
  }
30
33
 
31
34
  async resolve(