@silencelaboratories/walletprovider-sdk 4.1.0 → 4.1.2
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 +148 -76
- package/dist/auth/authentication.d.ts +2 -2
- package/dist/builder/userAuth.d.ts +7 -5
- package/dist/client/networkRequest.d.ts +48 -3
- package/dist/client/networkResponse.d.ts +40 -2
- package/dist/client/networkSigner.d.ts +1 -1
- package/dist/client/walletProviderServiceClient.d.ts +3 -3
- package/dist/client/walletProviderServiceClientInterface.d.ts +14 -10
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.esm.js +1 -1
- package/dist/policy.d.ts +33 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,10 +13,11 @@ The client library for Silent Network Wallet Provider Service.
|
|
|
13
13
|
- [Network Without Authentication](#network-without-authentication)
|
|
14
14
|
- [Keygen](#keygen)
|
|
15
15
|
- [Signgen](#signgen)
|
|
16
|
-
- [Network
|
|
16
|
+
- [Network With Authentication](#network-with-authentication)
|
|
17
17
|
- [Keygen](#keygen-1)
|
|
18
18
|
- [Authenticate with EOA wallet](#authenticate-with-eoa-wallet)
|
|
19
19
|
- [Authenticate with Passkey](#authenticate-with-passkey)
|
|
20
|
+
- [Policy](#policy)
|
|
20
21
|
- [Signing](#signing)
|
|
21
22
|
- [Key refresh](#key-refresh)
|
|
22
23
|
- [Development](#development)
|
|
@@ -105,7 +106,7 @@ The example usage of different types is [shown here](https://github.com/silence-
|
|
|
105
106
|
);
|
|
106
107
|
```
|
|
107
108
|
|
|
108
|
-
## Network
|
|
109
|
+
## Network With Authentication
|
|
109
110
|
### Initialize the Client object
|
|
110
111
|
Create the [WalletProviderServiceClient](./docs/classes/WalletProviderServiceClient.html), using [ClientConfig](./docs/types/ClientConfig.html). The `wpClient` will connect to the Wallet Provider Backend Service (WPBE).
|
|
111
112
|
|
|
@@ -137,80 +138,9 @@ We provide EOA authentication via [EOAAuth](./docs/classes/EOAAuth.html) module.
|
|
|
137
138
|
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
Now you can generate a key
|
|
141
|
+
Now you can generate a key by calling the [generateKey](./docs/classes/NetworkSigner.html#generatekey) method. See [Policy](#policy) if you want to restrict what the generated key is allowed to sign.
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
const POLICY_ERC20_TRANSFER = new Policy({
|
|
144
|
-
version: '1.0',
|
|
145
|
-
description: 'Simple ERC20 transfer policy',
|
|
146
|
-
rules: [
|
|
147
|
-
new Rule({
|
|
148
|
-
description: 'ERC20 transferFrom: sender/recipient match and value < 10000',
|
|
149
|
-
chain_type: ChainType.Ethereum,
|
|
150
|
-
conditions: [
|
|
151
|
-
{
|
|
152
|
-
logic: Logic.And,
|
|
153
|
-
abi: {
|
|
154
|
-
name: 'transfer',
|
|
155
|
-
type: 'function',
|
|
156
|
-
inputs: [
|
|
157
|
-
{
|
|
158
|
-
name: 'to',
|
|
159
|
-
type: 'address',
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'amount',
|
|
163
|
-
type: 'uint256',
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
outputs: [
|
|
167
|
-
{
|
|
168
|
-
name: '',
|
|
169
|
-
type: 'bool',
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
},
|
|
173
|
-
group: [
|
|
174
|
-
{
|
|
175
|
-
transaction_type: TransactionType.Erc20,
|
|
176
|
-
transaction_attr: TransactionAttribute.Receiver,
|
|
177
|
-
operator: Operator.Eq,
|
|
178
|
-
value: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
transaction_type: TransactionType.Erc20,
|
|
182
|
-
transaction_attr: "to",
|
|
183
|
-
operator: Operator.Eq,
|
|
184
|
-
value: '0x1758f42af7026fbbb559dc60ece0de3ef81f665e',
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
transaction_type: TransactionType.Erc20,
|
|
188
|
-
transaction_attr: "amount",
|
|
189
|
-
operator: Operator.Lt,
|
|
190
|
-
value: 10000,
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
}),
|
|
196
|
-
],
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
let signAlgs = ['secp256k1', 'ed25519'];
|
|
200
|
-
|
|
201
|
-
// Generate new eph key, will be later used in sign requests
|
|
202
|
-
const selectedEphSignAlg = 'secp256k1'; // Signing algorithm of Ephemeral Key
|
|
203
|
-
const sk = generateEphPrivateKey(selectedEphSignAlg);
|
|
204
|
-
const ephPK = getEphPublicKey(sk, selectedEphSignAlg);
|
|
205
|
-
const ephId = uuidv4();
|
|
206
|
-
|
|
207
|
-
const ephClaim = new EphKeyClaim(ephId, ephPK, selectedEphSignAlg, expireAt(60 * 60));
|
|
208
|
-
|
|
209
|
-
// Generate keys for secp256k1, ed25519, and include Ephemeral Key, Policy in the request
|
|
210
|
-
let resp: KeygenResponse[] = await sdk.generateKey(+threshold, +partiesNumber, signAlgs, ephClaim, POLICY_ERC20_TRANSFER);
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
Calling this method will cause to the Digital Wallet window to pop up, requesting the User to sign the request.
|
|
143
|
+
Calling this method will cause the Digital Wallet window to pop up, requesting the User to sign the request.
|
|
214
144
|
|
|
215
145
|
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.
|
|
216
146
|
|
|
@@ -272,6 +202,148 @@ Calling this method will prompt the device to request [Passkey User Verification
|
|
|
272
202
|
|
|
273
203
|
The `sk` key can be later used in subsequent signgen requests.
|
|
274
204
|
|
|
205
|
+
### Policy
|
|
206
|
+
Use a [Policy](./docs/classes/Policy.html) when you want a key to sign only a constrained set of requests.
|
|
207
|
+
|
|
208
|
+
Typical uses for policies:
|
|
209
|
+
|
|
210
|
+
- Allow transfers only to specific recipients.
|
|
211
|
+
- Cap the maximum amount for ERC-20, native-token, or SPL transfers.
|
|
212
|
+
- Restrict signing to a specific contract function or chain.
|
|
213
|
+
- Allow only specific EIP-191 messages or EIP-712 payloads.
|
|
214
|
+
|
|
215
|
+
If you do not provide a policy, the key is created without signing restrictions.
|
|
216
|
+
|
|
217
|
+
Policies are built from [Policy](./docs/classes/Policy.html), [Rule](./docs/classes/Rule.html), [ChainType](./docs/enums/ChainType.html), [TransactionType](./docs/enums/TransactionType.html), [TransactionAttribute](./docs/enums/TransactionAttribute.html), [Operator](./docs/enums/Operator.html), and optionally [Logic](./docs/enums/Logic.html).
|
|
218
|
+
|
|
219
|
+
The structure is:
|
|
220
|
+
|
|
221
|
+
- A `Policy` contains one or more ordered rules.
|
|
222
|
+
- A `Rule` targets a chain and defines the conditions that must match.
|
|
223
|
+
- A condition checks one transaction attribute, such as receiver, amount, chain ID, or message.
|
|
224
|
+
- A condition group can share an ABI so the policy engine can decode calldata and validate function arguments such as `to` or `value`.
|
|
225
|
+
|
|
226
|
+
Here is a common import set:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import {
|
|
230
|
+
Policy,
|
|
231
|
+
Rule,
|
|
232
|
+
ChainType,
|
|
233
|
+
Logic,
|
|
234
|
+
Operator,
|
|
235
|
+
TransactionType,
|
|
236
|
+
TransactionAttribute,
|
|
237
|
+
} from '@silencelaboratories/walletprovider-sdk';
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Example: allow only ERC-20 `transfer()` calls to a specific token contract, a specific recipient, and an amount below `10000`.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
const erc20TransferPolicy = new Policy({
|
|
244
|
+
version: '1.0',
|
|
245
|
+
description: 'Simple ERC20 transfer policy',
|
|
246
|
+
rules: [
|
|
247
|
+
new Rule({
|
|
248
|
+
description: 'Allow transfer() to one recipient with value < 10000',
|
|
249
|
+
chain_type: ChainType.Ethereum,
|
|
250
|
+
conditions: [
|
|
251
|
+
{
|
|
252
|
+
logic: Logic.And,
|
|
253
|
+
abi: {
|
|
254
|
+
name: 'transfer',
|
|
255
|
+
type: 'function',
|
|
256
|
+
inputs: [
|
|
257
|
+
{ name: 'to', type: 'address' },
|
|
258
|
+
{ name: 'value', type: 'uint256' },
|
|
259
|
+
],
|
|
260
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
261
|
+
},
|
|
262
|
+
group: [
|
|
263
|
+
{
|
|
264
|
+
transaction_type: TransactionType.Erc20,
|
|
265
|
+
transaction_attr: TransactionAttribute.Receiver,
|
|
266
|
+
operator: Operator.Eq,
|
|
267
|
+
value: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
transaction_type: TransactionType.Erc20,
|
|
271
|
+
transaction_attr: 'to',
|
|
272
|
+
operator: Operator.Eq,
|
|
273
|
+
value: '0x1758f42af7026fbbb559dc60ece0de3ef81f665e',
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
transaction_type: TransactionType.Erc20,
|
|
277
|
+
transaction_attr: 'value',
|
|
278
|
+
operator: Operator.Lt,
|
|
279
|
+
value: 10000,
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
}),
|
|
285
|
+
],
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Example: allow a Solana native transfer only to one recipient and only if the amount is at most `100`.
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
const solTransferPolicy = new Policy({
|
|
293
|
+
version: '1.0',
|
|
294
|
+
description: 'Solana transfer policy',
|
|
295
|
+
rules: [
|
|
296
|
+
new Rule({
|
|
297
|
+
description: 'Allow transfer to one address with value <= 100',
|
|
298
|
+
chain_type: ChainType.Solana,
|
|
299
|
+
conditions: [
|
|
300
|
+
{
|
|
301
|
+
transaction_type: TransactionType.NativeTransfer,
|
|
302
|
+
transaction_attr: TransactionAttribute.Receiver,
|
|
303
|
+
operator: Operator.Eq,
|
|
304
|
+
value: 'DGUiWE2kY5rEhPNrwCGygcyrWwLxJFrH7ApFep6A8rdF',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
transaction_type: TransactionType.NativeTransfer,
|
|
308
|
+
transaction_attr: TransactionAttribute.NativeValue,
|
|
309
|
+
operator: Operator.Lte,
|
|
310
|
+
value: 100,
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
}),
|
|
314
|
+
],
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
You can attach a policy during key generation:
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
const signAlgs = ['secp256k1', 'ed25519'];
|
|
322
|
+
|
|
323
|
+
const selectedEphSignAlg = 'secp256k1';
|
|
324
|
+
const sk = generateEphPrivateKey(selectedEphSignAlg);
|
|
325
|
+
const ephPK = getEphPublicKey(sk, selectedEphSignAlg);
|
|
326
|
+
const ephId = uuidv4();
|
|
327
|
+
const ephClaim = new EphKeyClaim(ephId, ephPK, selectedEphSignAlg, expireAt(60 * 60));
|
|
328
|
+
|
|
329
|
+
const resp: KeygenResponse[] = await sdk.generateKey(
|
|
330
|
+
+threshold,
|
|
331
|
+
+partiesNumber,
|
|
332
|
+
signAlgs,
|
|
333
|
+
ephClaim,
|
|
334
|
+
erc20TransferPolicy,
|
|
335
|
+
);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
You can also change or remove the policy later for an existing key:
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
await sdk.updatePolicy(selectedKeyId, solTransferPolicy);
|
|
342
|
+
await sdk.deletePolicy(selectedKeyId);
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
In practice, a good pattern is to start with the smallest policy that supports your flow, test the exact transaction payloads your app produces, and only then broaden the rules if needed.
|
|
346
|
+
|
|
275
347
|
### Signing
|
|
276
348
|
The full signing example is [here](https://github.com/silence-laboratories/walletprovider-sdk/blob/564cca4bb59658a6e477a59e8ea554a67c26b161/demo/src/routes/+page.svelte#L374).
|
|
277
349
|
|
|
@@ -372,4 +444,4 @@ npm run docs
|
|
|
372
444
|
|
|
373
445
|
```bash
|
|
374
446
|
./local_ci.sh
|
|
375
|
-
```
|
|
447
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddEphKeyRequest,
|
|
1
|
+
import { AddEphKeyRequest, KeyIdOfPolicy, KeyRefreshRequest, RegisterPasskeyRequest, UpdatePolicyRequest } from './../client/networkRequest';
|
|
2
2
|
import { KeygenSetupOpts, SignSetupOpts, FinishPresignOpts } from '../setupMessage';
|
|
3
3
|
import { EoaAuthPayload, IBrowserWallet } from './EOAauthentication';
|
|
4
4
|
import { PasskeyUser, RelyingPartyConfig } from './passkeyAuthentication';
|
|
@@ -34,7 +34,7 @@ export interface AuthModule {
|
|
|
34
34
|
authenticate(params: AuthModuleParams): Promise<UserAuthentication>;
|
|
35
35
|
}
|
|
36
36
|
export type AuthPayload = EoaAuthPayload | PasskeyLoginPayload | EphemeralAuthPayload | RegisterPasskeyRequest;
|
|
37
|
-
type PasskeyLoginPayload = KeygenSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | UpdatePolicyRequest |
|
|
37
|
+
type PasskeyLoginPayload = KeygenSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | UpdatePolicyRequest | KeyIdOfPolicy | SignSetupOpts | FinishPresignOpts | KeyRefreshRequest;
|
|
38
38
|
/** The `EOAAuth` implementing Externally Owned Account authentication.
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AuthModule, AuthModuleParams
|
|
2
|
-
import { ApiVersion, RequestPayloadV1, RequestPayloadV2, Slug } from '../client/walletProviderServiceClientInterface';
|
|
1
|
+
import { AuthModule, AuthModuleParams } from '../auth/authentication';
|
|
2
|
+
import { ApiVersion, RequestPayloadV1, RequestPayloadV2, Slug, WpUserSignatures } from '../client/walletProviderServiceClientInterface';
|
|
3
3
|
import { FinishPresignOpts, KeygenSetupOpts, SignSetupOpts } from '../setupMessage';
|
|
4
|
-
import { AddEphKeyRequest,
|
|
4
|
+
import { AddEphKeyRequest, CreateStateControllerRequest, DeleteStateControllerRequest, KeyIdOfPolicy, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest, UpdatePolicyRequest } from '../client/networkRequest';
|
|
5
5
|
export type UserSignaturesOptionalParams = {
|
|
6
6
|
challenge?: string | undefined;
|
|
7
7
|
};
|
|
@@ -28,6 +28,8 @@ export declare class UserSignatures {
|
|
|
28
28
|
setKeyRefreshUserSigs(authParams: AuthModuleParams<KeyRefreshRequest>): Promise<void>;
|
|
29
29
|
setFinishPresignUserSigs(authParams: AuthModuleParams<FinishPresignOpts>): Promise<void>;
|
|
30
30
|
setUpdatePolicyUserSigs(authParams: AuthModuleParams<UpdatePolicyRequest>): Promise<void>;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
setKeyIdOfPolicyUserSigs(authParams: AuthModuleParams<KeyIdOfPolicy>): Promise<void>;
|
|
32
|
+
setCreateStateControllerUserSigs(authParams: AuthModuleParams<CreateStateControllerRequest>): Promise<void>;
|
|
33
|
+
setDeleteStateControllerUserSigs(authParams: AuthModuleParams<DeleteStateControllerRequest>): Promise<void>;
|
|
34
|
+
build(slug: Slug, payload: RequestPayloadV1 | RequestPayloadV2, options?: UserSignaturesOptionalParams): Promise<WpUserSignatures>;
|
|
33
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EoaAuthPayload } from '../auth/EOAauthentication';
|
|
2
2
|
import { EphKeyClaim } from '../auth/ephemeralAuthentication';
|
|
3
|
-
import { Policy } from '../policy';
|
|
3
|
+
import { StateControllerAggregationMethod, StateControllerPartitionField, Policy, StateControllerWindowConfig } from '../policy';
|
|
4
4
|
export declare class RevokeEphKeyRequest implements EoaAuthPayload {
|
|
5
5
|
readonly key_id: string;
|
|
6
6
|
readonly eph_claim: string;
|
|
@@ -78,7 +78,7 @@ export declare class UpdatePolicyRequest implements EoaAuthPayload {
|
|
|
78
78
|
}[];
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
export declare class
|
|
81
|
+
export declare class KeyIdOfPolicy implements EoaAuthPayload {
|
|
82
82
|
/** Policy associated key ID */
|
|
83
83
|
readonly key_id: string;
|
|
84
84
|
constructor({ keyId }: {
|
|
@@ -89,7 +89,52 @@ export declare class DeletePolicyRequest implements EoaAuthPayload {
|
|
|
89
89
|
name: string;
|
|
90
90
|
type: string;
|
|
91
91
|
}[];
|
|
92
|
-
|
|
92
|
+
KeyIdOfPolicy: {
|
|
93
|
+
name: string;
|
|
94
|
+
type: string;
|
|
95
|
+
}[];
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface CreateStateControllerPayload {
|
|
99
|
+
key_id: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
method: StateControllerAggregationMethod;
|
|
102
|
+
window: StateControllerWindowConfig;
|
|
103
|
+
partition_by: StateControllerPartitionField[];
|
|
104
|
+
}
|
|
105
|
+
export declare class CreateStateControllerRequest implements EoaAuthPayload {
|
|
106
|
+
readonly key_id: string;
|
|
107
|
+
readonly description?: string;
|
|
108
|
+
readonly method: string;
|
|
109
|
+
readonly window: string;
|
|
110
|
+
readonly partition_by: string;
|
|
111
|
+
constructor({ key_id, description, method, window, partition_by }: CreateStateControllerPayload);
|
|
112
|
+
get eoaRequestSchema(): {
|
|
113
|
+
Request: {
|
|
114
|
+
name: string;
|
|
115
|
+
type: string;
|
|
116
|
+
}[];
|
|
117
|
+
CreateStateControllerRequest: {
|
|
118
|
+
name: string;
|
|
119
|
+
type: string;
|
|
120
|
+
}[];
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export interface DeleteStateControllerPayload {
|
|
124
|
+
key_id: string;
|
|
125
|
+
controller_id: string;
|
|
126
|
+
}
|
|
127
|
+
export declare class DeleteStateControllerRequest implements EoaAuthPayload {
|
|
128
|
+
/** State controller key ID */
|
|
129
|
+
readonly key_id: string;
|
|
130
|
+
readonly controller_id: string;
|
|
131
|
+
constructor({ key_id, controller_id }: DeleteStateControllerPayload);
|
|
132
|
+
get eoaRequestSchema(): {
|
|
133
|
+
Request: {
|
|
134
|
+
name: string;
|
|
135
|
+
type: string;
|
|
136
|
+
}[];
|
|
137
|
+
DeleteStateControllerRequest: {
|
|
93
138
|
name: string;
|
|
94
139
|
type: string;
|
|
95
140
|
}[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StateControllerPartitionField, StateControllerWindowConfig } from '../policy';
|
|
1
2
|
/**
|
|
2
3
|
* Response from the SDK for keygen. Receive plaintext response from network.
|
|
3
4
|
* @public
|
|
@@ -78,13 +79,50 @@ export interface RegisterPasskeyResponse {
|
|
|
78
79
|
passkeyCredentialId: string;
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
|
-
* Response from the network for updating
|
|
82
|
+
* Response from the network for updating policy request.
|
|
82
83
|
* @public
|
|
83
84
|
*/
|
|
84
85
|
export type UpdatePolicyResponse = SimpleResponse;
|
|
85
86
|
/**
|
|
86
|
-
* Response from the network for deleting
|
|
87
|
+
* Response from the network for deleting policy request.
|
|
87
88
|
* @public
|
|
88
89
|
*/
|
|
89
90
|
export type DeletePolicyResponse = SimpleResponse;
|
|
91
|
+
/**
|
|
92
|
+
* Response from the network for getting policy state entry, included in state controller get request.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export interface StateEntryResponse {
|
|
96
|
+
controller_id: string;
|
|
97
|
+
partition_key: string;
|
|
98
|
+
value: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Response from the network for getting policy state controller request.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export interface StateControllerResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
key_id: string;
|
|
107
|
+
description: string;
|
|
108
|
+
method: string;
|
|
109
|
+
window_config: StateControllerWindowConfig;
|
|
110
|
+
partition_by: StateControllerPartitionField[];
|
|
111
|
+
referenced_by: string | null;
|
|
112
|
+
entries: StateEntryResponse[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Response from the network for policy state controllers GET request.
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
export interface GetStateControllersResponse {
|
|
119
|
+
controllers: StateControllerResponse[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Response from the network for deleting policy state controller request.
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
export interface DeleteStateControllerResponse {
|
|
126
|
+
status: string;
|
|
127
|
+
}
|
|
90
128
|
export {};
|
|
@@ -7,7 +7,7 @@ import { Policy } from '../policy';
|
|
|
7
7
|
* Supported signature algorithms for MPC signing.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export type MPCSignAlgorithm = 'ed25519' | 'secp256k1';
|
|
10
|
+
export type MPCSignAlgorithm = 'ed25519' | 'secp256k1' | 'mldsa44' | 'mldsa65' | 'mldsa87';
|
|
11
11
|
/** The networkSigner contains an API to communicate with the Silent MPC Network. Call to sign and keygen require
|
|
12
12
|
* the Auth module, that is used to prompt the User before executing the request.
|
|
13
13
|
* @public
|
|
@@ -2,7 +2,7 @@ import { AuthModule } from '../auth/authentication';
|
|
|
2
2
|
import { type KeygenResponse, type SignResponse, type AddEphKeyResponse, type RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse, UpdatePolicyResponse, DeletePolicyResponse } from './networkResponse';
|
|
3
3
|
import { KeygenSetupOpts, SignSetupOpts } from '../setupMessage';
|
|
4
4
|
import { ApiVersion, type ClientConfig, IWalletProviderServiceClient, Slug, RequestPayloadV1, RequestPayloadV2, INoAuthWpServiceClient, NoAuthSlug, NoAuthRequestPayload } from './walletProviderServiceClientInterface';
|
|
5
|
-
import { AddEphKeyRequest,
|
|
5
|
+
import { AddEphKeyRequest, KeyIdOfPolicy, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest, UpdatePolicyRequest } from './networkRequest';
|
|
6
6
|
declare enum ProtocolState {
|
|
7
7
|
initiated = 0,
|
|
8
8
|
waitingForSign = 1,
|
|
@@ -52,7 +52,7 @@ export declare class WalletProviderServiceClient implements IWalletProviderServi
|
|
|
52
52
|
authModule: AuthModule;
|
|
53
53
|
}): Promise<UpdatePolicyResponse>;
|
|
54
54
|
deletePolicy({ payload, authModule, }: {
|
|
55
|
-
payload:
|
|
55
|
+
payload: KeyIdOfPolicy;
|
|
56
56
|
authModule: AuthModule;
|
|
57
57
|
}): Promise<DeletePolicyResponse>;
|
|
58
58
|
connect(slug: Slug, payload: RequestPayloadV1, authModule: AuthModule): Promise<string>;
|
|
@@ -97,7 +97,7 @@ export declare class NoAuthWalletProviderServiceClient implements INoAuthWpServi
|
|
|
97
97
|
payload: UpdatePolicyRequest;
|
|
98
98
|
}): Promise<UpdatePolicyResponse>;
|
|
99
99
|
deletePolicy({ payload }: {
|
|
100
|
-
payload:
|
|
100
|
+
payload: KeyIdOfPolicy;
|
|
101
101
|
}): Promise<DeletePolicyResponse>;
|
|
102
102
|
connect(slug: NoAuthSlug, payload: NoAuthRequestPayload): Promise<string>;
|
|
103
103
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthModule, UserAuthentication } from '../auth/authentication';
|
|
2
2
|
import { KeygenResponse, SignResponse, AddEphKeyResponse, RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse, UpdatePolicyResponse, DeletePolicyResponse } from './networkResponse';
|
|
3
3
|
import { KeygenSetupOpts, SignSetupOpts, InitPresignOpts, FinishPresignOpts } from '../setupMessage';
|
|
4
|
-
import { AddEphKeyRequest,
|
|
4
|
+
import { AddEphKeyRequest, CreateStateControllerRequest, KeyIdOfPolicy, DeleteStateControllerRequest, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest, UpdatePolicyRequest } from './networkRequest';
|
|
5
5
|
/**
|
|
6
6
|
* The config used to create Wallet Provider Service backend client.
|
|
7
7
|
* Please refer to {@link https://shipyard.rs/silencelaboratories/crates/wallet-provider-service | example backend service}
|
|
@@ -24,7 +24,10 @@ export type ClientConfig = {
|
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
26
|
export type ApiVersion = 'v1' | 'v2';
|
|
27
|
-
export type
|
|
27
|
+
export type WpChallengeMessage = string;
|
|
28
|
+
export type WpResultMessage = string;
|
|
29
|
+
export type WpUserSignatures = Record<string, UserAuthentication>;
|
|
30
|
+
export type Signer = (challenge: WpChallengeMessage) => Promise<UserAuthentication>;
|
|
28
31
|
/** Interface for client of Wallet Provider Service
|
|
29
32
|
* @public
|
|
30
33
|
*/
|
|
@@ -59,16 +62,17 @@ export interface IWalletProviderServiceClient {
|
|
|
59
62
|
authModule: AuthModule;
|
|
60
63
|
}): Promise<UpdatePolicyResponse>;
|
|
61
64
|
deletePolicy({ payload, authModule, }: {
|
|
62
|
-
payload:
|
|
65
|
+
payload: KeyIdOfPolicy;
|
|
63
66
|
authModule: AuthModule;
|
|
64
67
|
}): Promise<DeletePolicyResponse>;
|
|
65
68
|
}
|
|
66
|
-
export type Slug = 'signgen' | 'keygen' | 'keyRefresh' | 'quorumChange' | 'addEphemeralKey' | 'revokeEphemeralKey' | 'registerPasskey' | 'initPresign' | 'finishPresign' | 'updatePolicy' | 'deletePolicy';
|
|
67
|
-
export type RequestPayloadV1 = KeygenSetupOpts[] | KeyRefreshRequest | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | RegisterPasskeyRequest | UpdatePolicyRequest |
|
|
68
|
-
export type RequestPayloadV2 = KeygenSetupOpts[] | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | InitPresignOpts | FinishPresignOpts | UpdatePolicyRequest |
|
|
69
|
+
export type Slug = 'signgen' | 'keygen' | 'keyRefresh' | 'quorumChange' | 'addEphemeralKey' | 'revokeEphemeralKey' | 'registerPasskey' | 'initPresign' | 'finishPresign' | 'updatePolicy' | 'deletePolicy' | 'getStateControllers' | 'createStateController' | 'deleteStateController';
|
|
70
|
+
export type RequestPayloadV1 = KeygenSetupOpts[] | KeyRefreshRequest | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | RegisterPasskeyRequest | UpdatePolicyRequest | KeyIdOfPolicy | FinishPresignOpts;
|
|
71
|
+
export type RequestPayloadV2 = KeygenSetupOpts[] | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | InitPresignOpts | FinishPresignOpts | UpdatePolicyRequest | KeyIdOfPolicy | CreateStateControllerRequest | DeleteStateControllerRequest;
|
|
72
|
+
export type WpPayload = RequestPayloadV1 | RequestPayloadV2;
|
|
69
73
|
export interface WpRequest {
|
|
70
|
-
payload:
|
|
71
|
-
userSigs:
|
|
74
|
+
payload: WpPayload;
|
|
75
|
+
userSigs: WpUserSignatures | undefined;
|
|
72
76
|
}
|
|
73
77
|
/** Interface for client of Wallet Provider Service
|
|
74
78
|
* @public
|
|
@@ -88,8 +92,8 @@ export interface INoAuthWpServiceClient {
|
|
|
88
92
|
payload: UpdatePolicyRequest;
|
|
89
93
|
}): Promise<UpdatePolicyResponse>;
|
|
90
94
|
deletePolicy({ payload }: {
|
|
91
|
-
payload:
|
|
95
|
+
payload: KeyIdOfPolicy;
|
|
92
96
|
}): Promise<DeletePolicyResponse>;
|
|
93
97
|
}
|
|
94
98
|
export type NoAuthSlug = 'signgen' | 'keygen' | 'keyRefresh' | 'updatePolicy' | 'deletePolicy';
|
|
95
|
-
export type NoAuthRequestPayload = KeygenSetupOpts[] | SignSetupOpts | InitPresignOpts | FinishPresignOpts | KeyRefreshRequest | UpdatePolicyRequest |
|
|
99
|
+
export type NoAuthRequestPayload = KeygenSetupOpts[] | SignSetupOpts | InitPresignOpts | FinishPresignOpts | KeyRefreshRequest | UpdatePolicyRequest | KeyIdOfPolicy;
|