@silencelaboratories/walletprovider-sdk 1.4.0 → 1.6.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/README.md +130 -121
- package/dist/auth/EOAauthentication.d.ts +2 -5
- package/dist/auth/authentication.d.ts +5 -10
- package/dist/auth/ephemeralAuthentication.d.ts +2 -2
- package/dist/auth/passkeyAuthentication.d.ts +1 -3
- package/dist/builder/userAuth.d.ts +2 -1
- package/dist/client/networkRequest.d.ts +5 -2
- package/dist/client/networkSigner.d.ts +11 -7
- package/dist/client/walletProviderServiceClient.d.ts +45 -1
- package/dist/client/walletProviderServiceClientInterface.d.ts +21 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.esm.js +1 -1
- package/dist/setupMessage.d.ts +31 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/validator.d.ts +2 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
The client library for Silent Network Wallet Provider Service.
|
|
4
4
|
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
- [Installing](#installing)
|
|
6
9
|
- [Quick start](#quick-start)
|
|
7
10
|
- [Documentation](#documentation)
|
|
8
|
-
- [
|
|
9
|
-
- [Overview](#overview)
|
|
11
|
+
- [SDK Usage](#sdk-usage)
|
|
10
12
|
- [Authentication](#authentication)
|
|
11
|
-
- [
|
|
12
|
-
|
|
13
|
+
- [Network Without Authentication](#network-without-authentication)
|
|
14
|
+
- [Keygen](#keygen)
|
|
15
|
+
- [Signgen](#signgen)
|
|
16
|
+
- [Network with Authentication](#network-with-authentication)
|
|
17
|
+
- [Keygen](#keygen-1)
|
|
18
|
+
- [Authenticate with EOA wallet](#authenticate-with-eoa-wallet)
|
|
19
|
+
- [Authenticate with Passkey](#authenticate-with-passkey)
|
|
20
|
+
- [Signing](#signing)
|
|
21
|
+
- [Key refresh](#key-refresh)
|
|
13
22
|
- [Development](#development)
|
|
14
23
|
- [Build the library](#build-the-library)
|
|
15
24
|
- [End to end tests](#end-to-end-tests)
|
|
@@ -23,81 +32,106 @@ npm i @silencelaboratories/walletprovider-sdk
|
|
|
23
32
|
```
|
|
24
33
|
|
|
25
34
|
# Quick start
|
|
26
|
-
|
|
27
|
-
Check the [demo](
|
|
35
|
+
We provide simple demo-page what showcases the features of this SDK.
|
|
36
|
+
Check the [demo](https://github.com/silence-laboratories/walletprovider-sdk/tree/main/demo/) for a quick start guide.
|
|
28
37
|
|
|
29
38
|
# Documentation
|
|
30
39
|
|
|
31
|
-
For description of classes, interfaces, types, please refer to [documentation](
|
|
40
|
+
For description of classes, interfaces, types, please refer to [documentation](https://github.com/silence-laboratories/walletprovider-sdk/tree/main/docs/index.html).
|
|
32
41
|
|
|
33
|
-
#
|
|
42
|
+
# SDK Usage
|
|
43
|
+
## Authentication
|
|
44
|
+
Requests to the network can be authenticated by the User, using Externally Owned Account (EOA), by Passkeys, some of the requests, by session keys (also known as ephemeral keys).
|
|
34
45
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
46
|
+
- [Wallet-based](./docs/classes/EOAAuth.html) authenticate users using their digital wallet.
|
|
47
|
+
- [Passkey](./docs/classes/PasskeyAuth.html) has 2 steps: **register** and **login**. The user registers a passkey with the network, then authenticates request in with the Passkey.
|
|
48
|
+
- [Ephemeral keys](./docs/classes/EphAuth.html) Used to issue requests to the network and not prompt the user for the acceptance, contains expiry, and can be (self-)revoked.
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
The authentication can be required, or not, depending on the version of Silent Network backend.
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
In *no-authentication* case It's backend responsibility to authenticate the User, and then forward the request to the Silent Network nodes.
|
|
53
|
+
|
|
54
|
+
For more information, please read [Types of architectures](https://docs.silent.sg/silent-network/architecture) in our high-level documentation.
|
|
55
|
+
|
|
56
|
+
> This SDK supports both versions of Silent Network, *no-authentication*, and where User authentication is required.
|
|
42
57
|
|
|
43
|
-
Once authenticated, users register an ephemeral signing key pair and associate it with their identity. The ephemeral signing keys can later be used to authorize signing requests for duration of the session without the need for repeated user interaction, providing a seamless and secure authentication mechanism.
|
|
44
58
|
|
|
45
|
-
## Authentication
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
The core object to use is the [NetworkSigner](./docs/classes/NetworkSigner.html). It allows to send requests to the Silent Network.
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
## Network Without Authentication
|
|
63
|
+
The request goes to the backend, without any sort of User authentication.
|
|
50
64
|
|
|
51
|
-
|
|
65
|
+
Use the [NoAuthWalletProviderServiceClient](./docs/classes/NoAuthWalletProviderServiceClient.html) with the `Network Signer`.
|
|
66
|
+
### Keygen
|
|
67
|
+
During keygen provide number of parties `n`, the threshold `t` and [types of the keys](./docs/types/MPCSignAlgorithm.html) you want to generate.
|
|
52
68
|
|
|
69
|
+
[Example usage](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/e2e-tests/client/src/actions/noAuth/keygen.ts#L35-L37)
|
|
53
70
|
|
|
54
|
-
|
|
71
|
+
```typescript
|
|
72
|
+
const wpClient = new NoAuthWalletProviderServiceClient(selectedWpProvider);
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
- The library supports 2 signing algorithms for ephemeral signing keys: `secp256k1, ed25519`
|
|
74
|
+
const sdk = new NetworkSigner(wpClient);
|
|
58
75
|
|
|
59
|
-
|
|
76
|
+
const response = await sdk.generateKey(
|
|
77
|
+
config.threshold,
|
|
78
|
+
config.parties,
|
|
79
|
+
keySignAlgs,
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Signgen
|
|
84
|
+
The message to be signed can be of [different types](./docs/types/SignRequestType.html).
|
|
85
|
+
The example usage of different types is [shown here](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/e2e-tests/client/src/test/signature_verification.ts#L48).
|
|
86
|
+
|
|
87
|
+
[Example usage](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/e2e-tests/client/src/actions/noAuth/signgen.ts#L58-L74)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const wpClient = new NoAuthWalletProviderServiceClient(selectedWpProvider);
|
|
60
91
|
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
const sdk = new NetworkSigner(wpClient);
|
|
93
|
+
|
|
94
|
+
let sample_message = ...;
|
|
95
|
+
|
|
96
|
+
const response = await sdk.signMessage(
|
|
97
|
+
config.threshold,
|
|
98
|
+
config.keyId,
|
|
99
|
+
config.signAlg,
|
|
100
|
+
sample_message,
|
|
101
|
+
);
|
|
102
|
+
```
|
|
63
103
|
|
|
64
|
-
|
|
104
|
+
## Network with Authentication
|
|
105
|
+
### Keygen
|
|
106
|
+
#### Authenticate with EOA wallet
|
|
107
|
+
The full working example is in the [demo](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/%2Bpage.svelte#L295-L316).
|
|
65
108
|
|
|
66
|
-
|
|
67
|
-
|
|
109
|
+
In order to create your keys, you need two other components. The [WalletProviderServiceClient](./docs/classes/WalletProviderServiceClient.html) that connects to the Backend part of the SDK, and the **authenticator module**.
|
|
110
|
+
|
|
111
|
+
We provide EOA authentication via [EOAAuth](./docs/classes/EOAAuth.html) module. Let's create the `NetworkSigner` with associated `EOAAuth` object.
|
|
68
112
|
|
|
69
113
|
```ts
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const sk = generateEphPrivateKey(algSign);
|
|
73
|
-
// Derive public part epk from esk
|
|
74
|
-
const ephPK = getEphPublicKey(sk, algSign);
|
|
75
|
-
// Arbitrary ID to identify the ephemeral key
|
|
76
|
-
const ephId = uuidv4();
|
|
77
|
-
// Create ephemeral key claim instance based on the ephemeral key
|
|
78
|
-
const ephClaim = new EphKeyClaim(
|
|
79
|
-
ephId,
|
|
80
|
-
ephPK,
|
|
81
|
-
algSign,
|
|
82
|
-
// Lifetime of one hour
|
|
83
|
-
60 * 60,
|
|
84
|
-
);
|
|
114
|
+
// Create Client to the network
|
|
115
|
+
const wpClient = createWalletProviderService(clusterConfig);
|
|
85
116
|
|
|
86
|
-
//
|
|
87
|
-
const eoaAuth = new EOAAuth(
|
|
88
|
-
accountsFromBrowserWallet[0],
|
|
89
|
-
new BrowserWallet(),
|
|
90
|
-
ephClaim
|
|
91
|
-
);
|
|
117
|
+
// Authenticate using EOA
|
|
118
|
+
const eoaAuth = new EOAAuth(accountsFromBrowserWallet[0], new BrowserWallet());
|
|
92
119
|
|
|
93
|
-
// Create a
|
|
94
|
-
const
|
|
120
|
+
// Create a new signer instance
|
|
121
|
+
const sdk = new NetworkSigner(wpClient, eoaAuth);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// Generate new eph key
|
|
125
|
+
const selectedEphSignAlg = 'secp256k1'; // Signing algorithm of ephemeral key
|
|
126
|
+
const sk = generateEphPrivateKey(selectedEphSignAlg);
|
|
127
|
+
const ephPK = getEphPublicKey(sk, selectedEphSignAlg);
|
|
128
|
+
const ephId = uuidv4();
|
|
129
|
+
|
|
130
|
+
const ephClaim = new EphKeyClaim(ephId, ephPK, selectedEphSignAlg, expireAt(60 * 60));
|
|
95
131
|
|
|
96
|
-
// Create a new signer instance
|
|
97
|
-
const sdk = new NetworkSigner(wpClient, eoaAuth);
|
|
98
132
|
```
|
|
99
133
|
|
|
100
|
-
Now you can generate a key, using the [generateKey](./docs/
|
|
134
|
+
Now you can generate a key, using the [generateKey](./docs/classes/NetworkSigner.html#generatekey) method. The method accepts optional permissions. No permissions means _allow all operations_.
|
|
101
135
|
|
|
102
136
|
```ts
|
|
103
137
|
const permissions = {
|
|
@@ -117,25 +151,28 @@ const permissions = {
|
|
|
117
151
|
|
|
118
152
|
let signAlgs = ['secp256k1', 'ed25519'];
|
|
119
153
|
|
|
120
|
-
// Generate
|
|
121
|
-
let resp: KeygenResponse[] = await sdk.generateKey(threshold, partiesNumber, signAlgs,
|
|
154
|
+
// Generate keys for secp256k1, ed25519, and include ephemeral key, permissions in the request
|
|
155
|
+
let resp: KeygenResponse[] = await sdk.generateKey(+threshold, +partiesNumber, signAlgs, ephClaim, permissions);
|
|
122
156
|
```
|
|
123
157
|
|
|
124
158
|
Calling this method will cause to the Digital Wallet window to pop up, requesting the User to sign the request.
|
|
125
159
|
|
|
126
|
-
The returned response [KeygenResponse[]](./docs/
|
|
160
|
+
The returned response [KeygenResponse[]](./docs/interfaces/KeygenResponse.html) is a list of DKG results, each contains `keyId`, `publicKey` and `signAlg`. The `publicKey` is the public part of the key generated by Silent Network. The `signAlg` is the sign algorithm of the MPC key. Use the `keyId` in subsequent calls to sign.
|
|
127
161
|
|
|
128
162
|
The ephemeral `sk` key can be later used in subsequent signgen requests for authenticating.
|
|
129
163
|
|
|
130
|
-
|
|
131
|
-
First, we need to register user passkey to the network.
|
|
164
|
+
#### Authenticate with Passkey
|
|
165
|
+
First, we need to register user passkey to the network.
|
|
166
|
+
|
|
167
|
+
[Example usage](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/+page.svelte#L513)
|
|
168
|
+
|
|
132
169
|
```ts
|
|
133
|
-
const wpClient =
|
|
170
|
+
const wpClient = createWalletProviderService(clusterConfig);
|
|
134
171
|
const rpConfig: RelyingPartyConfig = {
|
|
135
|
-
rpId:
|
|
136
|
-
rpName:
|
|
172
|
+
rpId: clusterConfig.rpConfig.rpId,
|
|
173
|
+
rpName: clusterConfig.rpConfig.rpName,
|
|
137
174
|
};
|
|
138
|
-
|
|
175
|
+
userId = newUser();
|
|
139
176
|
const passkeyUser = {
|
|
140
177
|
id: userId,
|
|
141
178
|
displayName: 'Alice',
|
|
@@ -146,68 +183,56 @@ const passkeyAuth = new PasskeyRegister(rpConfig, passkeyUser);
|
|
|
146
183
|
// Create a new signer instance
|
|
147
184
|
const sdk = new NetworkSigner(wpClient, passkeyAuth);
|
|
148
185
|
|
|
149
|
-
//
|
|
186
|
+
// Generate a new key
|
|
150
187
|
let resp: RegisterPasskeyResponse = await sdk.registerPasskey();
|
|
151
188
|
```
|
|
152
189
|
|
|
153
|
-
We provide Passkey login authentication via [PasskeyAuth](./docs/
|
|
190
|
+
We provide Passkey login authentication via [PasskeyAuth](./docs/classes/PasskeyAuth.html) module. Let's create the `NetworkSigner` with associated `PasskeyAuth` object.
|
|
154
191
|
|
|
192
|
+
[Example usage](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/+page.svelte#L441)
|
|
155
193
|
```ts
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const sk = generateEphPrivateKey(algSign);
|
|
159
|
-
// Derive public part epk from esk
|
|
160
|
-
const ephPK = getEphPublicKey(sk, algSign);
|
|
161
|
-
// Arbitrary ID to identify the ephemeral key
|
|
162
|
-
const ephId = uuidv4();
|
|
163
|
-
// Create ephemeral key claim instance based on the ephemeral key
|
|
164
|
-
const ephClaim = new EphKeyClaim(
|
|
165
|
-
ephId,
|
|
166
|
-
ephPK,
|
|
167
|
-
// Lifetime of one hour
|
|
168
|
-
60 * 60,
|
|
169
|
-
);
|
|
170
|
-
// Create a client that connects to the backend service
|
|
171
|
-
const wpClient = await createWalletProviderService(clusterConfig);
|
|
172
|
-
// Here we configure the relying party for local development
|
|
173
|
-
const rpConfig: RelyingPartyConfig = {
|
|
174
|
-
rpId: 'localhost',
|
|
175
|
-
rpName: 'http://localhost:5173',
|
|
176
|
-
};
|
|
194
|
+
// Create a new signer instance
|
|
195
|
+
const sdk = new NetworkSigner(wpClient, passkeyAuth);
|
|
177
196
|
|
|
178
|
-
// Get passkey credential id from your storage
|
|
179
197
|
const credentialId = getPasskeyCredentialId();
|
|
180
|
-
|
|
198
|
+
if (!credentialId) {
|
|
199
|
+
throw new Error('Must register passkey first');
|
|
200
|
+
}
|
|
181
201
|
const passkeyAuth = new PasskeyAuth(
|
|
182
202
|
rpConfig,
|
|
183
|
-
// We will do passkey auth/login with the provided credentialId
|
|
184
203
|
credentialId,
|
|
185
|
-
ephClaim,
|
|
186
204
|
);
|
|
187
205
|
|
|
188
206
|
// Create a new signer instance
|
|
189
207
|
const sdk = new NetworkSigner(wpClient, passkeyAuth);
|
|
208
|
+
|
|
209
|
+
// Generate a new key
|
|
210
|
+
const sk = generateEphPrivateKey(selectedEphSignAlg);
|
|
211
|
+
const ephPK = getEphPublicKey(sk, selectedEphSignAlg);
|
|
212
|
+
const ephId = uuidv4();
|
|
213
|
+
|
|
214
|
+
const ephClaim = new EphKeyClaim(ephId, ephPK, selectedEphSignAlg, expireAt(60 * 60));
|
|
215
|
+
let resp: KeygenResponse[] = await sdk.generateKey(+threshold, +partiesNumber, signAlgs, ephClaim, permissions);
|
|
216
|
+
|
|
190
217
|
```
|
|
191
218
|
|
|
192
|
-
Now you can generate a key like in the EOA example by calling the [generateKey](./docs/
|
|
219
|
+
Now you can generate a key like in the EOA example by calling the [generateKey](./docs/classes/NetworkSigner.html#generatekey) method.
|
|
193
220
|
|
|
194
|
-
Calling this method will prompt the device to request [Passkey User Verification](https://web.dev/articles/webauthn-user-verification). Once user verification is done, the [KeygenResponse](./docs/
|
|
221
|
+
Calling this method will prompt the device to request [Passkey User Verification](https://web.dev/articles/webauthn-user-verification). Once user verification is done, the [KeygenResponse](./docs/interfaces/KeygenResponse.html) is returned.
|
|
195
222
|
|
|
196
223
|
The `sk` key can be later used in subsequent signgen requests.
|
|
197
224
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
The full signing example is [here](https://github.com/silence-laboratories/walletprovider-sdk/blob/main/demo/src/routes/%2Bpage.svelte).
|
|
225
|
+
### Signing
|
|
226
|
+
The full signing example is [here](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/+page.svelte#L374).
|
|
201
227
|
|
|
202
|
-
The workflow is similar to the keygen process. The core objects to use are the [NetworkSigner](./docs/
|
|
228
|
+
The workflow is similar to the keygen process. The core objects to use are the [NetworkSigner](./docs/classes/NetworkSigner.html), WalletProviderServiceClient, and the [ephemeral authenticator module](./docs/classes/EphAuth.html).
|
|
203
229
|
```ts
|
|
204
230
|
const authModule = new EphAuth(selectedEphId, ephSK, selectedEphSignAlg);
|
|
205
231
|
// Create a new signer instance
|
|
206
232
|
const sdk = new NetworkSigner(wpClient, authModule);
|
|
207
233
|
```
|
|
208
234
|
|
|
209
|
-
|
|
210
|
-
Use the [SignRequestBuilder](./docs/walletprovider-sdk.signrequestbuilder.md) builder to generate the sign message payload. Then call the [signMessage](./docs/walletprovider-sdk.networksigner.signmessage.md) method to run the signing process.
|
|
235
|
+
Use the [SignRequestBuilder](./docs/classes/SignRequestBuilder.html) builder to generate the sign message payload. Then call the [signMessage](./docs/classes/NetworkSigner.html#signmessage) method to run the signing process.
|
|
211
236
|
|
|
212
237
|
```ts
|
|
213
238
|
const signMessage = new SignRequestBuilder()
|
|
@@ -242,37 +267,21 @@ const signMessage = new SignRequestBuilder()
|
|
|
242
267
|
let resp = await sdk.signMessage( threshold, selectedKeyId, signMessage);
|
|
243
268
|
```
|
|
244
269
|
|
|
245
|
-
The [SignResponse](./docs/
|
|
270
|
+
The [SignResponse](./docs/interfaces/SignResponse.html) contains the signature `sign`, the recovery ID `recid` and the transaction ID `transactionId`.
|
|
246
271
|
|
|
247
|
-
|
|
272
|
+
### Key refresh
|
|
248
273
|
|
|
249
|
-
The full key refresh example is [here](https://github.com/silence-laboratories/walletprovider-sdk/blob/
|
|
250
|
-
|
|
251
|
-
The workflow is similar to the keygen process. The core objects to use are the [NetworkSigner](./docs/walletprovider-sdk.networksigner.md), WalletProviderServiceClient, and the [EOAAuth](./docs/walletprovider-sdk.eoaauth.md) module.
|
|
274
|
+
The full key refresh example is [here](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/+page.svelte#L351).
|
|
252
275
|
|
|
276
|
+
The workflow is similar to the keygen process.
|
|
253
277
|
|
|
254
278
|
```ts
|
|
255
279
|
const algSign = 'secp256k1'; // Signing algorithms of ephemeral key
|
|
256
|
-
// Generate ephemeral secret key esk
|
|
257
|
-
const sk = generateEphPrivateKey(algSign);
|
|
258
|
-
// Derive public part epk from esk
|
|
259
|
-
const ephPK = getEphPublicKey(sk, algSign);
|
|
260
|
-
// Arbitrary ID to identify the ephemeral key
|
|
261
|
-
const ephId = uuidv4();
|
|
262
|
-
// Create ephemeral key claim instance based on the ephemeral key
|
|
263
|
-
const ephClaim = new EphKeyClaim(
|
|
264
|
-
ephId,
|
|
265
|
-
ephPK,
|
|
266
|
-
algSign,
|
|
267
|
-
// Lifetime of one hour
|
|
268
|
-
60 * 60,
|
|
269
|
-
);
|
|
270
280
|
|
|
271
|
-
// Create EOA authenticator
|
|
281
|
+
// Create EOA authenticator
|
|
272
282
|
const eoaAuth = new EOAAuth(
|
|
273
283
|
accountsFromBrowserWallet[0],
|
|
274
284
|
new BrowserWallet(),
|
|
275
|
-
ephClaim
|
|
276
285
|
);
|
|
277
286
|
|
|
278
287
|
// Create a client that connects to the backend service
|
|
@@ -282,13 +291,13 @@ const wpClient = await createWalletProviderService(clusterConfig);
|
|
|
282
291
|
const sdk = new NetworkSigner(wpClient, eoaAuth);
|
|
283
292
|
```
|
|
284
293
|
|
|
285
|
-
Now you can refresh the key (before doing this, make sure you've already generated the key), using the [refreshKey](./docs/
|
|
294
|
+
Now you can refresh the key (before doing this, make sure you've already generated the key), using the [refreshKey](./docs/classes/NetworkSigner.html#refreshkey) method.
|
|
286
295
|
|
|
287
296
|
```ts
|
|
288
297
|
// Refresh the key
|
|
289
|
-
let resp: KeyRefreshResponse = await sdk.refreshKey(threshold,
|
|
298
|
+
let resp: KeyRefreshResponse = await sdk.refreshKey(+threshold, selectedKeyId, mpcKeySignAlg);
|
|
290
299
|
```
|
|
291
|
-
The returned response [KeyRefreshResponse](./docs/
|
|
300
|
+
The returned response [KeyRefreshResponse](./docs/types/KeyRefreshResponse.html) contains `keyId`, `publicKey` and `signAlg` of the refreshed MPC key.
|
|
292
301
|
|
|
293
302
|
|
|
294
303
|
# Development
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type UserAuthentication } from './authentication';
|
|
5
5
|
import { type TypedDataDomain } from 'viem';
|
|
6
|
-
import { EphKeyClaim } from './ephemeralAuthentication';
|
|
7
6
|
export type FieldDefinition = {
|
|
8
7
|
name: string;
|
|
9
8
|
type: string;
|
|
@@ -51,20 +50,18 @@ export declare const EIP712SilentShardAuthenticationDomain: {
|
|
|
51
50
|
type RequestToSign<T> = {
|
|
52
51
|
setup: T;
|
|
53
52
|
challenge: string;
|
|
54
|
-
eph_claim: string;
|
|
55
53
|
};
|
|
56
54
|
export interface EoaAuthPayload {
|
|
57
55
|
get eoaRequestSchema(): any;
|
|
58
56
|
}
|
|
59
|
-
export declare function createTypedRequest(request: EoaAuthPayload, final_challenge: string
|
|
57
|
+
export declare function createTypedRequest(request: EoaAuthPayload, final_challenge: string): TypedData<RequestToSign<EoaAuthPayload>>;
|
|
60
58
|
/** Present the request to the User using wallet UI, and ask for sign.
|
|
61
59
|
* The signature is the authorization for keygen operation
|
|
62
60
|
*/
|
|
63
|
-
export declare function authenticateUsingEOA({ setup, eoa, challenge, browserWallet,
|
|
61
|
+
export declare function authenticateUsingEOA({ setup, eoa, challenge, browserWallet, }: {
|
|
64
62
|
setup: EoaAuthPayload;
|
|
65
63
|
eoa: string;
|
|
66
64
|
challenge: string;
|
|
67
65
|
browserWallet: IBrowserWallet;
|
|
68
|
-
ephClaim: EphKeyClaim | undefined;
|
|
69
66
|
}): Promise<UserAuthentication>;
|
|
70
67
|
export {};
|
|
@@ -2,14 +2,15 @@ import { AddEphKeyRequest, RegisterPasskeyRequest } from './../client/networkReq
|
|
|
2
2
|
import { KeygenSetupOpts } from '../setupMessage';
|
|
3
3
|
import { EoaAuthPayload, IBrowserWallet } from './EOAauthentication';
|
|
4
4
|
import { PasskeyUser, RelyingPartyConfig } from './passkeyAuthentication';
|
|
5
|
-
import { EphemeralAuthPayload,
|
|
5
|
+
import { EphemeralAuthPayload, EphKeySignAlgorithm } from './ephemeralAuthentication';
|
|
6
6
|
import { RevokeEphKeyRequest } from '../client/networkRequest';
|
|
7
|
+
export type AuthMethod = 'eoa' | 'ephemeral' | 'passkey';
|
|
7
8
|
/** Contains essential information about how to authenticate the user request.
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
11
|
export type UserCredentials = {
|
|
11
12
|
id: string;
|
|
12
|
-
method:
|
|
13
|
+
method: AuthMethod;
|
|
13
14
|
credentials: string;
|
|
14
15
|
};
|
|
15
16
|
/** User signature container.
|
|
@@ -36,15 +37,12 @@ export declare class EOAAuth {
|
|
|
36
37
|
private browserWallet;
|
|
37
38
|
/** the ETH address that is used to do EOA authentication */
|
|
38
39
|
private eoa;
|
|
39
|
-
/** Ephemeral key claim populated for single or batched keys*/
|
|
40
|
-
private ephClaim;
|
|
41
40
|
/**
|
|
42
41
|
*
|
|
43
42
|
* @param eoa - Ethereum address
|
|
44
43
|
* @param browserWallet - Interface to the wallet provider, like MetaMask, that is used to sign the requests
|
|
45
|
-
* @param ephClaimOptions - Either EphKeyClaim or Map of SignatureAlgorithms and their appropriate EphKeyClaims
|
|
46
44
|
*/
|
|
47
|
-
constructor(eoa: string, browserWallet: IBrowserWallet
|
|
45
|
+
constructor(eoa: string, browserWallet: IBrowserWallet);
|
|
48
46
|
private validateInputs;
|
|
49
47
|
/**
|
|
50
48
|
* Prepares a message to present on the Browser Wallet window and requests to sign it.
|
|
@@ -95,15 +93,12 @@ export declare class PasskeyAuth {
|
|
|
95
93
|
private rpConfig;
|
|
96
94
|
/** ID of the acceptable credential by user. App proves that user has passkey credential by passing the value of this field */
|
|
97
95
|
private allowCredentialId;
|
|
98
|
-
/** Ephemeral key claim populated for non batched requests*/
|
|
99
|
-
private ephClaim;
|
|
100
96
|
/**
|
|
101
97
|
*
|
|
102
98
|
* @param rpConfig - Passkey relying party configuration. Read more: https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp
|
|
103
99
|
* @param allowCredentialId - ID of the acceptable credential by user. App proves that user has passkey credential by passing the value of this field
|
|
104
|
-
* @param ephClaimOptions - Either EphKeyClaim or Map of SignatureAlgorithms and their appropriate EphKeyClaims
|
|
105
100
|
*/
|
|
106
|
-
constructor(rpConfig: RelyingPartyConfig, allowCredentialId: string
|
|
101
|
+
constructor(rpConfig: RelyingPartyConfig, allowCredentialId: string);
|
|
107
102
|
/**
|
|
108
103
|
* Prepares a message for Passkey login flow and prompts user device's authenticator to sign it.
|
|
109
104
|
* @param payload - request payload to be sent to the backend
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { UserAuthentication } from './authentication';
|
|
2
|
-
import { SignSetupOpts } from '../setupMessage';
|
|
2
|
+
import { FinishPresignOpts, SignSetupOpts } from '../setupMessage';
|
|
3
3
|
import { RevokeEphKeyRequest } from '../client/networkRequest';
|
|
4
4
|
/**
|
|
5
5
|
* Supported signature algorithms for ephemeral signing.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
export type EphKeySignAlgorithm = 'ed25519' | 'secp256k1';
|
|
9
|
-
export type EphemeralAuthPayload = SignSetupOpts | RevokeEphKeyRequest;
|
|
9
|
+
export type EphemeralAuthPayload = SignSetupOpts | RevokeEphKeyRequest | FinishPresignOpts;
|
|
10
10
|
/** The `EphKeyClaim` object represents the public claim of the ephemeral key.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UserAuthentication } from './authentication';
|
|
2
|
-
import { EphKeyClaim } from './ephemeralAuthentication';
|
|
3
2
|
/** Information about the user currently registering. Read more: https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-user
|
|
4
3
|
* @public
|
|
5
4
|
* */
|
|
@@ -20,9 +19,8 @@ export declare function passkeyRegister({ user, challenge, rpConfig, }: {
|
|
|
20
19
|
challenge: string;
|
|
21
20
|
rpConfig: RelyingPartyConfig;
|
|
22
21
|
}): Promise<UserAuthentication>;
|
|
23
|
-
export declare function passkeyLogin({ challenge, allowCredentialId, rpConfig,
|
|
22
|
+
export declare function passkeyLogin({ challenge, allowCredentialId, rpConfig, }: {
|
|
24
23
|
challenge: string;
|
|
25
24
|
allowCredentialId: string | null;
|
|
26
25
|
rpConfig: RelyingPartyConfig;
|
|
27
|
-
ephClaim: EphKeyClaim;
|
|
28
26
|
}): Promise<UserAuthentication>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthModule, UserAuthentication } from '../auth/authentication';
|
|
2
2
|
import { ApiVersion, RequestPayloadV1, RequestPayloadV2, Slug } from '../client/walletProviderServiceClientInterface';
|
|
3
|
-
import { KeygenSetupOpts, SignSetupOpts } from '../setupMessage';
|
|
3
|
+
import { FinishPresignOpts, KeygenSetupOpts, SignSetupOpts } from '../setupMessage';
|
|
4
4
|
import { AddEphKeyRequest, KeyRefreshRequest, QuorumChangeRequest, RegisterPasskeyRequest, RevokeEphKeyRequest } from '../client/networkRequest';
|
|
5
5
|
/**
|
|
6
6
|
* Builder class for constructing user signatures in all kind of client requests to the network.
|
|
@@ -24,5 +24,6 @@ export declare class UserSignatures {
|
|
|
24
24
|
setRegisterPasskeyUserSigs(payload: RegisterPasskeyRequest, challenge?: string): Promise<void>;
|
|
25
25
|
setKeyRefreshUserSigs(payload: KeyRefreshRequest, challenge?: string): Promise<void>;
|
|
26
26
|
setQcUserSigs(payload: QuorumChangeRequest, challenge?: string): Promise<void>;
|
|
27
|
+
setFinishPresignUserSigs(payload: FinishPresignOpts, challenge?: string): Promise<void>;
|
|
27
28
|
build(slug: Slug, payload: RequestPayloadV1 | RequestPayloadV2, challenge?: string): Promise<Record<string, UserAuthentication>>;
|
|
28
29
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EoaAuthPayload } from '../auth/EOAauthentication';
|
|
2
|
+
import { EphKeyClaim } from '../auth/ephemeralAuthentication';
|
|
2
3
|
export declare class RevokeEphKeyRequest implements EoaAuthPayload {
|
|
3
4
|
readonly key_id: string;
|
|
4
|
-
|
|
5
|
+
readonly eph_claim: string;
|
|
6
|
+
constructor(keyId: string, eph_claim: EphKeyClaim);
|
|
5
7
|
get eoaRequestSchema(): {
|
|
6
8
|
Request: {
|
|
7
9
|
name: string;
|
|
@@ -15,7 +17,8 @@ export declare class RevokeEphKeyRequest implements EoaAuthPayload {
|
|
|
15
17
|
}
|
|
16
18
|
export declare class AddEphKeyRequest implements EoaAuthPayload {
|
|
17
19
|
readonly key_id_list: string[];
|
|
18
|
-
|
|
20
|
+
readonly eph_claim: string;
|
|
21
|
+
constructor(keyIdList: string[], eph_claim: EphKeyClaim);
|
|
19
22
|
get eoaRequestSchema(): {
|
|
20
23
|
Request: {
|
|
21
24
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthModule } from '../auth/authentication';
|
|
2
|
-
import { type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
2
|
+
import { INoAuthWpServiceClient, type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
3
3
|
import { KeygenResponse, AddEphKeyResponse, RegisterPasskeyResponse, SignResponse, RevokeEphKeyResponse, KeyRefreshResponse } from './networkResponse';
|
|
4
|
+
import { EphKeyClaim } from '../auth/ephemeralAuthentication';
|
|
4
5
|
/**
|
|
5
6
|
* Supported signature algorithms for MPC signing.
|
|
6
7
|
* @public
|
|
@@ -12,15 +13,15 @@ export type MPCSignAlgorithm = 'ed25519' | 'secp256k1';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class NetworkSigner {
|
|
14
15
|
/** Authentication module, used to get confirmation from the User before request execution */
|
|
15
|
-
authModule: AuthModule;
|
|
16
|
+
authModule: AuthModule | undefined;
|
|
16
17
|
/** Wallet Provider backend client */
|
|
17
|
-
wpClient: IWalletProviderServiceClient;
|
|
18
|
+
wpClient: IWalletProviderServiceClient | INoAuthWpServiceClient;
|
|
18
19
|
/**
|
|
19
20
|
* Facade class used to execute operations on Silent Network.
|
|
20
21
|
* @param wpClient - Wallet Provider backend client
|
|
21
22
|
* @param authModule - Authentication module, used to get confirmation from the User before request execution
|
|
22
23
|
*/
|
|
23
|
-
constructor(wpClient: IWalletProviderServiceClient, authModule
|
|
24
|
+
constructor(wpClient: IWalletProviderServiceClient | INoAuthWpServiceClient, authModule?: AuthModule);
|
|
24
25
|
validateQuorumSetup({ threshold, totalNodes }: {
|
|
25
26
|
threshold?: number;
|
|
26
27
|
totalNodes?: number;
|
|
@@ -30,12 +31,13 @@ export declare class NetworkSigner {
|
|
|
30
31
|
* @param threshold - Number of nodes that needs to participate in protocol in order to generate valid signature. Also known as `t`.
|
|
31
32
|
* @param totalNodes - Number of nodes that participate in keygen operation. Also known as `n`.
|
|
32
33
|
* @param signAlgs - signature algorithms for which MPC keys will be generated.
|
|
34
|
+
* @param eph_claim - optional eph key added to the generated key
|
|
33
35
|
* @param permissions - optional permissions that will be stored in the key metadata.
|
|
34
36
|
* The permissions are validated during sign requests.
|
|
35
37
|
* @returns {@link KeygenResponse} containing `keyId` and the `pubKey` public part of the key
|
|
36
38
|
* @public
|
|
37
39
|
*/
|
|
38
|
-
generateKey(threshold: number, totalNodes: number, signAlgs: string[], permissions?: string): Promise<KeygenResponse[]>;
|
|
40
|
+
generateKey(threshold: number, totalNodes: number, signAlgs: string[], ephClaim?: EphKeyClaim, permissions?: string): Promise<KeygenResponse[]>;
|
|
39
41
|
/** Generate a signature by the distributed key of Silent Network.
|
|
40
42
|
* Uses `authModule` to authenticate the sign request by the User.
|
|
41
43
|
* The network chooses `t` nodes to execute the protocol.
|
|
@@ -59,17 +61,19 @@ export declare class NetworkSigner {
|
|
|
59
61
|
/** Add new ephemeral key to an exist distributed key on the network.
|
|
60
62
|
* Uses `authModule` to authenticate the request by the User.
|
|
61
63
|
* @param keyIdList - the list of key id returned from `keygen`
|
|
64
|
+
* @param eph_claim - the claim to be added
|
|
62
65
|
* @returns {@link AddEphKeyResponse}
|
|
63
66
|
* @public
|
|
64
67
|
*/
|
|
65
|
-
addEphemeralKey(keyIdList: string[]): Promise<AddEphKeyResponse[]>;
|
|
68
|
+
addEphemeralKey(keyIdList: string[], eph_claim: EphKeyClaim): Promise<AddEphKeyResponse[]>;
|
|
66
69
|
/** Revoke ephemeral key of an exist distributed key on the network.
|
|
67
70
|
* Uses `authModule` to authenticate the request by the User.
|
|
68
71
|
* @param keyId - the key id returned from `keygen`
|
|
72
|
+
* @param eph_claim - the claim to be revoked
|
|
69
73
|
* @returns {@link RevokeEphKeyResponse}
|
|
70
74
|
* @public
|
|
71
75
|
*/
|
|
72
|
-
revokeEphemeralKey(keyId: string): Promise<RevokeEphKeyResponse>;
|
|
76
|
+
revokeEphemeralKey(keyId: string, eph_claim: EphKeyClaim): Promise<RevokeEphKeyResponse>;
|
|
73
77
|
/** Register new user's passkey on the network. This will try to register to all the available nodes on the network.
|
|
74
78
|
* Uses `authModule` to authenticate the request by the User.
|
|
75
79
|
* @param options - the options to customize the passkey authentication
|