@idos-network/kwil-infra 3.0.1 → 4.0.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.
@@ -110,7 +110,6 @@ type MmTokenAuth = KwilSigner & {
110
110
  declare function isMmTokenAuth(value: unknown): value is MmTokenAuth;
111
111
  /** `storage_id` from the capability token used to construct this signer. */
112
112
  declare function mmTokenStorageId(signer: KwilSigner): string;
113
- declare function mmTokenCredentialContentUri(signer: KwilSigner, credentialId: string): string;
114
113
  /**
115
114
  * Build the MM authentication object for one UKYC capability.
116
115
  *
@@ -176,6 +175,9 @@ declare const DataType: typeof Utils.DataType;
176
175
  declare const WALLET_TYPES: readonly ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign", "MM"];
177
176
  type WalletType = (typeof WALLET_TYPES)[number];
178
177
  declare const walletTypeSchema: z.ZodType<WalletType>;
178
+ declare const ADD_WALLET_TYPES: readonly ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign"];
179
+ type AddWalletType = (typeof ADD_WALLET_TYPES)[number];
180
+ declare const addWalletTypeSchema: z.ZodType<AddWalletType>;
179
181
  declare const ENCRYPTION_PASSWORD_STORES: readonly ["user", "mpc", "mm"];
180
182
  type EncryptionPasswordStore = (typeof ENCRYPTION_PASSWORD_STORES)[number];
181
183
  declare const encryptionPasswordStoreSchema: z.ZodType<EncryptionPasswordStore>;
@@ -217,7 +219,7 @@ declare const GetUserAsInserterOutputSchema: z.ZodObject<{
217
219
  inserter: z.ZodString;
218
220
  }>;
219
221
  type GetUserAsInserterOutput = z.infer<typeof GetUserAsInserterOutputSchema>;
220
- declare function getUserAsInserter(kwilClient: KwilActionClient, params: GetUserAsInserterInput): Promise<GetUserAsInserterOutput>;
222
+ declare function getUserAsInserter(kwilClient: KwilActionClient, params: GetUserAsInserterInput): Promise<GetUserAsInserterOutput | undefined>;
221
223
  declare const UpsertWalletAsInserterInputSchema: z.ZodObject<{
222
224
  id: z.ZodUUID;
223
225
  user_id: z.ZodUUID;
@@ -233,7 +235,7 @@ type UpsertWalletAsInserterInput = z.infer<typeof UpsertWalletAsInserterInputSch
233
235
  declare function upsertWalletAsInserter(kwilClient: KwilActionClient, params: UpsertWalletAsInserterInput): Promise<void>;
234
236
  declare const AddWalletMessageInputSchema: z.ZodObject<{
235
237
  address: z.ZodString;
236
- wallet_type: z.ZodType<WalletType>;
238
+ wallet_type: z.ZodType<AddWalletType>;
237
239
  user_id: z.ZodUUID;
238
240
  not_before: z.ZodISODateTime;
239
241
  not_after: z.ZodISODateTime;
@@ -248,7 +250,7 @@ declare const AddWalletInputSchema: z.ZodObject<{
248
250
  id: z.ZodUUID;
249
251
  address: z.ZodString;
250
252
  public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
251
- wallet_type: z.ZodType<WalletType>;
253
+ wallet_type: z.ZodType<AddWalletType>;
252
254
  not_before: z.ZodISODateTime;
253
255
  not_after: z.ZodISODateTime;
254
256
  signature: z.ZodString;
@@ -261,7 +263,7 @@ declare const GetWalletsOutputSchema: z.ZodObject<{
261
263
  address: z.ZodString;
262
264
  public_key: z.ZodNullable<z.ZodString>;
263
265
  wallet_type: z.ZodType<WalletType>;
264
- message: z.ZodString;
266
+ message: z.ZodNullable<z.ZodString>;
265
267
  signature: z.ZodString;
266
268
  inserter: z.ZodNullable<z.ZodString>;
267
269
  }>;
@@ -272,6 +274,18 @@ declare const RemoveWalletInputSchema: z.ZodObject<{
272
274
  }>;
273
275
  type RemoveWalletInput = z.infer<typeof RemoveWalletInputSchema>;
274
276
  declare function removeWallet(kwilClient: KwilActionClient, params: RemoveWalletInput): Promise<void>;
277
+ declare const CredentialBroaderMessageInputSchema: z.ZodObject<{
278
+ public_notes_signature: z.ZodString;
279
+ content_uri: z.ZodString;
280
+ recipient_wallet: z.ZodString;
281
+ }>;
282
+ type CredentialBroaderMessageInput = z.infer<typeof CredentialBroaderMessageInputSchema>;
283
+ declare const CredentialBroaderMessageOutputSchema: z.ZodObject<{
284
+ message: z.ZodString;
285
+ }>;
286
+ type CredentialBroaderMessageOutput = z.infer<typeof CredentialBroaderMessageOutputSchema>;
287
+ /** CREDENTIAL ACTIONS */
288
+ declare function credentialBroaderMessage(kwilClient: KwilActionClient, params: CredentialBroaderMessageInput): Promise<CredentialBroaderMessageOutput>;
275
289
  declare const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
276
290
  request_id: z.ZodUUID;
277
291
  credential_id: z.ZodUUID;
@@ -285,7 +299,6 @@ declare const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
285
299
  broader_signature: z.ZodString;
286
300
  }>;
287
301
  type CreatePreliminaryCredentialInput = z.infer<typeof CreatePreliminaryCredentialInputSchema>;
288
- /** CREDENTIAL ACTIONS */
289
302
  declare function createPreliminaryCredential(kwilClient: KwilActionClient, params: CreatePreliminaryCredentialInput): Promise<void>;
