@silencelaboratories/walletprovider-sdk 0.0.5 → 0.0.7
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 +131 -1
- package/dist/EOAauthentication.d.ts +33 -0
- package/dist/EOAauthentication.d.ts.map +1 -1
- package/dist/authentication.d.ts +18 -3
- package/dist/authentication.d.ts.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -18425
- package/dist/networkSigner.d.ts +57 -8
- package/dist/networkSigner.d.ts.map +1 -1
- package/dist/walletProviderServiceClient.d.ts +10 -1
- package/dist/walletProviderServiceClient.d.ts.map +1 -1
- package/dist/walletProviderServiceClientInterface.d.ts +17 -1
- package/dist/walletProviderServiceClientInterface.d.ts.map +1 -1
- package/package.json +7 -4
package/dist/networkSigner.d.ts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import { AuthModule, UserAuthentication } from './authentication.ts';
|
|
2
2
|
import { type IWalletProviderServiceClient } from './walletProviderServiceClientInterface.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Response from the network for keygen requests
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
3
7
|
export interface KeygenResponse {
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
keyId: string;
|
|
9
|
+
publicKey: string;
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Response from the network for sign request
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
7
15
|
export interface SignResponse {
|
|
8
|
-
sign
|
|
9
|
-
recid
|
|
10
|
-
preSignId?: string;
|
|
16
|
+
sign: string;
|
|
17
|
+
recid: number;
|
|
11
18
|
}
|
|
19
|
+
/** Key parameters used during generation */
|
|
12
20
|
export declare class KeygenSetupOpts {
|
|
21
|
+
/** Threshold, number of parties that needs to participate in a protocol in order to produce valid signature */
|
|
13
22
|
t: number;
|
|
23
|
+
/** Total number of nodes that participate in Key generation, must be greater or equal than `t` */
|
|
14
24
|
n: number;
|
|
25
|
+
/** Optional key label */
|
|
15
26
|
key_label?: string;
|
|
27
|
+
/** Metadata for a key. Currently they store the permissions, can be set in a constructor of this class.
|
|
28
|
+
If permissions are not set, all operations are allowed.
|
|
29
|
+
*/
|
|
16
30
|
metadata: [number, string][];
|
|
17
31
|
constructor({ t, n, key_label, permissions }: {
|
|
18
32
|
t: number;
|
|
@@ -21,25 +35,60 @@ export declare class KeygenSetupOpts {
|
|
|
21
35
|
permissions?: string;
|
|
22
36
|
});
|
|
23
37
|
}
|
|
38
|
+
/** Parameters used in Signature execution */
|
|
24
39
|
export type SignSetupOpts = {
|
|
40
|
+
/** Nymber of nodes that will participate in the signature execution */
|
|
25
41
|
t: number;
|
|
42
|
+
/** Select the key using it's ID */
|
|
26
43
|
key_id: string;
|
|
44
|
+
/** The message to sign */
|
|
27
45
|
message: string;
|
|
28
46
|
};
|
|
47
|
+
/** Verifies if passed `params` object is of type SignSetupOpts */
|
|
29
48
|
export declare function isSignSetupOpts(params: KeygenSetupOpts | SignSetupOpts): params is SignSetupOpts;
|
|
49
|
+
/** The `user_authentication` contains signature over the `setup` parameter. */
|
|
30
50
|
export type UserAuthenticatedRequest<T> = {
|
|
31
51
|
setup: T;
|
|
32
52
|
user_authentication: UserAuthentication;
|
|
33
|
-
ttl: number;
|
|
34
53
|
};
|
|
54
|
+
/** The networkSigner contains an API to communicate with the Silent MPC Network. Call to sign and keygen require
|
|
55
|
+
* the Auth module, that is used to prompt the User before executing the request.
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
35
58
|
export declare class NetworkSigner {
|
|
59
|
+
/** Authentication module, used to get confirmation from the User before request execution */
|
|
36
60
|
authModule: AuthModule;
|
|
61
|
+
/** Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`. */
|
|
37
62
|
threshold: number;
|
|
63
|
+
/** Number of nodes that participate in keygen operation. Also known as `n`. */
|
|
38
64
|
totalNodes: number;
|
|
39
|
-
|
|
65
|
+
/** Wallet Provider backend client */
|
|
40
66
|
wp_client: IWalletProviderServiceClient;
|
|
41
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Facade class used to execute operations on Silent Network.
|
|
69
|
+
* @param wpClient - Wallet Provider backend client
|
|
70
|
+
* @param threshold - Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`.
|
|
71
|
+
* @param totalNodes - Number of nodes that participate in keygen operation. Also known as `n`.
|
|
72
|
+
* @param authModule - Authentication module, used to get confirmation from the User before request execution
|
|
73
|
+
*/
|
|
74
|
+
constructor(wpClient: IWalletProviderServiceClient, threshold: number, totalNodes: number, authModule: AuthModule);
|
|
75
|
+
/** API to generate a distributed key that's generated by Silent Network.
|
|
76
|
+
* Uses `authModule` to get authentication of the request from the User
|
|
77
|
+
* @param permissions - optional permissions that will be stored in the key metadata.
|
|
78
|
+
* The permissions are validated during sign requests.
|
|
79
|
+
* @returns {@link KeygenResponse} containing `keyId` and the `pubKey` public part of the key
|
|
80
|
+
* @public
|
|
81
|
+
* @alpha
|
|
82
|
+
*/
|
|
42
83
|
authenticateAndCreateKey(permissions?: string): Promise<KeygenResponse>;
|
|
84
|
+
/** Generate a signature. Uses `authModule` to authenticate the sign request by the User.
|
|
85
|
+
* The network chooses `t` nodes to execute the protocol.
|
|
86
|
+
* @param keyId - the key id returned from `authenticateAndCreateKey`
|
|
87
|
+
* @param message - the message to sign by the MPC network
|
|
88
|
+
* @returns {@link SignResponse}
|
|
89
|
+
* @public
|
|
90
|
+
* @alpha
|
|
91
|
+
*/
|
|
43
92
|
authenticateAndSign(keyId: string, message: string): Promise<SignResponse>;
|
|
44
93
|
}
|
|
45
94
|
//# sourceMappingURL=networkSigner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networkSigner.d.ts","sourceRoot":"","sources":["../src/networkSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC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AAM,IAAI,aAAa,CAEhG;AAED,+EAA+E;AAC/E,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI;IACxC,KAAK,EAAE,CAAC,CAAC;IACT,mBAAmB,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAa;IACxB,6FAA6F;IAC7F,UAAU,EAAE,UAAU,CAAC;IACvB,qHAAqH;IACrH,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,SAAS,EAAE,4BAA4B,CAAC;IAExC;;;;;;OAMG;gBACS,QAAQ,EAAE,4BAA4B,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAYjH;;;;;;;OAOG;IACU,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAuBpF;;;;;;;OAOG;IACU,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAexF"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { type KeygenSetupOpts, type KeygenResponse, type SignSetupOpts, type SignResponse } from './networkSigner';
|
|
2
2
|
import { type ClientConfig, IWalletProviderServiceClient, type Signer } from './walletProviderServiceClientInterface';
|
|
3
|
+
/**
|
|
4
|
+
* The Websocket client to the Wallet Provider backend service.
|
|
5
|
+
* All requests are relayed by this entity to the MPC network.
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
3
8
|
export declare class WalletProviderServiceClient implements IWalletProviderServiceClient {
|
|
4
9
|
walletProviderId: string;
|
|
5
10
|
walletProviderUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create new client that connects to the backend service
|
|
13
|
+
* @param config - config containing information about backend service
|
|
14
|
+
*/
|
|
6
15
|
constructor(config: ClientConfig);
|
|
7
16
|
getWalletId(): string;
|
|
8
17
|
startKeygen({ setup, signer }: {
|
|
@@ -13,6 +22,6 @@ export declare class WalletProviderServiceClient implements IWalletProviderServi
|
|
|
13
22
|
setup: SignSetupOpts;
|
|
14
23
|
signer: Signer;
|
|
15
24
|
}): Promise<SignResponse>;
|
|
16
|
-
connect(params: KeygenSetupOpts | SignSetupOpts, signer: Signer): Promise<
|
|
25
|
+
connect(params: KeygenSetupOpts | SignSetupOpts, signer: Signer): Promise<string>;
|
|
17
26
|
}
|
|
18
27
|
//# sourceMappingURL=walletProviderServiceClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletProviderServiceClient.d.ts","sourceRoot":"","sources":["../src/walletProviderServiceClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,KAAK,YAAY,EAAE,4BAA4B,EAAE,KAAK,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAStH,qBAAa,2BAA4B,YAAW,4BAA4B;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"walletProviderServiceClient.d.ts","sourceRoot":"","sources":["../src/walletProviderServiceClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,KAAK,YAAY,EAAE,4BAA4B,EAAE,KAAK,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAStH;;;;GAIG;AACH,qBAAa,2BAA4B,YAAW,4BAA4B;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;OAGG;gBACS,MAAM,EAAE,YAAY;IAKhC,WAAW,IAAI,MAAM;IAIf,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAYnG,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAatG,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAkFlF"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { UserAuthentication } from './authentication';
|
|
2
2
|
import { KeygenResponse, KeygenSetupOpts, SignResponse, SignSetupOpts } from './networkSigner';
|
|
3
|
+
/**
|
|
4
|
+
* The config used to create Wallet Provider Service backend client.
|
|
5
|
+
* Please refer to {@link https://shipyard.rs/silencelaboratories/crates/wallet-provider-service | example backend service}
|
|
6
|
+
* implementation for requirements that the backend service must fulfill.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
3
9
|
export type ClientConfig = {
|
|
10
|
+
/**
|
|
11
|
+
* The id of the Wallet Provider Service
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
4
14
|
walletProviderId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The URL used to connect to the service
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
5
19
|
walletProviderUrl: string;
|
|
6
|
-
secretKey: string;
|
|
7
20
|
};
|
|
8
21
|
export type Signer = (challenge: string) => Promise<UserAuthentication>;
|
|
22
|
+
/** Interface for client of Wallet Provider Service
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
9
25
|
export interface IWalletProviderServiceClient {
|
|
10
26
|
getWalletId(): string;
|
|
11
27
|
startKeygen({ setup, signer }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletProviderServiceClientInterface.d.ts","sourceRoot":"","sources":["../src/walletProviderServiceClientInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE/F,MAAM,MAAM,YAAY,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"walletProviderServiceClientInterface.d.ts","sourceRoot":"","sources":["../src/walletProviderServiceClientInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,WAAW,IAAI,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACpG,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAClG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silencelaboratories/walletprovider-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Frontend SDK for Wallet Providers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,17 +15,20 @@
|
|
|
15
15
|
"build": "bun run scripts/build.mjs && bun run build:declaration",
|
|
16
16
|
"build:declaration": "tsc -p . --emitDeclarationOnly",
|
|
17
17
|
"test": "bun test",
|
|
18
|
-
"test:watch": "bun test --watch"
|
|
18
|
+
"test:watch": "bun test --watch",
|
|
19
|
+
"docs": "bun run build:declaration && api-extractor run --local --verbose && api-documenter markdown -i ./temp -o ./docs"
|
|
19
20
|
},
|
|
20
21
|
"type": "module",
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@eslint/js": "^9.3.0",
|
|
24
|
+
"@microsoft/api-documenter": "^7.25.2",
|
|
25
|
+
"@microsoft/api-extractor": "^7.46.2",
|
|
23
26
|
"@types/bun": "^1.1.2",
|
|
24
|
-
"eslint": "
|
|
27
|
+
"eslint": "^8.x",
|
|
25
28
|
"globals": "^15.3.0",
|
|
26
29
|
"prettier": "^3.2.5",
|
|
27
30
|
"typescript": "^5.4.5",
|
|
28
|
-
"typescript-eslint": "^7.
|
|
31
|
+
"typescript-eslint": "^7.11.0"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
34
|
"@noble/secp256k1": "^2.1.0",
|