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

@magic-sdk/provider

Package Overview
Dependencies
Maintainers
10
Versions
717
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magic-sdk/provider - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

# v4.3.0 (Tue May 04 2021)
#### 🚀 Enhancement
- Add test-mode prefix to Ethereum RPC methods [#181](https://github.com/magiclabs/magic-js/pull/181) ([@smithki](https://github.com/smithki))
#### Authors: 1
- Ian K Smith ([@smithki](https://github.com/smithki))
---
# v4.2.0 (Mon Mar 15 2021)

@@ -2,0 +14,0 @@

20

dist/commonjs/modules/rpc-provider.d.ts
import { JsonRpcRequestPayload, JsonRpcRequestCallback, JsonRpcBatchRequestCallback, JsonRpcResponsePayload } from '@magic-sdk/types';
import { BaseModule } from './base-module';
import { PromiEvent } from '../util/promise-tools';
import { TypedEmitter } from '../util/events';
import { EventsDefinition, TypedEmitter } from '../util/events';
/** */

@@ -19,2 +19,20 @@ export declare class RPCProviderModule extends BaseModule implements TypedEmitter {

}>;
/**
* Here, we wrap `BaseModule.request` with an additional check
* to determine if the RPC method requires a test-mode prefix.
*/
protected request<ResultType = any, Events extends EventsDefinition = void>(payload: Partial<JsonRpcRequestPayload>): PromiEvent<ResultType, Events extends void ? {
done: (result: ResultType) => void;
error: (reason: any) => void;
settled: () => void;
} : Events & {
done: (result: ResultType) => void;
error: (reason: any) => void;
settled: () => void;
}>;
/**
* Prefixes Ethereum RPC methods with a `testMode` identifier. This is done so
* that Magic's <iframe> can handle signing methods using test-specific keys.
*/
private prefixPayloadMethodForTestMode;
on: (event: string | symbol, fn: (...args: any[]) => void, context?: any) => this;

@@ -21,0 +39,0 @@ once: (event: string | symbol, fn: (...args: any[]) => void, context?: any) => this;

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

RPCProviderModule.prototype.sendAsync = function (payload, onRequestComplete) {
var _this = this;
if (!onRequestComplete) {

@@ -44,3 +45,7 @@ throw sdk_exceptions_1.createInvalidArgumentError({

this.transport
.post(this.overlay, types_1.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, payload.map(function (p) { return json_rpc_1.standardizeJsonRpcRequestPayload(p); }))
.post(this.overlay, types_1.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, payload.map(function (p) {
var standardizedPayload = json_rpc_1.standardizeJsonRpcRequestPayload(p);
_this.prefixPayloadMethodForTestMode(standardizedPayload);
return standardizedPayload;
}))
.then(function (batchResponse) {

@@ -52,2 +57,3 @@ onRequestComplete(null, batchResponse.map(function (response) { return (tslib_1.__assign(tslib_1.__assign({}, response.payload), { error: response.hasError ? new sdk_exceptions_1.MagicRPCError(response.payload.error) : null })); }));

var finalPayload = json_rpc_1.standardizeJsonRpcRequestPayload(payload);
this.prefixPayloadMethodForTestMode(finalPayload);
this.transport

@@ -88,2 +94,23 @@ .post(this.overlay, types_1.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, finalPayload)

};
/**
* Here, we wrap `BaseModule.request` with an additional check
* to determine if the RPC method requires a test-mode prefix.
*/
RPCProviderModule.prototype.request = function (payload) {
this.prefixPayloadMethodForTestMode(payload);
return _super.prototype.request.call(this, payload);
};
/**
* Prefixes Ethereum RPC methods with a `testMode` identifier. This is done so
* that Magic's <iframe> can handle signing methods using test-specific keys.
*/
RPCProviderModule.prototype.prefixPayloadMethodForTestMode = function (payload) {
var testModePrefix = 'testMode/eth/';
// In test mode, we prefix all RPC methods with `test/` so that the
// Magic <iframe> can handle them without requiring network calls.
if (this.sdk.testMode) {
// eslint-disable-next-line no-param-reassign
payload.method = "" + testModePrefix + payload.method;
}
};
return RPCProviderModule;

@@ -90,0 +117,0 @@ }(base_module_1.BaseModule));

import { JsonRpcRequestPayload, JsonRpcRequestCallback, JsonRpcBatchRequestCallback, JsonRpcResponsePayload } from '@magic-sdk/types';
import { BaseModule } from './base-module';
import { PromiEvent } from '../util/promise-tools';
import { TypedEmitter } from '../util/events';
import { EventsDefinition, TypedEmitter } from '../util/events';
/** */

@@ -19,2 +19,20 @@ export declare class RPCProviderModule extends BaseModule implements TypedEmitter {

}>;
/**
* Here, we wrap `BaseModule.request` with an additional check
* to determine if the RPC method requires a test-mode prefix.
*/
protected request<ResultType = any, Events extends EventsDefinition = void>(payload: Partial<JsonRpcRequestPayload>): PromiEvent<ResultType, Events extends void ? {
done: (result: ResultType) => void;
error: (reason: any) => void;
settled: () => void;
} : Events & {
done: (result: ResultType) => void;
error: (reason: any) => void;
settled: () => void;
}>;
/**
* Prefixes Ethereum RPC methods with a `testMode` identifier. This is done so
* that Magic's <iframe> can handle signing methods using test-specific keys.
*/
private prefixPayloadMethodForTestMode;
on: (event: string | symbol, fn: (...args: any[]) => void, context?: any) => this;

@@ -21,0 +39,0 @@ once: (event: string | symbol, fn: (...args: any[]) => void, context?: any) => this;

@@ -31,2 +31,3 @@ /* eslint-disable consistent-return, prefer-spread */

RPCProviderModule.prototype.sendAsync = function (payload, onRequestComplete) {
var _this = this;
if (!onRequestComplete) {

@@ -42,3 +43,7 @@ throw createInvalidArgumentError({

this.transport
.post(this.overlay, MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, payload.map(function (p) { return standardizeJsonRpcRequestPayload(p); }))
.post(this.overlay, MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, payload.map(function (p) {
var standardizedPayload = standardizeJsonRpcRequestPayload(p);
_this.prefixPayloadMethodForTestMode(standardizedPayload);
return standardizedPayload;
}))
.then(function (batchResponse) {

@@ -50,2 +55,3 @@ onRequestComplete(null, batchResponse.map(function (response) { return (__assign(__assign({}, response.payload), { error: response.hasError ? new MagicRPCError(response.payload.error) : null })); }));

var finalPayload = standardizeJsonRpcRequestPayload(payload);
this.prefixPayloadMethodForTestMode(finalPayload);
this.transport

@@ -86,2 +92,23 @@ .post(this.overlay, MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST, finalPayload)

};
/**
* Here, we wrap `BaseModule.request` with an additional check
* to determine if the RPC method requires a test-mode prefix.
*/
RPCProviderModule.prototype.request = function (payload) {
this.prefixPayloadMethodForTestMode(payload);
return _super.prototype.request.call(this, payload);
};
/**
* Prefixes Ethereum RPC methods with a `testMode` identifier. This is done so
* that Magic's <iframe> can handle signing methods using test-specific keys.
*/
RPCProviderModule.prototype.prefixPayloadMethodForTestMode = function (payload) {
var testModePrefix = 'testMode/eth/';
// In test mode, we prefix all RPC methods with `test/` so that the
// Magic <iframe> can handle them without requiring network calls.
if (this.sdk.testMode) {
// eslint-disable-next-line no-param-reassign
payload.method = "" + testModePrefix + payload.method;
}
};
return RPCProviderModule;

@@ -88,0 +115,0 @@ }(BaseModule));

4

package.json
{
"name": "@magic-sdk/provider",
"version": "4.2.1",
"version": "4.3.0",
"description": "Core business logic for Magic SDK packages.",

@@ -61,3 +61,3 @@ "author": "Magic Labs <team@magic.link> (https://magic.link/)",

},
"gitHead": "cbb3017091f25bcc236063edc7d8bac601a0134e"
"gitHead": "020523d25bd9ea0c81778eb801c8e36c9dde088a"
}

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