@silencelaboratories/walletprovider-sdk 1.3.0 → 1.4.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/LICENSE +103 -0
- package/README.md +89 -32
- package/dist/{EOAauthentication.d.ts → auth/EOAauthentication.d.ts} +13 -10
- package/dist/{authentication.d.ts → auth/authentication.d.ts} +56 -38
- package/dist/auth/ephemeralAuthentication.d.ts +58 -0
- package/dist/{passkeyAuthentication.d.ts → auth/passkeyAuthentication.d.ts} +2 -2
- package/dist/builder/signRequest.d.ts +28 -0
- package/dist/builder/userAuth.d.ts +28 -0
- package/dist/client/ethUtil.d.ts +8 -0
- package/dist/client/httpClient.d.ts +23 -0
- package/dist/client/networkRequest.d.ts +82 -0
- package/dist/client/networkResponse.d.ts +118 -0
- package/dist/{networkSigner.d.ts → client/networkSigner.d.ts} +35 -72
- package/dist/client/walletProviderServiceClient.d.ts +46 -0
- package/dist/client/walletProviderServiceClientInterface.d.ts +64 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +35 -13
- package/dist/index.esm.js +1 -1
- package/dist/setupMessage.d.ts +25 -32
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/encoder.d.ts +7 -0
- package/dist/utils/validator.d.ts +7 -0
- package/dist/viemSigner.d.ts +13 -4
- package/package.json +6 -3
- package/dist/encoding.d.ts +0 -4
- package/dist/ephemeralAuthentication.d.ts +0 -44
- package/dist/validator.d.ts +0 -6
- package/dist/walletProviderServiceClient.d.ts +0 -43
- package/dist/walletProviderServiceClientInterface.d.ts +0 -59
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EphKeySignAlgorithm } from '../auth/ephemeralAuthentication';
|
|
2
|
+
import { MPCSignAlgorithm } from '../client/networkSigner';
|
|
3
|
+
export declare const throwIfInvalidString: (key: string, value: string) => void;
|
|
4
|
+
export declare const throwIfInvalidEphPK: (ephKey: Uint8Array, signAlg: EphKeySignAlgorithm) => void;
|
|
5
|
+
export declare const throwIfInvalidEphSK: (ephKey: Uint8Array, signAlg: EphKeySignAlgorithm) => void;
|
|
6
|
+
export declare const throwIfInvalidMPCSignAlg: (signAlg: MPCSignAlgorithm) => void;
|
|
7
|
+
export declare const throwIf: (condition: boolean, message: string) => void;
|
package/dist/viemSigner.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { LocalAccount } from 'viem/accounts';
|
|
2
|
-
import { NetworkSigner } from './networkSigner';
|
|
2
|
+
import { MPCSignAlgorithm, NetworkSigner } from './client/networkSigner';
|
|
3
3
|
import { Address } from 'viem';
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating a distributed signing request for signing transactions using Silent Network.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface DSGOpts {
|
|
9
|
+
threshold: number;
|
|
10
|
+
keyId: string;
|
|
11
|
+
signAlg: MPCSignAlgorithm;
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Create a new viem custom account for signing transactions using
|
|
6
15
|
* the MPC network.
|
|
7
|
-
* @param
|
|
16
|
+
* @param networkSigner API to communicate with the Silent MPC Network.
|
|
8
17
|
* @param keyId The selected Key ID.
|
|
9
18
|
* @param publicKey Associated public key of the selected Key ID.
|
|
10
|
-
* @param
|
|
19
|
+
* @param signAlg The signature algorithm for signing (default: secp256k1).
|
|
11
20
|
*/
|
|
12
|
-
export declare function createViemAccount(networkSigner: NetworkSigner,
|
|
21
|
+
export declare function createViemAccount(networkSigner: NetworkSigner, publicKey: string, dsgOpts: DSGOpts): LocalAccount;
|
|
13
22
|
/** Computes ETH address from ECDSA `publicKey` returned by Silent Network
|
|
14
23
|
* @public
|
|
15
24
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silencelaboratories/walletprovider-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"author": "Silence Laboratories",
|
|
5
5
|
"description": "Frontend SDK for Wallet Providers",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
@@ -16,12 +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",
|
|
24
|
-
"test": "vitest",
|
|
25
|
+
"test": "vitest run",
|
|
25
26
|
"build": "node build.js && npm run build:declaration",
|
|
26
27
|
"build:declaration": "tsc -p . --emitDeclarationOnly",
|
|
27
28
|
"clean": "rimraf dist",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"docs": "npm run build:declaration && api-extractor run --local --verbose && api-documenter markdown -i ./temp -o ./docs"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
33
|
+
"@commitlint/config-conventional": "^12.1.1",
|
|
32
34
|
"@eslint/js": "9.14.0",
|
|
33
35
|
"@microsoft/api-documenter": "^7.25.2",
|
|
34
36
|
"@microsoft/api-extractor": "^7.46.2",
|
|
@@ -43,11 +45,12 @@
|
|
|
43
45
|
"rimraf": "^6.0.1",
|
|
44
46
|
"typescript": "5.6.3",
|
|
45
47
|
"typescript-eslint": "8.13.0",
|
|
46
|
-
"vitest": "^2.1.
|
|
48
|
+
"vitest": "^2.1.8"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
51
|
"@noble/curves": "^1.6.0",
|
|
50
52
|
"js-base64": "^3.7.7",
|
|
53
|
+
"json-canonicalize": "^1.0.6",
|
|
51
54
|
"viem": "2.21.54"
|
|
52
55
|
}
|
|
53
56
|
}
|
package/dist/encoding.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const decodeBase64: (b64: string) => Uint8Array;
|
|
2
|
-
export declare const encodeBase64: (b: Uint8Array) => string;
|
|
3
|
-
export declare const arrayBufferToBase64Url: (a: ArrayBuffer) => string;
|
|
4
|
-
export declare const calculateFinalChallenge: (setupOpts: string) => string;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { UserAuthentication } from './authentication';
|
|
2
|
-
import { SignSetupOpts } from './setupMessage';
|
|
3
|
-
/**
|
|
4
|
-
* Supported signature algorithms for ephemeral key
|
|
5
|
-
* @alpha
|
|
6
|
-
*/
|
|
7
|
-
export type SignAlgorithm = 'ed25519' | 'secp256k1';
|
|
8
|
-
/** The `EphKeyClaim` object represents the public claim of the ephemeral key.
|
|
9
|
-
* @alpha
|
|
10
|
-
*/
|
|
11
|
-
export declare class EphKeyClaim {
|
|
12
|
-
ephId: string;
|
|
13
|
-
ephPK: string;
|
|
14
|
-
signAlg: SignAlgorithm;
|
|
15
|
-
expiry: number;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param ephId - Ephemeral key ID
|
|
19
|
-
* @param ephPK - Ephemeral public key
|
|
20
|
-
* @param signAlg - Signature algorithm.
|
|
21
|
-
* @param lifetime - Lifetime of the ephemeral key. Default is 1 hour
|
|
22
|
-
*/
|
|
23
|
-
constructor(ephId: string, ephPK: Uint8Array, signAlg: SignAlgorithm, lifetime?: number);
|
|
24
|
-
private validateInputs;
|
|
25
|
-
toJSON(): string;
|
|
26
|
-
}
|
|
27
|
-
/** Locally sign the signature requests to network without asking the user, the ephSK is registered during keygen.
|
|
28
|
-
* The signature is the authorization for signgen operation
|
|
29
|
-
*/
|
|
30
|
-
export declare function authenticateUsingEphKey({ setup, challenge, ephSK, ephClaim, }: {
|
|
31
|
-
setup: SignSetupOpts;
|
|
32
|
-
challenge: string;
|
|
33
|
-
ephSK: Uint8Array;
|
|
34
|
-
ephClaim: EphKeyClaim;
|
|
35
|
-
}): Promise<UserAuthentication>;
|
|
36
|
-
export declare function genHexSignature(msg: Uint8Array, ephSK: Uint8Array, signAlg: SignAlgorithm): Promise<string>;
|
|
37
|
-
/** Generate Ephemeral `privateKey`
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export declare function generateEphPrivateKey(algSign: SignAlgorithm): Uint8Array;
|
|
41
|
-
/** Derive Ephemeral `publicKey` from `privateKey` returned from `generateEphPrivateKey`
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export declare function getEphPublicKey(ephSK: Uint8Array, algSign: SignAlgorithm): Uint8Array;
|
package/dist/validator.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SignAlgorithm } from './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;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AuthModule, DkgAuthModule } from './authentication';
|
|
2
|
-
import { type KeygenResponse, type SignResponse, type OperationStatusResponse, type RegisterPasskeyResponse } from './networkSigner';
|
|
3
|
-
import { MetadataSetupOpts, KeygenSetupOpts, SignSetupOpts } from './setupMessage';
|
|
4
|
-
import { ApiVersion, type ClientConfig, IWalletProviderServiceClient, QueryPath } from './walletProviderServiceClientInterface';
|
|
5
|
-
/**
|
|
6
|
-
* The Websocket client to the Wallet Provider backend service.
|
|
7
|
-
* All requests are relayed by this entity to the MPC network.
|
|
8
|
-
* @alpha
|
|
9
|
-
*/
|
|
10
|
-
export declare class WalletProviderServiceClient implements IWalletProviderServiceClient {
|
|
11
|
-
walletProviderId: string;
|
|
12
|
-
walletProviderUrl: string;
|
|
13
|
-
apiVersion: ApiVersion;
|
|
14
|
-
/**
|
|
15
|
-
* Create new client that connects to the backend service
|
|
16
|
-
* @param config - config containing information about backend service
|
|
17
|
-
*/
|
|
18
|
-
constructor(config: ClientConfig);
|
|
19
|
-
getVersion(): ApiVersion;
|
|
20
|
-
getWalletId(): string;
|
|
21
|
-
startKeygen({ setup, authModule, }: {
|
|
22
|
-
setup: KeygenSetupOpts;
|
|
23
|
-
authModule: DkgAuthModule;
|
|
24
|
-
}): Promise<KeygenResponse>;
|
|
25
|
-
startSigngen({ setup, authModule }: {
|
|
26
|
-
setup: SignSetupOpts;
|
|
27
|
-
authModule: AuthModule;
|
|
28
|
-
}): Promise<SignResponse>;
|
|
29
|
-
addEphemeralKey({ setup, authModule, }: {
|
|
30
|
-
setup: MetadataSetupOpts;
|
|
31
|
-
authModule: DkgAuthModule;
|
|
32
|
-
}): Promise<OperationStatusResponse>;
|
|
33
|
-
revokeEphemeralKey({ setup, authModule, }: {
|
|
34
|
-
setup: MetadataSetupOpts;
|
|
35
|
-
authModule: AuthModule;
|
|
36
|
-
}): Promise<OperationStatusResponse>;
|
|
37
|
-
registerPasskey({ setup, authModule, }: {
|
|
38
|
-
setup: MetadataSetupOpts;
|
|
39
|
-
authModule: AuthModule;
|
|
40
|
-
}): Promise<RegisterPasskeyResponse>;
|
|
41
|
-
connect(path: QueryPath, setupOpts: KeygenSetupOpts | SignSetupOpts | MetadataSetupOpts, authModule: AuthModule): Promise<string>;
|
|
42
|
-
connectV2(path: QueryPath, setupOpts: KeygenSetupOpts | SignSetupOpts | MetadataSetupOpts, authModule: AuthModule): Promise<string>;
|
|
43
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { AuthModule, UserAuthentication } from './authentication';
|
|
2
|
-
import { KeygenResponse, SignResponse, OperationStatusResponse, RegisterPasskeyResponse } from './networkSigner';
|
|
3
|
-
import { MetadataSetupOpts, KeygenSetupOpts, SignSetupOpts } from './setupMessage';
|
|
4
|
-
/**
|
|
5
|
-
* The config used to create Wallet Provider Service backend client.
|
|
6
|
-
* Please refer to {@link https://shipyard.rs/silencelaboratories/crates/wallet-provider-service | example backend service}
|
|
7
|
-
* implementation for requirements that the backend service must fulfill.
|
|
8
|
-
* @alpha
|
|
9
|
-
*/
|
|
10
|
-
export type ClientConfig = {
|
|
11
|
-
/**
|
|
12
|
-
* The version of the API used to connect to the service
|
|
13
|
-
*/
|
|
14
|
-
apiVersion: ApiVersion;
|
|
15
|
-
/**
|
|
16
|
-
* The id of the Wallet Provider Service
|
|
17
|
-
* @alpha
|
|
18
|
-
*/
|
|
19
|
-
walletProviderId: string;
|
|
20
|
-
/**
|
|
21
|
-
* The URL used to connect to the service
|
|
22
|
-
* @alpha
|
|
23
|
-
*/
|
|
24
|
-
walletProviderUrl: string;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* The API version of the Wallet Provider Service
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
export type ApiVersion = 'v1' | 'v2';
|
|
31
|
-
export type Signer = (challenge: string) => Promise<UserAuthentication>;
|
|
32
|
-
/** Interface for client of Wallet Provider Service
|
|
33
|
-
* @alpha
|
|
34
|
-
*/
|
|
35
|
-
export interface IWalletProviderServiceClient {
|
|
36
|
-
getWalletId(): string;
|
|
37
|
-
getVersion(): ApiVersion;
|
|
38
|
-
startKeygen({ setup, authModule }: {
|
|
39
|
-
setup: KeygenSetupOpts;
|
|
40
|
-
authModule: AuthModule;
|
|
41
|
-
}): Promise<KeygenResponse>;
|
|
42
|
-
startSigngen({ setup, authModule }: {
|
|
43
|
-
setup: SignSetupOpts;
|
|
44
|
-
authModule: AuthModule;
|
|
45
|
-
}): Promise<SignResponse>;
|
|
46
|
-
addEphemeralKey({ setup, authModule, }: {
|
|
47
|
-
setup: MetadataSetupOpts;
|
|
48
|
-
authModule: AuthModule;
|
|
49
|
-
}): Promise<OperationStatusResponse>;
|
|
50
|
-
revokeEphemeralKey({ setup, authModule, }: {
|
|
51
|
-
setup: MetadataSetupOpts;
|
|
52
|
-
authModule: AuthModule;
|
|
53
|
-
}): Promise<OperationStatusResponse>;
|
|
54
|
-
registerPasskey({ setup, authModule, }: {
|
|
55
|
-
setup: MetadataSetupOpts;
|
|
56
|
-
authModule: AuthModule;
|
|
57
|
-
}): Promise<RegisterPasskeyResponse>;
|
|
58
|
-
}
|
|
59
|
-
export type QueryPath = 'signgen' | 'keygen' | 'addEphemeralKey' | 'revokeEphemeralKey' | 'registerPasskey';
|