@@ -5,11 +5,12 @@ import (
5
5
"fmt"
6
6
"net/url"
7
7
8
+ "github.com/googleapis/gax-go/v2"
9
+ "google.golang.org/grpc"
10
+
8
11
"github.com/coinbase/waas-client-library-go/clients"
9
12
innerClient "github.com/coinbase/waas-client-library-go/gen/go/coinbase/cloud/clients/v1"
10
13
mpc_keyspb "github.com/coinbase/waas-client-library-go/gen/go/coinbase/cloud/mpc_keys/v1"
11
- "github.com/googleapis/gax-go/v2"
12
- "google.golang.org/grpc"
13
14
)
14
15
15
16
const (
@@ -260,3 +261,221 @@ func (m *MPCKeyServiceClient) CreateSignatureOperation(name string) *WrappedCrea
260
261
pathPrefix : m .pathPrefix ,
261
262
}
262
263
}
264
+
265
+ // WrappedPrepareDeviceArchiveOperation wraps the long-running operation to handle
266
+ // unwrapping errors and setting the LRO options.
267
+ type WrappedPrepareDeviceArchiveOperation struct {
268
+ * innerClient.PrepareDeviceArchiveOperation
269
+ pathPrefix string
270
+ }
271
+
272
+ // PathPrefix returns the path prefix for the operation to be used in HTTP requests.
273
+ // E.g. if the path prefix is `/waas/mpc_keys`, then the request path would be:
274
+ // `/waas/mpc_keys/v1/operations/<operationId>`.
275
+ func (w * WrappedPrepareDeviceArchiveOperation ) PathPrefix () string {
276
+ return w .pathPrefix
277
+ }
278
+
279
+ // Wait delegates to the wrapped longrunning PrepareDeviceArchiveOperation with the
280
+ // override LRO options and handling unwrapping client errors.
281
+ func (w * WrappedPrepareDeviceArchiveOperation ) Wait (
282
+ ctx context.Context ,
283
+ opts ... gax.CallOption ,
284
+ ) (* mpc_keyspb.DeviceGroup , error ) {
285
+ deviceGroup , err := w .PrepareDeviceArchiveOperation .Wait (ctx , clients .LROOptions (w , version , opts )... )
286
+
287
+ return deviceGroup , clients .UnwrapError (err )
288
+ }
289
+
290
+ // Poll delegates to the wrapped longrunning PrepareDeviceArchiveOperation with the
291
+ // override LRO options and handling unwrapping client errors.
292
+ func (w * WrappedPrepareDeviceArchiveOperation ) Poll (
293
+ ctx context.Context ,
294
+ opts ... gax.CallOption ,
295
+ ) (* mpc_keyspb.DeviceGroup , error ) {
296
+ deviceGroup , err := w .PrepareDeviceArchiveOperation .Poll (ctx , clients .LROOptions (w , version , opts )... )
297
+
298
+ return deviceGroup , clients .UnwrapError (err )
299
+ }
300
+
301
+ // PrepareDeviceArchive prepares an archive in the local storage of the given Device. The archive contains
302
+ // cryptographic materials that can be used to export MPCKeys, which have the given DeviceGroup as their parent.
303
+ // The Device specified in the request must be a member of this DeviceGroup and must participate
304
+ // in the associated MPC operation for the archive to be prepared. After calling this,
305
+ // use ListMPCOperations to poll for the pending PrepareDeviceArchive operation, and use the WaaS SDK's
306
+ // ComputeMPCOperation to complete the operation. Once the operation completes, the Device can utilize the
307
+ // WaaS SDK to export the private keys corresponding to each of the MPCKeys under this DeviceGroup.
308
+ func (m * MPCKeyServiceClient ) PrepareDeviceArchive (
309
+ ctx context.Context ,
310
+ req * mpc_keyspb.PrepareDeviceArchiveRequest ,
311
+ opts ... gax.CallOption ) (* WrappedPrepareDeviceArchiveOperation , error ) {
312
+ op , err := m .client .PrepareDeviceArchive (ctx , req , opts ... )
313
+ if err != nil {
314
+ return nil , clients .UnwrapError (err )
315
+ }
316
+
317
+ return & WrappedPrepareDeviceArchiveOperation {
318
+ PrepareDeviceArchiveOperation : op ,
319
+ pathPrefix : m .pathPrefix ,
320
+ }, nil
321
+ }
322
+
323
+ // PrepareDeviceArchiveOperation returns the PrepareDeviceArchiveOperation indicated by the given name.
324
+ func (m * MPCKeyServiceClient ) PrepareDeviceArchiveOperation (name string ) * WrappedPrepareDeviceArchiveOperation {
325
+ return & WrappedPrepareDeviceArchiveOperation {
326
+ PrepareDeviceArchiveOperation : m .client .PrepareDeviceArchiveOperation (name ),
327
+ pathPrefix : m .pathPrefix ,
328
+ }
329
+ }
330
+
331
+ // WrappedPrepareDeviceBackupOperation wraps the long-running operation to handle
332
+ // unwrapping errors and setting the LRO options.
333
+ type WrappedPrepareDeviceBackupOperation struct {
334
+ * innerClient.PrepareDeviceBackupOperation
335
+ pathPrefix string
336
+ }
337
+
338
+ // PathPrefix returns the path prefix for the operation to be used in HTTP requests.
339
+ // E.g. if the path prefix is `/waas/mpc_keys`, then the request path would be:
340
+ // `/waas/mpc_keys/v1/operations/<operationId>`.
341
+ func (w * WrappedPrepareDeviceBackupOperation ) PathPrefix () string {
342
+ return w .pathPrefix
343
+ }
344
+
345
+ // Wait delegates to the wrapped longrunning PrepareDeviceBackupOperation with the
346
+ // override LRO options and handling unwrapping client errors.
347
+ func (w * WrappedPrepareDeviceBackupOperation ) Wait (
348
+ ctx context.Context ,
349
+ opts ... gax.CallOption ,
350
+ ) (* mpc_keyspb.DeviceGroup , error ) {
351
+ deviceGroup , err := w .PrepareDeviceBackupOperation .Wait (ctx , clients .LROOptions (w , version , opts )... )
352
+
353
+ return deviceGroup , clients .UnwrapError (err )
354
+ }
355
+
356
+ // Poll delegates to the wrapped longrunning PrepareDeviceBackupOperation with the
357
+ // override LRO options and handling unwrapping client errors.
358
+ func (w * WrappedPrepareDeviceBackupOperation ) Poll (
359
+ ctx context.Context ,
360
+ opts ... gax.CallOption ,
361
+ ) (* mpc_keyspb.DeviceGroup , error ) {
362
+ deviceGroup , err := w .PrepareDeviceBackupOperation .Poll (ctx , clients .LROOptions (w , version , opts )... )
363
+
364
+ return deviceGroup , clients .UnwrapError (err )
365
+ }
366
+
367
+ // PrepareDeviceBackup prepares a backup in the given Device. The backup contains certain
368
+ // cryptographic materials that can be used to restore MPCKeys, which have the given DeviceGroup as their parent,
369
+ // on a new Device. The Device specified in the request must be a member of this DeviceGroup and must participate
370
+ // in the associated MPC operation for the backup to be prepared.
371
+ // After calling this RPC, use ListMPCOperations to poll for the pending PrepareDeviceBackup operation,
372
+ // and use the WaaS SDK's ComputeMPCOperation to complete the operation. Once the operation completes,
373
+ // the Device can utilize WaaS SDK to download the backup bundle. We recommend storing this backup bundle securely
374
+ // in a storage provider of your choice. If the user loses access to their existing Device and wants to recover
375
+ // MPCKeys in the given DeviceGroup on a new Device, use AddDevice RPC on the MPCKeyService.
376
+ func (m * MPCKeyServiceClient ) PrepareDeviceBackup (
377
+ ctx context.Context ,
378
+ req * mpc_keyspb.PrepareDeviceBackupRequest ,
379
+ opts ... gax.CallOption ) (* WrappedPrepareDeviceBackupOperation , error ) {
380
+ op , err := m .client .PrepareDeviceBackup (ctx , req , opts ... )
381
+ if err != nil {
382
+ return nil , clients .UnwrapError (err )
383
+ }
384
+
385
+ return & WrappedPrepareDeviceBackupOperation {
386
+ PrepareDeviceBackupOperation : op ,
387
+ pathPrefix : m .pathPrefix ,
388
+ }, nil
389
+ }
390
+
391
+ // PrepareDeviceBackupOperation returns the PrepareDeviceBackupOperation indicated by the given name.
392
+ func (m * MPCKeyServiceClient ) PrepareDeviceBackupOperation (name string ) * WrappedPrepareDeviceBackupOperation {
393
+ return & WrappedPrepareDeviceBackupOperation {
394
+ PrepareDeviceBackupOperation : m .client .PrepareDeviceBackupOperation (name ),
395
+ pathPrefix : m .pathPrefix ,
396
+ }
397
+ }
398
+
399
+ // WrappedAddDeviceOperation wraps the long-running operation to handle
400
+ // unwrapping errors and setting the LRO options.
401
+ type WrappedAddDeviceOperation struct {
402
+ * innerClient.AddDeviceOperation
403
+ pathPrefix string
404
+ }
405
+
406
+ // PathPrefix returns the path prefix for the operation to be used in HTTP requests.
407
+ // E.g. if the path prefix is `/waas/mpc_keys`, then the request path would be:
408
+ // `/waas/mpc_keys/v1/operations/<operationId>`.
409
+ func (w * WrappedAddDeviceOperation ) PathPrefix () string {
410
+ return w .pathPrefix
411
+ }
412
+
413
+ // Wait delegates to the wrapped longrunning AddDeviceOperation with the
414
+ // override LRO options and handling unwrapping client errors.
415
+ func (w * WrappedAddDeviceOperation ) Wait (
416
+ ctx context.Context ,
417
+ opts ... gax.CallOption ,
418
+ ) (* mpc_keyspb.DeviceGroup , error ) {
419
+ deviceGroup , err := w .AddDeviceOperation .Wait (ctx , clients .LROOptions (w , version , opts )... )
420
+
421
+ return deviceGroup , clients .UnwrapError (err )
422
+ }
423
+
424
+ // Poll delegates to the wrapped longrunning AddDeviceOperation with the
425
+ // override LRO options and handling unwrapping client errors.
426
+ func (w * WrappedAddDeviceOperation ) Poll (
427
+ ctx context.Context ,
428
+ opts ... gax.CallOption ,
429
+ ) (* mpc_keyspb.DeviceGroup , error ) {
430
+ deviceGroup , err := w .AddDeviceOperation .Poll (ctx , clients .LROOptions (w , version , opts )... )
431
+
432
+ return deviceGroup , clients .UnwrapError (err )
433
+ }
434
+
435
+ // AddDevice adds a Device to an existing DeviceGroup. Prior to this API being called, the Device must be registered using
436
+ // RegisterDevice RPC. The Device must have access to the backup created with PrepareDeviceBackup RPC to compute this
437
+ // operation. After calling this RPC, use ListMPCOperations to poll for the pending AddDevice operation,
438
+ // and use the WaaS SDK's ComputeAddDeviceMPCOperation to complete the operation.
439
+ // After the operation is computed on WaaS SDK, the Device will have access to cryptographic materials
440
+ // required to process MPCOperations for this DeviceGroup.
441
+ // Once the operation completes on MPCKeyService, the Device will be added to the given DeviceGroup as a new member
442
+ // and all existing Devices in the DeviceGroup will stay functional.
443
+ // MPCKeyService will expose RemoveDevice RPC in a future release that can remove any of the
444
+ // existing Devices from the DeviceGroup.
445
+ func (m * MPCKeyServiceClient ) AddDevice (
446
+ ctx context.Context ,
447
+ req * mpc_keyspb.AddDeviceRequest ,
448
+ opts ... gax.CallOption ) (* WrappedAddDeviceOperation , error ) {
449
+ op , err := m .client .AddDevice (ctx , req , opts ... )
450
+ if err != nil {
451
+ return nil , clients .UnwrapError (err )
452
+ }
453
+
454
+ return & WrappedAddDeviceOperation {
455
+ AddDeviceOperation : op ,
456
+ pathPrefix : m .pathPrefix ,
457
+ }, nil
458
+ }
459
+
460
+ // AddDeviceOperation returns the AddDeviceOperation indicated by the given name.
461
+ func (m * MPCKeyServiceClient ) AddDeviceOperation (name string ) * WrappedAddDeviceOperation {
462
+ return & WrappedAddDeviceOperation {
463
+ AddDeviceOperation : m .client .AddDeviceOperation (name ),
464
+ pathPrefix : m .pathPrefix ,
465
+ }
466
+ }
467
+
468
+ // RevokeDevice revokes a registered Device. This operation removes the registered Device from all the DeviceGroups that it is a
469
+ // part of. Once the Device is revoked, cryptographic materials in your physical Device are invalidated,
470
+ // and the Device can no longer participate in any MPCOperations of the DeviceGroups it was a part of.
471
+ // Use this API in scenarios such as losing the existing Device, switching to a new physical Device, etc.
472
+ // Ensure that a new Device is successfully added to your DeviceGroups using the AddDevice RPC before invoking
473
+ // the RevokeDevice RPC.
474
+ func (m * MPCKeyServiceClient ) RevokeDevice (
475
+ ctx context.Context ,
476
+ req * mpc_keyspb.RevokeDeviceRequest ,
477
+ opts ... gax.CallOption ) error {
478
+ err := m .client .RevokeDevice (ctx , req , opts ... )
479
+
480
+ return clients .UnwrapError (err )
481
+ }
0 commit comments