@cheqd/did-provider-cheqd 1.1.1 → 1.2.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/build/agent/cheqd.d.ts +11 -0
- package/build/agent/cheqd.d.ts.map +1 -0
- package/build/agent/cheqd.js +80 -0
- package/build/agent/cheqd.js.map +1 -0
- package/build/did-manager/cheqd-did-provider.d.ts +9 -2
- package/build/did-manager/cheqd-did-provider.d.ts.map +1 -1
- package/build/did-manager/cheqd-did-provider.js +14 -1
- package/build/did-manager/cheqd-did-provider.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/package.json +4 -4
- package/src/agent/cheqd.ts +90 -0
- package/src/did-manager/cheqd-did-provider.ts +32 -4
- package/src/index.ts +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IAgentPlugin, IPluginMethodMap, IAgentPluginSchema } from '@veramo/core';
|
|
2
|
+
import { CheqdDIDProvider } from '../did-manager/cheqd-did-provider';
|
|
3
|
+
export declare class Cheqd implements IAgentPlugin {
|
|
4
|
+
readonly methods?: IPluginMethodMap;
|
|
5
|
+
readonly schema?: IAgentPluginSchema;
|
|
6
|
+
readonly didProvider: CheqdDIDProvider;
|
|
7
|
+
constructor(provider: CheqdDIDProvider);
|
|
8
|
+
private CreateIdentifier;
|
|
9
|
+
private UpdateIdentifier;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=cheqd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheqd.d.ts","sourceRoot":"","sources":["../../src/agent/cheqd.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAErB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAOpE,qBAAa,KAAM,YAAW,YAAY;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAA;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAErC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAE3B,QAAQ,EAAE,gBAAgB;YA4BxB,gBAAgB;YAsBhB,gBAAgB;CAkBjC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Cheqd = void 0;
|
|
13
|
+
const CreateIdentifierMethodName = 'cheqdCreateIdentifier';
|
|
14
|
+
const UpdateIdentifierMethodName = 'cheqdUpdateIdentifier';
|
|
15
|
+
class Cheqd {
|
|
16
|
+
constructor(provider) {
|
|
17
|
+
this.didProvider = provider;
|
|
18
|
+
this.methods = {
|
|
19
|
+
[CreateIdentifierMethodName]: this.CreateIdentifier.bind(this),
|
|
20
|
+
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this)
|
|
21
|
+
};
|
|
22
|
+
// z-schema rules
|
|
23
|
+
// https://github.com/zaggino/z-schema
|
|
24
|
+
this.schema = {
|
|
25
|
+
components: {
|
|
26
|
+
schemas: {},
|
|
27
|
+
methods: {
|
|
28
|
+
[CreateIdentifierMethodName]: {
|
|
29
|
+
arguments: {},
|
|
30
|
+
// This property is required
|
|
31
|
+
returnType: {}
|
|
32
|
+
},
|
|
33
|
+
[UpdateIdentifierMethodName]: {
|
|
34
|
+
arguments: {},
|
|
35
|
+
returnType: {}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
CreateIdentifier(args, context) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (typeof args.kms !== 'string') {
|
|
44
|
+
throw new Error('[cheqd-plugin]: kms is required');
|
|
45
|
+
}
|
|
46
|
+
if (typeof args.alias !== 'string') {
|
|
47
|
+
throw new Error('[cheqd-plugin]: alias is required');
|
|
48
|
+
}
|
|
49
|
+
if (typeof args.document !== 'object') {
|
|
50
|
+
throw new Error('[cheqd-plugin]: document object is required');
|
|
51
|
+
}
|
|
52
|
+
return yield this.didProvider.createIdentifier({
|
|
53
|
+
kms: args.kms,
|
|
54
|
+
alias: args.alias,
|
|
55
|
+
options: {
|
|
56
|
+
document: args.document
|
|
57
|
+
}
|
|
58
|
+
}, context);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
UpdateIdentifier(args, context) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (typeof args.kms !== 'string') {
|
|
64
|
+
throw new Error('[cheqd-plugin]: kms is required');
|
|
65
|
+
}
|
|
66
|
+
if (typeof args.did !== 'string') {
|
|
67
|
+
throw new Error('[cheqd-plugin]: did is required');
|
|
68
|
+
}
|
|
69
|
+
if (typeof args.document !== 'object') {
|
|
70
|
+
throw new Error('[cheqd-plugin]: document object is required');
|
|
71
|
+
}
|
|
72
|
+
return yield this.didProvider.updateIdentifier({
|
|
73
|
+
did: args.did,
|
|
74
|
+
document: args.document,
|
|
75
|
+
}, context);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.Cheqd = Cheqd;
|
|
80
|
+
//# sourceMappingURL=cheqd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,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBAC3C,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,OAAO,EAAE;oBACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBAC1B;aACJ,EAAE,OAAO,CAAC,CAAA;QACf,CAAC;KAAA;IAEa,gBAAgB,CAAC,IAAS,EAAE,OAAiB;;YACvD,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE;gBAC9B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;aACrD;YAED,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE;gBAC9B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;aACrD;YAED,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACnC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aACjE;YAED,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBAC3C,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;aAC1B,EAAE,OAAO,CAAC,CAAA;QACf,CAAC;KAAA;CACJ;AA1ED,sBA0EC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core';
|
|
1
|
+
import { IIdentifier, IKey, IService, IAgentContext, IKeyManager, DIDDocument } from '@veramo/core';
|
|
2
2
|
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
3
3
|
declare type IContext = IAgentContext<IKeyManager>;
|
|
4
4
|
export declare enum DefaultRPCUrl {
|
|
@@ -31,10 +31,17 @@ export declare class CheqdDIDProvider extends AbstractIdentifierProvider {
|
|
|
31
31
|
rpcUrl?: string;
|
|
32
32
|
networkType?: NetworkType;
|
|
33
33
|
});
|
|
34
|
-
createIdentifier({ kms, alias }: {
|
|
34
|
+
createIdentifier({ kms, alias, options }: {
|
|
35
35
|
kms?: string;
|
|
36
36
|
alias?: string;
|
|
37
|
+
options?: {
|
|
38
|
+
document?: DIDDocument;
|
|
39
|
+
};
|
|
37
40
|
}, context: IContext): Promise<Omit<IIdentifier, 'provider'>>;
|
|
41
|
+
updateIdentifier({ did, document }: {
|
|
42
|
+
did: string;
|
|
43
|
+
document: Partial<DIDDocument>;
|
|
44
|
+
}, context: IContext): Promise<void>;
|
|
38
45
|
deleteIdentifier(identity: IIdentifier, context: IContext): Promise<boolean>;
|
|
39
46
|
addKey({ identifier, key, options, }: {
|
|
40
47
|
identifier: IIdentifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cheqd-did-provider.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,WAAW,EAEX,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAIhE,aAAK,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;AAE1C,oBAAY,aAAa;
|
|
1
|
+
{"version":3,"file":"cheqd-did-provider.d.ts","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,WAAW,EAEX,WAAW,EACX,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAIhE,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;;;;;;;;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;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"}
|
|
@@ -48,8 +48,13 @@ class CheqdDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
48
48
|
}
|
|
49
49
|
createIdentifier(
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
-
{ kms, alias }, context) {
|
|
51
|
+
{ kms, alias, options }, context) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (!(options === null || options === void 0 ? void 0 : options.document)) {
|
|
54
|
+
throw Error('[did-provider] cheqd: document is required');
|
|
55
|
+
}
|
|
56
|
+
console.log("document recieved: " + JSON.stringify(options.document, null, 2));
|
|
57
|
+
// TODO: Handle did creation
|
|
53
58
|
const key = yield context.agent.keyManagerCreate({
|
|
54
59
|
kms: kms || this.defaultKms,
|
|
55
60
|
type: 'Ed25519',
|
|
@@ -68,6 +73,14 @@ class CheqdDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
68
73
|
return identifier;
|
|
69
74
|
});
|
|
70
75
|
}
|
|
76
|
+
updateIdentifier(
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
{ did, document }, context) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
console.log("document recieved: " + JSON.stringify(document, null, 2));
|
|
81
|
+
// TODO: Handle did update
|
|
82
|
+
});
|
|
83
|
+
}
|
|
71
84
|
deleteIdentifier(identity, context) {
|
|
72
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
86
|
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":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cheqd-did-provider.js","sourceRoot":"","sources":["../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,qDAAgE;AAChE,0DAAiC;AACjC,4DAAmC;AAInC,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,QAGtB;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,gBAAiB,SAAQ,wCAA0B;IAK/D,YAAY,OAA2E;QACtF,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAA;QAC9E,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAA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AAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;YAEtE,0BAA0B;QAC3B,CAAC;KAAA;IAEK,gBAAgB,CACrB,QAAqB,EACrB,OAAiB;;YAEjB,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE;gBACpC,MAAM,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;aAC7C;YACD,OAAO,IAAI,CAAA;QACZ,CAAC;KAAA;IAEK,MAAM,CACX;IACC,8DAA8D;IAC9D,UAAU;IACV,8DAA8D;IAC9D,GAAG;IACH,8DAA8D;IAC9D,OAAO;IACP,+DAA+D;MACR;IACxD,8DAA8D;IAC9D,OAAiB;;YAGjB,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAA;QAC1D,CAAC;KAAA;IAEK,UAAU,CACf;IACC,8DAA8D;IAC9D,UAAU;IACV,8DAA8D;IAC9D,OAAO;IACP,8DAA8D;IAC9D,OAAO;IACP,+DAA+D;MACA;IAChE,8DAA8D;IAC9D,OAAiB;;YAGjB,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC9D,CAAC;KAAA;IAEK,SAAS;IACd,8DAA8D;IAC9D,IAKC;IACD,8DAA8D;IAC9D,OAAiB;;YAGjB,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAC7D,CAAC;KAAA;IAEK,aAAa;IAClB,8DAA8D;IAC9D,IAKC;IACD,8DAA8D;IAC9D,OAAiB;;YAGjB,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAA;QACjE,CAAC;KAAA;CACD;AAlJD,4CAkJC"}
|
package/build/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { schema };
|
|
|
6
6
|
export { CheqdDIDProvider } from './did-manager/cheqd-did-provider';
|
|
7
7
|
export { CheqdDidResolver, getResolver } from './did-manager/cheqd-did-resolver';
|
|
8
8
|
export { CheqdResolver } from './did-manager/resolver';
|
|
9
|
+
export { Cheqd } from './agent/cheqd';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CheqdResolver = exports.getResolver = exports.CheqdDidResolver = exports.CheqdDIDProvider = exports.schema = void 0;
|
|
3
|
+
exports.Cheqd = exports.CheqdResolver = exports.getResolver = exports.CheqdDidResolver = exports.CheqdDIDProvider = exports.schema = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
@@ -15,4 +15,6 @@ Object.defineProperty(exports, "CheqdDidResolver", { enumerable: true, get: func
|
|
|
15
15
|
Object.defineProperty(exports, "getResolver", { enumerable: true, get: function () { return cheqd_did_resolver_1.getResolver; } });
|
|
16
16
|
var resolver_1 = require("./did-manager/resolver");
|
|
17
17
|
Object.defineProperty(exports, "CheqdResolver", { enumerable: true, get: function () { return resolver_1.CheqdResolver; } });
|
|
18
|
+
var cheqd_1 = require("./agent/cheqd");
|
|
19
|
+
Object.defineProperty(exports, "Cheqd", { enumerable: true, get: function () { return cheqd_1.Cheqd; } });
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAAyD;AACzD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,uEAAmE;AAA1D,sHAAA,gBAAgB,OAAA;AACzB,uEAAgF;AAAvE,sHAAA,gBAAgB,OAAA;AAAE,iHAAA,WAAW,OAAA;AACtC,mDAAsD;AAA7C,yGAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAAyD;AACzD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,uEAAmE;AAA1D,sHAAA,gBAAgB,OAAA;AACzB,uEAAgF;AAAvE,sHAAA,gBAAgB,OAAA;AAAE,iHAAA,WAAW,OAAA;AACtC,mDAAsD;AAA7C,yGAAA,aAAa,OAAA;AACtB,uCAAqC;AAA5B,8FAAA,KAAK,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheqd/did-provider-cheqd",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"types": "build/index.d.ts",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"@typescript-eslint/parser": "^5.31.0",
|
|
49
49
|
"@veramo/cli": "^3.1.5",
|
|
50
50
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
51
|
-
"eslint": "^
|
|
51
|
+
"eslint": "^8.20.0",
|
|
52
52
|
"eslint-config-prettier": "^8.5.0",
|
|
53
53
|
"eslint-config-typescript": "^3.0.0",
|
|
54
54
|
"jest": "27.5.1",
|
|
55
55
|
"prettier": "^2.7.1",
|
|
56
56
|
"semantic-release": "^19.0.3",
|
|
57
57
|
"ts-jest": "27.1.5",
|
|
58
|
-
"typescript": "4.7.
|
|
58
|
+
"typescript": "4.7.4"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"build/**/*",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IAgentContext,
|
|
3
|
+
IKeyManager,
|
|
4
|
+
IAgentPlugin,
|
|
5
|
+
IPluginMethodMap,
|
|
6
|
+
IAgentPluginSchema,
|
|
7
|
+
IIdentifier
|
|
8
|
+
} from '@veramo/core'
|
|
9
|
+
import { CheqdDIDProvider } from '../did-manager/cheqd-did-provider'
|
|
10
|
+
|
|
11
|
+
type IContext = IAgentContext<IKeyManager>
|
|
12
|
+
|
|
13
|
+
const CreateIdentifierMethodName = 'cheqdCreateIdentifier'
|
|
14
|
+
const UpdateIdentifierMethodName = 'cheqdUpdateIdentifier'
|
|
15
|
+
|
|
16
|
+
export class Cheqd implements IAgentPlugin {
|
|
17
|
+
readonly methods?: IPluginMethodMap
|
|
18
|
+
readonly schema?: IAgentPluginSchema;
|
|
19
|
+
|
|
20
|
+
readonly didProvider: CheqdDIDProvider;
|
|
21
|
+
|
|
22
|
+
constructor(provider: CheqdDIDProvider) {
|
|
23
|
+
this.didProvider = provider
|
|
24
|
+
|
|
25
|
+
this.methods = {
|
|
26
|
+
[CreateIdentifierMethodName]: this.CreateIdentifier.bind(this),
|
|
27
|
+
[UpdateIdentifierMethodName]: this.UpdateIdentifier.bind(this)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// z-schema rules
|
|
31
|
+
// https://github.com/zaggino/z-schema
|
|
32
|
+
this.schema = {
|
|
33
|
+
components: {
|
|
34
|
+
schemas: {},
|
|
35
|
+
methods: {
|
|
36
|
+
[CreateIdentifierMethodName]: {
|
|
37
|
+
arguments: {},
|
|
38
|
+
// This property is required
|
|
39
|
+
returnType: {}
|
|
40
|
+
},
|
|
41
|
+
[UpdateIdentifierMethodName]: {
|
|
42
|
+
arguments: {},
|
|
43
|
+
returnType: {}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private async CreateIdentifier(args: any, context: IContext): Promise<Omit<IIdentifier, 'provider'>> {
|
|
51
|
+
if (typeof args.kms !== 'string') {
|
|
52
|
+
throw new Error('[cheqd-plugin]: kms is required')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (typeof args.alias !== 'string') {
|
|
56
|
+
throw new Error('[cheqd-plugin]: alias is required')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof args.document !== 'object') {
|
|
60
|
+
throw new Error('[cheqd-plugin]: document object is required')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return await this.didProvider.createIdentifier({
|
|
64
|
+
kms: args.kms,
|
|
65
|
+
alias: args.alias,
|
|
66
|
+
options: {
|
|
67
|
+
document: args.document
|
|
68
|
+
}
|
|
69
|
+
}, context)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private async UpdateIdentifier(args: any, context: IContext) {
|
|
73
|
+
if (typeof args.kms !== 'string') {
|
|
74
|
+
throw new Error('[cheqd-plugin]: kms is required')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof args.did !== 'string') {
|
|
78
|
+
throw new Error('[cheqd-plugin]: did is required')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof args.document !== 'object') {
|
|
82
|
+
throw new Error('[cheqd-plugin]: document object is required')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return await this.didProvider.updateIdentifier({
|
|
86
|
+
did: args.did,
|
|
87
|
+
document: args.document,
|
|
88
|
+
}, context)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
IAgentContext,
|
|
6
6
|
IKeyManager,
|
|
7
7
|
ManagedKeyInfo,
|
|
8
|
+
DIDDocument,
|
|
8
9
|
} from '@veramo/core'
|
|
9
10
|
import { AbstractIdentifierProvider } from '@veramo/did-manager'
|
|
10
11
|
import Multibase from 'multibase'
|
|
@@ -13,8 +14,8 @@ import Multicodec from 'multicodec'
|
|
|
13
14
|
type IContext = IAgentContext<IKeyManager>
|
|
14
15
|
|
|
15
16
|
export enum DefaultRPCUrl {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
Mainnet = 'https://rpc.cheqd.net',
|
|
18
|
+
Testnet = 'https://rpc.cheqd.network'
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export enum NetworkType {
|
|
@@ -44,14 +45,28 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
|
|
|
44
45
|
super()
|
|
45
46
|
this.defaultKms = options.defaultKms
|
|
46
47
|
this.network = options.networkType ? options.networkType : NetworkType.Testnet
|
|
47
|
-
this.rpcUrl = options.rpcUrl ? options.rpcUrl : (
|
|
48
|
+
this.rpcUrl = options.rpcUrl ? options.rpcUrl : (this.network === NetworkType.Testnet ? DefaultRPCUrl.Testnet : DefaultRPCUrl.Mainnet)
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
async createIdentifier(
|
|
51
52
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
-
{ kms, alias }: {
|
|
53
|
+
{ kms, alias, options }: {
|
|
54
|
+
kms?: string;
|
|
55
|
+
alias?: string,
|
|
56
|
+
options?: {
|
|
57
|
+
document?: DIDDocument,
|
|
58
|
+
}
|
|
59
|
+
},
|
|
53
60
|
context: IContext,
|
|
54
61
|
): Promise<Omit<IIdentifier, 'provider'>> {
|
|
62
|
+
if (!options?.document) {
|
|
63
|
+
throw Error('[did-provider] cheqd: document is required')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log("document recieved: " + JSON.stringify(options.document, null, 2))
|
|
67
|
+
|
|
68
|
+
// TODO: Handle did creation
|
|
69
|
+
|
|
55
70
|
const key: ManagedKeyInfo = await context.agent.keyManagerCreate({
|
|
56
71
|
kms: kms || this.defaultKms,
|
|
57
72
|
type: 'Ed25519',
|
|
@@ -81,6 +96,19 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider {
|
|
|
81
96
|
return identifier
|
|
82
97
|
}
|
|
83
98
|
|
|
99
|
+
async updateIdentifier(
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
101
|
+
{ did, document}: {
|
|
102
|
+
did: string,
|
|
103
|
+
document: Partial<DIDDocument>
|
|
104
|
+
},
|
|
105
|
+
context: IContext,
|
|
106
|
+
) {
|
|
107
|
+
console.log("document recieved: " + JSON.stringify(document, null, 2))
|
|
108
|
+
|
|
109
|
+
// TODO: Handle did update
|
|
110
|
+
}
|
|
111
|
+
|
|
84
112
|
async deleteIdentifier(
|
|
85
113
|
identity: IIdentifier,
|
|
86
114
|
context: IContext,
|
package/src/index.ts
CHANGED