Socket
Socket
Sign inDemoInstall

@web3modal/wallet

Package Overview
Dependencies
Maintainers
11
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3modal/wallet - npm Package Compare versions

Comparing version 3.6.0-33e0d8ea to 3.6.0-36d0a6c

5

dist/esm/src/W3mFrameConstants.js

@@ -22,2 +22,3 @@ export const W3mFrameConstants = {

APP_AWAIT_UPDATE_EMAIL: '@w3m-app/AWAIT_UPDATE_EMAIL',
APP_SYNC_THEME: '@w3m-app/SYNC_THEME',
FRAME_SWITCH_NETWORK_ERROR: '@w3m-frame/SWITCH_NETWORK_ERROR',

@@ -45,4 +46,6 @@ FRAME_SWITCH_NETWORK_SUCCESS: '@w3m-frame/SWITCH_NETWORK_SUCCESS',

FRAME_AWAIT_UPDATE_EMAIL_SUCCESS: '@w3m-frame/AWAIT_UPDATE_EMAIL_SUCCESS',
FRAME_AWAIT_UPDATE_EMAIL_ERROR: '@w3m-frame/AWAIT_UPDATE_EMAIL_ERROR'
FRAME_AWAIT_UPDATE_EMAIL_ERROR: '@w3m-frame/AWAIT_UPDATE_EMAIL_ERROR',
FRAME_SYNC_THEME_SUCCESS: '@w3m-frame/SYNC_THEME_SUCCESS',
FRAME_SYNC_THEME_ERROR: '@w3m-frame/SYNC_THEME_ERROR'
};
//# sourceMappingURL=W3mFrameConstants.js.map

15

dist/esm/src/W3mFrameHelpers.js

@@ -15,2 +15,3 @@ import { W3mFrameStorage } from './W3mFrameStorage.js';

];
const EMAIL_MINIMUM_TIMEOUT = 30 * 1000;
export const W3mFrameHelpers = {

@@ -33,9 +34,19 @@ getBlockchainApiUrl() {

const difference = Date.now() - Number(lastEmailLoginTime);
if (difference < 30000) {
const cooldownSec = Math.ceil((30000 - difference) / 1000);
if (difference < EMAIL_MINIMUM_TIMEOUT) {
const cooldownSec = Math.ceil((EMAIL_MINIMUM_TIMEOUT - difference) / 1000);
throw new Error(`Please try again after ${cooldownSec} seconds`);
}
}
},
getTimeToNextEmailLogin() {
const lastEmailLoginTime = W3mFrameStorage.get(W3mFrameConstants.LAST_EMAIL_LOGIN_TIME);
if (lastEmailLoginTime) {
const difference = Date.now() - Number(lastEmailLoginTime);
if (difference < EMAIL_MINIMUM_TIMEOUT) {
return Math.ceil((EMAIL_MINIMUM_TIMEOUT - difference) / 1000);
}
}
return 0;
}
};
//# sourceMappingURL=W3mFrameHelpers.js.map

@@ -17,2 +17,4 @@ import { W3mFrame } from './W3mFrame.js';

this.updateEmailResolver = undefined;
this.awaitUpdateEmailResolver = undefined;
this.syncThemeResolver = undefined;
this.w3mFrame = new W3mFrame(projectId, true);

