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

@abcnews/dev-proxy

Package Overview
Dependencies
Maintainers
4
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.2.0 to 1.2.1

dist/chunk-5EPSWJ4G.mjs

6

dist/index.js

@@ -54,3 +54,3 @@ "use strict";

}
if (url.hostname.match(domainMatcher) === null) {
if (url.hostname.match(/abc\.net\.au$/) === null) {
return resolve(2 /* NON_ABC_SCRIPT */);

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

domainMatcher = /^(www|newsapp)\.abc\.net\.au$/;
proxy = (project) => new Promise((resolve) => {
proxy = (project) => new Promise((resolve, reject) => {
if (document.location.host.match(domainMatcher) && !document.location.pathname.match(/news-projects/)) {

@@ -130,3 +130,3 @@ return resolve(1 /* IN_PRODUCTION */);

manager2();
resolve(init2(project));
init2(project).then(resolve).catch(reject);
});

@@ -133,0 +133,0 @@ });

{
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",

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

@@ -22,2 +22,3 @@ # Dev script proxy

The `proxy` function returns a promise that will either:
- **resolve successfully**, indicating that the script initialisation should go ahead (i.e. the `.then(init)` part of the above implementation example), or

@@ -27,2 +28,3 @@ - **be rejected**, indicating that an alternative script has been successfully identified and added to the document and the init function should not be run.

For the `proxy` function to successfully identify a script to run instead a few criteria need to be met:
- The script importing the `proxy` function should not have a `NODE_ENV` of 'development' (this prevents infinite loops when this `proxy` function is used on a dev server.

@@ -32,4 +34,4 @@ - The script should not be running on a production URL.

## Bookmarklet
## Usage
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.
As of version 1.2.0 pressing the key combination `Alt-M` when you're in an approprate dev or preview environment offers an easy way to set the appropriate localStorage values to proxy relevant scripts on the page.

@@ -15,3 +15,3 @@ export enum RESOLUTION_REASONS {

export const proxy = (project: string) =>
new Promise<number>((resolve) => {
new Promise<number>((resolve, reject) => {
// Never run on live/production.

@@ -28,4 +28,4 @@ if (

manager();
resolve(init(project));
init(project).then(resolve).catch(reject);
});
});

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

import { RESOLUTION_REASONS, domainMatcher } from '.';
import { RESOLUTION_REASONS } from '.';

@@ -40,3 +40,3 @@ declare global {

// Don't allow proxying of scripts that aren't loaded from the ABC domain.
if (url.hostname.match(domainMatcher) === null) {
if (url.hostname.match(/abc\.net\.au$/) === null) {
return resolve(RESOLUTION_REASONS.NON_ABC_SCRIPT);

@@ -43,0 +43,0 @@ }

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