@cheqd/did-provider-cheqd 1.4.4 → 1.6.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.
- package/README.md +1 -1
- package/build/agent/ICheqd.d.ts +11 -0
- package/build/agent/ICheqd.d.ts.map +1 -1
- package/build/agent/ICheqd.js +70 -1
- package/build/agent/ICheqd.js.map +1 -1
- package/build/did-manager/cheqd-did-provider.d.ts +2 -1
- package/build/did-manager/cheqd-did-provider.d.ts.map +1 -1
- package/package.json +10 -8
- package/src/agent/ICheqd.ts +85 -2
- package/src/did-manager/cheqd-did-provider.ts +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ New DID creation can also be done by passing a full-body DIDoc payload in JSON,
|
|
|
24
24
|
|
|
25
25
|
## 📚 Tutorials
|
|
26
26
|
|
|
27
|
-
Extensive [tutorials on how to use Veramo SDK for cheqd](https://docs.cheqd.io/identity/
|
|
27
|
+
Extensive [tutorials on how to use Veramo SDK for cheqd](https://docs.cheqd.io/identity/using-decentralised-identity-in-apps/veramo-sdk-for-cheqd) are available on the [cheqd Identity Documentation site](https://docs.cheqd.io/identity/).
|
|
28
28
|
|
|
29
29
|
## 🧑💻🛠 Developer Guide
|
|
30
30
|
|
package/build/agent/ICheqd.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { IAgentContext, IKeyManager, IAgentPlugin, IPluginMethodMap, IAgentPluginSchema, IIdentifier } from '@veramo/core';
|
|
2
|
+
import { IdentifierPayload, TImportableEd25519Key } from '../did-manager/cheqd-did-provider';
|
|
2
3
|
declare type IContext = IAgentContext<IKeyManager>;
|
|
4
|
+
declare type TExportedDIDDocWithKeys = {
|
|
5
|
+
didDoc: IdentifierPayload;
|
|
6
|
+
keys: TImportableEd25519Key;
|
|
7
|
+
};
|
|
3
8
|
declare const CreateIdentifierMethodName = "cheqdCreateIdentifier";
|
|
4
9
|
declare const UpdateIdentifierMethodName = "cheqdUpdateIdentifier";
|
|
10
|
+
declare const GenerateDidDocMethodName = "cheqdGenerateDidDoc";
|
|
11
|
+
declare const GenerateKeyPairMethodName = "cheqdGenerateIdentityKeys";
|
|
5
12
|
export interface ICheqd extends IPluginMethodMap {
|
|
6
13
|
[CreateIdentifierMethodName]: (args: any, context: IContext) => Promise<Omit<IIdentifier, 'provider'>>;
|
|
7
14
|
[UpdateIdentifierMethodName]: (args: any, context: IContext) => Promise<void>;
|
|
15
|
+
[GenerateDidDocMethodName]: (args: any, context: IContext) => Promise<TExportedDIDDocWithKeys>;
|
|
16
|
+
[GenerateKeyPairMethodName]: (args: any, context: IContext) => Promise<TImportableEd25519Key>;
|
|
8
17
|
}
|
|
9
18
|
export declare class Cheqd implements IAgentPlugin {
|
|
10
19
|
readonly methods?: ICheqd;
|
|
@@ -15,6 +24,8 @@ export declare class Cheqd implements IAgentPlugin {
|
|
|
15
24
|
});
|
|
16
25
|
private CreateIdentifier;
|
|
17
26
|
private UpdateIdentifier;
|
|
27
|
+
private GenerateDidDoc;
|
|
28
|
+
private GenerateIdentityKeys;
|
|
18
29
|
}
|
|
19
30
|
export {};
|
|
20
31
|
//# sourceMappingURL=ICheqd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICheqd.d.ts","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ICheqd.d.ts","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAG5F,aAAK,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;AAC1C,aAAK,uBAAuB,GAAG;IAAE,MAAM,EAAE,iBAAiB,CAAC;IAAC,IA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d/sdk/src/utils");
|
|
5
|
+
const uint8arrays_1 = require("uint8arrays");
|
|
4
6
|
const CreateIdentifierMethodName = 'cheqdCreateIdentifier';
|
|
5
7
|
const UpdateIdentifierMethodName = 'cheqdUpdateIdentifier';
|
|
8
|
+
const GenerateDidDocMethodName = 'cheqdGenerateDidDoc';
|
|
9
|
+
const GenerateKeyPairMethodName = 'cheqdGenerateIdentityKeys';
|
|
6
10
|
class Cheqd {
|
|
7
11
|
constructor(args) {
|
|
8
12
|
this.schema = {
|
|
@@ -44,6 +48,30 @@ class Cheqd {
|
|
|
44
48
|
"returnType": {
|
|
45
49
|
"type": "object"
|
|
46
50
|
}
|
|
51
|
+
},
|
|
52
|
+
'cheqdGenerateDidDoc': {
|
|
53
|
+
'description': 'Generate a new DID document to use with `createIdentifier`',
|
|
54
|
+
'arguments': {
|
|
55
|
+
'type': 'object',
|
|
56
|
+
'properties': {
|
|
57
|
+
'args': {
|
|
58
|
+
'type': 'object',
|
|
59
|
+
'description': 'A cheqdGenerateDidDocArgs object as any for extensibility'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'cheqdGenerateKeyPair': {
|
|
65
|
+
'description': 'Generate a new key pair in hex to use with `createIdentifier`',
|
|
66
|
+
'arguments': {
|
|
67
|
+
'type': 'object',
|
|
68
|
+
'properties': {
|
|
69
|
+
'args': {
|
|
70
|
+
'type': 'object',
|
|
71
|
+
'description': 'A cheqdGenerateKeyPairArgs object as any for extensibility'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
}
|
|
@@ -54,7 +82,9 @@ class Cheqd {
|
|
|
54
82
|
this.didProvider = args.provider;
|
|
55
83
|
this.methods = {
|
|
56
84
|
[CreateIdentifierMethodName]: this.CreateIdentifier.bind(this),
|
|
57
|
-
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this)
|
|
85
|
+
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this),
|
|
86
|
+
[GenerateDidDocMethodName]: this.GenerateDidDoc.bind(this),
|
|
87
|
+
[GenerateKeyPairMethodName]: this.GenerateIdentityKeys.bind(this)
|
|
58
88
|
};
|
|
59
89
|
}
|
|
60
90
|
async CreateIdentifier(args, context) {
|
|
@@ -103,6 +133,45 @@ class Cheqd {
|
|
|
103
133
|
}
|
|
104
134
|
});
|
|
105
135
|
}
|
|
136
|
+
async GenerateDidDoc(args,
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
138
|
+
context) {
|
|
139
|
+
if (typeof args.verificationMethod !== 'string') {
|
|
140
|
+
throw new Error('[cheqd-plugin]: verificationMethod is required');
|
|
141
|
+
}
|
|
142
|
+
if (typeof args.methodSpecificIdAlgo !== 'string') {
|
|
143
|
+
throw new Error('[cheqd-plugin]: methodSpecificIdAlgo is required');
|
|
144
|
+
}
|
|
145
|
+
if (typeof args.methodSpecificIdLength !== 'number') {
|
|
146
|
+
throw new Error('[cheqd-plugin]: methodSpecificIdLength is required');
|
|
147
|
+
}
|
|
148
|
+
if (typeof args.network !== 'string') {
|
|
149
|
+
throw new Error('[cheqd-plugin]: network is required');
|
|
150
|
+
}
|
|
151
|
+
const keyPair = (0, utils_1.createKeyPairBase64)();
|
|
152
|
+
const keyPairHex = { publicKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.publicKey, 'base64'), 'hex'), privateKey: (0, uint8arrays_1.toString)((0, uint8arrays_1.fromString)(keyPair.privateKey, 'base64'), 'hex') };
|
|
153
|
+
const verificationKeys = (0, utils_1.createVerificationKeys)(keyPair, args.methodSpecificIdAlgo, 'key-1', args.methodSpecificIdLength, args.network);
|
|
154
|
+
const verificationMethods = (0, utils_1.createDidVerificationMethod)([args.verificationMethod], [verificationKeys]);
|
|
155
|
+
return {
|
|
156
|
+
didDoc: (0, utils_1.createDidPayload)(verificationMethods, [verificationKeys]),
|
|
157
|
+
keys: {
|
|
158
|
+
publicKeyHex: keyPairHex.publicKey,
|
|
159
|
+
privateKeyHex: keyPairHex.privateKey,
|
|
160
|
+
kid: keyPairHex.publicKey,
|
|
161
|
+
type: 'Ed25519'
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
166
|
+
async GenerateIdentityKeys(args, context) {
|
|
167
|
+
const keyPair = (0, utils_1.createKeyPairHex)();
|
|
168
|
+
return {
|
|
169
|
+
publicKeyHex: keyPair.publicKey,
|
|
170
|
+
privateKeyHex: keyPair.privateKey,
|
|
171
|
+
kid: keyPair.publicKey,
|
|
172
|
+
type: 'Ed25519'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
106
175
|
}
|
|
107
176
|
exports.Cheqd = Cheqd;
|
|
108
177
|
//# sourceMappingURL=ICheqd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICheqd.js","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ICheqd.js","sourceRoot":"","sources":["../../src/agent/ICheqd.ts"],"names":[],"mappings":";;;AACA,gDAAmJ;AAUnJ,6CAAkD;AAKlD,MAAM,0BAA0B,GAAG,uBAAuB,CAAA;AAC1D,MAAM,0BAA0B,GAAG,uBAAuB,CAAA;AAC1D,MAAM,wBAAwB,GAAG,qBAAqB,CAAA;AACtD,MAAM,yBAAyB,GAAG,2BAA2B,CAAA;AAS7D,MAAa,KAAK;IAuEd,YAAY,IAA0B;QArE7B,WAAM,GAAwB;YACnC,YAAY,EAAE;gBACV,SAAS,EAAE,EAAE;gBACb,SAAS,EAAE;oBACP,uBAAuB,EAAE;wBACrB,aAAa,EAAE,yBAAyB;wBACxC,WAAW,EAAE;4BACT,MAAM,EAAE,QAAQ;4BAChB,YAAY,EAAE;gCACV,MAAM,EAAE;oCACJ,MAAM,EAAE,QAAQ;oCAChB,aAAa,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,SAAS,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,wBAAU,EAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;QAC3K,MAAM,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACvI,MAAM,mBAAmB,GAAG,IAAA,mCAA2B,EAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAEtG,OAAO;YACH,MAAM,EAAE,IAAA,wBAAgB,EAAC,mBAAmB,EAAE,CAAC,gBAAgB,CAAC,CAAC;YACjE,IAAI,EAAE;gBACF,YAAY,EAAE,UAAU,CAAC,SAAS;gBAClC,aAAa,EAAE,UAAU,CAAC,UAAU;gBACpC,GAAG,EAAE,UAAU,CAAC,SAAS;gBACzB,IAAI,EAAE,SAAS;aAClB;SACJ,CAAA;IACL,CAAC;IAED,6DAA6D;IACrD,KAAK,CAAC,oBAAoB,CAAC,IAAS,EAAE,OAAiB;QAC3D,MAAM,OAAO,GAAG,IAAA,wBAAgB,GAAE,CAAA;QAClC,OAAO;YACH,YAAY,EAAE,OAAO,CAAC,SAAS;YAC/B,aAAa,EAAE,OAAO,CAAC,UAAU;YACjC,GAAG,EAAE,OAAO,CAAC,SAAS;YACtB,IAAI,EAAE,SAAS;SAClB,CAAA;IACL,CAAC;CACJ;AA7LD,sBA6LC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MsgCreateDidPayload, MsgUpdateDidPayload } from '@cheqd/ts-proto/cheqd/v1/tx';
|
|
2
|
-
import {
|
|
2
|
+
import { DIDDocument } from '@veramo/core/src';
|
|
3
|
+
import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core';
|
|
3
4
|
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
4
5
|
declare type IContext = IAgentContext<IKeyManager>;
|
|
5
6
|
export declare enum DefaultRPCUrl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cheqd-did-provider.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtF,OAAO,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,WAAW,EAGX,
|
|
1
|
+
{"version":3,"file":"cheqd-did-provider.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,WAAW,EAGX,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,SAAS,CAAA;CAAE,CAAA;AAE5J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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheqd/did-provider-cheqd",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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,8 +45,9 @@
|
|
|
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
|
-
"@
|
|
49
|
-
"@typescript-eslint/
|
|
48
|
+
"@types/uuid": "^8.3.4",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
50
|
+
"@typescript-eslint/parser": "^5.33.0",
|
|
50
51
|
"@veramo/cli": "^3.1.5",
|
|
51
52
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
52
53
|
"eslint": "^8.21.0",
|
|
@@ -67,17 +68,18 @@
|
|
|
67
68
|
"tsconfig.json"
|
|
68
69
|
],
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@cheqd/sdk": "^1.2.
|
|
71
|
+
"@cheqd/sdk": "^1.2.7",
|
|
71
72
|
"@cheqd/ts-proto": "^1.0.11",
|
|
72
73
|
"@cosmjs/proto-signing": "^0.28.11",
|
|
73
74
|
"@cosmjs/utils": "^0.28.11",
|
|
74
|
-
"@veramo/core": "^3.1.6-next.
|
|
75
|
-
"@veramo/did-manager": "^3.1.6-next.
|
|
75
|
+
"@veramo/core": "^3.1.6-next.160",
|
|
76
|
+
"@veramo/did-manager": "^3.1.6-next.160",
|
|
76
77
|
"@veramo/did-provider-key": "^3.1.3",
|
|
77
|
-
"@veramo/key-manager": "^3.1.6-next.
|
|
78
|
+
"@veramo/key-manager": "^3.1.6-next.160",
|
|
78
79
|
"debug": "^4.3.4",
|
|
79
80
|
"multibase": "^4.0.6",
|
|
80
|
-
"multicodec": "^3.2.1"
|
|
81
|
+
"multicodec": "^3.2.1",
|
|
82
|
+
"uint8arrays": "^3.1.0"
|
|
81
83
|
},
|
|
82
84
|
"publishConfig": {
|
|
83
85
|
"registry": "https://registry.npmjs.org/",
|
package/src/agent/ICheqd.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CheqdNetwork, IKeyPair, MethodSpecificIdAlgo, VerificationMethods } from '@cheqd/sdk/build/types'
|
|
2
|
+
import { createDidPayload, createDidVerificationMethod, createKeyPairBase64, createKeyPairHex, createVerificationKeys } from '@cheqd/sdk/src/utils'
|
|
1
3
|
import {
|
|
2
4
|
IAgentContext,
|
|
3
5
|
IKeyManager,
|
|
@@ -6,15 +8,22 @@ import {
|
|
|
6
8
|
IAgentPluginSchema,
|
|
7
9
|
IIdentifier
|
|
8
10
|
} from '@veramo/core'
|
|
11
|
+
import { IdentifierPayload, TImportableEd25519Key } from '../did-manager/cheqd-did-provider'
|
|
12
|
+
import { fromString, toString } from 'uint8arrays'
|
|
9
13
|
|
|
10
14
|
type IContext = IAgentContext<IKeyManager>
|
|
15
|
+
type TExportedDIDDocWithKeys = { didDoc: IdentifierPayload, keys: TImportableEd25519Key }
|
|
11
16
|
|
|
12
17
|
const CreateIdentifierMethodName = 'cheqdCreateIdentifier'
|
|
13
18
|
const UpdateIdentifierMethodName = 'cheqdUpdateIdentifier'
|
|
19
|
+
const GenerateDidDocMethodName = 'cheqdGenerateDidDoc'
|
|
20
|
+
const GenerateKeyPairMethodName = 'cheqdGenerateIdentityKeys'
|
|
14
21
|
|
|
15
22
|
export interface ICheqd extends IPluginMethodMap {
|
|
16
23
|
[CreateIdentifierMethodName]: (args: any, context: IContext) => Promise<Omit<IIdentifier, 'provider'>>
|
|
17
|
-
[UpdateIdentifierMethodName]: (args: any, context: IContext) => Promise<void
|
|
24
|
+
[UpdateIdentifierMethodName]: (args: any, context: IContext) => Promise<void>,
|
|
25
|
+
[GenerateDidDocMethodName]: (args: any, context: IContext) => Promise<TExportedDIDDocWithKeys>,
|
|
26
|
+
[GenerateKeyPairMethodName]: (args: any, context: IContext) => Promise<TImportableEd25519Key>
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
export class Cheqd implements IAgentPlugin {
|
|
@@ -58,6 +67,30 @@ export class Cheqd implements IAgentPlugin {
|
|
|
58
67
|
"returnType": {
|
|
59
68
|
"type": "object"
|
|
60
69
|
}
|
|
70
|
+
},
|
|
71
|
+
'cheqdGenerateDidDoc': {
|
|
72
|
+
'description': 'Generate a new DID document to use with `createIdentifier`',
|
|
73
|
+
'arguments': {
|
|
74
|
+
'type': 'object',
|
|
75
|
+
'properties': {
|
|
76
|
+
'args': {
|
|
77
|
+
'type': 'object',
|
|
78
|
+
'description': 'A cheqdGenerateDidDocArgs object as any for extensibility'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
'cheqdGenerateKeyPair': {
|
|
84
|
+
'description': 'Generate a new key pair in hex to use with `createIdentifier`',
|
|
85
|
+
'arguments': {
|
|
86
|
+
'type': 'object',
|
|
87
|
+
'properties': {
|
|
88
|
+
'args': {
|
|
89
|
+
'type': 'object',
|
|
90
|
+
'description': 'A cheqdGenerateKeyPairArgs object as any for extensibility'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
61
94
|
}
|
|
62
95
|
}
|
|
63
96
|
}
|
|
@@ -73,7 +106,9 @@ export class Cheqd implements IAgentPlugin {
|
|
|
73
106
|
|
|
74
107
|
this.methods = {
|
|
75
108
|
[CreateIdentifierMethodName]: this.CreateIdentifier.bind(this),
|
|
76
|
-
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this)
|
|
109
|
+
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this),
|
|
110
|
+
[GenerateDidDocMethodName]: this.GenerateDidDoc.bind(this),
|
|
111
|
+
[GenerateKeyPairMethodName]: this.GenerateIdentityKeys.bind(this)
|
|
77
112
|
}
|
|
78
113
|
}
|
|
79
114
|
|
|
@@ -132,4 +167,52 @@ export class Cheqd implements IAgentPlugin {
|
|
|
132
167
|
}
|
|
133
168
|
})
|
|
134
169
|
}
|
|
170
|
+
|
|
171
|
+
private async GenerateDidDoc(
|
|
172
|
+
args: { verificationMethod: VerificationMethods, methodSpecificIdAlgo: MethodSpecificIdAlgo, methodSpecificIdLength: 16 | 32, network: CheqdNetwork },
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
174
|
+
context: IContext
|
|
175
|
+
): Promise<TExportedDIDDocWithKeys> {
|
|
176
|
+
if (typeof args.verificationMethod !== 'string') {
|
|
177
|
+
throw new Error('[cheqd-plugin]: verificationMethod is required')
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (typeof args.methodSpecificIdAlgo !== 'string') {
|
|
181
|
+
throw new Error('[cheqd-plugin]: methodSpecificIdAlgo is required')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (typeof args.methodSpecificIdLength !== 'number') {
|
|
185
|
+
throw new Error('[cheqd-plugin]: methodSpecificIdLength is required')
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (typeof args.network !== 'string') {
|
|
189
|
+
throw new Error('[cheqd-plugin]: network is required')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const keyPair = createKeyPairBase64()
|
|
193
|
+
const keyPairHex: IKeyPair = { publicKey: toString(fromString(keyPair.publicKey, 'base64'), 'hex'), privateKey: toString(fromString(keyPair.privateKey, 'base64'), 'hex') }
|
|
194
|
+
const verificationKeys = createVerificationKeys(keyPair, args.methodSpecificIdAlgo, 'key-1', args.methodSpecificIdLength, args.network)
|
|
195
|
+
const verificationMethods = createDidVerificationMethod([args.verificationMethod], [verificationKeys])
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
didDoc: createDidPayload(verificationMethods, [verificationKeys]),
|
|
199
|
+
keys: {
|
|
200
|
+
publicKeyHex: keyPairHex.publicKey,
|
|
201
|
+
privateKeyHex: keyPairHex.privateKey,
|
|
202
|
+
kid: keyPairHex.publicKey,
|
|
203
|
+
type: 'Ed25519'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
209
|
+
private async GenerateIdentityKeys(args: any, context: IContext): Promise<TImportableEd25519Key> {
|
|
210
|
+
const keyPair = createKeyPairHex()
|
|
211
|
+
return {
|
|
212
|
+
publicKeyHex: keyPair.publicKey,
|
|
213
|
+
privateKeyHex: keyPair.privateKey,
|
|
214
|
+
kid: keyPair.publicKey,
|
|
215
|
+
type: 'Ed25519'
|
|
216
|
+
}
|
|
217
|
+
}
|
|
135
218
|
}
|
|
@@ -5,6 +5,7 @@ import { Service, VerificationMethod } from '@cheqd/ts-proto/cheqd/v1/did'
|
|
|
5
5
|
import { MsgCreateDidPayload, MsgUpdateDidPayload } from '@cheqd/ts-proto/cheqd/v1/tx'
|
|
6
6
|
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'
|
|
7
7
|
import { assert } from '@cosmjs/utils'
|
|
8
|
+
import { DIDDocument } from '@veramo/core/src'
|
|
8
9
|
import {
|
|
9
10
|
IIdentifier,
|
|
10
11
|
IKey,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
IKeyManager,
|
|
14
15
|
ManagedKeyInfo,
|
|
15
16
|
MinimalImportableKey,
|
|
16
|
-
DIDDocument,
|
|
17
17
|
} from '@veramo/core'
|
|
18
18
|
import { AbstractIdentifierProvider } from '@veramo/did-manager'
|
|
19
19
|
import Debug from 'debug'
|