@@ -64,2 +66,10 @@ this.w3mFrame.events.onFrameEvent(event => {

return this.onUpdateEmailError(event);
case W3mFrameConstants.FRAME_AWAIT_UPDATE_EMAIL_SUCCESS:
return this.onAwaitUpdateEmailSuccess(event);
case W3mFrameConstants.FRAME_AWAIT_UPDATE_EMAIL_ERROR:
return this.onAwaitUpdateEmailError(event);
case W3mFrameConstants.FRAME_SYNC_THEME_SUCCESS:
return this.onSyncThemeSuccess();
case W3mFrameConstants.FRAME_SYNC_THEME_ERROR:
return this.onSyncThemeError(event);
default:

@@ -123,2 +133,16 @@ return null;

}
async awaitUpdateEmail() {
await this.w3mFrame.frameLoadPromise;
this.w3mFrame.events.postAppEvent({ type: W3mFrameConstants.APP_AWAIT_UPDATE_EMAIL });
return new Promise((resolve, reject) => {
this.awaitUpdateEmailResolver = { resolve, reject };
});
}
async syncTheme(payload) {
await this.w3mFrame.frameLoadPromise;
this.w3mFrame.events.postAppEvent({ type: W3mFrameConstants.APP_SYNC_THEME, payload });
return new Promise((resolve, reject) => {
this.syncThemeResolver = { resolve, reject };
});
}
async connect(payload) {

@@ -199,5 +223,3 @@ await this.w3mFrame.frameLoadPromise;

onConnectSuccess(event) {
W3mFrameStorage.set(W3mFrameConstants.EMAIL, event.payload.email);
W3mFrameStorage.set(W3mFrameConstants.EMAIL_LOGIN_USED_KEY, 'true');
W3mFrameStorage.delete(W3mFrameConstants.LAST_EMAIL_LOGIN_TIME);
this.setEmailLoginSuccess(event.payload.email);
this.connectResolver?.resolve(event.payload);

@@ -252,6 +274,24 @@ }

}
onAwaitUpdateEmailSuccess(event) {
this.setEmailLoginSuccess(event.payload.email);
this.awaitUpdateEmailResolver?.resolve(event.payload);
}
onAwaitUpdateEmailError(event) {
this.awaitUpdateEmailResolver?.reject(event.payload.message);
}
onSyncThemeSuccess() {
this.syncThemeResolver?.resolve(undefined);
}
onSyncThemeError(event) {
this.syncThemeResolver?.reject(event.payload.message);
}
setNewLastEmailLoginTime() {
W3mFrameStorage.set(W3mFrameConstants.LAST_EMAIL_LOGIN_TIME, Date.now().toString());
}
setEmailLoginSuccess(email) {
W3mFrameStorage.set(W3mFrameConstants.EMAIL, email);
W3mFrameStorage.set(W3mFrameConstants.EMAIL_LOGIN_USED_KEY, 'true');
W3mFrameStorage.delete(W3mFrameConstants.LAST_EMAIL_LOGIN_TIME);
}
}
//# sourceMappingURL=W3mFrameProvider.js.map

@@ -12,2 +12,6 @@ import { z } from 'zod';

export const AppUpdateEmailRequest = z.object({ email: z.string().email() });
export const AppSyncThemeRequest = z.object({
themeMode: z.optional(z.enum(['light', 'dark'])),
themeVariables: z.optional(z.record(z.string(), z.string().or(z.number())))
});
export const FrameConnectEmailResponse = z.object({

@@ -51,2 +55,8 @@ action: z.enum(['VERIFY_DEVICE', 'VERIFY_OTP'])

});
export const RpcEthBlockNumber = z.object({
method: z.literal('eth_blockNumber')
});
export const RpcEthChainId = z.object({
method: z.literal('eth_chainId')
});
export const FrameSession = z.object({

@@ -73,5 +83,8 @@ token: z.string()

.or(RpcEthSignTypedDataV4)
.or(RpcEthBlockNumber)
.or(RpcEthChainId)
}))
.or(z.object({ type: zType('APP_UPDATE_EMAIL'), payload: AppUpdateEmailRequest }))
.or(z.object({ type: zType('APP_AWAIT_UPDATE_EMAIL') })),
.or(z.object({ type: zType('APP_AWAIT_UPDATE_EMAIL') }))
.or(z.object({ type: zType('APP_SYNC_THEME'), payload: AppSyncThemeRequest })),
frameEvent: z

@@ -104,3 +117,5 @@ .object({ type: zType('FRAME_SWITCH_NETWORK_ERROR'), payload: zError })

}))
.or(z.object({ type: zType('FRAME_SYNC_THEME_ERROR'), payload: zError }))
.or(z.object({ type: zType('FRAME_SYNC_THEME_SUCCESS') }))
};
//# sourceMappingURL=W3mFrameSchema.js.map
import { z } from 'zod';
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcGetBalance, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameAwaitUpdateEmailResponse } from './W3mFrameSchema.js';
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcGetBalance, RpcEthBlockNumber, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameAwaitUpdateEmailResponse, AppSyncThemeRequest, RpcEthChainId } from './W3mFrameSchema.js';
//# sourceMappingURL=W3mFrameTypes.js.map

