@cheqd/sdk 2.1.0-develop.1 → 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/.github/workflows/cleanup-cache-manual.yml +1 -1
- package/.github/workflows/pull-request.yml +1 -1
- package/CHANGELOG.md +11 -0
- package/build/cjs/index.d.ts +45 -0
- package/build/cjs/index.d.ts.map +1 -0
- package/build/cjs/index.js +144 -0
- package/build/cjs/index.js.map +1 -0
- package/build/{modules → cjs/modules}/_.d.ts +3 -3
- package/build/cjs/modules/_.d.ts.map +1 -0
- package/build/{modules → cjs/modules}/_.js +0 -0
- package/build/cjs/modules/_.js.map +1 -0
- package/build/{modules → cjs/modules}/did.d.ts +7 -5
- package/build/cjs/modules/did.d.ts.map +1 -0
- package/build/{modules → cjs/modules}/did.js +45 -37
- package/build/cjs/modules/did.js.map +1 -0
- package/build/{modules → cjs/modules}/resource.d.ts +6 -6
- package/build/cjs/modules/resource.d.ts.map +1 -0
- package/build/{modules → cjs/modules}/resource.js +14 -14
- package/build/cjs/modules/resource.js.map +1 -0
- package/build/{querier.d.ts → cjs/querier.d.ts} +1 -1
- package/build/cjs/querier.d.ts.map +1 -0
- package/build/{querier.js → cjs/querier.js} +0 -0
- package/build/cjs/querier.js.map +1 -0
- package/build/{registry.d.ts → cjs/registry.d.ts} +0 -0
- package/build/cjs/registry.d.ts.map +1 -0
- package/build/{registry.js → cjs/registry.js} +0 -0
- package/build/cjs/registry.js.map +1 -0
- package/build/{signer.d.ts → cjs/signer.d.ts} +6 -6
- package/build/cjs/signer.d.ts.map +1 -0
- package/build/{signer.js → cjs/signer.js} +19 -19
- package/build/cjs/signer.js.map +1 -0
- package/build/{types.d.ts → cjs/types.d.ts} +3 -3
- package/build/cjs/types.d.ts.map +1 -0
- package/build/{types.js → cjs/types.js} +0 -0
- package/build/cjs/types.js.map +1 -0
- package/build/{utils.d.ts → cjs/utils.d.ts} +1 -1
- package/build/cjs/utils.d.ts.map +1 -0
- package/build/{utils.js → cjs/utils.js} +18 -21
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.d.ts +45 -0
- package/build/esm/index.d.ts.map +1 -0
- package/build/esm/index.js +89 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/modules/_.d.ts +20 -0
- package/build/esm/modules/_.d.ts.map +1 -0
- package/build/esm/modules/_.js +37 -0
- package/build/esm/modules/_.js.map +1 -0
- package/build/esm/modules/did.d.ts +109 -0
- package/build/esm/modules/did.d.ts.map +1 -0
- package/build/esm/modules/did.js +432 -0
- package/build/esm/modules/did.js.map +1 -0
- package/build/esm/modules/resource.d.ts +62 -0
- package/build/esm/modules/resource.d.ts.map +1 -0
- package/build/esm/modules/resource.js +156 -0
- package/build/esm/modules/resource.js.map +1 -0
- package/build/esm/querier.d.ts +11 -0
- package/build/esm/querier.d.ts.map +1 -0
- package/build/esm/querier.js +27 -0
- package/build/esm/querier.js.map +1 -0
- package/build/esm/registry.d.ts +4 -0
- package/build/esm/registry.d.ts.map +1 -0
- package/build/esm/registry.js +9 -0
- package/build/esm/registry.js.map +1 -0
- package/build/esm/signer.d.ts +36 -0
- package/build/esm/signer.d.ts.map +1 -0
- package/build/esm/signer.js +197 -0
- package/build/esm/signer.js.map +1 -0
- package/build/esm/types.d.ts +80 -0
- package/build/esm/types.d.ts.map +1 -0
- package/build/esm/types.js +22 -0
- package/build/esm/types.js.map +1 -0
- package/build/esm/utils.d.ts +18 -0
- package/build/esm/utils.d.ts.map +1 -0
- package/build/esm/utils.js +196 -0
- package/build/esm/utils.js.map +1 -0
- package/build/types/index.d.ts +45 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/modules/_.d.ts +20 -0
- package/build/types/modules/_.d.ts.map +1 -0
- package/build/types/modules/did.d.ts +109 -0
- package/build/types/modules/did.d.ts.map +1 -0
- package/build/types/modules/resource.d.ts +62 -0
- package/build/types/modules/resource.d.ts.map +1 -0
- package/build/types/querier.d.ts +11 -0
- package/build/types/querier.d.ts.map +1 -0
- package/build/types/registry.d.ts +4 -0
- package/build/types/registry.d.ts.map +1 -0
- package/build/types/signer.d.ts +36 -0
- package/build/types/signer.d.ts.map +1 -0
- package/build/types/types.d.ts +80 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils.d.ts +18 -0
- package/build/types/utils.d.ts.map +1 -0
- package/jest.config.cjs +19 -0
- package/package.json +44 -21
- package/src/index.ts +51 -11
- package/src/modules/_.ts +3 -3
- package/src/modules/did.ts +32 -7
- package/src/modules/resource.ts +34 -9
- package/src/querier.ts +1 -1
- package/src/signer.ts +7 -7
- package/src/types.ts +3 -3
- package/src/utils.ts +3 -7
- package/tests/modules/resource.test.ts +174 -2
- package/tests/testutils.test.ts +6 -1
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +8 -0
- package/tsconfig.json +9 -5
- package/tsconfig.types.json +10 -0
- package/build/index.d.ts +0 -40
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -97
- package/build/index.js.map +0 -1
- package/build/modules/_.d.ts.map +0 -1
- package/build/modules/_.js.map +0 -1
- package/build/modules/did.d.ts.map +0 -1
- package/build/modules/did.js.map +0 -1
- package/build/modules/resource.d.ts.map +0 -1
- package/build/modules/resource.js.map +0 -1
- package/build/querier.d.ts.map +0 -1
- package/build/querier.js.map +0 -1
- package/build/registry.d.ts.map +0 -1
- package/build/registry.js.map +0 -1
- package/build/signer.d.ts.map +0 -1
- package/build/signer.js.map +0 -1
- package/build/types.d.ts.map +0 -1
- package/build/types.js.map +0 -1
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js.map +0 -1
- package/jest.config.js +0 -6
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Service as ProtobufService, VerificationMethod as ProtobufVerificationMethod } from "@cheqd/ts-proto/cheqd/did/v2";
|
|
2
|
+
import { CheqdSDK } from "./index.js";
|
|
3
|
+
import { Coin } from "@cosmjs/proto-signing";
|
|
4
|
+
import { Signer } from "did-jwt";
|
|
5
|
+
import { QueryClient } from "@cosmjs/stargate";
|
|
6
|
+
import { DIDResolutionResult } from "did-resolver";
|
|
7
|
+
import { DidExtension } from "./modules/did.js";
|
|
8
|
+
import { ResourceExtension } from './modules/resource.js';
|
|
9
|
+
export { DIDDocument, VerificationMethod, Service, ServiceEndpoint, JsonWebKey } from "did-resolver";
|
|
10
|
+
export declare enum CheqdNetwork {
|
|
11
|
+
Mainnet = "mainnet",
|
|
12
|
+
Testnet = "testnet"
|
|
13
|
+
}
|
|
14
|
+
export type QueryExtensionSetup<T> = (base: QueryClient) => T;
|
|
15
|
+
export type CheqdExtension<K extends string, V = any> = {
|
|
16
|
+
[P in K]: (Record<P, V> & Partial<Record<Exclude<K, P>, never>>) extends infer O ? {
|
|
17
|
+
[Q in keyof O]: O[Q];
|
|
18
|
+
} : never;
|
|
19
|
+
}[K];
|
|
20
|
+
export type CheqdExtensions = DidExtension | ResourceExtension;
|
|
21
|
+
export interface IModuleMethod {
|
|
22
|
+
(...args: any[]): Promise<any>;
|
|
23
|
+
}
|
|
24
|
+
export interface IModuleMethodMap extends Record<string, IModuleMethod> {
|
|
25
|
+
}
|
|
26
|
+
export interface IContext {
|
|
27
|
+
sdk: CheqdSDK;
|
|
28
|
+
}
|
|
29
|
+
export type DIDDocumentWithMetadata = Pick<DIDResolutionResult, 'didDocument' | 'didDocumentMetadata'>;
|
|
30
|
+
export type SpecValidationResult = {
|
|
31
|
+
valid: boolean;
|
|
32
|
+
error?: string;
|
|
33
|
+
protobufVerificationMethod?: ProtobufVerificationMethod[];
|
|
34
|
+
protobufService?: ProtobufService[];
|
|
35
|
+
};
|
|
36
|
+
export declare enum VerificationMethods {
|
|
37
|
+
Ed255192020 = "Ed25519VerificationKey2020",
|
|
38
|
+
Ed255192018 = "Ed25519VerificationKey2018",
|
|
39
|
+
JWK = "JsonWebKey2020"
|
|
40
|
+
}
|
|
41
|
+
export declare enum MethodSpecificIdAlgo {
|
|
42
|
+
Base58 = "base58btc",
|
|
43
|
+
Uuid = "uuid"
|
|
44
|
+
}
|
|
45
|
+
export type TSignerAlgo = {
|
|
46
|
+
[key in VerificationMethods as string]?: (secretKey: Uint8Array) => Signer;
|
|
47
|
+
};
|
|
48
|
+
export interface ISignInputs {
|
|
49
|
+
verificationMethodId: string;
|
|
50
|
+
keyType?: 'Ed25519' | 'Secp256k1' | 'P256';
|
|
51
|
+
privateKeyHex: string;
|
|
52
|
+
}
|
|
53
|
+
export interface IKeyPair {
|
|
54
|
+
publicKey: string;
|
|
55
|
+
privateKey: string;
|
|
56
|
+
algo?: MethodSpecificIdAlgo;
|
|
57
|
+
}
|
|
58
|
+
export interface IKeyValuePair {
|
|
59
|
+
key: string;
|
|
60
|
+
value: any;
|
|
61
|
+
}
|
|
62
|
+
export type TVerificationKeyPrefix = string;
|
|
63
|
+
export type TVerificationKey<K extends TVerificationKeyPrefix, N extends number> = `${K}-${N}`;
|
|
64
|
+
export interface IVerificationKeys {
|
|
65
|
+
readonly methodSpecificId: TMethodSpecificId;
|
|
66
|
+
readonly didUrl: `did:cheqd:${CheqdNetwork}:${IVerificationKeys['methodSpecificId']}` extends string ? string : never;
|
|
67
|
+
readonly keyId: `${IVerificationKeys['didUrl']}#${TVerificationKey<TVerificationKeyPrefix, number>}`;
|
|
68
|
+
readonly publicKey: string;
|
|
69
|
+
}
|
|
70
|
+
export type TMethodSpecificId = string;
|
|
71
|
+
export interface DidStdFee {
|
|
72
|
+
readonly amount: readonly Coin[];
|
|
73
|
+
readonly gas: string;
|
|
74
|
+
payer?: string;
|
|
75
|
+
granter?: string;
|
|
76
|
+
}
|
|
77
|
+
export declare const ISignInputs: {
|
|
78
|
+
isSignInput(object: Object[]): object is ISignInputs[];
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IKeyPair, IKeyValuePair, ISignInputs, VerificationMethods, MethodSpecificIdAlgo, TVerificationKey, TVerificationKeyPrefix, CheqdNetwork, IVerificationKeys, VerificationMethod, DIDDocument, SpecValidationResult } from "./types.js";
|
|
2
|
+
import { KeyPair } from '@stablelib/ed25519';
|
|
3
|
+
export type TImportableEd25519Key = {
|
|
4
|
+
publicKeyHex: string;
|
|
5
|
+
privateKeyHex: string;
|
|
6
|
+
kid: string;
|
|
7
|
+
type: "Ed25519";
|
|
8
|
+
};
|
|
9
|
+
export declare function isEqualKeyValuePair(kv1: IKeyValuePair[], kv2: IKeyValuePair[]): boolean;
|
|
10
|
+
export declare function createSignInputsFromImportableEd25519Key(key: TImportableEd25519Key, verificationMethod: VerificationMethod[]): ISignInputs;
|
|
11
|
+
export declare function createKeyPairRaw(seed?: string): KeyPair;
|
|
12
|
+
export declare function createKeyPairBase64(seed?: string): IKeyPair;
|
|
13
|
+
export declare function createKeyPairHex(seed?: string): IKeyPair;
|
|
14
|
+
export declare function createVerificationKeys(publicKey: string, algo: MethodSpecificIdAlgo, key: TVerificationKey<TVerificationKeyPrefix, number>, network?: CheqdNetwork): IVerificationKeys;
|
|
15
|
+
export declare function createDidVerificationMethod(verificationMethodTypes: VerificationMethods[], verificationKeys: IVerificationKeys[]): VerificationMethod[];
|
|
16
|
+
export declare function createDidPayload(verificationMethods: VerificationMethod[], verificationKeys: IVerificationKeys[]): DIDDocument;
|
|
17
|
+
export declare function validateSpecCompliantPayload(didDocument: DIDDocument): SpecValidationResult;
|
|
18
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,aAAa,EACb,WAAW,EACX,mBAAmB,EAEnB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EAEvB,MAAM,YAAY,CAAA;AAInB,OAAO,EAA4C,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAQtF,MAAM,MAAM,qBAAqB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,SAAS,CAAA;CAClB,CAAA;AAID,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,OAAO,CAEvF;AAED,wBAAgB,wCAAwC,CAAC,GAAG,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAuC1I;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAM3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAMxD;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,EAAE,gBAAgB,CAAC,sBAAsB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE,YAAmC,GAAG,iBAAiB,CAyB5M;AAED,wBAAgB,2BAA2B,CAAC,uBAAuB,EAAE,mBAAmB,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,kBAAkB,EAAE,CA8BvJ;AAED,wBAAgB,gBAAgB,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,WAAW,CAa9H;AAED,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAsD3F"}
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
moduleNameMapper: {
|
|
4
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
5
|
+
},
|
|
6
|
+
transform: {
|
|
7
|
+
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
|
|
8
|
+
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
|
|
9
|
+
'^.+\\.m?[tj]sx?$': [
|
|
10
|
+
'ts-jest',
|
|
11
|
+
{
|
|
12
|
+
useESM: true,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
testEnvironment: 'node',
|
|
17
|
+
moduleDirectories: ['node_modules', 'src'],
|
|
18
|
+
modulePathIgnorePatterns: ["tests/testutils.test.ts"],
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheqd/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-develop.1",
|
|
4
4
|
"description": "A TypeScript SDK built with CosmJS to interact with cheqd network ledger",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Cheqd Foundation Limited (https://github.com/cheqd)",
|
|
7
7
|
"source": "src/index.ts",
|
|
8
|
-
"main": "build/index.js",
|
|
9
|
-
"types": "build/index.d.ts",
|
|
8
|
+
"main": "build/esm/index.js",
|
|
9
|
+
"types": "build/types/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./build/types/index.d.ts",
|
|
14
|
+
"import": "./build/esm/index.js",
|
|
15
|
+
"require": "./build/cjs/index.js",
|
|
16
|
+
"default": "./build/esm/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./*": {
|
|
19
|
+
"types": "./build/types/*.d.ts",
|
|
20
|
+
"import": "./build/esm/*.js",
|
|
21
|
+
"require": "./build/cjs/*.js",
|
|
22
|
+
"default": "./build/esm/*.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
10
25
|
"scripts": {
|
|
11
26
|
"test": "jest --colors --passWithNoTests --maxWorkers 1 --maxConcurrency 1",
|
|
27
|
+
"test:esm": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --colors --passWithNoTests --maxWorkers 1 --maxConcurrency 1",
|
|
12
28
|
"test:watch": "jest --passWithNoTests --watch",
|
|
13
|
-
"build": "
|
|
29
|
+
"build": "rm -rf build && npm run build:types && npm run build:esm && npm run build:cjs",
|
|
30
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
31
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
32
|
+
"build:cjs": "tsc -p tsconfig.cjs.json"
|
|
14
33
|
},
|
|
15
34
|
"repository": "https://github.com/cheqd/sdk.git",
|
|
16
35
|
"keywords": [
|
|
@@ -26,41 +45,45 @@
|
|
|
26
45
|
},
|
|
27
46
|
"homepage": "https://github.com/cheqd/sdk#readme",
|
|
28
47
|
"dependencies": {
|
|
29
|
-
"@cheqd/ts-proto": "^
|
|
30
|
-
"@cosmjs/amino": "^0.29.
|
|
31
|
-
"@cosmjs/encoding": "^0.29.
|
|
32
|
-
"@cosmjs/math": "^0.29.
|
|
33
|
-
"@cosmjs/proto-signing": "^0.29.
|
|
34
|
-
"@cosmjs/stargate": "^0.29.
|
|
35
|
-
"@cosmjs/tendermint-rpc": "^0.29.
|
|
36
|
-
"@cosmjs/utils": "^0.29.
|
|
48
|
+
"@cheqd/ts-proto": "^3.0.0",
|
|
49
|
+
"@cosmjs/amino": "^0.29.5",
|
|
50
|
+
"@cosmjs/encoding": "^0.29.5",
|
|
51
|
+
"@cosmjs/math": "^0.29.5",
|
|
52
|
+
"@cosmjs/proto-signing": "^0.29.5",
|
|
53
|
+
"@cosmjs/stargate": "^0.29.5",
|
|
54
|
+
"@cosmjs/tendermint-rpc": "^0.29.5",
|
|
55
|
+
"@cosmjs/utils": "^0.29.5",
|
|
37
56
|
"@stablelib/ed25519": "^1.0.3",
|
|
38
57
|
"cosmjs-types": "^0.5.2",
|
|
39
|
-
"did-jwt": "^6.
|
|
58
|
+
"did-jwt": "^6.11.1",
|
|
40
59
|
"did-resolver": "^4.0.1",
|
|
41
60
|
"file-type": "^16.5.4",
|
|
42
61
|
"multiformats": "^9.9.0",
|
|
43
62
|
"uuid": "^9.0.0"
|
|
44
63
|
},
|
|
45
64
|
"devDependencies": {
|
|
46
|
-
"@semantic-release/changelog": "^6.0.
|
|
65
|
+
"@semantic-release/changelog": "^6.0.2",
|
|
47
66
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
48
67
|
"@semantic-release/git": "^10.0.1",
|
|
49
|
-
"@semantic-release/github": "^8.0.
|
|
68
|
+
"@semantic-release/github": "^8.0.7",
|
|
50
69
|
"@semantic-release/npm": "^9.0.1",
|
|
51
70
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
52
|
-
"@types/jest": "^29.
|
|
53
|
-
"@types/node": "^18.
|
|
54
|
-
"@types/uuid": "^
|
|
71
|
+
"@types/jest": "^29.4.0",
|
|
72
|
+
"@types/node": "^18.13.0",
|
|
73
|
+
"@types/uuid": "^9.0.0",
|
|
55
74
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
75
|
+
"cross-env": "^7.0.3",
|
|
76
|
+
"jest": "^29.4.2",
|
|
77
|
+
"ts-jest": "^29.0.5",
|
|
58
78
|
"ts-node": "^10.9.1",
|
|
59
|
-
"typescript": "^4.9.
|
|
79
|
+
"typescript": "^4.9.5",
|
|
60
80
|
"uint8arrays": "^3.1.1"
|
|
61
81
|
},
|
|
62
82
|
"publishConfig": {
|
|
63
83
|
"registry": "https://registry.npmjs.org/",
|
|
64
84
|
"access": "public"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=18.0.0"
|
|
65
88
|
}
|
|
66
89
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { OfflineSigner, Registry } from '@cosmjs/proto-signing'
|
|
2
|
-
import { DIDModule, MinimalImportableDIDModule, DidExtension } from './modules/did';
|
|
3
|
-
import { MinimalImportableResourceModule, ResourceModule, ResourceExtension } from './modules/resource';
|
|
4
|
-
import { AbstractCheqdSDKModule, applyMixins, instantiateCheqdSDKModule, instantiateCheqdSDKModuleRegistryTypes, instantiateCheqdSDKModuleQuerierExtensionSetup } from './modules/_';
|
|
5
|
-
import { createDefaultCheqdRegistry } from './registry'
|
|
6
|
-
import { CheqdSigningStargateClient } from './signer'
|
|
7
|
-
import { CheqdNetwork, IContext, IModuleMethodMap } from './types';
|
|
8
|
-
import { createSignInputsFromImportableEd25519Key } from './utils'
|
|
2
|
+
import { DIDModule, MinimalImportableDIDModule, DidExtension } from './modules/did.js';
|
|
3
|
+
import { MinimalImportableResourceModule, ResourceModule, ResourceExtension } from './modules/resource.js';
|
|
4
|
+
import { AbstractCheqdSDKModule, applyMixins, instantiateCheqdSDKModule, instantiateCheqdSDKModuleRegistryTypes, instantiateCheqdSDKModuleQuerierExtensionSetup } from './modules/_.js';
|
|
5
|
+
import { createDefaultCheqdRegistry } from './registry.js'
|
|
6
|
+
import { CheqdSigningStargateClient } from './signer.js'
|
|
7
|
+
import { CheqdNetwork, IContext, IModuleMethodMap } from './types.js';
|
|
9
8
|
import { GasPrice, QueryClient } from '@cosmjs/stargate'
|
|
10
|
-
import { CheqdQuerier } from './querier'
|
|
9
|
+
import { CheqdQuerier } from './querier.js'
|
|
11
10
|
import { Tendermint34Client } from '@cosmjs/tendermint-rpc'
|
|
12
11
|
|
|
13
12
|
export interface ICheqdSDKOptions {
|
|
@@ -117,12 +116,53 @@ export async function createCheqdSDK(options: ICheqdSDKOptions): Promise<CheqdSD
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
export { DIDModule, ResourceModule }
|
|
120
|
-
export {
|
|
119
|
+
export { AbstractCheqdSDKModule, applyMixins } from './modules/_.js'
|
|
121
120
|
export {
|
|
121
|
+
DidExtension,
|
|
122
|
+
MinimalImportableDIDModule,
|
|
123
|
+
MsgCreateDidDocEncodeObject,
|
|
124
|
+
MsgCreateDidDocResponseEncodeObject,
|
|
125
|
+
MsgUpdateDidDocEncodeObject,
|
|
126
|
+
MsgUpdateDidDocResponseEncodeObject,
|
|
127
|
+
MsgDeactivateDidDocEncodeObject,
|
|
128
|
+
MsgDeactivateDidDocResponseEncodeObject,
|
|
129
|
+
contexts,
|
|
130
|
+
defaultDidExtensionKey,
|
|
131
|
+
protobufLiterals as protobufLiteralsDid,
|
|
132
|
+
typeUrlMsgCreateDidDoc,
|
|
133
|
+
typeUrlMsgCreateDidDocResponse,
|
|
134
|
+
typeUrlMsgUpdateDidDoc,
|
|
135
|
+
typeUrlMsgUpdateDidDocResponse,
|
|
136
|
+
typeUrlMsgDeactivateDidDoc,
|
|
137
|
+
typeUrlMsgDeactivateDidDocResponse,
|
|
138
|
+
setupDidExtension,
|
|
139
|
+
isMsgCreateDidDocEncodeObject,
|
|
140
|
+
isMsgUpdateDidDocEncodeObject,
|
|
141
|
+
isMsgDeactivateDidDocEncodeObject,
|
|
142
|
+
} from './modules/did.js'
|
|
143
|
+
export {
|
|
144
|
+
ResourceExtension,
|
|
145
|
+
MinimalImportableResourceModule,
|
|
146
|
+
defaultResourceExtensionKey,
|
|
147
|
+
protobufLiterals as protobufLiteralsResource,
|
|
148
|
+
typeUrlMsgCreateResource,
|
|
149
|
+
typeUrlMsgCreateResourceResponse,
|
|
150
|
+
setupResourceExtension,
|
|
151
|
+
isMsgCreateResourceEncodeObject,
|
|
152
|
+
} from './modules/resource.js'
|
|
153
|
+
export * from './signer.js'
|
|
154
|
+
export * from './querier.js'
|
|
155
|
+
export * from './registry.js'
|
|
156
|
+
export * from './types.js'
|
|
157
|
+
export {
|
|
158
|
+
TImportableEd25519Key,
|
|
122
159
|
createKeyPairRaw,
|
|
123
160
|
createKeyPairBase64,
|
|
124
161
|
createKeyPairHex,
|
|
125
162
|
createVerificationKeys,
|
|
126
163
|
createDidVerificationMethod,
|
|
127
|
-
createDidPayload
|
|
128
|
-
|
|
164
|
+
createDidPayload,
|
|
165
|
+
createSignInputsFromImportableEd25519Key,
|
|
166
|
+
validateSpecCompliantPayload,
|
|
167
|
+
isEqualKeyValuePair,
|
|
168
|
+
} from './utils.js'
|
package/src/modules/_.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GeneratedType } from "@cosmjs/proto-signing"
|
|
2
2
|
import { QueryClient } from "@cosmjs/stargate"
|
|
3
|
-
import { CheqdSigningStargateClient } from '../signer'
|
|
4
|
-
import { IModuleMethodMap, QueryExtensionSetup } from '../types';
|
|
5
|
-
import { CheqdQuerier } from "../querier";
|
|
3
|
+
import { CheqdSigningStargateClient } from '../signer.js'
|
|
4
|
+
import { IModuleMethodMap, QueryExtensionSetup } from '../types.js';
|
|
5
|
+
import { CheqdQuerier } from "../querier.js";
|
|
6
6
|
|
|
7
7
|
export abstract class AbstractCheqdSDKModule {
|
|
8
8
|
_signer: CheqdSigningStargateClient
|
package/src/modules/did.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
createPagination,
|
|
3
|
+
createProtobufRpcClient,
|
|
4
|
+
DeliverTxResponse,
|
|
5
|
+
QueryClient
|
|
6
|
+
} from "@cosmjs/stargate"
|
|
7
|
+
import {
|
|
8
|
+
AbstractCheqdSDKModule,
|
|
9
|
+
MinimalImportableCheqdSDKModule
|
|
10
|
+
} from './_.js';
|
|
11
|
+
import { CheqdSigningStargateClient } from "../signer.js"
|
|
12
|
+
import {
|
|
13
|
+
DIDDocument,
|
|
14
|
+
DidStdFee,
|
|
15
|
+
IContext,
|
|
16
|
+
ISignInputs,
|
|
17
|
+
QueryExtensionSetup,
|
|
18
|
+
SpecValidationResult,
|
|
19
|
+
VerificationMethods,
|
|
20
|
+
DIDDocumentWithMetadata
|
|
21
|
+
} from '../types.js';
|
|
5
22
|
import {
|
|
6
23
|
MsgCreateDidDoc,
|
|
7
24
|
MsgCreateDidDocPayload,
|
|
@@ -21,12 +38,12 @@ import {
|
|
|
21
38
|
DidDocWithMetadata,
|
|
22
39
|
DidDoc,
|
|
23
40
|
Metadata
|
|
24
|
-
} from "@cheqd/ts-proto/cheqd/did/v2"
|
|
41
|
+
} from "@cheqd/ts-proto/cheqd/did/v2/index.js"
|
|
25
42
|
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"
|
|
26
43
|
import { v4 } from "uuid"
|
|
27
44
|
import { assert } from "@cosmjs/utils";
|
|
28
|
-
import { PageRequest } from "@cheqd/ts-proto/cosmos/base/query/v1beta1/pagination";
|
|
29
|
-
import { CheqdQuerier } from "../querier";
|
|
45
|
+
import { PageRequest } from "@cheqd/ts-proto/cosmos/base/query/v1beta1/pagination.js";
|
|
46
|
+
import { CheqdQuerier } from "../querier.js";
|
|
30
47
|
import { DIDDocumentMetadata } from "did-resolver";
|
|
31
48
|
|
|
32
49
|
export const defaultDidExtensionKey = "did" as const
|
|
@@ -62,6 +79,14 @@ export function isMsgCreateDidDocEncodeObject(obj: EncodeObject): obj is MsgCrea
|
|
|
62
79
|
return obj.typeUrl === typeUrlMsgCreateDidDoc
|
|
63
80
|
}
|
|
64
81
|
|
|
82
|
+
export function isMsgUpdateDidDocEncodeObject(obj: EncodeObject): obj is MsgUpdateDidDocEncodeObject {
|
|
83
|
+
return obj.typeUrl === typeUrlMsgUpdateDidDoc
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isMsgDeactivateDidDocEncodeObject(obj: EncodeObject): obj is MsgDeactivateDidDocEncodeObject {
|
|
87
|
+
return obj.typeUrl === typeUrlMsgDeactivateDidDoc
|
|
88
|
+
}
|
|
89
|
+
|
|
65
90
|
export interface MsgCreateDidDocResponseEncodeObject extends EncodeObject {
|
|
66
91
|
readonly typeUrl: typeof typeUrlMsgCreateDidDocResponse,
|
|
67
92
|
readonly value: Partial<MsgCreateDidDocResponse>
|
package/src/modules/resource.ts
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
AbstractCheqdSDKModule,
|
|
3
|
+
MinimalImportableCheqdSDKModule
|
|
4
|
+
} from './_.js';
|
|
5
|
+
import { CheqdSigningStargateClient } from "../signer.js"
|
|
6
|
+
import {
|
|
7
|
+
EncodeObject,
|
|
8
|
+
GeneratedType
|
|
9
|
+
} from "@cosmjs/proto-signing"
|
|
10
|
+
import {
|
|
11
|
+
DidStdFee,
|
|
12
|
+
IContext,
|
|
13
|
+
ISignInputs,
|
|
14
|
+
QueryExtensionSetup
|
|
15
|
+
} from '../types.js';
|
|
16
|
+
import {
|
|
17
|
+
Metadata,
|
|
18
|
+
MsgCreateResource,
|
|
19
|
+
MsgCreateResourcePayload,
|
|
20
|
+
MsgCreateResourceResponse,
|
|
21
|
+
QueryClientImpl,
|
|
22
|
+
QueryCollectionResourcesResponse,
|
|
23
|
+
ResourceWithMetadata,
|
|
24
|
+
protobufPackage
|
|
25
|
+
} from "@cheqd/ts-proto/cheqd/resource/v2/index.js"
|
|
26
|
+
import {
|
|
27
|
+
DeliverTxResponse,
|
|
28
|
+
QueryClient,
|
|
29
|
+
createPagination,
|
|
30
|
+
createProtobufRpcClient
|
|
31
|
+
} from "@cosmjs/stargate"
|
|
32
|
+
import { SignInfo } from "@cheqd/ts-proto/cheqd/did/v2/index.js";
|
|
8
33
|
import { fromBuffer } from "file-type";
|
|
9
34
|
import { assert } from '@cosmjs/utils';
|
|
10
|
-
import { PageRequest } from '@cheqd/ts-proto/cosmos/base/query/v1beta1/pagination';
|
|
11
|
-
import { CheqdQuerier } from '../querier';
|
|
35
|
+
import { PageRequest } from '@cheqd/ts-proto/cosmos/base/query/v1beta1/pagination.js';
|
|
36
|
+
import { CheqdQuerier } from '../querier.js';
|
|
12
37
|
|
|
13
38
|
export const defaultResourceExtensionKey = 'resource' as const
|
|
14
39
|
|
package/src/querier.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryClient } from "@cosmjs/stargate";
|
|
2
2
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
3
|
-
import { QueryExtensionSetup, CheqdExtensions } from "./types";
|
|
3
|
+
import { QueryExtensionSetup, CheqdExtensions } from "./types.js";
|
|
4
4
|
|
|
5
5
|
export class CheqdQuerier extends QueryClient {
|
|
6
6
|
constructor(tmClient: Tendermint34Client) {
|
package/src/signer.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { EncodeObject, isOfflineDirectSigner, OfflineSigner, encodePubkey, TxBodyEncodeObject, makeSignDoc } from "@cosmjs/proto-signing"
|
|
2
2
|
import { DeliverTxResponse, GasPrice, HttpEndpoint, SigningStargateClient, SigningStargateClientOptions, calculateFee, SignerData } from "@cosmjs/stargate"
|
|
3
3
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"
|
|
4
|
-
import { createDefaultCheqdRegistry } from "./registry"
|
|
4
|
+
import { createDefaultCheqdRegistry } from "./registry.js"
|
|
5
5
|
import { MsgCreateDidDocPayload, SignInfo, MsgUpdateDidDocPayload, MsgDeactivateDidDocPayload, VerificationMethod } from '@cheqd/ts-proto/cheqd/did/v2';
|
|
6
|
-
import { DidStdFee, ISignInputs, TSignerAlgo, VerificationMethods } from './types';
|
|
7
|
-
import { base64ToBytes, EdDSASigner, hexToBytes, Signer, ES256Signer, ES256KSigner } from 'did-jwt';
|
|
6
|
+
import { DidStdFee, ISignInputs, TSignerAlgo, VerificationMethods } from './types.js';
|
|
7
|
+
import { base64ToBytes, EdDSASigner, hexToBytes, Signer, ES256Signer, ES256KSigner } from '../node_modules/did-jwt/lib/index.js';
|
|
8
8
|
import { assert, assertDefined } from '@cosmjs/utils'
|
|
9
9
|
import { encodeSecp256k1Pubkey } from '@cosmjs/amino'
|
|
10
10
|
import { Int53 } from '@cosmjs/math'
|
|
11
11
|
import { fromBase64 } from '@cosmjs/encoding'
|
|
12
|
-
import { AuthInfo, SignerInfo, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx'
|
|
13
|
-
import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing'
|
|
14
|
-
import { Any } from 'cosmjs-types/google/protobuf/any'
|
|
15
|
-
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin'
|
|
12
|
+
import { AuthInfo, SignerInfo, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js'
|
|
13
|
+
import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing.js'
|
|
14
|
+
import { Any } from 'cosmjs-types/google/protobuf/any.js'
|
|
15
|
+
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin.js'
|
|
16
16
|
import Long from 'long'
|
|
17
17
|
|
|
18
18
|
export function calculateDidFee(gasLimit: number, gasPrice: string | GasPrice): DidStdFee {
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Service as ProtobufService, VerificationMethod as ProtobufVerificationMethod } from "@cheqd/ts-proto/cheqd/did/v2"
|
|
2
|
-
import { CheqdSDK } from "."
|
|
2
|
+
import { CheqdSDK } from "./index.js"
|
|
3
3
|
import { Coin } from "@cosmjs/proto-signing"
|
|
4
4
|
import { Signer } from "did-jwt"
|
|
5
5
|
import { QueryClient } from "@cosmjs/stargate"
|
|
6
6
|
import { DIDResolutionResult } from "did-resolver"
|
|
7
|
-
import { DidExtension } from "./modules/did"
|
|
8
|
-
import { ResourceExtension } from './modules/resource';
|
|
7
|
+
import { DidExtension } from "./modules/did.js"
|
|
8
|
+
import { ResourceExtension } from './modules/resource.js';
|
|
9
9
|
export { DIDDocument, VerificationMethod, Service, ServiceEndpoint, JsonWebKey } from "did-resolver"
|
|
10
10
|
|
|
11
11
|
export enum CheqdNetwork {
|
package/src/utils.ts
CHANGED
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
DIDDocument,
|
|
14
14
|
SpecValidationResult,
|
|
15
15
|
JsonWebKey,
|
|
16
|
-
} from "./types"
|
|
16
|
+
} from "./types.js"
|
|
17
17
|
import { fromString, toString } from 'uint8arrays'
|
|
18
18
|
import { bases } from "multiformats/basics"
|
|
19
19
|
import { base64ToBytes } from "did-jwt"
|
|
20
20
|
import { generateKeyPair, generateKeyPairFromSeed, KeyPair } from '@stablelib/ed25519'
|
|
21
|
+
import { sha256 } from '@cosmjs/crypto'
|
|
21
22
|
import { v4 } from 'uuid'
|
|
22
|
-
import { createHash } from 'crypto'
|
|
23
23
|
import {
|
|
24
24
|
VerificationMethod as ProtoVerificationMethod,
|
|
25
25
|
Service as ProtoService,
|
|
@@ -107,7 +107,7 @@ export function createVerificationKeys(publicKey: string, algo: MethodSpecificId
|
|
|
107
107
|
switch (algo) {
|
|
108
108
|
case MethodSpecificIdAlgo.Base58:
|
|
109
109
|
methodSpecificId = bases['base58btc'].encode(base64ToBytes(publicKey))
|
|
110
|
-
didUrl = `did:cheqd:${network}:${(bases['base58btc'].encode((
|
|
110
|
+
didUrl = `did:cheqd:${network}:${(bases['base58btc'].encode((sha256(base64ToBytes(publicKey))).slice(0,16))).slice(1)}`
|
|
111
111
|
return {
|
|
112
112
|
methodSpecificId,
|
|
113
113
|
didUrl,
|
|
@@ -229,10 +229,6 @@ export function validateSpecCompliantPayload(didDocument: DIDDocument): SpecVali
|
|
|
229
229
|
return { valid: true, protobufVerificationMethod: protoVerificationMethod, protobufService: protoService }
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
function sha256(message: string) {
|
|
233
|
-
return createHash('sha256').update(message).digest('hex')
|
|
234
|
-
}
|
|
235
|
-
|
|
236
232
|
function toMultibaseRaw(key: Uint8Array) {
|
|
237
233
|
const multibase = new Uint8Array(MULTICODEC_ED25519_HEADER.length + key.length);
|
|
238
234
|
|