@renovatebot/pgp 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -30,20 +30,20 @@ let setGlobalName = function(name, value) {
30
30
  new Function("value", name + " = value;")(value);
31
31
  }
32
32
 
33
- function defaults(imports, userExports, options, module) {
33
+ function defaults(imports, userExports, options, module, stringBuiltins) {
34
34
  let context = {
35
35
  exports: null,
36
36
  userExports: userExports,
37
37
  stackDeobfuscator: null
38
38
  };
39
- if (!hasStringBuiltins()) {
39
+ if (!stringBuiltins) {
40
40
  stringImports(imports);
41
41
  }
42
42
  dateImports(imports);
43
43
  consoleImports(imports, context);
44
44
  coreImports(imports, context, options, module);
45
45
  asyncImports(imports, context);
46
- jsoImports(imports, context);
46
+ jsoImports(imports, context, stringBuiltins);
47
47
  imports.teavmMath = Math;
48
48
  return {
49
49
  supplyExports(exports) {
@@ -212,19 +212,25 @@ function coreImports(imports, context, options, module) {
212
212
  },
213
213
  notifyHeapResized: memoryOptions.onResize || function() {}
214
214
  };
215
- if (module && hasImportedMemory(module)) {
216
- let memoryInstance = memoryOptions["external"];
217
- if (!memoryInstance) {
218
- let defaults = getMemoryDefaults(module);
219
- let minSize = memoryOptions.minSize || defaults.min || 0;
220
- let maxSize = memoryOptions.maxSize || defaults.max;
221
- memoryInstance = new WebAssembly.Memory({
222
- shared: memoryOptions.shared === true,
223
- initial: minSize,
224
- maximum: maxSize
225
- });
215
+ if (module) {
216
+ let memDefaults = getMemoryDefaults(module);
217
+ let imported = memDefaults !== null ? memDefaults.imported : hasImportedMemory(module);
218
+ if (imported) {
219
+ let memoryInstance = memoryOptions["external"];
220
+ if (!memoryInstance) {
221
+ if (memDefaults === null) {
222
+ memDefaults = {};
223
+ }
224
+ let minSize = memoryOptions.minSize || memDefaults.min || 0;
225
+ let maxSize = memoryOptions.maxSize || memDefaults.max;
226
+ memoryInstance = new WebAssembly.Memory({
227
+ shared: memoryOptions.shared === true,
228
+ initial: minSize,
229
+ maximum: maxSize
230
+ });
231
+ }
232
+ imports.teavm.memory = memoryInstance;
226
233
  }
227
- imports.teavm.memory = memoryInstance;
228
234
  }
229
235
  }
230
236
 
@@ -250,12 +256,12 @@ function hasImportedMemory(module) {
250
256
  function getMemoryDefaults(module) {
251
257
  let sections = WebAssembly.Module.customSections(module, "teavm.memoryRequirements");
252
258
  if (sections.length !== 1) {
253
- return {};
259
+ return null;
254
260
  }
255
261
  return JSON.parse(new TextDecoder().decode(sections[0]));
256
262
  }
257
263
 
258
- function jsoImports(imports, context) {
264
+ function jsoImports(imports, context, stringBuiltins) {
259
265
  let javaObjectSymbol = Symbol("javaObject");
260
266
  let functionsSymbol = Symbol("functions");
261
267
  let functionOriginSymbol = Symbol("functionOrigin");
@@ -376,7 +382,7 @@ function jsoImports(imports, context) {
376
382
  )(c);
377
383
  }
378
384
  imports.teavmJso = {
379
- stringBuiltinsSupported: () => hasStringBuiltins(),
385
+ stringBuiltinsSupported: () => stringBuiltins,
380
386
  isUndefined: o => typeof o === "undefined",
381
387
  emptyArray: () => [],
382
388
  appendToArray: (array, e) => array.push(e),
@@ -750,7 +756,7 @@ async function load(src, options) {
750
756
 
751
757
  const importObj = {};
752
758
  let userExports = {};
753
- const defaultsResult = defaults(importObj, userExports, options, module);
759
+ const defaultsResult = defaults(importObj, userExports, options, module, await hasStringBuiltins());
754
760
  if (typeof options.installImports !== "undefined") {
755
761
  options.installImports(importObj);
756
762
  }
@@ -793,20 +799,30 @@ async function compileModule(src, isNodeJs) {
793
799
  return result;
794
800
  }
795
801
 
802
+ let hasStringBuiltinsPromise = null;
796
803
  function hasStringBuiltins() {
797
- if (stringBuiltinsCache === null) {
798
- /*
799
- (module
800
- (type (func))
801
- (import "wasm:js-string" "cast" (func (type 0)))
802
- )
803
- */
804
- let bytes = new Int8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 2, 23, 1, 14, 119, 97,
805
- 115, 109, 58, 106, 115, 45, 115, 116, 114, 105, 110, 103, 4, 99, 97, 115, 116, 0, 0, 3, 1, 0,
806
- 5, 4, 1, 1, 0, 0, 10, -127, -128, -128, 0, 0]);
807
- stringBuiltinsCache = !WebAssembly.validate(bytes, {builtins: ["js-string"]});
808
- }
809
- return stringBuiltinsCache;
804
+ if (hasStringBuiltinsPromise === null) {
805
+ hasStringBuiltinsPromise = (async () => {
806
+ // A more sophisticated way to detect string builtins support due to bug in Safari 26.2
807
+ let bytes = new Int8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 7, 1, 96, 1, 127, 1, 100, 111, 2, 31, 1, 14,
808
+ 119, 97, 115, 109, 58, 106, 115, 45, 115, 116, 114, 105, 110, 103, 12, 102, 114, 111, 109, 67, 104,
809
+ 97, 114, 67, 111, 100, 101, 0, 0, 3, 1, 0, 5, 4, 1, 1, 0, 0, 7, 10, 1, 6, 109, 101, 109, 111, 114,
810
+ 121, 2, 0, 10, -127, -128, -128, 0, 0]);
811
+ try {
812
+ let response = new Response(bytes, {
813
+ headers: {
814
+ "Content-Type": "application/wasm"
815
+ }
816
+ });
817
+ let module = await WebAssembly.compileStreaming(response, { builtins: ["js-string"] });
818
+ await WebAssembly.instantiate(module, {}, { builtins: ["js-string"] });
819
+ return true;
820
+ } catch (e) {
821
+ return false;
822
+ }
823
+ })();
824
+ }
825
+ return hasStringBuiltinsPromise;
810
826
  }
811
827
 
812
828
  async function getDeobfuscator(path, options, isNodeJs) {
@@ -815,7 +831,7 @@ async function getDeobfuscator(path, options, isNodeJs) {
815
831
  }
816
832
  try {
817
833
  const importObj = {};
818
- const defaultsResult = defaults(importObj, {}, {});
834
+ const defaultsResult = defaults(importObj, {}, {}, null, await hasStringBuiltins());
819
835
  const instance = await instantiateModule(options.path, path, isNodeJs, importObj);
820
836
  defaultsResult.supplyExports(instance.exports);
821
837
  return instance;
@@ -868,8 +884,6 @@ async function importNodeFs() {
868
884
  return await nodeFsImportObject;
869
885
  }
870
886
 
871
- let stringBuiltinsCache = null;
872
-
873
887
  function createDeobfuscator(module, externalData, deobfuscatorFactory) {
874
888
  let deobfuscator = null;
875
889
  let deobfuscatorInitialized = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renovatebot/pgp",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "PGP library for renovate",
5
5
  "keywords": [
6
6
  "renovate",
@@ -22,18 +22,18 @@
22
22
  "dist/"
23
23
  ],
24
24
  "devDependencies": {
25
- "@containerbase/semantic-release-pnpm": "1.3.20",
25
+ "@containerbase/semantic-release-pnpm": "1.3.24",
26
26
  "@renovatebot/kbpgp": "4.0.4",
27
- "@types/node": "22.19.8",
27
+ "@types/node": "22.19.13",
28
28
  "@vitest/coverage-v8": "4.0.18",
29
- "conventional-changelog-conventionalcommits": "9.1.0",
29
+ "conventional-changelog-conventionalcommits": "9.2.0",
30
30
  "husky": "9.1.7",
31
- "lint-staged": "16.2.7",
32
- "markdownlint-cli2": "0.20.0",
31
+ "lint-staged": "16.3.2",
32
+ "markdownlint-cli2": "0.21.0",
33
33
  "npm-run-all2": "8.0.4",
34
34
  "openpgp": "6.3.0",
35
35
  "prettier": "3.8.1",
36
- "prettier-plugin-packagejson": "2.5.22",
36
+ "prettier-plugin-packagejson": "3.0.0",
37
37
  "semantic-release": "25.0.3",
38
38
  "typescript": "5.9.3",
39
39
  "vitest": "4.0.18"