@@ -22,2 +22,3 @@ export declare const W3mFrameConstants: {

readonly APP_AWAIT_UPDATE_EMAIL: "@w3m-app/AWAIT_UPDATE_EMAIL";
readonly APP_SYNC_THEME: "@w3m-app/SYNC_THEME";
readonly FRAME_SWITCH_NETWORK_ERROR: "@w3m-frame/SWITCH_NETWORK_ERROR";

@@ -46,2 +47,4 @@ readonly FRAME_SWITCH_NETWORK_SUCCESS: "@w3m-frame/SWITCH_NETWORK_SUCCESS";

readonly FRAME_AWAIT_UPDATE_EMAIL_ERROR: "@w3m-frame/AWAIT_UPDATE_EMAIL_ERROR";
readonly FRAME_SYNC_THEME_SUCCESS: "@w3m-frame/SYNC_THEME_SUCCESS";
readonly FRAME_SYNC_THEME_ERROR: "@w3m-frame/SYNC_THEME_ERROR";
};
export declare const W3mFrameHelpers: {
getBlockchainApiUrl(): false | "https://rpc.walletconnect.org" | "https://rpc.walletconnect.com";
checkIfAllowedToTriggerEmail(): void;
getTimeToNextEmailLogin(): number;
};

@@ -14,2 +14,4 @@ import type { W3mFrameTypes } from './W3mFrameTypes.js';

private updateEmailResolver;
private awaitUpdateEmailResolver;
private syncThemeResolver;
constructor(projectId: string);

@@ -30,2 +32,6 @@ getLoginEmailUsed(): boolean;

updateEmail(payload: W3mFrameTypes.Requests['AppUpdateEmailRequest']): Promise<unknown>;
awaitUpdateEmail(): Promise<{
email: string;
}>;
syncTheme(payload: W3mFrameTypes.Requests['AppSyncThemeRequest']): Promise<unknown>;
connect(payload?: W3mFrameTypes.Requests['AppGetUserRequest']): Promise<{

@@ -63,3 +69,8 @@ chainId: number;

private onUpdateEmailError;
private onAwaitUpdateEmailSuccess;
private onAwaitUpdateEmailError;
private onSyncThemeSuccess;
private onSyncThemeError;
private setNewLastEmailLoginTime;
private setEmailLoginSuccess;
}

@@ -37,2 +37,12 @@ import { z } from 'zod';

}>;
export declare const AppSyncThemeRequest: z.ZodObject<{
themeMode: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
themeVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
}, "strip", z.ZodTypeAny, {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
}, {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
}>;
export declare const FrameConnectEmailResponse: z.ZodObject<{

@@ -144,2 +154,16 @@ action: z.ZodEnum<["VERIFY_DEVICE", "VERIFY_OTP"]>;

}>;
export declare const RpcEthBlockNumber: z.ZodObject<{
method: z.ZodLiteral<"eth_blockNumber">;
}, "strip", z.ZodTypeAny, {
method: "eth_blockNumber";
}, {
method: "eth_blockNumber";
}>;
export declare const RpcEthChainId: z.ZodObject<{
method: z.ZodLiteral<"eth_chainId">;
}, "strip", z.ZodTypeAny, {
method: "eth_chainId";
}, {
method: "eth_chainId";
}>;
export declare const FrameSession: z.ZodObject<{

@@ -153,3 +177,3 @@ token: z.ZodString;

export declare const W3mFrameSchema: {
appEvent: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
appEvent: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
type: z.ZodLiteral<"@w3m-app/SWITCH_NETWORK">;

@@ -269,3 +293,3 @@ payload: z.ZodObject<{

type: z.ZodLiteral<"@w3m-app/RPC_REQUEST">;
payload: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
payload: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
method: z.ZodLiteral<"personal_sign">;

@@ -327,2 +351,14 @@ params: z.ZodArray<z.ZodAny, "many">;

method: "eth_signTypedData_v4";
}>]>, z.ZodObject<{
method: z.ZodLiteral<"eth_blockNumber">;
}, "strip", z.ZodTypeAny, {
method: "eth_blockNumber";
}, {
method: "eth_blockNumber";
}>]>, z.ZodObject<{
method: z.ZodLiteral<"eth_chainId">;
}, "strip", z.ZodTypeAny, {
method: "eth_chainId";
}, {
method: "eth_chainId";
}>]>;

