@ramp-network/ramp-instant-sdk
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -39,2 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
function doFetchPurchase(apiUrl, purchaseExternalId, token) { | ||
@@ -47,3 +48,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, fetch(apiUrl + "/host-api/purchase/" + purchaseExternalId + "?secret=" + token, { | ||
return [4 /*yield*/, fetch(utils_1.concatRelativePath(apiUrl, "/host-api/purchase/" + purchaseExternalId + "?secret=" + token).href, { | ||
headers: { | ||
@@ -50,0 +51,0 @@ 'Content-Type': 'application/json', |
@@ -149,2 +149,19 @@ "use strict"; | ||
} | ||
/** | ||
* Concatenates `base` with `path`, always treating `path` as a relative path. Ignores: | ||
* - trailing slash in `base` | ||
* - leading slash in `path` | ||
* @param base base URL, e.g.: 'http://example.com/api' or 'http://example.com/service/api/' | ||
* @param path path to append, e.g.: 'user/getByEmail' or '/swap' | ||
*/ | ||
function concatRelativePath(base, path) { | ||
var normalizedBase = urlWithoutTrailingSlash(base instanceof URL ? base.href : base); | ||
var normalizedPath = path.startsWith('/') ? path.substr(1) : path; | ||
return new URL(normalizedBase + "/" + normalizedPath); | ||
} | ||
exports.concatRelativePath = concatRelativePath; | ||
function urlWithoutTrailingSlash(url) { | ||
return url.endsWith('/') ? url.slice(0, -1) : url; | ||
} | ||
exports.urlWithoutTrailingSlash = urlWithoutTrailingSlash; | ||
//# sourceMappingURL=utils.js.map |
@@ -102,39 +102,2 @@ /*! ***************************************************************************** | ||
function doFetchPurchase(apiUrl, purchaseExternalId, token) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawResponse, response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, fetch(apiUrl + "/host-api/purchase/" + purchaseExternalId + "?secret=" + token, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
if (!rawResponse.ok) { | ||
throw new Error("Request for purchase #" + purchaseExternalId + " failed"); | ||
} | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
response = _b.sent(); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
_a = _b.sent(); | ||
return [2 /*return*/, null]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function delay(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
}); | ||
}); | ||
} | ||
var EventSeverity; | ||
@@ -286,3 +249,55 @@ (function (EventSeverity) { | ||
} | ||
/** | ||
* Concatenates `base` with `path`, always treating `path` as a relative path. Ignores: | ||
* - trailing slash in `base` | ||
* - leading slash in `path` | ||
* @param base base URL, e.g.: 'http://example.com/api' or 'http://example.com/service/api/' | ||
* @param path path to append, e.g.: 'user/getByEmail' or '/swap' | ||
*/ | ||
function concatRelativePath(base, path) { | ||
var normalizedBase = urlWithoutTrailingSlash(base instanceof URL ? base.href : base); | ||
var normalizedPath = path.startsWith('/') ? path.substr(1) : path; | ||
return new URL(normalizedBase + "/" + normalizedPath); | ||
} | ||
function urlWithoutTrailingSlash(url) { | ||
return url.endsWith('/') ? url.slice(0, -1) : url; | ||
} | ||
function doFetchPurchase(apiUrl, purchaseExternalId, token) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawResponse, response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, fetch(concatRelativePath(apiUrl, "/host-api/purchase/" + purchaseExternalId + "?secret=" + token).href, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
if (!rawResponse.ok) { | ||
throw new Error("Request for purchase #" + purchaseExternalId + " failed"); | ||
} | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
response = _b.sent(); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
_a = _b.sent(); | ||
return [2 /*return*/, null]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function delay(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
}); | ||
}); | ||
} | ||
function initWidgetIframeUrl(config) { | ||
@@ -289,0 +304,0 @@ var baseUrl = new URL(config.url || baseWidgetUrl); |
@@ -108,39 +108,2 @@ (function (global, factory) { | ||
function doFetchPurchase(apiUrl, purchaseExternalId, token) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawResponse, response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, fetch(apiUrl + "/host-api/purchase/" + purchaseExternalId + "?secret=" + token, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
if (!rawResponse.ok) { | ||
throw new Error("Request for purchase #" + purchaseExternalId + " failed"); | ||
} | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
response = _b.sent(); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
_a = _b.sent(); | ||
return [2 /*return*/, null]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function delay(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
}); | ||
}); | ||
} | ||
var EventSeverity; | ||
@@ -291,3 +254,55 @@ (function (EventSeverity) { | ||
} | ||
/** | ||
* Concatenates `base` with `path`, always treating `path` as a relative path. Ignores: | ||
* - trailing slash in `base` | ||
* - leading slash in `path` | ||
* @param base base URL, e.g.: 'http://example.com/api' or 'http://example.com/service/api/' | ||
* @param path path to append, e.g.: 'user/getByEmail' or '/swap' | ||
*/ | ||
function concatRelativePath(base, path) { | ||
var normalizedBase = urlWithoutTrailingSlash(base instanceof URL ? base.href : base); | ||
var normalizedPath = path.startsWith('/') ? path.substr(1) : path; | ||
return new URL(normalizedBase + "/" + normalizedPath); | ||
} | ||
function urlWithoutTrailingSlash(url) { | ||
return url.endsWith('/') ? url.slice(0, -1) : url; | ||
} | ||
function doFetchPurchase(apiUrl, purchaseExternalId, token) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawResponse, response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, fetch(concatRelativePath(apiUrl, "/host-api/purchase/" + purchaseExternalId + "?secret=" + token).href, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
if (!rawResponse.ok) { | ||
throw new Error("Request for purchase #" + purchaseExternalId + " failed"); | ||
} | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
response = _b.sent(); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
_a = _b.sent(); | ||
return [2 /*return*/, null]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function delay(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
}); | ||
}); | ||
} | ||
function initWidgetIframeUrl(config) { | ||
@@ -294,0 +309,0 @@ var baseUrl = new URL(config.url || baseWidgetUrl); |
@@ -12,1 +12,10 @@ import { AllWidgetVariants, IHostConfig, TAllEventTypes, TEventListenerDict } from './types'; | ||
export declare function isHtmlElement(element: Element): element is HTMLElement; | ||
/** | ||
* Concatenates `base` with `path`, always treating `path` as a relative path. Ignores: | ||
* - trailing slash in `base` | ||
* - leading slash in `path` | ||
* @param base base URL, e.g.: 'http://example.com/api' or 'http://example.com/service/api/' | ||
* @param path path to append, e.g.: 'user/getByEmail' or '/swap' | ||
*/ | ||
export declare function concatRelativePath(base: string | URL, path: string): URL; | ||
export declare function urlWithoutTrailingSlash(url: string): string; |
{ | ||
"name": "@ramp-network/ramp-instant-sdk", | ||
"version": "2.4.1", | ||
"version": "2.4.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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
313341
2653