@swype-org/react-sdk 0.1.228 → 0.1.229
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/dist/index.cjs +41 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +41 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -446,11 +446,16 @@ interface GuestBalanceOption extends SourceOption {
|
|
|
446
446
|
* GET /v1/transfers/:id/balances?walletAddress=...
|
|
447
447
|
*/
|
|
448
448
|
declare function fetchGuestTransferBalances(apiBaseUrl: string, transferId: string, guestSessionToken: string, walletAddress: string): Promise<GuestBalanceOption[]>;
|
|
449
|
-
declare function
|
|
449
|
+
declare function fetchGuestAccount(apiBaseUrl: string, guestToken: string): Promise<{
|
|
450
450
|
accountId: string;
|
|
451
451
|
hasPasskey: boolean;
|
|
452
452
|
walletAddress: string | null;
|
|
453
453
|
} | null>;
|
|
454
|
+
declare function createGuestAccount(apiBaseUrl: string, guestSessionToken: string, providerId: string, name: string): Promise<{
|
|
455
|
+
accountId: string;
|
|
456
|
+
sessionToken: string;
|
|
457
|
+
sessionUri: string;
|
|
458
|
+
}>;
|
|
454
459
|
declare function setAccountOwner(apiBaseUrl: string, accessToken: string, accountId: string, guestSessionToken: string, body: {
|
|
455
460
|
credentialId: string;
|
|
456
461
|
publicKey: string;
|
|
@@ -467,13 +472,14 @@ type api_GuestBalanceOption = GuestBalanceOption;
|
|
|
467
472
|
type api_GuestTransferResult = GuestTransferResult;
|
|
468
473
|
declare const api_createAccount: typeof createAccount;
|
|
469
474
|
declare const api_createAccountAuthorizationSession: typeof createAccountAuthorizationSession;
|
|
475
|
+
declare const api_createGuestAccount: typeof createGuestAccount;
|
|
470
476
|
declare const api_createGuestTransfer: typeof createGuestTransfer;
|
|
471
477
|
declare const api_createTransfer: typeof createTransfer;
|
|
472
478
|
declare const api_fetchAccount: typeof fetchAccount;
|
|
473
479
|
declare const api_fetchAccounts: typeof fetchAccounts;
|
|
474
480
|
declare const api_fetchAuthorizationSession: typeof fetchAuthorizationSession;
|
|
475
481
|
declare const api_fetchChains: typeof fetchChains;
|
|
476
|
-
declare const
|
|
482
|
+
declare const api_fetchGuestAccount: typeof fetchGuestAccount;
|
|
477
483
|
declare const api_fetchGuestTransferBalances: typeof fetchGuestTransferBalances;
|
|
478
484
|
declare const api_fetchMerchantPublicKey: typeof fetchMerchantPublicKey;
|
|
479
485
|
declare const api_fetchProviders: typeof fetchProviders;
|
|
@@ -491,7 +497,7 @@ declare const api_signTransfer: typeof signTransfer;
|
|
|
491
497
|
declare const api_updateUserConfig: typeof updateUserConfig;
|
|
492
498
|
declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
|
|
493
499
|
declare namespace api {
|
|
494
|
-
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains,
|
|
500
|
+
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestAccount as createGuestAccount, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestAccount as fetchGuestAccount, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setAccountOwner as setAccountOwner, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
495
501
|
}
|
|
496
502
|
|
|
497
503
|
interface BlinkPaymentProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -446,11 +446,16 @@ interface GuestBalanceOption extends SourceOption {
|
|
|
446
446
|
* GET /v1/transfers/:id/balances?walletAddress=...
|
|
447
447
|
*/
|
|
448
448
|
declare function fetchGuestTransferBalances(apiBaseUrl: string, transferId: string, guestSessionToken: string, walletAddress: string): Promise<GuestBalanceOption[]>;
|
|
449
|
-
declare function
|
|
449
|
+
declare function fetchGuestAccount(apiBaseUrl: string, guestToken: string): Promise<{
|
|
450
450
|
accountId: string;
|
|
451
451
|
hasPasskey: boolean;
|
|
452
452
|
walletAddress: string | null;
|
|
453
453
|
} | null>;
|
|
454
|
+
declare function createGuestAccount(apiBaseUrl: string, guestSessionToken: string, providerId: string, name: string): Promise<{
|
|
455
|
+
accountId: string;
|
|
456
|
+
sessionToken: string;
|
|
457
|
+
sessionUri: string;
|
|
458
|
+
}>;
|
|
454
459
|
declare function setAccountOwner(apiBaseUrl: string, accessToken: string, accountId: string, guestSessionToken: string, body: {
|
|
455
460
|
credentialId: string;
|
|
456
461
|
publicKey: string;
|
|
@@ -467,13 +472,14 @@ type api_GuestBalanceOption = GuestBalanceOption;
|
|
|
467
472
|
type api_GuestTransferResult = GuestTransferResult;
|
|
468
473
|
declare const api_createAccount: typeof createAccount;
|
|
469
474
|
declare const api_createAccountAuthorizationSession: typeof createAccountAuthorizationSession;
|
|
475
|
+
declare const api_createGuestAccount: typeof createGuestAccount;
|
|
470
476
|
declare const api_createGuestTransfer: typeof createGuestTransfer;
|
|
471
477
|
declare const api_createTransfer: typeof createTransfer;
|
|
472
478
|
declare const api_fetchAccount: typeof fetchAccount;
|
|
473
479
|
declare const api_fetchAccounts: typeof fetchAccounts;
|
|
474
480
|
declare const api_fetchAuthorizationSession: typeof fetchAuthorizationSession;
|
|
475
481
|
declare const api_fetchChains: typeof fetchChains;
|
|
476
|
-
declare const
|
|
482
|
+
declare const api_fetchGuestAccount: typeof fetchGuestAccount;
|
|
477
483
|
declare const api_fetchGuestTransferBalances: typeof fetchGuestTransferBalances;
|
|
478
484
|
declare const api_fetchMerchantPublicKey: typeof fetchMerchantPublicKey;
|
|
479
485
|
declare const api_fetchProviders: typeof fetchProviders;
|
|
@@ -491,7 +497,7 @@ declare const api_signTransfer: typeof signTransfer;
|
|
|
491
497
|
declare const api_updateUserConfig: typeof updateUserConfig;
|
|
492
498
|
declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
|
|
493
499
|
declare namespace api {
|
|
494
|
-
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains,
|
|
500
|
+
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestAccount as createGuestAccount, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestAccount as fetchGuestAccount, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setAccountOwner as setAccountOwner, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
495
501
|
}
|
|
496
502
|
|
|
497
503
|
interface BlinkPaymentProps {
|
package/dist/index.js
CHANGED
|
@@ -458,13 +458,14 @@ var api_exports = {};
|
|
|
458
458
|
__export(api_exports, {
|
|
459
459
|
createAccount: () => createAccount,
|
|
460
460
|
createAccountAuthorizationSession: () => createAccountAuthorizationSession,
|
|
461
|
+
createGuestAccount: () => createGuestAccount,
|
|
461
462
|
createGuestTransfer: () => createGuestTransfer,
|
|
462
463
|
createTransfer: () => createTransfer,
|
|
463
464
|
fetchAccount: () => fetchAccount,
|
|
464
465
|
fetchAccounts: () => fetchAccounts,
|
|
465
466
|
fetchAuthorizationSession: () => fetchAuthorizationSession,
|
|
466
467
|
fetchChains: () => fetchChains,
|
|
467
|
-
|
|
468
|
+
fetchGuestAccount: () => fetchGuestAccount,
|
|
468
469
|
fetchGuestTransferBalances: () => fetchGuestTransferBalances,
|
|
469
470
|
fetchMerchantPublicKey: () => fetchMerchantPublicKey,
|
|
470
471
|
fetchProviders: () => fetchProviders,
|
|
@@ -766,13 +767,25 @@ async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionTo
|
|
|
766
767
|
const data = await res.json();
|
|
767
768
|
return data.items;
|
|
768
769
|
}
|
|
769
|
-
async function
|
|
770
|
+
async function fetchGuestAccount(apiBaseUrl, guestToken) {
|
|
770
771
|
const params = new URLSearchParams({ guestToken });
|
|
771
|
-
const res = await fetch(`${apiBaseUrl}/v1/
|
|
772
|
+
const res = await fetch(`${apiBaseUrl}/v1/accounts?${params.toString()}`);
|
|
772
773
|
if (res.status === 404) return null;
|
|
773
774
|
if (!res.ok) await throwApiError(res);
|
|
774
775
|
return await res.json();
|
|
775
776
|
}
|
|
777
|
+
async function createGuestAccount(apiBaseUrl, guestSessionToken, providerId, name) {
|
|
778
|
+
const res = await fetch(`${apiBaseUrl}/v1/accounts`, {
|
|
779
|
+
method: "POST",
|
|
780
|
+
headers: {
|
|
781
|
+
"Content-Type": "application/json",
|
|
782
|
+
"x-guest-session-token": guestSessionToken
|
|
783
|
+
},
|
|
784
|
+
body: JSON.stringify({ providerId, name })
|
|
785
|
+
});
|
|
786
|
+
if (!res.ok) await throwApiError(res);
|
|
787
|
+
return await res.json();
|
|
788
|
+
}
|
|
776
789
|
async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
|
|
777
790
|
const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
|
|
778
791
|
method: "PUT",
|
|
@@ -2210,7 +2223,8 @@ function paymentReducer(state, action) {
|
|
|
2210
2223
|
...state,
|
|
2211
2224
|
guestPreauthAccountId: null,
|
|
2212
2225
|
activePublicKey: null,
|
|
2213
|
-
error: null
|
|
2226
|
+
error: null,
|
|
2227
|
+
userIntent: "configure-one-tap"
|
|
2214
2228
|
};
|
|
2215
2229
|
// ── User intent & error ──────────────────────────────────────
|
|
2216
2230
|
case "SET_USER_INTENT":
|
|
@@ -8242,21 +8256,40 @@ function usePaymentEffects(deps) {
|
|
|
8242
8256
|
if (state.guestPreauthAccountId) return;
|
|
8243
8257
|
if (!state.transfer || state.transfer.status !== "COMPLETED") return;
|
|
8244
8258
|
let cancelled = false;
|
|
8245
|
-
const
|
|
8259
|
+
const ensureGuestAccount = async () => {
|
|
8246
8260
|
try {
|
|
8247
|
-
|
|
8261
|
+
let result = await fetchGuestAccount(apiBaseUrl, state.guestSessionToken);
|
|
8248
8262
|
if (cancelled) return;
|
|
8263
|
+
if (!result && state.selectedProviderId) {
|
|
8264
|
+
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? "Wallet";
|
|
8265
|
+
const created = await createGuestAccount(
|
|
8266
|
+
apiBaseUrl,
|
|
8267
|
+
state.guestSessionToken,
|
|
8268
|
+
state.selectedProviderId,
|
|
8269
|
+
providerName
|
|
8270
|
+
);
|
|
8271
|
+
if (cancelled) return;
|
|
8272
|
+
result = { accountId: created.accountId, hasPasskey: false, walletAddress: null };
|
|
8273
|
+
}
|
|
8249
8274
|
if (result && !result.hasPasskey) {
|
|
8250
8275
|
dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: result.accountId });
|
|
8251
8276
|
}
|
|
8252
8277
|
} catch {
|
|
8253
8278
|
}
|
|
8254
8279
|
};
|
|
8255
|
-
|
|
8280
|
+
ensureGuestAccount();
|
|
8256
8281
|
return () => {
|
|
8257
8282
|
cancelled = true;
|
|
8258
8283
|
};
|
|
8259
|
-
}, [
|
|
8284
|
+
}, [
|
|
8285
|
+
state.transfer,
|
|
8286
|
+
state.guestSessionToken,
|
|
8287
|
+
state.guestPreauthAccountId,
|
|
8288
|
+
state.selectedProviderId,
|
|
8289
|
+
state.providers,
|
|
8290
|
+
apiBaseUrl,
|
|
8291
|
+
dispatch
|
|
8292
|
+
]);
|
|
8260
8293
|
const settingOwnerRef = useRef(false);
|
|
8261
8294
|
useEffect(() => {
|
|
8262
8295
|
if (!state.guestPreauthAccountId) return;
|