Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onekeyfe/cross-inpage-provider-core

Package Overview
Dependencies
Maintainers
2
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onekeyfe/cross-inpage-provider-core - npm Package Compare versions

Comparing version 1.1.58-alpha.2 to 1.1.58

dist/cjs/loggerConsole.js

3

dist/cjs/consts.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WALLET_INFO_LOACAL_KEY_V5 = exports.WALLET_INFO_LOACAL_KEY = exports.DEBUG_LOGGER_STORAGE_KEY = exports.EXT_PORT_UI_TO_BG = exports.EXT_PORT_CS_TO_BG = exports.EXT_PORT_OFFSCREEN_TO_BG = exports.JS_BRIDGE_MESSAGE_DIRECTION = exports.JS_BRIDGE_MESSAGE_EXT_PING = exports.JS_BRIDGE_MESSAGE_EXT_CHANNEL = exports.JS_BRIDGE_MESSAGE_IPC_CHANNEL = void 0;
exports.WALLET_INFO_LOACAL_KEY = exports.DEBUG_LOGGER_STORAGE_KEY = exports.EXT_PORT_UI_TO_BG = exports.EXT_PORT_CS_TO_BG = exports.EXT_PORT_OFFSCREEN_TO_BG = exports.JS_BRIDGE_MESSAGE_DIRECTION = exports.JS_BRIDGE_MESSAGE_EXT_PING = exports.JS_BRIDGE_MESSAGE_EXT_CHANNEL = exports.JS_BRIDGE_MESSAGE_IPC_CHANNEL = void 0;
exports.JS_BRIDGE_MESSAGE_IPC_CHANNEL = 'onekey@JS_BRIDGE_MESSAGE_IPC_CHANNEL';

@@ -16,2 +16,1 @@ exports.JS_BRIDGE_MESSAGE_EXT_CHANNEL = 'onekey@JS_BRIDGE_MESSAGE_EXT_CHANNEL';

exports.WALLET_INFO_LOACAL_KEY = 'onekey_wallet_info_local_key';
exports.WALLET_INFO_LOACAL_KEY_V5 = "onekey_wallet_info_local_key_v5";

@@ -21,3 +21,3 @@ "use strict";

const consts_1 = require("../consts");
const lodash_1 = require("lodash");
const lodash_es_1 = require("lodash-es");
const ms_1 = __importDefault(require("ms"));

@@ -227,3 +227,3 @@ const storageKey = consts_1.DEBUG_LOGGER_STORAGE_KEY;

