@idos-network/kwil-infra 3.0.0 → 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.
- package/CHANGELOG.md +27 -0
- package/dist/actions/index.d.mts +2 -2
- package/dist/actions/index.mjs +1 -1
- package/dist/actions/index.mjs.map +1 -1
- package/dist/facesign/index.d.mts +2 -2
- package/dist/facesign/index.mjs +1 -1
- package/dist/facesign-signer-CTPPUFxT.mjs +2 -0
- package/dist/facesign-signer-CTPPUFxT.mjs.map +1 -0
- package/dist/{facesign-signer-5I8juA7p.d.mts → facesign-signer-Dqh899om.d.mts} +3 -2
- package/dist/facesign-signer-Dqh899om.d.mts.map +1 -0
- package/dist/{index-Bqz6trCk.d.mts → index-Dwonqvwu.d.mts} +33 -20
- package/dist/index-Dwonqvwu.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/nep413-D_D-6Yf6.mjs +2 -0
- package/dist/nep413-D_D-6Yf6.mjs.map +1 -0
- package/dist/signature-verification/index.d.mts +1 -1
- package/dist/signature-verification/index.mjs +1 -1
- package/dist/signature-verification/index.mjs.map +1 -1
- package/dist/xrp/utils.d.mts +41 -41
- package/dist/xrp/utils.d.mts.map +1 -1
- package/package.json +3 -3
- package/src/actions/actions.test.ts +18 -2
- package/src/actions/actions.ts +76 -19
- package/src/facesign/facesign-signer.test.ts +58 -1
- package/src/facesign/facesign-signer.ts +8 -0
- package/src/facesign/index.ts +1 -1
- package/src/mm-token/create-mm-token-kwil-signer.test.ts +0 -16
- package/src/mm-token/create-mm-token-kwil-signer.ts +0 -5
- package/src/near/create-near-wallet-kwil-signer.test.ts +218 -0
- package/src/near/create-near-wallet-kwil-signer.ts +121 -28
- package/src/near/nep413.ts +47 -37
- package/src/near/signature-verification.test.ts +35 -0
- package/src/near/signature-verification.ts +15 -36
- package/dist/facesign-signer-5I8juA7p.d.mts.map +0 -1
- package/dist/facesign-signer-z5T312uQ.mjs +0 -2
- package/dist/facesign-signer-z5T312uQ.mjs.map +0 -1
- package/dist/index-Bqz6trCk.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as FaceSignSignerProvider } from "./facesign-signer-
|
|
1
|
+
import { n as FaceSignSignerProvider } from "./facesign-signer-Dqh899om.mjs";
|
|
2
2
|
import { KwilSigner, KwilSigner as KwilSigner$1, NodeKwil, Utils, WebKwil } from "@idos-network/kwil-js";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { BlobGateway, BlobGatewayParams } from "@idos-network/utils/blob-gateway";
|
|
@@ -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<
|
|
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<
|
|
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 {
|
|
730
|
-
//# sourceMappingURL=index-
|
|
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-w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yB,EAAE,aAAa;;iBAG9B,kBACpB,YAAY,kBACZ,QAAQ,yBACP;cASU,0BAA0B,EAAE;EACvC,eAAe,EAAE;;KAKP,qBAAqB,EAAE,aAAa;;iBAG1B,aACpB,YAAY,mBACX,QAAQ;iBASW,iBAAiB,YAAY,mBAAmB;cAQzD,mCAAmC,EAAE;EAChD,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;;;KC/kES,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
|
|
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,
|
|
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-z5T312uQ.mjs";import{getXrpPublicKey as n,getXrpTxHash as r,looksLikeXrpWallet as i}from"./xrp/utils.mjs";import{KwilSigner as a,KwilSigner as o,NodeKwil as s,WebKwil as c}from"@idos-network/kwil-js";import l from"tiny-invariant";import{BlobGateway as u,createUkycContentUri as d}from"@idos-network/utils/blob-gateway";import{base64Decode as f,base64UrlDecode as p,base64UrlEncode as m,binaryWriteUint16BE as h,borshSerialize as g,bs58Decode as ee,bs58Encode as _,bytesConcat as v,hexDecode as y,hexEncode as b,sha256Hash as te,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 D(e){return Math.min(e*1.5,2e3)}function O(e){return e+Math.floor(Math.random()*101)}function ne(e){return e.height>0}async function re(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&&ne(n)){if(n.tx_result.code!==0)throw new w(t,n.tx_result.code,n.tx_result.log,n.height);return}let o=O(i),s=r-Date.now();if(s<=0)break;await E(Math.min(o,s)),i=D(i)}throw new T(t,n,a===void 0?void 0:{cause:a})}var k=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){l(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 re(e=>this.client.txInfo(e),e)}setSigner(e){this.signer=e}};const A=e=>async({nodeUrl:t,chainId:n})=>{let r=new e({kwilProvider:t,chainId:``});return n||=(await r.chainInfo({disableWarning:!0})).data?.chain_id,l(n,"Can't discover `chainId`. You must pass it explicitly."),new k(new e({kwilProvider:t,chainId:n,timeout:3e4}))},ie=A(s),ae=A(c);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 d(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(x(e))}catch(e){throw Error(t,{cause:e})}}function I(e,t){try{return p(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=m(S(JSON.stringify(n)))}let r=S(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 s=I(a,`Invalid mm_token signing_public_key encoding`);if(s.length!==32)throw Error(`Invalid mm_token signing_public_key length: expected 32, got ${s.length}`);let c=Object.assign(new o(async()=>r.slice(),s,`mm_token`),{mmTokenPayload:n.payload});return Object.defineProperty(c,"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 u({url:e,maxFetchBytes:t,accessToken:i?.accessToken,fetchFn:z(r)})}function z({kwilClient:e,signer:t,fetchFn:n=fetch,isAuthFailure:r=se}){let i=J(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(...Y(e,W(a),i)),l=B(c);if(!await r(l.response))return c;await V(l.discardResponses);let u=await o();return n(...Y(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 J(e){if(!(e.client instanceof s))throw Error(`KGW authenticated fetch can only be created from a NodeKwil client`);if(!oe(e.client))throw Error(`NodeKwil client does not expose KGW session cookie helpers`);return e.client}function oe(e){let t=e;return typeof t.getKgwCookie==`function`&&typeof t.authenticateKGWAndSetCookie==`function`}function Y(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 X=class{bytes;constructor(e=32){this.bytes=crypto.getRandomValues(new Uint8Array(e))}get clampUTF8(){return this.bytes.map(e=>e&127)}};function Z(e,t){return async n=>{let r=typeof n==`string`?n:x(n);if(!e.signMessage)throw Error(`Only wallets with signMessage are supported.`);let i=Buffer.from(new X(32).bytes),{nonce:a=i,signature:o,callbackUrl:s}=await e.signMessage({message:r,recipient:t,nonce:i}),c={struct:{tag:`u32`,message:`string`,nonce:{array:{type:`u8`,len:32}},recipient:`string`,callbackUrl:{option:`string`}}},l={tag:2147484061,message:r,nonce:Array.from(a),recipient:t,callbackUrl:s},u=g(c,l);return v(h(u.length),u,f(o))}}function Q(e){let t=e.replace(/^ed25519:/,``);return b(ee(t),!0)}async function pe(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}}async function me(e,t,n=`idos.network`){let r=await Z(e,n)(t);return b(r)}async function he(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{accountId:r,signature:i,publicKey:a,error:o}=Object.fromEntries(new URLSearchParams(window.location.hash.slice(1)).entries());i&&(await n.set(`signer-address`,r),await n.set(`signer-public-key`,a));let s=e.signMessage.bind(e);e.signMessage=async({message:e,recipient:r})=>{if(o)return Promise.reject();let c=await n.get(`sign-last-message`),l=await n.get(`sign-last-nonce`);if(i&&e===c&&l){let r=Buffer.from(l),o=await n.get(`sign-last-url`);return Promise.resolve({accountId:t,publicKey:a,signature:i,nonce:r,message:e,callbackUrl:o})}let u=window.location.href,d=Buffer.from(new X(32).clampUTF8);return await n.set(`sign-last-message`,e),await n.set(`sign-last-nonce`,Array.from(d)),await n.set(`sign-last-url`,u),s({message:e,nonce:d,recipient:r,callbackUrl:u}),new Promise(()=>({}))}}let a=await n.get(`signer-address`),s=await n.get(`signer-public-key`);if(a!==t||!s){n.reset(),await r.client.auth.logoutKGW();let a=Buffer.from(new X(32).bytes),o=await e.signMessage({message:`idOS authentication`,recipient:i,nonce:a});if(!o)throw Error(`signMessage returned no result`);({publicKey:s}=o),await n.set(`signer-address`,t),await n.set(`signer-public-key`,s)}let c=Z(e,i);return{kwilSigner:new o(c,Q(s),`nep413`),publicKey:s}}function ge(e){return t=>async n=>{let r=x(n),i=crypto.getRandomValues(new Uint8Array(32)),a={struct:{message:`string`,nonce:{array:{type:`u8`,len:32}},recipient:`string`,callbackUrl:{option:`string`}}},o=2147484061,{signature:s}=t.sign(te(v(g(`u32`,o),g(a,{message:r,nonce:i,recipient:e})))),c={struct:{tag:`u32`,...a.struct}},l=g(c,{tag:o,message:r,nonce:i,recipient:e});return v(h(l.length),l,s)}}async function $(e,t,n,i,a){let s=await n.get(`signer-address`),c=await n.get(`signer-public-key`);if(s!==t||c&&c!==a)try{console.log(`logoutKGW`,i)}catch(e){console.error(`Failed to logout KGW:`,e)}return await n.set(`signer-address`,t),await n.set(`signer-public-key`,a),new o(async t=>{let n=await r(t,e);if(!n||!/^(?:[0-9a-f]{2})+$/i.test(n))throw Error(`Failed to sign transaction with XRP`);return Buffer.from(n,`hex`)},a,`xrpl`)}function _e(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 ve(e){return typeof e==`object`&&!!e&&`getPublicKey`in e&&`sign`in e&&typeof e.getPublicKey==`function`&&typeof e.sign==`function`}function ye(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 be(e){return typeof e==`object`&&!!e&&`publicAddress`in e&&`signatureType`in e&&`publicKey`in e&&`signMessage`in e}function xe(e){return!!e&&typeof e==`object`&&`privateKey`in e&&`publicKey`in e}async function Se(e){if(j(e))return[e,m(e.identifier)];if(_e(e))return[new o(async t=>C.sign.detached(t,e.secretKey),e.publicKey,`ed25519`),Q(_(e.publicKey))];if(ve(e)){let t=e.getPublicKey().toString(),n=Q(t);return[new o(ge(`idos-issuer`)(e),n,`nep413`),t]}if(ye(e)){let t=e.publicKey(),n=e.rawPublicKey();return[new o(async t=>e.sign(Buffer.from(t)),n,`ed25519`),t]}if(xe(e)){let t;try{t=await import(`ripple-keypairs`)}catch(e){throw Error(`Can't load ripple-keypairs`,{cause:e})}return[new o(async n=>y(t.sign(b(n),e.privateKey)),e.publicKey,`xrpl`),e.publicKey]}return`address`in e?[new o(e,e.address),e.address]:(e=>{throw Error("Invalid `signer` type")})(e)}async function Ce(e,r,a){if(`connect`in a&&`address`in a){a=a;let t=await a.getAddress();if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await r.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new o(a,t),t,void 0,`EVM`]}if(fe(a)){let t=await a.getAccounts(),{kwilSigner:n,publicKey:i}=await he(a,t[0].accountId,e,r);return[n,t[0].accountId,i,`NEAR`]}if(i(a)){let{address:t,publicKey:i}=await n(a);if(!t)throw Error(`Failed to get XRP address`);return[await $(a,t,e,r,i),t,i,`XRPL`]}if(j(a)){let t=m(a.identifier);if(await e.get(`signer-address`)!==t){e.set(`signer-address`,t);try{await r.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[a,t,t,`MM`]}if(be(a)||a instanceof t){if(await e.get(`signer-address`)!==a.publicAddress){e.set(`signer-address`,a.publicAddress);try{await r.client.auth.logoutKGW()}catch(e){console.log(`error logoutKGW`,e)}}return[new o(async e=>a.signMessage(e),a.publicAddress,`ed25519`),a.publicAddress,a.publicKey,a.walletType]}return(e=>{throw Error("Invalid `signer` type")})(a)}export{k as KwilActionClient,a as KwilSigner,w as KwilTxFailedError,T as KwilTxPollTimeoutError,Ce as createClientKwilSigner,R as createKgwAuthenticatedBlobGateway,z as createKgwAuthenticatedFetch,L as createMmTokenAuth,ie as createNodeKwilClient,Se as createServerKwilSigner,ae as createWebKwilClient,pe as getNearFullAccessPublicKeys,Q as implicitAddressFromPublicKey,j as isMmTokenAuth,N as mmTokenCredentialContentUri,M as mmTokenStorageId,me 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
|