@de./sdk 2.3.0 → 2.3.1
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.
|
@@ -27,10 +27,29 @@ class RealtimeSocket extends Access_1.default {
|
|
|
27
27
|
open(id, options = {}) {
|
|
28
28
|
this.id = id;
|
|
29
29
|
return new Promise((resolve, reject) => {
|
|
30
|
+
/**
|
|
31
|
+
* The document's own origin where there is one, and the configured
|
|
32
|
+
* origin everywhere else.
|
|
33
|
+
*
|
|
34
|
+
* This tested `globalThis.window` and then took `globalThis.origin` on
|
|
35
|
+
* the strength of it. React Native defines `window` and no `origin`, so
|
|
36
|
+
* every native app sent `remoteOrigin: undefined` and de.arch refused
|
|
37
|
+
* the handshake — "Undefined Request Origin". This client could not open
|
|
38
|
+
* a user socket from a native app at all, which is the same shape of
|
|
39
|
+
* mistake `Access` made testing `window && fetch`, with the same result.
|
|
40
|
+
*
|
|
41
|
+
* Reading `origin` is what the value actually is, so nothing has to be
|
|
42
|
+
* assumed about the runtime. `"null"` is what a sandboxed or `file://`
|
|
43
|
+
* document reports for it, and is no more usable to de.arch than
|
|
44
|
+
* nothing — so that falls back too.
|
|
45
|
+
*/
|
|
46
|
+
const documentOrigin = typeof globalThis.origin == 'string' && globalThis.origin !== 'null'
|
|
47
|
+
? globalThis.origin
|
|
48
|
+
: undefined;
|
|
30
49
|
const credentials = async () => ({
|
|
31
50
|
utype: this.utype,
|
|
32
51
|
id,
|
|
33
|
-
remoteOrigin:
|
|
52
|
+
remoteOrigin: documentOrigin || this.remoteOrigin,
|
|
34
53
|
accessToken: options.getToken ? await options.getToken() : this.accessToken
|
|
35
54
|
});
|
|
36
55
|
this.nsp = (0, socket_io_client_1.default)(this.iosHost, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-socket.js","sourceRoot":"","sources":["../../src/allend/realtime-socket.ts"],"names":[],"mappings":";;;;;AAGA,wEAA6C;AAC7C,sDAAoC;AACpC,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AAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClB,MAAA,IAAI,CAAC,GAAG,0CAAE,UAAU,EAAE,CAAA;QACtB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAE,SAAiB,EAAE,KAAa;;QACtC,MAAA,IAAI,CAAC,GAAG,0CAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAjJD,iCAiJC"}
|
package/package.json
CHANGED
|
@@ -75,10 +75,30 @@ export default abstract class RealtimeSocket extends AccessManager {
|
|
|
75
75
|
this.id = id
|
|
76
76
|
|
|
77
77
|
return new Promise( ( resolve, reject ) => {
|
|
78
|
+
/**
|
|
79
|
+
* The document's own origin where there is one, and the configured
|
|
80
|
+
* origin everywhere else.
|
|
81
|
+
*
|
|
82
|
+
* This tested `globalThis.window` and then took `globalThis.origin` on
|
|
83
|
+
* the strength of it. React Native defines `window` and no `origin`, so
|
|
84
|
+
* every native app sent `remoteOrigin: undefined` and de.arch refused
|
|
85
|
+
* the handshake — "Undefined Request Origin". This client could not open
|
|
86
|
+
* a user socket from a native app at all, which is the same shape of
|
|
87
|
+
* mistake `Access` made testing `window && fetch`, with the same result.
|
|
88
|
+
*
|
|
89
|
+
* Reading `origin` is what the value actually is, so nothing has to be
|
|
90
|
+
* assumed about the runtime. `"null"` is what a sandboxed or `file://`
|
|
91
|
+
* document reports for it, and is no more usable to de.arch than
|
|
92
|
+
* nothing — so that falls back too.
|
|
93
|
+
*/
|
|
94
|
+
const documentOrigin = typeof globalThis.origin == 'string' && globalThis.origin !== 'null'
|
|
95
|
+
? globalThis.origin
|
|
96
|
+
: undefined
|
|
97
|
+
|
|
78
98
|
const credentials = async (): Promise<SocketAuthCredentials> => ({
|
|
79
99
|
utype: this.utype,
|
|
80
100
|
id,
|
|
81
|
-
remoteOrigin:
|
|
101
|
+
remoteOrigin: documentOrigin || this.remoteOrigin as string,
|
|
82
102
|
accessToken: options.getToken ? await options.getToken() : this.accessToken as string
|
|
83
103
|
})
|
|
84
104
|
|