@itwin/core-common 5.0.0-dev.75 → 5.0.0-dev.76
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/lib/cjs/rpc/core/RpcRegistry.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcRegistry.js.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.d.ts +1 -1
- package/lib/cjs/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.d.ts +3 -0
- package/lib/cjs/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.js +1 -6
- package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.js +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts +0 -2
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js +2 -10
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
- package/lib/esm/rpc/core/RpcRegistry.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcRegistry.js.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.d.ts +1 -1
- package/lib/esm/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.d.ts +3 -0
- package/lib/esm/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.js +1 -6
- package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.js +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts +0 -2
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.js +2 -10
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAuC,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAA0B,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"WebAppRpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAuC,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAA0B,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB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M;cAqB3C,qBAAqB,CAAC,IAAI,EAAE,MAAM;cAQrC,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA2CnD,sDAAsD;IACtD,SAAS,CAAC,WAAW,IAAI,OAAO,KAAK;IAIrC,wDAAwD;IACxD,SAAS,CAAC,aAAa,IAAI,OAAO,OAAO;YAI3B,YAAY;YAkBZ,QAAQ;YAMR,UAAU;YAMV,aAAa;YAMb,cAAc;IAa5B,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,kBAAkB;IAkB1B,gBAAgB;IAChB,OAAc,OAAO;kCACa,iBAAiB,YAAY,oBAAoB,gBAAgB,qBAAqB,QAAQ,iBAAiB,QAAQ,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAAC;kCAGzJ,iBAAiB,QAAQ,iBAAiB,KAAG,OAAO,CAAC,oBAAoB,CAAC;MAG1G;CACH"}
|
|
@@ -156,7 +156,7 @@ export class WebAppRpcRequest extends RpcRequest {
|
|
|
156
156
|
async performFetch() {
|
|
157
157
|
const requestClass = this.supplyRequest();
|
|
158
158
|
const fetchFunction = this.supplyFetch();
|
|
159
|
-
const path = new URL(this.path, typeof
|
|
159
|
+
const path = new URL(this.path, typeof location !== "undefined" ? location.origin : undefined);
|
|
160
160
|
if (this._pathSuffix) {
|
|
161
161
|
const params = new URLSearchParams();
|
|
162
162
|
params.set("parameters", this._pathSuffix);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MA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,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7C,IAAI,WAAW,CAAC,MAAM,IAAI,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;gBAC/D,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;gBAC/B,OAAO;YACT,CAAC;QACH,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,OAAO,GAAG;QACtB,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,QAA8B,EAAE,YAAmC,EAAE,IAAuB,EAAE,IAAwB,EAAiB,EAAE;YAC1L,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,IAAuB,EAAiC,EAAE;YAC3G,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\nimport { RpcInterface } from \"../../RpcInterface\";\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\nimport { RpcMultipart } from \"./RpcMultipart\";\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\n\n/** A web application RPC request.\n * @internal\n */\nexport class WebAppRpcRequest extends RpcRequest {\n private _loading: boolean = false;\n private _request: RequestInit = {};\n private _pathSuffix: string = \"\";\n private get _headers() { return this._request.headers as { [key: string]: string }; }\n\n /** The maximum size permitted for an encoded component in a URL.\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\n * In addition to the url size, an authorization header may also add considerably to the request size.\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\n */\n public static maxUrlComponentSize = 1024 * 8;\n\n /** The HTTP method for this request. */\n public override method: HttpMethod_T;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\n\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\n public metadata = { status: 0, message: \"\" };\n\n /** Parses a request. */\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\n return this.backend.parseRequest(protocol, req);\n }\n\n /** Sends the response for a web request. */\n public static async sendResponse(\n protocol: WebAppRpcProtocol,\n request: SerializedRpcRequest,\n fulfillment: RpcRequestFulfillment,\n req: HttpServerRequest,\n res: HttpServerResponse,\n ): Promise<void> {\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\n }\n\n /** Determines the most efficient transport type for an RPC value. */\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\n return RpcContentType.Binary;\n } else if (value.data.length > 0) {\n return RpcContentType.Multipart;\n } else if (value.stream) {\n return RpcContentType.Stream;\n } else {\n return RpcContentType.Text;\n }\n }\n\n /** Constructs a web application request. */\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\n super(client, operation, parameters);\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\n this.method = \"head\";\n this._request.headers = {};\n }\n\n /** Sets request header values. */\n protected setHeader(name: string, value: string): void {\n this._headers[name] = value;\n }\n\n /** Sends the request. */\n protected async send(): Promise<number> {\n this._loading = true;\n await this.setupTransport();\n\n return new Promise<number>(async (resolve, reject) => {\n try {\n resolve(await this.performFetch());\n } catch (reason) {\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\n }\n });\n }\n\n protected override computeRetryAfter(attempts: number): number {\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\n if (retryAfter) {\n this.resetTransientFaultCount();\n\n const r = Number(retryAfter);\n if (Number.isFinite(r)) {\n return r * 1000;\n }\n\n const d = Date.parse(retryAfter);\n if (!Number.isNaN(d)) {\n return d - Date.now();\n }\n } else {\n this.recordTransientFault();\n }\n\n return super.computeRetryAfter(attempts);\n }\n\n protected override handleUnknownResponse(code: number) {\n if (this.protocol.isTimeout(code)) {\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\n } else {\n this.reject(new ServerError(code, \"Unknown server response code.\"));\n }\n }\n\n protected async load(): Promise<RpcSerializedValue> {\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\n try {\n if (!this._loading)\n return;\n\n const response = this._response;\n if (!response) {\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\n return;\n }\n\n if (this.protocol.protocolVersionHeaderName) {\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\n if (version) {\n this.responseProtocolVersion = parseInt(version, 10);\n }\n }\n\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\n\n if (responseType === RpcContentType.Binary) {\n resolve(await this.loadBinary(response));\n } else if (responseType === RpcContentType.Multipart) {\n resolve(await this.loadMultipart(response, contentType!));\n } else {\n resolve(await this.loadText(response));\n }\n\n this._loading = false;\n this.setLastUpdatedTime();\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\n } catch (reason) {\n if (!this._loading)\n return;\n\n this._loading = false;\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\n }\n });\n }\n\n /** Override to supply an alternate fetch function. */\n protected supplyFetch(): typeof fetch {\n return fetch;\n }\n\n /** Override to supply an alternate Request function. */\n protected supplyRequest(): typeof Request {\n return Request;\n }\n\n private async performFetch(): Promise<number> {\n const requestClass = this.supplyRequest();\n const fetchFunction = this.supplyFetch();\n\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\n if (this._pathSuffix) {\n const params = new URLSearchParams();\n params.set(\"parameters\", this._pathSuffix);\n path.search = `?${params.toString()}`;\n }\n\n const request = new requestClass(path.toString(), this._request);\n const response = await fetchFunction(request);\n this._response = response;\n this.metadata.status = response.status;\n return response.status;\n }\n\n private async loadText(response: Response) {\n const value = await response.text();\n this.metadata.message = value;\n return RpcSerializedValue.create(value);\n }\n\n private async loadBinary(response: Response) {\n const value = new Uint8Array(await response.arrayBuffer());\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\n return RpcSerializedValue.create(objects, [value]);\n }\n\n private async loadMultipart(response: Response, contentType: string) {\n const data = await response.arrayBuffer();\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\n return value;\n }\n\n private async setupTransport(): Promise<void> {\n const parameters = (await this.protocol.serialize(this)).parameters;\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\n\n if (transportType === RpcContentType.Binary) {\n this.setupBinaryTransport(parameters);\n } else if (transportType === RpcContentType.Multipart) {\n this.setupMultipartTransport(parameters);\n } else {\n this.setupTextTransport(parameters);\n }\n }\n\n private setupBinaryTransport(parameters: RpcSerializedValue) {\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\n this._request.method = \"post\";\n this._request.body = parameters.data[0];\n }\n\n private setupMultipartTransport(parameters: RpcSerializedValue) {\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._request.method = \"post\";\n this._request.body = RpcMultipart.createForm(parameters);\n }\n\n private setupTextTransport(parameters: RpcSerializedValue) {\n if (this.operation.policy.allowResponseCaching(this)) {\n const encodedBody = btoa(parameters.objects);\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\n this._request.method = \"get\";\n this._request.body = undefined;\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._pathSuffix = encodedBody;\n return;\n }\n }\n\n this._pathSuffix = \"\";\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\n this._request.method = \"post\";\n this._request.body = parameters.objects;\n }\n\n /** @internal */\n public static backend = {\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"WebAppRpcRequest.js","sourceRoot":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Aa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\nimport { RpcInterface } from \"../../RpcInterface\";\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\nimport { RpcMultipart } from \"./RpcMultipart\";\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\ndeclare const location: any;\n\n/** @internal */\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\n\n/** A web application RPC request.\n * @internal\n */\nexport class WebAppRpcRequest extends RpcRequest {\n private _loading: boolean = false;\n private _request: RequestInit = {};\n private _pathSuffix: string = \"\";\n private get _headers() { return this._request.headers as { [key: string]: string }; }\n\n /** The maximum size permitted for an encoded component in a URL.\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\n * In addition to the url size, an authorization header may also add considerably to the request size.\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\n */\n public static maxUrlComponentSize = 1024 * 8;\n\n /** The HTTP method for this request. */\n public override method: HttpMethod_T;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\n\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\n public metadata = { status: 0, message: \"\" };\n\n /** Parses a request. */\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\n return this.backend.parseRequest(protocol, req);\n }\n\n /** Sends the response for a web request. */\n public static async sendResponse(\n protocol: WebAppRpcProtocol,\n request: SerializedRpcRequest,\n fulfillment: RpcRequestFulfillment,\n req: HttpServerRequest,\n res: HttpServerResponse,\n ): Promise<void> {\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\n }\n\n /** Determines the most efficient transport type for an RPC value. */\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\n return RpcContentType.Binary;\n } else if (value.data.length > 0) {\n return RpcContentType.Multipart;\n } else if (value.stream) {\n return RpcContentType.Stream;\n } else {\n return RpcContentType.Text;\n }\n }\n\n /** Constructs a web application request. */\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\n super(client, operation, parameters);\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\n this.method = \"head\";\n this._request.headers = {};\n }\n\n /** Sets request header values. */\n protected setHeader(name: string, value: string): void {\n this._headers[name] = value;\n }\n\n /** Sends the request. */\n protected async send(): Promise<number> {\n this._loading = true;\n await this.setupTransport();\n\n return new Promise<number>(async (resolve, reject) => {\n try {\n resolve(await this.performFetch());\n } catch (reason) {\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\n }\n });\n }\n\n protected override computeRetryAfter(attempts: number): number {\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\n if (retryAfter) {\n this.resetTransientFaultCount();\n\n const r = Number(retryAfter);\n if (Number.isFinite(r)) {\n return r * 1000;\n }\n\n const d = Date.parse(retryAfter);\n if (!Number.isNaN(d)) {\n return d - Date.now();\n }\n } else {\n this.recordTransientFault();\n }\n\n return super.computeRetryAfter(attempts);\n }\n\n protected override handleUnknownResponse(code: number) {\n if (this.protocol.isTimeout(code)) {\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\n } else {\n this.reject(new ServerError(code, \"Unknown server response code.\"));\n }\n }\n\n protected async load(): Promise<RpcSerializedValue> {\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\n try {\n if (!this._loading)\n return;\n\n const response = this._response;\n if (!response) {\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\n return;\n }\n\n if (this.protocol.protocolVersionHeaderName) {\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\n if (version) {\n this.responseProtocolVersion = parseInt(version, 10);\n }\n }\n\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\n\n if (responseType === RpcContentType.Binary) {\n resolve(await this.loadBinary(response));\n } else if (responseType === RpcContentType.Multipart) {\n resolve(await this.loadMultipart(response, contentType!));\n } else {\n resolve(await this.loadText(response));\n }\n\n this._loading = false;\n this.setLastUpdatedTime();\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\n } catch (reason) {\n if (!this._loading)\n return;\n\n this._loading = false;\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\n }\n });\n }\n\n /** Override to supply an alternate fetch function. */\n protected supplyFetch(): typeof fetch {\n return fetch;\n }\n\n /** Override to supply an alternate Request function. */\n protected supplyRequest(): typeof Request {\n return Request;\n }\n\n private async performFetch(): Promise<number> {\n const requestClass = this.supplyRequest();\n const fetchFunction = this.supplyFetch();\n\n const path = new URL(this.path, typeof location !== \"undefined\" ? location.origin : undefined);\n if (this._pathSuffix) {\n const params = new URLSearchParams();\n params.set(\"parameters\", this._pathSuffix);\n path.search = `?${params.toString()}`;\n }\n\n const request = new requestClass(path.toString(), this._request);\n const response = await fetchFunction(request);\n this._response = response;\n this.metadata.status = response.status;\n return response.status;\n }\n\n private async loadText(response: Response) {\n const value = await response.text();\n this.metadata.message = value;\n return RpcSerializedValue.create(value);\n }\n\n private async loadBinary(response: Response) {\n const value = new Uint8Array(await response.arrayBuffer());\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\n return RpcSerializedValue.create(objects, [value]);\n }\n\n private async loadMultipart(response: Response, contentType: string) {\n const data = await response.arrayBuffer();\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\n return value;\n }\n\n private async setupTransport(): Promise<void> {\n const parameters = (await this.protocol.serialize(this)).parameters;\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\n\n if (transportType === RpcContentType.Binary) {\n this.setupBinaryTransport(parameters);\n } else if (transportType === RpcContentType.Multipart) {\n this.setupMultipartTransport(parameters);\n } else {\n this.setupTextTransport(parameters);\n }\n }\n\n private setupBinaryTransport(parameters: RpcSerializedValue) {\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\n this._request.method = \"post\";\n this._request.body = parameters.data[0];\n }\n\n private setupMultipartTransport(parameters: RpcSerializedValue) {\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._request.method = \"post\";\n this._request.body = RpcMultipart.createForm(parameters);\n }\n\n private setupTextTransport(parameters: RpcSerializedValue) {\n if (this.operation.policy.allowResponseCaching(this)) {\n const encodedBody = btoa(parameters.objects);\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\n this._request.method = \"get\";\n this._request.body = undefined;\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._pathSuffix = encodedBody;\n return;\n }\n }\n\n this._pathSuffix = \"\";\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\n this._request.method = \"post\";\n this._request.body = parameters.objects;\n }\n\n /** @internal */\n public static backend = {\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcMultipartParser.d.ts","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAIA;;GAEG;AA6BH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA0B9D,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"RpcMultipartParser.d.ts","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAIA;;GAEG;AA6BH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA0B9D,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,MAAM,CAAqB;gBAEhB,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAoCnD,KAAK,IAAI,kBAAkB;IAqOlC,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,kBAAkB;CAE3B"}
|
|
@@ -60,8 +60,6 @@ export class RpcMultipartParser {
|
|
|
60
60
|
_headerValueMark;
|
|
61
61
|
_partDataMark;
|
|
62
62
|
_partBoundaryFlag;
|
|
63
|
-
_headerFieldDecoder;
|
|
64
|
-
_headerValueDecoder;
|
|
65
63
|
_headerField;
|
|
66
64
|
_partHeaders;
|
|
67
65
|
_partName;
|
|
@@ -86,8 +84,6 @@ export class RpcMultipartParser {
|
|
|
86
84
|
if (!boundary) {
|
|
87
85
|
throw new Error("content-type missing boundary");
|
|
88
86
|
}
|
|
89
|
-
this._headerFieldDecoder = null;
|
|
90
|
-
this._headerValueDecoder = null;
|
|
91
87
|
this._headerField = "";
|
|
92
88
|
this._partHeaders = {};
|
|
93
89
|
this._partName = null;
|
|
@@ -321,16 +317,14 @@ export class RpcMultipartParser {
|
|
|
321
317
|
this._partHeaders = {};
|
|
322
318
|
this._partName = null;
|
|
323
319
|
this._partChunks.length = 0;
|
|
324
|
-
this._headerFieldDecoder = new TextDecoder("utf8");
|
|
325
320
|
this._headerField = "";
|
|
326
|
-
this._headerValueDecoder = new TextDecoder("utf8");
|
|
327
321
|
this._headerValue = "";
|
|
328
322
|
}
|
|
329
323
|
_onParseHeaderField(b) {
|
|
330
|
-
this._headerField +=
|
|
324
|
+
this._headerField += new TextDecoder("utf8").decode(b);
|
|
331
325
|
}
|
|
332
326
|
_onParseHeaderValue(b) {
|
|
333
|
-
this._headerValue +=
|
|
327
|
+
this._headerValue += new TextDecoder("utf8").decode(b);
|
|
334
328
|
}
|
|
335
329
|
_onParseHeaderEnd() {
|
|
336
330
|
this._headerField = this._headerField.toLowerCase();
|
|
@@ -345,9 +339,7 @@ export class RpcMultipartParser {
|
|
|
345
339
|
else if (this._headerField === "content-transfer-encoding") {
|
|
346
340
|
// this._partTransferEncoding = this._headerValue.toLowerCase();
|
|
347
341
|
}
|
|
348
|
-
this._headerFieldDecoder = new TextDecoder("utf8");
|
|
349
342
|
this._headerField = "";
|
|
350
|
-
this._headerValueDecoder = new TextDecoder("utf8");
|
|
351
343
|
this._headerValue = "";
|
|
352
344
|
}
|
|
353
345
|
_onParsePartData(b) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcMultipartParser.js","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BE;AACF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,MAAM,MAAM,GAAG,EAAE,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M,QAAQ,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3C,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,eAAe;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5F,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEO,kBAAkB,CAAC,OAAe;IAC1C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\n/*\nAdapted from https://github.com/pillarjs/multiparty. Multiparty license as follows:\n(The MIT License)\n\nCopyright (c) 2013 Felix Geisendörfer\nCopyright (c) 2014 Andrew Kelley\nCopyright (c) 2014 Douglas Christopher Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\nimport { RpcSerializedValue } from \"../../core/RpcMarshaling\";\n\nconst START = 0;\nconst START_BOUNDARY = 1;\nconst HEADER_FIELD_START = 2;\nconst HEADER_FIELD = 3;\nconst HEADER_VALUE_START = 4;\nconst HEADER_VALUE = 5;\nconst HEADER_VALUE_ALMOST_DONE = 6;\nconst HEADERS_ALMOST_DONE = 7;\nconst PART_DATA_START = 8;\nconst PART_DATA = 9;\nconst CLOSE_BOUNDARY = 10;\nconst END = 11;\n\nconst LF = 10;\nconst CR = 13;\nconst SPACE = 32;\nconst HYPHEN = 45;\nconst COLON = 58;\nconst A = 97;\nconst Z = 122;\n\nconst CONTENT_TYPE_RE = /^multipart\\/(?:form-data|related)(?:;|$)/i;\nconst CONTENT_TYPE_PARAM_RE = /;\\s*([^=]+)=(?:\"([^\"]+)\"|([^;]+))/gi;\n\n/** @internal */\nexport class RpcMultipartParser {\n private _headerFieldMark: number | null;\n private _headerValueMark: number | null;\n private _partDataMark: number | null;\n private _partBoundaryFlag: boolean;\n private _headerFieldDecoder: TextDecoder | null;\n private _headerValueDecoder: TextDecoder | null;\n private _headerField: string;\n private _partHeaders: { [index: string]: string };\n private _partName: string | null;\n private _partChunks: Uint8Array[];\n private _headerValue: string;\n private _boundary: string;\n private _buffer: Uint8Array;\n private _value: RpcSerializedValue;\n\n public constructor(contentType: string, buffer: Uint8Array) {\n let m = CONTENT_TYPE_RE.exec(contentType);\n if (!m) {\n throw new Error(\"unsupported content-type\");\n }\n\n let boundary = \"\";\n CONTENT_TYPE_PARAM_RE.lastIndex = m.index + m[0].length - 1;\n while ((m = CONTENT_TYPE_PARAM_RE.exec(contentType))) {\n if (m[1].toLowerCase() !== \"boundary\")\n continue;\n\n boundary = m[2] || m[3];\n break;\n }\n\n if (!boundary) {\n throw new Error(\"content-type missing boundary\");\n }\n\n this._headerFieldDecoder = null;\n this._headerValueDecoder = null;\n this._headerField = \"\";\n this._partHeaders = {};\n this._partName = null;\n this._partChunks = [];\n this._headerValue = \"\";\n\n this._headerFieldMark = null;\n this._headerValueMark = null;\n this._partDataMark = null;\n this._partBoundaryFlag = false;\n\n this._boundary = boundary;\n this._buffer = buffer;\n this._value = RpcSerializedValue.create();\n }\n\n public parse(): RpcSerializedValue {\n let i = 0;\n const len = this._buffer.length;\n let prevIndex = 0;\n let index = 0;\n let state = START;\n\n const boundary = new Uint8Array(this._boundary.length + 4);\n const boundaryEncoder = new TextEncoder(); // encodes utf8 only\n boundaryEncoder.encodeInto(\"\\r\\n--\", boundary.subarray(0));\n boundaryEncoder.encodeInto(this._boundary, boundary.subarray(4));\n\n const boundaryChars: { [index: number]: boolean } = {};\n for (const char of boundary) {\n boundaryChars[char] = true;\n }\n\n const boundaryLength = boundary.length;\n const boundaryEnd = boundaryLength - 1;\n const bufferLength = this._buffer.length;\n const lookbehind = new Uint8Array(boundaryLength + 8);\n\n let c;\n let cl;\n\n for (i = 0; i < len; i++) {\n c = this._buffer[i];\n switch (state) {\n case START:\n index = 0;\n state = START_BOUNDARY;\n /* falls through */\n case START_BOUNDARY:\n if (index === boundaryLength - 2 && c === HYPHEN) {\n index = 1;\n state = CLOSE_BOUNDARY;\n break;\n } else if (index === boundaryLength - 2) {\n if (c !== CR)\n throw new Error(`Expected CR Received ${c}`);\n\n index++;\n break;\n } else if (index === boundaryLength - 1) {\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n index = 0;\n this._onParsePartBegin();\n state = HEADER_FIELD_START;\n break;\n }\n\n if (c !== boundary[index + 2])\n index = -2;\n\n if (c === boundary[index + 2])\n index++;\n\n break;\n case HEADER_FIELD_START:\n state = HEADER_FIELD;\n this._headerFieldMark = i;\n index = 0;\n /* falls through */\n case HEADER_FIELD:\n if (c === CR) {\n this._headerFieldMark = null;\n state = HEADERS_ALMOST_DONE;\n break;\n }\n\n index++;\n if (c === HYPHEN)\n break;\n\n if (c === COLON) {\n if (index === 1) {\n // empty header field\n throw new Error(\"Empty header field\");\n }\n this._onParseHeaderField(this._buffer.subarray(this._headerFieldMark as number, i));\n this._headerFieldMark = null;\n state = HEADER_VALUE_START;\n break;\n }\n\n cl = c | 0x20;\n if (cl < A || cl > Z) {\n throw new Error(`Expected alphabetic character, received ${c}`);\n }\n break;\n case HEADER_VALUE_START:\n if (c === SPACE)\n break;\n\n this._headerValueMark = i;\n state = HEADER_VALUE;\n /* falls through */\n case HEADER_VALUE:\n if (c === CR) {\n this._onParseHeaderValue(this._buffer.subarray(this._headerValueMark as number, i));\n this._headerValueMark = null;\n this._onParseHeaderEnd();\n state = HEADER_VALUE_ALMOST_DONE;\n }\n break;\n case HEADER_VALUE_ALMOST_DONE:\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n state = HEADER_FIELD_START;\n break;\n case HEADERS_ALMOST_DONE:\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n const err: any = this._onParseHeadersEnd(i + 1);\n if (err)\n throw err;\n\n state = PART_DATA_START;\n break;\n case PART_DATA_START:\n state = PART_DATA;\n this._partDataMark = i;\n /* falls through */\n case PART_DATA:\n prevIndex = index;\n\n if (index === 0) {\n // boyer-moore derived algorithm to safely skip non-boundary data\n i += boundaryEnd;\n while (i < bufferLength && !(this._buffer[i] in boundaryChars)) {\n i += boundaryLength;\n }\n i -= boundaryEnd;\n c = this._buffer[i];\n }\n\n if (index < boundaryLength) {\n if (boundary[index] === c) {\n if (index === 0) {\n this._onParsePartData(this._buffer.subarray(this._partDataMark as number, i));\n this._partDataMark = null;\n }\n index++;\n } else {\n index = 0;\n }\n } else if (index === boundaryLength) {\n index++;\n if (c === CR) {\n // CR = part boundary\n this._partBoundaryFlag = true;\n } else if (c === HYPHEN) {\n index = 1;\n state = CLOSE_BOUNDARY;\n break;\n } else {\n index = 0;\n }\n } else if (index - 1 === boundaryLength) {\n if (this._partBoundaryFlag) {\n index = 0;\n if (c === LF) {\n this._partBoundaryFlag = false;\n this._onParsePartEnd();\n this._onParsePartBegin();\n state = HEADER_FIELD_START;\n break;\n }\n } else {\n index = 0;\n }\n }\n\n if (index > 0) {\n // when matching a possible boundary, keep a lookbehind reference\n // in case it turns out to be a false lead\n lookbehind[index - 1] = c;\n } else if (prevIndex > 0) {\n // if our boundary turned out to be rubbish, the captured lookbehind\n // belongs to partData\n this._onParsePartData(lookbehind.subarray(0, prevIndex));\n prevIndex = 0;\n this._partDataMark = i;\n\n // reconsider the current character even so it interrupted the sequence\n // it could be the beginning of a new sequence\n i--;\n }\n\n break;\n case CLOSE_BOUNDARY:\n if (c !== HYPHEN)\n throw new Error(`Expected HYPHEN Received ${c}`);\n\n if (index === 1) {\n this._onParsePartEnd();\n state = END;\n } else if (index > 1) {\n throw new Error(\"Parser has invalid state.\");\n }\n index++;\n break;\n case END:\n break;\n default:\n throw new Error(\"Parser has invalid state.\");\n }\n }\n\n if (this._headerFieldMark != null) {\n this._onParseHeaderField(this._buffer.subarray(this._headerFieldMark));\n this._headerFieldMark = 0;\n }\n if (this._headerValueMark != null) {\n this._onParseHeaderValue(this._buffer.subarray(this._headerValueMark));\n this._headerValueMark = 0;\n }\n if (this._partDataMark != null) {\n this._onParsePartData(this._buffer.subarray(this._partDataMark));\n this._partDataMark = 0;\n }\n\n return this._value;\n }\n\n private _onParsePartBegin() {\n this._clearPartVars();\n }\n\n private _clearPartVars() {\n this._partHeaders = {};\n this._partName = null;\n this._partChunks.length = 0;\n\n this._headerFieldDecoder = new TextDecoder(\"utf8\");\n this._headerField = \"\";\n this._headerValueDecoder = new TextDecoder(\"utf8\");\n this._headerValue = \"\";\n }\n\n private _onParseHeaderField(b: Uint8Array) {\n this._headerField += this._headerFieldDecoder!.decode(b);\n }\n\n private _onParseHeaderValue(b: Uint8Array) {\n this._headerValue += this._headerValueDecoder!.decode(b);\n }\n\n private _onParseHeaderEnd() {\n this._headerField = this._headerField.toLowerCase();\n this._partHeaders[this._headerField] = this._headerValue;\n\n let m: RegExpMatchArray | null;\n if (this._headerField === \"content-disposition\") {\n if (m = this._headerValue.match(/\\bname=\"([^\"]+)\"/i)) {\n this._partName = m[1];\n }\n // this._partFilename = parseFilename(this._headerValue);\n } else if (this._headerField === \"content-transfer-encoding\") {\n // this._partTransferEncoding = this._headerValue.toLowerCase();\n }\n\n this._headerFieldDecoder = new TextDecoder(\"utf8\");\n this._headerField = \"\";\n this._headerValueDecoder = new TextDecoder(\"utf8\");\n this._headerValue = \"\";\n }\n\n private _onParsePartData(b: Uint8Array) {\n this._partChunks.push(b);\n }\n\n private _concatParts() {\n let totalSize = 0;\n for (const chunk of this._partChunks) {\n totalSize += chunk.length;\n }\n\n const combined = new Uint8Array(totalSize);\n\n let offset = 0;\n for (const chunk of this._partChunks) {\n combined.set(chunk, offset);\n offset += chunk.length;\n }\n\n return combined;\n }\n\n private _onParsePartEnd() {\n const partValue = this._partChunks.length === 1 ? this._partChunks[0] : this._concatParts();\n\n if (this._partName === \"objects\") {\n const partDecoder = new TextDecoder();\n this._value.objects = partDecoder.decode(partValue);\n } else {\n this._value.data.push(partValue);\n }\n\n this._clearPartVars();\n }\n\n private _onParseHeadersEnd(_offset: number) {\n }\n}\n"]}
|
|
1
|
+
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CAAC;IAEO,kBAAkB,CAAC,OAAe;IAC1C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\n/*\nAdapted from https://github.com/pillarjs/multiparty. Multiparty license as follows:\n(The MIT License)\n\nCopyright (c) 2013 Felix Geisendörfer\nCopyright (c) 2014 Andrew Kelley\nCopyright (c) 2014 Douglas Christopher Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\nimport { RpcSerializedValue } from \"../../core/RpcMarshaling\";\n\nconst START = 0;\nconst START_BOUNDARY = 1;\nconst HEADER_FIELD_START = 2;\nconst HEADER_FIELD = 3;\nconst HEADER_VALUE_START = 4;\nconst HEADER_VALUE = 5;\nconst HEADER_VALUE_ALMOST_DONE = 6;\nconst HEADERS_ALMOST_DONE = 7;\nconst PART_DATA_START = 8;\nconst PART_DATA = 9;\nconst CLOSE_BOUNDARY = 10;\nconst END = 11;\n\nconst LF = 10;\nconst CR = 13;\nconst SPACE = 32;\nconst HYPHEN = 45;\nconst COLON = 58;\nconst A = 97;\nconst Z = 122;\n\nconst CONTENT_TYPE_RE = /^multipart\\/(?:form-data|related)(?:;|$)/i;\nconst CONTENT_TYPE_PARAM_RE = /;\\s*([^=]+)=(?:\"([^\"]+)\"|([^;]+))/gi;\n\n/** @internal */\nexport class RpcMultipartParser {\n private _headerFieldMark: number | null;\n private _headerValueMark: number | null;\n private _partDataMark: number | null;\n private _partBoundaryFlag: boolean;\n private _headerField: string;\n private _partHeaders: { [index: string]: string };\n private _partName: string | null;\n private _partChunks: Uint8Array[];\n private _headerValue: string;\n private _boundary: string;\n private _buffer: Uint8Array;\n private _value: RpcSerializedValue;\n\n public constructor(contentType: string, buffer: Uint8Array) {\n let m = CONTENT_TYPE_RE.exec(contentType);\n if (!m) {\n throw new Error(\"unsupported content-type\");\n }\n\n let boundary = \"\";\n CONTENT_TYPE_PARAM_RE.lastIndex = m.index + m[0].length - 1;\n while ((m = CONTENT_TYPE_PARAM_RE.exec(contentType))) {\n if (m[1].toLowerCase() !== \"boundary\")\n continue;\n\n boundary = m[2] || m[3];\n break;\n }\n\n if (!boundary) {\n throw new Error(\"content-type missing boundary\");\n }\n\n this._headerField = \"\";\n this._partHeaders = {};\n this._partName = null;\n this._partChunks = [];\n this._headerValue = \"\";\n\n this._headerFieldMark = null;\n this._headerValueMark = null;\n this._partDataMark = null;\n this._partBoundaryFlag = false;\n\n this._boundary = boundary;\n this._buffer = buffer;\n this._value = RpcSerializedValue.create();\n }\n\n public parse(): RpcSerializedValue {\n let i = 0;\n const len = this._buffer.length;\n let prevIndex = 0;\n let index = 0;\n let state = START;\n\n const boundary = new Uint8Array(this._boundary.length + 4);\n const boundaryEncoder = new TextEncoder(); // encodes utf8 only\n boundaryEncoder.encodeInto(\"\\r\\n--\", boundary.subarray(0));\n boundaryEncoder.encodeInto(this._boundary, boundary.subarray(4));\n\n const boundaryChars: { [index: number]: boolean } = {};\n for (const char of boundary) {\n boundaryChars[char] = true;\n }\n\n const boundaryLength = boundary.length;\n const boundaryEnd = boundaryLength - 1;\n const bufferLength = this._buffer.length;\n const lookbehind = new Uint8Array(boundaryLength + 8);\n\n let c;\n let cl;\n\n for (i = 0; i < len; i++) {\n c = this._buffer[i];\n switch (state) {\n case START:\n index = 0;\n state = START_BOUNDARY;\n /* falls through */\n case START_BOUNDARY:\n if (index === boundaryLength - 2 && c === HYPHEN) {\n index = 1;\n state = CLOSE_BOUNDARY;\n break;\n } else if (index === boundaryLength - 2) {\n if (c !== CR)\n throw new Error(`Expected CR Received ${c}`);\n\n index++;\n break;\n } else if (index === boundaryLength - 1) {\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n index = 0;\n this._onParsePartBegin();\n state = HEADER_FIELD_START;\n break;\n }\n\n if (c !== boundary[index + 2])\n index = -2;\n\n if (c === boundary[index + 2])\n index++;\n\n break;\n case HEADER_FIELD_START:\n state = HEADER_FIELD;\n this._headerFieldMark = i;\n index = 0;\n /* falls through */\n case HEADER_FIELD:\n if (c === CR) {\n this._headerFieldMark = null;\n state = HEADERS_ALMOST_DONE;\n break;\n }\n\n index++;\n if (c === HYPHEN)\n break;\n\n if (c === COLON) {\n if (index === 1) {\n // empty header field\n throw new Error(\"Empty header field\");\n }\n this._onParseHeaderField(this._buffer.subarray(this._headerFieldMark as number, i));\n this._headerFieldMark = null;\n state = HEADER_VALUE_START;\n break;\n }\n\n cl = c | 0x20;\n if (cl < A || cl > Z) {\n throw new Error(`Expected alphabetic character, received ${c}`);\n }\n break;\n case HEADER_VALUE_START:\n if (c === SPACE)\n break;\n\n this._headerValueMark = i;\n state = HEADER_VALUE;\n /* falls through */\n case HEADER_VALUE:\n if (c === CR) {\n this._onParseHeaderValue(this._buffer.subarray(this._headerValueMark as number, i));\n this._headerValueMark = null;\n this._onParseHeaderEnd();\n state = HEADER_VALUE_ALMOST_DONE;\n }\n break;\n case HEADER_VALUE_ALMOST_DONE:\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n state = HEADER_FIELD_START;\n break;\n case HEADERS_ALMOST_DONE:\n if (c !== LF)\n throw new Error(`Expected LF Received ${c}`);\n\n const err: any = this._onParseHeadersEnd(i + 1);\n if (err)\n throw err;\n\n state = PART_DATA_START;\n break;\n case PART_DATA_START:\n state = PART_DATA;\n this._partDataMark = i;\n /* falls through */\n case PART_DATA:\n prevIndex = index;\n\n if (index === 0) {\n // boyer-moore derived algorithm to safely skip non-boundary data\n i += boundaryEnd;\n while (i < bufferLength && !(this._buffer[i] in boundaryChars)) {\n i += boundaryLength;\n }\n i -= boundaryEnd;\n c = this._buffer[i];\n }\n\n if (index < boundaryLength) {\n if (boundary[index] === c) {\n if (index === 0) {\n this._onParsePartData(this._buffer.subarray(this._partDataMark as number, i));\n this._partDataMark = null;\n }\n index++;\n } else {\n index = 0;\n }\n } else if (index === boundaryLength) {\n index++;\n if (c === CR) {\n // CR = part boundary\n this._partBoundaryFlag = true;\n } else if (c === HYPHEN) {\n index = 1;\n state = CLOSE_BOUNDARY;\n break;\n } else {\n index = 0;\n }\n } else if (index - 1 === boundaryLength) {\n if (this._partBoundaryFlag) {\n index = 0;\n if (c === LF) {\n this._partBoundaryFlag = false;\n this._onParsePartEnd();\n this._onParsePartBegin();\n state = HEADER_FIELD_START;\n break;\n }\n } else {\n index = 0;\n }\n }\n\n if (index > 0) {\n // when matching a possible boundary, keep a lookbehind reference\n // in case it turns out to be a false lead\n lookbehind[index - 1] = c;\n } else if (prevIndex > 0) {\n // if our boundary turned out to be rubbish, the captured lookbehind\n // belongs to partData\n this._onParsePartData(lookbehind.subarray(0, prevIndex));\n prevIndex = 0;\n this._partDataMark = i;\n\n // reconsider the current character even so it interrupted the sequence\n // it could be the beginning of a new sequence\n i--;\n }\n\n break;\n case CLOSE_BOUNDARY:\n if (c !== HYPHEN)\n throw new Error(`Expected HYPHEN Received ${c}`);\n\n if (index === 1) {\n this._onParsePartEnd();\n state = END;\n } else if (index > 1) {\n throw new Error(\"Parser has invalid state.\");\n }\n index++;\n break;\n case END:\n break;\n default:\n throw new Error(\"Parser has invalid state.\");\n }\n }\n\n if (this._headerFieldMark != null) {\n this._onParseHeaderField(this._buffer.subarray(this._headerFieldMark));\n this._headerFieldMark = 0;\n }\n if (this._headerValueMark != null) {\n this._onParseHeaderValue(this._buffer.subarray(this._headerValueMark));\n this._headerValueMark = 0;\n }\n if (this._partDataMark != null) {\n this._onParsePartData(this._buffer.subarray(this._partDataMark));\n this._partDataMark = 0;\n }\n\n return this._value;\n }\n\n private _onParsePartBegin() {\n this._clearPartVars();\n }\n\n private _clearPartVars() {\n this._partHeaders = {};\n this._partName = null;\n this._partChunks.length = 0;\n\n this._headerField = \"\";\n this._headerValue = \"\";\n }\n\n private _onParseHeaderField(b: Uint8Array) {\n this._headerField += new TextDecoder(\"utf8\").decode(b);\n }\n\n private _onParseHeaderValue(b: Uint8Array) {\n this._headerValue += new TextDecoder(\"utf8\").decode(b);\n }\n\n private _onParseHeaderEnd() {\n this._headerField = this._headerField.toLowerCase();\n this._partHeaders[this._headerField] = this._headerValue;\n\n let m: RegExpMatchArray | null;\n if (this._headerField === \"content-disposition\") {\n if (m = this._headerValue.match(/\\bname=\"([^\"]+)\"/i)) {\n this._partName = m[1];\n }\n // this._partFilename = parseFilename(this._headerValue);\n } else if (this._headerField === \"content-transfer-encoding\") {\n // this._partTransferEncoding = this._headerValue.toLowerCase();\n }\n\n this._headerField = \"\";\n this._headerValue = \"\";\n }\n\n private _onParsePartData(b: Uint8Array) {\n this._partChunks.push(b);\n }\n\n private _concatParts() {\n let totalSize = 0;\n for (const chunk of this._partChunks) {\n totalSize += chunk.length;\n }\n\n const combined = new Uint8Array(totalSize);\n\n let offset = 0;\n for (const chunk of this._partChunks) {\n combined.set(chunk, offset);\n offset += chunk.length;\n }\n\n return combined;\n }\n\n private _onParsePartEnd() {\n const partValue = this._partChunks.length === 1 ? this._partChunks[0] : this._concatParts();\n\n if (this._partName === \"objects\") {\n const partDecoder = new TextDecoder();\n this._value.objects = partDecoder.decode(partValue);\n } else {\n this._value.data.push(partValue);\n }\n\n this._clearPartVars();\n }\n\n private _onParseHeadersEnd(_offset: number) {\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-common",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.76",
|
|
4
4
|
"description": "iTwin.js components common to frontend and backend",
|
|
5
5
|
"main": "lib/cjs/core-common.js",
|
|
6
6
|
"module": "lib/esm/core-common.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"js-base64": "^3.6.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@itwin/core-bentley": "5.0.0-dev.
|
|
31
|
-
"@itwin/core-geometry": "5.0.0-dev.
|
|
30
|
+
"@itwin/core-bentley": "5.0.0-dev.76",
|
|
31
|
+
"@itwin/core-geometry": "5.0.0-dev.76"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"typescript": "~5.6.2",
|
|
44
44
|
"vitest": "^3.0.6",
|
|
45
|
-
"@itwin/build-tools": "5.0.0-dev.
|
|
46
|
-
"@itwin/core-geometry": "5.0.0-dev.
|
|
47
|
-
"@itwin/core-bentley": "5.0.0-dev.
|
|
45
|
+
"@itwin/build-tools": "5.0.0-dev.76",
|
|
46
|
+
"@itwin/core-geometry": "5.0.0-dev.76",
|
|
47
|
+
"@itwin/core-bentley": "5.0.0-dev.76"
|
|
48
48
|
},
|
|
49
49
|
"nyc": {
|
|
50
50
|
"extends": "./node_modules/@itwin/build-tools/.nycrc",
|