Socket
Socket
Sign inDemoInstall

@metamask/ppom-validator

Package Overview
Dependencies
Maintainers
10
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/ppom-validator - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

7

CHANGELOG.md

@@ -9,2 +9,6 @@ # Changelog

## [0.5.0]
### Changed
- Fix the check for ethereum mainnet and add hex prefix to chainId ([#48](https://github.com/MetaMask/ppom-validator/pull/48))
## [0.4.0]

@@ -49,3 +53,4 @@ ### Changed

[Unreleased]: https://github.com/MetaMask/ppom-validator/compare/v0.4.0...HEAD
[Unreleased]: https://github.com/MetaMask/ppom-validator/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/MetaMask/ppom-validator/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/MetaMask/ppom-validator/compare/v0.3.0...v0.4.0

@@ -52,0 +57,0 @@ [0.3.0]: https://github.com/MetaMask/ppom-validator/compare/v0.2.0...v0.3.0

40

dist/ppom-controller.js

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

_PPOMController_blockaidPublicKey.set(this, void 0);
__classPrivateFieldSet(this, _PPOMController_chainId, chainId, "f");
__classPrivateFieldSet(this, _PPOMController_chainId, (0, util_1.addHexPrefix)(chainId), "f");
__classPrivateFieldSet(this, _PPOMController_provider, provider, "f");

@@ -200,3 +200,3 @@ __classPrivateFieldSet(this, _PPOMController_ppomProvider, ppomProvider, "f");

}
if (!__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_includesEthereumMainnet).call(this)) {
if (__classPrivateFieldGet(this, _PPOMController_chainId, "f") !== ETHEREUM_CHAIN_ID) {
throw Error('Blockaid validation is available only on ethereum mainnet');

@@ -221,3 +221,3 @@ }

}, _PPOMController_onNetworkChange = function _PPOMController_onNetworkChange(networkControllerState) {
const id = networkControllerState.providerConfig.chainId;
const id = (0, util_1.addHexPrefix)(networkControllerState.providerConfig.chainId);
if (id === __classPrivateFieldGet(this, _PPOMController_chainId, "f")) {

@@ -232,2 +232,3 @@ return;

[id]: {
chainId: id,
lastVisited: new Date().getTime(),

@@ -426,20 +427,19 @@ dataFetched: existingNetworkObject?.dataFetched ?? false,

const fileToBeFetched = fileToBeFetchedList.pop();
if (!fileToBeFetched) {
return;
if (fileToBeFetched) {
const { chainStatus } = this.state;
const { fileVersionInfo, isLastFileOfNetwork } = fileToBeFetched;
// check here if chain is present in chainStatus, it may be removed from chainStatus
// if more than 5 networks are added to it.
if (chainStatus[fileVersionInfo.chainId]) {
// get the file from CDN
__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_getFile).call(this, fileVersionInfo)
.then(() => {
if (isLastFileOfNetwork) {
// if this was last file for the chainId set dataFetched for chainId to true
__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_setChainIdDataFetched).call(this, fileVersionInfo.chainId);
}
})
.catch((exp) => console.error(`Error in getting file ${fileVersionInfo.filePath}: ${exp.message}`));
}
}
const { chainStatus } = this.state;
const { fileVersionInfo, isLastFileOfNetwork } = fileToBeFetched;
// check here if chain is present in chainStatus, it may be removed from chainStatus
// if more than 5 networks are added to it.
if (chainStatus[fileVersionInfo.chainId]) {
// get the file from CDN
__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_getFile).call(this, fileVersionInfo)
.then(() => {
if (isLastFileOfNetwork) {
// if this was last file for the chainId set dataFetched for chainId to true
__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_setChainIdDataFetched).call(this, fileVersionInfo.chainId);
}
})
.catch((exp) => console.error(`Error in getting file ${fileVersionInfo.filePath}: ${exp.message}`));
}
// clear interval if all files are fetched

@@ -446,0 +446,0 @@ if (!fileToBeFetchedList.length) {

@@ -28,1 +28,2 @@ export declare const IdGenerator: () => number;

export declare const constructURLHref: (base: string, path: string) => string;
export declare const addHexPrefix: (str: string) => string;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.constructURLHref = exports.validateSignature = exports.PROVIDER_ERRORS = exports.createPayload = exports.IdGenerator = void 0;
exports.addHexPrefix = exports.constructURLHref = exports.validateSignature = exports.PROVIDER_ERRORS = exports.createPayload = exports.IdGenerator = void 0;
const elliptic_1 = __importDefault(require("elliptic"));

@@ -52,2 +52,12 @@ const json_rpc_random_id_1 = __importDefault(require("json-rpc-random-id"));

exports.constructURLHref = constructURLHref;
const addHexPrefix = (str) => {
if (typeof str !== 'string' || str.match(/^-?0x/u)) {
return str;
}
if (str.match(/^-?0X/u)) {
return str.replace('0X', '0x');
}
return `0x${str}`;
};
exports.addHexPrefix = addHexPrefix;
//# sourceMappingURL=util.js.map
{
"name": "@metamask/ppom-validator",
"version": "0.4.0",
"version": "0.5.0",
"description": "This module has code to integrate Blockaid PPOM with MetaMask",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/MetaMask/ppom-validator#readme",

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