@portal-hq/web 3.7.0 → 3.8.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/types.d.ts CHANGED
@@ -3,6 +3,98 @@ import { type DkgData, PortalError } from '@portal-hq/utils'
3
3
  import type { MpcErrorCodes } from './src/mpc/errors'
4
4
  import Portal, { BackupMethods, PortalCurve } from './src/index'
5
5
 
6
+ // Re-export shared types for backward compatibility
7
+ export type {
8
+ Address,
9
+ AddressResult,
10
+ BackupConfigs,
11
+ BackupData,
12
+ BackupResponse,
13
+ BackupResult,
14
+ Balance,
15
+ BuiltEip155Transaction,
16
+ BuiltSolanaTransaction,
17
+ BuiltTransaction,
18
+ CustomBackupConfig,
19
+ Dapp,
20
+ DappImage,
21
+ DappOnNetwork,
22
+ DecryptArgs,
23
+ DecryptData,
24
+ DecryptResult,
25
+ EIP1559Transaction,
26
+ EjectPrivateKeysResult,
27
+ EjectResult,
28
+ EncryptArgs,
29
+ EncryptedData,
30
+ EncryptedResult,
31
+ EncryptedWithPasswordData,
32
+ EncryptedWithPasswordResult,
33
+ EvaluatedTransaction,
34
+ EvaluateTransactionParam,
35
+ FeatureFlags,
36
+ FundParams,
37
+ FundResponse,
38
+ FundResponseData,
39
+ FundResponseMetadata,
40
+ GDriveConfig,
41
+ GenerateData,
42
+ GenerateResponse,
43
+ GenerateResult,
44
+ LegacyTransaction,
45
+ MpcStatus,
46
+ Network,
47
+ NFT,
48
+ NFTContract,
49
+ OrgBackupShares,
50
+ PasskeyConfig,
51
+ PasskeyStatusResponse,
52
+ PasswordConfig,
53
+ QuoteArgs,
54
+ QuoteResponse,
55
+ RotateData,
56
+ RotateResult,
57
+ SendAssetParams,
58
+ SendAssetResponse,
59
+ SharesOnDeviceResponse,
60
+ SignArgs,
61
+ SignResult,
62
+ SimulatedTransaction,
63
+ SimulatedTransactionChange,
64
+ SimulatedTransactionError,
65
+ SimulateTransactionParam,
66
+ SwitchEthereumChainParameter,
67
+ Transaction,
68
+ Type,
69
+ TypedData,
70
+ GetAssetsResponse,
71
+ IframeConfigurationOptions,
72
+ NFTAsset,
73
+ EvaluateTransactionOperationType,
74
+ PortalError,
75
+ } from './src/shared/types'
76
+
77
+ import type {
78
+ BackupConfigs,
79
+ FeatureFlags,
80
+ GDriveConfig,
81
+ MpcStatus,
82
+ OrgBackupShares,
83
+ PasskeyConfig,
84
+ DecryptArgs,
85
+ EncryptArgs,
86
+ SignArgs,
87
+ BackupResult,
88
+ DecryptResult,
89
+ EncryptedResult,
90
+ EncryptedWithPasswordResult,
91
+ GenerateResult,
92
+ SignResult,
93
+ EjectResult,
94
+ EIP1559Transaction,
95
+ LegacyTransaction,
96
+ } from './src/shared/types'
97
+
6
98
  export type EventHandler = (event: Event<any>) => void | Promise<void>
7
99
  export type EthereumTransaction = EIP1559Transaction | LegacyTransaction
8
100
  export type MessageData =
@@ -17,59 +109,9 @@ export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901
17
109
 
18
110
  // Interfaces
19
111
 