@@ -350,2 +386,6 @@ }, "strip", z.ZodTypeAny, {

method: "eth_signTypedData_v4";
} | {
method: "eth_blockNumber";
} | {
method: "eth_chainId";
};

@@ -373,2 +413,6 @@ }, {

method: "eth_signTypedData_v4";
} | {
method: "eth_blockNumber";
} | {
method: "eth_chainId";
};

@@ -400,4 +444,28 @@ }>]>, z.ZodObject<{

type: "@w3m-app/AWAIT_UPDATE_EMAIL";
}>]>, z.ZodObject<{
type: z.ZodLiteral<"@w3m-app/SYNC_THEME">;
payload: z.ZodObject<{
themeMode: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
themeVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
}, "strip", z.ZodTypeAny, {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
}, {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
}>;
}, "strip", z.ZodTypeAny, {
type: "@w3m-app/SYNC_THEME";
payload: {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
};
}, {
type: "@w3m-app/SYNC_THEME";
payload: {
themeMode?: "light" | "dark" | undefined;
themeVariables?: Record<string, string | number> | undefined;
};
}>]>;
frameEvent: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
frameEvent: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
type: z.ZodLiteral<"@w3m-frame/SWITCH_NETWORK_ERROR">;

@@ -774,3 +842,28 @@ payload: z.ZodObject<{

};
}>]>, z.ZodObject<{
type: z.ZodLiteral<"@w3m-frame/SYNC_THEME_ERROR">;
payload: z.ZodObject<{
message: z.ZodString;
}, "strip", z.ZodTypeAny, {
message: string;
}, {
message: string;
}>;
}, "strip", z.ZodTypeAny, {
type: "@w3m-frame/SYNC_THEME_ERROR";
payload: {
message: string;
};
}, {
type: "@w3m-frame/SYNC_THEME_ERROR";
payload: {
message: string;
};
}>]>, z.ZodObject<{
type: z.ZodLiteral<"@w3m-frame/SYNC_THEME_SUCCESS">;
}, "strip", z.ZodTypeAny, {
type: "@w3m-frame/SYNC_THEME_SUCCESS";
}, {
type: "@w3m-frame/SYNC_THEME_SUCCESS";
}>]>;
};
import { z } from 'zod';
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcGetBalance, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameAwaitUpdateEmailResponse } from './W3mFrameSchema.js';
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcGetBalance, RpcEthBlockNumber, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameAwaitUpdateEmailResponse, AppSyncThemeRequest, RpcEthChainId } from './W3mFrameSchema.js';
export declare namespace W3mFrameTypes {

@@ -12,2 +12,3 @@ type AppEvent = z.infer<typeof W3mFrameSchema.appEvent>;

AppUpdateEmailRequest: z.infer<typeof AppUpdateEmailRequest>;
AppSyncThemeRequest: z.infer<typeof AppSyncThemeRequest>;
}

@@ -25,5 +26,5 @@ interface Responses {

}
type RPCRequest = z.infer<typeof RpcPersonalSignRequest> | z.infer<typeof RpcEthSendTransactionRequest> | z.infer<typeof RpcEthSignTypedDataV4> | z.infer<typeof RpcEthAccountsRequest> | z.infer<typeof RpcEthEstimateGas> | z.infer<typeof RpcEthGasPrice> | z.infer<typeof RpcGetBalance>;
type RPCRequest = z.infer<typeof RpcPersonalSignRequest> | z.infer<typeof RpcEthSendTransactionRequest> | z.infer<typeof RpcEthSignTypedDataV4> | z.infer<typeof RpcEthAccountsRequest> | z.infer<typeof RpcEthEstimateGas> | z.infer<typeof RpcEthGasPrice> | z.infer<typeof RpcGetBalance> | z.infer<typeof RpcEthBlockNumber> | z.infer<typeof RpcEthChainId>;
type RPCResponse = z.infer<typeof RpcResponse>;
type FrameSessionType = z.infer<typeof FrameSession>;
}
{
"name": "@web3modal/wallet",
"version": "3.6.0-33e0d8ea",
"version": "3.6.0-36d0a6c",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/esm/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc