@idos-network/kwil-infra 3.0.1 → 5.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.
@@ -43,6 +43,16 @@ type AllKwilExecuteAction = { [Name in ActionName]: AllKwilCallAction[Name] & {
43
43
  description: string;
44
44
  }; };
45
45
  type KwilExecuteActionRequestParams = AllKwilExecuteAction[ActionName];
46
+ /**
47
+ * A view action ran but failed (its `error()` or a runtime error). kwild reports that in the
48
+ * call response's `error` field, not as an HTTP/RPC error, so it is only thrown when
49
+ * `KwilActionClient.throwOnCallError` is set.
50
+ */
51
+ declare class KwilCallError extends Error {
52
+ readonly actionName: string;
53
+ readonly name = "KwilCallError";
54
+ constructor(actionName: string, message: string);
55
+ }
46
56
  /**
47
57
  * A client for interacting with kwil with type-safe abstractions for `call` and `execute`.
48
58
  * Has utility methods for creating actions and setting a signer.
@@ -50,6 +60,11 @@ type KwilExecuteActionRequestParams = AllKwilExecuteAction[ActionName];
50
60
  declare class KwilActionClient {
51
61
  #private;
52
62
  signer?: KwilSigner;
63
+ /**
64
+ * When true, `call` throws `KwilCallError` if the view action reports an error. When false
65
+ * (default) such a call resolves to its (empty) result, as it always has.
66
+ */
67
+ throwOnCallError: boolean;
53
68
  readonly client: NodeKwil | WebKwil;
54
69
  constructor(client: NodeKwil | WebKwil);
55
70
  /**
@@ -82,47 +97,6 @@ declare const createNodeKwilClient: (params: CreateKwilClientParams) => Promise<
82
97
  */
83
98
  declare const createWebKwilClient: (params: CreateKwilClientParams) => Promise<KwilActionClient>;
84
99
  //#endregion
85
- //#region src/mm-token/create-mm-token-kwil-signer.d.ts
86
- /** Decoded UKYC capability envelope. KGW signature data is base64url(JSON of this). */
87
- interface MmTokenEnvelope {
88
- payload: MmTokenPayload | Record<string, unknown>;
89
- signature: string;
90
- }
91
- interface MmTokenPayload {
92
- signing_public_key: string;
93
- storage_id?: string;
94
- [key: string]: unknown;
95
- }
96
- /**
97
- * One MM/UKYC capability, valid both as a KGW `mm_token` signer and as the
98
- * `Authorization: AccessToken …` credential for UKYC blob requests.
99
- */
100
- type MmTokenAuth = KwilSigner & {
101
- readonly mmTokenPayload: MmTokenPayload | Record<string, unknown>;
102
- /** Exact encoded envelope KGW and UKYC storage verify. Non-enumerable, so it stays out of logs. */
103
- readonly accessToken: string;
104
- /**
105
- * A capability signs its own envelope, never an arbitrary message. Declared so callers
106
- * handling a `Wallet` union can keep asking wallets for a message signature.
107
- */
108
- readonly signMessage?: undefined;
109
- };
110
- declare function isMmTokenAuth(value: unknown): value is MmTokenAuth;
111
- /** `storage_id` from the capability token used to construct this signer. */
112
- declare function mmTokenStorageId(signer: KwilSigner): string;
113
- declare function mmTokenCredentialContentUri(signer: KwilSigner, credentialId: string): string;
114
- /**
115
- * Build the MM authentication object for one UKYC capability.
116
- *
117
- * Pass the MetaMask-issued capability token as a **base64url-encoded** envelope string
118
- * (what KGW verifies). A decoded `{ payload, signature }` object is also accepted and
119
- * will be re-encoded.
120
- *
121
- * `signMessage` always returns the UTF-8 bytes of that encoded string — KGW ignores the
122
- * request message and only verifies the envelope.
123
- */
124
- declare function createMmTokenAuth(encodedEnvelope: string | MmTokenEnvelope): MmTokenAuth;
125
- //#endregion
126
100
  //#region src/create-kgw-authenticated-fetch.d.ts
127
101
  /** Return true when the response means KGW auth is missing/expired.
128
102
  * May read the body only for `application/json` responses (those are probed via a clone). */
@@ -137,16 +111,16 @@ type CreateKgwAuthenticatedBlobGatewayParams = CreateKgwAuthenticatedFetchParams
137
111
  url: string;
138
112
  maxFetchBytes?: BlobGatewayParams["maxFetchBytes"];
139
113
  /**
140
- * UKYC storage authority for blob requests. Defaults to `signer` when that signer
141
- * is itself an MM authentication object, so the capability is never passed twice.
114
+ * UKYC storage token, sent as `Authorization: AccessToken <token>` next to the KGW session
115
+ * cookie. Only MM operators use it; `BlobGateway.withAccessToken()` swaps it per request.
142
116
  */
143
- mmAuth?: MmTokenAuth;
117
+ accessToken?: string;
144
118
  };
145
- declare function createKgwAuthenticatedBlobGateway({ url, maxFetchBytes, mmAuth, ...fetchParams }: CreateKgwAuthenticatedBlobGatewayParams): BlobGateway;
119
+ declare function createKgwAuthenticatedBlobGateway({ url, maxFetchBytes, accessToken, ...fetchParams }: CreateKgwAuthenticatedBlobGatewayParams): BlobGateway;
146
120
  declare function createKgwAuthenticatedFetch({ kwilClient, signer, fetchFn, isAuthFailure }: CreateKgwAuthenticatedFetchParams): typeof fetch;
147
121
  //#endregion
148
122
  //#region src/create-kwil-signer.d.ts
