@silencelaboratories/walletprovider-sdk 0.3.0 → 0.4.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/README.md +135 -112
- package/dist/{EOAauthentication.d.ts → auth/EOAauthentication.d.ts} +14 -4
- package/dist/{authentication.d.ts → auth/authentication.d.ts} +51 -24
- package/dist/auth/ephemeralAuthentication.d.ts +44 -0
- package/dist/{passkeyAuthentication.d.ts → auth/passkeyAuthentication.d.ts} +3 -4
- package/dist/client/networkSigner.d.ts +96 -0
- package/dist/client/types.d.ts +60 -0
- package/dist/client/walletProviderServiceClient.d.ts +43 -0
- package/dist/client/walletProviderServiceClientInterface.d.ts +59 -0
- package/dist/index.cjs.js +6 -1
- package/dist/index.d.ts +30 -8
- package/dist/index.esm.js +6 -1
- package/dist/setupMessage.d.ts +77 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/encoder.d.ts +2 -0
- package/dist/utils/validator.d.ts +6 -0
- package/dist/viemSigner.d.ts +4 -4
- package/package.json +10 -6
- package/dist/encoding.d.ts +0 -3
- package/dist/ephemeralAuthentication.d.ts +0 -21
- package/dist/networkSigner.d.ts +0 -182
- package/dist/validator.d.ts +0 -3
- package/dist/walletProviderServiceClient.d.ts +0 -32
- package/dist/walletProviderServiceClientInterface.d.ts +0 -43
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SignAlgorithm } from '../auth/ephemeralAuthentication';
|
|
2
|
+
export declare const throwIfInvalidString: (key: string, value: string) => void;
|
|
3
|
+
export declare const throwIfInvalidEphPK: (ephKey: Uint8Array, signAlg: SignAlgorithm) => void;
|
|
4
|
+
export declare const throwIfInvalidEphSK: (ephKey: Uint8Array, signAlg: SignAlgorithm) => void;
|
|
5
|
+
export declare const throwIfInvalidSignAlg: (signAlg: SignAlgorithm) => void;
|
|
6
|
+
export declare const throwIf: (condition: boolean, message: string) => void;
|
package/dist/viemSigner.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { LocalAccount } from 'viem/accounts';
|
|
2
|
-
import { NetworkSigner } from './networkSigner';
|
|
2
|
+
import { NetworkSigner } from './client/networkSigner';
|
|
3
3
|
import { Address } from 'viem';
|
|
4
4
|
/**
|
|
5
5
|
* Create a new viem custom account for signing transactions using
|
|
6
6
|
* the MPC network.
|
|
7
|
-
* @param
|
|
7
|
+
* @param networkSigner API to communicate with the Silent MPC Network.
|
|
8
8
|
* @param keyId The selected Key ID.
|
|
9
9
|
* @param publicKey Associated public key of the selected Key ID.
|
|
10
|
-
* @param
|
|
10
|
+
* @param signAlg The signature algorithm for signing (default: secp256k1).
|
|
11
11
|
*/
|
|
12
|
-
export declare function createViemAccount(networkSigner: NetworkSigner, keyId: string, publicKey: string): LocalAccount;
|
|
12
|
+
export declare function createViemAccount(networkSigner: NetworkSigner, keyId: string, publicKey: string, signAlg?: string): LocalAccount;
|
|
13
13
|
/** Computes ETH address from ECDSA `publicKey` returned by Silent Network
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silencelaboratories/walletprovider-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"author": "Silence Laboratories",
|
|
5
5
|
"description": "Frontend SDK for Wallet Providers",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
+
"type": "module",
|
|
19
20
|
"scripts": {
|
|
20
21
|
"format": "prettier --write --cache .",
|
|
21
22
|
"formatcheck": "prettier --check --cache .",
|
|
22
23
|
"lint": "eslint --cache ./src/**/*.ts",
|
|
23
24
|
"typecheck": "tsc -p . --noEmit",
|
|
25
|
+
"test": "vitest",
|
|
24
26
|
"build": "node build.js && npm run build:declaration",
|
|
25
27
|
"build:declaration": "tsc -p . --emitDeclarationOnly",
|
|
26
28
|
"clean": "rimraf dist",
|
|
@@ -28,24 +30,26 @@
|
|
|
28
30
|
"docs": "npm run build:declaration && api-extractor run --local --verbose && api-documenter markdown -i ./temp -o ./docs"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@eslint/js": "
|
|
33
|
+
"@eslint/js": "9.14.0",
|
|
32
34
|
"@microsoft/api-documenter": "^7.25.2",
|
|
33
35
|
"@microsoft/api-extractor": "^7.46.2",
|
|
34
36
|
"@types/eslint-plugin-security": "^3.0.0",
|
|
35
37
|
"esbuild": "0.24.0",
|
|
36
38
|
"esbuild-node-externals": "^1.15.0",
|
|
37
|
-
"eslint": "
|
|
39
|
+
"eslint": "9.14.0",
|
|
38
40
|
"eslint-plugin-security": "^3.0.1",
|
|
39
41
|
"globals": "^15.3.0",
|
|
40
42
|
"npm-dts": "^1.3.13",
|
|
41
|
-
"prettier": "
|
|
43
|
+
"prettier": "3.3.3",
|
|
42
44
|
"rimraf": "^6.0.1",
|
|
43
45
|
"typescript": "5.6.3",
|
|
44
|
-
"typescript-eslint": "
|
|
46
|
+
"typescript-eslint": "8.13.0",
|
|
47
|
+
"vitest": "^2.1.8",
|
|
48
|
+
"@commitlint/config-conventional": "^12.1.1"
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
51
|
"@noble/curves": "^1.6.0",
|
|
48
52
|
"js-base64": "^3.7.7",
|
|
49
|
-
"viem": "2.21.
|
|
53
|
+
"viem": "2.21.54"
|
|
50
54
|
}
|
|
51
55
|
}
|
package/dist/encoding.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { UserAuthentication } from './authentication';
|
|
2
|
-
import { SignSetupOpts } from './networkSigner';
|
|
3
|
-
export declare class EphClaim {
|
|
4
|
-
ephId: string;
|
|
5
|
-
ephPK: string;
|
|
6
|
-
expiry: number;
|
|
7
|
-
constructor(ephId: string, ephPK: Uint8Array, lifetime?: number);
|
|
8
|
-
private validateInputs;
|
|
9
|
-
toJSON(): string;
|
|
10
|
-
}
|
|
11
|
-
/** Locally sign the signature requests to network without asking the user, the ephSK is registered during keygen.
|
|
12
|
-
* The signature is the authorization for signgen operation
|
|
13
|
-
*/
|
|
14
|
-
export declare function authenticateUsingEphKey({ setup, challenge, ephSK, ephClaim, }: {
|
|
15
|
-
setup: SignSetupOpts;
|
|
16
|
-
challenge: string;
|
|
17
|
-
ephSK: Uint8Array;
|
|
18
|
-
ephClaim: EphClaim;
|
|
19
|
-
}): Promise<UserAuthentication>;
|
|
20
|
-
export declare function generateEphPrivateKey(): Uint8Array;
|
|
21
|
-
export declare function getEphPublicKey(ephSK: Uint8Array): Uint8Array;
|
package/dist/networkSigner.d.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { AuthModule, UserAuthentication } from './authentication';
|
|
2
|
-
import { GetQueryPath, QueryPath, type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
3
|
-
import { EphClaim } from './ephemeralAuthentication';
|
|
4
|
-
/**
|
|
5
|
-
* Response from the network for keygen requests
|
|
6
|
-
* @alpha
|
|
7
|
-
*/
|
|
8
|
-
export interface KeygenResponse {
|
|
9
|
-
/**
|
|
10
|
-
* Unique ID of produced key used in subsequent API calls.
|
|
11
|
-
*/
|
|
12
|
-
keyId: string;
|
|
13
|
-
/**
|
|
14
|
-
* Public key encoded with SEC1 format.
|
|
15
|
-
*
|
|
16
|
-
* If point is uncompressed it's in a form of 0x04 || X || Y
|
|
17
|
-
*
|
|
18
|
-
* If point is compressed it's in a form Y || X,
|
|
19
|
-
*
|
|
20
|
-
* where Y is set to 0x02 if Y-coord is even, or 0x03 if Y-coord is odd
|
|
21
|
-
*/
|
|
22
|
-
publicKey: string;
|
|
23
|
-
/**
|
|
24
|
-
* Optional credential id used for passkey authentication.
|
|
25
|
-
*
|
|
26
|
-
* Returned by Authenticator.
|
|
27
|
-
*/
|
|
28
|
-
passkeyCredentialId?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Response from the network for sign request
|
|
32
|
-
* @alpha
|
|
33
|
-
*/
|
|
34
|
-
export interface SignResponse {
|
|
35
|
-
/**
|
|
36
|
-
* Hexstring of length 128 bytes, in a form: r || s
|
|
37
|
-
*/
|
|
38
|
-
sign: string;
|
|
39
|
-
/**
|
|
40
|
-
* Recovery id, either 0, or 1
|
|
41
|
-
*/
|
|
42
|
-
recid: number;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Response from the network for adding ephemeral key request
|
|
46
|
-
* @alpha
|
|
47
|
-
*/
|
|
48
|
-
export interface AddEphemeralKeyResponse {
|
|
49
|
-
status: string;
|
|
50
|
-
}
|
|
51
|
-
/** Key parameters used during generation */
|
|
52
|
-
export declare class KeygenSetupOpts implements GetQueryPath {
|
|
53
|
-
/** Threshold, number of parties that needs to participate in a protocol in order to produce valid signature */
|
|
54
|
-
t: number;
|
|
55
|
-
/** Total number of nodes that participate in Key generation, must be greater or equal than `t` */
|
|
56
|
-
n: number;
|
|
57
|
-
/** Optional key label */
|
|
58
|
-
key_label?: string;
|
|
59
|
-
/** Metadata for a key. Currently they store the permissions, can be set in a constructor of this class.
|
|
60
|
-
If permissions are not set, all operations are allowed.
|
|
61
|
-
*/
|
|
62
|
-
private metadata;
|
|
63
|
-
constructor({ t, n, key_label, permissions, }: {
|
|
64
|
-
t: number;
|
|
65
|
-
n: number;
|
|
66
|
-
key_label: string | undefined;
|
|
67
|
-
permissions: string | undefined;
|
|
68
|
-
});
|
|
69
|
-
set ephClaim(ephClaim: EphClaim);
|
|
70
|
-
get queryPath(): QueryPath;
|
|
71
|
-
get requestSchema(): {
|
|
72
|
-
Request: {
|
|
73
|
-
name: string;
|
|
74
|
-
type: string;
|
|
75
|
-
}[];
|
|
76
|
-
KeygenSetupOpts: {
|
|
77
|
-
name: string;
|
|
78
|
-
type: string;
|
|
79
|
-
}[];
|
|
80
|
-
TaggedValue: {
|
|
81
|
-
name: string;
|
|
82
|
-
type: string;
|
|
83
|
-
}[];
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/** Parameters used in Signature execution */
|
|
87
|
-
export declare class SignSetupOpts implements GetQueryPath {
|
|
88
|
-
/** Number of nodes that will participate in the signature execution */
|
|
89
|
-
t: number;
|
|
90
|
-
/** Select the key using it's ID */
|
|
91
|
-
key_id: string;
|
|
92
|
-
/** The message to sign */
|
|
93
|
-
message: string;
|
|
94
|
-
constructor({ t, key_id, message }: {
|
|
95
|
-
t: number;
|
|
96
|
-
key_id: string;
|
|
97
|
-
message: string;
|
|
98
|
-
});
|
|
99
|
-
get queryPath(): QueryPath;
|
|
100
|
-
}
|
|
101
|
-
export declare class AddEphemeralKeyOpts implements GetQueryPath {
|
|
102
|
-
/** Total number of nodes that participate in Adding Ephemeral Key */
|
|
103
|
-
n: number;
|
|
104
|
-
/** Select the key using it's ID */
|
|
105
|
-
key_id: string;
|
|
106
|
-
/** Metadata for a key. Currently they store the permissions, can be set in a constructor of this class.
|
|
107
|
-
If permissions are not set, all operations are allowed.
|
|
108
|
-
*/
|
|
109
|
-
private metadata;
|
|
110
|
-
constructor({ n, key_id }: {
|
|
111
|
-
n: number;
|
|
112
|
-
key_id: string;
|
|
113
|
-
});
|
|
114
|
-
set ephClaim(ephClaim: EphClaim);
|
|
115
|
-
get queryPath(): QueryPath;
|
|
116
|
-
get requestSchema(): {
|
|
117
|
-
Request: {
|
|
118
|
-
name: string;
|
|
119
|
-
type: string;
|
|
120
|
-
}[];
|
|
121
|
-
AddEphemeralKeyOpts: {
|
|
122
|
-
name: string;
|
|
123
|
-
type: string;
|
|
124
|
-
}[];
|
|
125
|
-
TaggedValue: {
|
|
126
|
-
name: string;
|
|
127
|
-
type: string;
|
|
128
|
-
}[];
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/** The `user_authentication` contains signature over the `setup` parameter. */
|
|
132
|
-
export type UserAuthenticatedRequest<T> = {
|
|
133
|
-
setup: T;
|
|
134
|
-
user_authentication: UserAuthentication;
|
|
135
|
-
};
|
|
136
|
-
/** The networkSigner contains an API to communicate with the Silent MPC Network. Call to sign and keygen require
|
|
137
|
-
* the Auth module, that is used to prompt the User before executing the request.
|
|
138
|
-
* @alpha
|
|
139
|
-
*/
|
|
140
|
-
export declare class NetworkSigner {
|
|
141
|
-
/** Authentication module, used to get confirmation from the User before request execution */
|
|
142
|
-
authModule: AuthModule;
|
|
143
|
-
/** Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`. */
|
|
144
|
-
threshold: number;
|
|
145
|
-
/** Number of nodes that participate in keygen operation. Also known as `n`. */
|
|
146
|
-
totalNodes: number;
|
|
147
|
-
/** Wallet Provider backend client */
|
|
148
|
-
wp_client: IWalletProviderServiceClient;
|
|
149
|
-
/**
|
|
150
|
-
* Facade class used to execute operations on Silent Network.
|
|
151
|
-
* @param wpClient - Wallet Provider backend client
|
|
152
|
-
* @param threshold - Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`.
|
|
153
|
-
* @param totalNodes - Number of nodes that participate in keygen operation. Also known as `n`.
|
|
154
|
-
* @param authModule - Authentication module, used to get confirmation from the User before request execution
|
|
155
|
-
*/
|
|
156
|
-
constructor(wpClient: IWalletProviderServiceClient, threshold: number, totalNodes: number, authModule: AuthModule);
|
|
157
|
-
/** Generate a distributed key that's generated by Silent Network.
|
|
158
|
-
* Uses `authModule` to authenticate the User with the Silent Network.
|
|
159
|
-
* @param permissions - optional permissions that will be stored in the key metadata.
|
|
160
|
-
* The permissions are validated during sign requests.
|
|
161
|
-
* @returns {@link KeygenResponse} containing `keyId` and the `pubKey` public part of the key
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
generateKey(permissions?: string): Promise<KeygenResponse>;
|
|
165
|
-
/** Generate a signature by the distributed key of Silent Network.
|
|
166
|
-
* Uses `authModule` to authenticate the sign request by the User.
|
|
167
|
-
* The network chooses `t` nodes to execute the protocol.
|
|
168
|
-
* @param keyId - the key id returned from `keygen`
|
|
169
|
-
* @param message - the message to sign by the MPC network
|
|
170
|
-
* @returns {@link SignResponse}
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
signMessage(keyId: string, message: string): Promise<SignResponse>;
|
|
174
|
-
/** Add new ephemeral key to an exist distributed key on the network.
|
|
175
|
-
* Uses `authModule` to authenticate the request by the User.
|
|
176
|
-
* @param keyId - the key id returned from `keygen`
|
|
177
|
-
* @returns {@link AddEphemeralKeyResponse}
|
|
178
|
-
* @public
|
|
179
|
-
*/
|
|
180
|
-
addEphemeralKey(keyId: string): Promise<AddEphemeralKeyResponse>;
|
|
181
|
-
private setEphClaimOf;
|
|
182
|
-
}
|
package/dist/validator.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AuthModule } from './authentication';
|
|
2
|
-
import { type KeygenSetupOpts, type KeygenResponse, type SignSetupOpts, type SignResponse, AddEphemeralKeyOpts, AddEphemeralKeyResponse } from './networkSigner';
|
|
3
|
-
import { type ClientConfig, IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
4
|
-
/**
|
|
5
|
-
* The Websocket client to the Wallet Provider backend service.
|
|
6
|
-
* All requests are relayed by this entity to the MPC network.
|
|
7
|
-
* @alpha
|
|
8
|
-
*/
|
|
9
|
-
export declare class WalletProviderServiceClient implements IWalletProviderServiceClient {
|
|
10
|
-
walletProviderId: string;
|
|
11
|
-
walletProviderUrl: string;
|
|
12
|
-
passkeyCredentialId?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Create new client that connects to the backend service
|
|
15
|
-
* @param config - config containing information about backend service
|
|
16
|
-
*/
|
|
17
|
-
constructor(config: ClientConfig);
|
|
18
|
-
getWalletId(): string;
|
|
19
|
-
startKeygen({ setup, authModule, }: {
|
|
20
|
-
setup: KeygenSetupOpts;
|
|
21
|
-
authModule: AuthModule;
|
|
22
|
-
}): Promise<KeygenResponse>;
|
|
23
|
-
startSigngen({ setup, authModule }: {
|
|
24
|
-
setup: SignSetupOpts;
|
|
25
|
-
authModule: AuthModule;
|
|
26
|
-
}): Promise<SignResponse>;
|
|
27
|
-
addEphemeralKey({ setup, authModule, }: {
|
|
28
|
-
setup: AddEphemeralKeyOpts;
|
|
29
|
-
authModule: AuthModule;
|
|
30
|
-
}): Promise<AddEphemeralKeyResponse>;
|
|
31
|
-
connect(setupOpts: KeygenSetupOpts | SignSetupOpts | AddEphemeralKeyOpts, authModule: AuthModule): Promise<string>;
|
|
32
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AuthModule, UserAuthentication } from './authentication';
|
|
2
|
-
import { AddEphemeralKeyOpts, KeygenResponse, KeygenSetupOpts, SignResponse, SignSetupOpts, AddEphemeralKeyResponse } 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
|
-
*/
|
|
9
|
-
export type ClientConfig = {
|
|
10
|
-
/**
|
|
11
|
-
* The id of the Wallet Provider Service
|
|
12
|
-
* @alpha
|
|
13
|
-
*/
|
|
14
|
-
walletProviderId: string;
|
|
15
|
-
/**
|
|
16
|
-
* The URL used to connect to the service
|
|
17
|
-
* @alpha
|
|
18
|
-
*/
|
|
19
|
-
walletProviderUrl: string;
|
|
20
|
-
};
|
|
21
|
-
export type Signer = (challenge: string) => Promise<UserAuthentication>;
|
|
22
|
-
/** Interface for client of Wallet Provider Service
|
|
23
|
-
* @alpha
|
|
24
|
-
*/
|
|
25
|
-
export interface IWalletProviderServiceClient {
|
|
26
|
-
getWalletId(): string;
|
|
27
|
-
startKeygen({ setup, authModule }: {
|
|
28
|
-
setup: KeygenSetupOpts;
|
|
29
|
-
authModule: AuthModule;
|
|
30
|
-
}): Promise<KeygenResponse>;
|
|
31
|
-
startSigngen({ setup, authModule }: {
|
|
32
|
-
setup: SignSetupOpts;
|
|
33
|
-
authModule: AuthModule;
|
|
34
|
-
}): Promise<SignResponse>;
|
|
35
|
-
addEphemeralKey({ setup, authModule, }: {
|
|
36
|
-
setup: AddEphemeralKeyOpts;
|
|
37
|
-
authModule: AuthModule;
|
|
38
|
-
}): Promise<AddEphemeralKeyResponse>;
|
|
39
|
-
}
|
|
40
|
-
export type QueryPath = 'signgen' | 'keygen' | 'addEphemeralKey';
|
|
41
|
-
export interface GetQueryPath {
|
|
42
|
-
get queryPath(): QueryPath;
|
|
43
|
-
}
|