20
- export interface FeatureFlags {
21
- isMultiBackupEnabled?: boolean
22
- }
23
-
24
- export interface AddressResult {
25
- data: string
26
- type: string
27
- }
28
-
29
112
  export interface BackupArgs extends MpcOperationArgs {
30
113
  backupMethod: BackupMethods
31
- backupConfigs: BackupConfigs = {}
32
- }
33
-
34
-
35
- export interface CustomBackupConfig {
36
- encryptionKey: string
37
- }
38
-
39
- export interface BackupConfigs {
40
- passwordStorage?: PasswordConfig
41
- customStorage?: CustomBackupConfig
42
- }
43
-
44
- export interface OrgBackupShares {
45
- SECP256K1: string
46
- ED25519?: string
47
- }
48
-
49
- export interface PasswordConfig {
50
- password: string
51
- }
52
-
53
- export interface BackupData {
54
- share: string
55
- }
56
-
57
- export interface BackupResult {
58
- backupIds: string[]
59
- cipherText: string
60
- encryptionKey?: string
61
- }
62
-
63
- export interface Address {
64
- id: string
65
- network: Network
66
- value: string
67
- }
68
-
69
- export interface BackupResponse {
70
- cipherText: string
71
- storageCallback: () => Promise<void>
72
- encryptionKey?: string
114
+ backupConfigs: BackupConfigs = { }
73
115
  }
74
116
 
