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

@abcnews/dev-proxy

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abcnews/dev-proxy - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

12

dist/dev-proxy.cjs.development.js

@@ -5,8 +5,16 @@ 'use strict';

// Checks if a proxy is requested for this project and loads it if required.
(function (RESOLUTION_REASONS) {
RESOLUTION_REASONS[RESOLUTION_REASONS["DEV_ENV"] = 0] = "DEV_ENV";
RESOLUTION_REASONS[RESOLUTION_REASONS["IN_PRODUCTION"] = 1] = "IN_PRODUCTION";
RESOLUTION_REASONS[RESOLUTION_REASONS["NON_ABC_SCRIPT"] = 2] = "NON_ABC_SCRIPT";
RESOLUTION_REASONS[RESOLUTION_REASONS["BAD_SCRIPT_URL"] = 3] = "BAD_SCRIPT_URL";
RESOLUTION_REASONS[RESOLUTION_REASONS["OTHER"] = 4] = "OTHER";
})(exports.RESOLUTION_REASONS || (exports.RESOLUTION_REASONS = {})); // Checks if a proxy is requested for this project and loads it if required.
// The returned promise will only resolve if no proxy is loaded.
var proxy = function proxy(project) {
return new Promise(function (resolve, reject) {
// If we're already in a dev environment, there's nothing to do here.
return resolve(); // Never run on live/production.
return resolve(exports.RESOLUTION_REASONS.DEV_ENV); // Never run on live/production.
});

@@ -13,0 +21,0 @@ };

2

dist/dev-proxy.cjs.production.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.proxy=function(e){return new Promise((function(t,r){if("www.abc.net.au"===document.location.host)return t();var o=localStorage.getItem("proxy_"+e);if(o){var n=document.createElement("script");n.src=o,document.head.appendChild(n);var c="[dev-proxy] Loaded script: "+o+" ("+e+")";return console.info(c),r(c)}t()}))};
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.RESOLUTION_REASONS||(exports.RESOLUTION_REASONS={}))[e.DEV_ENV=0]="DEV_ENV",e[e.IN_PRODUCTION=1]="IN_PRODUCTION",e[e.NON_ABC_SCRIPT=2]="NON_ABC_SCRIPT",e[e.BAD_SCRIPT_URL=3]="BAD_SCRIPT_URL",e[e.OTHER=4]="OTHER",exports.proxy=function(e){return new Promise((function(t,r){if("www.abc.net.au"===document.location.host&&!document.location.pathname.match(/news-projects/))return t(exports.RESOLUTION_REASONS.IN_PRODUCTION);var o;try{o=localStorage.getItem("proxy_"+e)}catch(e){o=null}if(o){var O;try{O=new URL(o)}catch(e){return t(exports.RESOLUTION_REASONS.BAD_SCRIPT_URL)}if(null===O.hostname.match(/abc\.net\.au$/))return t(exports.RESOLUTION_REASONS.NON_ABC_SCRIPT);var n=document.createElement("script");n.src=o,document.head.appendChild(n);var R="[dev-proxy] Loaded script: "+o+" ("+e+")";return console.info(R),r(R)}t(exports.RESOLUTION_REASONS.OTHER)}))};
//# sourceMappingURL=dev-proxy.cjs.production.min.js.map

@@ -1,12 +0,40 @@

