socket-function 0.77.0 → 0.79.0
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.
- package/SocketFunction.ts +4 -0
- package/package.json +1 -1
- package/require/RequireController.ts +2 -1
- package/require/require.ts +23 -7
- package/src/callHTTPHandler.ts +1 -2
package/SocketFunction.ts
CHANGED
|
@@ -65,6 +65,10 @@ export class SocketFunction {
|
|
|
65
65
|
|
|
66
66
|
public static HTTP_COMPRESS = false;
|
|
67
67
|
|
|
68
|
+
// If you have HTTP resources that require cookies you might to set `SocketFunction.COEP = "require-corp"`
|
|
69
|
+
// - Cross-origin-resource-policy.
|
|
70
|
+
public static COEP = "credentialless";
|
|
71
|
+
|
|
68
72
|
// In retrospect... dynamically changing the wire serializer is a BAD idea. If any calls happen
|
|
69
73
|
// before it is changed, things just break. Also, it needs to be changed on both sides,
|
|
70
74
|
// or else things break. Also, it is very hard to detect when the issue is different serializers
|
package/package.json
CHANGED
|
@@ -243,9 +243,10 @@ class RequireControllerBase {
|
|
|
243
243
|
asyncRequests: module.asyncRequires || {},
|
|
244
244
|
flags: {},
|
|
245
245
|
};
|
|
246
|
+
let flags = modules[module.filename].flags!;
|
|
246
247
|
for (let [flag, value] of Object.entries(module)) {
|
|
247
248
|
if (value === true) {
|
|
248
|
-
|
|
249
|
+
flags[flag] = value;
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
let moduleObj = modules[module.filename];
|
package/require/require.ts
CHANGED
|
@@ -165,7 +165,7 @@ export function requireMain() {
|
|
|
165
165
|
source?: string;
|
|
166
166
|
}
|
|
167
167
|
}} */
|
|
168
|
-
let serializedModules = Object.create(null);
|
|
168
|
+
let serializedModules: { [id: string]: SerializedModule | undefined } = Object.create(null);
|
|
169
169
|
|
|
170
170
|
type ModuleType = {
|
|
171
171
|
id: string;
|
|
@@ -468,7 +468,7 @@ export function requireMain() {
|
|
|
468
468
|
return builtInModuleExports[request as keyof typeof builtInModuleExports];
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
let resolvedPath;
|
|
471
|
+
let resolvedPath: string | undefined;
|
|
472
472
|
if (request in moduleCache) {
|
|
473
473
|
resolvedPath = request;
|
|
474
474
|
} else {
|
|
@@ -512,7 +512,7 @@ export function requireMain() {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
let exportsOverride: unknown | undefined;
|
|
515
|
-
if (resolvedPath === "NOTALLOWEDCLIENTSIDE" || !serializedModules[resolvedPath]
|
|
515
|
+
if (resolvedPath === "NOTALLOWEDCLIENTSIDE" || !serializedModules[resolvedPath]?.allowclient) {
|
|
516
516
|
let childId = resolvedPath === "NOTALLOWEDCLIENTSIDE" ? request : resolvedPath;
|
|
517
517
|
if (serializedModules[resolvedPath]?.serveronly) {
|
|
518
518
|
exportsOverride = new Proxy(
|
|
@@ -540,8 +540,13 @@ export function requireMain() {
|
|
|
540
540
|
if (property === unloadedModule) return true;
|
|
541
541
|
if (property === "default") return exportsOverride;
|
|
542
542
|
|
|
543
|
+
let type = "non-whitelisted";
|
|
544
|
+
if (!serializedModules[resolvedPath!]) {
|
|
545
|
+
type = "missing module";
|
|
546
|
+
}
|
|
547
|
+
|
|
543
548
|
console.warn(
|
|
544
|
-
`Accessed
|
|
549
|
+
`Accessed ${type} module %c${childId}%c, specifically property %c${String(
|
|
545
550
|
property
|
|
546
551
|
)}%c.\n\tAdd %cmodule.allowclient = true%c to the file to allow access.\n\t(IF it is a 3rd party library, use the global "setFlag" helper (in the file you imported the module) to set properties on other modules (it can even recursively set properties)).\n\n\tFrom ${module.id
|
|
547
552
|
}`,
|
|
@@ -623,6 +628,16 @@ export function requireMain() {
|
|
|
623
628
|
}
|
|
624
629
|
|
|
625
630
|
let serializedModule = serializedModules[resolvedId];
|
|
631
|
+
if (!serializedModule) {
|
|
632
|
+
// I can't figure out why this happens as it seems to happen very rarely and only when I'm debugging other code.
|
|
633
|
+
// - I have had it happen immediately after starting the app. Although in theory a hot reload could have
|
|
634
|
+
// triggered due to VS code writing to a file.
|
|
635
|
+
// - I've had times when it happens once after startup and then it goes away and other times where it
|
|
636
|
+
// happens every single time and never goes away until I restart aipaint.
|
|
637
|
+
// - Maybe it happens if we switch servers and so the root paths are different in some way?
|
|
638
|
+
debugger;
|
|
639
|
+
console.warn(`Failed to find module ${resolvedId}. The server should have given an error about this.`, serializedModules);
|
|
640
|
+
}
|
|
626
641
|
|
|
627
642
|
let module = Object.create(null);
|
|
628
643
|
moduleCache[resolvedId] = module;
|
|
@@ -631,14 +646,14 @@ export function requireMain() {
|
|
|
631
646
|
module.exports = {};
|
|
632
647
|
module.exports.default = module.exports;
|
|
633
648
|
module.children = [];
|
|
634
|
-
for (let key in serializedModule
|
|
649
|
+
for (let key in serializedModule?.flags || {}) {
|
|
635
650
|
if (key === "loaded") continue;
|
|
636
651
|
module[key] = true;
|
|
637
652
|
}
|
|
638
653
|
|
|
639
654
|
module.load = load;
|
|
640
655
|
|
|
641
|
-
let originalSource = serializedModule
|
|
656
|
+
let originalSource = serializedModule?.source || "";
|
|
642
657
|
let moduleFnc = wrapSafe(module.id, originalSource);
|
|
643
658
|
|
|
644
659
|
globalThis.onProgressHandler?.({
|
|
@@ -653,7 +668,8 @@ export function requireMain() {
|
|
|
653
668
|
}
|
|
654
669
|
|
|
655
670
|
function load() {
|
|
656
|
-
|
|
671
|
+
const serializedModule = serializedModules[resolvedId];
|
|
672
|
+
if (!serializedModule) return;
|
|
657
673
|
if (!module.loaded) {
|
|
658
674
|
if (alreadyHave) {
|
|
659
675
|
delete alreadyHave.seqNums[serializedModule.seqNum];
|
package/src/callHTTPHandler.ts
CHANGED
|
@@ -65,8 +65,7 @@ export async function httpCallHandler(request: http.IncomingMessage, response: h
|
|
|
65
65
|
{
|
|
66
66
|
response.setHeader("Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload");
|
|
67
67
|
response.setHeader("Cross-Origin-Opener-Policy", "same-origin-allow-popups");
|
|
68
|
-
|
|
69
|
-
response.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
|
|
68
|
+
response.setHeader("Cross-Origin-Embedder-Policy", SocketFunction.COEP);
|
|
70
69
|
|
|
71
70
|
let origin = request.headers.origin || request.headers.referer;
|
|
72
71
|
let allowed = false;
|