@dfns/sdk 0.8.19 → 0.8.21

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.
@@ -3,6 +3,26 @@ import * as T from './types';
3
3
  export declare class SignersClient {
4
4
  private apiOptions;
5
5
  constructor(apiOptions: DfnsApiClientOptions);
6
+ createCloneInput(request: T.CreateCloneInputRequest): Promise<T.CreateCloneInputResponse>;
7
+ createGenesisInput(request: T.CreateGenesisInputRequest): Promise<T.CreateGenesisInputResponse>;
8
+ createOnchainSignInput(request: T.CreateOnchainSignInputRequest): Promise<T.CreateOnchainSignInputResponse>;
9
+ createProofOfControlInput(request: T.CreateProofOfControlInputRequest): Promise<T.CreateProofOfControlInputResponse>;
6
10
  listKeyStores(): Promise<T.ListKeyStoresResponse>;
7
11
  listSigners(): Promise<T.ListSignersResponse>;
12
+ submitCloneOutput(request: T.SubmitCloneOutputRequest, file: {
13
+ bytes: Uint8Array;
14
+ name?: string;
15
+ }): Promise<T.SubmitCloneOutputResponse>;
16
+ submitGenesisOutput(request: T.SubmitGenesisOutputRequest, file: {
17
+ bytes: Uint8Array;
18
+ name?: string;
19
+ }): Promise<T.SubmitGenesisOutputResponse>;
20
+ submitOnchainSignOutput(request: T.SubmitOnchainSignOutputRequest, file: {
21
+ bytes: Uint8Array;
22
+ name?: string;
23
+ }): Promise<T.SubmitOnchainSignOutputResponse>;
24
+ submitProofOfControlOutput(request: T.SubmitProofOfControlOutputRequest, file: {
25
+ bytes: Uint8Array;
26
+ name?: string;
27
+ }): Promise<T.SubmitProofOfControlOutputResponse>;
8
28
  }
@@ -3,11 +3,60 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.SignersClient = void 0;
5
5
  const fetch_1 = require("../../utils/fetch");
6
+ const userActionFetch_1 = require("../../utils/userActionFetch");
6
7
  const url_1 = require("../../utils/url");
7
8
  class SignersClient {
8
9
  constructor(apiOptions) {
9
10
  this.apiOptions = apiOptions;
10
11
  }
12
+ async createCloneInput(request) {
13
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/clone/input', {
14
+ path: request ?? {},
15
+ query: {},
16
+ });
17
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
18
+ method: 'POST',
19
+ body: request.body,
20
+ apiOptions: this.apiOptions,
21
+ });
22
+ return response.json();
23
+ }
24
+ async createGenesisInput(request) {
25
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/genesis/input', {
26
+ path: request ?? {},
27
+ query: {},
28
+ });
29
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
30
+ method: 'POST',
31
+ body: request.body,
32
+ apiOptions: this.apiOptions,
33
+ });
34
+ return response.json();
35
+ }
36
+ async createOnchainSignInput(request) {
37
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/onchain-sign/input', {
38
+ path: request ?? {},
39
+ query: {},
40
+ });
41
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
42
+ method: 'POST',
43
+ body: request.body,
44
+ apiOptions: this.apiOptions,
45
+ });
46
+ return response.json();
47
+ }
48
+ async createProofOfControlInput(request) {
49
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/proof-of-control/input', {
50
+ path: request ?? {},
51
+ query: {},
52
+ });
53
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
54
+ method: 'POST',
55
+ body: request.body,
56
+ apiOptions: this.apiOptions,
57
+ });
58
+ return response.json();
59
+ }
11
60
  async listKeyStores() {
12
61
  const path = (0, url_1.buildPathAndQuery)('/key-stores', {
13
62
  path: {},
@@ -30,5 +79,57 @@ class SignersClient {
30
79
  });
31
80
  return response.json();
32
81
  }
82
+ async submitCloneOutput(request, file) {
83
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/clone/output', {
84
+ path: request ?? {},
85
+ query: {},
86
+ });
87
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
88
+ method: 'POST',
89
+ body: request.body,
90
+ file,
91
+ apiOptions: this.apiOptions,
92
+ });
93
+ return response.json();
94
+ }
95
+ async submitGenesisOutput(request, file) {
96
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/genesis/output', {
97
+ path: request ?? {},
98
+ query: {},
99
+ });
100
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
101
+ method: 'POST',
102
+ body: request.body,
103
+ file,
104
+ apiOptions: this.apiOptions,
105
+ });
106
+ return response.json();
107
+ }
108
+ async submitOnchainSignOutput(request, file) {
109
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/onchain-sign/output', {
110
+ path: request ?? {},
111
+ query: {},
112
+ });
113
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
114
+ method: 'POST',
115
+ body: request.body,
116
+ file,
117
+ apiOptions: this.apiOptions,
118
+ });
119
+ return response.json();
120
+ }
121
+ async submitProofOfControlOutput(request, file) {
122
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/proof-of-control/output', {
123
+ path: request ?? {},
124
+ query: {},
125
+ });
126
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
127
+ method: 'POST',
128
+ body: request.body,
129
+ file,
130
+ apiOptions: this.apiOptions,
131
+ });
132
+ return response.json();
133
+ }
33
134
  }