75
117
  export interface BackupShareResult {
@@ -106,48 +148,6 @@ export interface BackupOptions extends PasskeyOptions {
106
148
  backupMethod?: BackupMethods
107
149
  }
108
150
 
109
- export interface Balance {
110
- contractAddress: string
111
- balance: string
112
- }
113
-
114
- export interface SendAssetParams {
115
- amount: string
116
- to: string
117
- token: string
118
- sponsorGas?: boolean
119
- }
120
-
121
- export interface FundParams {
122
- amount: string
123
- token: string
124
- }
125
-
126
- export interface FundResponseData {
127
- explorerUrl: string
128
- txHash: string
129
- }
130
-
131
- export interface FundResponseMetadata {
132
- amount: string
133
- chainId: string
134
- clientId: string
135
- custodianId: string
136
- environmentId: string
137
- token: string
138
- }
139
-
140
- export interface FundResponse {
141
- data?: FundResponseData
142
- metadata: FundResponseMetadata
143
- error?: string
144
- }
145
-
146
- export interface SharesOnDeviceResponse {
147
- ED25519: boolean
148
- SECP256K1: boolean
149
- }
150
-
151
151
  export interface ClientResponse {
152
152
  id: string
153
153
  address: string
@@ -201,93 +201,6 @@ export interface ClientResponseWallet {
201
201
  signingSharePairs: ClientResponseSharePair[]
202
202
  }
203
203
 
204
- export interface DappOnNetwork {
205
- clientUrl?: string
206
- dapp: Dapp
207
- id: string
208
- network: Network
209
- }
210
-
211
- export interface Dapp {
212
- id: string
213
- name: string
214
-
215
- addresses: Address[]
216
- dappOnNetworks: DappOnNetwork[]
217
- image: DappImage
218
- }
219
-
220
- export interface DappImage {
221
- id: string
222
- filename: string
223
- data: string
224
- }
225
-
226
- export interface DecryptArgs {
227
- cipherText: string
228
- key: string
229
- }
230
-
231
- export interface DkgData {
232
- backupSharePairId?: string
233
- share: string
234
- signingSharePairId?: string
235
- }
236
-
237
- export interface EIP1559Transaction {
238
- from: string
239
- to: string
240
-
241
- // Optional
242
- data?: string
243
- gasLimit?: string
244
- maxFeePerGas?: string
245
- maxPriorityFeePerGas?: string
246
- nonce?: string
247
- value?: string
248
- }
249
-
250
- export interface EjectResult {
251
- SECP256K1: string
252
- }
253
-
254
- export interface EjectPrivateKeysResult {
255
- ED25519: string
256
- SECP256K1: string
257
- }
258
-
259
- export interface EncryptArgs {
260
- dkgData: string
261
- }
262
-
263
- export interface EncryptedWithPasswordData {
264
- cipherText: string
265
- }
266
-
267
- export interface EncryptedData {
268
- cipherText: string
269
- key: string
270
- }
271
-
272
- export interface EncryptedResult {
273
- data: EncryptData
274
- error: PortalError
275
- }
276
-
277
- export interface EncryptedWithPasswordResult {
278
- data: EncryptedWithPasswordData
279
- error: PortalError
280
- }
281
-
282
- export interface DecryptData {
283
- plaintext: string
284
- }
285
-
286
- export interface DecryptResult {
287
- data: DecryptData
288
- error: PortalError
289
- }
290
-
291
204
  export interface EjectArgs extends RecoverArgs {
292
205
  organizationBackupShare: string
293
206
  }
@@ -305,73 +218,18 @@ export interface RpcConfig {
305
218
  [key: string]: string
306
219
  }
307
220
 
308
- export interface GDriveConfig {
309
- clientId: string
310
- }
311
-
312
221
  export interface GDriveStorageOptions {
313
222
  portal: Portal
314
223
  }
315
224
 
316
225
  export type GenerateArgs = MpcOperationArgs
317
226
 
318
- export interface PasskeyConfig {
319
- relyingParty?: string = 'portalhq.io'
320
- relyingPartyOrigins?: [string] = ['https://web.portalhq.io']
321
- webAuthnHost?: string = 'backup.web.portalhq.io'
322
- }
323
227
  export interface PasskeyStorageOptions {
324
228
  portal: IPortal
325
- relyingParty?: string = 'portalhq.io'
326
- relyingPartyOrigins?: [string] = ['https://web.portalhq.io']
327
- webAuthnHost?: string = 'backup.web.portalhq.io'
328
- authOrigin?: string = 'web.portalhq.io'
329
- }
330
- export interface PasskeyStatusResponse {
331
- status: PasskeyStatus
332
- }
333
-
334
- export interface GenerateData {
335
- address: string
336
- dkgResult: DkgData
337
- }
338
-
339
- export interface GenerateResult {
340
- data: GenerateData
341
- error: PortalError
342
- }
343
-
344
- export interface GenerateResponse {
345
- address: string
346
- cipherText?: string
347
- share?: string
348
- }
349
-
350
- export interface IframeConfigurationOptions {
351
- autoApprove: boolean
352
- featureFlags?: FeatureFlags
353
- gdrive?: GDriveConfig
354
- passkey?: PasskeyConfig
355
- host: string
356
- mpcHost: string
357
- mpcVersion: string
358
-
359
- // One of these three is required for authentication
360
- apiKey?: string
361
- authToken?: string
362
- authUrl?: string
363
- }
364
-
365
- export interface LegacyTransaction {
366
- from: string
367
- to: string
368
-
369
- // Optional
370
- data?: string
371
- gasLimit?: string
372
- gasPrice?: string
373
- nonce?: string
374
- value?: string
229
+ relyingParty?: string
230
+ relyingPartyOrigins?: string[]
231
+ webAuthnHost?: string
232
+ authOrigin?: string
375
233
  }
376
234
 
377
235
  export interface MpcErrorData {
@@ -389,42 +247,6 @@ export interface MpcOptions {
389
247
  portal: Portal
390
248
  }
391
249
 
392
- export interface MpcStatus {
393
- status: MpcStatuses
394
- done: boolean
395
- }
396
-
397
- export interface Network {
398
- id: string
399
- chainId: string
400
- name: string
401
- }
402
-
403
- export interface NFT {
404
- contract: NFTContract
405
- id: TokenId
406
- balance: string
407
- title: string
408
- description: string
409
- tokenUri: TokenUri
410
- media: Media[]
411
- metadata: Metadata
412
- timeLastUpdated: string
413
- contractMetadata: ContractMetadata
414
- }
415
-
416
- export interface NFTContract {
417
- address: string
418
- }
419
-
420
- export interface PasskeyConfig {
421
- relyingParty?: string = 'backup.web.portalhq.io'
422
- }
423
-
424
- export interface PasskeyStatusResponse {
425
- status: PasskeyStatus
426
- }
427
-
428
250
  export interface PortalApiOptions {
429
251
  apiKey: string
430
252
  baseUrl: string
@@ -433,11 +255,6 @@ export interface PortalApiOptions {
433
255
  portal: Portal
434
256
  }
435
257
 
436
- export interface PortalError {
437
- code: number
438
- message?: string
439
- }
440
-
441
258
  export interface PortalOptions {
442
259
  // Required options
443
260
  rpcConfig: RpcConfig
@@ -465,31 +282,6 @@ export interface ProviderOptions {
465
282
  chainId?: number
466
283
  }
467
284
 
468
- export interface QuoteArgs {
469
- affiliateAddress?: string
470
- buyAmount?: number
471
- buyToken: string
472
- buyTokenPercentageFee?: number
473
- enableSlippageProtection?: boolean
474
- excludedSources?: string
475
- feeRecipient?: string
476
- gasPrice?: number
477
- includedSources?: string
478
- intentOnFilling?: boolean
479
- priceImpactProtectionPercentage?: number
480
- sellAmount?: number
481
- sellToken: string
482
- skipValidation?: boolean
483
- slippagePercentage?: number
484
- takerAddress?: string
485
- }
486
-
487
- export interface QuoteResponse {
488
- allowanceTarget: string
489
- cost: string
490
- transaction: Eip1559 | LegacyTx
491
- }
492
-
493
285
  export interface RegisteredEventHandler {
494
286
  handler: EventHandler
495
287
  once?: boolean
@@ -506,17 +298,7 @@ export interface RecoverArgs extends MpcOperationArgs {
506
298
  backupConfigs: BackupConfigs
507
299
  backupMethod: BackupMethods
508
300
  cipherText: string
509
- featureFlags?: FeatureFlags // TODO: Remove this
510
- }
511
-
512
- export interface RotateResult {
513
- data: RotateData
514
- error: PortalError
515
- }
516
-
517
- export interface RotateData {
518
- address: string
519
- dkgResult: DkgData
301
+ featureFlags?: FeatureFlags
520
302
  }
521
303
 
522
304
  export interface RpcErrorDefinition {
@@ -529,409 +311,40 @@ export interface RpcErrorOptions {
529
311
  data?: unknown
530
312
  }
531
313
 
532
- export interface SignArgs {
533
- chainId: string
534
- method: string
535
- params: string
536
- rpcUrl: string
537
- sponsorGas?: boolean
538
- }
539
-
540
314
  export interface SignData {
541
315
  R: string
542
316
  S: string
543
317
  }
544
318
 
545
- export interface SignResult {
546
- data: string
547
- error: PortalError
548
- }
549
-
550
319
  export interface SignerOptions {
551
320
  portal: Portal
552
321
  }
553
322
 
554
- export interface SimulateTransactionParam {
555
- to: string
556
- value?: string
557
- data?: string
558
- gas?: string
559
- gasPrice?: string
560
- maxFeePerGas?: string
561
- maxPriorityFeePerGas?: string
562
- }
563
-
564
- export interface SimulatedTransactionChange {
565
- amount?: string
566
- assetType?: string
567
- changeType?: string
568
- contractAddress?: string
569
- decimals?: number
570
- from?: string
571
- name?: string
572
- rawAmount?: string
573
- symbol?: string
574
- to?: string
575
- tokenId?: number
576
- }
577
-
578
- export interface SimulatedTransactionError {
579
- message: string
580
- }
581
-
582
- export interface SimulatedTransaction {
583
- changes: SimulatedTransactionChange[]
584
- gasUsed?: string
585
- error?: SimulatedTransactionError
586
- requestError?: SimulatedTransactionError
587
- }
588
-
589
- export type EvaluateTransactionParam =
590
- | {
591
- to: string
592
- value?: string
593
- data?: string
594
- gas?: string
595
- gasPrice?: string
596
- maxFeePerGas?: string
597
- maxPriorityFeePerGas?: string
598
- }
599
- | {
600
- transactions: string[]
601
- }
602
-
603
- type EvaluateTransactionOperationType = 'validation' | 'simulation' | 'all'
604
-
605
- export interface EvaluatedTransaction {
606
- validation?: Validation
607
- simulation?: Simulation
608
- block?: number
609
- }
610
-
611
- interface AssetMovement {
612
- summary: string
613
- value: string
614
- usdPrice?: string
615
- rawValue: string
616
- }
617
-
618
- interface AssetDiff {
619
- asset: Record<
620
- string,
621
- {
622
- type: string
623
- decimals: number
624
- chainName?: string
625
- chainId?: number
626
- logoUrl?: string
627
- name?: string
628
- symbol?: string
629
- }
630
- >
631
- in: Record<string, AssetMovement>[]
632
- out: Record<string, AssetMovement>[]
633
- }
634
-
635
- interface AccountSummary {
636
- assetsDiffs: Record<string, AssetDiff>[]
637
- [k: string]: any
638
- }
639
-
640
- type Simulation = SuccessfulSimulation | UnsuccessfulSimulation
641
-
642
- interface SuccessfulSimulation {
643
- accountAddress: string
644
- accountSummary: AccountSummary
645
- addressDetails: Record<string, any>
646
- assetsDiffs: Record<string, AssetDiff[]>
647
- status: string
648
- exposures?: Record<string, any>
649
- totalUsdDiff?: Record<string, any>
650
- totalUsdExposure?: Record<string, any>
651
- solana?: {
652
- delegations: Record<string, Record<string, any>[]>
653
- assetsOwnershipDiff: Record<string, Record<string, any>[]>
654
- }
655
- }
656
- interface UnsuccessfulSimulation {
657
- status: 'Error'
658
- error: string
659
- }
660
-
661
- type Validation = SuccessfulValidation | UnsuccessfulValidation
662
-
663
- interface SuccessfulValidation {
664
- classification?: string | null
665
- description?: string | null
666
- features: {
667
- type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
668
- featureId?: string
669
- description: string
670
- address?: string | null
671
- }[]
672
- reason?: string | null
673
- resultType: 'Benign' | 'Warning' | 'Malicious'
674
- status: string
675
- }
676
-
677
- interface UnsuccessfulValidation {
678
- error: string
679
- classification?: string | null
680
- description?: string | null
681
- features: {
682
- type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
683
- featureId?: string
684
- description: string
685
- address?: string | null
686
- }[]
687
- reason?: string | null
688
- resultType: 'Error'
689
- status: 'Error'
690
- }
691
-
692
- export interface Transaction {
693
- asset: string
694
- blockNum: string
695
- category: string
696
- chainId: string
697
- erc1155Metadata: null | string
698
- erc721TokenId: null | string
699
- from: string
700
- hash: string
701
- metadata: {
702
- blockTimestamp: string
703
- }
704
- rawContract: {
705
- address: string
706
- decimal: string
707
- value: string
708
- }
709
- to: string
710
- tokenId: null | string
711
- uniqueId: string
712
- value: number
713
- }
714
-
715
- export interface GetAssetsResponse {
716
- nativeBalance: {
717
- balance: string
718
- decimals: number
719
- name: string
720
- rawBalance: string
721
- symbol: string
722
- metadata: Record<string, any>
723
- }
724
- tokenBalances: {
725
- balance: string
726
- decimals: number
727
- name: string
728
- rawBalance: string
729
- symbol: string
730
- metadata: Record<string, any>
731
- }[]
732
- nfts?: NFTAsset[]
733
- }
734
-
735
- export interface NFTAsset {
736
- nftId: string
737
- name: string
738
- description: string
739
- imageUrl: string
740
- chain: string
741
- contractAddress: string
742
- tokenId: string
743
- collection: {
744
- name: string
745
- description: string | null
746
- imageUrl: string
747
- }
748
- lastSale: {
749
- price: number
750
- currency: string
751
- date: string
752
- } | null
753
- rarity: {
754
- rank: number | null
755
- score: number | null
756
- }
757
- floorPrice: {
758
- price: number
759
- currency: string
760
- } | null
761
- detailedInfo: {
762
- ownerCount: number
763
- tokenCount: number
764
- createdDate: string | null
765
- attributes: Attribute[]
766
- owners: Owner[]
767
- extendedCollectionInfo: ExtendedCollectionInfo
768
- extendedSaleInfo: ExtendedSaleInfo | null
769
- marketplaceInfo: MarketplaceInfo[]
770
- mediaInfo: MediaInfo
771
- }
772
- }
773
-
774
- interface Attribute {
775
- traitType: string
776
- value: string | number
777
- displayType: string | null
778
- }
779
-
780
- interface Owner {
781
- ownerAddress: string
782
- quantity: number
783
- firstAcquiredDate: string
784
- lastAcquiredDate: string
785
- }
786
-
787
- interface ExtendedCollectionInfo {
788
- bannerImageUrl: string | null
789
- externalUrl: string | null
790
- twitterUsername: string | null
791
- discordUrl: string | null
792
- instagramUsername: string | null
793
- mediumUsername: string | null
794
- telegramUrl: string | null
795
- distinctOwnerCount: number
796
- distinctNftCount: number
797
- totalQuantity: number
798
- }
799
-
800
- interface ExtendedSaleInfo {
801
- fromAddress: string
802
- toAddress: string
803
- priceUsdCents: number
804
- transaction: string
805
- marketplaceId: string
806
- marketplaceName: string
807
- }
808
-
809
- interface MarketplaceInfo {
810
- marketplaceId: string
811
- marketplaceName: string
812
- marketplaceCollectionId: string
813
- nftUrl: string
814
- collectionUrl: string
815
- verified: boolean | null
816
- floorPrice: {
817
- value: number
818
- paymentToken: {
819
- paymentTokenId: string
820
- name: string
821
- symbol: string
822
- address: string | null
823
- decimals: number
824
- }
825
- valueUsdCents: number | null
826
- } | null
827
- }
828
-
829
- interface MediaInfo {
830
- previews: {
831
- imageSmallUrl: string
832
- imageMediumUrl: string
833
- imageLargeUrl: string
834
- imageOpengraphUrl: string
835
- blurhash: string
836
- predominantColor: string
837
- }
838
- animationUrl: string | null
839
- backgroundColor: string | null
840
- }
841
-
842
- export type BuiltTransaction = BuiltEip155Transaction | BuiltSolanaTransaction
843
-
844
- export interface BuiltEip155Transaction {
845
- transaction: {
846
- from: string
847
- to: string
848
- data: string
849
- }
850
- metadata: {
851
- amount: string
852
- fromAddress: string
853
- toAddress: string
854
- tokenAddress: string
855
- tokenDecimals: number
856
- rawAmount: string
857
- }
858
- }
859
-
860
- export interface BuiltSolanaTransaction {
861
- transaction: string
862
- metadata: {
863
- amount: string
864
- fromAddress: string
865
- toAddress: string
866
- tokenMintAddress: string
867
- tokenDecimals: number
868
- tokenProgramId: string
869
- tokenExtensions: any[]
870
- rawAmount: string
871
- lastValidBlockHeight: string
872
- serializedTransactionBase64Encoded: string
873
- serializedTransactionBase58Encoded: string
874
- unsignedTransactionMessage: {
875
- signatures: null
876
- message: {
877
- accountKeys: string[]
878
- header: {
879
- numRequiredSignatures: number
880
- numReadonlySignedAccounts: number
881
- numReadonlyUnsignedAccounts: number
882
- }
883
- instructions: {
884
- programIdIndex: number
885
- accounts: number[]
886
- data: string
887
- }[]
888
- recentBlockhash: string
889
- }
890
- }
891
- }
892
- }
893
-
894
- export interface SwitchEthereumChainParameter {
895
- chainId: string
896
- }
897
-
898
- export interface TypedData {
899
- types: Type[]
900
- primaryType: string
901
- domain: string
902
- message: string
903
- }
904
-
905
- export interface Type {
906
- name: string
907
- type: string
908
- }
909
-
910
323
  export interface WorkerMessage {
911
324
  type: string
912
325
  data:
913
- | BackupArgs
914
- | DecryptArgs
915
- | EncryptArgs
916
- | GenerateArgs
917
- | RecoverArgs
918
- | SignArgs
326
+ | BackupArgs
327
+ | DecryptArgs
328
+ | EncryptArgs
329
+ | GenerateArgs
330
+ | RecoverArgs
331
+ | SignArgs
919
332
  }
920
333
 
921
334
  export interface WorkerResult {
922
335
  type: string
923
336
  data:
924
- | boolean
925
- | string
926
- | BackupResult
927
- | DecryptResult
928
- | EncryptedResult
929
- | EncryptedWithPasswordResult
930
- | GenerateResult
931
- | MpcStatus
932
- | PortalError
933
- | ReadyResult
934
- | RecoverResult
935
- | SignResult
936
- | EjectResult
337
+ | boolean
338
+ | string
339
+ | BackupResult
340
+ | DecryptResult
341
+ | EncryptedResult
342
+ | EncryptedWithPasswordResult
343
+ | GenerateResult
344
+ | MpcStatus
345
+ | PortalError
346
+ | ReadyResult
347
+ | RecoverResult
348
+ | SignResult
349
+ | EjectResult
937
350
  }