// Checks if a proxy is requested for this project and loads it if required.
var RESOLUTION_REASONS;
(function (RESOLUTION_REASONS) {
RESOLUTION_REASONS[RESOLUTION_REASONS["DEV_ENV"] = 0] = "DEV_ENV";
RESOLUTION_REASONS[RESOLUTION_REASONS["IN_PRODUCTION"] = 1] = "IN_PRODUCTION";
RESOLUTION_REASONS[RESOLUTION_REASONS["NON_ABC_SCRIPT"] = 2] = "NON_ABC_SCRIPT";
RESOLUTION_REASONS[RESOLUTION_REASONS["BAD_SCRIPT_URL"] = 3] = "BAD_SCRIPT_URL";
RESOLUTION_REASONS[RESOLUTION_REASONS["OTHER"] = 4] = "OTHER";
})(RESOLUTION_REASONS || (RESOLUTION_REASONS = {})); // Checks if a proxy is requested for this project and loads it if required.
// The returned promise will only resolve if no proxy is loaded.
var proxy = function proxy(project) {
return new Promise(function (resolve, reject) {
// If we're already in a dev environment, there's nothing to do here.
if (process.env.NODE_ENV === 'development') return resolve(); // Never run on live/production.
if (process.env.NODE_ENV === 'development') return resolve(RESOLUTION_REASONS.DEV_ENV); // Never run on live/production.
if (document.location.host === 'www.abc.net.au') return resolve();
var src = localStorage.getItem('proxy_' + project);
if (document.location.host === 'www.abc.net.au' && !document.location.pathname.match(/news-projects/)) return resolve(RESOLUTION_REASONS.IN_PRODUCTION);
var src;
try {
src = localStorage.getItem('proxy_' + project);
} catch (e) {
src = null;
}
if (src) {
var url;
try {
url = new URL(src);
} catch (e) {
return resolve(RESOLUTION_REASONS.BAD_SCRIPT_URL);
}
if (url.hostname.match(/abc\.net\.au$/) === null) {
return resolve(RESOLUTION_REASONS.NON_ABC_SCRIPT);
}
var scr = document.createElement('script');

@@ -20,7 +48,7 @@ scr.src = src;

resolve();
resolve(RESOLUTION_REASONS.OTHER);
});
};
export { proxy };
export { RESOLUTION_REASONS, proxy };
//# sourceMappingURL=dev-proxy.esm.js.map

@@ -1,1 +0,8 @@

export declare const proxy: (project: string) => Promise<void>;
export declare enum RESOLUTION_REASONS {
'DEV_ENV' = 0,
'IN_PRODUCTION' = 1,
'NON_ABC_SCRIPT' = 2,
'BAD_SCRIPT_URL' = 3,
'OTHER' = 4
}
export declare const proxy: (project: string) => Promise<number>;
{
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -21,19 +21,2 @@ # Dev script proxy

You can use <a href="javascript: (function() {
const project = prompt(
'Project',
Array.from(document.querySelectorAll('script[src]'))
.map(x => {
const m = x.getAttribute('src').match(/news-projects\/([\w-]+)/);
return m ? m[1] : false;
})
.filter(d => !!d)
.join(',')
);
if (!project) return;
project.split(',').forEach(project => {
const replace = prompt('Replacement for ' + project);
if (!replace) return;
localStorage['proxy_' + project] = replace;
});
})();">this bookmarklet</a> to help setup the config.
You can use [this bookmarklet](<https://bookmarklet-topaz.vercel.app/?name=Proxy%20news-project&source=!function()%7Bconst%20t%3Dprompt(%22Project%22%2CArray.from(document.querySelectorAll(%22script%5Bsrc%5D%22)).map((t%3D%3E%7Bconst%20r%3Dt.getAttribute(%22src%22).match(%2Fnews-projects%5C%2F(%5B%5Cw-%5D%2B)%2F)%3Breturn!!r%26%26r%5B1%5D%7D)).filter((t%3D%3E!!t)).join(%22%2C%22))%3Bt%26%26t.split(%22%2C%22).forEach((t%3D%3E%7Bconst%20r%3Dprompt(%22Replacement%20for%20%22%2Bt)%3Br%26%26(localStorage%5B%22proxy_%22%2Bt%5D%3Dr)%7D))%7D()%3B>) to help setup the config.

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

export enum RESOLUTION_REASONS {
'DEV_ENV',
'IN_PRODUCTION',
'NON_ABC_SCRIPT',
'BAD_SCRIPT_URL',
'OTHER',
}
// Checks if a proxy is requested for this project and loads it if required.
// The returned promise will only resolve if no proxy is loaded.
export const proxy = (project: string) =>
new Promise<void>((resolve, reject) => {
new Promise<number>((resolve, reject) => {
// If we're already in a dev environment, there's nothing to do here.
if (process.env.NODE_ENV === 'development') return resolve();
if (process.env.NODE_ENV === 'development')
return resolve(RESOLUTION_REASONS.DEV_ENV);
// Never run on live/production.
if (document.location.host === 'www.abc.net.au') return resolve();
if (
document.location.host === 'www.abc.net.au' &&
!document.location.pathname.match(/news-projects/)
)
return resolve(RESOLUTION_REASONS.IN_PRODUCTION);
const src = localStorage.getItem('proxy_' + project);
let src: string | null;
try {
src = localStorage.getItem('proxy_' + project);
} catch (e) {
src = null;
}
if (src) {
let url: URL;
try {
url = new URL(src);
} catch (e) {
return resolve(RESOLUTION_REASONS.BAD_SCRIPT_URL);
}
if (url.hostname.match(/abc\.net\.au$/) === null) {
return resolve(RESOLUTION_REASONS.NON_ABC_SCRIPT);
}
const scr = document.createElement('script');

@@ -21,3 +51,3 @@ scr.src = src;

resolve();
resolve(RESOLUTION_REASONS.OTHER);
});

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