Skip to content

Commit

Permalink
fix(a3p-integration): Patch Hardened JS compatibility into n:upgrade-…
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Nov 18, 2024
1 parent a41aa25 commit 77a0871
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 7 deletions.
4 changes: 3 additions & 1 deletion a3p-integration/proposals/n:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
"lint-fix": "yarn lint:eslint --fix",
"lint": "run-s --continue-on-error 'lint:*'",
"lint:types": "tsc",
"lint:eslint": "eslint ."
"lint:eslint": "eslint .",
"postinstall": "patch-package"
},
"packageManager": "[email protected]",
"devDependencies": {
"eslint": "^8.57.0",
"npm-run-all": "^4.1.5",
"patch-package": "^8.0.0",
"typescript": "^5.6.3"
}
}
49 changes: 49 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/patches/axios+1.7.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/node_modules/axios/dist/node/.axios.cjs.swp b/node_modules/axios/dist/node/.axios.cjs.swp
new file mode 100644
index 0000000..a905990
Binary files /dev/null and b/node_modules/axios/dist/node/.axios.cjs.swp differ
diff --git a/node_modules/axios/dist/node/axios.cjs b/node_modules/axios/dist/node/axios.cjs
index db4997b..fb39f7e 100644
--- a/node_modules/axios/dist/node/axios.cjs
+++ b/node_modules/axios/dist/node/axios.cjs
@@ -371,9 +371,18 @@ function merge(/* obj1, obj2, obj3, ... */) {
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
forEach(b, (val, key) => {
if (thisArg && isFunction(val)) {
- a[key] = bind(val, thisArg);
- } else {
+ val = bind(val, thisArg);
+ }
+ const oldDesc = Object.getOwnPropertyDescriptor(a, key);
+ if (oldDesc) {
a[key] = val;
+ } else {
+ Object.defineProperty(a, key, {
+ value: val,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ });
}
}, {allOwnKeys});
return a;
@@ -404,7 +413,9 @@ const stripBOM = (content) => {
*/
const inherits = (constructor, superConstructor, props, descriptors) => {
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
- constructor.prototype.constructor = constructor;
+ Object.defineProperty(constructor.prototype, 'constructor', {
+ value: constructor
+ });
Object.defineProperty(constructor, 'super', {
value: superConstructor.prototype
});
@@ -566,7 +577,7 @@ const isRegExp = kindOfTest('RegExp');

const reduceDescriptors = (obj, reducer) => {
const descriptors = Object.getOwnPropertyDescriptors(obj);
- const reducedDescriptors = {};
+ const reducedDescriptors = Object.create(null);

forEach(descriptors, (descriptor, name) => {
let ret;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/node_modules/protobufjs/src/util/.minimal.js.swp b/node_modules/protobufjs/src/util/.minimal.js.swp
new file mode 100644
index 0000000..8605a72
Binary files /dev/null and b/node_modules/protobufjs/src/util/.minimal.js.swp differ
diff --git a/node_modules/protobufjs/src/util/minimal.js b/node_modules/protobufjs/src/util/minimal.js
index 3c406de..564e5da 100644
--- a/node_modules/protobufjs/src/util/minimal.js
+++ b/node_modules/protobufjs/src/util/minimal.js
@@ -280,7 +280,30 @@ function newError(name) {
merge(this, properties);
}

- (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;
+ CustomError.prototype = Object.create(Error.prototype, {
+ constructor: {
+ value: CustomError,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+ },
+ name: {
+ get() { return name; },
+ set: undefined,
+ enumerable: false,
+ // configurable: false would accurately preserve the behavior of
+ // the original, but I'm guessing that was not intentional.
+ // For an actual error subclass, this property would
+ // be configurable.
+ configurable: true,
+ },
+ toString: {
+ value() { return this.name + ": " + this.message; },
+ writable: true,
+ enumerable: false,
+ configurable: true,
+ },
+ });

Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } });

Loading

0 comments on commit 77a0871

Please sign in to comment.