MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / _createTunnel

Method _createTunnel

src/common/util/EncryptRequest.js:122–141  ·  view source on GitHub ↗

* @private * @description 创建隧道 * @function EncryptRequest.prototype._createTunnel

()

Source from the content-addressed store, hash-verified

120 * @function EncryptRequest.prototype._createTunnel
121 */
122 async _createTunnel() {
123 if (!this.tunnelUrl) {
124 try {
125 const data = await this._getRSAPublicKey();
126 if (!data) {
127 throw 'fetch RSA publicKey failed';
128 }
129 // 创建隧道
130 const response = await FetchRequest.post(URI(this.serverUrl).segment('services/security/tunnel/v1/tunnels').toString(), data);
131 const result = await response.json();
132 Object.assign(this, {
133 tunnelUrl: result.tunnelUrl,
134 blockedUrlRegex: Object.assign({}, this.blockedUrlRegex, result.blockedUrlRegex)
135 });
136 } catch (error) {
137 console.debug('安全隧道创建失败,错误详情:' + error);
138 }
139 }
140 return this.tunnelUrl;
141 }
142}
143
144/**

Callers 1

requestMethod · 0.95

Calls 2

_getRSAPublicKeyMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected