Socket
Socket
Sign inDemoInstall

@ramp-network/ramp-instant-sdk

Package Overview
Dependencies
Maintainers
3
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 3.0.0 to 3.1.0-rc0

1

dist/lib/consts.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.baseWidgetUrl = void 0;
exports.baseWidgetUrl = 'https://buy.ramp.network/';
//# sourceMappingURL=consts.js.map

13

dist/lib/init-helpers.js

@@ -25,7 +25,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareCloseModalNode = exports.isCloseModalAlreadyOpen = exports.areUrlsEqual = exports.importFonts = exports.initDOMNodeWithoutOverlay = exports.initDOMNodeWithOverlay = exports.hideWebsiteBelow = exports.initWidgetIframeUrl = exports.getBaseUrl = void 0;
var consts_1 = require("./consts");
var types_1 = require("./types");
var utils_1 = require("./utils");
function getBaseUrl(config) {
return new URL(config.url || consts_1.baseWidgetUrl);
}
exports.getBaseUrl = getBaseUrl;
function initWidgetIframeUrl(config) {
var baseUrl = new URL(config.url || consts_1.baseWidgetUrl);
var baseUrl = getBaseUrl(config);
var hostUrl = window.location.origin;

@@ -47,3 +52,3 @@ var containerNode = config.containerNode, url = config.url, configWithoutIframeUrl = __rest(config, ["containerNode", "url"]);

if (containerWidth) {
backgroundWebsiteHider.style.maxWidth = containerWidth + "px";
backgroundWebsiteHider.style.maxWidth = "".concat(containerWidth, "px");
}

@@ -207,7 +212,7 @@ parent.appendChild(backgroundWebsiteHider);

var isEmbedded = variant === 'embedded-mobile' || variant === 'embedded-desktop';
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: " + (isMobile ? '100%;' : '100vh;') + "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n min-width: " + (isMobile ? utils_1.minWidgetMobileWidth : utils_1.widgetDesktopWidth) + "px;\n min-height: " + (isMobile ? utils_1.minWidgetMobileHeight : utils_1.widgetDesktopHeight) + "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n " + (!isEmbedded && isMobile
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: ".concat(isMobile ? '100%;' : '100vh;', "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n min-width: ").concat(isMobile ? utils_1.minWidgetMobileWidth : utils_1.widgetDesktopWidth, "px;\n min-height: ").concat(isMobile ? utils_1.minWidgetMobileHeight : utils_1.widgetDesktopHeight, "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n ").concat(!isEmbedded && isMobile
? "\n width: 100vw;\n height: 100%;\n "
: '') + "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ";
: '', "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ");
return styles;
}
//# sourceMappingURL=init-helpers.js.map

@@ -13,5 +13,41 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RampInstantSDK = exports.RampInstantEventTypes = void 0;
var body_scroll_lock_1 = require("body-scroll-lock");
var consts_1 = require("./consts");
var init_helpers_1 = require("./init-helpers");

@@ -22,8 +58,8 @@ var init_helpers_2 = require("./init-helpers");

var types_2 = require("./types");
exports.RampInstantEventTypes = types_2.WidgetEventTypes;
Object.defineProperty(exports, "RampInstantEventTypes", { enumerable: true, get: function () { return types_2.WidgetEventTypes; } });
var RampInstantSDK = /** @class */ (function () {
function RampInstantSDK(config) {
this._listeners = utils_1.initEventListenersDict();
this._listeners = (0, utils_1.initEventListenersDict)();
this._isVisible = false;
init_helpers_2.importFonts();
(0, init_helpers_2.importFonts)();
this.unsubscribe = this.unsubscribe.bind(this);

@@ -38,5 +74,5 @@ this.on = this.on.bind(this);

this._subscribeToWidgetEvents = this._subscribeToWidgetEvents.bind(this);
this._rawNormalizedConfig = utils_1.normalizeConfigAndLogErrorsOnInvalidFields(__assign({ variant: 'desktop' }, config));
var widgetVariant = utils_1.determineWidgetVariant(this._rawNormalizedConfig);
this._config = __assign(__assign({}, this._rawNormalizedConfig), { variant: widgetVariant, widgetInstanceId: utils_1.getRandomIntString() });
this._rawNormalizedConfig = (0, utils_1.normalizeConfigAndLogErrorsOnInvalidFields)(__assign({ variant: 'desktop' }, config));
var widgetVariant = (0, utils_1.determineWidgetVariant)(this._rawNormalizedConfig);
this._config = __assign(__assign({}, this._rawNormalizedConfig), { variant: widgetVariant, widgetInstanceId: (0, utils_1.getRandomIntString)() });
}

@@ -47,3 +83,3 @@ RampInstantSDK.prototype.show = function () {

}
if (document.activeElement && utils_1.isHtmlElement(document.activeElement)) {
if (document.activeElement && (0, utils_1.isHtmlElement)(document.activeElement)) {
document.activeElement.blur();

@@ -87,3 +123,3 @@ }

// tslint:disable-next-line:no-console
console.warn("Unknown / unsupported event name - '" + type + "'. This listener will have no effect.");
console.warn("Unknown / unsupported event name - '".concat(type, "'. This listener will have no effect."));
}

@@ -106,2 +142,50 @@ if (type === '*') {

};
RampInstantSDK.prototype.onRequestCryptoAccount = function (callback) {
var _this = this;
var onRequestCryptoAccount = function (event) { return __awaiter(_this, void 0, void 0, function () {
var result, e_1, errorMessage;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, callback(event.payload.type, event.payload.assetSymbol)];
case 1:
result = _a.sent();
if (!result.address) {
throw new Error('Missing address in the callback result');
}
return [3 /*break*/, 3];
case 2:
e_1 = _a.sent();
errorMessage = void 0;
if (typeof e_1 === 'string') {
errorMessage = e_1;
}
else if (e_1 instanceof Error) {
errorMessage = e_1.message;
}
this._sendEventToWidget({
type: types_1.InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
error: errorMessage,
},
});
return [2 /*return*/];
case 3:
this._sendEventToWidget({
type: types_1.InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
address: result.address,
type: result.type,
name: result.name,
assetSymbol: result.assetSymbol,
},
});
return [2 /*return*/];
}
});
}); };
this._on(types_1.InternalEventTypes.REQUEST_CRYPTO_ACCOUNT, onRequestCryptoAccount, true);
return this;
};
RampInstantSDK.prototype._subscribeToWidgetEvents = function (event) {

@@ -111,3 +195,3 @@ if (!event.data) {

}
if (!init_helpers_2.areUrlsEqual(event.origin, this._config.url || consts_1.baseWidgetUrl)) {
if (!(0, init_helpers_2.areUrlsEqual)(event.origin, (0, init_helpers_1.getBaseUrl)(this._config).origin)) {
return;

@@ -136,3 +220,3 @@ }

(_b = _this.domNodes) === null || _b === void 0 ? void 0 : _b.shadowHost.remove();
body_scroll_lock_1.default.clearAllBodyScrollLocks();
(0, body_scroll_lock_1.clearAllBodyScrollLocks)();
}

@@ -158,6 +242,6 @@ _this._teardownEventSubscriptions();

}
if (_this._config.variant === 'mobile' || init_helpers_2.isCloseModalAlreadyOpen(_this.domNodes.overlay)) {
if (_this._config.variant === 'mobile' || (0, init_helpers_2.isCloseModalAlreadyOpen)(_this.domNodes.overlay)) {
return;
}
_this.domNodes.overlay.appendChild(init_helpers_2.prepareCloseModalNode(_this._dispatchEvent));
_this.domNodes.overlay.appendChild((0, init_helpers_2.prepareCloseModalNode)(_this._dispatchEvent));
}, true);

