Socket
Socket
Sign inDemoInstall

@ramp-network/ramp-instant-sdk

Package Overview
Dependencies
Maintainers
4
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ramp-network/ramp-instant-sdk - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

dist/lib/consts.js

52

dist/lib/ramp-instant-sdk.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var knownFieldNames = [
'swapAsset',
'swapAmount',
'userAddress',
'hostLogoUrl',
'hostAppName'
];
function initUrl(config) {
var baseUrl = new URL(config.url || 'http://localhost:8080/');
var sanitizedConfig = sanitizeConfig(config, knownFieldNames).sanitizedConfig;
Object.entries(sanitizedConfig).forEach(function (_a) {
var key = _a[0], value = _a[1];
baseUrl.searchParams.append(key, value);
});
return baseUrl.toString();
}
function initDOMNode(url) {
var body = document.querySelector('body');
var iframe = document.createElement('iframe');
iframe.setAttribute('src', url);
iframe.setAttribute('width', '1500');
iframe.setAttribute('height', '1000');
return {
body: body,
iframe: iframe
};
}
var consts_1 = require("./consts");
var event_handler_1 = require("./event-handler");
var init_helpers_1 = require("./init-helpers");
function initialize(config) {
var url = initUrl(config);
var _a = initDOMNode(url), body = _a.body, iframe = _a.iframe;
var url = init_helpers_1.initUrl(config);
var _a = init_helpers_1.initDOMNode(url), body = _a.body, iframe = _a.iframe;
init_helpers_1.listenForEvents(config.url || consts_1.baseWidgetUrl, event_handler_1.createWidgetEventHandler(iframe));
return {

@@ -44,19 +21,2 @@ show: function () {

exports.initialize = initialize;
function sanitizeConfig(config, whitelistedKeys) {
var rejectedKeys = [];
var sanitizedConfig = Object.entries(config).reduce(function (config, _a) {
var key = _a[0], value = _a[1];
if (whitelistedKeys.includes(key)) {
config[key] = value;
}
else {
rejectedKeys.push(key);
}
return config;
}, {});
return {
rejectedKeys: rejectedKeys,
sanitizedConfig: sanitizedConfig
};
}
//# sourceMappingURL=ramp-instant-sdk.js.map

@@ -1,14 +0,61 @@

var knownFieldNames = [
'swapAsset',
'swapAmount',
'userAddress',
'hostLogoUrl',
'hostAppName'
];
var baseWidgetUrl = 'http://localhost:8080';
//# sourceMappingURL=consts.js.map
function createWidgetEventHandler(iframeNode) {
return function handleWidgetEvents(event) {
switch (event.type) {
case 'WIDGET_CLOSE': {
iframeNode.parentNode.removeChild(iframeNode);
}
}
};
}
//# sourceMappingURL=event-handler.js.map
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
function initUrl(config) {
var baseUrl = new URL(config.url || 'http://localhost:8080/');
var sanitizedConfig = sanitizeConfig(config, knownFieldNames).sanitizedConfig;
Object.entries(sanitizedConfig).forEach(function (_a) {
var baseUrl = new URL(config.url || baseWidgetUrl);
var hostUrl = window.location.origin;
var url = config.url, configWithoutIframeUrl = __rest(config, ["url"]);
var preparedConfig = __assign({}, configWithoutIframeUrl, { hostUrl: hostUrl });
Object.entries(preparedConfig).forEach(function (_a) {
var key = _a[0], value = _a[1];
baseUrl.searchParams.append(key, value);
if (value) {
baseUrl.searchParams.append(key, value);
}
});

@@ -21,4 +68,5 @@ return baseUrl.toString();

iframe.setAttribute('src', url);
iframe.setAttribute('width', '1500');
iframe.setAttribute('height', '1000');
iframe.setAttribute('width', '895');
iframe.setAttribute('height', '590');
iframe.style.border = 'none';
return {

@@ -29,5 +77,20 @@ body: body,

}
function listenForEvents(widgetUrl, handler) {
window.addEventListener('message', function (event) {
if (!areUrlsEqual(event.origin, widgetUrl)) {
return;
}
// tslint:disable-next-line:no-console
console.log(event.data);
handler(event.data);
});
}
function areUrlsEqual(url1, url2) {
return new URL(url1).toString() === new URL(url2).toString();
}
function initialize(config) {
var url = initUrl(config);
var _a = initDOMNode(url), body = _a.body, iframe = _a.iframe;
listenForEvents(config.url || baseWidgetUrl, createWidgetEventHandler(iframe));
return {

@@ -43,21 +106,5 @@ show: function () {

}
function sanitizeConfig(config, whitelistedKeys) {
var rejectedKeys = [];
var sanitizedConfig = Object.entries(config).reduce(function (config, _a) {
var key = _a[0], value = _a[1];
if (whitelistedKeys.includes(key)) {
config[key] = value;
}
else {
rejectedKeys.push(key);
}
return config;
}, {});
return {
rejectedKeys: rejectedKeys,
sanitizedConfig: sanitizedConfig
};
}
//# sourceMappingURL=ramp-instant-sdk.js.map
export { initialize };
//# sourceMappingURL=ramp-instant-sdk.es5.js.map

@@ -7,15 +7,62 @@ (function (global, factory) {

var knownFieldNames = [
'swapAsset',
'swapAmount',
'userAddress',
'hostLogoUrl',
'hostAppName'
];
var baseWidgetUrl = 'http://localhost:8080';
//# sourceMappingURL=consts.js.map
function createWidgetEventHandler(iframeNode) {
return function handleWidgetEvents(event) {
switch (event.type) {
case 'WIDGET_CLOSE': {
iframeNode.parentNode.removeChild(iframeNode);
}
}
};
}
//# sourceMappingURL=event-handler.js.map
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
function initUrl(config) {
var baseUrl = new URL(config.url || 'http://localhost:8080/');
var sanitizedConfig = sanitizeConfig(config, knownFieldNames).sanitizedConfig;
Object.entries(sanitizedConfig).forEach(function (_a) {
var baseUrl = new URL(config.url || baseWidgetUrl);
var hostUrl = window.location.origin;
var url = config.url, configWithoutIframeUrl = __rest(config, ["url"]);
var preparedConfig = __assign({}, configWithoutIframeUrl, { hostUrl: hostUrl });
Object.entries(preparedConfig).forEach(function (_a) {
var key = _a[0], value = _a[1];
baseUrl.searchParams.append(key, value);
if (value) {
baseUrl.searchParams.append(key, value);
}
});

@@ -28,4 +75,5 @@ return baseUrl.toString();

iframe.setAttribute('src', url);
iframe.setAttribute('width', '1500');
iframe.setAttribute('height', '1000');
iframe.setAttribute('width', '895');
iframe.setAttribute('height', '590');
iframe.style.border = 'none';
return {

@@ -36,5 +84,20 @@ body: body,

}
function listenForEvents(widgetUrl, handler) {
window.addEventListener('message', function (event) {
if (!areUrlsEqual(event.origin, widgetUrl)) {
return;
}
// tslint:disable-next-line:no-console
console.log(event.data);
handler(event.data);
});
}
function areUrlsEqual(url1, url2) {
return new URL(url1).toString() === new URL(url2).toString();
}
function initialize(config) {
var url = initUrl(config);
var _a = initDOMNode(url), body = _a.body, iframe = _a.iframe;
listenForEvents(config.url || baseWidgetUrl, createWidgetEventHandler(iframe));
return {

@@ -50,19 +113,3 @@ show: function () {

}
function sanitizeConfig(config, whitelistedKeys) {
var rejectedKeys = [];
var sanitizedConfig = Object.entries(config).reduce(function (config, _a) {
var key = _a[0], value = _a[1];
if (whitelistedKeys.includes(key)) {
config[key] = value;
}
else {
rejectedKeys.push(key);
}
return config;
}, {});
return {
rejectedKeys: rejectedKeys,
sanitizedConfig: sanitizedConfig
};
}
//# sourceMappingURL=ramp-instant-sdk.js.map

@@ -69,0 +116,0 @@ exports.initialize = initialize;

@@ -1,18 +0,4 @@

declare type TAsset = string;
declare type TEthAddress = string;
declare type TSwapAmount = string;
declare type THostLogoUrl = string;
declare type THostAppName = string;
declare type TURL = string;
export interface IHostConfig {
swapAsset?: TAsset;
swapAmount?: TSwapAmount;
userAddress?: TEthAddress;
hostLogoUrl: THostLogoUrl;
hostAppName: THostAppName;
url?: TURL;
}
import { IHostConfig } from './types';
export declare function initialize(config: IHostConfig): {
show(): HTMLIFrameElement;
};
export {};
{
"name": "@ramp-network/ramp-instant-sdk",
"version": "0.1.1",
"version": "0.1.2",
"description": "SDK for Ramp Instant",

@@ -5,0 +5,0 @@ "keywords": [],

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