@silencelaboratories/walletprovider-sdk 4.0.2-hackathon → 4.0.3-hackathon
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/package.json +1 -1
- package/dist/EOAauthentication.d.ts +0 -67
- package/dist/authentication.d.ts +0 -146
- package/dist/client/api.d.ts +0 -18
- package/dist/client/intentServiceClient.d.ts +0 -4
- package/dist/client/keyRefresher.d.ts +0 -34
- package/dist/client/types.d.ts +0 -60
- package/dist/encoding.d.ts +0 -4
- package/dist/ephemeralAuthentication.d.ts +0 -44
- package/dist/networkSigner.d.ts +0 -129
- package/dist/passkeyAuthentication.d.ts +0 -28
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/validator.d.ts +0 -6
- package/dist/walletProviderServiceClient.d.ts +0 -43
- package/dist/walletProviderServiceClientInterface.d.ts +0 -59
package/package.json
CHANGED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** Externally Owned Account (EOA) atuhentication. Uses secret key stored on a wallet to sign requests.
|
|
2
|
-
* The requests are presented to the user in a readable form by using TypedData (EIP712).
|
|
3
|
-
*/
|
|
4
|
-
import { MetadataSetupOpts, KeygenSetupOpts } from './setupMessage';
|
|
5
|
-
import { type UserAuthentication } from './authentication';
|
|
6
|
-
import { type TypedDataDomain } from 'viem';
|
|
7
|
-
import { EphKeyClaim } from './ephemeralAuthentication';
|
|
8
|
-
export type FieldDefinition = {
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
};
|
|
12
|
-
/** EIP-712 Typed data struct definition.
|
|
13
|
-
* @alpha
|
|
14
|
-
* */
|
|
15
|
-
export type TypedData<T> = {
|
|
16
|
-
/** contains the schema definition of the types that are in `msg` */
|
|
17
|
-
types: Record<string, Array<FieldDefinition>>;
|
|
18
|
-
/** is the signature domain separator */
|
|
19
|
-
domain: TypedDataDomain;
|
|
20
|
-
/** points to the type from `types`. It's the root object of `message` */
|
|
21
|
-
primaryType: string;
|
|
22
|
-
/** the request that User is asked to sign */
|
|
23
|
-
message: T;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Interface to implement communication between this library, and a Browser Wallet. In order to
|
|
27
|
-
* request the signature from the User.
|
|
28
|
-
* @alpha
|
|
29
|
-
*/
|
|
30
|
-
export interface IBrowserWallet {
|
|
31
|
-
/** Sign data using the secret key stored on Browser Wallet
|
|
32
|
-
* It creates a popup window, presenting the human readable form of `request`
|
|
33
|
-
* @param from - the address used to sign the request
|
|
34
|
-
* @param request - the request to sign by the User in the form of EIP712 typed data.
|
|
35
|
-
* @throws Throws an error if User rejected signature
|
|
36
|
-
* @example The example implementation:
|
|
37
|
-
* ```ts
|
|
38
|
-
* async signTypedData<T>(from: string, request: TypedData<T>): Promise<unknown> {
|
|
39
|
-
* return await browserWallet.request({
|
|
40
|
-
* method: 'eth_signTypedData_v4',
|
|
41
|
-
* params: [from, JSON.stringify(request)],
|
|
42
|
-
* });
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
signTypedData<T>(from: string, request: TypedData<T>): Promise<unknown>;
|
|
47
|
-
}
|
|
48
|
-
type RequestToSign<T> = {
|
|
49
|
-
setup: T;
|
|
50
|
-
challenge: string;
|
|
51
|
-
};
|
|
52
|
-
export declare const EIP712SilentShardAuthenticationDomain: {
|
|
53
|
-
name: string;
|
|
54
|
-
version: string;
|
|
55
|
-
};
|
|
56
|
-
export declare function createTypedRequest(setup: KeygenSetupOpts | MetadataSetupOpts, aggregated_challenge: string, ephClaim: EphKeyClaim): TypedData<RequestToSign<KeygenSetupOpts | MetadataSetupOpts>>;
|
|
57
|
-
/** Present the request to the User using wallet UI, and ask for sign.
|
|
58
|
-
* The signature is the authorization for keygen operation
|
|
59
|
-
*/
|
|
60
|
-
export declare function authenticateUsingEOA({ setup, eoa, challenge, browserWallet, ephClaim, }: {
|
|
61
|
-
setup: KeygenSetupOpts | MetadataSetupOpts;
|
|
62
|
-
eoa: string;
|
|
63
|
-
challenge: string;
|
|
64
|
-
browserWallet: IBrowserWallet;
|
|
65
|
-
ephClaim: EphKeyClaim;
|
|
66
|
-
}): Promise<UserAuthentication>;
|
|
67
|
-
export {};
|
package/dist/authentication.d.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { MetadataSetupOpts, KeygenSetupOpts, SignSetupOpts } from './setupMessage';
|
|
2
|
-
import { IBrowserWallet } from './EOAauthentication';
|
|
3
|
-
import { PasskeyUser, RelyingPartyConfig } from './passkeyAuthentication';
|
|
4
|
-
import { EphKeyClaim, SignAlgorithm } from './ephemeralAuthentication';
|
|
5
|
-
/** Type of the request authentication
|
|
6
|
-
* @alpha
|
|
7
|
-
*/
|
|
8
|
-
export type UserCredentials = {
|
|
9
|
-
id: string;
|
|
10
|
-
method: 'eoa' | 'ephemeral' | 'passkey';
|
|
11
|
-
credentials: string;
|
|
12
|
-
};
|
|
13
|
-
export type UserAuthentication = {
|
|
14
|
-
credentials: UserCredentials;
|
|
15
|
-
signature: string;
|
|
16
|
-
};
|
|
17
|
-
export interface AuthModule {
|
|
18
|
-
authenticate({ setup, challenge, signAlg, }: {
|
|
19
|
-
setup: KeygenSetupOpts | SignSetupOpts | MetadataSetupOpts;
|
|
20
|
-
challenge: string;
|
|
21
|
-
signAlg: string;
|
|
22
|
-
}): Promise<UserAuthentication>;
|
|
23
|
-
}
|
|
24
|
-
export interface DkgAuthModule extends AuthModule {
|
|
25
|
-
getEphClaims(): EphKeyClaim | Map<string, EphKeyClaim>;
|
|
26
|
-
}
|
|
27
|
-
/** The `EOAAuth` implementing Externally Owned Account authentication.
|
|
28
|
-
* @alpha
|
|
29
|
-
*/
|
|
30
|
-
export declare class EOAAuth implements DkgAuthModule {
|
|
31
|
-
/** An interface to the wallet, like MetaMask, that is used to sign the requests */
|
|
32
|
-
private browserWallet;
|
|
33
|
-
/** the ETH address that is used to do EOA authentication */
|
|
34
|
-
private eoa;
|
|
35
|
-
/** Ephemeral key claim populated for non batched requests*/
|
|
36
|
-
ephClaim?: EphKeyClaim;
|
|
37
|
-
/** Ephemeral key claims map contains pairs of
|
|
38
|
-
* SignatureAlgorithms and their appropriate EphKeyClaims in case of batched requests */
|
|
39
|
-
ephClaims?: Map<string, EphKeyClaim>;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param eoa - Ethereum address
|
|
43
|
-
* @param browserWallet - Interface to the wallet provider, like MetaMask, that is used to sign the requests
|
|
44
|
-
* @param ephClaimOptions - Either EphKeyClaim or Map of SignatureAlgorithms and their appropriate EphKeyClaims
|
|
45
|
-
*/
|
|
46
|
-
constructor(eoa: string, browserWallet: IBrowserWallet, ephClaimOptions: {
|
|
47
|
-
ephClaim?: EphKeyClaim;
|
|
48
|
-
ephClaims?: Map<string, EphKeyClaim>;
|
|
49
|
-
});
|
|
50
|
-
private validateInputs;
|
|
51
|
-
getEphClaims(): EphKeyClaim | Map<string, EphKeyClaim>;
|
|
52
|
-
/**
|
|
53
|
-
* Prepares a message to present on the Browser Wallet window and requests to sign it.
|
|
54
|
-
* @param setup - Keygen setup options
|
|
55
|
-
* @param challenge - the challenge received from the backend
|
|
56
|
-
* @param signAlg - signature algorithm of the EphKeyClaim used for authentication
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
authenticate({ setup, challenge, signAlg, }: {
|
|
60
|
-
setup: KeygenSetupOpts | MetadataSetupOpts;
|
|
61
|
-
challenge: string;
|
|
62
|
-
signAlg: string;
|
|
63
|
-
}): Promise<UserAuthentication>;
|
|
64
|
-
}
|
|
65
|
-
/** The `EphAuth` module is only used for signing requests to the network.
|
|
66
|
-
* @alpha
|
|
67
|
-
* An Ephmeral key used to locally sign the signature requests to network.
|
|
68
|
-
* This eph key is registered during keygen. The key is used to sign the requests without
|
|
69
|
-
* asking the user to sign the request each time.
|
|
70
|
-
* */
|
|
71
|
-
export declare class EphAuth implements AuthModule {
|
|
72
|
-
/** Secret key of the ephemeral keypair */
|
|
73
|
-
private ephSK;
|
|
74
|
-
/** Ephemeral key claim */
|
|
75
|
-
private ephClaim;
|
|
76
|
-
/**
|
|
77
|
-
*
|
|
78
|
-
* @param ephId - Ephemeral key ID
|
|
79
|
-
* @param ephSK - Ephemeral secret key
|
|
80
|
-
* @param signAlg - Signature algorithm
|
|
81
|
-
*/
|
|
82
|
-
constructor(ephId: string, ephSK: Uint8Array, signAlg: SignAlgorithm);
|
|
83
|
-
/**
|
|
84
|
-
* Prepares a message to present on the Browser Wallet window and requests to sign it.
|
|
85
|
-
* @param setup - Signgen setup options
|
|
86
|
-
* @param challenge - the challenge received from the backend
|
|
87
|
-
*
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
authenticate({ setup, challenge, }: {
|
|
91
|
-
setup: SignSetupOpts | MetadataSetupOpts;
|
|
92
|
-
challenge: string;
|
|
93
|
-
signAlg: string;
|
|
94
|
-
}): Promise<UserAuthentication>;
|
|
95
|
-
}
|
|
96
|
-
/** The `AuthModule` implementing Passkey authentication.
|
|
97
|
-
* @alpha
|
|
98
|
-
*/
|
|
99
|
-
export declare class PasskeyAuth implements DkgAuthModule {
|
|
100
|
-
/** Replying party object. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp */
|
|
101
|
-
private rpConfig;
|
|
102
|
-
/** ID of the acceptable credential by user. App proves that user has passkey credential by passing the value of this field */
|
|
103
|
-
private allowCredentialId;
|
|
104
|
-
/** Ephemeral key claim populated for non batched requests*/
|
|
105
|
-
ephClaim?: EphKeyClaim;
|
|
106
|
-
/** Ephemeral key claims map contains pairs of
|
|
107
|
-
* SignatureAlgorithms and their appropriate EphKeyClaims in case of batched requests */
|
|
108
|
-
ephClaims?: Map<string, EphKeyClaim>;
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
* @param rpConfig - Passkey relying party configuration. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp
|
|
112
|
-
* @param allowCredentialId - ID of the acceptable credential by user. App proves that user has passkey credential by passing the value of this field
|
|
113
|
-
* @param ephClaimOptions - Either EphKeyClaim or Map of SignatureAlgorithms and their appropriate EphKeyClaims
|
|
114
|
-
*/
|
|
115
|
-
constructor(rpConfig: RelyingPartyConfig, allowCredentialId: string, ephClaimOptions: {
|
|
116
|
-
ephClaim?: EphKeyClaim;
|
|
117
|
-
ephClaims?: Map<string, EphKeyClaim>;
|
|
118
|
-
});
|
|
119
|
-
private validateInputs;
|
|
120
|
-
getEphClaims(): EphKeyClaim | Map<string, EphKeyClaim>;
|
|
121
|
-
authenticate({ setup, challenge, signAlg, }: {
|
|
122
|
-
setup: KeygenSetupOpts | MetadataSetupOpts;
|
|
123
|
-
challenge: string;
|
|
124
|
-
signAlg: string;
|
|
125
|
-
}): Promise<UserAuthentication>;
|
|
126
|
-
}
|
|
127
|
-
/** The `AuthModule` implementing Passkey register.
|
|
128
|
-
* @alpha
|
|
129
|
-
*/
|
|
130
|
-
export declare class PasskeyRegister implements AuthModule {
|
|
131
|
-
/** Replying party object. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp */
|
|
132
|
-
private rpConfig;
|
|
133
|
-
/** Passkey user information, only requires while registering. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#user */
|
|
134
|
-
private user;
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* @param rpConfig - Passkey relying party configuration. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp
|
|
138
|
-
* @param user - Passkey user information, only requires while registering. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#user
|
|
139
|
-
*/
|
|
140
|
-
constructor(rpConfig: RelyingPartyConfig, user: PasskeyUser);
|
|
141
|
-
authenticate({ setup, challenge, }: {
|
|
142
|
-
setup: MetadataSetupOpts;
|
|
143
|
-
challenge: string;
|
|
144
|
-
signAlg: string;
|
|
145
|
-
}): Promise<UserAuthentication>;
|
|
146
|
-
}
|
package/dist/client/api.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface RequestOptions extends RequestInit {
|
|
2
|
-
headers?: Record<string, string>;
|
|
3
|
-
}
|
|
4
|
-
export declare class HttpClient {
|
|
5
|
-
private readonly baseURL;
|
|
6
|
-
private defaultHeaders;
|
|
7
|
-
constructor(baseURL?: string);
|
|
8
|
-
setDefaultHeaders(headers: Record<string, string>): void;
|
|
9
|
-
private buildUrl;
|
|
10
|
-
private handleResponse;
|
|
11
|
-
private request;
|
|
12
|
-
get<T>(endpoint: string, options?: RequestOptions): Promise<T>;
|
|
13
|
-
post<T, D = unknown>(endpoint: string, data: D, options?: RequestOptions): Promise<T>;
|
|
14
|
-
put<T, D = unknown>(endpoint: string, data: D, options?: RequestOptions): Promise<T>;
|
|
15
|
-
patch<T, D = unknown>(endpoint: string, data: D, options?: RequestOptions): Promise<T>;
|
|
16
|
-
delete<T>(endpoint: string, options?: RequestOptions): Promise<T>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AuthModule } from '../auth/authentication';
|
|
2
|
-
import { type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
3
|
-
import { KeyRefreshResponse } from './networkResponse';
|
|
4
|
-
import { MPCSignAlgorithm } from './networkSigner';
|
|
5
|
-
/** The NetworkKeyRefresher contains API to run key refresh towards Silent Network.
|
|
6
|
-
* the Auth module, that is used to prompt the User before executing the request.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare class NetworkKeyRefresher {
|
|
10
|
-
/** Authentication module, used to get confirmation from the User before request execution */
|
|
11
|
-
authModule: AuthModule;
|
|
12
|
-
/** Number of nodes that needs to participate in DSG. New `t` of (t;n) setup for this key. */
|
|
13
|
-
newThreshold: number;
|
|
14
|
-
/** Number of nodes that participate in key refresh operation. New `n` of (t;n) setup for this key. */
|
|
15
|
-
newTotalNodes: number;
|
|
16
|
-
/** Wallet Provider backend client */
|
|
17
|
-
wpClient: IWalletProviderServiceClient;
|
|
18
|
-
/**
|
|
19
|
-
* Facade class used to execute key refresh on Silent Network.
|
|
20
|
-
* @param wpClient - Wallet Provider backend client
|
|
21
|
-
* @param newThreshold - Number of nodes that needs to participate in DSG. New `t` of (t;n) setup for this key.
|
|
22
|
-
* @param newTotalNodes - Number of nodes that participate in key refresh operation. New `n` of (t;n) setup for this key.
|
|
23
|
-
* @param authModule - Authentication module, used to get confirmation from the User before request execution
|
|
24
|
-
*/
|
|
25
|
-
constructor(wpClient: IWalletProviderServiceClient, newThreshold: number, newTotalNodes: number, authModule: AuthModule);
|
|
26
|
-
/** Generate a distributed key that's generated by Silent Network.
|
|
27
|
-
* Uses `authModule` to authenticate the User with the Silent Network.
|
|
28
|
-
* @param keyId - the key id returned from `keygen`
|
|
29
|
-
* @param signAlg - signature algorithm of the refresh key.
|
|
30
|
-
* @returns {@link KeyRefreshResponse} containing `keyId`, `pubKey`,
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
refreshKey(keyId: string, signAlg: MPCSignAlgorithm): Promise<KeyRefreshResponse>;
|
|
34
|
-
}
|
package/dist/client/types.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Response from the network for keygen requests
|
|
3
|
-
* @alpha
|
|
4
|
-
*/
|
|
5
|
-
export interface KeygenResponse {
|
|
6
|
-
/**
|
|
7
|
-
* Unique ID of produced key used in subsequent API calls.
|
|
8
|
-
*/
|
|
9
|
-
keyId: string;
|
|
10
|
-
/**
|
|
11
|
-
* Public key encoded with SEC1 format.
|
|
12
|
-
*
|
|
13
|
-
* If point is uncompressed it's in a form of 0x04 || X || Y
|
|
14
|
-
*
|
|
15
|
-
* If point is compressed it's in a form Y || X,
|
|
16
|
-
*
|
|
17
|
-
* where Y is set to 0x02 if Y-coord is even, or 0x03 if Y-coord is odd
|
|
18
|
-
*/
|
|
19
|
-
publicKey: string;
|
|
20
|
-
/**
|
|
21
|
-
* Signature algorithm that uses this key for signing
|
|
22
|
-
*/
|
|
23
|
-
signAlg: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Response from the network for sign request
|
|
27
|
-
* @alpha
|
|
28
|
-
*/
|
|
29
|
-
export interface SignResponse {
|
|
30
|
-
transactionId: string;
|
|
31
|
-
/**
|
|
32
|
-
* Hexstring of length 128 bytes, in a form: r || s
|
|
33
|
-
*/
|
|
34
|
-
sign: string;
|
|
35
|
-
/**
|
|
36
|
-
* Recovery id, either 0, or 1
|
|
37
|
-
*/
|
|
38
|
-
recid: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Response from the network for adding ephemeral key request
|
|
42
|
-
* @alpha
|
|
43
|
-
*/
|
|
44
|
-
export interface OperationStatusResponse {
|
|
45
|
-
/**
|
|
46
|
-
* Status of the request.
|
|
47
|
-
*/
|
|
48
|
-
status: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Response from the network for registering passkey request
|
|
52
|
-
* @alpha
|
|
53
|
-
*/
|
|
54
|
-
export interface RegisterPasskeyResponse {
|
|
55
|
-
/**
|
|
56
|
-
* The registered passkey credential id. This helps both the user and the network to identify the passkey.
|
|
57
|
-
* @alpha
|
|
58
|
-
*/
|
|
59
|
-
passkeyCredentialId: string;
|
|
60
|
-
}
|
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/networkSigner.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { AuthModule } from './authentication';
|
|
2
|
-
import { type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
3
|
-
/**
|
|
4
|
-
* Response from the network for keygen requests
|
|
5
|
-
* @alpha
|
|
6
|
-
*/
|
|
7
|
-
export interface KeygenResponse {
|
|
8
|
-
/**
|
|
9
|
-
* Unique ID of produced key used in subsequent API calls.
|
|
10
|
-
*/
|
|
11
|
-
keyId: string;
|
|
12
|
-
/**
|
|
13
|
-
* Public key encoded with SEC1 format.
|
|
14
|
-
*
|
|
15
|
-
* If point is uncompressed it's in a form of 0x04 || X || Y
|
|
16
|
-
*
|
|
17
|
-
* If point is compressed it's in a form Y || X,
|
|
18
|
-
*
|
|
19
|
-
* where Y is set to 0x02 if Y-coord is even, or 0x03 if Y-coord is odd
|
|
20
|
-
*/
|
|
21
|
-
publicKey: string;
|
|
22
|
-
/**
|
|
23
|
-
* Signature algorithm that uses this key for signing
|
|
24
|
-
*/
|
|
25
|
-
signAlg: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Response from the network for sign request
|
|
29
|
-
* @alpha
|
|
30
|
-
*/
|
|
31
|
-
export interface SignResponse {
|
|
32
|
-
/**
|
|
33
|
-
* Hexstring of length 128 bytes, in a form: r || s
|
|
34
|
-
*/
|
|
35
|
-
sign: string;
|
|
36
|
-
/**
|
|
37
|
-
* Recovery id, either 0, or 1
|
|
38
|
-
*/
|
|
39
|
-
recid: number;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Response from the network for adding ephemeral key request
|
|
43
|
-
* @alpha
|
|
44
|
-
*/
|
|
45
|
-
export interface OperationStatusResponse {
|
|
46
|
-
/**
|
|
47
|
-
* Status of the request.
|
|
48
|
-
*/
|
|
49
|
-
status: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Response from the network for registering passkey request
|
|
53
|
-
* @alpha
|
|
54
|
-
*/
|
|
55
|
-
export interface RegisterPasskeyResponse {
|
|
56
|
-
/**
|
|
57
|
-
* The registered passkey credential id. This helps both the user and the network to identify the passkey.
|
|
58
|
-
* @alpha
|
|
59
|
-
*/
|
|
60
|
-
passkeyCredentialId: string;
|
|
61
|
-
}
|
|
62
|
-
/** The networkSigner contains an API to communicate with the Silent MPC Network. Call to sign and keygen require
|
|
63
|
-
* the Auth module, that is used to prompt the User before executing the request.
|
|
64
|
-
* @alpha
|
|
65
|
-
*/
|
|
66
|
-
export declare class NetworkSigner {
|
|
67
|
-
/** Authentication module, used to get confirmation from the User before request execution */
|
|
68
|
-
authModule: AuthModule;
|
|
69
|
-
/** Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`. */
|
|
70
|
-
threshold: number;
|
|
71
|
-
/** Number of nodes that participate in keygen operation. Also known as `n`. */
|
|
72
|
-
totalNodes: number;
|
|
73
|
-
/** Wallet Provider backend client */
|
|
74
|
-
wpClient: IWalletProviderServiceClient;
|
|
75
|
-
/**
|
|
76
|
-
* Facade class used to execute operations on Silent Network.
|
|
77
|
-
* @param wpClient - Wallet Provider backend client
|
|
78
|
-
* @param threshold - Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`.
|
|
79
|
-
* @param totalNodes - Number of nodes that participate in keygen operation. Also known as `n`.
|
|
80
|
-
* @param authModule - Authentication module, used to get confirmation from the User before request execution
|
|
81
|
-
*/
|
|
82
|
-
constructor(wpClient: IWalletProviderServiceClient, threshold: number, totalNodes: number, authModule: AuthModule);
|
|
83
|
-
/** Generate a distributed key that's generated by Silent Network.
|
|
84
|
-
* Uses `authModule` to authenticate the User with the Silent Network.
|
|
85
|
-
* @param signAlgs - signature algorithms for which MPC keys will be generated.
|
|
86
|
-
* @param permissions - optional permissions that will be stored in the key metadata.
|
|
87
|
-
* The permissions are validated during sign requests.
|
|
88
|
-
* @returns {@link KeygenResponse} containing `keyId` and the `pubKey` public part of the key
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
generateKey(signAlgs: string[], permissions?: string): Promise<KeygenResponse[]>;
|
|
92
|
-
/** Generate a signature by the distributed key of Silent Network.
|
|
93
|
-
* Uses `authModule` to authenticate the sign request by the User.
|
|
94
|
-
* The network chooses `t` nodes to execute the protocol.
|
|
95
|
-
* @param keyId - the key id returned from `keygen`
|
|
96
|
-
* @param signAlg - the signature algorithm to use for MPC signing, different form signAlg inside EphKeyClaim
|
|
97
|
-
* @param message - the message to sign by the MPC network
|
|
98
|
-
* @returns {@link SignResponse}
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
signMessage(keyId: string, signAlg: string, message: string): Promise<SignResponse>;
|
|
102
|
-
/** Add new ephemeral key to an exist distributed key on the network.
|
|
103
|
-
* Uses `authModule` to authenticate the request by the User.
|
|
104
|
-
* @param keyId - the key id returned from `keygen`
|
|
105
|
-
* @returns {@link OperationStatusResponse}
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
108
|
-
addEphemeralKey(keyId: string): Promise<OperationStatusResponse>;
|
|
109
|
-
/** Revoke ephemeral key of an exist distributed key on the network.
|
|
110
|
-
* Uses `authModule` to authenticate the request by the User.
|
|
111
|
-
* @param keyId - the key id returned from `keygen`
|
|
112
|
-
* @returns {@link OperationStatusResponse}
|
|
113
|
-
* @public
|
|
114
|
-
*/
|
|
115
|
-
revokeEphemeralKey(keyId: string): Promise<OperationStatusResponse>;
|
|
116
|
-
/** Register new user's passkey on the network. This will try to register to all the available nodes on the network.
|
|
117
|
-
* Uses `authModule` to authenticate the request by the User.
|
|
118
|
-
* @returns {@link RegisterPasskeyResponse}
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
registerPasskey(): Promise<RegisterPasskeyResponse>;
|
|
122
|
-
private setEphClaimOf;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
*
|
|
126
|
-
* @param signgenResponse - response from the network for sign request
|
|
127
|
-
* @returns - flattened signature in a form: 0x{signature}{recover_id}
|
|
128
|
-
*/
|
|
129
|
-
export declare const flattenSignature: (signgenResponse: SignResponse) => `0x${string}`;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { UserAuthentication } from './authentication';
|
|
2
|
-
import { EphKeyClaim } from './ephemeralAuthentication';
|
|
3
|
-
/** Information about the user currently registering. Read more: https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-user
|
|
4
|
-
* @alpha
|
|
5
|
-
* */
|
|
6
|
-
export type PasskeyUser = {
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
displayName: string;
|
|
10
|
-
};
|
|
11
|
-
/** The RP responsible for registering and authenticating the user. Read more: https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-rp
|
|
12
|
-
* @alpha
|
|
13
|
-
* */
|
|
14
|
-
export type RelyingPartyConfig = {
|
|
15
|
-
rpName: string;
|
|
16
|
-
rpId: string;
|
|
17
|
-
};
|
|
18
|
-
export declare function passkeyRegister({ user, challenge, rpConfig, }: {
|
|
19
|
-
user: PasskeyUser;
|
|
20
|
-
challenge: string;
|
|
21
|
-
rpConfig: RelyingPartyConfig;
|
|
22
|
-
}): Promise<UserAuthentication>;
|
|
23
|
-
export declare function passkeyLogin({ challenge, allowCredentialId, rpConfig, ephClaim, }: {
|
|
24
|
-
challenge: string;
|
|
25
|
-
allowCredentialId: string | null;
|
|
26
|
-
rpConfig: RelyingPartyConfig;
|
|
27
|
-
ephClaim: EphKeyClaim;
|
|
28
|
-
}): Promise<UserAuthentication>;
|
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.55.1"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
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({ setups, authModule, }: {
|
|
22
|
-
setups: 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({ setups, authModule }: {
|
|
39
|
-
setups: 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';
|