@@ -181,2 +265,13 @@ this._on(types_1.InternalEventTypes.WIDGET_CLOSE_REQUEST_CONFIRMED, function (_event) {

};
RampInstantSDK.prototype._sendEventToWidget = function (event) {
var _a, _b, _c;
if (!this._isVisible) {
throw new Error("Widget is not visible couldn't send the event");
}
try {
(_c = ((_a = this.widgetWindow) !== null && _a !== void 0 ? _a : (_b = this.domNodes) === null || _b === void 0 ? void 0 : _b.iframe.contentWindow)) === null || _c === void 0 ? void 0 : _c.postMessage(event, (0, init_helpers_1.getBaseUrl)(this._config).origin);
// tslint:disable-next-line:no-empty
}
catch (_d) { }
};
RampInstantSDK.prototype._dispatchEvent = function (event) {

@@ -204,4 +299,4 @@ var type = event.type;

var _a, _b;
var widgetUrl = init_helpers_2.initWidgetIframeUrl(this._config);
this.domNodes = init_helpers_2.initDOMNodeWithoutOverlay(widgetUrl, this._dispatchEvent, this._config);
var widgetUrl = (0, init_helpers_2.initWidgetIframeUrl)(this._config);
this.domNodes = (0, init_helpers_2.initDOMNodeWithoutOverlay)(widgetUrl, this._dispatchEvent, this._config);
if (!((_a = this.domNodes) === null || _a === void 0 ? void 0 : _a.body)) {

@@ -215,4 +310,4 @@ throw new Error("Couldn't find <body> element.");

var _a;
var widgetUrl = init_helpers_2.initWidgetIframeUrl(this._config);
this.domNodes = init_helpers_2.initDOMNodeWithOverlay(widgetUrl, this._dispatchEvent, this._config);
var widgetUrl = (0, init_helpers_2.initWidgetIframeUrl)(this._config);
this.domNodes = (0, init_helpers_2.initDOMNodeWithOverlay)(widgetUrl, this._dispatchEvent, this._config);
if (!((_a = this.domNodes) === null || _a === void 0 ? void 0 : _a.body)) {

@@ -223,6 +318,6 @@ throw new Error("Couldn't find <body> element.");

this._isVisible = true;
body_scroll_lock_1.default.disableBodyScroll(this.domNodes.iframe);
var widgetMode = utils_1.determineWidgetVariant(this._config);
(0, body_scroll_lock_1.disableBodyScroll)(this.domNodes.iframe);
var widgetMode = (0, utils_1.determineWidgetVariant)(this._config);
if (widgetMode !== 'desktop' && widgetMode !== 'embedded-desktop') {
init_helpers_1.hideWebsiteBelow(this.domNodes.shadow);
(0, init_helpers_1.hideWebsiteBelow)(this.domNodes.shadow);
}

@@ -232,4 +327,4 @@ };

var _a;
var widgetUrl = init_helpers_2.initWidgetIframeUrl(this._config);
this.widgetWindow = (_a = window.open(widgetUrl), (_a !== null && _a !== void 0 ? _a : undefined));
var widgetUrl = (0, init_helpers_2.initWidgetIframeUrl)(this._config);
this.widgetWindow = (_a = window.open(widgetUrl)) !== null && _a !== void 0 ? _a : undefined;
};

@@ -236,0 +331,0 @@ RampInstantSDK.prototype._isConfiguredWithOverlay = function () {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalSdkEventTypes = exports.InternalEventTypes = exports.WidgetEventTypes = exports.EventSeverity = exports.PurchaseStatus = exports.PaymentMethodName = void 0;
var PaymentMethodName;

@@ -47,3 +48,8 @@ (function (PaymentMethodName) {

InternalEventTypes["WIDGET_CLOSE_REQUEST_CONFIRMED"] = "WIDGET_CLOSE_REQUEST_CONFIRMED";
InternalEventTypes["REQUEST_CRYPTO_ACCOUNT"] = "REQUEST_CRYPTO_ACCOUNT";
})(InternalEventTypes = exports.InternalEventTypes || (exports.InternalEventTypes = {}));
var InternalSdkEventTypes;
(function (InternalSdkEventTypes) {
InternalSdkEventTypes["REQUEST_CRYPTO_ACCOUNT_RESULT"] = "REQUEST_CRYPTO_ACCOUNT_RESULT";
})(InternalSdkEventTypes = exports.InternalSdkEventTypes || (exports.InternalSdkEventTypes = {}));
//# sourceMappingURL=types.js.map

@@ -13,10 +13,13 @@ "use strict";

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.urlWithoutTrailingSlash = exports.concatRelativePath = exports.isHtmlElement = exports.determineWidgetVariant = exports.initEventListenersDict = exports.normalizeConfigAndLogErrorsOnInvalidFields = exports.minWidgetMobileHeight = exports.minWidgetMobileWidth = exports.widgetDesktopHeight = exports.widgetDesktopWidth = exports.getRandomIntString = void 0;
var types_1 = require("./types");

@@ -78,4 +81,4 @@ function getRandomIntString() {

console.log(error.description);
console.log("Example expected value: " + error.exampleValue);
console.log("Severity: " + error.severity);
console.log("Example expected value: ".concat(error.exampleValue));
console.log("Severity: ".concat(error.severity));
console.groupEnd();

@@ -89,3 +92,3 @@ });

var internalEventTypes = Array.from(Object.values(types_1.InternalEventTypes));
return __spreadArrays(widgetEventTypes, internalEventTypes).reduce(function (listenersDict, eventType) {
return __spreadArray(__spreadArray([], widgetEventTypes, true), internalEventTypes, true).reduce(function (listenersDict, eventType) {
listenersDict[eventType] = [];

@@ -132,6 +135,6 @@ return listenersDict;

if (width + 1 < exports.widgetDesktopWidth) {
throw new Error("Container node must be at least " + exports.widgetDesktopWidth + "px wide.");
throw new Error("Container node must be at least ".concat(exports.widgetDesktopWidth, "px wide."));
}
if (height + 1 < exports.widgetDesktopHeight) {
throw new Error("Container node must be at least " + exports.widgetDesktopHeight + "px tall.");
throw new Error("Container node must be at least ".concat(exports.widgetDesktopHeight, "px tall."));
}

@@ -141,6 +144,6 @@ }

if (width + 1 < exports.minWidgetMobileWidth) {
throw new Error("Container node must be at least " + exports.minWidgetMobileWidth + "px wide.");
throw new Error("Container node must be at least ".concat(exports.minWidgetMobileWidth, "px wide."));
}
if (height + 1 < exports.minWidgetMobileHeight) {
throw new Error("Container node must be at least " + exports.minWidgetMobileHeight + "px tall.");
throw new Error("Container node must be at least ".concat(exports.minWidgetMobileHeight, "px tall."));
}

@@ -159,3 +162,3 @@ }

var normalizedPath = path.startsWith('/') ? path.substr(1) : path;
return new URL(normalizedBase + "/" + normalizedPath);
return new URL("".concat(normalizedBase, "/").concat(normalizedPath));
}

@@ -162,0 +165,0 @@ exports.concatRelativePath = concatRelativePath;

/*! *****************************************************************************
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
Copyright (c) Microsoft Corporation.
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.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -39,26 +39,238 @@

function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
// Older browsers don't support event options, feature detect it.
// Adopted and modified solution from Bohdan Didukh (2017)
// https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
var hasPassiveEvents = false;
if (typeof window !== 'undefined') {
var passiveTestOptions = {
get passive() {
hasPassiveEvents = true;
return undefined;
}
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
}
var bodyScrollLock_min = createCommonjsModule(function (module, exports) {
!function(e,t){t(exports);}(commonjsGlobal,function(exports){function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}Object.defineProperty(exports,"__esModule",{value:!0});var l=!1;if("undefined"!=typeof window){var e={get passive(){l=!0;}};window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e);}var d="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),c=[],u=!1,a=-1,s=void 0,v=void 0,f=function(t){return c.some(function(e){return !(!e.options.allowTouchMove||!e.options.allowTouchMove(t))})},m=function(e){var t=e||window.event;return !!f(t.target)||(1<t.touches.length||(t.preventDefault&&t.preventDefault(),!1))},o=function(){setTimeout(function(){void 0!==v&&(document.body.style.paddingRight=v,v=void 0),void 0!==s&&(document.body.style.overflow=s,s=void 0);});};exports.disableBodyScroll=function(i,e){if(d){if(!i)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(i&&!c.some(function(e){return e.targetElement===i})){var t={targetElement:i,options:e||{}};c=[].concat(r(c),[t]),i.ontouchstart=function(e){1===e.targetTouches.length&&(a=e.targetTouches[0].clientY);},i.ontouchmove=function(e){var t,o,n,r;1===e.targetTouches.length&&(o=i,r=(t=e).targetTouches[0].clientY-a,!f(t.target)&&(o&&0===o.scrollTop&&0<r?m(t):(n=o)&&n.scrollHeight-n.scrollTop<=n.clientHeight&&r<0?m(t):t.stopPropagation()));},u||(document.addEventListener("touchmove",m,l?{passive:!1}:void 0),u=!0);}}else{n=e,setTimeout(function(){if(void 0===v){var e=!!n&&!0===n.reserveScrollBarGap,t=window.innerWidth-document.documentElement.clientWidth;e&&0<t&&(v=document.body.style.paddingRight,document.body.style.paddingRight=t+"px");}void 0===s&&(s=document.body.style.overflow,document.body.style.overflow="hidden");});var o={targetElement:i,options:e||{}};c=[].concat(r(c),[o]);}var n;},exports.clearAllBodyScrollLocks=function(){d?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null;}),u&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1),c=[],a=-1):(o(),c=[]);},exports.enableBodyScroll=function(t){if(d){if(!t)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");t.ontouchstart=null,t.ontouchmove=null,c=c.filter(function(e){return e.targetElement!==t}),u&&0===c.length&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1);}else(c=c.filter(function(e){return e.targetElement!==t})).length||o();};});
});
var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
var bodyScrollLock = unwrapExports(bodyScrollLock_min);
var locks = [];
var documentListenerAdded = false;
var initialClientY = -1;
var previousBodyOverflowSetting = void 0;
var previousBodyPaddingRight = void 0;
// returns true if `el` should be allowed to receive touchmove events.
var allowTouchMove = function allowTouchMove(el) {
return locks.some(function (lock) {
if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
return true;
}
return false;
});
};
var preventDefault = function preventDefault(rawEvent) {
var e = rawEvent || window.event;
// For the case whereby consumers adds a touchmove event listener to document.
// Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
// in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
// the touchmove event on document will break.
if (allowTouchMove(e.target)) {
return true;
}
// Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
if (e.touches.length > 1) return true;
if (e.preventDefault) e.preventDefault();
return false;
};
var setOverflowHidden = function setOverflowHidden(options) {
// If previousBodyPaddingRight is already set, don't set it again.
if (previousBodyPaddingRight === undefined) {
var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
if (_reserveScrollBarGap && scrollBarGap > 0) {
previousBodyPaddingRight = document.body.style.paddingRight;
document.body.style.paddingRight = scrollBarGap + 'px';
}
}
// If previousBodyOverflowSetting is already set, don't set it again.
if (previousBodyOverflowSetting === undefined) {
previousBodyOverflowSetting = document.body.style.overflow;
document.body.style.overflow = 'hidden';
}
};
var restoreOverflowSetting = function restoreOverflowSetting() {
if (previousBodyPaddingRight !== undefined) {
document.body.style.paddingRight = previousBodyPaddingRight;
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
// can be set again.
previousBodyPaddingRight = undefined;
}
if (previousBodyOverflowSetting !== undefined) {
document.body.style.overflow = previousBodyOverflowSetting;
// Restore previousBodyOverflowSetting to undefined
// so setOverflowHidden knows it can be set again.
previousBodyOverflowSetting = undefined;
}
};
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
var isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {
return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
};
var handleScroll = function handleScroll(event, targetElement) {
var clientY = event.targetTouches[0].clientY - initialClientY;
if (allowTouchMove(event.target)) {
return false;
}
if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
// element is at the top of its scroll.
return preventDefault(event);
}
if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
// element is at the bottom of its scroll.
return preventDefault(event);
}
event.stopPropagation();
return true;
};
var disableBodyScroll = function disableBodyScroll(targetElement, options) {
// targetElement must be provided
if (!targetElement) {
// eslint-disable-next-line no-console
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
return;
}
// disableBodyScroll must not have been called on this targetElement before
if (locks.some(function (lock) {
return lock.targetElement === targetElement;
})) {
return;
}
var lock = {
targetElement: targetElement,
options: options || {}
};
locks = [].concat(_toConsumableArray(locks), [lock]);
if (isIosDevice) {
targetElement.ontouchstart = function (event) {
if (event.targetTouches.length === 1) {
// detect single touch.
initialClientY = event.targetTouches[0].clientY;
}
};
targetElement.ontouchmove = function (event) {
if (event.targetTouches.length === 1) {
// detect single touch.
handleScroll(event, targetElement);
}
};
if (!documentListenerAdded) {
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
documentListenerAdded = true;
}
} else {
setOverflowHidden(options);
}
};
var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {
if (isIosDevice) {
// Clear all locks ontouchstart/ontouchmove handlers, and the references.
locks.forEach(function (lock) {
lock.targetElement.ontouchstart = null;
lock.targetElement.ontouchmove = null;
});
if (documentListenerAdded) {
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
documentListenerAdded = false;
}
// Reset initial clientY.
initialClientY = -1;
} else {
restoreOverflowSetting();
}
locks = [];
};
var baseWidgetUrl = 'https://buy.ramp.network/';

@@ -110,3 +322,8 @@

InternalEventTypes["WIDGET_CLOSE_REQUEST_CONFIRMED"] = "WIDGET_CLOSE_REQUEST_CONFIRMED";
InternalEventTypes["REQUEST_CRYPTO_ACCOUNT"] = "REQUEST_CRYPTO_ACCOUNT";
})(InternalEventTypes || (InternalEventTypes = {}));
var InternalSdkEventTypes;
(function (InternalSdkEventTypes) {
InternalSdkEventTypes["REQUEST_CRYPTO_ACCOUNT_RESULT"] = "REQUEST_CRYPTO_ACCOUNT_RESULT";
})(InternalSdkEventTypes || (InternalSdkEventTypes = {}));

@@ -166,4 +383,4 @@ function getRandomIntString() {

console.log(error.description);
console.log("Example expected value: " + error.exampleValue);
console.log("Severity: " + error.severity);
console.log("Example expected value: ".concat(error.exampleValue));
console.log("Severity: ".concat(error.severity));
console.groupEnd();

@@ -177,3 +394,3 @@ });

var internalEventTypes = Array.from(Object.values(InternalEventTypes));
return __spreadArrays(widgetEventTypes, internalEventTypes).reduce(function (listenersDict, eventType) {
return __spreadArray(__spreadArray([], widgetEventTypes, true), internalEventTypes, true).reduce(function (listenersDict, eventType) {
listenersDict[eventType] = [];

@@ -217,6 +434,6 @@ return listenersDict;

if (width + 1 < widgetDesktopWidth) {
throw new Error("Container node must be at least " + widgetDesktopWidth + "px wide.");
throw new Error("Container node must be at least ".concat(widgetDesktopWidth, "px wide."));
}
if (height + 1 < widgetDesktopHeight) {
throw new Error("Container node must be at least " + widgetDesktopHeight + "px tall.");
throw new Error("Container node must be at least ".concat(widgetDesktopHeight, "px tall."));
}

@@ -226,6 +443,6 @@ }

if (width + 1 < minWidgetMobileWidth) {
throw new Error("Container node must be at least " + minWidgetMobileWidth + "px wide.");
throw new Error("Container node must be at least ".concat(minWidgetMobileWidth, "px wide."));
}
if (height + 1 < minWidgetMobileHeight) {
throw new Error("Container node must be at least " + minWidgetMobileHeight + "px tall.");
throw new Error("Container node must be at least ".concat(minWidgetMobileHeight, "px tall."));
}

@@ -235,6 +452,9 @@ }

function getBaseUrl(config) {
return new URL(config.url || baseWidgetUrl);
}
function initWidgetIframeUrl(config) {
var baseUrl = new URL(config.url || baseWidgetUrl);
var baseUrl = getBaseUrl(config);
var hostUrl = window.location.origin;
var containerNode = config.containerNode, url = config.url, configWithoutIframeUrl = __rest(config, ["containerNode", "url"]);
config.containerNode; config.url; var configWithoutIframeUrl = __rest(config, ["containerNode", "url"]);
var preparedConfig = __assign(__assign({}, configWithoutIframeUrl), { hostUrl: hostUrl });

@@ -253,3 +473,3 @@ Object.entries(preparedConfig).forEach(function (_a) {

if (containerWidth) {
backgroundWebsiteHider.style.maxWidth = containerWidth + "px";
backgroundWebsiteHider.style.maxWidth = "".concat(containerWidth, "px");
}

@@ -406,5 +626,5 @@ parent.appendChild(backgroundWebsiteHider);

var isEmbedded = variant === 'embedded-mobile' || variant === 'embedded-desktop';
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: " + (isMobile ? '100%;' : '100vh;') + "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n min-width: " + (isMobile ? minWidgetMobileWidth : widgetDesktopWidth) + "px;\n min-height: " + (isMobile ? minWidgetMobileHeight : widgetDesktopHeight) + "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n " + (!isEmbedded && isMobile
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: ".concat(isMobile ? '100%;' : '100vh;', "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n min-width: ").concat(isMobile ? minWidgetMobileWidth : widgetDesktopWidth, "px;\n min-height: ").concat(isMobile ? minWidgetMobileHeight : widgetDesktopHeight, "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n ").concat(!isEmbedded && isMobile
? "\n width: 100vw;\n height: 100%;\n "
: '') + "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ";
: '', "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ");
return styles;

@@ -474,3 +694,3 @@ }

// tslint:disable-next-line:no-console
console.warn("Unknown / unsupported event name - '" + type + "'. This listener will have no effect.");
console.warn("Unknown / unsupported event name - '".concat(type, "'. This listener will have no effect."));
}

@@ -493,2 +713,50 @@ if (type === '*') {

};
RampInstantSDK.prototype.onRequestCryptoAccount = function (callback) {
var _this = this;
var onRequestCryptoAccount = function (event) { return __awaiter(_this, void 0, void 0, function () {
var result, e_1, errorMessage;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, callback(event.payload.type, event.payload.assetSymbol)];
case 1:
result = _a.sent();
if (!result.address) {
throw new Error('Missing address in the callback result');
}
return [3 /*break*/, 3];
case 2:
e_1 = _a.sent();
errorMessage = void 0;
if (typeof e_1 === 'string') {
errorMessage = e_1;
}
else if (e_1 instanceof Error) {
errorMessage = e_1.message;
}
this._sendEventToWidget({
type: InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
error: errorMessage,
},
});
return [2 /*return*/];
case 3:
this._sendEventToWidget({
type: InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
address: result.address,
type: result.type,
name: result.name,
assetSymbol: result.assetSymbol,
},
});
return [2 /*return*/];
}
});
}); };
this._on(InternalEventTypes.REQUEST_CRYPTO_ACCOUNT, onRequestCryptoAccount, true);
return this;
};
RampInstantSDK.prototype._subscribeToWidgetEvents = function (event) {

@@ -498,3 +766,3 @@ if (!event.data) {

}
if (!areUrlsEqual(event.origin, this._config.url || baseWidgetUrl)) {
if (!areUrlsEqual(event.origin, getBaseUrl(this._config).origin)) {
return;

@@ -523,3 +791,3 @@ }

(_b = _this.domNodes) === null || _b === void 0 ? void 0 : _b.shadowHost.remove();
bodyScrollLock.clearAllBodyScrollLocks();
clearAllBodyScrollLocks();
}

@@ -567,2 +835,13 @@ _this._teardownEventSubscriptions();

};
RampInstantSDK.prototype._sendEventToWidget = function (event) {
var _a, _b, _c;
if (!this._isVisible) {
throw new Error("Widget is not visible couldn't send the event");
}
try {
(_c = ((_a = this.widgetWindow) !== null && _a !== void 0 ? _a : (_b = this.domNodes) === null || _b === void 0 ? void 0 : _b.iframe.contentWindow)) === null || _c === void 0 ? void 0 : _c.postMessage(event, getBaseUrl(this._config).origin);
// tslint:disable-next-line:no-empty
}
catch (_d) { }
};
RampInstantSDK.prototype._dispatchEvent = function (event) {

@@ -607,3 +886,3 @@ var type = event.type;

this._isVisible = true;
bodyScrollLock.disableBodyScroll(this.domNodes.iframe);
disableBodyScroll(this.domNodes.iframe);
var widgetMode = determineWidgetVariant(this._config);

@@ -617,3 +896,3 @@ if (widgetMode !== 'desktop' && widgetMode !== 'embedded-desktop') {

var widgetUrl = initWidgetIframeUrl(this._config);
this.widgetWindow = (_a = window.open(widgetUrl), (_a !== null && _a !== void 0 ? _a : undefined));
this.widgetWindow = (_a = window.open(widgetUrl)) !== null && _a !== void 0 ? _a : undefined;
};

@@ -620,0 +899,0 @@ RampInstantSDK.prototype._isConfiguredWithOverlay = function () {

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.rampInstantSdk = {}));
}(this, (function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.rampInstantSdk = {}));
})(this, (function (exports) { 'use strict';
/*! *****************************************************************************
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
Copyright (c) Microsoft Corporation.
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.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -45,26 +45,238 @@

function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
// Older browsers don't support event options, feature detect it.
// Adopted and modified solution from Bohdan Didukh (2017)
// https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
var hasPassiveEvents = false;
if (typeof window !== 'undefined') {
var passiveTestOptions = {
get passive() {
hasPassiveEvents = true;
return undefined;
}
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
}
var bodyScrollLock_min = createCommonjsModule(function (module, exports) {
!function(e,t){t(exports);}(commonjsGlobal,function(exports){function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}Object.defineProperty(exports,"__esModule",{value:!0});var l=!1;if("undefined"!=typeof window){var e={get passive(){l=!0;}};window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e);}var d="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),c=[],u=!1,a=-1,s=void 0,v=void 0,f=function(t){return c.some(function(e){return !(!e.options.allowTouchMove||!e.options.allowTouchMove(t))})},m=function(e){var t=e||window.event;return !!f(t.target)||(1<t.touches.length||(t.preventDefault&&t.preventDefault(),!1))},o=function(){setTimeout(function(){void 0!==v&&(document.body.style.paddingRight=v,v=void 0),void 0!==s&&(document.body.style.overflow=s,s=void 0);});};exports.disableBodyScroll=function(i,e){if(d){if(!i)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(i&&!c.some(function(e){return e.targetElement===i})){var t={targetElement:i,options:e||{}};c=[].concat(r(c),[t]),i.ontouchstart=function(e){1===e.targetTouches.length&&(a=e.targetTouches[0].clientY);},i.ontouchmove=function(e){var t,o,n,r;1===e.targetTouches.length&&(o=i,r=(t=e).targetTouches[0].clientY-a,!f(t.target)&&(o&&0===o.scrollTop&&0<r?m(t):(n=o)&&n.scrollHeight-n.scrollTop<=n.clientHeight&&r<0?m(t):t.stopPropagation()));},u||(document.addEventListener("touchmove",m,l?{passive:!1}:void 0),u=!0);}}else{n=e,setTimeout(function(){if(void 0===v){var e=!!n&&!0===n.reserveScrollBarGap,t=window.innerWidth-document.documentElement.clientWidth;e&&0<t&&(v=document.body.style.paddingRight,document.body.style.paddingRight=t+"px");}void 0===s&&(s=document.body.style.overflow,document.body.style.overflow="hidden");});var o={targetElement:i,options:e||{}};c=[].concat(r(c),[o]);}var n;},exports.clearAllBodyScrollLocks=function(){d?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null;}),u&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1),c=[],a=-1):(o(),c=[]);},exports.enableBodyScroll=function(t){if(d){if(!t)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");t.ontouchstart=null,t.ontouchmove=null,c=c.filter(function(e){return e.targetElement!==t}),u&&0===c.length&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1);}else(c=c.filter(function(e){return e.targetElement!==t})).length||o();};});
});
var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
var bodyScrollLock = unwrapExports(bodyScrollLock_min);
var locks = [];
var documentListenerAdded = false;
var initialClientY = -1;
var previousBodyOverflowSetting = void 0;
var previousBodyPaddingRight = void 0;
// returns true if `el` should be allowed to receive touchmove events.
var allowTouchMove = function allowTouchMove(el) {
return locks.some(function (lock) {
if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
return true;
}
return false;
});
};
var preventDefault = function preventDefault(rawEvent) {
var e = rawEvent || window.event;
// For the case whereby consumers adds a touchmove event listener to document.
// Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
// in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
// the touchmove event on document will break.
if (allowTouchMove(e.target)) {
return true;
}
// Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
if (e.touches.length > 1) return true;
if (e.preventDefault) e.preventDefault();
return false;
};
var setOverflowHidden = function setOverflowHidden(options) {
// If previousBodyPaddingRight is already set, don't set it again.
if (previousBodyPaddingRight === undefined) {
var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
if (_reserveScrollBarGap && scrollBarGap > 0) {
previousBodyPaddingRight = document.body.style.paddingRight;
document.body.style.paddingRight = scrollBarGap + 'px';
}
}
// If previousBodyOverflowSetting is already set, don't set it again.
if (previousBodyOverflowSetting === undefined) {
previousBodyOverflowSetting = document.body.style.overflow;
document.body.style.overflow = 'hidden';
}
};
var restoreOverflowSetting = function restoreOverflowSetting() {
if (previousBodyPaddingRight !== undefined) {
document.body.style.paddingRight = previousBodyPaddingRight;
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
// can be set again.
previousBodyPaddingRight = undefined;
}
if (previousBodyOverflowSetting !== undefined) {
document.body.style.overflow = previousBodyOverflowSetting;
// Restore previousBodyOverflowSetting to undefined
// so setOverflowHidden knows it can be set again.
previousBodyOverflowSetting = undefined;
}
};
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
var isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {
return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
};
var handleScroll = function handleScroll(event, targetElement) {
var clientY = event.targetTouches[0].clientY - initialClientY;
if (allowTouchMove(event.target)) {
return false;
}
if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
// element is at the top of its scroll.
return preventDefault(event);
}
if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
// element is at the bottom of its scroll.
return preventDefault(event);
}
event.stopPropagation();
return true;
};
var disableBodyScroll = function disableBodyScroll(targetElement, options) {
// targetElement must be provided
if (!targetElement) {
// eslint-disable-next-line no-console
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
return;
}
// disableBodyScroll must not have been called on this targetElement before
if (locks.some(function (lock) {
return lock.targetElement === targetElement;
})) {
return;
}
var lock = {
targetElement: targetElement,
options: options || {}
};
locks = [].concat(_toConsumableArray(locks), [lock]);
if (isIosDevice) {
targetElement.ontouchstart = function (event) {
if (event.targetTouches.length === 1) {
// detect single touch.
initialClientY = event.targetTouches[0].clientY;
}
};
targetElement.ontouchmove = function (event) {
if (event.targetTouches.length === 1) {
// detect single touch.
handleScroll(event, targetElement);
}
};
if (!documentListenerAdded) {
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
documentListenerAdded = true;
}
} else {
setOverflowHidden(options);
}
};
var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {
if (isIosDevice) {
// Clear all locks ontouchstart/ontouchmove handlers, and the references.
locks.forEach(function (lock) {
lock.targetElement.ontouchstart = null;
lock.targetElement.ontouchmove = null;
});
if (documentListenerAdded) {
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
documentListenerAdded = false;
}
// Reset initial clientY.
initialClientY = -1;
} else {
restoreOverflowSetting();
}
locks = [];
};
var baseWidgetUrl = 'https://buy.ramp.network/';

@@ -102,2 +314,3 @@

})(EventSeverity || (EventSeverity = {}));
exports.RampInstantEventTypes = void 0;
(function (WidgetEventTypes) {

@@ -116,3 +329,8 @@ WidgetEventTypes["WIDGET_CLOSE"] = "WIDGET_CLOSE";

InternalEventTypes["WIDGET_CLOSE_REQUEST_CONFIRMED"] = "WIDGET_CLOSE_REQUEST_CONFIRMED";
InternalEventTypes["REQUEST_CRYPTO_ACCOUNT"] = "REQUEST_CRYPTO_ACCOUNT";
})(InternalEventTypes || (InternalEventTypes = {}));
var InternalSdkEventTypes;
(function (InternalSdkEventTypes) {
InternalSdkEventTypes["REQUEST_CRYPTO_ACCOUNT_RESULT"] = "REQUEST_CRYPTO_ACCOUNT_RESULT";
})(InternalSdkEventTypes || (InternalSdkEventTypes = {}));

@@ -172,4 +390,4 @@ function getRandomIntString() {

console.log(error.description);
console.log("Example expected value: " + error.exampleValue);
console.log("Severity: " + error.severity);
console.log("Example expected value: ".concat(error.exampleValue));
console.log("Severity: ".concat(error.severity));
console.groupEnd();

@@ -183,3 +401,3 @@ });

var internalEventTypes = Array.from(Object.values(InternalEventTypes));
return __spreadArrays(widgetEventTypes, internalEventTypes).reduce(function (listenersDict, eventType) {
return __spreadArray(__spreadArray([], widgetEventTypes, true), internalEventTypes, true).reduce(function (listenersDict, eventType) {
listenersDict[eventType] = [];

@@ -223,6 +441,6 @@ return listenersDict;

if (width + 1 < widgetDesktopWidth) {
throw new Error("Container node must be at least " + widgetDesktopWidth + "px wide.");
throw new Error("Container node must be at least ".concat(widgetDesktopWidth, "px wide."));
}
if (height + 1 < widgetDesktopHeight) {
throw new Error("Container node must be at least " + widgetDesktopHeight + "px tall.");
throw new Error("Container node must be at least ".concat(widgetDesktopHeight, "px tall."));
}

@@ -232,6 +450,6 @@ }

if (width + 1 < minWidgetMobileWidth) {
throw new Error("Container node must be at least " + minWidgetMobileWidth + "px wide.");
throw new Error("Container node must be at least ".concat(minWidgetMobileWidth, "px wide."));
}
if (height + 1 < minWidgetMobileHeight) {
throw new Error("Container node must be at least " + minWidgetMobileHeight + "px tall.");
throw new Error("Container node must be at least ".concat(minWidgetMobileHeight, "px tall."));
}

@@ -241,6 +459,9 @@ }

function getBaseUrl(config) {
return new URL(config.url || baseWidgetUrl);
}
function initWidgetIframeUrl(config) {
var baseUrl = new URL(config.url || baseWidgetUrl);
var baseUrl = getBaseUrl(config);
var hostUrl = window.location.origin;
var containerNode = config.containerNode, url = config.url, configWithoutIframeUrl = __rest(config, ["containerNode", "url"]);
config.containerNode; config.url; var configWithoutIframeUrl = __rest(config, ["containerNode", "url"]);
var preparedConfig = __assign(__assign({}, configWithoutIframeUrl), { hostUrl: hostUrl });

@@ -259,3 +480,3 @@ Object.entries(preparedConfig).forEach(function (_a) {

if (containerWidth) {
backgroundWebsiteHider.style.maxWidth = containerWidth + "px";
backgroundWebsiteHider.style.maxWidth = "".concat(containerWidth, "px");
}

@@ -412,5 +633,5 @@ parent.appendChild(backgroundWebsiteHider);

var isEmbedded = variant === 'embedded-mobile' || variant === 'embedded-desktop';
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: " + (isMobile ? '100%;' : '100vh;') + "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n " + (isMobile ? 'align-items: flex-start;' : 'align-items: center;') + "\n min-width: " + (isMobile ? minWidgetMobileWidth : widgetDesktopWidth) + "px;\n min-height: " + (isMobile ? minWidgetMobileHeight : widgetDesktopHeight) + "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n " + (!isEmbedded && isMobile
styles.textContent = "\n\n .background-hider {\n content: '';\n height: 30vh;\n width: 100vw;\n position: fixed;\n bottom: 0;\n transform: translateY(50%);\n background-color: #f5f8fb;\n z-index: 999;\n }\n\n .overlay {\n position: fixed;\n z-index: 1000;\n width: 100vw;\n height: ".concat(isMobile ? '100%;' : '100vh;', "\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: rgba(166, 174, 185, 0.7);\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n }\n\n .embedded-container {\n z-index: 1000;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-flow: row nowrap;\n justify-content: center;\n ").concat(isMobile ? 'align-items: flex-start;' : 'align-items: center;', "\n min-width: ").concat(isMobile ? minWidgetMobileWidth : widgetDesktopWidth, "px;\n min-height: ").concat(isMobile ? minWidgetMobileHeight : widgetDesktopHeight, "px;\n }\n\n .loader-container {\n align-self: center;\n }\n\n .loader {\n transform-origin: center;\n animation: logoAnimation 4s linear infinite;\n width: 100px;\n height: auto;\n align-self: center;\n }\n\n .loader path:nth-child(3) {\n transform-origin: center;\n position: relative;\n }\n\n .loader path:nth-child(1) {\n transform-origin: center;\n position: relative;\n animation: box1Animation 4s linear infinite;\n transform: scale(0.4) translateX(6px);\n }\n\n .loader path:nth-child(2) {\n transform-origin: center;\n position: relative;\n animation: box4Animation 4s linear infinite;\n transform: scale(0.4) translateX(-6px);\n }\n\n @keyframes logoAnimation {\n 10% {\n transform: rotate(180deg);\n }\n 30%{\n transform: rotate(360deg);\n }\n 70% {\n transform: rotate(360deg);\n }\n 90% {\n transform: rotate(520deg);\n }\n 100% {\n transform: rotate(720deg);\n }\n }\n\n @keyframes box1Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(6px);\n }\n }\n\n\n @keyframes box4Animation {\n 0%, 10% {\n transform: scale(0.4) translateX(-6px);\n }\n 30%, 70% {\n transform: scale(1) translateX(0);\n }\n 90% {\n transform: scale(0.4) translateX(-6px);\n }\n }\n\n .iframe {\n border: none;\n user-select: none;\n visibility: hidden;\n position: absolute;\n }\n\n .iframe.visible {\n visibility: visible;\n ").concat(!isEmbedded && isMobile
? "\n width: 100vw;\n height: 100%;\n "
: '') + "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ";
: '', "\n }\n\n .close-modal {\n font-family: 'Poppins', sans-serif;\n width: 678px;\n height: 276px;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n box-shadow: 0px 54px 200px rgba(36, 37, 57, 0.2);\n display: flex;\n flex-flow: column nowrap;\n justify-content: flex-start;\n align-items: center;\n padding: 35px;\n border-radius: 8px;\n background: #fff;\n\n box-sizing: border-box;\n }\n\n .close-modal * {\n box-sizing: border-box;\n }\n\n .close-modal__text {\n margin: 40px auto 30px;\n font-weight: 600;\n font-size: 24px;\n line-height: 36px;\n text-align: center;\n\n color: #242539;\n }\n\n .close-modal__button-container {\n width: 318px;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n }\n\n .close-modal__button {\n background: #fff;\n border: 2px solid #EDEEF3;\n border-radius: 74px;\n width: 152px;\n height: 56px;\n cursor: pointer;\n font-weight: 600;\n font-size: 14px;\n line-height: 21px;\n color: #2B2D56;\n text-transform: uppercase;\n }\n\n .close-modal__button--exit {\n background: #DD3E56;\n box-shadow: 0px 8px 34px rgba(221, 62, 86, 0.4);\n color: #fff;\n border-color: transparent;\n }\n ");
return styles;

@@ -480,3 +701,3 @@ }

// tslint:disable-next-line:no-console
console.warn("Unknown / unsupported event name - '" + type + "'. This listener will have no effect.");
console.warn("Unknown / unsupported event name - '".concat(type, "'. This listener will have no effect."));
}

@@ -499,2 +720,50 @@ if (type === '*') {

};
RampInstantSDK.prototype.onRequestCryptoAccount = function (callback) {
var _this = this;
var onRequestCryptoAccount = function (event) { return __awaiter(_this, void 0, void 0, function () {
var result, e_1, errorMessage;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, callback(event.payload.type, event.payload.assetSymbol)];
case 1:
result = _a.sent();
if (!result.address) {
throw new Error('Missing address in the callback result');
}
return [3 /*break*/, 3];
case 2:
e_1 = _a.sent();
errorMessage = void 0;
if (typeof e_1 === 'string') {
errorMessage = e_1;
}
else if (e_1 instanceof Error) {
errorMessage = e_1.message;
}
this._sendEventToWidget({
type: InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
error: errorMessage,
},
});
return [2 /*return*/];
case 3:
this._sendEventToWidget({
type: InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT,
payload: {
address: result.address,
type: result.type,
name: result.name,
assetSymbol: result.assetSymbol,
},
});
return [2 /*return*/];
}
});
}); };
this._on(InternalEventTypes.REQUEST_CRYPTO_ACCOUNT, onRequestCryptoAccount, true);
return this;
};
RampInstantSDK.prototype._subscribeToWidgetEvents = function (event) {

@@ -504,3 +773,3 @@ if (!event.data) {

}
if (!areUrlsEqual(event.origin, this._config.url || baseWidgetUrl)) {
if (!areUrlsEqual(event.origin, getBaseUrl(this._config).origin)) {
return;

@@ -529,3 +798,3 @@ }

(_b = _this.domNodes) === null || _b === void 0 ? void 0 : _b.shadowHost.remove();
bodyScrollLock.clearAllBodyScrollLocks();
clearAllBodyScrollLocks();
}

@@ -573,2 +842,13 @@ _this._teardownEventSubscriptions();

};
RampInstantSDK.prototype._sendEventToWidget = function (event) {
var _a, _b, _c;
if (!this._isVisible) {
throw new Error("Widget is not visible couldn't send the event");
}
try {
(_c = ((_a = this.widgetWindow) !== null && _a !== void 0 ? _a : (_b = this.domNodes) === null || _b === void 0 ? void 0 : _b.iframe.contentWindow)) === null || _c === void 0 ? void 0 : _c.postMessage(event, getBaseUrl(this._config).origin);
// tslint:disable-next-line:no-empty
}
catch (_d) { }
};
RampInstantSDK.prototype._dispatchEvent = function (event) {

@@ -613,3 +893,3 @@ var type = event.type;

this._isVisible = true;
bodyScrollLock.disableBodyScroll(this.domNodes.iframe);
disableBodyScroll(this.domNodes.iframe);
var widgetMode = determineWidgetVariant(this._config);

@@ -623,3 +903,3 @@ if (widgetMode !== 'desktop' && widgetMode !== 'embedded-desktop') {

var widgetUrl = initWidgetIframeUrl(this._config);
this.widgetWindow = (_a = window.open(widgetUrl), (_a !== null && _a !== void 0 ? _a : undefined));
this.widgetWindow = (_a = window.open(widgetUrl)) !== null && _a !== void 0 ? _a : undefined;
};

@@ -642,3 +922,3 @@ RampInstantSDK.prototype._isConfiguredWithOverlay = function () {

})));
}));
//# sourceMappingURL=ramp-instant-sdk.umd.js.map
import { IHostConfigWithWidgetInstanceId, TAllEvents } from './types';
export declare function getBaseUrl(config: IHostConfigWithWidgetInstanceId): URL;
export declare function initWidgetIframeUrl(config: IHostConfigWithWidgetInstanceId): string;

