@cheqd/did-provider-cheqd 2.1.0-develop.2 → 3.0.0-develop.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/build/{agent → cjs/agent}/ICheqd.d.ts +2 -2
- package/build/cjs/agent/ICheqd.d.ts.map +1 -0
- package/build/{agent → cjs/agent}/ICheqd.js +134 -126
- package/build/cjs/agent/ICheqd.js.map +1 -0
- package/build/{did-manager → cjs/did-manager}/cheqd-did-provider.d.ts +2 -2
- package/build/cjs/did-manager/cheqd-did-provider.d.ts.map +1 -0
- package/build/{did-manager → cjs/did-manager}/cheqd-did-provider.js +7 -1
- package/build/cjs/did-manager/cheqd-did-provider.js.map +1 -0
- package/build/{did-manager → cjs/did-manager}/cheqd-did-resolver.d.ts +0 -0
- package/build/cjs/did-manager/cheqd-did-resolver.d.ts.map +1 -0
- package/build/{did-manager → cjs/did-manager}/cheqd-did-resolver.js +1 -1
- package/build/cjs/did-manager/cheqd-did-resolver.js.map +1 -0
- package/build/{did-manager → cjs/did-manager}/resolver.d.ts +0 -0
- package/build/cjs/did-manager/resolver.d.ts.map +1 -0
- package/build/{did-manager → cjs/did-manager}/resolver.js +0 -0
- package/build/cjs/did-manager/resolver.js.map +1 -0
- package/build/cjs/index.d.ts +8 -0
- package/build/cjs/index.d.ts.map +1 -0
- package/build/cjs/index.js +16 -0
- package/build/cjs/index.js.map +1 -0
- package/build/esm/agent/ICheqd.d.ts +53 -0
- package/build/esm/agent/ICheqd.d.ts.map +1 -0
- package/build/esm/agent/ICheqd.js +397 -0
- package/build/esm/agent/ICheqd.js.map +1 -0
- package/build/esm/did-manager/cheqd-did-provider.d.ts +105 -0
- package/build/esm/did-manager/cheqd-did-provider.d.ts.map +1 -0
- package/build/esm/did-manager/cheqd-did-provider.js +202 -0
- package/build/esm/did-manager/cheqd-did-provider.js.map +1 -0
- package/build/esm/did-manager/cheqd-did-resolver.d.ts +21 -0
- package/build/esm/did-manager/cheqd-did-resolver.d.ts.map +1 -0
- package/build/esm/did-manager/cheqd-did-resolver.js +42 -0
- package/build/esm/did-manager/cheqd-did-resolver.js.map +1 -0
- package/build/esm/did-manager/resolver.d.ts +47 -0
- package/build/esm/did-manager/resolver.d.ts.map +1 -0
- package/build/esm/did-manager/resolver.js +69 -0
- package/build/esm/did-manager/resolver.js.map +1 -0
- package/build/esm/index.d.ts +8 -0
- package/build/esm/index.d.ts.map +1 -0
- package/build/esm/index.js +8 -0
- package/build/esm/index.js.map +1 -0
- package/build/tsconfig.cjs.tsbuildinfo +1 -0
- package/build/tsconfig.esm.tsbuildinfo +1 -0
- package/build/tsconfig.types.tsbuildinfo +1 -0
- package/build/types/agent/ICheqd.d.ts +53 -0
- package/build/types/agent/ICheqd.d.ts.map +1 -0
- package/build/types/did-manager/cheqd-did-provider.d.ts +105 -0
- package/build/types/did-manager/cheqd-did-provider.d.ts.map +1 -0
- package/build/types/did-manager/cheqd-did-resolver.d.ts +21 -0
- package/build/types/did-manager/cheqd-did-resolver.d.ts.map +1 -0
- package/build/types/did-manager/resolver.d.ts +47 -0
- package/build/types/did-manager/resolver.d.ts.map +1 -0
- package/build/types/index.d.ts +8 -0
- package/build/types/index.d.ts.map +1 -0
- package/package.json +47 -31
- package/src/agent/ICheqd.ts +11 -6
- package/src/did-manager/cheqd-did-provider.ts +26 -7
- package/src/index.ts +4 -5
- package/tsconfig.json +0 -3
- package/build/agent/ICheqd.d.ts.map +0 -1
- package/build/agent/ICheqd.js.map +0 -1
- package/build/did-manager/cheqd-did-provider.d.ts.map +0 -1
- package/build/did-manager/cheqd-did-provider.js.map +0 -1
- package/build/did-manager/cheqd-did-resolver.d.ts.map +0 -1
- package/build/did-manager/cheqd-did-resolver.js.map +0 -1
- package/build/did-manager/resolver.d.ts.map +0 -1
- package/build/did-manager/resolver.js.map +0 -1
- package/build/index.d.ts +0 -8
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -16
- package/build/index.js.map +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
// any is used for extensibility
|
|
3
|
+
// unused vars are kept by convention
|
|
4
|
+
// non-null assertion is used when we know better than the compiler that the value is not null or undefined
|
|
5
|
+
import { createCheqdSDK, createSignInputsFromImportableEd25519Key, DIDModule, ResourceModule } from '@cheqd/sdk';
|
|
6
|
+
import { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
|
|
7
|
+
import { assert } from '@cosmjs/utils';
|
|
8
|
+
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
9
|
+
import Debug from 'debug';
|
|
10
|
+
import { EnglishMnemonic as _, Ed25519 } from '@cosmjs/crypto';
|
|
11
|
+
import { fromString, toString } from 'uint8arrays';
|
|
12
|
+
const debug = Debug('veramo:did-provider-cheqd');
|
|
13
|
+
export var DefaultRPCUrl;
|
|
14
|
+
(function (DefaultRPCUrl) {
|
|
15
|
+
DefaultRPCUrl["Mainnet"] = "https://rpc.cheqd.net";
|
|
16
|
+
DefaultRPCUrl["Testnet"] = "https://rpc.cheqd.network";
|
|
17
|
+
})(DefaultRPCUrl || (DefaultRPCUrl = {}));
|
|
18
|
+
export var NetworkType;
|
|
19
|
+
(function (NetworkType) {
|
|
20
|
+
NetworkType["Mainnet"] = "mainnet";
|
|
21
|
+
NetworkType["Testnet"] = "testnet";
|
|
22
|
+
})(NetworkType || (NetworkType = {}));
|
|
23
|
+
export class EnglishMnemonic extends _ {
|
|
24
|
+
static _mnemonicMatcher = /^[a-z]+( [a-z]+)*$/;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* {@link @veramo/did-manager#DIDManager} identifier provider for `did:cheqd` identifiers.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export class CheqdDIDProvider extends AbstractIdentifierProvider {
|
|
31
|
+
defaultKms;
|
|
32
|
+
network;
|
|
33
|
+
rpcUrl;
|
|
34
|
+
cosmosPayerWallet;
|
|
35
|
+
sdk;
|
|
36
|
+
fee;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super();
|
|
39
|
+
this.defaultKms = options.defaultKms;
|
|
40
|
+
this.network = options.networkType ? options.networkType : NetworkType.Testnet;
|
|
41
|
+
this.rpcUrl = options.rpcUrl ? options.rpcUrl : (this.network === NetworkType.Testnet ? DefaultRPCUrl.Testnet : DefaultRPCUrl.Mainnet);
|
|
42
|
+
if (!options?.cosmosPayerSeed || options.cosmosPayerSeed === '') {
|
|
43
|
+
this.cosmosPayerWallet = DirectSecp256k1HdWallet.generate();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.cosmosPayerWallet = EnglishMnemonic._mnemonicMatcher.test(options.cosmosPayerSeed)
|
|
47
|
+
? DirectSecp256k1HdWallet.fromMnemonic(options.cosmosPayerSeed, { prefix: 'cheqd' })
|
|
48
|
+
: DirectSecp256k1Wallet.fromKey(fromString(options.cosmosPayerSeed.replace(/^0x/, ''), 'hex'), 'cheqd');
|
|
49
|
+
}
|
|
50
|
+
async getCheqdSDK(fee) {
|
|
51
|
+
if (!this.sdk) {
|
|
52
|
+
const wallet = await this.cosmosPayerWallet.catch(() => {
|
|
53
|
+
throw new Error(`[did-provider-cheqd]: network: ${this.network} valid cosmosPayerSeed is required`);
|
|
54
|
+
});
|
|
55
|
+
const sdkOptions = {
|
|
56
|
+
modules: [DIDModule, ResourceModule],
|
|
57
|
+
rpcUrl: this.rpcUrl,
|
|
58
|
+
wallet: wallet,
|
|
59
|
+
};
|
|
60
|
+
this.sdk = await createCheqdSDK(sdkOptions);
|
|
61
|
+
this.fee = fee;
|
|
62
|
+
if (this?.fee && !this?.fee?.payer) {
|
|
63
|
+
const feePayer = (await (await this.cosmosPayerWallet).getAccounts())[0].address;
|
|
64
|
+
this.fee.payer = feePayer;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return this.sdk;
|
|
68
|
+
}
|
|
69
|
+
async createIdentifier({ kms, options }, context) {
|
|
70
|
+
const sdk = await this.getCheqdSDK(options?.fee);
|
|
71
|
+
const signInputs = options.keys.map(key => createSignInputsFromImportableEd25519Key(key, options.document.verificationMethod ?? []));
|
|
72
|
+
const tx = await sdk.createDidDocTx(signInputs, options.document, '', this?.fee, undefined, options?.versionId, { sdk: sdk });
|
|
73
|
+
assert(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`);
|
|
74
|
+
//* Currently, only one controller key is supported.
|
|
75
|
+
//* We assume that the first key in the list is the controller key.
|
|
76
|
+
//* This is subject to change in the near future.
|
|
77
|
+
const keys = [];
|
|
78
|
+
for (const key of options.keys) {
|
|
79
|
+
let managedKey;
|
|
80
|
+
try {
|
|
81
|
+
managedKey = await context.agent.keyManagerImport({
|
|
82
|
+
...key,
|
|
83
|
+
kms: kms || this.defaultKms,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
debug(`Failed to import key ${key.kid}. Reason: ${e}`);
|
|
88
|
+
}
|
|
89
|
+
if (managedKey) {
|
|
90
|
+
keys.push(managedKey);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const controllerKey = { ...options.keys[0], kms: kms || this.defaultKms };
|
|
94
|
+
const identifier = {
|
|
95
|
+
did: options.document.id,
|
|
96
|
+
controllerKeyId: controllerKey.kid,
|
|
97
|
+
keys: [controllerKey, ...keys],
|
|
98
|
+
services: options.document.service || [],
|
|
99
|
+
provider: 'cheqd',
|
|
100
|
+
};
|
|
101
|
+
debug('Created DID', identifier.did);
|
|
102
|
+
return identifier;
|
|
103
|
+
}
|
|
104
|
+
async updateIdentifier({ did, document, options }, context) {
|
|
105
|
+
const sdk = await this.getCheqdSDK(options?.fee);
|
|
106
|
+
const signInputs = options.keys.map(key => createSignInputsFromImportableEd25519Key(key, document.verificationMethod ?? []));
|
|
107
|
+
const tx = await sdk.updateDidDocTx(signInputs, document, '', this?.fee, undefined, options?.versionId, { sdk: sdk });
|
|
108
|
+
assert(tx.code === 0, `cosmos_transaction: Failed to update DID. Reason: ${tx.rawLog}`);
|
|
109
|
+
//* Currently, only one controller key is supported.
|
|
110
|
+
//* We assume that the first key in the list is the controller key.
|
|
111
|
+
//* This is subject to change in the near future.
|
|
112
|
+
const keys = [];
|
|
113
|
+
for (const key of options.keys) {
|
|
114
|
+
let managedKey;
|
|
115
|
+
try {
|
|
116
|
+
managedKey = await context.agent.keyManagerImport({
|
|
117
|
+
...key,
|
|
118
|
+
kms: options.kms || this.defaultKms,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
debug(`Failed to import key ${key.kid}. Reason: ${e}`);
|
|
123
|
+
}
|
|
124
|
+
if (managedKey) {
|
|
125
|
+
keys.push(managedKey);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const controllerKey = { ...options.keys[0], kms: options.kms || this.defaultKms };
|
|
129
|
+
const identifier = {
|
|
130
|
+
did: document.id,
|
|
131
|
+
controllerKeyId: controllerKey.kid,
|
|
132
|
+
keys: [controllerKey, ...keys],
|
|
133
|
+
services: document.service || [],
|
|
134
|
+
provider: 'cheqd',
|
|
135
|
+
};
|
|
136
|
+
debug('Updated DID', did);
|
|
137
|
+
return identifier;
|
|
138
|
+
}
|
|
139
|
+
async deactivateIdentifier({ did, document, options }, context) {
|
|
140
|
+
const sdk = await this.getCheqdSDK(options?.fee);
|
|
141
|
+
const signInputs = options.keys.map(key => createSignInputsFromImportableEd25519Key(key, document.verificationMethod ?? []));
|
|
142
|
+
const tx = await sdk.deactivateDidDocTx(signInputs, document, '', this?.fee, undefined, undefined, { sdk: sdk });
|
|
143
|
+
assert(tx.code === 0, `cosmos_transaction: Failed to update DID. Reason: ${tx.rawLog}`);
|
|
144
|
+
debug('Deactivated DID', did);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
async createResource({ options }, context) {
|
|
148
|
+
const sdk = await this.getCheqdSDK(options?.fee);
|
|
149
|
+
const tx = await sdk.createLinkedResourceTx(options.signInputs, options.payload, '', this?.fee, undefined, { sdk: sdk });
|
|
150
|
+
assert(tx.code === 0, `cosmos_transaction: Failed to create Resource. Reason: ${tx.rawLog}`);
|
|
151
|
+
const mapKeyType = (keyType) => {
|
|
152
|
+
switch (keyType) {
|
|
153
|
+
case "Ed25519": return "Ed25519";
|
|
154
|
+
case "Secp256k1": return "Secp256k1";
|
|
155
|
+
default: return undefined;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const signInput = options.signInputs.filter(input => mapKeyType(input.keyType) !== undefined);
|
|
159
|
+
const keys = [];
|
|
160
|
+
for (const input of signInput) {
|
|
161
|
+
let managedKey;
|
|
162
|
+
try {
|
|
163
|
+
// get public key from private key in hex
|
|
164
|
+
const publicKey = toString((await Ed25519.makeKeypair(fromString(input.privateKeyHex, 'hex'))).pubkey, 'hex');
|
|
165
|
+
managedKey = await context.agent.keyManagerImport({
|
|
166
|
+
kid: publicKey,
|
|
167
|
+
publicKeyHex: publicKey,
|
|
168
|
+
privateKeyHex: input.privateKeyHex,
|
|
169
|
+
type: mapKeyType(input.keyType),
|
|
170
|
+
kms: options.kms || this.defaultKms,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
debug(`Failed to import key ${input.verificationMethodId}. Reason: ${e}`);
|
|
175
|
+
}
|
|
176
|
+
if (managedKey) {
|
|
177
|
+
keys.push(managedKey);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
debug('Created Resource', options.payload);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
async deleteIdentifier(identity, context) {
|
|
184
|
+
for (const { kid } of identity.keys) {
|
|
185
|
+
await context.agent.keyManagerDelete({ kid });
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
async addKey({ identifier, key, options, }, context) {
|
|
190
|
+
throw Error('CheqdDIDProvider addKey is not supported.');
|
|
191
|
+
}
|
|
192
|
+
async addService({ identifier, service, options, }, context) {
|
|
193
|
+
throw Error('CheqdDIDProvider addService is not supported.');
|
|
194
|
+
}
|
|
195
|
+
async removeKey(args, context) {
|
|
196
|
+
throw Error('CheqdDIDProvider removeKey is not supported.');
|
|
197
|
+
}
|
|
198
|
+
async removeService(args, context) {
|
|
199
|
+
throw Error('CheqdDIDProvider removeService is not supported.');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=cheqd-did-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheqd-did-provider.js","sourceRoot":"","sources":["../../../src/did-manager/cheqd-did-provider.ts"],"names":[],"mappings":"AAAA,oIAAoI;AACpI,gCAAgC;AAChC,qCAAqC;AACrC,2GAA2G;AAC3G,OAAO,EAEN,cAAc,EACd,wCAAwC,EACxC,SAAS,EAGT,cAAc,EAKd,MAAM,YAAY,CAAA;AAEnB,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAYtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACN,eAAe,IAAI,CAAC,EACpB,OAAO,EACP,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACN,UAAU,EACV,QAAQ,EACR,MAAM,aAAa,CAAA;AAEpB,MAAM,KAAK,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAA;AAIhD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACxB,kDAAiC,CAAA;IACjC,sDAAqC,CAAA;AACtC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACpB,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DIDResolutionResult, DIDResolver, ParsedDID, Resolvable } from 'did-resolver';
|
|
2
|
+
interface Options {
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a CheqdDIDResolver instance that can be used with `did-resolver`.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function getResolver(options?: Options): Record<string, DIDResolver>;
|
|
10
|
+
/**
|
|
11
|
+
* CheqdDIDResolver instance that can be used with `did-resolver`.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class CheqdDidResolver {
|
|
15
|
+
private resolverUrl;
|
|
16
|
+
constructor(options?: Options);
|
|
17
|
+
resolve(did: string, parsed: ParsedDID, _unused: Resolvable, options: DIDResolutionOptions): Promise<DIDResolutionResult>;
|
|
18
|
+
build(): Record<string, DIDResolver>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=cheqd-did-resolver.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a CheqdDIDResolver instance that can be used with `did-resolver`.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export function getResolver(options) {
|
|
6
|
+
if (options?.url)
|
|
7
|
+
return new CheqdDidResolver(options).build();
|
|
8
|
+
return new CheqdDidResolver().build();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* CheqdDIDResolver instance that can be used with `did-resolver`.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export class CheqdDidResolver {
|
|
15
|
+
resolverUrl = 'https://resolver.cheqd.net/1.0/identifiers/';
|
|
16
|
+
constructor(options) {
|
|
17
|
+
if (options?.url)
|
|
18
|
+
this.resolverUrl = options.url;
|
|
19
|
+
}
|
|
20
|
+
async resolve(did,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
parsed,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
_unused,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
options) {
|
|
27
|
+
try {
|
|
28
|
+
const result = await fetch(this.resolverUrl + did, {
|
|
29
|
+
headers: { 'Content-Type': 'application/did+json' },
|
|
30
|
+
});
|
|
31
|
+
const ddo = (await result.json());
|
|
32
|
+
return ddo;
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return Promise.reject(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
build() {
|
|
39
|
+
return { cheqd: this.resolve.bind(this) };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=cheqd-did-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheqd-did-resolver.js","sourceRoot":"","sources":["../../../src/did-manager/cheqd-did-resolver.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAiB;IAC3C,IAAI,OAAO,EAAE,GAAG;QAAE,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;IAE9D,OAAO,IAAI,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAA;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,WAAW,GAAG,6CAA6C,CAAA;IAEnE,YAAY,OAAiB;QAC3B,IAAI,OAAO,EAAE,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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DIDResolver } from 'did-resolver';
|
|
2
|
+
interface Options {
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated please use `getUniresolver(url)` or `getUniresolverFor(methods, url)` instead
|
|
7
|
+
*/
|
|
8
|
+
export declare class CheqdUniversalResolver {
|
|
9
|
+
constructor(options: Options);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a DIDResolver instance that can be used with `did-resolver`
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const uniResolver = getUniversalResolver()
|
|
17
|
+
* const resolver = new Resolver({
|
|
18
|
+
* web: uniResolver,
|
|
19
|
+
* key: uniResolver,
|
|
20
|
+
* elem: uniResolver
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param url the URL for the universal resolver instance (See https://uniresolver.io )
|
|
25
|
+
* @returns `DIDResolver`
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function getUniversalResolver(url?: string): DIDResolver;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a mapping of DID methods to a DIDResolver instance that can be used with `did-resolver`
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const uniResolver = getUniversalResolverFor(['web', 'key', 'elem'])
|
|
35
|
+
* const resolver = new Resolver({
|
|
36
|
+
* ...uniResolver,
|
|
37
|
+
* // other resolvers
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param methods an array of DID methods that should be resolved by this universal resolver
|
|
42
|
+
* @param url the URL for the universal resolver instance (See https://uniresolver.io )
|
|
43
|
+
* @returns `Record<string, DIDResolver>` a mapping of the given methods to an instance of `DIDResolver`
|
|
44
|
+
*/
|
|
45
|
+
export declare function getUniversalResolverFor(methods: string[], url?: string): Record<string, DIDResolver>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/did-manager/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,qBAAa,sBAAsB;gBACrB,OAAO,EAAE,OAAO;CAG7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,SAAgD,GAClD,WAAW,CAmBb;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,GAAG,SAAgD,GAClD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAO7B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated please use `getUniresolver(url)` or `getUniresolverFor(methods, url)` instead
|
|
3
|
+
*/
|
|
4
|
+
export class CheqdUniversalResolver {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
return getUniversalResolver(options.url);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a DIDResolver instance that can be used with `did-resolver`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const uniResolver = getUniversalResolver()
|
|
15
|
+
* const resolver = new Resolver({
|
|
16
|
+
* web: uniResolver,
|
|
17
|
+
* key: uniResolver,
|
|
18
|
+
* elem: uniResolver
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param url the URL for the universal resolver instance (See https://uniresolver.io )
|
|
23
|
+
* @returns `DIDResolver`
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export function getUniversalResolver(url = 'https://resolver.cheqd.net/1.0/identifiers/') {
|
|
27
|
+
if (!url) {
|
|
28
|
+
throw Error('[did-resolver] Universal: url required');
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
const resolve = async (didUrl) => {
|
|
32
|
+
try {
|
|
33
|
+
const result = await fetch(url + didUrl, {
|
|
34
|
+
headers: { 'Content-Type': 'application/did+ld+json' },
|
|
35
|
+
});
|
|
36
|
+
const ddo = await result.json();
|
|
37
|
+
return ddo;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return Promise.reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return resolve;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a mapping of DID methods to a DIDResolver instance that can be used with `did-resolver`
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const uniResolver = getUniversalResolverFor(['web', 'key', 'elem'])
|
|
51
|
+
* const resolver = new Resolver({
|
|
52
|
+
* ...uniResolver,
|
|
53
|
+
* // other resolvers
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param methods an array of DID methods that should be resolved by this universal resolver
|
|
58
|
+
* @param url the URL for the universal resolver instance (See https://uniresolver.io )
|
|
59
|
+
* @returns `Record<string, DIDResolver>` a mapping of the given methods to an instance of `DIDResolver`
|
|
60
|
+
*/
|
|
61
|
+
export function getUniversalResolverFor(methods, url = 'https://resolver.cheqd.net/1.0/identifiers/') {
|
|
62
|
+
const uniResolver = getUniversalResolver(url);
|
|
63
|
+
const mapping = {};
|
|
64
|
+
for (const method of methods) {
|
|
65
|
+
mapping[method] = uniResolver;
|
|
66
|
+
}
|
|
67
|
+
return mapping;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/did-manager/resolver.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACjC,YAAY,OAAgB;QAC1B,OAAO,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAG,GAAG,6CAA6C;IAEnD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAA;KACtD;IAED,8DAA8D;IAC9D,MAAM,OAAO,GAAgB,KAAK,EAAE,MAAc,EAAgB,EAAE;QAClE,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,MAAM,EAAE;gBACvC,OAAO,EAAE,EAAE,cAAc,EAAE,yBAAyB,EAAE;aACvD,CAAC,CAAA;YACF,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;YAC/B,OAAO,GAAG,CAAA;SACX;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;SACzB;IACH,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAiB,EACjB,GAAG,GAAG,6CAA6C;IAEnD,MAAM,WAAW,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAgC,EAAE,CAAA;IAC/C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,OAAO,CAAC,MAAM,CAAC,GAAG,WAAW,CAAA;KAC9B;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export { CheqdDIDProvider } from './did-manager/cheqd-did-provider.js';
|
|
5
|
+
export { CheqdDidResolver, getResolver } from './did-manager/cheqd-did-resolver.js';
|
|
6
|
+
export { CheqdUniversalResolver } from './did-manager/resolver.js';
|
|
7
|
+
export { Cheqd } from './agent/ICheqd.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export { CheqdDIDProvider } from './did-manager/cheqd-did-provider.js';
|
|
5
|
+
export { CheqdDidResolver, getResolver } from './did-manager/cheqd-did-resolver.js';
|
|
6
|
+
export { CheqdUniversalResolver } from './did-manager/resolver.js';
|
|
7
|
+
export { Cheqd } from './agent/ICheqd.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA"}
|