else {
if ((0, lodash_1.isNil)(namespaces)) {
if ((0, lodash_es_1.isNil)(namespaces)) {
yield exportsBrowser.storage.removeItem(storageKey);

@@ -230,0 +230,0 @@ }

@@ -32,2 +32,3 @@ "use strict";

__exportStar(require("./loggers"), exports);
__exportStar(require("./loggerConsole"), exports);
__exportStar(require("./injectJsBridge"), exports);

@@ -39,3 +40,2 @@ __exportStar(require("./injectedProviderReceiveHandler"), exports);

__exportStar(require("./walletProperty"), exports);
__exportStar(require("./notification"), exports);
const consts = __importStar(require("./consts"));

@@ -42,0 +42,0 @@ exports.consts = consts;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectJsBridge = void 0;
const consts_1 = require("./consts");
const loggerConsole_1 = require("./loggerConsole");
// function fixGlobalShim() {

@@ -14,4 +14,4 @@ // // FIX errors in ReactNative

function injectJsBridge(bridgeCreator) {
// remove fixGlobalShim,
// because fixGlobalShim make some website not work properly
// remove fixGlobalShim,
// because fixGlobalShim make some website not work properly
// make cloudfare dead loop and make zhihu.com search functionally down

@@ -23,5 +23,3 @@ // fixGlobalShim();

window.$onekey.jsBridge = bridgeCreator();
if (typeof localStorage !== 'undefined' && localStorage.getItem(consts_1.DEBUG_LOGGER_STORAGE_KEY)) {
console.log('===== jsBridge injected success! >>>>> ', performance.now());
}
loggerConsole_1.commonLogger.debug('JsBridge injected success!', performance.now());
}

@@ -28,0 +26,0 @@ return window.$onekey.jsBridge;

@@ -17,4 +17,3 @@ "use strict";

/* eslint-disable @typescript-eslint/ban-ts-comment */
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
const isString_1 = __importDefault(require("lodash/isString"));
const lodash_es_1 = require("lodash-es");
const CrossEventEmitter_1 = require("./CrossEventEmitter");

@@ -265,6 +264,6 @@ const loggers_1 = require("./loggers");

};
if ((0, isPlainObject_1.default)(payloadReceived)) {
if ((0, lodash_es_1.isPlainObject)(payloadReceived)) {
payload = payloadReceived;
}
if ((0, isString_1.default)(payloadReceived)) {
if ((0, lodash_es_1.isString)(payloadReceived)) {
try {

@@ -271,0 +270,0 @@ payload = JSON.parse(payloadReceived);

@@ -17,3 +17,3 @@ "use strict";

/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/ban-ts-comment */
const isFunction_1 = __importDefault(require("lodash/isFunction"));
const lodash_es_1 = require("lodash-es");
const CrossEventEmitter_1 = require("./CrossEventEmitter");

@@ -99,3 +99,3 @@ const siteMetadata_1 = __importDefault(require("./siteMetadata"));

try {
localStorage.setItem(consts_1.WALLET_INFO_LOACAL_KEY_V5, JSON.stringify(result.walletInfo));
localStorage.setItem(consts_1.WALLET_INFO_LOACAL_KEY, JSON.stringify(result.walletInfo));
}

@@ -129,3 +129,3 @@ catch (e) {

let hasCallback = false;
if (callback && (0, isFunction_1.default)(callback)) {
if (callback && (0, lodash_es_1.isFunction)(callback)) {
hasCallback = true;

@@ -132,0 +132,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const version = '1.1.58-alpha.2';
const version = '1.1.58';
const versionBuild = '2020-0101-1';

@@ -5,0 +5,0 @@ exports.default = {

"use strict";
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

@@ -8,2 +7,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */

const consts_1 = require("./consts");
const loggerConsole_1 = require("./loggerConsole");
/**

@@ -21,26 +21,16 @@ * An enumeration mapping specific blockchain provider names to their corresponding blockchain identifiers.

})(ISpecialPropertyProviderNamesReflection = exports.ISpecialPropertyProviderNamesReflection || (exports.ISpecialPropertyProviderNamesReflection = {}));
function checkWalletSwitchEnable() {
function checkWalletSwitchEnable(property) {
try {
const walletInfoLocalStr = localStorage.getItem(consts_1.WALLET_INFO_LOACAL_KEY_V5);
const walletInfoLocalStr = localStorage.getItem(consts_1.WALLET_INFO_LOACAL_KEY);
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
if (!(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.isDefaultWallet)) {
if (process.env.NODE_ENV !== 'production') {
console.log('OneKey is not default wallet');
}
return false;
if (walletInfoLocal && walletInfoLocal.walletSwitchConfig) {
const { enable, disable } = walletInfoLocal.walletSwitchConfig;
const enableList = enable || [];
const disableList = disable || [];
return ((enableList.includes(property) && !disableList.includes(property)) ||
(!enableList.includes(property) && !disableList.includes(property)));
}
if (Array.isArray(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.excludedDappList)) {
const currentOrigin = window.location.origin;
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (walletInfoLocal.excludedDappList.includes(currentOrigin)) {
if (process.env.NODE_ENV !== 'production') {
console.log('skip inject web3 provider: ', currentOrigin);
}
return false;
}
}
return true;
}
catch (e) {
console.error(e);
loggerConsole_1.commonLogger.warn(e);
}

@@ -54,3 +44,3 @@ return true;

try {
const walletInfoLocalStr = localStorage.getItem(consts_1.WALLET_INFO_LOACAL_KEY_V5);
const walletInfoLocalStr = localStorage.getItem(consts_1.WALLET_INFO_LOACAL_KEY);
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;

@@ -60,3 +50,3 @@ return !!(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.platformEnv.isExtension);

catch (e) {
console.error(e);
loggerConsole_1.commonLogger.warn(e);
}

@@ -68,3 +58,3 @@ return false;

var _a;
if (!checkWalletSwitchEnable())
if (!checkWalletSwitchEnable(property))
return;

@@ -100,3 +90,3 @@ const enable = checkEnableDefineProperty(property);

catch (ex) {
console.error(ex);
loggerConsole_1.commonLogger.error(ex);
try {

@@ -106,3 +96,3 @@ window[property] = provider;

catch (error) {
console.error(error);
loggerConsole_1.commonLogger.warn(error);
}

@@ -109,0 +99,0 @@ }

@@ -13,2 +13,1 @@ export declare const JS_BRIDGE_MESSAGE_IPC_CHANNEL = "onekey@JS_BRIDGE_MESSAGE_IPC_CHANNEL";

export declare const WALLET_INFO_LOACAL_KEY = "onekey_wallet_info_local_key";
export declare const WALLET_INFO_LOACAL_KEY_V5 = "onekey_wallet_info_local_key_v5";

@@ -13,2 +13,1 @@ export const JS_BRIDGE_MESSAGE_IPC_CHANNEL = 'onekey@JS_BRIDGE_MESSAGE_IPC_CHANNEL';

export const WALLET_INFO_LOACAL_KEY = 'onekey_wallet_info_local_key';
export const WALLET_INFO_LOACAL_KEY_V5 = "onekey_wallet_info_local_key_v5";

@@ -16,3 +16,3 @@ /* eslint-disable */

import { DEBUG_LOGGER_STORAGE_KEY } from '../consts';
import { isNil } from 'lodash';
import { isNil } from 'lodash-es';
import humanize from 'ms';

@@ -19,0 +19,0 @@ const storageKey = DEBUG_LOGGER_STORAGE_KEY;

export * from './JsBridgeBase';
export * from './ProviderBase';
export * from './loggers';
export * from './loggerConsole';
export * from './injectJsBridge';

@@ -10,3 +11,2 @@ export * from './injectedProviderReceiveHandler';

export * from './walletProperty';
export * from './notification';
import * as consts from './consts';

@@ -13,0 +13,0 @@ export { consts };

export * from './JsBridgeBase';
export * from './ProviderBase';
export * from './loggers';
export * from './loggerConsole';
export * from './injectJsBridge';

@@ -10,3 +11,2 @@ export * from './injectedProviderReceiveHandler';

export * from './walletProperty';
export * from './notification';
import * as consts from './consts';

@@ -13,0 +13,0 @@ export { consts };

@@ -1,2 +0,2 @@

import { DEBUG_LOGGER_STORAGE_KEY } from './consts';
import { commonLogger } from './loggerConsole';
// function fixGlobalShim() {

@@ -11,4 +11,4 @@ // // FIX errors in ReactNative

function injectJsBridge(bridgeCreator) {
// remove fixGlobalShim,
// because fixGlobalShim make some website not work properly
// remove fixGlobalShim,
// because fixGlobalShim make some website not work properly
// make cloudfare dead loop and make zhihu.com search functionally down

@@ -20,5 +20,3 @@ // fixGlobalShim();

window.$onekey.jsBridge = bridgeCreator();
if (typeof localStorage !== 'undefined' && localStorage.getItem(DEBUG_LOGGER_STORAGE_KEY)) {
console.log('===== jsBridge injected success! >>>>> ', performance.now());
}
commonLogger.debug('JsBridge injected success!', performance.now());
}

@@ -25,0 +23,0 @@ return window.$onekey.jsBridge;

@@ -11,4 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

/* eslint-disable @typescript-eslint/ban-ts-comment */
import isPlainObject from 'lodash/isPlainObject';
import isString from 'lodash/isString';
import { isPlainObject, isString } from 'lodash-es';
import { CrossEventEmitter } from './CrossEventEmitter';

@@ -15,0 +14,0 @@ import { appDebugLogger, consoleErrorInDev } from './loggers';

@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/ban-ts-comment */
import isFunction from 'lodash/isFunction';
import { isFunction } from 'lodash-es';
import { CrossEventEmitter } from './CrossEventEmitter';

@@ -17,3 +17,3 @@ import siteMetadata from './siteMetadata';

import versionInfo from './versionInfo';
import { WALLET_INFO_LOACAL_KEY_V5 } from './consts';
import { WALLET_INFO_LOACAL_KEY } from './consts';
const METHODS = {

@@ -94,3 +94,3 @@ wallet_getConnectWalletInfo: 'wallet_getConnectWalletInfo',

try {
localStorage.setItem(WALLET_INFO_LOACAL_KEY_V5, JSON.stringify(result.walletInfo));
localStorage.setItem(WALLET_INFO_LOACAL_KEY, JSON.stringify(result.walletInfo));
}

@@ -97,0 +97,0 @@ catch (e) {

@@ -1,2 +0,2 @@

const version = '1.1.58-alpha.2';
const version = '1.1.58';
const versionBuild = '2020-0101-1';

@@ -3,0 +3,0 @@ export default {

@@ -12,3 +12,3 @@ /**

}
export declare function checkWalletSwitchEnable(): boolean;
export declare function checkWalletSwitchEnable(property: string): boolean;
export declare function checkEnableDefineProperty(property: string): boolean;

@@ -15,0 +15,0 @@ export declare function defineWindowProperty(property: string, provider: unknown, options?: {

@@ -1,5 +0,5 @@

/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { WALLET_INFO_LOACAL_KEY_V5 } from './consts';
import { WALLET_INFO_LOACAL_KEY } from './consts';
import { commonLogger } from './loggerConsole';
/**

@@ -17,26 +17,16 @@ * An enumeration mapping specific blockchain provider names to their corresponding blockchain identifiers.

})(ISpecialPropertyProviderNamesReflection || (ISpecialPropertyProviderNamesReflection = {}));
export function checkWalletSwitchEnable() {
export function checkWalletSwitchEnable(property) {
try {
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY_V5);
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
if (!(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.isDefaultWallet)) {
if (process.env.NODE_ENV !== 'production') {
console.log('OneKey is not default wallet');
}
return false;
if (walletInfoLocal && walletInfoLocal.walletSwitchConfig) {
const { enable, disable } = walletInfoLocal.walletSwitchConfig;
const enableList = enable || [];
const disableList = disable || [];
return ((enableList.includes(property) && !disableList.includes(property)) ||
(!enableList.includes(property) && !disableList.includes(property)));
}
if (Array.isArray(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.excludedDappList)) {
const currentOrigin = window.location.origin;
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (walletInfoLocal.excludedDappList.includes(currentOrigin)) {
if (process.env.NODE_ENV !== 'production') {
console.log('skip inject web3 provider: ', currentOrigin);
}
return false;
}
}
return true;
}
catch (e) {
console.error(e);
commonLogger.warn(e);
}

@@ -49,3 +39,3 @@ return true;

try {
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY_V5);
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;

@@ -55,3 +45,3 @@ return !!(walletInfoLocal === null || walletInfoLocal === void 0 ? void 0 : walletInfoLocal.platformEnv.isExtension);

catch (e) {
console.error(e);
commonLogger.warn(e);
}

@@ -62,3 +52,3 @@ return false;

var _a;
if (!checkWalletSwitchEnable())
if (!checkWalletSwitchEnable(property))
return;

@@ -94,3 +84,3 @@ const enable = checkEnableDefineProperty(property);

catch (ex) {
console.error(ex);
commonLogger.error(ex);
try {

@@ -100,5 +90,5 @@ window[property] = provider;

catch (error) {
console.error(error);
commonLogger.warn(error);
}
}
}
{
"name": "@onekeyfe/cross-inpage-provider-core",
"version": "1.1.58-alpha.2",
"version": "1.1.58",
"keywords": [

@@ -32,10 +32,13 @@ "cross-inpage-provider"

"dependencies": {
"@onekeyfe/cross-inpage-provider-errors": "1.1.58-alpha.2",
"@onekeyfe/cross-inpage-provider-events": "1.1.58-alpha.2",
"@onekeyfe/cross-inpage-provider-types": "1.1.58-alpha.2",
"@onekeyfe/cross-inpage-provider-errors": "1.1.58",
"@onekeyfe/cross-inpage-provider-events": "1.1.58",
"@onekeyfe/cross-inpage-provider-types": "1.1.58",
"events": "^3.3.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"ms": "^2.1.3"
},
"gitHead": "5e2426bfdaeec2bbb77248dc4518ce7cd4ad5dcf"
"devDependencies": {
"@types/lodash-es": "^4.17.12"
},
"gitHead": "975b254f7617940021ff9848163c1e1c84947d6c"
}
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