@@ -3,0 +4,0 @@ export declare function hideWebsiteBelow(parent: Element | ShadowRoot, containerWidth?: number | undefined): void;

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

import { IHostConfig, TAllEvents } from './types';
import { IHostConfig, TAllEvents, TOnRequestCryptoAccountCallback } from './types';
export { IWidgetCloseEvent as WidgetCloseEvent, IWidgetCloseRequestCancelledEvent as WidgetCloseRequestCancelledEvent, IWidgetCloseRequestConfirmedEvent as WidgetCloseRequestConfirmedEvent, IWidgetCloseRequestEvent as WidgetCloseRequestEvent, IWidgetConfigDoneEvent as WidgetConfigDoneEvent, IWidgetEvent as RampInstantEvent, TWidgetEvents as RampInstantEvents, WidgetEventTypes as RampInstantEventTypes, AllWidgetVariants as RampInstantWidgetVariantTypes, IPurchase as RampInstantPurchase, } from './types';

@@ -22,4 +22,6 @@ export declare class RampInstantSDK {

close(): RampInstantSDK;
onRequestCryptoAccount(callback: TOnRequestCryptoAccountCallback): RampInstantSDK;
private _subscribeToWidgetEvents;
private _registerSdkEventHandlers;
private _sendEventToWidget;
private _dispatchEvent;

@@ -26,0 +28,0 @@ private _handleEscapeClick;

@@ -126,3 +126,4 @@ declare type TAsset = string;

WIDGET_CLOSE_REQUEST_CANCELLED = "WIDGET_CLOSE_REQUEST_CANCELLED",
WIDGET_CLOSE_REQUEST_CONFIRMED = "WIDGET_CLOSE_REQUEST_CONFIRMED"
WIDGET_CLOSE_REQUEST_CONFIRMED = "WIDGET_CLOSE_REQUEST_CONFIRMED",
REQUEST_CRYPTO_ACCOUNT = "REQUEST_CRYPTO_ACCOUNT"
}