290
303
  declare const GetCredentialsOutputSchema: z.ZodObject<{
291
304
  id: z.ZodUUID;
@@ -422,7 +435,7 @@ declare const CredentialExistAsInserterOutputSchema: z.ZodObject<{
422
435
  credential_exist: z.ZodBoolean;
423
436
  }>;
424
437
  type CredentialExistAsInserterOutput = z.infer<typeof CredentialExistAsInserterOutputSchema>;
425
- declare function credentialExistAsInserter(kwilClient: KwilActionClient, params: CredentialExistAsInserterInput): Promise<CredentialExistAsInserterOutput>;
438
+ declare function credentialExistAsInserter(kwilClient: KwilActionClient, params: CredentialExistAsInserterInput): Promise<CredentialExistAsInserterOutput | undefined>;
426
439
  declare const GetCredentialOwnedInputSchema: z.ZodObject<{
427
440
  id: z.ZodUUID;
428
441
  }>;
@@ -468,7 +481,7 @@ declare const GetSiblingCredentialIdOutputSchema: z.ZodObject<{
468
481
  id: z.ZodUUID;
469
482
  }>;
470
483
  type GetSiblingCredentialIdOutput = z.infer<typeof GetSiblingCredentialIdOutputSchema>;
471
- declare function getSiblingCredentialId(kwilClient: KwilActionClient, params: GetSiblingCredentialIdInput): Promise<GetSiblingCredentialIdOutput>;
484
+ declare function getSiblingCredentialId(kwilClient: KwilActionClient, params: GetSiblingCredentialIdInput): Promise<GetSiblingCredentialIdOutput | undefined>;
472
485
  declare const AddAttributeAsInserterInputSchema: z.ZodObject<{
473
486
  id: z.ZodUUID;
474
487
  user_id: z.ZodUUID;
@@ -536,7 +549,7 @@ type DwgMessageOutput = z.infer<typeof DwgMessageOutputSchema>;
536
549
  * Will fail if not in the yyyy-mm-ddThh:mm:ssZ format, and not comply to RFC3339
537
550
  * Check the format and precedence
538
551
  */
539
- declare function dwgMessage(kwilClient: KwilActionClient, params: DwgMessageInput): Promise<DwgMessageOutput>;
552
+ declare function dwgMessage(kwilClient: KwilActionClient, params: DwgMessageInput): Promise<DwgMessageOutput | undefined>;
540
553
  declare const RevokeAccessGrantInputSchema: z.ZodObject<{
541
554
  id: z.ZodUUID;
542
555
  }>;
@@ -586,7 +599,7 @@ declare const GetAccessGrantsGrantedCountOutputSchema: z.ZodObject<{
586
599
  count: z.ZodNumber;
587
600
  }>;
588
601
  type GetAccessGrantsGrantedCountOutput = z.infer<typeof GetAccessGrantsGrantedCountOutputSchema>;
589
- declare function getAccessGrantsGrantedCount(kwilClient: KwilActionClient, params: GetAccessGrantsGrantedCountInput): Promise<GetAccessGrantsGrantedCountOutput>;
602
+ declare function getAccessGrantsGrantedCount(kwilClient: KwilActionClient, params: GetAccessGrantsGrantedCountInput): Promise<GetAccessGrantsGrantedCountOutput | undefined>;
590
603
  declare const HasLockedAccessGrantsInputSchema: z.ZodObject<{
591
604
  id: z.ZodUUID;
592
605
  }>;
@@ -595,7 +608,7 @@ declare const HasLockedAccessGrantsOutputSchema: z.ZodObject<{
595
608
  has: z.ZodBoolean;
596
609
  }>;
597
610
  type HasLockedAccessGrantsOutput = z.infer<typeof HasLockedAccessGrantsOutputSchema>;
598
- declare function hasLockedAccessGrants(kwilClient: KwilActionClient, params: HasLockedAccessGrantsInput): Promise<HasLockedAccessGrantsOutput>;
611
+ declare function hasLockedAccessGrants(kwilClient: KwilActionClient, params: HasLockedAccessGrantsInput): Promise<HasLockedAccessGrantsOutput | undefined>;
599
612
  declare const GetAccessGrantsForCredentialInputSchema: z.ZodObject<{
600
613
  credential_id: z.ZodUUID;
601
614
  }>;
@@ -624,7 +637,7 @@ type HasProfileOutput = z.infer<typeof HasProfileOutputSchema>;
624
637
  * OTHER ACTIONS
625
638
  * Should we improve it to work with near wallets too?
626
639
  */
627
- declare function hasProfile(kwilClient: KwilActionClient, params: HasProfileInput): Promise<HasProfileOutput>;
640
+ declare function hasProfile(kwilClient: KwilActionClient, params: HasProfileInput): Promise<HasProfileOutput | undefined>;
628
641
  declare const SetCallerPayerInputSchema: z.ZodObject<{
629
642
  address: z.ZodString;
630
643
  }>;
@@ -638,7 +651,7 @@ declare const CheckCallerPayerOutputSchema: z.ZodObject<{
638
651
  is_payer: z.ZodBoolean;
639
652
  }>;
640
653
  type CheckCallerPayerOutput = z.infer<typeof CheckCallerPayerOutputSchema>;
641
- declare function checkCallerPayer(kwilClient: KwilActionClient, params: CheckCallerPayerInput): Promise<CheckCallerPayerOutput>;
654
+ declare function checkCallerPayer(kwilClient: KwilActionClient, params: CheckCallerPayerInput): Promise<CheckCallerPayerOutput | undefined>;
642
655
  declare const UnsetCallerPayerInputSchema: z.ZodObject<{
643
656
  address: z.ZodString;
644
657
  }>;
@@ -653,7 +666,7 @@ declare const CheckBalanceOutputSchema: z.ZodObject<{
653
666
  balance: z.ZodNumber;
654
667
  }>;
655
668
  type CheckBalanceOutput = z.infer<typeof CheckBalanceOutputSchema>;
656
- declare function checkBalance(kwilClient: KwilActionClient, params: CheckBalanceInput): Promise<CheckBalanceOutput>;
669
+ declare function checkBalance(kwilClient: KwilActionClient, params: CheckBalanceInput): Promise<CheckBalanceOutput | undefined>;
657
670
  declare const GetWalletWithBalanceInputSchema: z.ZodObject<{
658
671
  token: z.ZodString;
659
672
  minimum_balance: z.ZodNumber;
@@ -663,7 +676,7 @@ declare const GetWalletWithBalanceOutputSchema: z.ZodObject<{
663
676
  wallet_address: z.ZodString;
664
677
  }>;
665
678
  type GetWalletWithBalanceOutput = z.infer<typeof GetWalletWithBalanceOutputSchema>;
666
- declare function getWalletWithBalance(kwilClient: KwilActionClient, params: GetWalletWithBalanceInput): Promise<GetWalletWithBalanceOutput>;
679
+ declare function getWalletWithBalance(kwilClient: KwilActionClient, params: GetWalletWithBalanceInput): Promise<GetWalletWithBalanceOutput | undefined>;
667
680
  declare const RequestWithdrawalInputSchema: z.ZodObject<{
668
681
  token: z.ZodString;
669
682
  }>;
@@ -675,7 +688,7 @@ declare const GetAllowanceOutputSchema: z.ZodObject<{
675
688
  }>;
676
689
  type GetAllowanceOutput = z.infer<typeof GetAllowanceOutputSchema>;
677
690
  /** FaceSign should not be able to call this */
678
- declare function getAllowance(kwilClient: KwilActionClient): Promise<GetAllowanceOutput>;
691
+ declare function getAllowance(kwilClient: KwilActionClient): Promise<GetAllowanceOutput | undefined>;
679
692
  declare function actionCostingGas(kwilClient: KwilActionClient): Promise<void>;
680
693
  declare const ActionCostingIdosTokenInputSchema: z.ZodObject<{
681
694
  amount: z.ZodNumber;
@@ -690,7 +703,7 @@ declare const GetIssuerFeeOutputSchema: z.ZodObject<{
690
703
  issuer_fee: z.ZodNumber;
691
704
  }>;
692
705
  type GetIssuerFeeOutput = z.infer<typeof GetIssuerFeeOutputSchema>;
693
- declare function getIssuerFee(kwilClient: KwilActionClient, params: GetIssuerFeeInput): Promise<GetIssuerFeeOutput>;
706
+ declare function getIssuerFee(kwilClient: KwilActionClient, params: GetIssuerFeeInput): Promise<GetIssuerFeeOutput | undefined>;
694
707
  declare const ActionCostingFeeInputSchema: z.ZodObject<{
695
708
  credential_id: z.ZodUUID;
696
709
  }>;
@@ -726,5 +739,5 @@ declare function removeWallets(kwilClient: KwilActionClient, ids: string[]): Pro
726
739
  declare const GET_GRANTS_DEFAULT_RECORDS_PER_PAGE = 10;
727
740
  declare function getGrants(kwilClient: KwilActionClient, params?: Partial<GetAccessGrantsGrantedInput>): Promise<idOSGrant[]>;
728
741
  //#endregion
729
- export { EditAttributeInput as $, editAttribute as $n, createMmTokenAuth as $r, GetWalletWithBalanceOutputSchema as $t, AddWalletMessageOutputSchema as A, UnsetCallerPayerInput as An, unsetCallerPayer as Ar, GetCredentialsOutput as At, CreatePreliminaryCredentialInputSchema as B, actionCostingIdosToken as Bn, SignerAddress as Br, GetSiblingCredentialIdInput as Bt, AddUserAsInserterInput as C, RevokeAccessGrantInputSchema as Cn, requestBalanceWithdrawal as Cr, GetCredentialOwnedInputSchema as Ct, AddWalletMessageInput as D, ShareAttributeInputSchema as Dn, setCallerPayer as Dr, GetCredentialSharedInputSchema as Dt, AddWalletInputSchema as E, ShareAttributeInput as En, revokeAccessGrant as Er, GetCredentialSharedInput as Et, CheckCallerPayerInput as F, UpsertWalletAsInserterInputSchema as Fn, implicitAddressFromPublicKey as Fr, GetCredentialsSharedByUserOutputSchema as Ft, CredentialExistAsInserterOutput as G, addWallet as Gn, CreateKgwAuthenticatedBlobGatewayParams as Gr, GetUserAsInserterInputSchema as Gt, CreatePreliminaryCredentialsByDwgInputSchema as H, addAttribute as Hn, Wallet$2 as Hr, GetSiblingCredentialIdOutput as Ht, CheckCallerPayerInputSchema as I, WALLET_TYPES as In, signNearMessage as Ir, GetIssuerFeeInput as It, DwgMessageInput as J, checkCallerPayer as Jn, createKgwAuthenticatedBlobGateway as Jr, GetUserOutput as Jt, CredentialExistAsInserterOutputSchema as K, addWalletMessage as Kn, CreateKgwAuthenticatedFetchParams as Kr, GetUserAsInserterOutput as Kt, CheckCallerPayerOutput as L, WalletType as Ln, CustomKwilSigner as Lr, GetIssuerFeeInputSchema as Lt, CheckBalanceInputSchema as M, UpdateUserPubKeyAsInserterInput as Mn, upsertWalletAsInserter as Mr, GetCredentialsSharedByUserInput as Mt, CheckBalanceOutput as N, UpdateUserPubKeyAsInserterInputSchema as Nn, walletTypeSchema as Nr, GetCredentialsSharedByUserInputSchema as Nt, AddWalletMessageInputSchema as O, SharePreliminaryCredentialInput as On, shareAttribute as Or, GetCredentialSharedOutput as Ot, CheckBalanceOutputSchema as P, UpsertWalletAsInserterInput as Pn, getNearFullAccessPublicKeys as Pr, GetCredentialsSharedByUserOutput as Pt, ENCRYPTION_PASSWORD_STORES as Q, dwgMessage as Qn, MmTokenPayload as Qr, GetWalletWithBalanceOutput as Qt, CheckCallerPayerOutputSchema as R, actionCostingFee as Rn, KwilSigner$1 as Rr, GetIssuerFeeOutput as Rt, AddAttributeInputSchema as S, RevokeAccessGrantInput as Sn, removeWallet as Sr, GetCredentialOwnedInput as St, AddWalletInput as T, SetCallerPayerInputSchema as Tn, rescindSharedCredential as Tr, GetCredentialOwnedOutputSchema as Tt, CredentialExistAsInserterInput as U, addAttributeAsInserter as Un, createClientKwilSigner as Ur, GetSiblingCredentialIdOutputSchema as Ut, CreatePreliminaryCredentialsByDwgInput as V, actionSchema as Vn, SignerPublicKey as Vr, GetSiblingCredentialIdInputSchema as Vt, CredentialExistAsInserterInputSchema as W, addUserAsInserter as Wn, createServerKwilSigner as Wr, GetUserAsInserterInput as Wt, DwgMessageOutput as X, createPreliminaryCredentialsByDwg as Xn, MmTokenAuth as Xr, GetWalletWithBalanceInput as Xt, DwgMessageInputSchema as Y, createPreliminaryCredential as Yn, createKgwAuthenticatedFetch as Yr, GetUserOutputSchema as Yt, DwgMessageOutputSchema as Z, credentialExistAsInserter as Zn, MmTokenEnvelope as Zr, GetWalletWithBalanceInputSchema as Zt, ActionCostingIdosTokenInputSchema as _, RequestBalanceWithdrawalInputSchema as _n, getWallets as _r, GetAccessGrantsOwnedOutputSchema as _t, idOSCredential as a, createWebKwilClient as ai, HasLockedAccessGrantsOutputSchema as an, getAccessGrantsOwned as ar, GetAccessGrantsForCredentialInputSchema as at, AddAttributeAsInserterInputSchema as b, RescindSharedCredentialInput as bn, removeAttribute as br, GetAttributesOutput as bt, idOSGrant as c, HasProfileOutput as cn, getCredentialOwned as cr, GetAccessGrantsGrantedCountInput as ct, idOSWallet as d, RemoveAttributeInputSchema as dn, getCredentialsSharedByUser as dr, GetAccessGrantsGrantedCountOutputSchema as dt, isMmTokenAuth as ei, GetWalletsOutput as en, editPublicNotesAsIssuer as er, EditAttributeInputSchema as et, removeWallets as f, RemoveCredentialInput as fn, getIssuerFee as fr, GetAccessGrantsGrantedInput as ft, ActionCostingIdosTokenInput as g, RequestBalanceWithdrawalInput as gn, getWalletWithBalance as gr, GetAccessGrantsOwnedOutput as gt, ActionCostingFeeInputSchema as h, RemoveWalletInputSchema as hn, getUserAsInserter as hr, GetAccessGrantsGrantedOutputSchema as ht, getGrants as i, createNodeKwilClient as ii, HasLockedAccessGrantsOutput as in, getAccessGrantsGrantedCount as ir, GetAccessGrantsForCredentialInput as it, CheckBalanceInput as j, UnsetCallerPayerInputSchema as jn, updateUserPubKeyAsInserter as jr, GetCredentialsOutputSchema as jt, AddWalletMessageOutput as k, SharePreliminaryCredentialInputSchema as kn, sharePreliminaryCredential as kr, GetCredentialSharedOutputSchema as kt, idOSUser as l, HasProfileOutputSchema as ln, getCredentialShared as lr, GetAccessGrantsGrantedCountInputSchema as lt, ActionCostingFeeInput as m, RemoveWalletInput as mn, getUser as mr, GetAccessGrantsGrantedOutput as mt, GET_GRANTS_DEFAULT_RECORDS_PER_PAGE as n, mmTokenStorageId as ni, HasLockedAccessGrantsInput as nn, getAccessGrantsForCredential as nr, EditPublicNotesAsIssuerInputSchema as nt, idOSCredentialListItem as o, KwilTxFailedError as oi, HasProfileInput as on, getAllowance as or, GetAccessGrantsForCredentialOutput as ot, toDelegatedWriteGrantBaseParams as p, RemoveCredentialInputSchema as pn, getSiblingCredentialId as pr, GetAccessGrantsGrantedInputSchema as pt, DataType as q, checkBalance as qn, KgwAuthFailurePredicate as qr, GetUserAsInserterOutputSchema as qt, addWallets as r, KwilActionClient as ri, HasLockedAccessGrantsInputSchema as rn, getAccessGrantsGranted as rr, EncryptionPasswordStore as rt, idOSDelegatedWriteGrant as s, KwilTxPollTimeoutError as si, HasProfileInputSchema as sn, getAttributes as sr, GetAccessGrantsForCredentialOutputSchema as st, DelegatedWriteGrantBaseParams as t, mmTokenCredentialContentUri as ti, GetWalletsOutputSchema as tn, encryptionPasswordStoreSchema as tr, EditPublicNotesAsIssuerInput as tt, idOSUserAttribute as u, RemoveAttributeInput as un, getCredentials as ur, GetAccessGrantsGrantedCountOutput as ut, ActionSchemaElement as v, RequestWithdrawalInput as vn, hasLockedAccessGrants as vr, GetAllowanceOutput as vt, AddUserAsInserterInputSchema as w, SetCallerPayerInput as wn, requestWithdrawal as wr, GetCredentialOwnedOutput as wt, AddAttributeInput as x, RescindSharedCredentialInputSchema as xn, removeCredential as xr, GetAttributesOutputSchema as xt, AddAttributeAsInserterInput as y, RequestWithdrawalInputSchema as yn, hasProfile as yr, GetAllowanceOutputSchema as yt, CreatePreliminaryCredentialInput as z, actionCostingGas as zn, KwilSignerType as zr, GetIssuerFeeOutputSchema as zt };
730
- //# sourceMappingURL=index-Bk8YCFlx.d.mts.map
742
+ export { DataType as $, addWalletTypeSchema as $n, CreateKgwAuthenticatedBlobGatewayParams as $r, GetUserAsInserterOutputSchema as $t, AddWalletMessageOutput as A, SetCallerPayerInput as An, removeWallet as Ar, GetCredentialOwnedOutput as At, CheckCallerPayerOutputSchema as B, UpsertWalletAsInserterInput as Bn, upsertWalletAsInserter as Br, GetCredentialsSharedByUserOutput as Bt, AddAttributeInputSchema as C, RequestBalanceWithdrawalInputSchema as Cn, getUserAsInserter as Cr, GetAccessGrantsOwnedOutputSchema as Ct, AddWalletInputSchema as D, RescindSharedCredentialInputSchema as Dn, hasProfile as Dr, GetAttributesOutputSchema as Dt, AddWalletInput as E, RescindSharedCredentialInput as En, hasLockedAccessGrants as Er, GetAttributesOutput as Et, CheckBalanceOutput as F, SharePreliminaryCredentialInputSchema as Fn, setCallerPayer as Fr, GetCredentialSharedOutputSchema as Ft, CredentialBroaderMessageInput as G, actionCostingGas as Gn, CustomKwilSigner as Gr, GetIssuerFeeOutputSchema as Gt, CreatePreliminaryCredentialInputSchema as H, WALLET_TYPES as Hn, getNearFullAccessPublicKeys as Hr, GetIssuerFeeInput as Ht, CheckBalanceOutputSchema as I, UnsetCallerPayerInput as In, shareAttribute as Ir, GetCredentialsOutput as It, CredentialBroaderMessageOutputSchema as J, addAttribute as Jn, SignerAddress as Jr, GetSiblingCredentialIdOutput as Jt, CredentialBroaderMessageInputSchema as K, actionCostingIdosToken as Kn, KwilSigner$1 as Kr, GetSiblingCredentialIdInput as Kt, CheckCallerPayerInput as L, UnsetCallerPayerInputSchema as Ln, sharePreliminaryCredential as Lr, GetCredentialsOutputSchema as Lt, AddWalletType as M, ShareAttributeInput as Mn, requestWithdrawal as Mr, GetCredentialSharedInput as Mt, CheckBalanceInput as N, ShareAttributeInputSchema as Nn, rescindSharedCredential as Nr, GetCredentialSharedInputSchema as Nt, AddWalletMessageInput as O, RevokeAccessGrantInput as On, removeAttribute as Or, GetCredentialOwnedInput as Ot, CheckBalanceInputSchema as P, SharePreliminaryCredentialInput as Pn, revokeAccessGrant as Pr, GetCredentialSharedOutput as Pt, CredentialExistAsInserterOutputSchema as Q, addWalletMessage as Qn, createServerKwilSigner as Qr, GetUserAsInserterOutput as Qt, CheckCallerPayerInputSchema as R, UpdateUserPubKeyAsInserterInput as Rn, unsetCallerPayer as Rr, GetCredentialsSharedByUserInput as Rt, AddAttributeInput as S, RequestBalanceWithdrawalInput as Sn, getUser as Sr, GetAccessGrantsOwnedOutput as St, AddUserAsInserterInputSchema as T, RequestWithdrawalInputSchema as Tn, getWallets as Tr, GetAllowanceOutputSchema as Tt, CreatePreliminaryCredentialsByDwgInput as U, WalletType as Un, implicitAddressFromPublicKey as Ur, GetIssuerFeeInputSchema as Ut, CreatePreliminaryCredentialInput as V, UpsertWalletAsInserterInputSchema as Vn, walletTypeSchema as Vr, GetCredentialsSharedByUserOutputSchema as Vt, CreatePreliminaryCredentialsByDwgInputSchema as W, actionCostingFee as Wn, signNearMessage as Wr, GetIssuerFeeOutput as Wt, CredentialExistAsInserterInputSchema as X, addUserAsInserter as Xn, Wallet$2 as Xr, GetUserAsInserterInput as Xt, CredentialExistAsInserterInput as Y, addAttributeAsInserter as Yn, SignerPublicKey as Yr, GetSiblingCredentialIdOutputSchema as Yt, CredentialExistAsInserterOutput as Z, addWallet as Zn, createClientKwilSigner as Zr, GetUserAsInserterInputSchema as Zt, ActionCostingIdosTokenInput as _, RemoveAttributeInputSchema as _n, getCredentialShared as _r, GetAccessGrantsGrantedCountOutputSchema as _t, idOSCredential as a, MmTokenEnvelope as ai, GetWalletWithBalanceOutputSchema as an, credentialExistAsInserter as ar, EditAttributeInput as at, AddAttributeAsInserterInput as b, RemoveWalletInput as bn, getIssuerFee as br, GetAccessGrantsGrantedOutput as bt, idOSGrant as c, isMmTokenAuth as ci, HasLockedAccessGrantsInput as cn, editPublicNotesAsIssuer as cr, EditPublicNotesAsIssuerInputSchema as ct, idOSWallet as d, createNodeKwilClient as di, HasLockedAccessGrantsOutputSchema as dn, getAccessGrantsGranted as dr, GetAccessGrantsForCredentialInputSchema as dt, CreateKgwAuthenticatedFetchParams as ei, GetUserOutput as en, checkBalance as er, DwgMessageInput as et, removeWallets as f, createWebKwilClient as fi, HasProfileInput as fn, getAccessGrantsGrantedCount as fr, GetAccessGrantsForCredentialOutput as ft, ActionCostingFeeInputSchema as g, RemoveAttributeInput as gn, getCredentialOwned as gr, GetAccessGrantsGrantedCountOutput as gt, ActionCostingFeeInput as h, HasProfileOutputSchema as hn, getAttributes as hr, GetAccessGrantsGrantedCountInputSchema as ht, getGrants as i, MmTokenAuth as ii, GetWalletWithBalanceOutput as in, credentialBroaderMessage as ir, ENCRYPTION_PASSWORD_STORES as it, AddWalletMessageOutputSchema as j, SetCallerPayerInputSchema as jn, requestBalanceWithdrawal as jr, GetCredentialOwnedOutputSchema as jt, AddWalletMessageInputSchema as k, RevokeAccessGrantInputSchema as kn, removeCredential as kr, GetCredentialOwnedInputSchema as kt, idOSUser as l, mmTokenStorageId as li, HasLockedAccessGrantsInputSchema as ln, encryptionPasswordStoreSchema as lr, EncryptionPasswordStore as lt, ADD_WALLET_TYPES as m, KwilTxPollTimeoutError as mi, HasProfileOutput as mn, getAllowance as mr, GetAccessGrantsGrantedCountInput as mt, GET_GRANTS_DEFAULT_RECORDS_PER_PAGE as n, createKgwAuthenticatedBlobGateway as ni, GetWalletWithBalanceInput as nn, createPreliminaryCredential as nr, DwgMessageOutput as nt, idOSCredentialListItem as o, MmTokenPayload as oi, GetWalletsOutput as on, dwgMessage as or, EditAttributeInputSchema as ot, toDelegatedWriteGrantBaseParams as p, KwilTxFailedError as pi, HasProfileInputSchema as pn, getAccessGrantsOwned as pr, GetAccessGrantsForCredentialOutputSchema as pt, CredentialBroaderMessageOutput as q, actionSchema as qn, KwilSignerType as qr, GetSiblingCredentialIdInputSchema as qt, addWallets as r, createKgwAuthenticatedFetch as ri, GetWalletWithBalanceInputSchema as rn, createPreliminaryCredentialsByDwg as rr, DwgMessageOutputSchema as rt, idOSDelegatedWriteGrant as s, createMmTokenAuth as si, GetWalletsOutputSchema as sn, editAttribute as sr, EditPublicNotesAsIssuerInput as st, DelegatedWriteGrantBaseParams as t, KgwAuthFailurePredicate as ti, GetUserOutputSchema as tn, checkCallerPayer as tr, DwgMessageInputSchema as tt, idOSUserAttribute as u, KwilActionClient as ui, HasLockedAccessGrantsOutput as un, getAccessGrantsForCredential as ur, GetAccessGrantsForCredentialInput as ut, ActionCostingIdosTokenInputSchema as v, RemoveCredentialInput as vn, getCredentials as vr, GetAccessGrantsGrantedInput as vt, AddUserAsInserterInput as w, RequestWithdrawalInput as wn, getWalletWithBalance as wr, GetAllowanceOutput as wt, AddAttributeAsInserterInputSchema as x, RemoveWalletInputSchema as xn, getSiblingCredentialId as xr, GetAccessGrantsGrantedOutputSchema as xt, ActionSchemaElement as y, RemoveCredentialInputSchema as yn, getCredentialsSharedByUser as yr, GetAccessGrantsGrantedInputSchema as yt, CheckCallerPayerOutput as z, UpdateUserPubKeyAsInserterInputSchema as zn, updateUserPubKeyAsInserter as zr, GetCredentialsSharedByUserInputSchema as zt };
743
+ //# sourceMappingURL=index-Dwonqvwu.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dwonqvwu.d.mts","names":[],"sources":["../src/wait-for-kwil-tx.ts","../src/create-kwil-client.ts","../src/mm-token/create-mm-token-kwil-signer.ts","../src/create-kgw-authenticated-fetch.ts","../src/create-kwil-signer.ts","../src/near/create-near-wallet-kwil-signer.ts","../src/actions/actions.ts","../src/actions/index.ts"],"mappings":";;;;;;;;;;;;cAca,0BAA0B;WAInC;WACA;WACA;WACA;WANO;EAET,YACE,gBACA,cACA,aACA;;cAMS,+BAA+B;WAIxC;WACA;WAJO;EAET,YACE,gBACA,oBACA;IAAY;;;;;KCnBX;EACH;EACA;;KAGG,qBAAqB;KACrB,mBAAmB;KAEnB,uBACF,QAAQ;EACP,MAAM;EAEN,QAAQ,OAAO,YAAY;;KAI1B,8BAA8B,kBAAkB;KAEhD,0BACF,QAAQ,aAAa,kBAAkB;EAAU;;KAG/C,iCAAiC,qBAAqB;;;;;cAM9C;;EACX,SAAS;WACA,QAAQ,WAAW;EAE5B,YAAY,QAAQ,WAAW;;;;EAyB/B,KAAW,aACT,QAAQ,6BACR,SAAQ,yBACP,QAAQ;;;;;;;EAkBX,QACE,QAAQ,gCACR,SAAQ,wBACR,wBACC;;;;;;;;EA8BH,UAAgB,iBAAiB;EAIjC,UAAU,QAAQ;;;;;cA6BP,uBAAuB,QAAQ,2BAA2B,QAAQ;;;;cAMlE,sBAAsB,QAAQ,2BAA2B,QAAQ;;;;UCzJ7D;EACf,SAAS,iBAAiB;EAC1B;;UAGe;EACf;EACA;;;;;;;KAQU,cAAc;WACf,gBAAgB,iBAAiB;;WAEjC;;;;;WAKA;;iBAGK,cAAc,iBAAiB,SAAS;;iBAaxC,iBAAiB,QAAQ;;;;;;;;;;;iBA+CzB,kBAAkB,0BAA0B,kBAAkB;;;;;KCtFlE,2BAA2B,UAAU,aAAa;KAElD;EACV,Y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UACpB,YAAY,kBACZ,SAAQ,QAAQ,+BAKf,QAAQ"}
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $r as createMmTokenAuth, Br as SignerAddress, Fr as implicitAddressFromPublicKey, Gr as CreateKgwAuthenticatedBlobGatewayParams, Hr as Wallet, Ir as signNearMessage, Jr as createKgwAuthenticatedBlobGateway, Kr as CreateKgwAuthenticatedFetchParams, Lr as CustomKwilSigner, Pr as getNearFullAccessPublicKeys, Qr as MmTokenPayload, Rr as KwilSigner, Ur as createClientKwilSigner, Vr as SignerPublicKey, Wr as createServerKwilSigner, Xr as MmTokenAuth, Yr as createKgwAuthenticatedFetch, Zr as MmTokenEnvelope, ai as createWebKwilClient, ei as isMmTokenAuth, ii as createNodeKwilClient, ni as mmTokenStorageId, oi as KwilTxFailedError, qr as KgwAuthFailurePredicate, ri as KwilActionClient, si as KwilTxPollTimeoutError, ti as mmTokenCredentialContentUri, zr as KwilSignerType } from "./index-Bk8YCFlx.mjs";
2
- export { CreateKgwAuthenticatedBlobGatewayParams, CreateKgwAuthenticatedFetchParams, CustomKwilSigner, KgwAuthFailurePredicate, KwilActionClient, KwilSigner, KwilSignerType, KwilTxFailedError, KwilTxPollTimeoutError, MmTokenAuth, MmTokenEnvelope, MmTokenPayload, SignerAddress, SignerPublicKey, Wallet, createClientKwilSigner, createKgwAuthenticatedBlobGateway, createKgwAuthenticatedFetch, createMmTokenAuth, createNodeKwilClient, createServerKwilSigner, createWebKwilClient, getNearFullAccessPublicKeys, implicitAddressFromPublicKey, isMmTokenAuth, mmTokenCredentialContentUri, mmTokenStorageId, signNearMessage };
1
+ import { $r as CreateKgwAuthenticatedBlobGatewayParams, Gr as CustomKwilSigner, Hr as getNearFullAccessPublicKeys, Jr as SignerAddress, Kr as KwilSigner, Qr as createServerKwilSigner, Ur as implicitAddressFromPublicKey, Wr as signNearMessage, Xr as Wallet, Yr as SignerPublicKey, Zr as createClientKwilSigner, ai as MmTokenEnvelope, ci as isMmTokenAuth, di as createNodeKwilClient, ei as CreateKgwAuthenticatedFetchParams, fi as createWebKwilClient, ii as MmTokenAuth, li as mmTokenStorageId, mi as KwilTxPollTimeoutError, ni as createKgwAuthenticatedBlobGateway, oi as MmTokenPayload, pi as KwilTxFailedError, qr as KwilSignerType, ri as createKgwAuthenticatedFetch, si as createMmTokenAuth, ti as KgwAuthFailurePredicate, ui as KwilActionClient } from "./index-Dwonqvwu.mjs";
2
+ export { CreateKgwAuthenticatedBlobGatewayParams, CreateKgwAuthenticatedFetchParams, CustomKwilSigner, KgwAuthFailurePredicate, KwilActionClient, KwilSigner, KwilSignerType, KwilTxFailedError, KwilTxPollTimeoutError, MmTokenAuth, MmTokenEnvelope, MmTokenPayload, SignerAddress, SignerPublicKey, Wallet, createClientKwilSigner, createKgwAuthenticatedBlobGateway, createKgwAuthenticatedFetch, createMmTokenAuth, createNodeKwilClient, createServerKwilSigner, createWebKwilClient, getNearFullAccessPublicKeys, implicitAddressFromPublicKey, isMmTokenAuth, mmTokenStorageId, signNearMessage };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{actionSchema as e}from"./actions/index.mjs";import{t}from"./facesign-signer-CTPPUFxT.mjs";import{i as n,n as r,r as i}from"./nep413-D_D-6Yf6.mjs";import{getXrpPublicKey as a,getXrpTxHash as o,looksLikeXrpWallet as s}from"./xrp/utils.mjs";import{KwilSigner as c,KwilSigner as l,NodeKwil as u,WebKwil as d}from"@idos-network/kwil-js";import f from"tiny-invariant";import{BlobGateway as p,createUkycContentUri as m}from"@idos-network/utils/blob-gateway";import{base64Decode as h,base64UrlDecode as g,base64UrlEncode as _,binaryWriteUint16BE as v,bs58Decode as y,bs58Encode as b,bytesConcat as ee,hexDecode as te,hexEncode as x,utf8Decode as S,utf8Encode as C}from"@idos-network/utils/codecs";import w from"tweetnacl";var T=class extends Error{txHash;code;log;height;name=`KwilTxFailedError`;constructor(e,t,n,r){super(`Kwil transaction ${e} failed at height ${r} (code ${t}): ${n}`),this.txHash=e,this.code=t,this.log=n,this.height=r}},E=class extends Error{txHash;deadlineMs;name=`KwilTxPollTimeoutError`;constructor(e,t,n){let r=n?.cause instanceof Error?n.cause.message:n?.cause==null?void 0:String(n.cause);super(r?`Timed out after ${t}ms waiting for Kwil transaction ${e}: last error: ${r}`:`Timed out after ${t}ms waiting for Kwil transaction ${e}`,n?.cause===void 0?void 0:{cause:n.cause}),this.txHash=e,this.deadlineMs=t}};function D(e){return new Promise(t=>setTimeout(t,e))}function ne(e){return Math.min(e*1.5,2e3)}function re(e){return e+Math.floor(Math.random()*101)}function ie(e){return e.height>0}async function ae(e,t,n=9e4){let r=Date.now()+n,i=300,a;for(;Date.now()<r;){let n;try{n=(await e(t)).data}catch(e){a=e}if(n&&ie(n)){if(n.tx_result.code!==0)throw new T(t,n.tx_result.code,n.tx_result.log,n.height);return}let o=re(i),s=r-Date.now();if(s<=0)break;await D(Math.min(o,s)),i=ne(i)}throw new E(t,n,a===void 0?void 0:{cause:a})}var O=class{signer;client;constructor(e){this.client=e}#e(t,n={}){return!n||!Object.keys(n).length?[]:e[t].map(({name:e})=>{let t=n[e];return t===``||t===0?t:t??null})}#t(t){return e[t].map(e=>e.type)}async call(e,t=this.signer){let n={name:e.name,namespace:`main`,inputs:this.#e(e.name,e.inputs),types:this.#t(e.name)};return(await this.client.call(n,t))?.data?.result}async execute(e,t=this.signer,n=!0){f(t,`Signer is not set, you must set it before executing an action`);let r={name:e.name,namespace:`main`,description:e.description,inputs:[this.#e(e.name,e.inputs)],types:this.#t(e.name)},i=(await this.client.execute(r,t,!1)).data?.tx_hash;if(!i)throw Error(`Kwil execute "${e.name}" did not return a transaction hash`);return n&&await this.waitForTx(i),i}async waitForTx(e){await ae(e=>this.client.txInfo(e),e)}setSigner(e){this.signer=e}};const k=e=>async({nodeUrl:t,chainId:n})=>{let r=new e({kwilProvider:t,chainId:``});return n||=(await r.chainInfo({disableWarning:!0})).data?.chain_id,f(n,"Can't discover `chainId`. You must pass it explicitly."),new O(new e({kwilProvider:t,chainId:n,timeout:3e4}))},oe=k(u),A=k(d);function j(e){return typeof e==`object`&&!!e&&`signatureType`in e&&e.signatureType===`mm_token`&&`identifier`in e&&`signer`in e&&typeof e.accessToken==`string`}function M(e){let t=e.mmTokenPayload?.storage_id;if(typeof t!=`string`||!t.trim())throw Error(`mm_token payload is missing storage_id`);return t.trim()}function N(e,t){return m(M(e),t)}function P(e){return typeof e==`object`&&!!e&&`payload`in e&&e.payload!==null&&typeof e.payload==`object`&&!Array.isArray(e.payload)&&`signature`in e&&typeof e.signature==`string`}function F(e,t){try{return JSON.parse(S(e))}catch(e){throw Error(t,{cause:e})}}function I(e,t){try{return g(e)}catch(e){throw Error(t,{cause:e})}}function L(e){let t,n;if(typeof e==`string`){let r=e.trim();if(!r)throw Error(`Invalid mm_token envelope: empty`);t=r;let i=F(I(r,`Invalid mm_token envelope encoding`),`Invalid mm_token envelope JSON`);if(!P(i))throw Error(`Invalid mm_token envelope: expected payload object and signature string`);n=i}else{if(!P(e))throw Error(`Invalid mm_token envelope: expected payload object and signature string`);n=e,t=_(C(JSON.stringify(n)))}let r=C(t),i=I(n.signature,`Invalid mm_token envelope signature encoding`);if(i.length!==64)throw Error(`Invalid mm_token signature length: expected 64, got ${i.length}`);let a=n.payload.signing_public_key;if(typeof a!=`string`)throw Error(`Invalid mm_token payload: missing signing_public_key`);let o=I(a,`Invalid mm_token signing_public_key encoding`);if(o.length!==32)throw Error(`Invalid mm_token signing_public_key length: expected 32, got ${o.length}`);let s=Object.assign(new l(async()=>r.slice(),o,`mm_token`),{mmTokenPayload:n.payload});return Object.defineProperty(s,"accessToken",{value:t,enumerable:!1})}function R({url:e,maxFetchBytes:t,mmAuth:n,...r}){let i=n??(j(r.signer)?r.signer:void 0);return new p({url:e,maxFetchBytes:t,accessToken:i?.accessToken,fetchFn:z(r)})}function z({kwilClient:e,signer:t,fetchFn:n=fetch,isAuthFailure:r=le}){let i=se(e),a,o=async()=>(a??=i.authenticateKGWAndSetCookie(t).finally(()=>{a=void 0}),a),s=async()=>{let e=i.getKgwCookie();return e?{cookie:e,refreshed:!1}:{cookie:await o(),refreshed:!0}};return async(e,t)=>{let{cookie:i}=await s(),a=await U(e,t),c=await n(...J(e,W(a),i)),l=B(c);if(!await r(l.response))return c;await V(l.discardResponses);let u=await o();return n(...J(e,W(a),u))}}function B(e){if(e.headers.get(`content-type`)?.includes(`application/json`)){let t=e.clone();return{response:t,discardResponses:[e,t]}}return{response:e,discardResponses:[e]}}async function V(e){await Promise.all(e.map(H))}async function H(e){if(!e.bodyUsed&&e.body)try{await e.body.cancel()}catch{}}async function U(e,t){if(t?.body!=null)return{requestInit:t,bufferedBody:await G(t.body)};if(e instanceof Request&&e.body!=null){let n=e.clone();return{requestInit:{...t,method:t?.method??e.method},bufferedBody:await G(n.body)}}return{requestInit:t}}function W({requestInit:e,bufferedBody:t}){return t?{...e,body:q(t)}:e}async function G(e){if(typeof e==`string`||e instanceof Blob||e instanceof ArrayBuffer||e instanceof URLSearchParams)return{kind:`body`,value:e};if(ArrayBuffer.isView(e))return{kind:`body`,value:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)};if(e instanceof FormData){let t=[];return e.forEach((e,n)=>{t.push(K(n,e))}),{kind:`form-data`,entries:await Promise.all(t)}}return e instanceof ReadableStream?{kind:`body`,value:await new Response(e).arrayBuffer()}:{kind:`body`,value:e}}async function K(e,t){return typeof t==`string`?{key:e,value:t}:{key:e,value:await new Response(t).arrayBuffer(),fileName:t instanceof File?t.name:`blob`,type:t.type||`application/octet-stream`}}function q(e){if(e.kind===`body`)return e.value;let t=new FormData;for(let n of e.entries)`fileName`in n?t.append(n.key,new Blob([n.value],{type:n.type}),n.fileName):t.append(n.key,n.value);return t}function se(e){if(!(e.client instanceof u))throw Error(`KGW authenticated fetch can only be created from a NodeKwil client`);if(!ce(e.client))throw Error(`NodeKwil client does not expose KGW session cookie helpers`);return e.client}function ce(e){let t=e;return typeof t.getKgwCookie==`function`&&typeof t.authenticateKGWAndSetCookie==`function`}function J(e,t,n){let r=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((e,t)=>{r.set(t,e)}),r.set(`Cookie`,n),[e,{...t,headers:r}]}async function le(e){if(e.status===401)return!0;if(!e.headers.get(`content-type`)?.includes(`application/json`))return!1;try{return(await e.json()).error?.code===-901}catch{return!1}}const ue={mainnet:{networkId:`mainnet`,nodeUrl:`https://rpc.mainnet.near.org`},testnet:{networkId:`testnet`,nodeUrl:`https://rpc.testnet.near.org`},betanet:{networkId:`betanet`,nodeUrl:`https://rpc.betanet.near.org`},shardnet:{networkId:`shardnet`,nodeUrl:`https://rpc.shardnet.near.org`}},de=e=>e.endsWith(`.near`)?`mainnet`:e.endsWith(`.testnet`)?`testnet`:e.endsWith(`.betanet`)?`betanet`:e.endsWith(`.shardnet`)?`shardnet`:`testnet`,fe=e=>{let t=de(e),n=ue[t];return{networkId:n.networkId,nodeUrl:n.nodeUrl}},pe=[`browser`,`injected`,`instant-link`,`hardware`,`bridge`];function me(e){return typeof e==`object`&&!!e&&`id`in e&&`metadata`in e&&`type`in e&&typeof e.type==`string`&&pe.includes(e.type)}var Y=class{bytes;constructor(e=32){this.bytes=crypto.getRandomValues(new Uint8Array(e))}get clampUTF8(){return this.bytes.map(e=>e&127)}};function X(e,t){return async r=>{let i=typeof r==`string`?r:S(r);if(!e.signMessage)throw Error(`Only wallets with signMessage are supported.`);let a=Buffer.from(new Y(32).bytes),{nonce:o=a,signature:s,callbackUrl:c}=await e.signMessage({message:i,recipient:t,nonce:a}),l=n({message:i,nonce:Array.from(o),recipient:t,callbackUrl:c});return ee(v(l.length),l,h(s))}}function Z(e){let t=e.replace(/^ed25519:/,``);return x(y(t),!0)}async function Q(e){let t;try{t=(await import(`near-api-js`)).connect}catch{throw Error(`Can't load near-api-js`)}let n=fe(e),r=await t(n);try{return(await r.connection.provider.query({request_type:`view_access_key_list`,finality:`final`,account_id:e})).keys.filter(e=>e.access_key.permission===`FullAccess`)?.map(e=>e.public_key)}catch{return}}function he(e){let t=new URLSearchParams(e.startsWith(`#`)?e.slice(1):e),n=t.get(`signature`);return{accountId:t.get(`accountId`)??void 0,publicKey:t.get(`publicKey`)??void 0,signature:n?.replaceAll(` `,`+`),error:t.get(`error`)??void 0}}function ge(){let e=he(window.location.hash);if(!e.accountId&&!e.publicKey&&!e.signature&&!e.error)return e;let t=new URLSearchParams(window.location.hash.slice(1));for(let e of[`accountId`,`publicKey`,`signature`,`error`,`state`])t.delete(e);let n=t.toString();return window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${n?`#${n}`:``}`),e}function _e(e,t,n,r,a,o){let s=o.split(`:`);if(s.length!==2||s[0]!==`ed25519`||!s[1]||t.length!==32)return!1;try{let o=y(s[1]),c=h(a);return o.length!==32||c.length!==64?!1:w.sign.detached.verify(i({message:e,nonce:t,recipient:n,callbackUrl:r}),c,o)}catch{return!1}}async function ve(e,t,n,r){if(e.error||!e.signature||!e.publicKey||e.accountId!==t)return;let i=await r.get(`sign-last-message`),a=await r.get(`sign-last-nonce`),o=await r.get(`sign-last-url`);if(i&&a&&o&&_e(i,Uint8Array.from(a),n,o,e.signature,e.publicKey)&&(await Q(t))?.includes(e.publicKey))return{signature:e.signature,publicKey:e.publicKey}}async function ye(e,t,n=`idos.network`){let r=await X(e,n)(t);return x(r)}async function be(e,t,n,r,i=`idos.network`){if(!e.signMessage)throw Error(`Only wallets with signMessage are supported.`);if(e.id===`my-near-wallet`){let r=ge(),a=await ve(r,t,i,n);a&&(await n.set(`signer-address`,t),await n.set(`signer-public-key`,a.publicKey));let o=e.signMessage.bind(e);e.signMessage=async({message:e,recipient:i})=>{if(r.error)return Promise.reject();let s=await n.get(`sign-last-message`),c=await n.get(`sign-last-nonce`);if(a&&e===s&&c){let r=Buffer.from(c),i=await n.get(`sign-last-url`);return Promise.resolve({accountId:t,publicKey:a.publicKey,signature:a.signature,nonce:r,message:e,callbackUrl:i})}let l=window.location.href,u=Buffer.from(new Y(32).clampUTF8);return await n.set(`sign-last-message`,e),await n.set(`sign-last-nonce`,Array.from(u)),await n.set(`sign-last-url`,l),o({message:e,nonce:u,recipient:i,callbackUrl:l}),new Promise(()=>({}))}}let a=await n.get(`signer-address`),o=await n.get(`signer-public-key`);if(a!==t||!o){n.reset(),await r.client.auth.logoutKGW();let a=Buffer.from(new Y(32).bytes),s=await e.signMessage({message:`idOS authentication`,recipient:i,nonce:a});if(!s)throw Error(`signMessage returned no result`);({publicKey:o}=s),await n.set(`signer-address`,t),await n.set(`signer-public-key`,o)}let s=X(e,i);return{kwilSigner:new l(s,Z(o),`nep413`),publicKey:o}}async function $(e,t,n,r,i){let a=await n.get(`signer-address`),s=await n.get(`signer-public-key`);if(a!==t||s&&s!==i)try{console.log(`logoutKGW`,r)}catch(e){console.error(`Failed to logout KGW:`,e)}return await n.set(`signer-address`,t),await n.set(`signer-public-key`,i),new l(async t=>{let n=await o(t,e);if(!n||!/^(?:[0-9a-f]{2})+$/i.test(n))throw Error(`Failed to sign transaction with XRP`);return Buffer.from(n,`hex`)},i,`xrpl`)}function xe(e){return typeof e==`object`&&!!e&&`publicKey`in e&&e.publicKey instanceof Uint8Array&&e.publicKey.length===w.sign.publicKeyLength&&`secretKey`in e&&e.secretKey instanceof Uint8Array&&e.secretKey.length===w.sign.secretKeyLength}function Se(e){return typeof e==`object`&&!!e&&`getPublicKey`in e&&`sign`in e&&typeof e.getPublicKey==`function`&&typeof e.sign==`function`}function Ce(e){return typeof e==`object`&&!!e&&`publicKey`in e&&`sign`in e&&`canSign`in e&&typeof e.publicKey==`function`&&typeof e.sign==`function`&&typeof e.canSign==`function`}function we(e){return typeof e==`object`&&!!e&&`publicAddress`in e&&`signatureType`in e&&`publicKey`in e&&`signMessage`in e}function Te(e){return!!e&&typeof e==`object`&&`privateKey`in e&&`publicKey`in e}async function Ee(e){if(j(e))return[e,_(e.identifier)];if(xe(e))return[new l(async t=>w.sign.detached(t,e.secretKey),e.publicKey,`ed25519`),Z(b(e.publicKey))];if(Se(e)){let t=e.getPublicKey().toString(),n=Z(t);return[new l(r(`idos-issuer`)(e),n,`nep413`),t]}if(Ce(e)){let t=e.publicKey(),n=e.rawPublicKey();return[new l(async t=>e.sign(Buffer.from(t)),n,`ed25519`),t]}if(Te(e)){let t;try{t=await import(`ripple-keypairs`)}catch(e){throw Error(`Can't load ripple-keypairs`,{cause:e})}return[new l(async n=>te(t.sign(x(n),e.privateKey)),e.publicKey,`xrpl`),e.publicKey]}return`address`in e?[new l(e,e.address),e.address]:(e=>{throw Error("Invalid `signer` type")})(e)}async function De(e,n,r){if(`connect`in r&&`address`in r){r=r;let t=await r.getAddress();if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new l(r,t),t,void 0,`EVM`]}if(me(r)){let t=await r.getAccounts(),{kwilSigner:i,publicKey:a}=await be(r,t[0].accountId,e,n);return[i,t[0].accountId,a,`NEAR`]}if(s(r)){let{address:t,publicKey:i}=await a(r);if(!t)throw Error(`Failed to get XRP address`);return[await $(r,t,e,n,i),t,i,`XRPL`]}if(j(r)){let t=_(r.identifier);if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[r,t,t,`MM`]}if(we(r)||r instanceof t){if(await e.get(`signer-address`)!==r.publicAddress){e.set(`signer-address`,r.publicAddress);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new l(async e=>r.signMessage(e),r.publicAddress,`ed25519`),r.publicAddress,r.publicKey,r.walletType]}return(e=>{throw Error("Invalid `signer` type")})(r)}export{O as KwilActionClient,c as KwilSigner,T as KwilTxFailedError,E as KwilTxPollTimeoutError,De as createClientKwilSigner,R as createKgwAuthenticatedBlobGateway,z as createKgwAuthenticatedFetch,L as createMmTokenAuth,oe as createNodeKwilClient,Ee as createServerKwilSigner,A as createWebKwilClient,Q as getNearFullAccessPublicKeys,Z as implicitAddressFromPublicKey,j as isMmTokenAuth,N as mmTokenCredentialContentUri,M as mmTokenStorageId,ye as signNearMessage};
1
+ import{actionSchema as e}from"./actions/index.mjs";import{t}from"./facesign-signer-CTPPUFxT.mjs";import{i as n,n as r,r as i}from"./nep413-D_D-6Yf6.mjs";import{getXrpPublicKey as a,getXrpTxHash as o,looksLikeXrpWallet as s}from"./xrp/utils.mjs";import{KwilSigner as c,KwilSigner as l,NodeKwil as u,WebKwil as d}from"@idos-network/kwil-js";import f from"tiny-invariant";import{BlobGateway as p}from"@idos-network/utils/blob-gateway";import{base64Decode as m,base64UrlDecode as ee,base64UrlEncode as h,binaryWriteUint16BE as g,bs58Decode as _,bs58Encode as v,bytesConcat as y,hexDecode as te,hexEncode as b,utf8Decode as x,utf8Encode as S}from"@idos-network/utils/codecs";import C from"tweetnacl";var w=class extends Error{txHash;code;log;height;name=`KwilTxFailedError`;constructor(e,t,n,r){super(`Kwil transaction ${e} failed at height ${r} (code ${t}): ${n}`),this.txHash=e,this.code=t,this.log=n,this.height=r}},T=class extends Error{txHash;deadlineMs;name=`KwilTxPollTimeoutError`;constructor(e,t,n){let r=n?.cause instanceof Error?n.cause.message:n?.cause==null?void 0:String(n.cause);super(r?`Timed out after ${t}ms waiting for Kwil transaction ${e}: last error: ${r}`:`Timed out after ${t}ms waiting for Kwil transaction ${e}`,n?.cause===void 0?void 0:{cause:n.cause}),this.txHash=e,this.deadlineMs=t}};function E(e){return new Promise(t=>setTimeout(t,e))}function ne(e){return Math.min(e*1.5,2e3)}function re(e){return e+Math.floor(Math.random()*101)}function ie(e){return e.height>0}async function ae(e,t,n=9e4){let r=Date.now()+n,i=300,a;for(;Date.now()<r;){let n;try{n=(await e(t)).data}catch(e){a=e}if(n&&ie(n)){if(n.tx_result.code!==0)throw new w(t,n.tx_result.code,n.tx_result.log,n.height);return}let o=re(i),s=r-Date.now();if(s<=0)break;await E(Math.min(o,s)),i=ne(i)}throw new T(t,n,a===void 0?void 0:{cause:a})}var D=class{signer;client;constructor(e){this.client=e}#e(t,n={}){return!n||!Object.keys(n).length?[]:e[t].map(({name:e})=>{let t=n[e];return t===``||t===0?t:t??null})}#t(t){return e[t].map(e=>e.type)}async call(e,t=this.signer){let n={name:e.name,namespace:`main`,inputs:this.#e(e.name,e.inputs),types:this.#t(e.name)};return(await this.client.call(n,t))?.data?.result}async execute(e,t=this.signer,n=!0){f(t,`Signer is not set, you must set it before executing an action`);let r={name:e.name,namespace:`main`,description:e.description,inputs:[this.#e(e.name,e.inputs)],types:this.#t(e.name)},i=(await this.client.execute(r,t,!1)).data?.tx_hash;if(!i)throw Error(`Kwil execute "${e.name}" did not return a transaction hash`);return n&&await this.waitForTx(i),i}async waitForTx(e){await ae(e=>this.client.txInfo(e),e)}setSigner(e){this.signer=e}};const O=e=>async({nodeUrl:t,chainId:n})=>{let r=new e({kwilProvider:t,chainId:``});return n||=(await r.chainInfo({disableWarning:!0})).data?.chain_id,f(n,"Can't discover `chainId`. You must pass it explicitly."),new D(new e({kwilProvider:t,chainId:n,timeout:3e4}))},oe=O(u),k=O(d);function A(e){return typeof e==`object`&&!!e&&`signatureType`in e&&e.signatureType===`mm_token`&&`identifier`in e&&`signer`in e&&typeof e.accessToken==`string`}function j(e){let t=e.mmTokenPayload?.storage_id;if(typeof t!=`string`||!t.trim())throw Error(`mm_token payload is missing storage_id`);return t.trim()}function M(e){return typeof e==`object`&&!!e&&`payload`in e&&e.payload!==null&&typeof e.payload==`object`&&!Array.isArray(e.payload)&&`signature`in e&&typeof e.signature==`string`}function N(e,t){try{return JSON.parse(x(e))}catch(e){throw Error(t,{cause:e})}}function P(e,t){try{return ee(e)}catch(e){throw Error(t,{cause:e})}}function F(e){let t,n;if(typeof e==`string`){let r=e.trim();if(!r)throw Error(`Invalid mm_token envelope: empty`);t=r;let i=N(P(r,`Invalid mm_token envelope encoding`),`Invalid mm_token envelope JSON`);if(!M(i))throw Error(`Invalid mm_token envelope: expected payload object and signature string`);n=i}else{if(!M(e))throw Error(`Invalid mm_token envelope: expected payload object and signature string`);n=e,t=h(S(JSON.stringify(n)))}let r=S(t),i=P(n.signature,`Invalid mm_token envelope signature encoding`);if(i.length!==64)throw Error(`Invalid mm_token signature length: expected 64, got ${i.length}`);let a=n.payload.signing_public_key;if(typeof a!=`string`)throw Error(`Invalid mm_token payload: missing signing_public_key`);let o=P(a,`Invalid mm_token signing_public_key encoding`);if(o.length!==32)throw Error(`Invalid mm_token signing_public_key length: expected 32, got ${o.length}`);let s=Object.assign(new l(async()=>r.slice(),o,`mm_token`),{mmTokenPayload:n.payload});return Object.defineProperty(s,"accessToken",{value:t,enumerable:!1})}function I({url:e,maxFetchBytes:t,mmAuth:n,...r}){let i=n??(A(r.signer)?r.signer:void 0);return new p({url:e,maxFetchBytes:t,accessToken:i?.accessToken,fetchFn:L(r)})}function L({kwilClient:e,signer:t,fetchFn:n=fetch,isAuthFailure:r=se}){let i=K(e),a,o=async()=>(a??=i.authenticateKGWAndSetCookie(t).finally(()=>{a=void 0}),a),s=async()=>{let e=i.getKgwCookie();return e?{cookie:e,refreshed:!1}:{cookie:await o(),refreshed:!0}};return async(e,t)=>{let{cookie:i}=await s(),a=await V(e,t),c=await n(...J(e,H(a),i)),l=R(c);if(!await r(l.response))return c;await z(l.discardResponses);let u=await o();return n(...J(e,H(a),u))}}function R(e){if(e.headers.get(`content-type`)?.includes(`application/json`)){let t=e.clone();return{response:t,discardResponses:[e,t]}}return{response:e,discardResponses:[e]}}async function z(e){await Promise.all(e.map(B))}async function B(e){if(!e.bodyUsed&&e.body)try{await e.body.cancel()}catch{}}async function V(e,t){if(t?.body!=null)return{requestInit:t,bufferedBody:await U(t.body)};if(e instanceof Request&&e.body!=null){let n=e.clone();return{requestInit:{...t,method:t?.method??e.method},bufferedBody:await U(n.body)}}return{requestInit:t}}function H({requestInit:e,bufferedBody:t}){return t?{...e,body:G(t)}:e}async function U(e){if(typeof e==`string`||e instanceof Blob||e instanceof ArrayBuffer||e instanceof URLSearchParams)return{kind:`body`,value:e};if(ArrayBuffer.isView(e))return{kind:`body`,value:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)};if(e instanceof FormData){let t=[];return e.forEach((e,n)=>{t.push(W(n,e))}),{kind:`form-data`,entries:await Promise.all(t)}}return e instanceof ReadableStream?{kind:`body`,value:await new Response(e).arrayBuffer()}:{kind:`body`,value:e}}async function W(e,t){return typeof t==`string`?{key:e,value:t}:{key:e,value:await new Response(t).arrayBuffer(),fileName:t instanceof File?t.name:`blob`,type:t.type||`application/octet-stream`}}function G(e){if(e.kind===`body`)return e.value;let t=new FormData;for(let n of e.entries)`fileName`in n?t.append(n.key,new Blob([n.value],{type:n.type}),n.fileName):t.append(n.key,n.value);return t}function K(e){if(!(e.client instanceof u))throw Error(`KGW authenticated fetch can only be created from a NodeKwil client`);if(!q(e.client))throw Error(`NodeKwil client does not expose KGW session cookie helpers`);return e.client}function q(e){let t=e;return typeof t.getKgwCookie==`function`&&typeof t.authenticateKGWAndSetCookie==`function`}function J(e,t,n){let r=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((e,t)=>{r.set(t,e)}),r.set(`Cookie`,n),[e,{...t,headers:r}]}async function se(e){if(e.status===401)return!0;if(!e.headers.get(`content-type`)?.includes(`application/json`))return!1;try{return(await e.json()).error?.code===-901}catch{return!1}}const ce={mainnet:{networkId:`mainnet`,nodeUrl:`https://rpc.mainnet.near.org`},testnet:{networkId:`testnet`,nodeUrl:`https://rpc.testnet.near.org`},betanet:{networkId:`betanet`,nodeUrl:`https://rpc.betanet.near.org`},shardnet:{networkId:`shardnet`,nodeUrl:`https://rpc.shardnet.near.org`}},le=e=>e.endsWith(`.near`)?`mainnet`:e.endsWith(`.testnet`)?`testnet`:e.endsWith(`.betanet`)?`betanet`:e.endsWith(`.shardnet`)?`shardnet`:`testnet`,ue=e=>{let t=le(e),n=ce[t];return{networkId:n.networkId,nodeUrl:n.nodeUrl}},de=[`browser`,`injected`,`instant-link`,`hardware`,`bridge`];function fe(e){return typeof e==`object`&&!!e&&`id`in e&&`metadata`in e&&`type`in e&&typeof e.type==`string`&&de.includes(e.type)}var Y=class{bytes;constructor(e=32){this.bytes=crypto.getRandomValues(new Uint8Array(e))}get clampUTF8(){return this.bytes.map(e=>e&127)}};function X(e,t){return async r=>{let i=typeof r==`string`?r:x(r);if(!e.signMessage)throw Error(`Only wallets with signMessage are supported.`);let a=Buffer.from(new Y(32).bytes),{nonce:o=a,signature:s,callbackUrl:c}=await e.signMessage({message:i,recipient:t,nonce:a}),l=n({message:i,nonce:Array.from(o),recipient:t,callbackUrl:c});return y(g(l.length),l,m(s))}}function Z(e){let t=e.replace(/^ed25519:/,``);return b(_(t),!0)}async function Q(e){let t;try{t=(await import(`near-api-js`)).connect}catch{throw Error(`Can't load near-api-js`)}let n=ue(e),r=await t(n);try{return(await r.connection.provider.query({request_type:`view_access_key_list`,finality:`final`,account_id:e})).keys.filter(e=>e.access_key.permission===`FullAccess`)?.map(e=>e.public_key)}catch{return}}function pe(e){let t=new URLSearchParams(e.startsWith(`#`)?e.slice(1):e),n=t.get(`signature`);return{accountId:t.get(`accountId`)??void 0,publicKey:t.get(`publicKey`)??void 0,signature:n?.replaceAll(` `,`+`),error:t.get(`error`)??void 0}}function me(){let e=pe(window.location.hash);if(!e.accountId&&!e.publicKey&&!e.signature&&!e.error)return e;let t=new URLSearchParams(window.location.hash.slice(1));for(let e of[`accountId`,`publicKey`,`signature`,`error`,`state`])t.delete(e);let n=t.toString();return window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${n?`#${n}`:``}`),e}function he(e,t,n,r,a,o){let s=o.split(`:`);if(s.length!==2||s[0]!==`ed25519`||!s[1]||t.length!==32)return!1;try{let o=_(s[1]),c=m(a);return o.length!==32||c.length!==64?!1:C.sign.detached.verify(i({message:e,nonce:t,recipient:n,callbackUrl:r}),c,o)}catch{return!1}}async function ge(e,t,n,r){if(e.error||!e.signature||!e.publicKey||e.accountId!==t)return;let i=await r.get(`sign-last-message`),a=await r.get(`sign-last-nonce`),o=await r.get(`sign-last-url`);if(i&&a&&o&&he(i,Uint8Array.from(a),n,o,e.signature,e.publicKey)&&(await Q(t))?.includes(e.publicKey))return{signature:e.signature,publicKey:e.publicKey}}async function _e(e,t,n=`idos.network`){let r=await X(e,n)(t);return b(r)}async function ve(e,t,n,r,i=`idos.network`){if(!e.signMessage)throw Error(`Only wallets with signMessage are supported.`);if(e.id===`my-near-wallet`){let r=me(),a=await ge(r,t,i,n);a&&(await n.set(`signer-address`,t),await n.set(`signer-public-key`,a.publicKey));let o=e.signMessage.bind(e);e.signMessage=async({message:e,recipient:i})=>{if(r.error)return Promise.reject();let s=await n.get(`sign-last-message`),c=await n.get(`sign-last-nonce`);if(a&&e===s&&c){let r=Buffer.from(c),i=await n.get(`sign-last-url`);return Promise.resolve({accountId:t,publicKey:a.publicKey,signature:a.signature,nonce:r,message:e,callbackUrl:i})}let l=window.location.href,u=Buffer.from(new Y(32).clampUTF8);return await n.set(`sign-last-message`,e),await n.set(`sign-last-nonce`,Array.from(u)),await n.set(`sign-last-url`,l),o({message:e,nonce:u,recipient:i,callbackUrl:l}),new Promise(()=>({}))}}let a=await n.get(`signer-address`),o=await n.get(`signer-public-key`);if(a!==t||!o){n.reset(),await r.client.auth.logoutKGW();let a=Buffer.from(new Y(32).bytes),s=await e.signMessage({message:`idOS authentication`,recipient:i,nonce:a});if(!s)throw Error(`signMessage returned no result`);({publicKey:o}=s),await n.set(`signer-address`,t),await n.set(`signer-public-key`,o)}let s=X(e,i);return{kwilSigner:new l(s,Z(o),`nep413`),publicKey:o}}async function ye(e,t,n,r,i){let a=await n.get(`signer-address`),s=await n.get(`signer-public-key`);if(a!==t||s&&s!==i)try{console.log(`logoutKGW`,r)}catch(e){console.error(`Failed to logout KGW:`,e)}return await n.set(`signer-address`,t),await n.set(`signer-public-key`,i),new l(async t=>{let n=await o(t,e);if(!n||!/^(?:[0-9a-f]{2})+$/i.test(n))throw Error(`Failed to sign transaction with XRP`);return Buffer.from(n,`hex`)},i,`xrpl`)}function be(e){return typeof e==`object`&&!!e&&`publicKey`in e&&e.publicKey instanceof Uint8Array&&e.publicKey.length===C.sign.publicKeyLength&&`secretKey`in e&&e.secretKey instanceof Uint8Array&&e.secretKey.length===C.sign.secretKeyLength}function $(e){return typeof e==`object`&&!!e&&`getPublicKey`in e&&`sign`in e&&typeof e.getPublicKey==`function`&&typeof e.sign==`function`}function xe(e){return typeof e==`object`&&!!e&&`publicKey`in e&&`sign`in e&&`canSign`in e&&typeof e.publicKey==`function`&&typeof e.sign==`function`&&typeof e.canSign==`function`}function Se(e){return typeof e==`object`&&!!e&&`publicAddress`in e&&`signatureType`in e&&`publicKey`in e&&`signMessage`in e}function Ce(e){return!!e&&typeof e==`object`&&`privateKey`in e&&`publicKey`in e}async function we(e){if(A(e))return[e,h(e.identifier)];if(be(e))return[new l(async t=>C.sign.detached(t,e.secretKey),e.publicKey,`ed25519`),Z(v(e.publicKey))];if($(e)){let t=e.getPublicKey().toString(),n=Z(t);return[new l(r(`idos-issuer`)(e),n,`nep413`),t]}if(xe(e)){let t=e.publicKey(),n=e.rawPublicKey();return[new l(async t=>e.sign(Buffer.from(t)),n,`ed25519`),t]}if(Ce(e)){let t;try{t=await import(`ripple-keypairs`)}catch(e){throw Error(`Can't load ripple-keypairs`,{cause:e})}return[new l(async n=>te(t.sign(b(n),e.privateKey)),e.publicKey,`xrpl`),e.publicKey]}return`address`in e?[new l(e,e.address),e.address]:(e=>{throw Error("Invalid `signer` type")})(e)}async function Te(e,n,r){if(`connect`in r&&`address`in r){r=r;let t=await r.getAddress();if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new l(r,t),t,void 0,`EVM`]}if(fe(r)){let t=await r.getAccounts(),{kwilSigner:i,publicKey:a}=await ve(r,t[0].accountId,e,n);return[i,t[0].accountId,a,`NEAR`]}if(s(r)){let{address:t,publicKey:i}=await a(r);if(!t)throw Error(`Failed to get XRP address`);return[await ye(r,t,e,n,i),t,i,`XRPL`]}if(A(r)){let t=h(r.identifier);if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[r,t,t,`MM`]}if(Se(r)||r instanceof t){if(await e.get(`signer-address`)!==r.publicAddress){e.set(`signer-address`,r.publicAddress);try{await n.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new l(async e=>r.signMessage(e),r.publicAddress,`ed25519`),r.publicAddress,r.publicKey,r.walletType]}return(e=>{throw Error("Invalid `signer` type")})(r)}export{D as KwilActionClient,c as KwilSigner,w as KwilTxFailedError,T as KwilTxPollTimeoutError,Te as createClientKwilSigner,I as createKgwAuthenticatedBlobGateway,L as createKgwAuthenticatedFetch,F as createMmTokenAuth,oe as createNodeKwilClient,we as createServerKwilSigner,k as createWebKwilClient,Q as getNearFullAccessPublicKeys,Z as implicitAddressFromPublicKey,A as isMmTokenAuth,j as mmTokenStorageId,_e as signNearMessage};
2
2
  //# sourceMappingURL=index.mjs.map