149
- type Wallet$2 = Wallet$1 | JsonRpcSigner | Wallet | CustomKwilSigner | MmTokenAuth | FaceSignSignerProvider;
123
+ type Wallet$2 = Wallet$1 | JsonRpcSigner | Wallet | CustomKwilSigner | FaceSignSignerProvider;
150
124
  interface CustomKwilSigner extends KwilSigner {
151
125
  publicAddress: string;
152
126
  signatureType: string;
@@ -154,7 +128,7 @@ interface CustomKwilSigner extends KwilSigner {
154
128
  walletType: string;
155
129
  signMessage: (message: Uint8Array | string) => Promise<Uint8Array>;
156
130
  }
157
- type KwilSignerType = KeyPair | Wallet$1 | nacl.SignKeyPair | JsonRpcSigner | Keypair | KeyPair$1 | MmTokenAuth;
131
+ type KwilSignerType = KeyPair | Wallet$1 | nacl.SignKeyPair | JsonRpcSigner | Keypair | KeyPair$1;
158
132
  type SignerAddress = string;
159
133
  type SignerPublicKey = string | undefined;
160
134
  /**
@@ -176,6 +150,9 @@ declare const DataType: typeof Utils.DataType;
176
150
  declare const WALLET_TYPES: readonly ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign", "MM"];
177
151
  type WalletType = (typeof WALLET_TYPES)[number];
178
152
  declare const walletTypeSchema: z.ZodType<WalletType>;
153
+ declare const ADD_WALLET_TYPES: readonly ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign"];
154
+ type AddWalletType = (typeof ADD_WALLET_TYPES)[number];
155
+ declare const addWalletTypeSchema: z.ZodType<AddWalletType>;
179
156
  declare const ENCRYPTION_PASSWORD_STORES: readonly ["user", "mpc", "mm"];
180
157
  type EncryptionPasswordStore = (typeof ENCRYPTION_PASSWORD_STORES)[number];
181
158
  declare const encryptionPasswordStoreSchema: z.ZodType<EncryptionPasswordStore>;
@@ -217,23 +194,26 @@ declare const GetUserAsInserterOutputSchema: z.ZodObject<{
217
194
  inserter: z.ZodString;
218
195
  }>;
219
196
  type GetUserAsInserterOutput = z.infer<typeof GetUserAsInserterOutputSchema>;
220
- declare function getUserAsInserter(kwilClient: KwilActionClient, params: GetUserAsInserterInput): Promise<GetUserAsInserterOutput>;
197
+ declare function getUserAsInserter(kwilClient: KwilActionClient, params: GetUserAsInserterInput): Promise<GetUserAsInserterOutput | undefined>;
221
198
  declare const UpsertWalletAsInserterInputSchema: z.ZodObject<{
222
199
  id: z.ZodUUID;
223
200
  user_id: z.ZodUUID;
224
201
  address: z.ZodString;
225
202
  public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
226
- wallet_type: z.ZodType<WalletType>;
227
- not_before: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
228
- not_after: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
203
+ wallet_type: z.ZodType<AddWalletType>;
204
+ not_before: z.ZodISODateTime;
205
+ not_after: z.ZodISODateTime;
229
206
  signature: z.ZodString;
230
207
  }>;
231
208
  type UpsertWalletAsInserterInput = z.infer<typeof UpsertWalletAsInserterInputSchema>;
232
- /** WALLET ACTIONS */
209
+ /**
210
+ * WALLET ACTIONS
211
+ * Existing MM wallets count too: a key can't be both an MM wallet and another wallet.
212
+ */
233
213
  declare function upsertWalletAsInserter(kwilClient: KwilActionClient, params: UpsertWalletAsInserterInput): Promise<void>;
234
214
  declare const AddWalletMessageInputSchema: z.ZodObject<{
235
215
  address: z.ZodString;
236
- wallet_type: z.ZodType<WalletType>;
216
+ wallet_type: z.ZodType<AddWalletType>;
237
217
  user_id: z.ZodUUID;
238
218
  not_before: z.ZodISODateTime;
239
219
  not_after: z.ZodISODateTime;
@@ -248,7 +228,7 @@ declare const AddWalletInputSchema: z.ZodObject<{
248
228
  id: z.ZodUUID;
249
229
  address: z.ZodString;
250
230
  public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
251
- wallet_type: z.ZodType<WalletType>;
231
+ wallet_type: z.ZodType<AddWalletType>;
252
232
  not_before: z.ZodISODateTime;
253
233
  not_after: z.ZodISODateTime;
254
234
  signature: z.ZodString;
@@ -261,7 +241,7 @@ declare const GetWalletsOutputSchema: z.ZodObject<{
261
241
  address: z.ZodString;
262
242
  public_key: z.ZodNullable<z.ZodString>;
263
243
  wallet_type: z.ZodType<WalletType>;
264
- message: z.ZodString;
244
+ message: z.ZodNullable<z.ZodString>;
265
245
  signature: z.ZodString;
266
246
  inserter: z.ZodNullable<z.ZodString>;
267
247
  }>;
@@ -271,7 +251,23 @@ declare const RemoveWalletInputSchema: z.ZodObject<{
271
251
  id: z.ZodUUID;
272
252
  }>;
273
253
  type RemoveWalletInput = z.infer<typeof RemoveWalletInputSchema>;
254
+ /**
255
+ * A user may have an MM wallet next to others (created before MM operators). Without it
256
+ * the user is no longer an MM user, and its ukyc:// credentials could never be wiped.
257
+ */
274
258
  declare function removeWallet(kwilClient: KwilActionClient, params: RemoveWalletInput): Promise<void>;
259
+ declare const CredentialBroaderMessageInputSchema: z.ZodObject<{
260
+ public_notes_signature: z.ZodString;
261
+ content_uri: z.ZodString;
262
+ recipient_wallet: z.ZodString;
263
+ }>;
264
+ type CredentialBroaderMessageInput = z.infer<typeof CredentialBroaderMessageInputSchema>;
265
+ declare const CredentialBroaderMessageOutputSchema: z.ZodObject<{
266
+ message: z.ZodString;
267
+ }>;
268
+ type CredentialBroaderMessageOutput = z.infer<typeof CredentialBroaderMessageOutputSchema>;
269
+ /** CREDENTIAL ACTIONS */
270
+ declare function credentialBroaderMessage(kwilClient: KwilActionClient, params: CredentialBroaderMessageInput): Promise<CredentialBroaderMessageOutput>;
275
271
  declare const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
276
272
  request_id: z.ZodUUID;
277
273
  credential_id: z.ZodUUID;
@@ -285,7 +281,10 @@ declare const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
285
281
  broader_signature: z.ZodString;
286
282
  }>;
287
283
  type CreatePreliminaryCredentialInput = z.infer<typeof CreatePreliminaryCredentialInputSchema>;
288
- /** CREDENTIAL ACTIONS */
284
+ /**
285
+ * Refused for MM users, also when signed in with another wallet: their MM operator stages
286
+ * their credentials (create_preliminary_credential_as_mm_operator), with their storage token.
287
+ */
289
288
  declare function createPreliminaryCredential(kwilClient: KwilActionClient, params: CreatePreliminaryCredentialInput): Promise<void>;
290
289
  declare const GetCredentialsOutputSchema: z.ZodObject<{
291
290
  id: z.ZodUUID;
@@ -364,6 +363,7 @@ declare const SharePreliminaryCredentialInputSchema: z.ZodObject<{
364
363
  locked_until: z.ZodNumber;
365
364
  }>;
366
365
  type SharePreliminaryCredentialInput = z.infer<typeof SharePreliminaryCredentialInputSchema>;
366
+ /** Refused for MM users, also when signed in with another wallet: their credentials can't be shared. */
367
367
  declare function sharePreliminaryCredential(kwilClient: KwilActionClient, params: SharePreliminaryCredentialInput): Promise<void>;
368
368
  declare const CreatePreliminaryCredentialsByDwgInputSchema: z.ZodObject<{
369
369
  request_id: z.ZodUUID;
@@ -396,6 +396,7 @@ type CreatePreliminaryCredentialsByDwgInput = z.infer<typeof CreatePreliminaryCr
396
396
  * Delegated write credential actions
397
397
  * For access grant
398
398
  * We will use the same ids for preliminary credentials as for credentials, so we need to check if they already exist
399
+ * MM users are managed by their MM operator only.
399
400
  * We capture gas upfront to prevent the real credential from being created if the gas is not enough
400
401
  * The gas can be refunded fully or partially
401
402
  * Temporary: an issuer is not an inserter/caller. A user grants a DWG to an issuer_key;
@@ -422,7 +423,7 @@ declare const CredentialExistAsInserterOutputSchema: z.ZodObject<{
422
423
  credential_exist: z.ZodBoolean;
423
424
  }>;
424
425
  type CredentialExistAsInserterOutput = z.infer<typeof CredentialExistAsInserterOutputSchema>;
425
- declare function credentialExistAsInserter(kwilClient: KwilActionClient, params: CredentialExistAsInserterInput): Promise<CredentialExistAsInserterOutput>;
426
+ declare function credentialExistAsInserter(kwilClient: KwilActionClient, params: CredentialExistAsInserterInput): Promise<CredentialExistAsInserterOutput | undefined>;
426
427
  declare const GetCredentialOwnedInputSchema: z.ZodObject<{
427
428
  id: z.ZodUUID;
428
429
  }>;
@@ -468,7 +469,86 @@ declare const GetSiblingCredentialIdOutputSchema: z.ZodObject<{
468
469
  id: z.ZodUUID;
469
470
  }>;
470
471
  type GetSiblingCredentialIdOutput = z.infer<typeof GetSiblingCredentialIdOutputSchema>;
471
- declare function getSiblingCredentialId(kwilClient: KwilActionClient, params: GetSiblingCredentialIdInput): Promise<GetSiblingCredentialIdOutput>;
472
+ declare function getSiblingCredentialId(kwilClient: KwilActionClient, params: GetSiblingCredentialIdInput): Promise<GetSiblingCredentialIdOutput | undefined>;
473
+ declare const GetUserAsMmOperatorInputSchema: z.ZodObject<{
474
+ storage_token: z.ZodString;
475
+ }>;
476
+ type GetUserAsMmOperatorInput = z.infer<typeof GetUserAsMmOperatorInputSchema>;
477
+ declare const GetUserAsMmOperatorOutputSchema: z.ZodObject<{
478
+ id: z.ZodUUID;
479
+ recipient_encryption_public_key: z.ZodString;
480
+ frozen: z.ZodBoolean;
481
+ }>;
482
+ type GetUserAsMmOperatorOutput = z.infer<typeof GetUserAsMmOperatorOutputSchema>;
483
+ /**
484
+ * MM OPERATOR ACTIONS
485
+ * An MM operator (see mm_operators) creates MM users, stages their ukyc:// credentials and
486
+ * freezes them for a data wipe. It only acts on the MM users it created, and every action
487
+ * also needs a valid UKYC storage token ($storage_token, the bare base64url envelope) minted
488
+ * by the user's app: the operator key alone can't do anything to an MM user. Tokens are
489
+ * verified at @block_timestamp (the last block's time in view calls).
490
+ */
491
+ declare function getUserAsMmOperator(kwilClient: KwilActionClient, params: GetUserAsMmOperatorInput): Promise<GetUserAsMmOperatorOutput[]>;
492
+ declare const CreateUserAsMmOperatorInputSchema: z.ZodObject<{
493
+ id: z.ZodUUID;
494
+ recipient_encryption_public_key: z.ZodString;
495
+ wallet_id: z.ZodUUID;
496
+ storage_token: z.ZodString;
497
+ }>;
498
+ type CreateUserAsMmOperatorInput = z.infer<typeof CreateUserAsMmOperatorInputSchema>;
499
+ /** The MM wallet key is the storage token's signing key (write token). */
500
+ declare function createUserAsMmOperator(kwilClient: KwilActionClient, params: CreateUserAsMmOperatorInput): Promise<void>;
501
+ declare const GetCredentialsAsMmOperatorInputSchema: z.ZodObject<{
502
+ user_id: z.ZodUUID;
503
+ storage_token: z.ZodString;
504
+ }>;
505
+ type GetCredentialsAsMmOperatorInput = z.infer<typeof GetCredentialsAsMmOperatorInputSchema>;
506
+ declare const GetCredentialsAsMmOperatorOutputSchema: z.ZodObject<{
507
+ id: z.ZodUUID;
508
+ user_id: z.ZodUUID;
509
+ public_notes: z.ZodString;
510
+ content_uri: z.ZodString;
511
+ content_size: z.ZodNumber;
512
+ encryptor_public_key: z.ZodString;
513
+ issuer_auth_public_key: z.ZodString;
514
+ inserter_type: z.ZodString;
515
+ inserter_id: z.ZodString;
516
+ }>;
517
+ type GetCredentialsAsMmOperatorOutput = z.infer<typeof GetCredentialsAsMmOperatorOutputSchema>;
518
+ /** Needs a read token of the user for the user's storage. */
519
+ declare function getCredentialsAsMmOperator(kwilClient: KwilActionClient, params: GetCredentialsAsMmOperatorInput): Promise<GetCredentialsAsMmOperatorOutput[]>;
520
+ declare const CreatePreliminaryCredentialAsMmOperatorInputSchema: z.ZodObject<{
521
+ request_id: z.ZodUUID;
522
+ user_id: z.ZodUUID;
523
+ credential_id: z.ZodUUID;
524
+ issuer_auth_public_key: z.ZodString;
525
+ encryptor_public_key: z.ZodString;
526
+ content_uri: z.ZodString;
527
+ content_size: z.ZodNumber;
528
+ content_hash: z.ZodString;
529
+ public_notes: z.ZodString;
530
+ public_notes_signature: z.ZodString;
531
+ broader_signature: z.ZodString;
532
+ storage_token: z.ZodString;
533
+ }>;
534
+ type CreatePreliminaryCredentialAsMmOperatorInput = z.infer<typeof CreatePreliminaryCredentialAsMmOperatorInputSchema>;
535
+ /**
536
+ * Like create_preliminary_credential, for an MM user. The issuer signs with the user's MM
537
+ * wallet public key as the recipient wallet. Needs a write token of the user; the content URI's
538
+ * storage must be the token's storage and the user's storage (the first credential defines it).
539
+ */
540
+ declare function createPreliminaryCredentialAsMmOperator(kwilClient: KwilActionClient, params: CreatePreliminaryCredentialAsMmOperatorInput): Promise<void>;
541
+ declare const RequestUserWipeAsMmOperatorInputSchema: z.ZodObject<{
542
+ user_id: z.ZodUUID;
543
+ storage_token: z.ZodString;
544
+ }>;
545
+ type RequestUserWipeAsMmOperatorInput = z.infer<typeof RequestUserWipeAsMmOperatorInputSchema>;
546
+ /**
547
+ * Freezes the MM user: no new credentials, no reads, no finalize. The gateway deletes the
548
+ * user once the UKYC storage is deleted (finalize_mm_user_wipe_as_gateway). No cancel.
549
+ * Needs a delete token of the user for the user's storage, also when already requested.
550
+ */
551
+ declare function requestUserWipeAsMmOperator(kwilClient: KwilActionClient, params: RequestUserWipeAsMmOperatorInput): Promise<void>;
472
552
  declare const AddAttributeAsInserterInputSchema: z.ZodObject<{
473
553
  id: z.ZodUUID;
474
554
  user_id: z.ZodUUID;
@@ -536,7 +616,7 @@ type DwgMessageOutput = z.infer<typeof DwgMessageOutputSchema>;
536
616
  * Will fail if not in the yyyy-mm-ddThh:mm:ssZ format, and not comply to RFC3339
537
617
  * Check the format and precedence
538
618
  */
539
- declare function dwgMessage(kwilClient: KwilActionClient, params: DwgMessageInput): Promise<DwgMessageOutput>;
619
+ declare function dwgMessage(kwilClient: KwilActionClient, params: DwgMessageInput): Promise<DwgMessageOutput | undefined>;
540
620
  declare const RevokeAccessGrantInputSchema: z.ZodObject<{
541
621
  id: z.ZodUUID;
542
622
  }>;
@@ -586,7 +666,7 @@ declare const GetAccessGrantsGrantedCountOutputSchema: z.ZodObject<{
586
666
  count: z.ZodNumber;
587
667
  }>;
588
668
  type GetAccessGrantsGrantedCountOutput = z.infer<typeof GetAccessGrantsGrantedCountOutputSchema>;
589
- declare function getAccessGrantsGrantedCount(kwilClient: KwilActionClient, params: GetAccessGrantsGrantedCountInput): Promise<GetAccessGrantsGrantedCountOutput>;
669
+ declare function getAccessGrantsGrantedCount(kwilClient: KwilActionClient, params: GetAccessGrantsGrantedCountInput): Promise<GetAccessGrantsGrantedCountOutput | undefined>;
590
670
  declare const HasLockedAccessGrantsInputSchema: z.ZodObject<{
591
671
  id: z.ZodUUID;
592
672
  }>;
@@ -595,7 +675,7 @@ declare const HasLockedAccessGrantsOutputSchema: z.ZodObject<{
595
675
  has: z.ZodBoolean;
596
676
  }>;
597
677
  type HasLockedAccessGrantsOutput = z.infer<typeof HasLockedAccessGrantsOutputSchema>;
598
- declare function hasLockedAccessGrants(kwilClient: KwilActionClient, params: HasLockedAccessGrantsInput): Promise<HasLockedAccessGrantsOutput>;
678
+ declare function hasLockedAccessGrants(kwilClient: KwilActionClient, params: HasLockedAccessGrantsInput): Promise<HasLockedAccessGrantsOutput | undefined>;
599
679
  declare const GetAccessGrantsForCredentialInputSchema: z.ZodObject<{
600
680
  credential_id: z.ZodUUID;
601
681
  }>;
@@ -624,7 +704,7 @@ type HasProfileOutput = z.infer<typeof HasProfileOutputSchema>;
624
704
  * OTHER ACTIONS
625
705
  * Should we improve it to work with near wallets too?
626
706
  */
627
- declare function hasProfile(kwilClient: KwilActionClient, params: HasProfileInput): Promise<HasProfileOutput>;
707
+ declare function hasProfile(kwilClient: KwilActionClient, params: HasProfileInput): Promise<HasProfileOutput | undefined>;
628
708
  declare const SetCallerPayerInputSchema: z.ZodObject<{
629
709
  address: z.ZodString;
630
710
  }>;
@@ -638,7 +718,7 @@ declare const CheckCallerPayerOutputSchema: z.ZodObject<{
638
718
  is_payer: z.ZodBoolean;
639
719
  }>;
640
720
  type CheckCallerPayerOutput = z.infer<typeof CheckCallerPayerOutputSchema>;
641
- declare function checkCallerPayer(kwilClient: KwilActionClient, params: CheckCallerPayerInput): Promise<CheckCallerPayerOutput>;
721
+ declare function checkCallerPayer(kwilClient: KwilActionClient, params: CheckCallerPayerInput): Promise<CheckCallerPayerOutput | undefined>;
642
722
  declare const UnsetCallerPayerInputSchema: z.ZodObject<{
643
723
  address: z.ZodString;
644
724
  }>;
@@ -653,7 +733,7 @@ declare const CheckBalanceOutputSchema: z.ZodObject<{
653
733
  balance: z.ZodNumber;
654
734
  }>;
655
735
  type CheckBalanceOutput = z.infer<typeof CheckBalanceOutputSchema>;
656
- declare function checkBalance(kwilClient: KwilActionClient, params: CheckBalanceInput): Promise<CheckBalanceOutput>;
736
+ declare function checkBalance(kwilClient: KwilActionClient, params: CheckBalanceInput): Promise<CheckBalanceOutput | undefined>;
657
737
  declare const GetWalletWithBalanceInputSchema: z.ZodObject<{
658
738
  token: z.ZodString;
659
739
  minimum_balance: z.ZodNumber;
@@ -663,7 +743,7 @@ declare const GetWalletWithBalanceOutputSchema: z.ZodObject<{
663
743
  wallet_address: z.ZodString;
664
744
  }>;
665
745
  type GetWalletWithBalanceOutput = z.infer<typeof GetWalletWithBalanceOutputSchema>;
666
- declare function getWalletWithBalance(kwilClient: KwilActionClient, params: GetWalletWithBalanceInput): Promise<GetWalletWithBalanceOutput>;
746
+ declare function getWalletWithBalance(kwilClient: KwilActionClient, params: GetWalletWithBalanceInput): Promise<GetWalletWithBalanceOutput | undefined>;
667
747
  declare const RequestWithdrawalInputSchema: z.ZodObject<{
668
748
  token: z.ZodString;
669
749
  }>;
@@ -675,7 +755,7 @@ declare const GetAllowanceOutputSchema: z.ZodObject<{
675
755
  }>;
676
756
  type GetAllowanceOutput = z.infer<typeof GetAllowanceOutputSchema>;
677
757
  /** FaceSign should not be able to call this */
678
- declare function getAllowance(kwilClient: KwilActionClient): Promise<GetAllowanceOutput>;
758
+ declare function getAllowance(kwilClient: KwilActionClient): Promise<GetAllowanceOutput | undefined>;
679
759
  declare function actionCostingGas(kwilClient: KwilActionClient): Promise<void>;
680
760
  declare const ActionCostingIdosTokenInputSchema: z.ZodObject<{
681
761
  amount: z.ZodNumber;
@@ -690,7 +770,7 @@ declare const GetIssuerFeeOutputSchema: z.ZodObject<{
690
770
  issuer_fee: z.ZodNumber;
691
771
  }>;
692
772
  type GetIssuerFeeOutput = z.infer<typeof GetIssuerFeeOutputSchema>;
693
- declare function getIssuerFee(kwilClient: KwilActionClient, params: GetIssuerFeeInput): Promise<GetIssuerFeeOutput>;
773
+ declare function getIssuerFee(kwilClient: KwilActionClient, params: GetIssuerFeeInput): Promise<GetIssuerFeeOutput | undefined>;
694
774
  declare const ActionCostingFeeInputSchema: z.ZodObject<{
695
775
  credential_id: z.ZodUUID;
696
776
  }>;
@@ -726,5 +806,5 @@ declare function removeWallets(kwilClient: KwilActionClient, ids: string[]): Pro
726
806
  declare const GET_GRANTS_DEFAULT_RECORDS_PER_PAGE = 10;
727
807
  declare function getGrants(kwilClient: KwilActionClient, params?: Partial<GetAccessGrantsGrantedInput>): Promise<idOSGrant[]>;
728
808
  //#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
809
+ export { CredentialExistAsInserterInput as $, UpdateUserPubKeyAsInserterInputSchema as $n, revokeAccessGrant as $r, GetIssuerFeeOutputSchema as $t, AddWalletMessageOutput as A, RemoveCredentialInput as An, getAllowance as Ar, GetAttributesOutput as At, CheckCallerPayerOutputSchema as B, RescindSharedCredentialInput as Bn, getUserAsInserter as Br, GetCredentialsAsMmOperatorInput as Bt, AddAttributeInputSchema as C, KwilActionClient as Ci, HasLockedAccessGrantsOutputSchema as Cn, editAttribute as Cr, GetAccessGrantsGrantedInputSchema as Ct, AddWalletInputSchema as D, KwilTxFailedError as Di, HasProfileOutputSchema as Dn, getAccessGrantsGranted as Dr, GetAccessGrantsOwnedOutputSchema as Dt, AddWalletInput as E, createWebKwilClient as Ei, HasProfileOutput as En, getAccessGrantsForCredential as Er, GetAccessGrantsOwnedOutput as Et, CheckBalanceOutput as F, RequestBalanceWithdrawalInputSchema as Fn, getCredentialsAsMmOperator as Fr, GetCredentialOwnedOutputSchema as Ft, CreatePreliminaryCredentialsByDwgInput as G, SetCallerPayerInputSchema as Gn, hasProfile as Gr, GetCredentialsOutputSchema as Gt, CreatePreliminaryCredentialAsMmOperatorInputSchema as H, RevokeAccessGrantInput as Hn, getWalletWithBalance as Hr, GetCredentialsAsMmOperatorOutput as Ht, CheckBalanceOutputSchema as I, RequestUserWipeAsMmOperatorInput as In, getCredentialsSharedByUser as Ir, GetCredentialSharedInput as It, CreateUserAsMmOperatorInputSchema as J, SharePreliminaryCredentialInput as Jn, removeWallet as Jr, GetCredentialsSharedByUserOutput as Jt, CreatePreliminaryCredentialsByDwgInputSchema as K, ShareAttributeInput as Kn, removeAttribute as Kr, GetCredentialsSharedByUserInput as Kt, CheckCallerPayerInput as L, RequestUserWipeAsMmOperatorInputSchema as Ln, getIssuerFee as Lr, GetCredentialSharedInputSchema as Lt, AddWalletType as M, RemoveWalletInput as Mn, getCredentialOwned as Mr, GetCredentialOwnedInput as Mt, CheckBalanceInput as N, RemoveWalletInputSchema as Nn, getCredentialShared as Nr, GetCredentialOwnedInputSchema as Nt, AddWalletMessageInput as O, KwilTxPollTimeoutError as Oi, RemoveAttributeInput as On, getAccessGrantsGrantedCount as Or, GetAllowanceOutput as Ot, CheckBalanceInputSchema as P, RequestBalanceWithdrawalInput as Pn, getCredentials as Pr, GetCredentialOwnedOutput as Pt, CredentialBroaderMessageOutputSchema as Q, UpdateUserPubKeyAsInserterInput as Qn, rescindSharedCredential as Qr, GetIssuerFeeOutput as Qt, CheckCallerPayerInputSchema as R, RequestWithdrawalInput as Rn, getSiblingCredentialId as Rr, GetCredentialSharedOutput as Rt, AddAttributeInput as S, createKgwAuthenticatedFetch as Si, HasLockedAccessGrantsOutput as Sn, dwgMessage as Sr, GetAccessGrantsGrantedInput as St, AddUserAsInserterInputSchema as T, createNodeKwilClient as Ti, HasProfileInputSchema as Tn, encryptionPasswordStoreSchema as Tr, GetAccessGrantsGrantedOutputSchema as Tt, CreatePreliminaryCredentialInput as U, RevokeAccessGrantInputSchema as Un, getWallets as Ur, GetCredentialsAsMmOperatorOutputSchema as Ut, CreatePreliminaryCredentialAsMmOperatorInput as V, RescindSharedCredentialInputSchema as Vn, getUserAsMmOperator as Vr, GetCredentialsAsMmOperatorInputSchema as Vt, CreatePreliminaryCredentialInputSchema as W, SetCallerPayerInput as Wn, hasLockedAccessGrants as Wr, GetCredentialsOutput as Wt, CredentialBroaderMessageInputSchema as X, UnsetCallerPayerInput as Xn, requestUserWipeAsMmOperator as Xr, GetIssuerFeeInput as Xt, CredentialBroaderMessageInput as Y, SharePreliminaryCredentialInputSchema as Yn, requestBalanceWithdrawal as Yr, GetCredentialsSharedByUserOutputSchema as Yt, CredentialBroaderMessageOutput as Z, UnsetCallerPayerInputSchema as Zn, requestWithdrawal as Zr, GetIssuerFeeInputSchema as Zt, ActionCostingIdosTokenInput as _, createServerKwilSigner as _i, GetWalletWithBalanceOutputSchema as _n, createPreliminaryCredentialAsMmOperator as _r, GetAccessGrantsForCredentialOutputSchema as _t, idOSCredential as a, upsertWalletAsInserter as ai, GetUserAsInserterInputSchema as an, actionCostingGas as ar, DwgMessageInputSchema as at, AddAttributeAsInserterInput as b, KgwAuthFailurePredicate as bi, HasLockedAccessGrantsInput as bn, credentialBroaderMessage as br, GetAccessGrantsGrantedCountOutput as bt, idOSGrant as c, implicitAddressFromPublicKey as ci, GetUserAsMmOperatorInput as cn, addAttribute as cr, ENCRYPTION_PASSWORD_STORES as ct, idOSWallet as d, KwilSigner$1 as di, GetUserAsMmOperatorOutputSchema as dn, addWallet as dr, EditPublicNotesAsIssuerInput as dt, setCallerPayer as ei, GetSiblingCredentialIdInput as en, UpsertWalletAsInserterInput as er, CredentialExistAsInserterInputSchema as et, removeWallets as f, KwilSignerType as fi, GetUserOutput as fn, addWalletMessage as fr, EditPublicNotesAsIssuerInputSchema as ft, ActionCostingFeeInputSchema as g, createClientKwilSigner as gi, GetWalletWithBalanceOutput as gn, createPreliminaryCredential as gr, GetAccessGrantsForCredentialOutput as gt, ActionCostingFeeInput as h, Wallet$2 as hi, GetWalletWithBalanceInputSchema as hn, checkCallerPayer as hr, GetAccessGrantsForCredentialInputSchema as ht, getGrants as i, updateUserPubKeyAsInserter as ii, GetUserAsInserterInput as in, actionCostingFee as ir, DwgMessageInput as it, AddWalletMessageOutputSchema as j, RemoveCredentialInputSchema as jn, getAttributes as jr, GetAttributesOutputSchema as jt, AddWalletMessageInputSchema as k, RemoveAttributeInputSchema as kn, getAccessGrantsOwned as kr, GetAllowanceOutputSchema as kt, idOSUser as l, signNearMessage as li, GetUserAsMmOperatorInputSchema as ln, addAttributeAsInserter as lr, EditAttributeInput as lt, ADD_WALLET_TYPES as m, SignerPublicKey as mi, GetWalletWithBalanceInput as mn, checkBalance as mr, GetAccessGrantsForCredentialInput as mt, GET_GRANTS_DEFAULT_RECORDS_PER_PAGE as n, sharePreliminaryCredential as ni, GetSiblingCredentialIdOutput as nn, WALLET_TYPES as nr, CredentialExistAsInserterOutputSchema as nt, idOSCredentialListItem as o, walletTypeSchema as oi, GetUserAsInserterOutput as on, actionCostingIdosToken as or, DwgMessageOutput as ot, toDelegatedWriteGrantBaseParams as p, SignerAddress as pi, GetUserOutputSchema as pn, addWalletTypeSchema as pr, EncryptionPasswordStore as pt, CreateUserAsMmOperatorInput as q, ShareAttributeInputSchema as qn, removeCredential as qr, GetCredentialsSharedByUserInputSchema as qt, addWallets as r, unsetCallerPayer as ri, GetSiblingCredentialIdOutputSchema as rn, WalletType as rr, DataType as rt, idOSDelegatedWriteGrant as s, getNearFullAccessPublicKeys as si, GetUserAsInserterOutputSchema as sn, actionSchema as sr, DwgMessageOutputSchema as st, DelegatedWriteGrantBaseParams as t, shareAttribute as ti, GetSiblingCredentialIdInputSchema as tn, UpsertWalletAsInserterInputSchema as tr, CredentialExistAsInserterOutput as tt, idOSUserAttribute as u, CustomKwilSigner as ui, GetUserAsMmOperatorOutput as un, addUserAsInserter as ur, EditAttributeInputSchema as ut, ActionCostingIdosTokenInputSchema as v, CreateKgwAuthenticatedBlobGatewayParams as vi, GetWalletsOutput as vn, createPreliminaryCredentialsByDwg as vr, GetAccessGrantsGrantedCountInput as vt, AddUserAsInserterInput as w, KwilCallError as wi, HasProfileInput as wn, editPublicNotesAsIssuer as wr, GetAccessGrantsGrantedOutput as wt, AddAttributeAsInserterInputSchema as x, createKgwAuthenticatedBlobGateway as xi, HasLockedAccessGrantsInputSchema as xn, credentialExistAsInserter as xr, GetAccessGrantsGrantedCountOutputSchema as xt, ActionSchemaElement as y, CreateKgwAuthenticatedFetchParams as yi, GetWalletsOutputSchema as yn, createUserAsMmOperator as yr, GetAccessGrantsGrantedCountInputSchema as yt, CheckCallerPayerOutput as z, RequestWithdrawalInputSchema as zn, getUser as zr, GetCredentialSharedOutputSchema as zt };
810
+ //# sourceMappingURL=index-Dc_rffi1.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dc_rffi1.d.mts","names":[],"sources":["../src/wait-for-kwil-tx.ts","../src/create-kwil-client.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;;;;;;cAO9C,sBAAsB;WAI/B;WAHO;EAET,YACE,oBACA;;;;;;cAUS;;EACX,SAAS;;;;;EAKT;WACS,QAAQ,WAAW;EAE5B,YAAY,QAAQ,WAAW;;;;EAyB/B,KAAW,aACT,QAAQ,6BACR,SAAQ,yBACP,QAAQ;;;;;;;EAsBX,QACE,QAAQ,gCACR,SAAQ,wBACR,wBACC;;;;;;;;EA8BH,UAAgB,iBAAiB;EAIjC,UAAU,QAAQ;;;;;cA6BP,uBAAuB,QAAQ,2BAA2B,QAAQ;;;;cAMlE,sBAAsB,QAAQ,2BAA2B,QAAQ;;;;;KCrLlE,2BAA2B,UAAU,aAAa;KAElD;EACV,YAAY;EACZ,QAAQ;EACR,iBAAiB;EACjB,gBAAgB;;KAGN,0CAA0C;EACpD;EACA,gBAAgB;;;;;EAKhB;;iBAQc,oCACd,KACA,eACA,gBACG,eACF,0CAA0C;iBAS7B,8BACd,YACA,QACA,SACA,iBACC,2CAA2C;;;KC3BlC,WACR,WACA,gBACA,SACA,mBACA;UAgDa,yBAAyB;EACxC;EACA;EACA;EACA;EACA,cAAc,SAAS,wBAAwB,QAAQ;;KAqB7C,iBACR,UACA,WACA,KAAK,cACL,gBACA,UACA;KAEQ;KACA;;;;;;;iBAQU,uBACpB,QAAQ,iBACP,SAAS,YA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,QAAQ,EAAE;;KAKA,8BAA8B,EAAE,aAAa;iBAEnC,uBACpB,YAAY,kBACZ,QAAQ,8BACP;cASU,yBAAyB,EAAE;EACtC,eAAe,EAAE;;KAKP,oBAAoB,EAAE,aAAa;cAElC,0BAA0B,EAAE;EACvC,YAAY,EAAE;;KAKJ,qBAAqB,EAAE,aAAa;iBAE1B,aACpB,YAAY,kBACZ,QAAQ,oBACP,QAAQ;cAUE,6BAA6B,EAAE;EAC1C,eAAe,EAAE;;KAKP,wBAAwB,EAAE,aAAa;iBAE7B,iBACpB,YAAY,kBACZ,QAAQ,wBACP;cASU,qCAAqC,EAAE;EAClD,OAAO,EAAE;EACT,gBAAgB,EAAE;;KAMR,gCAAgC,EAAE,aAAa;iBAErC,yBACpB,YAAY,kBACZ,QAAQ,gCACP;;;KCj3ES,WAAW;KACX,YAAY;KACZ,iBAAiB;KACjB,yBAAyB;KACzB,oBAAoB;KACpB,aAAa;KACb,0BAA0B;KAE1B;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGc,gCACd,QAAQ,0BACP;iBA0BmB,WACpB,YAAY,kBACZ,SAAS,mBACR;iBAImB,cAAc,YAAY,kBAAkB,gBAAgB;cAIrE;iBAES,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 { Ci as KwilActionClient, Di as KwilTxFailedError, Ei as createWebKwilClient, Oi as KwilTxPollTimeoutError, Si as createKgwAuthenticatedFetch, Ti as createNodeKwilClient, _i as createServerKwilSigner, bi as KgwAuthFailurePredicate, ci as implicitAddressFromPublicKey, di as KwilSigner, fi as KwilSignerType, gi as createClientKwilSigner, hi as Wallet, li as signNearMessage, mi as SignerPublicKey, pi as SignerAddress, si as getNearFullAccessPublicKeys, ui as CustomKwilSigner, vi as CreateKgwAuthenticatedBlobGatewayParams, wi as KwilCallError, xi as createKgwAuthenticatedBlobGateway, yi as CreateKgwAuthenticatedFetchParams } from "./index-Dc_rffi1.mjs";
2
+ export { CreateKgwAuthenticatedBlobGatewayParams, CreateKgwAuthenticatedFetchParams, CustomKwilSigner, KgwAuthFailurePredicate, KwilActionClient, KwilCallError, KwilSigner, KwilSignerType, KwilTxFailedError, KwilTxPollTimeoutError, SignerAddress, SignerPublicKey, Wallet, createClientKwilSigner, createKgwAuthenticatedBlobGateway, createKgwAuthenticatedFetch, createNodeKwilClient, createServerKwilSigner, createWebKwilClient, getNearFullAccessPublicKeys, implicitAddressFromPublicKey, 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,binaryWriteUint16BE as h,bs58Decode as g,bs58Encode as _,bytesConcat as v,hexDecode as y,hexEncode as b,utf8Decode as x}from"@idos-network/utils/codecs";import S from"tweetnacl";var C=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}},w=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 ee(e){return new Promise(t=>setTimeout(t,e))}function te(e){return Math.min(e*1.5,2e3)}function ne(e){return e+Math.floor(Math.random()*101)}function re(e){return e.height>0}async function ie(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&&re(n)){if(n.tx_result.code!==0)throw new C(t,n.tx_result.code,n.tx_result.log,n.height);return}let o=ne(i),s=r-Date.now();if(s<=0)break;await ee(Math.min(o,s)),i=te(i)}throw new w(t,n,a===void 0?void 0:{cause:a})}var T=class extends Error{actionName;name=`KwilCallError`;constructor(e,t){super(t),this.actionName=e}},E=class{signer;throwOnCallError=!1;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)},r=await this.client.call(n,t),i=r?.data?.error;if(this.throwOnCallError&&i)throw new T(e.name,i);return r?.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 ie(e=>this.client.txInfo(e),e)}setSigner(e){this.signer=e}};const D=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 E(new e({kwilProvider:t,chainId:n,timeout:3e4}))},O=D(u),k=D(d);function A({url:e,maxFetchBytes:t,accessToken:n,...r}){return new p({url:e,maxFetchBytes:t,accessToken:n,fetchFn:j(r)})}function j({kwilClient:e,signer:t,fetchFn:n=fetch,isAuthFailure:r=W}){let i=B(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 F(e,t),c=await n(...H(e,I(a),i)),l=M(c);if(!await r(l.response))return c;await N(l.discardResponses);let u=await o();return n(...H(e,I(a),u))}}function M(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 N(e){await Promise.all(e.map(P))}async function P(e){if(!e.bodyUsed&&e.body)try{await e.body.cancel()}catch{}}async function F(e,t){if(t?.body!=null)return{requestInit:t,bufferedBody:await L(t.body)};if(e instanceof Request&&e.body!=null){let n=e.clone();return{requestInit:{...t,method:t?.method??e.method},bufferedBody:await L(n.body)}}return{requestInit:t}}function I({requestInit:e,bufferedBody:t}){return t?{...e,body:z(t)}:e}async function L(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(R(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 R(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 z(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 B(e){if(!(e.client instanceof u))throw Error(`KGW authenticated fetch can only be created from a NodeKwil client`);if(!V(e.client))throw Error(`NodeKwil client does not expose KGW session cookie helpers`);return e.client}function V(e){let t=e;return typeof t.getKgwCookie==`function`&&typeof t.authenticateKGWAndSetCookie==`function`}function H(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}]}const U=new Set([`MM_TOKEN_INVALID`,`MM_TOKEN_EXPIRED`]);async function W(e){if(!e.headers.get(`content-type`)?.includes(`application/json`))return e.status===401;try{let t=await e.json();return e.status===401?!(typeof t.code==`string`&&U.has(t.code)):t.error?.code===-901}catch{return e.status===401}}const ae={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`}},G=e=>e.endsWith(`.near`)?`mainnet`:e.endsWith(`.testnet`)?`testnet`:e.endsWith(`.betanet`)?`betanet`:e.endsWith(`.shardnet`)?`shardnet`:`testnet`,K=e=>{let t=G(e),n=ae[t];return{networkId:n.networkId,nodeUrl:n.nodeUrl}},q=[`browser`,`injected`,`instant-link`,`hardware`,`bridge`];function J(e){return typeof e==`object`&&!!e&&`id`in e&&`metadata`in e&&`type`in e&&typeof e.type==`string`&&q.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 v(h(l.length),l,m(s))}}function Z(e){let t=e.replace(/^ed25519:/,``);return b(g(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=K(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 oe(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 se(){let e=oe(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 ce(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=g(s[1]),c=m(a);return o.length!==32||c.length!==64?!1:S.sign.detached.verify(i({message:e,nonce:t,recipient:n,callbackUrl:r}),c,o)}catch{return!1}}async function le(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&&ce(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 ue(e,t,n=`idos.network`){let r=await X(e,n)(t);return b(r)}async function de(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=se(),a=await le(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 fe(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 pe(e){return typeof e==`object`&&!!e&&`publicKey`in e&&e.publicKey instanceof Uint8Array&&e.publicKey.length===S.sign.publicKeyLength&&`secretKey`in e&&e.secretKey instanceof Uint8Array&&e.secretKey.length===S.sign.secretKeyLength}function $(e){return typeof e==`object`&&!!e&&`getPublicKey`in e&&`sign`in e&&typeof e.getPublicKey==`function`&&typeof e.sign==`function`}function me(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 he(e){return typeof e==`object`&&!!e&&`publicAddress`in e&&`signatureType`in e&&`publicKey`in e&&`signMessage`in e}function ge(e){return!!e&&typeof e==`object`&&`privateKey`in e&&`publicKey`in e}async function _e(e){if(pe(e))return[new l(async t=>S.sign.detached(t,e.secretKey),e.publicKey,`ed25519`),Z(_(e.publicKey))];if($(e)){let t=e.getPublicKey().toString(),n=Z(t);return[new l(r(`idos-issuer`)(e),n,`nep413`),t]}if(me(e)){let t=e.publicKey(),n=e.rawPublicKey();return[new l(async t=>e.sign(Buffer.from(t)),n,`ed25519`),t]}if(ge(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=>y(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 ve(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(J(r)){let t=await r.getAccounts(),{kwilSigner:i,publicKey:a}=await de(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 fe(r,t,e,n,i),t,i,`XRPL`]}if(he(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{E as KwilActionClient,T as KwilCallError,c as KwilSigner,C as KwilTxFailedError,w as KwilTxPollTimeoutError,ve as createClientKwilSigner,A as createKgwAuthenticatedBlobGateway,j as createKgwAuthenticatedFetch,O as createNodeKwilClient,_e as createServerKwilSigner,k as createWebKwilClient,Q as getNearFullAccessPublicKeys,Z as implicitAddressFromPublicKey,ue as signNearMessage};
2
2
  //# sourceMappingURL=index.mjs.map