@@ -178,2 +179,10 @@ export declare type TAllEventTypes = WidgetEventTypes | InternalEventTypes;

}
export interface IRequestCryptoAccountEvent extends IWidgetEvent {
type: InternalEventTypes.REQUEST_CRYPTO_ACCOUNT;
payload: {
type: string;
assetSymbol: string;
};
widgetInstanceId?: string;
}
export interface IWidgetCloseRequestCancelledEvent extends IWidgetEvent {

@@ -190,3 +199,14 @@ type: InternalEventTypes.WIDGET_CLOSE_REQUEST_CANCELLED;

export declare type TWidgetEvents = IWidgetCloseEvent | IWidgetConfigDoneEvent | IWidgetConfigFailedEvent | IPurchaseCreatedEvent | IPurchaseFailedEvent | IPurchaseSuccessfulEvent;
export declare type TInternalEvents = IWidgetCloseRequestEvent | IWidgetCloseRequestCancelledEvent | IWidgetCloseRequestConfirmedEvent;
export declare type TInternalEvents = IWidgetCloseRequestEvent | IWidgetCloseRequestCancelledEvent | IWidgetCloseRequestConfirmedEvent | IRequestCryptoAccountEvent;
export declare enum InternalSdkEventTypes {
REQUEST_CRYPTO_ACCOUNT_RESULT = "REQUEST_CRYPTO_ACCOUNT_RESULT"
}
export interface IRequestCryptoAccountResultEvent extends IWidgetEvent {
type: InternalSdkEventTypes.REQUEST_CRYPTO_ACCOUNT_RESULT;
payload: IOnRequestCryptoAccountResult | {
error: string | undefined;
};
widgetInstanceId?: string;
}
export declare type TSdkEvents = IRequestCryptoAccountResultEvent;
export declare type TAllEvents = TWidgetEvents | TInternalEvents;

@@ -204,2 +224,9 @@ export declare type WidgetVariantTypes = 'desktop' | 'mobile' | 'hosted-desktop' | 'hosted-mobile';

}
export interface IOnRequestCryptoAccountResult {
address: string;
type?: string;
name?: string;
assetSymbol?: string;
}
export declare type TOnRequestCryptoAccountCallback = (type: string, assetSymbol: string) => Promise<IOnRequestCryptoAccountResult>;
export {};
{
"name": "@ramp-network/ramp-instant-sdk",
"version": "3.0.0",
"version": "3.1.0-rc0",
"description": "SDK for Ramp Instant",

@@ -56,30 +56,30 @@ "keywords": [],

"devDependencies": {
"@types/body-scroll-lock": "^2.6.1",
"@types/jest": "^23.3.2",
"@types/node": "^10.11.0",
"cross-env": "^5.2.0",
"@types/body-scroll-lock": "^3.1.0",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.12",
"cross-env": "^7.0.3",
"husky": "^1.0.1",
"jest": "^23.6.0",
"jest-config": "^23.6.0",
"lint-staged": "^8.0.0",
"jest": "^27.4.4",
"jest-config": "^27.4.4",
"lint-staged": "^12.1.2",
"lodash.camelcase": "^4.3.0",
"prettier": "^2.0.5",
"rimraf": "^2.6.2",
"rollup": "^1.29.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^2.61.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.5.0",
"rollup-plugin-typescript2": "^0.25.3",
"ts-jest": "^23.10.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-standard": "^8.0.1",
"tslint-react": "^4.0.0",
"typescript": "3.7.2"
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.31.1",
"ts-jest": "^27.1.1",
"ts-node": "^10.4.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"tslint-react": "^5.0.0",
"typescript": "4.5.3"
},
"dependencies": {
"body-scroll-lock": "^2.6.4"
"body-scroll-lock": "^3.1.5"
}
}
}

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

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