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

@shopify/app-bridge

Package Overview
Dependencies
Maintainers
19
Versions
322
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/app-bridge - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

2

package.json
{
"name": "@shopify/app-bridge",
"version": "3.6.0",
"version": "3.7.0",
"types": "index.d.ts",

@@ -5,0 +5,0 @@ "main": "index.js",

import type { ClientApplication } from '../../client';
export declare function authenticatedFetch(app: ClientApplication, fetchOperation?: typeof fetch): (uri: RequestInfo, options?: RequestInit) => Promise<Response>;
declare type FetchOperation = (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>;
export interface AuthenticatedFetchOptions {
/**
* The fetch function to perform the network call.
*/
fetchOperation?: FetchOperation;
/**
* The URL to redirect to when the session token is invalid.
* If not provided, `requestFailureReauthorizeUrlHeader` will be used.
*/
reauthorizeUrl?: string;
/**
* The Header parameter.
*/
requestFailureReauthorizeUrlHeader: string;
}
export declare function authenticatedFetch(app: ClientApplication, fetchOperationOrOptions?: FetchOperation | AuthenticatedFetchOptions | undefined): (uri: RequestInfo, options?: RequestInit) => Promise<Response>;
export {};

@@ -51,15 +51,17 @@ "use strict";

exports.authenticatedFetch = void 0;
var actions_1 = require("../../actions");
var session_token_1 = require("./session-token");
function authenticatedFetch(app, fetchOperation) {
function authenticatedFetch(app, fetchOperationOrOptions) {
var _this = this;
if (fetchOperation === void 0) { fetchOperation = fetch; }
if (fetchOperationOrOptions === void 0) { fetchOperationOrOptions = undefined; }
return function (uri, options) {
if (options === void 0) { options = {}; }
return __awaiter(_this, void 0, void 0, function () {
var sessionToken, headers, finalHeaders;
return __generator(this, function (_a) {
switch (_a.label) {
var sessionToken, headers, finalHeaders, authenticatedFetchOptions, fetchOperation, response, reauthorizeUrl_1, requestFailureReauthorizeUrlHeader_1;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, session_token_1.getSessionToken(app)];
case 1:
sessionToken = _a.sent();
sessionToken = _b.sent();
headers = new Headers(options.headers);

@@ -72,3 +74,26 @@ headers.append('Authorization', "Bearer " + sessionToken);

});
return [2 /*return*/, fetchOperation(uri, __assign(__assign({}, options), { headers: finalHeaders }))];
authenticatedFetchOptions = typeof fetchOperationOrOptions === 'object' ? fetchOperationOrOptions : undefined;
fetchOperation = typeof fetchOperationOrOptions === 'function'
? fetchOperationOrOptions
: (_a = authenticatedFetchOptions === null || authenticatedFetchOptions === void 0 ? void 0 : authenticatedFetchOptions.fetchOperation) !== null && _a !== void 0 ? _a : fetch;
return [4 /*yield*/, fetchOperation(uri, __assign(__assign({}, options), { headers: finalHeaders }))];
case 2:
response = _b.sent();
if (authenticatedFetchOptions) {
reauthorizeUrl_1 = authenticatedFetchOptions.reauthorizeUrl, requestFailureReauthorizeUrlHeader_1 = authenticatedFetchOptions.requestFailureReauthorizeUrlHeader;
response.headers.forEach(function (value, name) {
if (requestFailureReauthorizeUrlHeader_1.toLowerCase() === name.toLowerCase()) {
var redirectUrl = new URL(reauthorizeUrl_1 || value, location.href).href;
var redirect = actions_1.Redirect.create(app);
if (redirectUrl) {
redirect.dispatch(actions_1.Redirect.Action.REMOTE, redirectUrl);
}
else {
// eslint-disable-next-line no-console
console.warn("Couldn't find a fallback auth path to redirect to.");
}
}
});
}
return [2 /*return*/, response];
}

@@ -75,0 +100,0 @@ });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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