34
135
  exports.SignersClient = SignersClient;
@@ -1,8 +1,17 @@
1
+ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
1
2
  import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
2
3
  import * as T from './types';
3
4
  export declare class DelegatedSignersClient {
4
5
  private apiOptions;
5
6
  constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ createCloneInputInit(request: T.CreateCloneInputRequest): Promise<UserActionChallengeResponse>;
8
+ createCloneInputComplete(request: T.CreateCloneInputRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateCloneInputResponse>;
9
+ createGenesisInputInit(request: T.CreateGenesisInputRequest): Promise<UserActionChallengeResponse>;
10
+ createGenesisInputComplete(request: T.CreateGenesisInputRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateGenesisInputResponse>;
11
+ createOnchainSignInputInit(request: T.CreateOnchainSignInputRequest): Promise<UserActionChallengeResponse>;
12
+ createOnchainSignInputComplete(request: T.CreateOnchainSignInputRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateOnchainSignInputResponse>;
13
+ createProofOfControlInputInit(request: T.CreateProofOfControlInputRequest): Promise<UserActionChallengeResponse>;
14
+ createProofOfControlInputComplete(request: T.CreateProofOfControlInputRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateProofOfControlInputResponse>;
6
15
  listKeyStores(): Promise<T.ListKeyStoresResponse>;
7
16
  listSigners(): Promise<T.ListSignersResponse>;
8
17
  }
@@ -1,12 +1,121 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DelegatedSignersClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
4
5
  const fetch_1 = require("../../utils/fetch");
5
6
  const url_1 = require("../../utils/url");
6
7
  class DelegatedSignersClient {
7
8
  constructor(apiOptions) {
8
9
  this.apiOptions = apiOptions;
9
10
  }
11
+ async createCloneInputInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/clone/input', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
17
+ userActionHttpMethod: 'POST',
18
+ userActionHttpPath: path,
19
+ userActionPayload: JSON.stringify(request.body),
20
+ userActionServerKind: 'Api',
21
+ }, this.apiOptions);
22
+ return challenge;
23
+ }
24
+ async createCloneInputComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/clone/input', {
26
+ path: request ?? {},
27
+ query: {},
28
+ });
29
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
30
+ const response = await (0, fetch_1.simpleFetch)(path, {
31
+ method: 'POST',
32
+ body: request.body,
33
+ headers: { 'x-dfns-useraction': userAction },
34
+ apiOptions: this.apiOptions,
35
+ });
36
+ return response.json();
37
+ }
38
+ async createGenesisInputInit(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/genesis/input', {
40
+ path: request ?? {},
41
+ query: {},
42
+ });
43
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
44
+ userActionHttpMethod: 'POST',
45
+ userActionHttpPath: path,
46
+ userActionPayload: JSON.stringify(request.body),
47
+ userActionServerKind: 'Api',
48
+ }, this.apiOptions);
49
+ return challenge;
50
+ }
51
+ async createGenesisInputComplete(request, signedChallenge) {
52
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/genesis/input', {
53
+ path: request ?? {},
54
+ query: {},
55
+ });
56
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
57
+ const response = await (0, fetch_1.simpleFetch)(path, {
58
+ method: 'POST',
59
+ body: request.body,
60
+ headers: { 'x-dfns-useraction': userAction },
61
+ apiOptions: this.apiOptions,
62
+ });
63
+ return response.json();
64
+ }
65
+ async createOnchainSignInputInit(request) {
66
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/onchain-sign/input', {
67
+ path: request ?? {},
68
+ query: {},
69
+ });
70
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
71
+ userActionHttpMethod: 'POST',
72
+ userActionHttpPath: path,
73
+ userActionPayload: JSON.stringify(request.body),
74
+ userActionServerKind: 'Api',
75
+ }, this.apiOptions);
76
+ return challenge;
77
+ }
78
+ async createOnchainSignInputComplete(request, signedChallenge) {
79
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/onchain-sign/input', {
80
+ path: request ?? {},
81
+ query: {},
82
+ });
83
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
84
+ const response = await (0, fetch_1.simpleFetch)(path, {
85
+ method: 'POST',
86
+ body: request.body,
87
+ headers: { 'x-dfns-useraction': userAction },
88
+ apiOptions: this.apiOptions,
89
+ });
90
+ return response.json();
91
+ }
92
+ async createProofOfControlInputInit(request) {
93
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/proof-of-control/input', {
94
+ path: request ?? {},
95
+ query: {},
96
+ });
97
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
98
+ userActionHttpMethod: 'POST',
99
+ userActionHttpPath: path,
100
+ userActionPayload: JSON.stringify(request.body),
101
+ userActionServerKind: 'Api',
102
+ }, this.apiOptions);
103
+ return challenge;
104
+ }
105
+ async createProofOfControlInputComplete(request, signedChallenge) {
106
+ const path = (0, url_1.buildPathAndQuery)('/key-stores/:storeId/proof-of-control/input', {
107
+ path: request ?? {},
108
+ query: {},
109
+ });
110
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
111
+ const response = await (0, fetch_1.simpleFetch)(path, {
112
+ method: 'POST',
113
+ body: request.body,
114
+ headers: { 'x-dfns-useraction': userAction },
115
+ apiOptions: this.apiOptions,
116
+ });
117
+ return response.json();
118
+ }
10
119
  async listKeyStores() {
11
120
  const path = (0, url_1.buildPathAndQuery)('/key-stores', {
12
121
  path: {},
@@ -1,7 +1,52 @@
1
+ export type CreateCloneInputBody = {
2
+ kind: "Clone";
3
+ hsmSourceSerial: string;
4
+ hsmTargetSerial: string;
5
+ };
6
+ export type CreateCloneInputParams = {
7
+ storeId: string;
8
+ };
9
+ export type CreateCloneInputResponse = string;
10
+ export type CreateCloneInputRequest = CreateCloneInputParams & {
11
+ body: CreateCloneInputBody;
12
+ };
13
+ export type CreateGenesisInputBody = {
14
+ kind: "Genesis";
15
+ numProvisioners: number;
16
+ numSecp256k1: number;
17
+ numEd25519: number;
18
+ hsmGenesisSerial: string;
19
+ hsmGenesisFirmwareVersion?: ("2.2" | "2.4") | undefined;
20
+ };
21
+ export type CreateGenesisInputParams = {
22
+ storeId: string;
23
+ };
24
+ export type CreateGenesisInputResponse = string;
25
+ export type CreateGenesisInputRequest = CreateGenesisInputParams & {
26
+ body: CreateGenesisInputBody;
27
+ };
28
+ export type CreateOnchainSignInputBody = {};
29
+ export type CreateOnchainSignInputParams = {
30
+ storeId: string;
31
+ };
32
+ export type CreateOnchainSignInputResponse = string;
33
+ export type CreateOnchainSignInputRequest = CreateOnchainSignInputParams & {
34
+ body: CreateOnchainSignInputBody;
35
+ };
36
+ export type CreateProofOfControlInputBody = {
37
+ walletIds: string[];
38
+ };
39
+ export type CreateProofOfControlInputParams = {
40
+ storeId: string;
41
+ };
42
+ export type CreateProofOfControlInputResponse = string;
43
+ export type CreateProofOfControlInputRequest = CreateProofOfControlInputParams & {
44
+ body: CreateProofOfControlInputBody;
45
+ };
1
46
  export type ListKeyStoresResponse = {
2
47
  items: {
3
48
  id: string;
4
- kind: "Hsm" | "Mpc";
49
+ kind: "Hsm" | "Mpc" | "OfflineSigner";
5
50
  name?: string | undefined;
6
51
  primary: boolean;
7
52
  }[];
@@ -15,3 +60,223 @@ export type ListSignersResponse = {
15
60
  }[];
16
61
  }[];
17
62
  };
63
+ export type __WireSubmitCloneOutputBody = {
64
+ fileChecksum: string;
65
+ outputJson: {
66
+ type: "fleet-output";
67
+ version: 1;
68
+ status: "success";
69
+ org_id: string;
70
+ fleet_id: string;
71
+ fleet_label: string;
72
+ keystore_id: string;
73
+ outputs: {
74
+ [x: string]: {
75
+ success: {
76
+ type: "genesis-registration";
77
+ ceremony_mode: string;
78
+ hsm_serial: string;
79
+ hsm_identity_key: string;
80
+ mac_serial: string;
81
+ mac_se_wrap_key_pub_key: string;
82
+ provisioners: {
83
+ [x: string]: string;
84
+ };
85
+ hsm_sealed?: unknown | null;
86
+ key_harvest: {
87
+ "ed25519-start": number;
88
+ ed25519: number;
89
+ error: string | null;
90
+ "secp256k1-start": number;
91
+ secp256k1: number;
92
+ };
93
+ } | {
94
+ type: "clone-registration";
95
+ ceremony_mode: string;
96
+ hsm_target_serial: string;
97
+ hsm_identity_key: string;
98
+ mac_target_serial: string;
99
+ mac_se_wrap_key_pub_key: string;
100
+ hsm_sealed?: unknown | null;
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ export type SubmitCloneOutputBody = Omit<__WireSubmitCloneOutputBody, 'fileChecksum'>;
107
+ export type SubmitCloneOutputParams = {
108
+ storeId: string;
109
+ };
110
+ export type SubmitCloneOutputResponse = {
111
+ message: string;
112
+ };
113
+ export type SubmitCloneOutputRequest = SubmitCloneOutputParams & {
114
+ body: SubmitCloneOutputBody;
115
+ };
116
+ export type __WireSubmitGenesisOutputBody = {
117
+ fileChecksum: string;
118
+ outputJson: {
119
+ type: "fleet-output";
120
+ version: 1;
121
+ status: "success";
122
+ org_id: string;
123
+ fleet_id: string;
124
+ fleet_label: string;
125
+ keystore_id: string;
126
+ outputs: {
127
+ [x: string]: {
128
+ success: {
129
+ type: "genesis-registration";
130
+ ceremony_mode: string;
131
+ hsm_serial: string;
132
+ hsm_identity_key: string;
133
+ mac_serial: string;
134
+ mac_se_wrap_key_pub_key: string;
135
+ provisioners: {
136
+ [x: string]: string;
137
+ };
138
+ hsm_sealed?: unknown | null;
139
+ key_harvest: {
140
+ "ed25519-start": number;
141
+ ed25519: number;
142
+ error: string | null;
143
+ "secp256k1-start": number;
144
+ secp256k1: number;
145
+ };
146
+ } | {
147
+ type: "clone-registration";
148
+ ceremony_mode: string;
149
+ hsm_target_serial: string;
150
+ hsm_identity_key: string;
151
+ mac_target_serial: string;
152
+ mac_se_wrap_key_pub_key: string;
153
+ hsm_sealed?: unknown | null;
154
+ };
155
+ };
156
+ };
157
+ };
158
+ };
159
+ export type SubmitGenesisOutputBody = Omit<__WireSubmitGenesisOutputBody, 'fileChecksum'>;
160
+ export type SubmitGenesisOutputParams = {
161
+ storeId: string;
162
+ };
163
+ export type SubmitGenesisOutputResponse = {
164
+ message: string;
165
+ };
166
+ export type SubmitGenesisOutputRequest = SubmitGenesisOutputParams & {
167
+ body: SubmitGenesisOutputBody;
168
+ };
169
+ export type __WireSubmitOnchainSignOutputBody = {
170
+ fileChecksum: string;
171
+ outputJson: {
172
+ type: "keystore-output";
173
+ version: 1;
174
+ org_id: string;
175
+ fleet_id: string;
176
+ keystore_id: string;
177
+ group_id: string;
178
+ status: "success" | "partial" | "fail";
179
+ outputs: {
180
+ [x: string]: {
181
+ type: "proof-of-control-v1";
182
+ result: {
183
+ success: {
184
+ signer_public_key: string;
185
+ prefix: string;
186
+ message: string;
187
+ exact_bytes_signed: string;
188
+ signature: string;
189
+ };
190
+ } | {
191
+ fail: {
192
+ message: string;
193
+ code: string;
194
+ };
195
+ };
196
+ } | {
197
+ type: "onchain-sign-v1";
198
+ result: {
199
+ success: {
200
+ [x: string]: {
201
+ signer_public_key: string;
202
+ exact_bytes_signed: string;
203
+ signature: string;
204
+ };
205
+ };
206
+ } | {
207
+ fail: {
208
+ message: string;
209
+ code: string;
210
+ };
211
+ };
212
+ };
213
+ };
214
+ };
215
+ };
216
+ export type SubmitOnchainSignOutputBody = Omit<__WireSubmitOnchainSignOutputBody, 'fileChecksum'>;
217
+ export type SubmitOnchainSignOutputParams = {
218
+ storeId: string;
219
+ };
220
+ export type SubmitOnchainSignOutputResponse = {
221
+ status: "success" | "partial";
222
+ };
223
+ export type SubmitOnchainSignOutputRequest = SubmitOnchainSignOutputParams & {
224
+ body: SubmitOnchainSignOutputBody;
225
+ };
226
+ export type __WireSubmitProofOfControlOutputBody = {
227
+ fileChecksum: string;
228
+ outputJson: {
229
+ type: "keystore-output";
230
+ version: 1;
231
+ org_id: string;
232
+ fleet_id: string;
233
+ keystore_id: string;
234
+ group_id: string;
235
+ status: "success" | "partial" | "fail";
236
+ outputs: {
237
+ [x: string]: {
238
+ type: "proof-of-control-v1";
239
+ result: {
240
+ success: {
241
+ signer_public_key: string;
242
+ prefix: string;
243
+ message: string;
244
+ exact_bytes_signed: string;
245
+ signature: string;
246
+ };
247
+ } | {
248
+ fail: {
249
+ message: string;
250
+ code: string;
251
+ };
252
+ };
253
+ } | {
254
+ type: "onchain-sign-v1";
255
+ result: {
256
+ success: {
257
+ [x: string]: {
258
+ signer_public_key: string;
259
+ exact_bytes_signed: string;
260
+ signature: string;
261
+ };
262
+ };
263
+ } | {
264
+ fail: {
265
+ message: string;
266
+ code: string;
267
+ };
268
+ };
269
+ };
270
+ };
271
+ };
272
+ };
273
+ export type SubmitProofOfControlOutputBody = Omit<__WireSubmitProofOfControlOutputBody, 'fileChecksum'>;
274
+ export type SubmitProofOfControlOutputParams = {
275
+ storeId: string;
276
+ };
277
+ export type SubmitProofOfControlOutputResponse = {
278
+ status: "success" | "partial";
279
+ };
280
+ export type SubmitProofOfControlOutputRequest = SubmitProofOfControlOutputParams & {
281
+ body: SubmitProofOfControlOutputBody;
282
+ };