request-iframe 0.1.0 → 0.2.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/QUICKSTART.CN.md +4 -2
- package/QUICKSTART.md +4 -2
- package/README.CN.md +302 -54
- package/README.md +281 -36
- package/cdn/request-iframe-react.umd.js +3354 -0
- package/cdn/request-iframe-react.umd.js.map +1 -0
- package/cdn/request-iframe-react.umd.min.js +2 -0
- package/cdn/request-iframe-react.umd.min.js.map +1 -0
- package/cdn/request-iframe.umd.js +19735 -0
- package/cdn/request-iframe.umd.js.map +1 -0
- package/cdn/request-iframe.umd.min.js +4 -0
- package/cdn/request-iframe.umd.min.js.map +1 -0
- package/esm/api/client.js +31 -22
- package/esm/api/endpoint.js +229 -0
- package/esm/api/server.js +19 -9
- package/esm/constants/debug.js +17 -0
- package/esm/constants/index.js +115 -66
- package/esm/constants/log.js +11 -0
- package/esm/constants/messages.js +6 -1
- package/esm/constants/warn-once.js +15 -0
- package/esm/endpoint/facade.js +390 -0
- package/esm/endpoint/heartbeat/heartbeat.js +60 -0
- package/esm/endpoint/heartbeat/ping.js +20 -0
- package/esm/endpoint/index.js +13 -0
- package/esm/endpoint/infra/hub.js +316 -0
- package/esm/endpoint/infra/inbox.js +232 -0
- package/esm/endpoint/infra/outbox.js +408 -0
- package/esm/endpoint/stream/dispatcher.js +58 -0
- package/esm/endpoint/stream/errors.js +27 -0
- package/esm/endpoint/stream/factory.js +76 -0
- package/esm/endpoint/stream/file-auto-resolve.js +34 -0
- package/esm/endpoint/stream/file-writable.js +105 -0
- package/esm/endpoint/stream/handler.js +26 -0
- package/esm/{core → impl}/client.js +243 -320
- package/esm/{core → impl}/response.js +120 -154
- package/esm/impl/server.js +568 -0
- package/esm/index.js +13 -6
- package/esm/message/ack.js +27 -0
- package/esm/message/channel-cache.js +108 -0
- package/esm/message/channel.js +92 -5
- package/esm/message/dispatcher.js +149 -98
- package/esm/stream/error.js +22 -0
- package/esm/stream/index.js +3 -1
- package/esm/stream/readable-stream.js +101 -26
- package/esm/stream/stream-core.js +121 -3
- package/esm/stream/writable-stream.js +368 -43
- package/esm/utils/ack.js +36 -0
- package/esm/utils/blob.js +16 -0
- package/esm/utils/cache.js +25 -76
- package/esm/utils/content-type.js +81 -0
- package/esm/utils/debug.js +157 -180
- package/esm/utils/hooks.js +130 -0
- package/esm/utils/id.js +14 -0
- package/esm/utils/iframe.js +20 -0
- package/esm/utils/index.js +12 -162
- package/esm/utils/is.js +3 -0
- package/esm/utils/logger.js +55 -0
- package/esm/utils/origin.js +3 -1
- package/esm/utils/promise.js +3 -0
- package/esm/utils/window.js +31 -0
- package/library/api/client.d.ts.map +1 -1
- package/library/api/client.js +32 -23
- package/library/api/endpoint.d.ts +23 -0
- package/library/api/endpoint.d.ts.map +1 -0
- package/library/api/endpoint.js +235 -0
- package/library/api/server.d.ts +4 -1
- package/library/api/server.d.ts.map +1 -1
- package/library/api/server.js +19 -9
- package/library/constants/debug.d.ts +18 -0
- package/library/constants/debug.d.ts.map +1 -0
- package/library/constants/debug.js +23 -0
- package/library/constants/index.d.ts +58 -7
- package/library/constants/index.d.ts.map +1 -1
- package/library/constants/index.js +143 -67
- package/library/constants/log.d.ts +12 -0
- package/library/constants/log.d.ts.map +1 -0
- package/library/constants/log.js +17 -0
- package/library/constants/messages.d.ts +6 -1
- package/library/constants/messages.d.ts.map +1 -1
- package/library/constants/messages.js +6 -1
- package/library/constants/warn-once.d.ts +12 -0
- package/library/constants/warn-once.d.ts.map +1 -0
- package/library/constants/warn-once.js +22 -0
- package/library/endpoint/facade.d.ts +238 -0
- package/library/endpoint/facade.d.ts.map +1 -0
- package/library/endpoint/facade.js +398 -0
- package/library/endpoint/heartbeat/heartbeat.d.ts +34 -0
- package/library/endpoint/heartbeat/heartbeat.d.ts.map +1 -0
- package/library/endpoint/heartbeat/heartbeat.js +67 -0
- package/library/endpoint/heartbeat/ping.d.ts +18 -0
- package/library/endpoint/heartbeat/ping.d.ts.map +1 -0
- package/library/endpoint/heartbeat/ping.js +26 -0
- package/library/endpoint/index.d.ts +16 -0
- package/library/endpoint/index.d.ts.map +1 -0
- package/library/endpoint/index.js +114 -0
- package/library/endpoint/infra/hub.d.ts +170 -0
- package/library/endpoint/infra/hub.d.ts.map +1 -0
- package/library/endpoint/infra/hub.js +323 -0
- package/library/endpoint/infra/inbox.d.ts +73 -0
- package/library/endpoint/infra/inbox.d.ts.map +1 -0
- package/library/endpoint/infra/inbox.js +239 -0
- package/library/endpoint/infra/outbox.d.ts +149 -0
- package/library/endpoint/infra/outbox.d.ts.map +1 -0
- package/library/endpoint/infra/outbox.js +415 -0
- package/library/endpoint/stream/dispatcher.d.ts +33 -0
- package/library/endpoint/stream/dispatcher.d.ts.map +1 -0
- package/library/endpoint/stream/dispatcher.js +66 -0
- package/library/endpoint/stream/errors.d.ts +20 -0
- package/library/endpoint/stream/errors.d.ts.map +1 -0
- package/library/endpoint/stream/errors.js +32 -0
- package/library/endpoint/stream/factory.d.ts +44 -0
- package/library/endpoint/stream/factory.d.ts.map +1 -0
- package/library/endpoint/stream/factory.js +82 -0
- package/library/endpoint/stream/file-auto-resolve.d.ts +26 -0
- package/library/endpoint/stream/file-auto-resolve.d.ts.map +1 -0
- package/library/endpoint/stream/file-auto-resolve.js +41 -0
- package/library/endpoint/stream/file-writable.d.ts +33 -0
- package/library/endpoint/stream/file-writable.d.ts.map +1 -0
- package/library/endpoint/stream/file-writable.js +115 -0
- package/library/endpoint/stream/handler.d.ts +20 -0
- package/library/endpoint/stream/handler.d.ts.map +1 -0
- package/library/endpoint/stream/handler.js +32 -0
- package/library/{core → impl}/client.d.ts +16 -13
- package/library/impl/client.d.ts.map +1 -0
- package/library/{core → impl}/client.js +254 -333
- package/library/{core → impl}/request.d.ts.map +1 -1
- package/library/{core → impl}/response.d.ts +7 -12
- package/library/impl/response.d.ts.map +1 -0
- package/library/{core → impl}/response.js +120 -154
- package/library/{core → impl}/server.d.ts +26 -55
- package/library/impl/server.d.ts.map +1 -0
- package/library/impl/server.js +575 -0
- package/library/index.d.ts +13 -6
- package/library/index.d.ts.map +1 -1
- package/library/index.js +16 -16
- package/library/message/ack.d.ts +15 -0
- package/library/message/ack.d.ts.map +1 -0
- package/library/message/ack.js +33 -0
- package/library/message/channel-cache.d.ts +26 -0
- package/library/message/channel-cache.d.ts.map +1 -0
- package/library/message/channel-cache.js +115 -0
- package/library/message/channel.d.ts +53 -6
- package/library/message/channel.d.ts.map +1 -1
- package/library/message/channel.js +96 -9
- package/library/message/dispatcher.d.ts +17 -0
- package/library/message/dispatcher.d.ts.map +1 -1
- package/library/message/dispatcher.js +149 -98
- package/library/stream/error.d.ts +24 -0
- package/library/stream/error.d.ts.map +1 -0
- package/library/stream/error.js +29 -0
- package/library/stream/index.d.ts +4 -1
- package/library/stream/index.d.ts.map +1 -1
- package/library/stream/index.js +7 -4
- package/library/stream/readable-stream.d.ts.map +1 -1
- package/library/stream/readable-stream.js +102 -27
- package/library/stream/stream-core.d.ts +22 -1
- package/library/stream/stream-core.d.ts.map +1 -1
- package/library/stream/stream-core.js +120 -2
- package/library/stream/types.d.ts +115 -2
- package/library/stream/types.d.ts.map +1 -1
- package/library/stream/writable-stream.d.ts +20 -2
- package/library/stream/writable-stream.d.ts.map +1 -1
- package/library/stream/writable-stream.js +366 -41
- package/library/types/index.d.ts +17 -22
- package/library/types/index.d.ts.map +1 -1
- package/library/utils/ack.d.ts +2 -0
- package/library/utils/ack.d.ts.map +1 -0
- package/library/utils/ack.js +44 -0
- package/library/utils/blob.d.ts +3 -0
- package/library/utils/blob.d.ts.map +1 -0
- package/library/utils/blob.js +22 -0
- package/library/utils/cache.d.ts +10 -20
- package/library/utils/cache.d.ts.map +1 -1
- package/library/utils/cache.js +25 -79
- package/library/utils/content-type.d.ts +13 -0
- package/library/utils/content-type.d.ts.map +1 -0
- package/library/utils/content-type.js +87 -0
- package/library/utils/debug.d.ts.map +1 -1
- package/library/utils/debug.js +156 -178
- package/library/utils/hooks.d.ts +30 -0
- package/library/utils/hooks.d.ts.map +1 -0
- package/library/utils/hooks.js +139 -0
- package/library/utils/id.d.ts +9 -0
- package/library/utils/id.d.ts.map +1 -0
- package/library/utils/id.js +21 -0
- package/library/utils/iframe.d.ts +5 -0
- package/library/utils/iframe.d.ts.map +1 -0
- package/library/utils/iframe.js +25 -0
- package/library/utils/index.d.ts +7 -34
- package/library/utils/index.d.ts.map +1 -1
- package/library/utils/index.js +58 -193
- package/library/utils/is.d.ts +2 -0
- package/library/utils/is.d.ts.map +1 -0
- package/library/utils/is.js +9 -0
- package/library/utils/logger.d.ts +13 -0
- package/library/utils/logger.d.ts.map +1 -0
- package/library/utils/logger.js +63 -0
- package/library/utils/origin.d.ts.map +1 -1
- package/library/utils/origin.js +2 -1
- package/library/utils/promise.d.ts +2 -0
- package/library/utils/promise.d.ts.map +1 -0
- package/library/utils/promise.js +9 -0
- package/library/utils/window.d.ts +2 -0
- package/library/utils/window.d.ts.map +1 -0
- package/library/utils/window.js +38 -0
- package/package.json +49 -2
- package/react/package.json +2 -1
- package/esm/core/client-server.js +0 -329
- package/esm/core/server.js +0 -767
- package/esm/utils/ack-meta.js +0 -53
- package/library/core/client-server.d.ts +0 -106
- package/library/core/client-server.d.ts.map +0 -1
- package/library/core/client-server.js +0 -336
- package/library/core/client.d.ts.map +0 -1
- package/library/core/response.d.ts.map +0 -1
- package/library/core/server.d.ts.map +0 -1
- package/library/core/server.js +0 -772
- package/library/utils/ack-meta.d.ts +0 -2
- package/library/utils/ack-meta.d.ts.map +0 -1
- package/library/utils/ack-meta.js +0 -59
- /package/esm/{core → impl}/request.js +0 -0
- /package/library/{core → impl}/request.d.ts +0 -0
- /package/library/{core → impl}/request.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/impl/request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAAE,cAAc,EAAE,eAAe,EAC/C,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IAC9C,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,cAAc,CAAC;gBAGzB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,cAAc,EACxB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;CAkBtC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ServerResponse, CookieOptions, SendOptions, SendFileOptions } from '../types';
|
|
2
2
|
import { IframeWritableStream } from '../stream';
|
|
3
|
-
import {
|
|
3
|
+
import { RequestIframeEndpointOutbox } from '../endpoint';
|
|
4
4
|
/**
|
|
5
5
|
* Callback waiting for client acknowledgment
|
|
6
6
|
*/
|
|
7
|
-
type AckCallback = (received: boolean,
|
|
7
|
+
type AckCallback = (received: boolean, ack?: any) => void;
|
|
8
8
|
type OnSentCallback = () => void;
|
|
9
9
|
/**
|
|
10
10
|
* ServerResponse implementation
|
|
@@ -14,30 +14,25 @@ export declare class ServerResponseImpl implements ServerResponse {
|
|
|
14
14
|
headers: Record<string, string | string[]>;
|
|
15
15
|
private readonly requestId;
|
|
16
16
|
private readonly path;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly targetWindow;
|
|
19
|
-
private readonly targetOrigin;
|
|
20
|
-
private readonly channel;
|
|
17
|
+
private readonly peer;
|
|
21
18
|
private readonly registerStreamHandler?;
|
|
22
19
|
private readonly unregisterStreamHandler?;
|
|
23
20
|
private readonly heartbeat?;
|
|
24
|
-
/** Target client ID (usually the creatorId of the original request) */
|
|
25
|
-
private readonly targetId?;
|
|
26
21
|
/** Server instance ID (for creatorId in responses) */
|
|
27
22
|
private readonly serverId?;
|
|
28
23
|
private onAckCallback?;
|
|
29
24
|
private onSentCallback?;
|
|
30
25
|
_sent: boolean;
|
|
31
|
-
constructor(requestId: string, path: string,
|
|
26
|
+
constructor(requestId: string, path: string, serverId?: string, peer?: RequestIframeEndpointOutbox, options?: {
|
|
32
27
|
registerStreamHandler?: (streamId: string, handler: (data: any) => void) => void;
|
|
33
28
|
unregisterStreamHandler?: (streamId: string) => void;
|
|
34
29
|
heartbeat?: () => Promise<boolean>;
|
|
35
30
|
onSent?: OnSentCallback;
|
|
36
31
|
});
|
|
37
32
|
/**
|
|
38
|
-
* Send message via
|
|
33
|
+
* Send message via bound peer
|
|
39
34
|
*/
|
|
40
|
-
private
|
|
35
|
+
private sendResponseMessage;
|
|
41
36
|
/**
|
|
42
37
|
* Check if header exists (case-insensitive)
|
|
43
38
|
*/
|
|
@@ -58,7 +53,7 @@ export declare class ServerResponseImpl implements ServerResponse {
|
|
|
58
53
|
/**
|
|
59
54
|
* Trigger client acknowledgment callback
|
|
60
55
|
*/
|
|
61
|
-
_triggerAck(received: boolean,
|
|
56
|
+
_triggerAck(received: boolean, ack?: any): void;
|
|
62
57
|
/**
|
|
63
58
|
* Mark response as sent (and trigger onSent callback once).
|
|
64
59
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/impl/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,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K,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,aAAa,GACtB,cAAc;IA4BV,WAAW,CAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,aAAa,GACtB,cAAc;CAkBlB"}
|
|
@@ -14,10 +14,11 @@ require("core-js/modules/es.promise.js");
|
|
|
14
14
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
var
|
|
17
|
+
var _cookie = require("../utils/cookie");
|
|
18
|
+
var _contentType = require("../utils/content-type");
|
|
18
19
|
var _constants = require("../constants");
|
|
19
20
|
var _stream = require("../stream");
|
|
20
|
-
var
|
|
21
|
+
var _endpoint = require("../endpoint");
|
|
21
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
24
|
/**
|
|
@@ -28,18 +29,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
28
29
|
* ServerResponse implementation
|
|
29
30
|
*/
|
|
30
31
|
class ServerResponseImpl {
|
|
31
|
-
constructor(requestId, path,
|
|
32
|
+
constructor(requestId, path, serverId, peer, options) {
|
|
32
33
|
(0, _defineProperty2.default)(this, "statusCode", _constants.HttpStatus.OK);
|
|
33
34
|
(0, _defineProperty2.default)(this, "headers", {});
|
|
34
35
|
(0, _defineProperty2.default)(this, "_sent", false);
|
|
35
36
|
this.requestId = requestId;
|
|
36
37
|
this.path = path;
|
|
37
|
-
this.secretKey = secretKey;
|
|
38
|
-
this.targetWindow = targetWindow;
|
|
39
|
-
this.targetOrigin = targetOrigin;
|
|
40
|
-
this.channel = channel;
|
|
41
38
|
this.serverId = serverId;
|
|
42
|
-
this.
|
|
39
|
+
this.peer = peer;
|
|
43
40
|
this.registerStreamHandler = options === null || options === void 0 ? void 0 : options.registerStreamHandler;
|
|
44
41
|
this.unregisterStreamHandler = options === null || options === void 0 ? void 0 : options.unregisterStreamHandler;
|
|
45
42
|
this.heartbeat = options === null || options === void 0 ? void 0 : options.heartbeat;
|
|
@@ -47,11 +44,10 @@ class ServerResponseImpl {
|
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
50
|
-
* Send message via
|
|
47
|
+
* Send message via bound peer
|
|
51
48
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.channel.send(this.targetWindow, message, this.targetOrigin);
|
|
49
|
+
sendResponseMessage(data) {
|
|
50
|
+
return this.peer.sendMessage(_constants.MessageType.RESPONSE, this.requestId, data);
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
/**
|
|
@@ -67,7 +63,7 @@ class ServerResponseImpl {
|
|
|
67
63
|
* Returns null if Content-Type should not be auto-set
|
|
68
64
|
*/
|
|
69
65
|
detectContentType(data) {
|
|
70
|
-
return (0,
|
|
66
|
+
return (0, _contentType.detectContentType)(data, {
|
|
71
67
|
checkStream: true,
|
|
72
68
|
isIframeWritableStream: _stream.isIframeWritableStream
|
|
73
69
|
});
|
|
@@ -94,9 +90,9 @@ class ServerResponseImpl {
|
|
|
94
90
|
/**
|
|
95
91
|
* Trigger client acknowledgment callback
|
|
96
92
|
*/
|
|
97
|
-
_triggerAck(received,
|
|
93
|
+
_triggerAck(received, ack) {
|
|
98
94
|
if (this.onAckCallback) {
|
|
99
|
-
this.onAckCallback(received,
|
|
95
|
+
this.onAckCallback(received, ack);
|
|
100
96
|
this.onAckCallback = undefined;
|
|
101
97
|
}
|
|
102
98
|
}
|
|
@@ -129,22 +125,24 @@ class ServerResponseImpl {
|
|
|
129
125
|
if (this._sent) return Promise.resolve(false);
|
|
130
126
|
this.markSent();
|
|
131
127
|
var requireAck = (_options$requireAck = options === null || options === void 0 ? void 0 : options.requireAck) !== null && _options$requireAck !== void 0 ? _options$requireAck : false;
|
|
132
|
-
|
|
128
|
+
/**
|
|
129
|
+
* When requireAck is enabled, attach a unique ack payload by default so ACK can be
|
|
130
|
+
* unambiguously associated with this send.
|
|
131
|
+
*
|
|
132
|
+
* NOTE: ack is an internal reserved field (not part of public API).
|
|
133
|
+
*/
|
|
134
|
+
var expectedAck = (0, _endpoint.buildExpectedAck)(requireAck, options === null || options === void 0 ? void 0 : options.ack);
|
|
133
135
|
try {
|
|
134
136
|
// If acknowledgment not required, send directly and return true
|
|
135
137
|
if (!requireAck) {
|
|
136
|
-
this.
|
|
138
|
+
this.sendResponseMessage({
|
|
137
139
|
path: this.path,
|
|
138
|
-
secretKey: this.secretKey,
|
|
139
140
|
data,
|
|
140
141
|
status: this.statusCode,
|
|
141
142
|
statusText: (0, _constants.getStatusText)(this.statusCode),
|
|
142
143
|
headers: this.headers,
|
|
143
|
-
requireAck: false
|
|
144
|
-
|
|
145
|
-
creatorId: this.serverId,
|
|
146
|
-
targetId: this.targetId
|
|
147
|
-
}));
|
|
144
|
+
requireAck: false
|
|
145
|
+
});
|
|
148
146
|
return Promise.resolve(true);
|
|
149
147
|
}
|
|
150
148
|
|
|
@@ -156,25 +154,21 @@ class ServerResponseImpl {
|
|
|
156
154
|
resolve(false);
|
|
157
155
|
return;
|
|
158
156
|
}
|
|
159
|
-
if (
|
|
157
|
+
if (!(0, _endpoint.isExpectedAckMatch)(expectedAck, receivedAckMeta)) {
|
|
160
158
|
resolve(false);
|
|
161
159
|
return;
|
|
162
160
|
}
|
|
163
161
|
resolve(true);
|
|
164
162
|
});
|
|
165
|
-
this.
|
|
163
|
+
this.sendResponseMessage({
|
|
166
164
|
path: this.path,
|
|
167
|
-
secretKey: this.secretKey,
|
|
168
165
|
data,
|
|
169
166
|
status: this.statusCode,
|
|
170
167
|
statusText: (0, _constants.getStatusText)(this.statusCode),
|
|
171
168
|
headers: this.headers,
|
|
172
169
|
requireAck: true,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
creatorId: this.serverId,
|
|
176
|
-
targetId: this.targetId
|
|
177
|
-
}));
|
|
170
|
+
ack: expectedAck
|
|
171
|
+
});
|
|
178
172
|
} catch (error) {
|
|
179
173
|
// If window is closed, reject immediately
|
|
180
174
|
if ((error === null || error === void 0 ? void 0 : error.code) === _constants.ErrorCode.TARGET_WINDOW_CLOSED) {
|
|
@@ -201,47 +195,59 @@ class ServerResponseImpl {
|
|
|
201
195
|
*/
|
|
202
196
|
send(data, options) {
|
|
203
197
|
var _this = this;
|
|
204
|
-
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
while (1) switch (_context.prev = _context.next) {
|
|
198
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
199
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
200
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
208
201
|
case 0:
|
|
209
202
|
if (!_this._sent) {
|
|
210
|
-
|
|
203
|
+
_context2.next = 1;
|
|
211
204
|
break;
|
|
212
205
|
}
|
|
213
|
-
return
|
|
206
|
+
return _context2.abrupt("return", Promise.resolve(false));
|
|
214
207
|
case 1:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
208
|
+
return _context2.abrupt("return", _this.peer.send({
|
|
209
|
+
data,
|
|
210
|
+
onStream: function () {
|
|
211
|
+
var _onStream = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(stream) {
|
|
212
|
+
return _regenerator.default.wrap(function (_context) {
|
|
213
|
+
while (1) switch (_context.prev = _context.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
_context.next = 1;
|
|
216
|
+
return _this.sendStream(stream);
|
|
217
|
+
case 1:
|
|
218
|
+
return _context.abrupt("return", true);
|
|
219
|
+
case 2:
|
|
220
|
+
case "end":
|
|
221
|
+
return _context.stop();
|
|
222
|
+
}
|
|
223
|
+
}, _callee);
|
|
224
|
+
}));
|
|
225
|
+
function onStream(_x) {
|
|
226
|
+
return _onStream.apply(this, arguments);
|
|
227
|
+
}
|
|
228
|
+
return onStream;
|
|
229
|
+
}(),
|
|
230
|
+
onFileOrBlob: () => {
|
|
231
|
+
// Extract options for sendFile
|
|
232
|
+
var fileOptions = _objectSpread({
|
|
233
|
+
requireAck: options === null || options === void 0 ? void 0 : options.requireAck
|
|
234
|
+
}, typeof File !== 'undefined' && data instanceof File ? {
|
|
235
|
+
mimeType: data.type,
|
|
236
|
+
fileName: data.name
|
|
237
|
+
} : {});
|
|
238
|
+
return _this.sendFile(data, fileOptions);
|
|
239
|
+
},
|
|
240
|
+
onOther: () => {
|
|
241
|
+
// For other types, auto-detect and set Content-Type, then send
|
|
242
|
+
_this.ensureContentTypeIfNeeded(data);
|
|
243
|
+
return _this._sendRaw(data, options);
|
|
244
|
+
}
|
|
245
|
+
}));
|
|
221
246
|
case 2:
|
|
222
|
-
return _context.abrupt("return", true);
|
|
223
|
-
case 3:
|
|
224
|
-
if (!(typeof File !== 'undefined' && data instanceof File || typeof Blob !== 'undefined' && data instanceof Blob)) {
|
|
225
|
-
_context.next = 4;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
// Extract options for sendFile
|
|
229
|
-
fileOptions = _objectSpread({
|
|
230
|
-
requireAck: options === null || options === void 0 ? void 0 : options.requireAck
|
|
231
|
-
}, typeof File !== 'undefined' && data instanceof File ? {
|
|
232
|
-
mimeType: data.type,
|
|
233
|
-
fileName: data.name
|
|
234
|
-
} : {});
|
|
235
|
-
return _context.abrupt("return", _this.sendFile(data, fileOptions));
|
|
236
|
-
case 4:
|
|
237
|
-
// For other types, auto-detect and set Content-Type, then send
|
|
238
|
-
_this.ensureContentTypeIfNeeded(data);
|
|
239
|
-
return _context.abrupt("return", _this._sendRaw(data, options));
|
|
240
|
-
case 5:
|
|
241
247
|
case "end":
|
|
242
|
-
return
|
|
248
|
+
return _context2.stop();
|
|
243
249
|
}
|
|
244
|
-
},
|
|
250
|
+
}, _callee2);
|
|
245
251
|
}))();
|
|
246
252
|
}
|
|
247
253
|
json(data, options) {
|
|
@@ -250,7 +256,6 @@ class ServerResponseImpl {
|
|
|
250
256
|
sendFile(content, options) {
|
|
251
257
|
var _this2 = this;
|
|
252
258
|
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
253
|
-
var mimeType, fileName, fileContent, stream;
|
|
254
259
|
return _regenerator.default.wrap(function (_context3) {
|
|
255
260
|
while (1) switch (_context3.prev = _context3.next) {
|
|
256
261
|
case 0:
|
|
@@ -260,77 +265,43 @@ class ServerResponseImpl {
|
|
|
260
265
|
}
|
|
261
266
|
return _context3.abrupt("return", false);
|
|
262
267
|
case 1:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
// If it's a plain string, convert to base64
|
|
270
|
-
fileContent = btoa(unescape(encodeURIComponent(content)));
|
|
271
|
-
_context3.next = 6;
|
|
272
|
-
break;
|
|
273
|
-
case 2:
|
|
274
|
-
if (!(content instanceof File)) {
|
|
275
|
-
_context3.next = 4;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
mimeType = content.type || mimeType;
|
|
279
|
-
fileName = fileName || content.name;
|
|
280
|
-
_context3.next = 3;
|
|
281
|
-
return (0, _utils.blobToBase64)(content);
|
|
282
|
-
case 3:
|
|
283
|
-
fileContent = _context3.sent;
|
|
284
|
-
_context3.next = 6;
|
|
285
|
-
break;
|
|
286
|
-
case 4:
|
|
287
|
-
_context3.next = 5;
|
|
288
|
-
return (0, _utils.blobToBase64)(content);
|
|
289
|
-
case 5:
|
|
290
|
-
fileContent = _context3.sent;
|
|
291
|
-
case 6:
|
|
292
|
-
// Set file-related headers
|
|
293
|
-
_this2.setHeader(_constants.HttpHeader.CONTENT_TYPE, mimeType);
|
|
294
|
-
if (fileName) {
|
|
295
|
-
_this2.setHeader(_constants.HttpHeader.CONTENT_DISPOSITION, `attachment; filename="${fileName}"`);
|
|
296
|
-
} else {
|
|
297
|
-
_this2.setHeader(_constants.HttpHeader.CONTENT_DISPOSITION, 'attachment');
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Create file stream with autoResolve enabled
|
|
301
|
-
stream = new _stream.IframeFileWritableStream({
|
|
302
|
-
filename: fileName || 'file',
|
|
303
|
-
mimeType,
|
|
268
|
+
_context3.next = 2;
|
|
269
|
+
return _this2.peer.sendFile({
|
|
270
|
+
content,
|
|
271
|
+
fileName: options === null || options === void 0 ? void 0 : options.fileName,
|
|
272
|
+
mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
|
|
304
273
|
chunked: false,
|
|
305
|
-
// File is sent in one chunk
|
|
306
274
|
autoResolve: true,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return _context2.stop();
|
|
320
|
-
}
|
|
321
|
-
}, _callee2);
|
|
322
|
-
}));
|
|
323
|
-
function next() {
|
|
324
|
-
return _next.apply(this, arguments);
|
|
275
|
+
defaultFileName: 'file',
|
|
276
|
+
defaultMimeType: 'application/octet-stream',
|
|
277
|
+
onFileInfo: ({
|
|
278
|
+
fileName,
|
|
279
|
+
mimeType
|
|
280
|
+
}) => {
|
|
281
|
+
// Set file-related headers
|
|
282
|
+
_this2.setHeader(_constants.HttpHeader.CONTENT_TYPE, mimeType);
|
|
283
|
+
if (fileName) {
|
|
284
|
+
_this2.setHeader(_constants.HttpHeader.CONTENT_DISPOSITION, `attachment; filename="${fileName}"`);
|
|
285
|
+
} else {
|
|
286
|
+
_this2.setHeader(_constants.HttpHeader.CONTENT_DISPOSITION, 'attachment');
|
|
325
287
|
}
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
288
|
+
_this2.markSent();
|
|
289
|
+
},
|
|
290
|
+
stream: {
|
|
291
|
+
bind: {
|
|
292
|
+
requestId: _this2.requestId,
|
|
293
|
+
registerStreamHandler: _this2.registerStreamHandler,
|
|
294
|
+
unregisterStreamHandler: _this2.unregisterStreamHandler,
|
|
295
|
+
heartbeat: _this2.heartbeat,
|
|
296
|
+
serverId: _this2.serverId,
|
|
297
|
+
targetId: _this2.peer.defaultTargetId
|
|
298
|
+
},
|
|
299
|
+
awaitStart: true
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
case 2:
|
|
332
303
|
return _context3.abrupt("return", true);
|
|
333
|
-
case
|
|
304
|
+
case 3:
|
|
334
305
|
case "end":
|
|
335
306
|
return _context3.stop();
|
|
336
307
|
}
|
|
@@ -354,27 +325,22 @@ class ServerResponseImpl {
|
|
|
354
325
|
}
|
|
355
326
|
return _context4.abrupt("return");
|
|
356
327
|
case 1:
|
|
357
|
-
_this3.markSent();
|
|
358
|
-
|
|
359
|
-
// Window check is handled in MessageDispatcher when stream sends messages
|
|
360
|
-
|
|
361
|
-
// Bind stream to request context
|
|
362
|
-
stream._bind({
|
|
363
|
-
requestId: _this3.requestId,
|
|
364
|
-
targetWindow: _this3.targetWindow,
|
|
365
|
-
targetOrigin: _this3.targetOrigin,
|
|
366
|
-
secretKey: _this3.secretKey,
|
|
367
|
-
channel: _this3.channel,
|
|
368
|
-
registerStreamHandler: _this3.registerStreamHandler,
|
|
369
|
-
unregisterStreamHandler: _this3.unregisterStreamHandler,
|
|
370
|
-
heartbeat: _this3.heartbeat,
|
|
371
|
-
serverId: _this3.serverId,
|
|
372
|
-
targetId: _this3.targetId
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
// Start stream transmission
|
|
376
328
|
_context4.next = 2;
|
|
377
|
-
return
|
|
329
|
+
return _this3.peer.sendStream({
|
|
330
|
+
stream: stream,
|
|
331
|
+
bind: {
|
|
332
|
+
requestId: _this3.requestId,
|
|
333
|
+
registerStreamHandler: _this3.registerStreamHandler,
|
|
334
|
+
unregisterStreamHandler: _this3.unregisterStreamHandler,
|
|
335
|
+
heartbeat: _this3.heartbeat,
|
|
336
|
+
serverId: _this3.serverId,
|
|
337
|
+
targetId: _this3.peer.defaultTargetId
|
|
338
|
+
},
|
|
339
|
+
awaitStart: true,
|
|
340
|
+
beforeStart: () => {
|
|
341
|
+
_this3.markSent();
|
|
342
|
+
}
|
|
343
|
+
});
|
|
378
344
|
case 2:
|
|
379
345
|
case "end":
|
|
380
346
|
return _context4.stop();
|
|
@@ -418,7 +384,7 @@ class ServerResponseImpl {
|
|
|
418
384
|
* Generate Set-Cookie string and add to headers[HttpHeader.SET_COOKIE] array
|
|
419
385
|
* Client will parse and save to cookie storage upon receiving
|
|
420
386
|
*/
|
|
421
|
-
var setCookieStr = (0,
|
|
387
|
+
var setCookieStr = (0, _cookie.createSetCookie)(name, value, {
|
|
422
388
|
path: options === null || options === void 0 ? void 0 : options.path,
|
|
423
389
|
expires: options === null || options === void 0 ? void 0 : options.expires,
|
|
424
390
|
maxAge: options === null || options === void 0 ? void 0 : options.maxAge,
|
|
@@ -441,7 +407,7 @@ class ServerResponseImpl {
|
|
|
441
407
|
* Clear specified Cookie
|
|
442
408
|
* Generate an expired Set-Cookie string, client will delete this cookie upon receiving
|
|
443
409
|
*/
|
|
444
|
-
var setCookieStr = (0,
|
|
410
|
+
var setCookieStr = (0, _cookie.createClearCookie)(name, {
|
|
445
411
|
path: options === null || options === void 0 ? void 0 : options.path
|
|
446
412
|
});
|
|
447
413
|
|
|
@@ -23,35 +23,41 @@ export interface ServerOptions {
|
|
|
23
23
|
* Used to mitigate message explosion caused by abnormal code or attacks.
|
|
24
24
|
*/
|
|
25
25
|
maxConcurrentRequestsPerClient?: number;
|
|
26
|
+
/** Advanced: auto-ack echo limit for ack.meta length (internal). */
|
|
27
|
+
autoAckMaxMetaLength?: number;
|
|
28
|
+
/** Advanced: auto-ack echo limit for ack.id length (internal). */
|
|
29
|
+
autoAckMaxIdLength?: number;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* RequestIframeServer implementation
|
|
29
33
|
* Uses shared MessageDispatcher (backed by MessageChannel) to listen for and send messages
|
|
30
34
|
*/
|
|
31
35
|
export declare class RequestIframeServerImpl implements RequestIframeServer {
|
|
36
|
+
private static readonly PENDING_ACKS;
|
|
37
|
+
private static readonly PENDING_PONGS;
|
|
38
|
+
private static readonly PENDING_STREAM_REQUESTS;
|
|
39
|
+
private static readonly LIMIT_IN_FLIGHT_BY_CLIENT;
|
|
32
40
|
/** Unique instance ID */
|
|
33
41
|
readonly id: string;
|
|
34
|
-
private readonly
|
|
42
|
+
private readonly endpoint;
|
|
43
|
+
private readonly hub;
|
|
35
44
|
private readonly ackTimeout;
|
|
36
|
-
private readonly versionValidator;
|
|
37
45
|
private readonly handlers;
|
|
38
46
|
private readonly middlewares;
|
|
39
47
|
private readonly originValidator?;
|
|
40
48
|
private readonly maxConcurrentRequestsPerClient;
|
|
41
|
-
private readonly inFlightByClientKey;
|
|
42
|
-
/** Responses waiting for client acknowledgment */
|
|
43
|
-
private readonly pendingAcks;
|
|
44
|
-
/** Pending pings waiting for client PONG (server -> client heartbeat) */
|
|
45
|
-
private readonly pendingPongs;
|
|
46
|
-
/** Pending requests waiting for client stream_start (streamId present) */
|
|
47
|
-
private readonly pendingStreamRequests;
|
|
48
|
-
/** Stream message handlers (streamId -> handler) for client→server streams */
|
|
49
|
-
private readonly streamHandlers;
|
|
50
|
-
/** List of functions to unregister handlers */
|
|
51
|
-
private readonly unregisterFns;
|
|
52
|
-
/** Whether it is open */
|
|
53
|
-
private _isOpen;
|
|
54
49
|
constructor(options?: ServerOptions);
|
|
50
|
+
private get dispatcher();
|
|
51
|
+
/** Message isolation key (read-only) */
|
|
52
|
+
get secretKey(): string | undefined;
|
|
53
|
+
/** Whether message handling is enabled */
|
|
54
|
+
get isOpen(): boolean;
|
|
55
|
+
/** Enable message handling (register message handler) */
|
|
56
|
+
open(): void;
|
|
57
|
+
/** Disable message handling (unregister message handler, but don't release resources) */
|
|
58
|
+
close(): void;
|
|
59
|
+
/** Get the underlying MessageDispatcher */
|
|
60
|
+
get messageDispatcher(): MessageDispatcher;
|
|
55
61
|
/**
|
|
56
62
|
* Check whether an incoming message origin is allowed.
|
|
57
63
|
*/
|
|
@@ -61,45 +67,10 @@ export declare class RequestIframeServerImpl implements RequestIframeServer {
|
|
|
61
67
|
* We intentionally include origin to prevent cross-origin collisions.
|
|
62
68
|
*/
|
|
63
69
|
private getClientKey;
|
|
64
|
-
private incInFlight;
|
|
65
|
-
private decInFlight;
|
|
66
|
-
/**
|
|
67
|
-
* Open message processing (register message handlers)
|
|
68
|
-
*/
|
|
69
|
-
open(): void;
|
|
70
|
-
/**
|
|
71
|
-
* Close message processing (unregister message handlers, but don't release channel)
|
|
72
|
-
*/
|
|
73
|
-
close(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Whether it is open
|
|
76
|
-
*/
|
|
77
|
-
get isOpen(): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Register message handlers
|
|
80
|
-
*/
|
|
81
|
-
private registerHandlers;
|
|
82
|
-
/** Handle stream_start from client (stream request with streamId) */
|
|
83
|
-
private handleStreamStart;
|
|
84
|
-
private dispatchStreamMessage;
|
|
85
70
|
/**
|
|
86
71
|
* Handle protocol version error
|
|
87
72
|
*/
|
|
88
73
|
private handleVersionError;
|
|
89
|
-
/**
|
|
90
|
-
* Handle ping message
|
|
91
|
-
*/
|
|
92
|
-
private handlePing;
|
|
93
|
-
private handlePong;
|
|
94
|
-
private pingClient;
|
|
95
|
-
/**
|
|
96
|
-
* Handle received acknowledgment
|
|
97
|
-
*/
|
|
98
|
-
private handleReceived;
|
|
99
|
-
/** Get secretKey */
|
|
100
|
-
get secretKey(): string | undefined;
|
|
101
|
-
/** Get the underlying MessageDispatcher */
|
|
102
|
-
get messageDispatcher(): MessageDispatcher;
|
|
103
74
|
private handleRequestError;
|
|
104
75
|
private handleRequestResult;
|
|
105
76
|
/**
|
|
@@ -112,10 +83,6 @@ export declare class RequestIframeServerImpl implements RequestIframeServer {
|
|
|
112
83
|
* Handle request
|
|
113
84
|
*/
|
|
114
85
|
private handleRequest;
|
|
115
|
-
/**
|
|
116
|
-
* Register pending acknowledgment response
|
|
117
|
-
*/
|
|
118
|
-
private registerPendingAck;
|
|
119
86
|
use(middleware: Middleware): void;
|
|
120
87
|
use(path: PathMatcher, middleware: Middleware): void;
|
|
121
88
|
on(path: string, handler: ServerHandler): () => void;
|
|
@@ -123,7 +90,11 @@ export declare class RequestIframeServerImpl implements RequestIframeServer {
|
|
|
123
90
|
off(path: string | string[]): void;
|
|
124
91
|
map(handlers: Record<string, ServerHandler>): (() => void);
|
|
125
92
|
/**
|
|
126
|
-
*
|
|
93
|
+
* Cleanup before destroy
|
|
94
|
+
*/
|
|
95
|
+
private cleanup;
|
|
96
|
+
/**
|
|
97
|
+
* Destroy server (close and release resources)
|
|
127
98
|
*/
|
|
128
99
|
destroy(): void;
|
|
129
100
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/impl/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,UAAU,CAAC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