@azure/core-amqp 2.2.0-alpha.20210326.1 → 3.0.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/CHANGELOG.md +16 -2
- package/dist/index.js +301 -39
- package/dist/index.js.map +1 -1
- package/dist-esm/src/amqpAnnotatedMessage.js +7 -0
- package/dist-esm/src/amqpAnnotatedMessage.js.map +1 -1
- package/dist-esm/src/auth/tokenProvider.js +79 -0
- package/dist-esm/src/auth/tokenProvider.js.map +1 -0
- package/dist-esm/src/cbs.js +14 -13
- package/dist-esm/src/cbs.js.map +1 -1
- package/dist-esm/src/errors.js +8 -0
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/index.js +3 -2
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/internals.js +6 -0
- package/dist-esm/src/internals.js.map +1 -0
- package/dist-esm/src/messageProperties.js +4 -4
- package/dist-esm/src/messageProperties.js.map +1 -1
- package/dist-esm/src/requestResponseLink.js +2 -2
- package/dist-esm/src/requestResponseLink.js.map +1 -1
- package/dist-esm/src/retry.js +1 -0
- package/dist-esm/src/retry.js.map +1 -1
- package/dist-esm/src/util/lock.js +165 -0
- package/dist-esm/src/util/lock.js.map +1 -0
- package/dist-esm/src/util/typeGuards.js +8 -0
- package/dist-esm/src/util/typeGuards.js.map +1 -1
- package/dist-esm/src/util/utils.js +5 -15
- package/dist-esm/src/util/utils.js.map +1 -1
- package/package.json +6 -9
- package/types/3.1/core-amqp.d.ts +103 -6
- package/types/latest/core-amqp.d.ts +109 -6
|
@@ -21,6 +21,13 @@ export const AmqpAnnotatedMessage = {
|
|
|
21
21
|
properties: AmqpMessageProperties.fromRheaMessageProperties(msg),
|
|
22
22
|
body: msg.body
|
|
23
23
|
};
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Takes AmqpAnnotatedMessage and returns it in the RheaMessage(`Message` type from "rhea") format.
|
|
27
|
+
*/
|
|
28
|
+
toRheaMessage(msg) {
|
|
29
|
+
const message = Object.assign(Object.assign(Object.assign({}, AmqpMessageProperties.toRheaMessageProperties(msg.properties || {})), AmqpMessageHeader.toRheaMessageHeader(msg.header || {})), { body: msg.body, message_annotations: msg.messageAnnotations, delivery_annotations: msg.deliveryAnnotations, application_properties: msg.applicationProperties, footer: msg.footer });
|
|
30
|
+
return message;
|
|
24
31
|
}
|
|
25
32
|
};
|
|
26
33
|
//# sourceMappingURL=amqpAnnotatedMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqpAnnotatedMessage.js","sourceRoot":"","sources":["../../src/amqpAnnotatedMessage.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"amqpAnnotatedMessage.js","sourceRoot":"","sources":["../../src/amqpAnnotatedMessage.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AA0C5D;;GAEG;AACH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC;;OAEG;IACH,eAAe,CAAC,GAAgB;QAC9B,OAAO;YACL,MAAM,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,GAAG,CAAC;YACpD,MAAM,EAAG,GAAW,CAAC,MAAM;YAC3B,kBAAkB,EAAE,GAAG,CAAC,mBAAmB;YAC3C,mBAAmB,EAAE,GAAG,CAAC,oBAAoB;YAC7C,qBAAqB,EAAE,GAAG,CAAC,sBAAsB;YACjD,UAAU,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,GAAG,CAAC;YAChE,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC;IACJ,CAAC;IACD;;OAEG;IACH,aAAa,CAAC,GAAyB;QACrC,MAAM,OAAO,iDACR,qBAAqB,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,GACnE,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,KAC1D,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,mBAAmB,EAAE,GAAG,CAAC,kBAAkB,EAC3C,oBAAoB,EAAE,GAAG,CAAC,mBAAmB,EAC7C,sBAAsB,EAAE,GAAG,CAAC,qBAAqB,EACjD,MAAM,EAAE,GAAG,CAAC,MAAM,GACnB,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable eqeqeq */\nimport { AmqpMessageHeader } from \"./messageHeader\";\nimport { AmqpMessageProperties } from \"./messageProperties\";\nimport { Message as RheaMessage } from \"rhea-promise\";\n\n/**\n * Describes the AmqpAnnotatedMessage, part of the ServiceBusReceivedMessage(as `amqpAnnotatedMessage` property).\n */\nexport interface AmqpAnnotatedMessage {\n /**\n * Describes the defined set of standard header properties of the message.\n */\n header?: AmqpMessageHeader;\n /**\n * Describes set of footer properties of the message.\n */\n footer?: { [key: string]: any };\n /**\n * A dictionary containing message attributes that will be held in the message header\n */\n messageAnnotations?: { [key: string]: any };\n /**\n * A dictionary used for delivery-specific\n * non-standard properties at the head of the message.\n */\n deliveryAnnotations?: { [key: string]: any };\n /**\n * A dictionary containing application specific message properties.\n */\n applicationProperties?: { [key: string]: any };\n /**\n * Describes the defined set of standard properties of the message.\n */\n properties?: AmqpMessageProperties;\n /**\n * The message body.\n */\n body: any;\n /**\n * The AMQP section where the data was decoded from.\n */\n bodyType?: \"data\" | \"sequence\" | \"value\";\n}\n\n/**\n * Describes the operations that can be performed on(or to get) the AmqpAnnotatedMessage.\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- renaming constant would be a breaking change.\nexport const AmqpAnnotatedMessage = {\n /**\n * Takes RheaMessage(`Message` type from \"rhea\") and returns it in the AmqpAnnotatedMessage format.\n */\n fromRheaMessage(msg: RheaMessage): AmqpAnnotatedMessage {\n return {\n header: AmqpMessageHeader.fromRheaMessageHeader(msg),\n footer: (msg as any).footer,\n messageAnnotations: msg.message_annotations,\n deliveryAnnotations: msg.delivery_annotations,\n applicationProperties: msg.application_properties,\n properties: AmqpMessageProperties.fromRheaMessageProperties(msg),\n body: msg.body\n };\n },\n /**\n * Takes AmqpAnnotatedMessage and returns it in the RheaMessage(`Message` type from \"rhea\") format.\n */\n toRheaMessage(msg: AmqpAnnotatedMessage): RheaMessage {\n const message = {\n ...AmqpMessageProperties.toRheaMessageProperties(msg.properties || {}),\n ...AmqpMessageHeader.toRheaMessageHeader(msg.header || {}),\n body: msg.body,\n message_annotations: msg.messageAnnotations,\n delivery_annotations: msg.deliveryAnnotations,\n application_properties: msg.applicationProperties,\n footer: msg.footer\n };\n return message;\n }\n};\n"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { isNamedKeyCredential, isSASCredential } from "@azure/core-auth";
|
|
4
|
+
import jssha from "jssha";
|
|
5
|
+
import { isObjectWithProperties } from "../util/typeGuards";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a token provider from the provided shared access data.
|
|
8
|
+
* @param data - The sharedAccessKeyName/sharedAccessKey pair or the sharedAccessSignature.
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export function createSasTokenProvider(data) {
|
|
12
|
+
if (isNamedKeyCredential(data) || isSASCredential(data)) {
|
|
13
|
+
return new SasTokenProviderImpl(data);
|
|
14
|
+
}
|
|
15
|
+
else if (isObjectWithProperties(data, ["sharedAccessKeyName", "sharedAccessKey"])) {
|
|
16
|
+
return new SasTokenProviderImpl({ name: data.sharedAccessKeyName, key: data.sharedAccessKey });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return new SasTokenProviderImpl({ signature: data.sharedAccessSignature });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A TokenProvider that generates a Sas token:
|
|
24
|
+
* `SharedAccessSignature sr=<resource>&sig=<signature>&se=<expiry>&skn=<keyname>`
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export class SasTokenProviderImpl {
|
|
29
|
+
/**
|
|
30
|
+
* Initializes a new instance of SasTokenProvider
|
|
31
|
+
* @param credential - The source `NamedKeyCredential` or `SASCredential`.
|
|
32
|
+
*/
|
|
33
|
+
constructor(credential) {
|
|
34
|
+
this._credential = credential;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Property used to distinguish TokenProvider from TokenCredential.
|
|
38
|
+
*/
|
|
39
|
+
get isSasTokenProvider() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the sas token for the specified audience
|
|
44
|
+
* @param audience - The audience for which the token is desired.
|
|
45
|
+
*/
|
|
46
|
+
getToken(audience) {
|
|
47
|
+
if (isNamedKeyCredential(this._credential)) {
|
|
48
|
+
return createToken(this._credential.name, this._credential.key, Math.floor(Date.now() / 1000) + 3600, audience);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return {
|
|
52
|
+
token: this._credential.signature,
|
|
53
|
+
expiresOnTimestamp: 0
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates the sas token based on the provided information.
|
|
60
|
+
* @param keyName - The shared access key name.
|
|
61
|
+
* @param key - The shared access key.
|
|
62
|
+
* @param expiry - The time period in unix time after which the token will expire.
|
|
63
|
+
* @param audience - The audience for which the token is desired.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
function createToken(keyName, key, expiry, audience) {
|
|
67
|
+
audience = encodeURIComponent(audience);
|
|
68
|
+
keyName = encodeURIComponent(keyName);
|
|
69
|
+
const stringToSign = audience + "\n" + expiry;
|
|
70
|
+
const shaObj = new jssha("SHA-256", "TEXT");
|
|
71
|
+
shaObj.setHMACKey(key, "TEXT");
|
|
72
|
+
shaObj.update(stringToSign);
|
|
73
|
+
const sig = encodeURIComponent(shaObj.getHMAC("B64"));
|
|
74
|
+
return {
|
|
75
|
+
token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,
|
|
76
|
+
expiresOnTimestamp: expiry
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=tokenProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenProvider.js","sourceRoot":"","sources":["../../../src/auth/tokenProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAIL,oBAAoB,EACpB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAqB5D;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAIiB;IAEjB,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;QACvD,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;KACvC;SAAM,IAAI,sBAAsB,CAAC,IAAI,EAAE,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC,EAAE;QACnF,OAAO,IAAI,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;KAChG;SAAM;QACL,OAAO,IAAI,oBAAoB,CAAC,EAAE,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AK,EAAE,4BAA4B,QAAQ,QAAQ,GAAG,OAAO,MAAM,QAAQ,OAAO,EAAE;QACpF,kBAAkB,EAAE,MAAM;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AccessToken,\n NamedKeyCredential,\n SASCredential,\n isNamedKeyCredential,\n isSASCredential\n} from \"@azure/core-auth\";\nimport jssha from \"jssha\";\nimport { isObjectWithProperties } from \"../util/typeGuards\";\n\n/**\n * A SasTokenProvider provides an alternative to TokenCredential for providing an `AccessToken`.\n * @hidden\n */\nexport interface SasTokenProvider {\n /**\n * Property used to distinguish SasTokenProvider from TokenCredential.\n */\n isSasTokenProvider: true;\n /**\n * Gets the token provided by this provider.\n *\n * This method is called automatically by Azure SDK client libraries.\n *\n * @param audience - The audience for which the token is desired.\n */\n getToken(audience: string): AccessToken;\n}\n\n/**\n * Creates a token provider from the provided shared access data.\n * @param data - The sharedAccessKeyName/sharedAccessKey pair or the sharedAccessSignature.\n * @hidden\n */\nexport function createSasTokenProvider(\n data:\n | { sharedAccessKeyName: string; sharedAccessKey: string }\n | { sharedAccessSignature: string }\n | NamedKeyCredential\n | SASCredential\n): SasTokenProvider {\n if (isNamedKeyCredential(data) || isSASCredential(data)) {\n return new SasTokenProviderImpl(data);\n } else if (isObjectWithProperties(data, [\"sharedAccessKeyName\", \"sharedAccessKey\"])) {\n return new SasTokenProviderImpl({ name: data.sharedAccessKeyName, key: data.sharedAccessKey });\n } else {\n return new SasTokenProviderImpl({ signature: data.sharedAccessSignature });\n }\n}\n\n/**\n * A TokenProvider that generates a Sas token:\n * `SharedAccessSignature sr=<resource>&sig=<signature>&se=<expiry>&skn=<keyname>`\n *\n * @internal\n */\nexport class SasTokenProviderImpl implements SasTokenProvider {\n /**\n * Property used to distinguish TokenProvider from TokenCredential.\n */\n get isSasTokenProvider(): true {\n return true;\n }\n\n /**\n * The SASCredential containing the key name and secret key value.\n */\n private _credential: SASCredential | NamedKeyCredential;\n\n /**\n * Initializes a new instance of SasTokenProvider\n * @param credential - The source `NamedKeyCredential` or `SASCredential`.\n */\n constructor(credential: SASCredential | NamedKeyCredential) {\n this._credential = credential;\n }\n\n /**\n * Gets the sas token for the specified audience\n * @param audience - The audience for which the token is desired.\n */\n getToken(audience: string): AccessToken {\n if (isNamedKeyCredential(this._credential)) {\n return createToken(\n this._credential.name,\n this._credential.key,\n Math.floor(Date.now() / 1000) + 3600,\n audience\n );\n } else {\n return {\n token: this._credential.signature,\n expiresOnTimestamp: 0\n };\n }\n }\n}\n\n/**\n * Creates the sas token based on the provided information.\n * @param keyName - The shared access key name.\n * @param key - The shared access key.\n * @param expiry - The time period in unix time after which the token will expire.\n * @param audience - The audience for which the token is desired.\n * @internal\n */\nfunction createToken(keyName: string, key: string, expiry: number, audience: string): AccessToken {\n audience = encodeURIComponent(audience);\n keyName = encodeURIComponent(keyName);\n const stringToSign = audience + \"\\n\" + expiry;\n\n const shaObj = new jssha(\"SHA-256\", \"TEXT\");\n shaObj.setHMACKey(key, \"TEXT\");\n shaObj.update(stringToSign);\n const sig = encodeURIComponent(shaObj.getHMAC(\"B64\"));\n return {\n token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,\n expiresOnTimestamp: expiry\n };\n}\n"]}
|
package/dist-esm/src/cbs.js
CHANGED
|
@@ -5,8 +5,8 @@ import { ReceiverEvents, SenderEvents, generate_uuid } from "rhea-promise";
|
|
|
5
5
|
import { AbortError } from "@azure/abort-controller";
|
|
6
6
|
import { Constants } from "./util/constants";
|
|
7
7
|
import { logErrorStackTrace, logger } from "./log";
|
|
8
|
-
import { translate } from "./errors";
|
|
9
|
-
import {
|
|
8
|
+
import { StandardAbortMessage, translate } from "./errors";
|
|
9
|
+
import { defaultCancellableLock } from "./util/utils";
|
|
10
10
|
import { RequestResponseLink } from "./requestResponseLink";
|
|
11
11
|
/**
|
|
12
12
|
* Describes the EventHub/ServiceBus Cbs client that talks to the $cbs endpoint over AMQP connection.
|
|
@@ -42,20 +42,19 @@ export class CbsClient {
|
|
|
42
42
|
*/
|
|
43
43
|
init(options = {}) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const { abortSignal } = options;
|
|
46
|
-
const initAbortMessage = "The init operation has been cancelled by the user.";
|
|
45
|
+
const { abortSignal, timeoutInMs } = options;
|
|
47
46
|
try {
|
|
48
47
|
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
|
|
49
|
-
throw new AbortError(
|
|
48
|
+
throw new AbortError(StandardAbortMessage);
|
|
50
49
|
}
|
|
51
50
|
// Acquire the lock and establish an amqp connection if it does not exist.
|
|
52
51
|
if (!this.connection.isOpen()) {
|
|
53
52
|
logger.verbose("The CBS client is trying to establish an AMQP connection.");
|
|
54
|
-
yield
|
|
53
|
+
yield defaultCancellableLock.acquire(this.connectionLock, () => {
|
|
55
54
|
return this.connection.open({ abortSignal });
|
|
56
|
-
});
|
|
55
|
+
}, { abortSignal: abortSignal, timeoutInMs: timeoutInMs });
|
|
57
56
|
}
|
|
58
|
-
if (!this.
|
|
57
|
+
if (!this.isOpen()) {
|
|
59
58
|
const rxOpt = {
|
|
60
59
|
source: {
|
|
61
60
|
address: this.endpoint
|
|
@@ -133,10 +132,10 @@ export class CbsClient {
|
|
|
133
132
|
*/
|
|
134
133
|
negotiateClaim(audience, token, tokenType, options = {}) {
|
|
135
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
const { abortSignal } = options;
|
|
135
|
+
const { abortSignal, timeoutInMs } = options;
|
|
137
136
|
try {
|
|
138
137
|
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
|
|
139
|
-
throw new AbortError(
|
|
138
|
+
throw new AbortError(StandardAbortMessage);
|
|
140
139
|
}
|
|
141
140
|
if (!this._cbsSenderReceiverLink) {
|
|
142
141
|
throw new Error("Attempted to negotiate a claim but the CBS link does not exist.");
|
|
@@ -154,6 +153,7 @@ export class CbsClient {
|
|
|
154
153
|
};
|
|
155
154
|
const responseMessage = yield this._cbsSenderReceiverLink.sendRequest(request, {
|
|
156
155
|
abortSignal,
|
|
156
|
+
timeoutInMs,
|
|
157
157
|
requestName: "negotiateClaim"
|
|
158
158
|
});
|
|
159
159
|
logger.verbose("[%s] The CBS response is: %O", this.connection.id, responseMessage);
|
|
@@ -174,7 +174,7 @@ export class CbsClient {
|
|
|
174
174
|
close() {
|
|
175
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
176
|
try {
|
|
177
|
-
if (this.
|
|
177
|
+
if (this.isOpen()) {
|
|
178
178
|
const cbsLink = this._cbsSenderReceiverLink;
|
|
179
179
|
this._cbsSenderReceiverLink = undefined;
|
|
180
180
|
yield cbsLink.close();
|
|
@@ -213,8 +213,9 @@ export class CbsClient {
|
|
|
213
213
|
* Indicates whether the cbs sender receiver link is open or closed.
|
|
214
214
|
* @returns `true` open, `false` closed.
|
|
215
215
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
isOpen() {
|
|
217
|
+
var _a;
|
|
218
|
+
return Boolean((_a = this._cbsSenderReceiverLink) === null || _a === void 0 ? void 0 : _a.isOpen());
|
|
218
219
|
}
|
|
219
220
|
_fromRheaMessageResponse(msg) {
|
|
220
221
|
const cbsResponse = {
|
package/dist-esm/src/cbs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cbs.js","sourceRoot":"","sources":["../../src/cbs.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAIL,cAAc,EAEd,YAAY,EAEZ,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,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,MAAM,WAAW,GAAG;YAClB,aAAa,EAAE,GAAG,CAAC,cAAyB;YAC5C,UAAU,EAAE,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;YACvF,iBAAiB,EAAE,GAAG,CAAC,sBAAsB;gBAC3C,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,oBAAoB,CAAC;gBAClD,CAAC,CAAC,EAAE;SACP,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,2CAA2C,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7F,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TokenType } from \"./auth/token\";\nimport {\n Message as RheaMessage,\n Connection,\n EventContext,\n ReceiverEvents,\n ReceiverOptions,\n SenderEvents,\n SenderOptions,\n generate_uuid\n} from \"rhea-promise\";\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { Constants } from \"./util/constants\";\nimport { logErrorStackTrace, logger } from \"./log\";\nimport { translate } from \"./errors\";\nimport { defaultLock } from \"./util/utils\";\nimport { RequestResponseLink } from \"./requestResponseLink\";\n\n/**\n * Describes the CBS Response.\n */\nexport interface CbsResponse {\n correlationId: string;\n statusCode: string;\n statusDescription: string;\n}\n\n/**\n * Describes the EventHub/ServiceBus Cbs client that talks to the $cbs endpoint over AMQP connection.\n */\nexport class CbsClient {\n /**\n * CBS endpoint - \"$cbs\"\n */\n readonly endpoint: string = Constants.cbsEndpoint;\n /**\n * CBS replyTo - The receiver link name that the service should reply to.\n */\n readonly replyTo: string = `${Constants.cbsReplyTo}-${generate_uuid()}`;\n /**\n * The unique lock name per $cbs session per connection that is used to\n * acquire the lock for establishing a cbs session if one does not exist for an amqp connection.\n */\n readonly cbsLock: string = `${Constants.negotiateCbsKey}-${generate_uuid()}`;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for establishing an amqp connection if one does not exist.\n */\n readonly connectionLock: string;\n /**\n * The AMQP connection.\n */\n connection: Connection;\n\n /**\n * CBS sender, receiver on the same session.\n */\n private _cbsSenderReceiverLink?: RequestResponseLink;\n\n /**\n * @param connection - The AMQP connection.\n * @param connectionLock - A unique string (usually a guid) per connection.\n */\n constructor(connection: Connection, connectionLock: string) {\n this.connection = connection;\n this.connectionLock = connectionLock;\n }\n\n /**\n * Creates a singleton instance of the CBS session if it hasn't been initialized previously on\n * the given connection.\n * @param options - Optional parameters that can be used to affect this method's behavior.\n * For example, `abortSignal` can be passed to allow cancelling an in-progress `init` invocation.\n * @returns Promise<void>.\n */\n async init(options: { abortSignal?: AbortSignalLike } = {}): Promise<void> {\n const { abortSignal } = options;\n const initAbortMessage = \"The init operation has been cancelled by the user.\";\n\n try {\n if (abortSignal?.aborted) {\n throw new AbortError(initAbortMessage);\n }\n\n // Acquire the lock and establish an amqp connection if it does not exist.\n if (!this.connection.isOpen()) {\n logger.verbose(\"The CBS client is trying to establish an AMQP connection.\");\n await defaultLock.acquire(this.connectionLock, () => {\n return this.connection.open({ abortSignal });\n });\n }\n\n if (!this._isCbsSenderReceiverLinkOpen()) {\n const rxOpt: ReceiverOptions = {\n source: {\n address: this.endpoint\n },\n name: this.replyTo,\n onSessionError: (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.session!.error!);\n logger.verbose(\n \"[%s] An error occurred on the session for request/response links \" + \"for $cbs: %O\",\n id,\n ehError\n );\n }\n };\n const srOpt: SenderOptions = { target: { address: this.endpoint } };\n logger.verbose(\n \"[%s] Creating sender/receiver links on a session for $cbs endpoint.\",\n this.connection.id\n );\n this._cbsSenderReceiverLink = await RequestResponseLink.create(\n this.connection,\n srOpt,\n rxOpt,\n { abortSignal }\n );\n this._cbsSenderReceiverLink.sender.on(SenderEvents.senderError, (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.sender!.error!);\n logger.verbose(\"[%s] An error occurred on the cbs sender link.. %O\", id, ehError);\n });\n this._cbsSenderReceiverLink.receiver.on(\n ReceiverEvents.receiverError,\n (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.receiver!.error!);\n logger.verbose(\"[%s] An error occurred on the cbs receiver link.. %O\", id, ehError);\n }\n );\n logger.verbose(\n \"[%s] Successfully created the cbs sender '%s' and receiver '%s' \" +\n \"links over cbs session.\",\n this.connection.id,\n this._cbsSenderReceiverLink.sender.name,\n this._cbsSenderReceiverLink.receiver.name\n );\n } else {\n logger.verbose(\n \"[%s] CBS session is already present. Reusing the cbs sender '%s' \" +\n \"and receiver '%s' links over cbs session.\",\n this.connection.id,\n this._cbsSenderReceiverLink!.sender.name,\n this._cbsSenderReceiverLink!.receiver.name\n );\n }\n } catch (err) {\n const translatedError = translate(err);\n logger.warning(\n \"[%s] An error occurred while establishing the cbs links: %s\",\n this.connection.id,\n `${translatedError?.name}: ${translatedError?.message}`\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Negotiates the CBS claim with the EventHub/ServiceBus Service.\n * @param audience - The entity token audience for which the token is requested in one\n * of the following forms:\n *\n * - **ServiceBus**\n * - **Sender**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<queue-name>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<topic-name>\"`\n *\n * - **Receiver**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<queue-name>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<topic-name>\"`\n *\n * - **ManagementClient**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<queue-name>/$management\"`.\n * - `\"sb://<your-namespace>.servicebus.windows.net/<topic-name>/$management\"`.\n *\n * - **EventHubs**\n * - **Sender**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`.\n *\n * - **Receiver**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/ConsumerGroups/<consumer-group-name>/Partitions/<partition-id>\"`.\n *\n * - **ManagementClient**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/$management\"`.\n * @param token - The token that needs to be sent in the put-token request.\n * @param tokenType - The type of token being used. For example, 'jwt' or 'servicebus.windows.net:sastoken'.\n * @param options - Optional parameters that can be used to affect this method's behavior.\n * For example, `abortSignal` can be passed to allow cancelling an in-progress `negotiateClaim` invocation.\n * @returns A Promise that resolves when $cbs authentication is successful\n * and rejects when an error occurs during $cbs authentication.\n */\n async negotiateClaim(\n audience: string,\n token: string,\n tokenType: TokenType,\n options: { abortSignal?: AbortSignalLike } = {}\n ): Promise<CbsResponse> {\n const { abortSignal } = options;\n try {\n if (abortSignal?.aborted) {\n throw new AbortError(\"The negotiateClaim operation has been cancelled by the user.\");\n }\n\n if (!this._cbsSenderReceiverLink) {\n throw new Error(\"Attempted to negotiate a claim but the CBS link does not exist.\");\n }\n\n const request: RheaMessage = {\n body: token,\n message_id: generate_uuid(),\n reply_to: this.replyTo,\n to: this.endpoint,\n application_properties: {\n operation: Constants.operationPutToken,\n name: audience,\n type: tokenType\n }\n };\n const responseMessage = await this._cbsSenderReceiverLink.sendRequest(request, {\n abortSignal,\n requestName: \"negotiateClaim\"\n });\n logger.verbose(\"[%s] The CBS response is: %O\", this.connection.id, responseMessage);\n return this._fromRheaMessageResponse(responseMessage);\n } catch (err) {\n logger.warning(\n \"[%s] An error occurred while negotiating the cbs claim: %s\",\n this.connection.id,\n `${err?.name}: ${err?.message}`\n );\n logErrorStackTrace(err);\n throw err;\n }\n }\n\n /**\n * Closes the AMQP cbs session to the EventHub/ServiceBus for this client,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns\n */\n async close(): Promise<void> {\n try {\n if (this._isCbsSenderReceiverLinkOpen()) {\n const cbsLink = this._cbsSenderReceiverLink;\n this._cbsSenderReceiverLink = undefined;\n await cbsLink!.close();\n logger.verbose(\"[%s] Successfully closed the cbs session.\", this.connection.id);\n }\n } catch (err) {\n const msg = `An error occurred while closing the cbs link: ${err.stack ||\n JSON.stringify(err)}.`;\n logger.verbose(\"[%s] %s\", this.connection.id, msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Removes the AMQP cbs session to the EventHub/ServiceBus for this client,\n * @returns void\n */\n remove(): void {\n try {\n if (this._cbsSenderReceiverLink) {\n const cbsLink = this._cbsSenderReceiverLink;\n this._cbsSenderReceiverLink = undefined;\n cbsLink!.remove();\n logger.verbose(\"[%s] Successfully removed the cbs session.\", this.connection.id);\n }\n } catch (err) {\n const msg = `An error occurred while removing the cbs link: ${err.stack ||\n JSON.stringify(err)}.`;\n logger.verbose(\"[%s] %s\", this.connection.id, msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Indicates whether the cbs sender receiver link is open or closed.\n * @returns `true` open, `false` closed.\n */\n private _isCbsSenderReceiverLinkOpen(): boolean {\n return this._cbsSenderReceiverLink! && this._cbsSenderReceiverLink!.isOpen();\n }\n\n private _fromRheaMessageResponse(msg: RheaMessage): CbsResponse {\n const cbsResponse = {\n correlationId: msg.correlation_id! as string,\n statusCode: msg.application_properties ? msg.application_properties[\"status-code\"] : \"\",\n statusDescription: msg.application_properties\n ? msg.application_properties[\"status-description\"]\n : \"\"\n };\n logger.verbose(\"[%s] The deserialized CBS response is: %o\", this.connection.id, cbsResponse);\n return cbsResponse;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cbs.js","sourceRoot":"","sources":["../../src/cbs.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAIL,cAAc,EAEd,YAAY,EAEZ,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC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AAC,sBAAsB,0CAAE,MAAM,EAAE,CAAC,CAAC;IACxD,CAAC;IAEO,wBAAwB,CAAC,GAAgB;QAC/C,MAAM,WAAW,GAAG;YAClB,aAAa,EAAE,GAAG,CAAC,cAAyB;YAC5C,UAAU,EAAE,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;YACvF,iBAAiB,EAAE,GAAG,CAAC,sBAAsB;gBAC3C,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,oBAAoB,CAAC;gBAClD,CAAC,CAAC,EAAE;SACP,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,2CAA2C,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7F,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TokenType } from \"./auth/token\";\nimport {\n Message as RheaMessage,\n Connection,\n EventContext,\n ReceiverEvents,\n ReceiverOptions,\n SenderEvents,\n SenderOptions,\n generate_uuid\n} from \"rhea-promise\";\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { Constants } from \"./util/constants\";\nimport { logErrorStackTrace, logger } from \"./log\";\nimport { StandardAbortMessage, translate } from \"./errors\";\nimport { defaultCancellableLock } from \"./util/utils\";\nimport { RequestResponseLink } from \"./requestResponseLink\";\n\n/**\n * Describes the CBS Response.\n */\nexport interface CbsResponse {\n correlationId: string;\n statusCode: string;\n statusDescription: string;\n}\n\n/**\n * Describes the EventHub/ServiceBus Cbs client that talks to the $cbs endpoint over AMQP connection.\n */\nexport class CbsClient {\n /**\n * CBS endpoint - \"$cbs\"\n */\n readonly endpoint: string = Constants.cbsEndpoint;\n /**\n * CBS replyTo - The receiver link name that the service should reply to.\n */\n readonly replyTo: string = `${Constants.cbsReplyTo}-${generate_uuid()}`;\n /**\n * The unique lock name per $cbs session per connection that is used to\n * acquire the lock for establishing a cbs session if one does not exist for an amqp connection.\n */\n readonly cbsLock: string = `${Constants.negotiateCbsKey}-${generate_uuid()}`;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for establishing an amqp connection if one does not exist.\n */\n readonly connectionLock: string;\n /**\n * The AMQP connection.\n */\n connection: Connection;\n\n /**\n * CBS sender, receiver on the same session.\n */\n private _cbsSenderReceiverLink?: RequestResponseLink;\n\n /**\n * @param connection - The AMQP connection.\n * @param connectionLock - A unique string (usually a guid) per connection.\n */\n constructor(connection: Connection, connectionLock: string) {\n this.connection = connection;\n this.connectionLock = connectionLock;\n }\n\n /**\n * Creates a singleton instance of the CBS session if it hasn't been initialized previously on\n * the given connection.\n * @param options - Optional parameters that can be used to affect this method's behavior.\n * For example, `abortSignal` can be passed to allow cancelling an in-progress `init` invocation.\n * @returns Promise<void>.\n */\n async init(options: { abortSignal?: AbortSignalLike; timeoutInMs?: number } = {}): Promise<void> {\n const { abortSignal, timeoutInMs } = options;\n\n try {\n if (abortSignal?.aborted) {\n throw new AbortError(StandardAbortMessage);\n }\n\n // Acquire the lock and establish an amqp connection if it does not exist.\n if (!this.connection.isOpen()) {\n logger.verbose(\"The CBS client is trying to establish an AMQP connection.\");\n await defaultCancellableLock.acquire(\n this.connectionLock,\n () => {\n return this.connection.open({ abortSignal });\n },\n { abortSignal: abortSignal, timeoutInMs: timeoutInMs }\n );\n }\n\n if (!this.isOpen()) {\n const rxOpt: ReceiverOptions = {\n source: {\n address: this.endpoint\n },\n name: this.replyTo,\n onSessionError: (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.session!.error!);\n logger.verbose(\n \"[%s] An error occurred on the session for request/response links \" + \"for $cbs: %O\",\n id,\n ehError\n );\n }\n };\n const srOpt: SenderOptions = { target: { address: this.endpoint } };\n logger.verbose(\n \"[%s] Creating sender/receiver links on a session for $cbs endpoint.\",\n this.connection.id\n );\n this._cbsSenderReceiverLink = await RequestResponseLink.create(\n this.connection,\n srOpt,\n rxOpt,\n { abortSignal }\n );\n this._cbsSenderReceiverLink.sender.on(SenderEvents.senderError, (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.sender!.error!);\n logger.verbose(\"[%s] An error occurred on the cbs sender link.. %O\", id, ehError);\n });\n this._cbsSenderReceiverLink.receiver.on(\n ReceiverEvents.receiverError,\n (context: EventContext) => {\n const id = context.connection.options.id;\n const ehError = translate(context.receiver!.error!);\n logger.verbose(\"[%s] An error occurred on the cbs receiver link.. %O\", id, ehError);\n }\n );\n logger.verbose(\n \"[%s] Successfully created the cbs sender '%s' and receiver '%s' \" +\n \"links over cbs session.\",\n this.connection.id,\n this._cbsSenderReceiverLink.sender.name,\n this._cbsSenderReceiverLink.receiver.name\n );\n } else {\n logger.verbose(\n \"[%s] CBS session is already present. Reusing the cbs sender '%s' \" +\n \"and receiver '%s' links over cbs session.\",\n this.connection.id,\n this._cbsSenderReceiverLink!.sender.name,\n this._cbsSenderReceiverLink!.receiver.name\n );\n }\n } catch (err) {\n const translatedError = translate(err);\n logger.warning(\n \"[%s] An error occurred while establishing the cbs links: %s\",\n this.connection.id,\n `${translatedError?.name}: ${translatedError?.message}`\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Negotiates the CBS claim with the EventHub/ServiceBus Service.\n * @param audience - The entity token audience for which the token is requested in one\n * of the following forms:\n *\n * - **ServiceBus**\n * - **Sender**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<queue-name>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<topic-name>\"`\n *\n * - **Receiver**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<queue-name>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<topic-name>\"`\n *\n * - **ManagementClient**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<queue-name>/$management\"`.\n * - `\"sb://<your-namespace>.servicebus.windows.net/<topic-name>/$management\"`.\n *\n * - **EventHubs**\n * - **Sender**\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`.\n *\n * - **Receiver**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/ConsumerGroups/<consumer-group-name>/Partitions/<partition-id>\"`.\n *\n * - **ManagementClient**\n * - `\"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/$management\"`.\n * @param token - The token that needs to be sent in the put-token request.\n * @param tokenType - The type of token being used. For example, 'jwt' or 'servicebus.windows.net:sastoken'.\n * @param options - Optional parameters that can be used to affect this method's behavior.\n * For example, `abortSignal` can be passed to allow cancelling an in-progress `negotiateClaim` invocation.\n * @returns A Promise that resolves when $cbs authentication is successful\n * and rejects when an error occurs during $cbs authentication.\n */\n async negotiateClaim(\n audience: string,\n token: string,\n tokenType: TokenType,\n options: { abortSignal?: AbortSignalLike; timeoutInMs?: number } = {}\n ): Promise<CbsResponse> {\n const { abortSignal, timeoutInMs } = options;\n try {\n if (abortSignal?.aborted) {\n throw new AbortError(StandardAbortMessage);\n }\n\n if (!this._cbsSenderReceiverLink) {\n throw new Error(\"Attempted to negotiate a claim but the CBS link does not exist.\");\n }\n\n const request: RheaMessage = {\n body: token,\n message_id: generate_uuid(),\n reply_to: this.replyTo,\n to: this.endpoint,\n application_properties: {\n operation: Constants.operationPutToken,\n name: audience,\n type: tokenType\n }\n };\n const responseMessage = await this._cbsSenderReceiverLink.sendRequest(request, {\n abortSignal,\n timeoutInMs,\n requestName: \"negotiateClaim\"\n });\n logger.verbose(\"[%s] The CBS response is: %O\", this.connection.id, responseMessage);\n return this._fromRheaMessageResponse(responseMessage);\n } catch (err) {\n logger.warning(\n \"[%s] An error occurred while negotiating the cbs claim: %s\",\n this.connection.id,\n `${err?.name}: ${err?.message}`\n );\n logErrorStackTrace(err);\n throw err;\n }\n }\n\n /**\n * Closes the AMQP cbs session to the EventHub/ServiceBus for this client,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns\n */\n async close(): Promise<void> {\n try {\n if (this.isOpen()) {\n const cbsLink = this._cbsSenderReceiverLink;\n this._cbsSenderReceiverLink = undefined;\n await cbsLink!.close();\n logger.verbose(\"[%s] Successfully closed the cbs session.\", this.connection.id);\n }\n } catch (err) {\n const msg = `An error occurred while closing the cbs link: ${err.stack ||\n JSON.stringify(err)}.`;\n logger.verbose(\"[%s] %s\", this.connection.id, msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Removes the AMQP cbs session to the EventHub/ServiceBus for this client,\n * @returns void\n */\n remove(): void {\n try {\n if (this._cbsSenderReceiverLink) {\n const cbsLink = this._cbsSenderReceiverLink;\n this._cbsSenderReceiverLink = undefined;\n cbsLink!.remove();\n logger.verbose(\"[%s] Successfully removed the cbs session.\", this.connection.id);\n }\n } catch (err) {\n const msg = `An error occurred while removing the cbs link: ${err.stack ||\n JSON.stringify(err)}.`;\n logger.verbose(\"[%s] %s\", this.connection.id, msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Indicates whether the cbs sender receiver link is open or closed.\n * @returns `true` open, `false` closed.\n */\n public isOpen(): boolean {\n return Boolean(this._cbsSenderReceiverLink?.isOpen());\n }\n\n private _fromRheaMessageResponse(msg: RheaMessage): CbsResponse {\n const cbsResponse = {\n correlationId: msg.correlation_id! as string,\n statusCode: msg.application_properties ? msg.application_properties[\"status-code\"] : \"\",\n statusDescription: msg.application_properties\n ? msg.application_properties[\"status-description\"]\n : \"\"\n };\n logger.verbose(\"[%s] The deserialized CBS response is: %o\", this.connection.id, cbsResponse);\n return cbsResponse;\n }\n}\n"]}
|
package/dist-esm/src/errors.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { isAmqpError as rheaIsAmqpError } from "rhea-promise";
|
|
5
5
|
import { isNode, isNumber, isString } from "../src/util/utils";
|
|
6
6
|
import { isDefined, isObjectWithProperties } from "./util/typeGuards";
|
|
7
|
+
/**
|
|
8
|
+
* The standard error message accompanying an AbortError.
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export const StandardAbortMessage = "The operation was aborted.";
|
|
7
12
|
/**
|
|
8
13
|
* Maps the conditions to the numeric AMQP Response status codes.
|
|
9
14
|
* @internal
|
|
@@ -495,6 +500,9 @@ export const retryableErrors = [
|
|
|
495
500
|
"ServerBusyError",
|
|
496
501
|
"ServiceUnavailableError",
|
|
497
502
|
"OperationCancelledError",
|
|
503
|
+
// The service may throw UnauthorizedError if credentials have been rotated.
|
|
504
|
+
// Attempt to retry in case the user has also rotated their credentials.
|
|
505
|
+
"UnauthorizedError",
|
|
498
506
|
// OperationTimeoutError occurs when the service fails to respond within a given timeframe.
|
|
499
507
|
// Since reasons for such failures can be transient, this is treated as a retryable error.
|
|
500
508
|
"OperationTimeoutError",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA2B;AAE3B,OAAO,EAAqC,WAAW,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAN,IAAY,qBAqBX;AArBD,WAAY,qBAAqB;IAC/B,qGAA+D,CAAA;IAC/D,uFAAkD,CAAA;IAClD,mGAA8D,CAAA;IAC9D,iIAAuE,CAAA;IACvE,yHAA+D,CAAA;IAC/D,yHAA+D,CAAA;IAC/D,uIAAqF,CAAA;IACrF,yHAAoE,CAAA;IACpE,6GAAuE,CAAA;IACvE,mHAAkE,CAAA;IAClE,iIAAyE,CAAA;IACzE,qHAA6D,CAAA;IAC7D,uIAAsE,CAAA;IACtE,6HAAiE,CAAA;IACjE,qHAAmE,CAAA;IACnE,yHAAuE,CA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;SACzF;QACD,IAAI,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;YAC7C,YAAY;YACZ,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;SACzB;QACD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,uBAAuB,CAAC,GAAG,CAAC,EAAE;QAChC,uGAAuG;QACvG,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,8BAA8B,CAAC,CAAC;QACjE,KAAK,CAAC,IAAI,GAAG,wBAAwB,CAAC,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;QAC1F,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QACxB,OAAO,KAAK,CAAC;KACd;IAED,iFAAiF;IACjF,wCAAwC;IACxC,IAAI,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;QAC9C,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACnD,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,KAAK,CAAC,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;YAC5D,YAAY;YACZ,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;SACzB;QACD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAU;IAC7B,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable eqeqeq */\n\nimport { AmqpError, AmqpResponseStatusCode, isAmqpError as rheaIsAmqpError } from \"rhea-promise\";\nimport { isNode, isNumber, isString } from \"../src/util/utils\";\nimport { isDefined, isObjectWithProperties } from \"./util/typeGuards\";\n\n/**\n * Maps the conditions to the numeric AMQP Response status codes.\n * @internal\n */\nexport enum ConditionStatusMapper {\n \"com.microsoft:timeout\" = AmqpResponseStatusCode.RequestTimeout,\n \"amqp:not-found\" = AmqpResponseStatusCode.NotFound,\n \"amqp:not-implemented\" = AmqpResponseStatusCode.NotImplemented,\n \"com.microsoft:entity-already-exists\" = AmqpResponseStatusCode.Conflict,\n \"com.microsoft:message-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:session-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:no-matching-subscription\" = AmqpResponseStatusCode.InternalServerError,\n \"amqp:link:message-size-exceeded\" = AmqpResponseStatusCode.Forbidden,\n \"com.microsoft:server-busy\" = AmqpResponseStatusCode.ServiceUnavailable,\n \"com.microsoft:argument-error\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:argument-out-of-range\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:store-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:session-cannot-be-locked\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:partition-not-owned\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:entity-disabled\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:publisher-revoked\" = AmqpResponseStatusCode.Unauthorized,\n \"amqp:link:stolen\" = AmqpResponseStatusCode.Gone,\n \"amqp:not-allowed\" = AmqpResponseStatusCode.BadRequest,\n \"amqp:unauthorized-access\" = AmqpResponseStatusCode.Unauthorized,\n \"amqp:resource-limit-exceeded\" = AmqpResponseStatusCode.Forbidden\n}\n\n/**\n * Maps the amqp error conditions to the Error names.\n */\nexport enum ConditionErrorNameMapper {\n /**\n * Error is thrown when the address is already in use.\n */\n \"com.microsoft:address-already-in-use\" = \"AddressAlreadyInUseError\",\n /**\n * Error is thrown when the store lock is lost.\n */\n \"com.microsoft:store-lock-lost\" = \"StoreLockLostError\",\n /**\n * Error is thrown when a matching subscription is not found.\n */\n \"com.microsoft:no-matching-subscription\" = \"NoMatchingSubscriptionError\",\n /**\n * Error is thrown when an attempt is made to access a partition that is not owned by the\n * requesting entity.\n */\n \"com.microsoft:partition-not-owned\" = \"PartitionNotOwnedError\",\n /**\n * Error is thrown when access to publisher has been revoked.\n */\n \"com.microsoft:publisher-revoked\" = \"PublisherRevokedError\",\n /**\n * Error is thrown when an attempt is made to create an entity that already exists.\n */\n \"com.microsoft:entity-already-exists\" = \"MessagingEntityAlreadyExistsError\",\n /**\n * Error is thrown when trying to access/connect to a disabled messaging entity.\n */\n \"com.microsoft:entity-disabled\" = \"MessagingEntityDisabledError\",\n /**\n * Error is thrown when the lock on the message is lost.\n */\n \"com.microsoft:message-lock-lost\" = \"MessageLockLostError\",\n /**\n * Error is thrown when the lock on the Azure ServiceBus session is lost.\n */\n \"com.microsoft:session-lock-lost\" = \"SessionLockLostError\",\n /**\n * Error is thrown when the Azure ServiceBus session cannot be locked.\n */\n \"com.microsoft:session-cannot-be-locked\" = \"SessionCannotBeLockedError\",\n /**\n * Error is thrown when an internal server error occurred. You may have found a bug?\n */\n \"amqp:internal-error\" = \"InternalServerError\", // Retryable\n /**\n * Error for signaling general communication errors related to messaging operations.\n */\n \"amqp:not-found\" = \"ServiceCommunicationError\",\n /**\n * Error is thrown when the message is not found.\n */\n \"com.microsoft:message-not-found\" = \"MessageNotFoundError\",\n /**\n * Error is thrown when relay is not found.\n */\n \"com.microsoft:relay-not-found\" = \"RelayNotFoundError\",\n /**\n * Error is thrown when a feature is not implemented yet but the placeholder is present.\n */\n \"amqp:not-implemented\" = \"NotImplementedError\",\n /**\n * Error is thrown when an operation is attempted but is not allowed.\n */\n \"amqp:not-allowed\" = \"InvalidOperationError\",\n /**\n * Error is thrown the the Azure EventHub/ServiceBus quota has been exceeded.\n * Quotas are reset periodically, this operation will have to wait until then.\n * The messaging entity has reached its maximum allowable size.\n * This can happen if the maximum number of receivers (which is 5) has already\n * been opened on a per-consumer group level.\n */\n \"amqp:resource-limit-exceeded\" = \"QuotaExceededError\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n \"amqp:unauthorized-access\" = \"UnauthorizedError\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n \"com.microsoft:auth-failed\" = \"UnauthorizedError\",\n /**\n * Error is thrown when the service is unavailable. The operation should be retried.\n */\n \"com.microsoft:timeout\" = \"ServiceUnavailableError\", // Retryable\n /**\n * Error is thrown when no new messages are received for the specified time.\n */\n \"com.microsoft:message-wait-timeout\" = \"MessageWaitTimeout\",\n /**\n * Error is thrown when an argument has a value that is out of the admissible range.\n */\n \"com.microsoft:argument-out-of-range\" = \"ArgumentOutOfRangeError\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n \"amqp:precondition-failed\" = \"PreconditionFailedError\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n \"com.microsoft:precondition-failed\" = \"PreconditionFailedError\",\n /**\n * Error is thrown when data could not be decoded.\n */\n \"amqp:decode-error\" = \"DecodeError\",\n /**\n * Error is thrown when an invalid field was passed in a frame body, and the operation could not proceed.\n */\n \"amqp:invalid-field\" = \"InvalidFieldError\",\n /**\n * Error is thrown when the client attempted to work with a server entity to which it\n * has no access because another client is working with it.\n */\n \"amqp:resource-locked\" = \"ResourceLockedError\",\n /**\n * Error is thrown when a server entity the client is working with has been deleted.\n */\n \"amqp:resource-deleted\" = \"ResourceDeletedError\",\n /**\n * Error is thrown when the peer sent a frame that is not permitted in the current state.\n */\n \"amqp:illegal-state\" = \"IllegalStateError\",\n /**\n * Error is thrown when the peer cannot send a frame because the smallest encoding of\n * the performative with the currently valid values would be too large to fit within\n * a frame of the agreed maximum frame size.\n */\n \"amqp:frame-size-too-small\" = \"FrameSizeTooSmallError\",\n /**\n * Error is thrown when an operator intervened to detach for some reason.\n */\n \"amqp:link:detach-forced\" = \"DetachForcedError\", // Retryable\n /**\n * Error is thrown when the peer sent more message transfers than currently allowed on the link.\n */\n \"amqp:link:transfer-limit-exceeded\" = \"TransferLimitExceededError\", // Retryable\n /**\n * Error is thrown when the message sent is too large: the maximum size is 256Kb.\n */\n \"amqp:link:message-size-exceeded\" = \"MessageTooLargeError\",\n /**\n * Error is thrown when the address provided cannot be resolved to a terminus at the current container.\n */\n \"amqp:link:redirect\" = \"LinkRedirectError\",\n /**\n * Error is thrown when two or more instances connect to the same partition\n * with different epoch values.\n */\n \"amqp:link:stolen\" = \"ReceiverDisconnectedError\",\n /**\n * Error is thrown when the peer violated incoming window for the session.\n */\n \"amqp:session:window-violation\" = \"SessionWindowViolationError\",\n /**\n * Error is thrown when input was received for a link that was detached with an error.\n */\n \"amqp:session:errant-link\" = \"ErrantLinkError\",\n /**\n * Error is thrown when an attach was received using a handle that is already in use for an attached link.\n */\n \"amqp:session:handle-in-use\" = \"HandleInUseError\",\n /**\n * Error is thrown when a frame (other than attach) was received referencing a handle which is not\n * currently in use of an attached link.\n */\n \"amqp:session:unattached-handle\" = \"UnattachedHandleError\",\n /**\n * Error is thrown when an operator intervened to close the connection for some reason.\n */\n \"amqp:connection:forced\" = \"ConnectionForcedError\", // Retryable\n /**\n * Error is thrown when a valid frame header cannot be formed from the incoming byte stream.\n */\n \"amqp:connection:framing-error\" = \"FramingError\",\n /**\n * Error is thrown when the container is no longer available on the current connection.\n */\n \"amqp:connection:redirect\" = \"ConnectionRedirectError\",\n /**\n * Error is thrown when the server is busy. Callers should wait a while and retry the operation.\n */\n \"com.microsoft:server-busy\" = \"ServerBusyError\", // Retryable\n /**\n * Error is thrown when an incorrect argument was received.\n */\n \"com.microsoft:argument-error\" = \"ArgumentError\",\n /**\n * Error is thrown when server cancels the operation due to an internal issue.\n */\n \"com.microsoft:operation-cancelled\" = \"OperationCancelledError\", // Retryable\n /**\n * Error is thrown when the client sender does not have enough link credits to send the message.\n */\n \"client.sender:not-enough-link-credit\" = \"SenderBusyError\", // Retryable\n /**\n * Error is thrown when a low level system error is thrown by node.js.\n * {@link https://nodejs.org/dist/latest-v8.x/docs/api/all.html#errors_class_system_error}\n */\n \"system:error\" = \"SystemError\"\n}\n\n/**\n * Maps the Error names to the amqp error conditions.\n */\nexport enum ErrorNameConditionMapper {\n /**\n * Error is thrown when the address is already in use.\n */\n AddressAlreadyInUseError = \"com.microsoft:address-already-in-use\",\n /**\n * Error is thrown when the store lock is lost.\n */\n StoreLockLostError = \"com.microsoft:store-lock-lost\",\n /**\n * Error is thrown when a matching subscription is not found.\n */\n NoMatchingSubscriptionError = \"com.microsoft:no-matching-subscription\",\n /**\n * Error is thrown when an attempt is made to access a partition that is not owned by the\n * requesting entity.\n */\n PartitionNotOwnedError = \"com.microsoft:partition-not-owned\",\n /**\n * Error is thrown when access to publisher has been revoked.\n */\n PublisherRevokedError = \"com.microsoft:publisher-revoked\",\n /**\n * Error is thrown when an attempt is made to create an entity that already exists.\n */\n MessagingEntityAlreadyExistsError = \"com.microsoft:entity-already-exists\",\n /**\n * Error is thrown when trying to access/connect to a disabled messaging entity.\n */\n MessagingEntityDisabledError = \"com.microsoft:entity-disabled\",\n /**\n * Error is thrown when the lock on the message is lost.\n */\n MessageLockLostError = \"com.microsoft:message-lock-lost\",\n /**\n * Error is thrown when the lock on the Azure ServiceBus session is lost.\n */\n SessionLockLostError = \"com.microsoft:session-lock-lost\",\n /**\n * Error is thrown when the Azure ServiceBus session cannot be locked.\n */\n SessionCannotBeLockedError = \"com.microsoft:session-cannot-be-locked\",\n /**\n * Error is thrown when an internal server error occurred. You may have found a bug?\n */\n InternalServerError = \"amqp:internal-error\", // Retryable\n /**\n * Error for signaling general communication errors related to messaging operations.\n */\n ServiceCommunicationError = \"amqp:not-found\",\n /**\n * Error is thrown when message is not found.\n */\n MessageNotFoundError = \"com.microsoft:message-not-found\",\n /**\n * Error is thrown when relay is not found.\n */\n RelayNotFoundError = \"com.microsoft:relay-not-found\",\n /**\n * Error is thrown when a feature is not implemented yet but the placeholder is present.\n */\n NotImplementedError = \"amqp:not-implemented\",\n /**\n * Error is thrown when an operation is attempted but is not allowed.\n */\n InvalidOperationError = \"amqp:not-allowed\",\n /**\n * Error is thrown the the Azure EventHub/ServiceBus quota has been exceeded.\n * Quotas are reset periodically, this operation will have to wait until then.\n * The messaging entity has reached its maximum allowable size.\n * This can happen if the maximum number of receivers (which is 5) has already\n * been opened on a per-consumer group level.\n */\n QuotaExceededError = \"amqp:resource-limit-exceeded\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n UnauthorizedError = \"amqp:unauthorized-access\",\n /**\n * Error is thrown when the service is unavailable. The operation should be retried.\n */\n ServiceUnavailableError = \"com.microsoft:timeout\", // Retryable\n /**\n * Error is thrown when no new messages are received for the specified time.\n */\n MessageWaitTimeout = \"com.microsoft:message-wait-timeout\",\n /**\n * Error is thrown when an argument has a value that is out of the admissible range.\n */\n ArgumentOutOfRangeError = \"com.microsoft:argument-out-of-range\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n PreconditionFailedError = \"amqp:precondition-failed\",\n /**\n * Error is thrown when data could not be decoded.\n */\n DecodeError = \"amqp:decode-error\",\n /**\n * Error is thrown when an invalid field was passed in a frame body, and the operation could not proceed.\n */\n InvalidFieldError = \"amqp:invalid-field\",\n /**\n * Error is thrown when the client attempted to work with a server entity to which it\n * has no access because another client is working with it.\n */\n ResourceLockedError = \"amqp:resource-locked\",\n /**\n * Error is thrown when a server entity the client is working with has been deleted.\n */\n ResourceDeletedError = \"amqp:resource-deleted\",\n /**\n * Error is thrown when the peer sent a frame that is not permitted in the current state.\n */\n IllegalStateError = \"amqp:illegal-state\",\n /**\n * Error is thrown when the peer cannot send a frame because the smallest encoding of\n * the performative with the currently valid values would be too large to fit within\n * a frame of the agreed maximum frame size.\n */\n FrameSizeTooSmallError = \"amqp:frame-size-too-small\",\n /**\n * Error is thrown when an operator intervened to detach for some reason.\n */\n DetachForcedError = \"amqp:link:detach-forced\", // Retryable\n /**\n * Error is thrown when the peer sent more message transfers than currently allowed on the link.\n */\n TransferLimitExceededError = \"amqp:link:transfer-limit-exceeded\", // Retryable\n /**\n * Error is thrown when the message sent is too large: the maximum size is 256Kb.\n */\n MessageTooLargeError = \"amqp:link:message-size-exceeded\",\n /**\n * Error is thrown when the address provided cannot be resolved to a terminus at the current container.\n */\n LinkRedirectError = \"amqp:link:redirect\",\n /**\n * Error is thrown when two or more instances connect to the same partition\n * with different epoch values.\n */\n ReceiverDisconnectedError = \"amqp:link:stolen\",\n /**\n * Error is thrown when the peer violated incoming window for the session.\n */\n SessionWindowViolationError = \"amqp:session:window-violation\",\n /**\n * Error is thrown when input was received for a link that was detached with an error.\n */\n ErrantLinkError = \"amqp:session:errant-link\",\n /**\n * Error is thrown when an attach was received using a handle that is already in use for an attached link.\n */\n HandleInUseError = \"amqp:session:handle-in-use\",\n /**\n * Error is thrown when a frame (other than attach) was received referencing a handle which is not\n * currently in use of an attached link.\n */\n UnattachedHandleError = \"amqp:session:unattached-handle\",\n /**\n * Error is thrown when an operator intervened to close the connection for some reason.\n */\n ConnectionForcedError = \"amqp:connection:forced\", // Retryable\n /**\n * Error is thrown when a valid frame header cannot be formed from the incoming byte stream.\n */\n FramingError = \"amqp:connection:framing-error\",\n /**\n * Error is thrown when the container is no longer available on the current connection.\n */\n ConnectionRedirectError = \"amqp:connection:redirect\",\n /**\n * Error is thrown when the server is busy. Callers should wait a while and retry the operation.\n */\n ServerBusyError = \"com.microsoft:server-busy\", // Retryable\n /**\n * Error is thrown when an incorrect argument was received.\n */\n ArgumentError = \"com.microsoft:argument-error\",\n /**\n * Error is thrown when server cancels the operation due to an internal issue.\n */\n OperationCancelledError = \"com.microsoft:operation-cancelled\", // Retryable\n /**\n * Error is thrown when the client sender does not have enough link credits to send the message.\n */\n SenderBusyError = \"client.sender:not-enough-link-credit\", // Retryable\n /**\n * Error is thrown when a low level system error is thrown by node.js.\n * {@link https://nodejs.org/api/errors.html#errors_class_systemerror}\n */\n SystemError = \"system:error\"\n}\n\n/**\n * Describes the fields on a Node.js SystemError.\n * Omits fields that are not related to network calls (e.g. file system calls).\n * See https://nodejs.org/dist/latest-v12.x/docs/api/errors.html#errors_class_systemerror\n */\nexport interface NetworkSystemError {\n address?: string;\n code: string;\n errno: string | number;\n info?: any;\n message: string;\n name: string;\n port?: number;\n stack: string;\n syscall: string;\n}\n\n/**\n * @internal\n */\nconst systemErrorFieldsToCopy: (keyof Omit<NetworkSystemError, \"name\" | \"message\">)[] = [\n \"address\",\n \"code\",\n \"errno\",\n \"info\",\n \"port\",\n \"stack\",\n \"syscall\"\n];\n\n/**\n * Determines if an error is a MessagingError.\n *\n * @param error - An error that can either be an Error or a MessagingError.\n */\nexport function isMessagingError(error: Error | MessagingError): error is MessagingError {\n return error.name === \"MessagingError\";\n}\n\n/**\n * Describes the base class for Messaging Error.\n */\nexport class MessagingError extends Error {\n /**\n * Address to which the network connection failed.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n address?: string;\n /**\n * A string label that identifies the error.\n */\n code?: string;\n /**\n * System-provided error number.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n errno?: number | string;\n /**\n * The error name. Default value: \"MessagingError\".\n */\n name: string = \"MessagingError\";\n /**\n * The unavailable network connection port.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n port?: number;\n /**\n * Name of the system call that triggered the error.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n syscall?: string;\n /**\n *\n * Describes whether the error is retryable. Default: true.\n */\n retryable: boolean = true;\n /**\n * Extra details about the error.\n */\n info?: any;\n /**\n * @param message - The error message that provides more information about the error.\n * @param originalError - An error whose properties will be copied to the MessagingError if the\n * property matches one found on the Node.js `SystemError`.\n */\n constructor(message: string, originalError?: Error) {\n super(message);\n\n if (!originalError) {\n return;\n }\n\n // copy properties from system error\n for (const propName of systemErrorFieldsToCopy) {\n if ((originalError as NetworkSystemError)[propName] != undefined) {\n this[propName] = (originalError as NetworkSystemError)[propName];\n }\n }\n }\n}\n\n/**\n * Provides a list of retryable AMQP errors.\n * \"InternalServerError\", \"ServerBusyError\", \"ServiceUnavailableError\", \"OperationCancelledError\",\n * \"SenderBusyError\", \"MessagingError\", \"DetachForcedError\", \"ConnectionForcedError\",\n * \"TransferLimitExceededError\"\n */\nexport const retryableErrors: string[] = [\n \"InternalServerError\",\n \"ServerBusyError\",\n \"ServiceUnavailableError\",\n \"OperationCancelledError\",\n\n // OperationTimeoutError occurs when the service fails to respond within a given timeframe.\n // Since reasons for such failures can be transient, this is treated as a retryable error.\n \"OperationTimeoutError\",\n\n \"SenderBusyError\",\n \"MessagingError\",\n \"DetachForcedError\",\n \"ConnectionForcedError\",\n \"TransferLimitExceededError\",\n\n // InsufficientCreditError occurs when the number of credits available on Rhea link is insufficient.\n // Since reasons for such shortage can be transient such as for pending delivery of messages, this is treated as a retryable error.\n \"InsufficientCreditError\"\n];\n\n/**\n * Maps some SystemErrors to amqp error conditions\n */\nexport enum SystemErrorConditionMapper {\n ENOTFOUND = \"amqp:not-found\",\n EBUSY = \"com.microsoft:server-busy\",\n ECONNREFUSED = \"amqp:connection:forced\",\n ETIMEDOUT = \"com.microsoft:timeout\",\n ECONNRESET = \"com.microsoft:timeout\",\n ENETDOWN = \"com.microsoft:timeout\",\n EHOSTDOWN = \"com.microsoft:timeout\",\n ENETRESET = \"com.microsoft:timeout\",\n ENETUNREACH = \"com.microsoft:timeout\",\n ENONET = \"com.microsoft:timeout\"\n}\n\n/**\n * Checks whether the provided error is a node.js SystemError.\n * @param err - An object that may contain error information.\n */\nexport function isSystemError(err: unknown): err is NetworkSystemError {\n if (!isObjectWithProperties(err, [\"code\", \"syscall\", \"errno\"])) {\n return false;\n }\n\n if (!isString(err.code) || !isString(err.syscall)) {\n return false;\n }\n\n if (!isString(err.errno) && !isNumber(err.errno)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * @internal\n * Since browser doesn't differentiate between the various kinds of service communication errors,\n * this utility is used to look at the error target to identify such category of errors.\n * For more information refer to - https://html.spec.whatwg.org/multipage/comms.html#feedback-from-the-protocol\n * @param err - object that may contain error information\n */\nfunction isBrowserWebsocketError(err: any): boolean {\n let result: boolean = false;\n if (!isNode && self && err.type === \"error\" && err.target instanceof (self as any).WebSocket) {\n result = true;\n }\n return result;\n}\n\n/**\n * @internal\n */\nconst rheaPromiseErrors = [\n // OperationTimeoutError occurs when the service fails to respond within a given timeframe.\n \"OperationTimeoutError\",\n\n // InsufficientCreditError occurs when the number of credits available on Rhea link is insufficient.\n \"InsufficientCreditError\",\n\n // Defines the error that occurs when the Sender fails to send a message.\n \"SendOperationFailedError\"\n];\n\n/**\n * Translates the AMQP error received at the protocol layer or a SystemError into a MessagingError.\n * All other errors are returned unaltered.\n *\n * @param err - The amqp error that was received.\n * @returns MessagingError object.\n */\nexport function translate(err: AmqpError | Error): MessagingError | Error {\n if (!isDefined(err)) {\n return new Error(`Unknown error encountered.`);\n } else if (typeof err !== \"object\") {\n // The error is a scalar type, make it the message of an actual error.\n return new Error(err);\n }\n // Built-in errors like TypeError and RangeError should not be retryable as these indicate issues\n // with user input and not an issue with the Messaging process.\n if (err instanceof TypeError || err instanceof RangeError) {\n return err;\n }\n\n if (isAmqpError(err)) {\n // translate\n const condition = err.condition;\n const description = err.description!;\n const error = new MessagingError(description);\n if ((err as any).stack) error.stack = (err as any).stack;\n error.info = err.info;\n if (condition) {\n error.code = ConditionErrorNameMapper[condition as keyof typeof ConditionErrorNameMapper];\n }\n if (\n description &&\n (description.includes(\"status-code: 404\") ||\n description.match(/The messaging entity .* could not be found.*/i) !== null)\n ) {\n error.code = \"MessagingEntityNotFoundError\";\n }\n if (error.code && retryableErrors.indexOf(error.code) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n if (err.name === \"MessagingError\") {\n // already translated\n return err;\n }\n\n if (isSystemError(err)) {\n // translate\n const condition = err.code;\n const description = err.message;\n const error = new MessagingError(description, err);\n let errorType = \"SystemError\";\n if (condition) {\n const amqpErrorCondition =\n SystemErrorConditionMapper[condition as keyof typeof SystemErrorConditionMapper];\n errorType =\n ConditionErrorNameMapper[amqpErrorCondition as keyof typeof ConditionErrorNameMapper];\n }\n if (retryableErrors.indexOf(errorType) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n if (isBrowserWebsocketError(err)) {\n // Translate browser communication errors during opening handshake to generic ServiceCommunicationError\n const error = new MessagingError(\"Websocket connection failed.\");\n error.code = ConditionErrorNameMapper[ErrorNameConditionMapper.ServiceCommunicationError];\n error.retryable = false;\n return error;\n }\n\n // Some errors come from rhea-promise and need to be converted to MessagingError.\n // A subset of these are also retryable.\n if (rheaPromiseErrors.indexOf(err.name) !== -1) {\n const error = new MessagingError(err.message, err);\n error.code = err.name;\n if (error.code && retryableErrors.indexOf(error.code) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n return err;\n}\n\n/**\n * @internal\n */\nfunction isAmqpError(error: any): error is AmqpError {\n return rheaIsAmqpError(error);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA2B;AAE3B,OAAO,EAAqC,WAAW,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAN,IAAY,qBAqBX;AArBD,WAAY,qBAAqB;IAC/B,qGAA+D,CAAA;IAC/D,uFAAkD,CAAA;IAClD,mGAA8D,CAAA;IAC9D,iIAAuE,CAAA;IACvE,yHAA+D,CAAA;IAC/D,yHAA+D,CAAA;IAC/D,uIAAqF,CAAA;IACrF,yHAAoE,CAAA;IACpE,6GAAuE,CAA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oft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable eqeqeq */\n\nimport { AmqpError, AmqpResponseStatusCode, isAmqpError as rheaIsAmqpError } from \"rhea-promise\";\nimport { isNode, isNumber, isString } from \"../src/util/utils\";\nimport { isDefined, isObjectWithProperties } from \"./util/typeGuards\";\n\n/**\n * The standard error message accompanying an AbortError.\n * @hidden\n */\nexport const StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * Maps the conditions to the numeric AMQP Response status codes.\n * @internal\n */\nexport enum ConditionStatusMapper {\n \"com.microsoft:timeout\" = AmqpResponseStatusCode.RequestTimeout,\n \"amqp:not-found\" = AmqpResponseStatusCode.NotFound,\n \"amqp:not-implemented\" = AmqpResponseStatusCode.NotImplemented,\n \"com.microsoft:entity-already-exists\" = AmqpResponseStatusCode.Conflict,\n \"com.microsoft:message-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:session-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:no-matching-subscription\" = AmqpResponseStatusCode.InternalServerError,\n \"amqp:link:message-size-exceeded\" = AmqpResponseStatusCode.Forbidden,\n \"com.microsoft:server-busy\" = AmqpResponseStatusCode.ServiceUnavailable,\n \"com.microsoft:argument-error\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:argument-out-of-range\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:store-lock-lost\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:session-cannot-be-locked\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:partition-not-owned\" = AmqpResponseStatusCode.Gone,\n \"com.microsoft:entity-disabled\" = AmqpResponseStatusCode.BadRequest,\n \"com.microsoft:publisher-revoked\" = AmqpResponseStatusCode.Unauthorized,\n \"amqp:link:stolen\" = AmqpResponseStatusCode.Gone,\n \"amqp:not-allowed\" = AmqpResponseStatusCode.BadRequest,\n \"amqp:unauthorized-access\" = AmqpResponseStatusCode.Unauthorized,\n \"amqp:resource-limit-exceeded\" = AmqpResponseStatusCode.Forbidden\n}\n\n/**\n * Maps the amqp error conditions to the Error names.\n */\nexport enum ConditionErrorNameMapper {\n /**\n * Error is thrown when the address is already in use.\n */\n \"com.microsoft:address-already-in-use\" = \"AddressAlreadyInUseError\",\n /**\n * Error is thrown when the store lock is lost.\n */\n \"com.microsoft:store-lock-lost\" = \"StoreLockLostError\",\n /**\n * Error is thrown when a matching subscription is not found.\n */\n \"com.microsoft:no-matching-subscription\" = \"NoMatchingSubscriptionError\",\n /**\n * Error is thrown when an attempt is made to access a partition that is not owned by the\n * requesting entity.\n */\n \"com.microsoft:partition-not-owned\" = \"PartitionNotOwnedError\",\n /**\n * Error is thrown when access to publisher has been revoked.\n */\n \"com.microsoft:publisher-revoked\" = \"PublisherRevokedError\",\n /**\n * Error is thrown when an attempt is made to create an entity that already exists.\n */\n \"com.microsoft:entity-already-exists\" = \"MessagingEntityAlreadyExistsError\",\n /**\n * Error is thrown when trying to access/connect to a disabled messaging entity.\n */\n \"com.microsoft:entity-disabled\" = \"MessagingEntityDisabledError\",\n /**\n * Error is thrown when the lock on the message is lost.\n */\n \"com.microsoft:message-lock-lost\" = \"MessageLockLostError\",\n /**\n * Error is thrown when the lock on the Azure ServiceBus session is lost.\n */\n \"com.microsoft:session-lock-lost\" = \"SessionLockLostError\",\n /**\n * Error is thrown when the Azure ServiceBus session cannot be locked.\n */\n \"com.microsoft:session-cannot-be-locked\" = \"SessionCannotBeLockedError\",\n /**\n * Error is thrown when an internal server error occurred. You may have found a bug?\n */\n \"amqp:internal-error\" = \"InternalServerError\", // Retryable\n /**\n * Error for signaling general communication errors related to messaging operations.\n */\n \"amqp:not-found\" = \"ServiceCommunicationError\",\n /**\n * Error is thrown when the message is not found.\n */\n \"com.microsoft:message-not-found\" = \"MessageNotFoundError\",\n /**\n * Error is thrown when relay is not found.\n */\n \"com.microsoft:relay-not-found\" = \"RelayNotFoundError\",\n /**\n * Error is thrown when a feature is not implemented yet but the placeholder is present.\n */\n \"amqp:not-implemented\" = \"NotImplementedError\",\n /**\n * Error is thrown when an operation is attempted but is not allowed.\n */\n \"amqp:not-allowed\" = \"InvalidOperationError\",\n /**\n * Error is thrown the the Azure EventHub/ServiceBus quota has been exceeded.\n * Quotas are reset periodically, this operation will have to wait until then.\n * The messaging entity has reached its maximum allowable size.\n * This can happen if the maximum number of receivers (which is 5) has already\n * been opened on a per-consumer group level.\n */\n \"amqp:resource-limit-exceeded\" = \"QuotaExceededError\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n \"amqp:unauthorized-access\" = \"UnauthorizedError\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n \"com.microsoft:auth-failed\" = \"UnauthorizedError\",\n /**\n * Error is thrown when the service is unavailable. The operation should be retried.\n */\n \"com.microsoft:timeout\" = \"ServiceUnavailableError\", // Retryable\n /**\n * Error is thrown when no new messages are received for the specified time.\n */\n \"com.microsoft:message-wait-timeout\" = \"MessageWaitTimeout\",\n /**\n * Error is thrown when an argument has a value that is out of the admissible range.\n */\n \"com.microsoft:argument-out-of-range\" = \"ArgumentOutOfRangeError\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n \"amqp:precondition-failed\" = \"PreconditionFailedError\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n \"com.microsoft:precondition-failed\" = \"PreconditionFailedError\",\n /**\n * Error is thrown when data could not be decoded.\n */\n \"amqp:decode-error\" = \"DecodeError\",\n /**\n * Error is thrown when an invalid field was passed in a frame body, and the operation could not proceed.\n */\n \"amqp:invalid-field\" = \"InvalidFieldError\",\n /**\n * Error is thrown when the client attempted to work with a server entity to which it\n * has no access because another client is working with it.\n */\n \"amqp:resource-locked\" = \"ResourceLockedError\",\n /**\n * Error is thrown when a server entity the client is working with has been deleted.\n */\n \"amqp:resource-deleted\" = \"ResourceDeletedError\",\n /**\n * Error is thrown when the peer sent a frame that is not permitted in the current state.\n */\n \"amqp:illegal-state\" = \"IllegalStateError\",\n /**\n * Error is thrown when the peer cannot send a frame because the smallest encoding of\n * the performative with the currently valid values would be too large to fit within\n * a frame of the agreed maximum frame size.\n */\n \"amqp:frame-size-too-small\" = \"FrameSizeTooSmallError\",\n /**\n * Error is thrown when an operator intervened to detach for some reason.\n */\n \"amqp:link:detach-forced\" = \"DetachForcedError\", // Retryable\n /**\n * Error is thrown when the peer sent more message transfers than currently allowed on the link.\n */\n \"amqp:link:transfer-limit-exceeded\" = \"TransferLimitExceededError\", // Retryable\n /**\n * Error is thrown when the message sent is too large: the maximum size is 256Kb.\n */\n \"amqp:link:message-size-exceeded\" = \"MessageTooLargeError\",\n /**\n * Error is thrown when the address provided cannot be resolved to a terminus at the current container.\n */\n \"amqp:link:redirect\" = \"LinkRedirectError\",\n /**\n * Error is thrown when two or more instances connect to the same partition\n * with different epoch values.\n */\n \"amqp:link:stolen\" = \"ReceiverDisconnectedError\",\n /**\n * Error is thrown when the peer violated incoming window for the session.\n */\n \"amqp:session:window-violation\" = \"SessionWindowViolationError\",\n /**\n * Error is thrown when input was received for a link that was detached with an error.\n */\n \"amqp:session:errant-link\" = \"ErrantLinkError\",\n /**\n * Error is thrown when an attach was received using a handle that is already in use for an attached link.\n */\n \"amqp:session:handle-in-use\" = \"HandleInUseError\",\n /**\n * Error is thrown when a frame (other than attach) was received referencing a handle which is not\n * currently in use of an attached link.\n */\n \"amqp:session:unattached-handle\" = \"UnattachedHandleError\",\n /**\n * Error is thrown when an operator intervened to close the connection for some reason.\n */\n \"amqp:connection:forced\" = \"ConnectionForcedError\", // Retryable\n /**\n * Error is thrown when a valid frame header cannot be formed from the incoming byte stream.\n */\n \"amqp:connection:framing-error\" = \"FramingError\",\n /**\n * Error is thrown when the container is no longer available on the current connection.\n */\n \"amqp:connection:redirect\" = \"ConnectionRedirectError\",\n /**\n * Error is thrown when the server is busy. Callers should wait a while and retry the operation.\n */\n \"com.microsoft:server-busy\" = \"ServerBusyError\", // Retryable\n /**\n * Error is thrown when an incorrect argument was received.\n */\n \"com.microsoft:argument-error\" = \"ArgumentError\",\n /**\n * Error is thrown when server cancels the operation due to an internal issue.\n */\n \"com.microsoft:operation-cancelled\" = \"OperationCancelledError\", // Retryable\n /**\n * Error is thrown when the client sender does not have enough link credits to send the message.\n */\n \"client.sender:not-enough-link-credit\" = \"SenderBusyError\", // Retryable\n /**\n * Error is thrown when a low level system error is thrown by node.js.\n * {@link https://nodejs.org/dist/latest-v8.x/docs/api/all.html#errors_class_system_error}\n */\n \"system:error\" = \"SystemError\"\n}\n\n/**\n * Maps the Error names to the amqp error conditions.\n */\nexport enum ErrorNameConditionMapper {\n /**\n * Error is thrown when the address is already in use.\n */\n AddressAlreadyInUseError = \"com.microsoft:address-already-in-use\",\n /**\n * Error is thrown when the store lock is lost.\n */\n StoreLockLostError = \"com.microsoft:store-lock-lost\",\n /**\n * Error is thrown when a matching subscription is not found.\n */\n NoMatchingSubscriptionError = \"com.microsoft:no-matching-subscription\",\n /**\n * Error is thrown when an attempt is made to access a partition that is not owned by the\n * requesting entity.\n */\n PartitionNotOwnedError = \"com.microsoft:partition-not-owned\",\n /**\n * Error is thrown when access to publisher has been revoked.\n */\n PublisherRevokedError = \"com.microsoft:publisher-revoked\",\n /**\n * Error is thrown when an attempt is made to create an entity that already exists.\n */\n MessagingEntityAlreadyExistsError = \"com.microsoft:entity-already-exists\",\n /**\n * Error is thrown when trying to access/connect to a disabled messaging entity.\n */\n MessagingEntityDisabledError = \"com.microsoft:entity-disabled\",\n /**\n * Error is thrown when the lock on the message is lost.\n */\n MessageLockLostError = \"com.microsoft:message-lock-lost\",\n /**\n * Error is thrown when the lock on the Azure ServiceBus session is lost.\n */\n SessionLockLostError = \"com.microsoft:session-lock-lost\",\n /**\n * Error is thrown when the Azure ServiceBus session cannot be locked.\n */\n SessionCannotBeLockedError = \"com.microsoft:session-cannot-be-locked\",\n /**\n * Error is thrown when an internal server error occurred. You may have found a bug?\n */\n InternalServerError = \"amqp:internal-error\", // Retryable\n /**\n * Error for signaling general communication errors related to messaging operations.\n */\n ServiceCommunicationError = \"amqp:not-found\",\n /**\n * Error is thrown when message is not found.\n */\n MessageNotFoundError = \"com.microsoft:message-not-found\",\n /**\n * Error is thrown when relay is not found.\n */\n RelayNotFoundError = \"com.microsoft:relay-not-found\",\n /**\n * Error is thrown when a feature is not implemented yet but the placeholder is present.\n */\n NotImplementedError = \"amqp:not-implemented\",\n /**\n * Error is thrown when an operation is attempted but is not allowed.\n */\n InvalidOperationError = \"amqp:not-allowed\",\n /**\n * Error is thrown the the Azure EventHub/ServiceBus quota has been exceeded.\n * Quotas are reset periodically, this operation will have to wait until then.\n * The messaging entity has reached its maximum allowable size.\n * This can happen if the maximum number of receivers (which is 5) has already\n * been opened on a per-consumer group level.\n */\n QuotaExceededError = \"amqp:resource-limit-exceeded\",\n /**\n * Error is thrown when the connection parameters are wrong and the server refused the connection.\n */\n UnauthorizedError = \"amqp:unauthorized-access\",\n /**\n * Error is thrown when the service is unavailable. The operation should be retried.\n */\n ServiceUnavailableError = \"com.microsoft:timeout\", // Retryable\n /**\n * Error is thrown when no new messages are received for the specified time.\n */\n MessageWaitTimeout = \"com.microsoft:message-wait-timeout\",\n /**\n * Error is thrown when an argument has a value that is out of the admissible range.\n */\n ArgumentOutOfRangeError = \"com.microsoft:argument-out-of-range\",\n /**\n * Error is thrown when a condition that should have been met in order to execute an operation was not.\n */\n PreconditionFailedError = \"amqp:precondition-failed\",\n /**\n * Error is thrown when data could not be decoded.\n */\n DecodeError = \"amqp:decode-error\",\n /**\n * Error is thrown when an invalid field was passed in a frame body, and the operation could not proceed.\n */\n InvalidFieldError = \"amqp:invalid-field\",\n /**\n * Error is thrown when the client attempted to work with a server entity to which it\n * has no access because another client is working with it.\n */\n ResourceLockedError = \"amqp:resource-locked\",\n /**\n * Error is thrown when a server entity the client is working with has been deleted.\n */\n ResourceDeletedError = \"amqp:resource-deleted\",\n /**\n * Error is thrown when the peer sent a frame that is not permitted in the current state.\n */\n IllegalStateError = \"amqp:illegal-state\",\n /**\n * Error is thrown when the peer cannot send a frame because the smallest encoding of\n * the performative with the currently valid values would be too large to fit within\n * a frame of the agreed maximum frame size.\n */\n FrameSizeTooSmallError = \"amqp:frame-size-too-small\",\n /**\n * Error is thrown when an operator intervened to detach for some reason.\n */\n DetachForcedError = \"amqp:link:detach-forced\", // Retryable\n /**\n * Error is thrown when the peer sent more message transfers than currently allowed on the link.\n */\n TransferLimitExceededError = \"amqp:link:transfer-limit-exceeded\", // Retryable\n /**\n * Error is thrown when the message sent is too large: the maximum size is 256Kb.\n */\n MessageTooLargeError = \"amqp:link:message-size-exceeded\",\n /**\n * Error is thrown when the address provided cannot be resolved to a terminus at the current container.\n */\n LinkRedirectError = \"amqp:link:redirect\",\n /**\n * Error is thrown when two or more instances connect to the same partition\n * with different epoch values.\n */\n ReceiverDisconnectedError = \"amqp:link:stolen\",\n /**\n * Error is thrown when the peer violated incoming window for the session.\n */\n SessionWindowViolationError = \"amqp:session:window-violation\",\n /**\n * Error is thrown when input was received for a link that was detached with an error.\n */\n ErrantLinkError = \"amqp:session:errant-link\",\n /**\n * Error is thrown when an attach was received using a handle that is already in use for an attached link.\n */\n HandleInUseError = \"amqp:session:handle-in-use\",\n /**\n * Error is thrown when a frame (other than attach) was received referencing a handle which is not\n * currently in use of an attached link.\n */\n UnattachedHandleError = \"amqp:session:unattached-handle\",\n /**\n * Error is thrown when an operator intervened to close the connection for some reason.\n */\n ConnectionForcedError = \"amqp:connection:forced\", // Retryable\n /**\n * Error is thrown when a valid frame header cannot be formed from the incoming byte stream.\n */\n FramingError = \"amqp:connection:framing-error\",\n /**\n * Error is thrown when the container is no longer available on the current connection.\n */\n ConnectionRedirectError = \"amqp:connection:redirect\",\n /**\n * Error is thrown when the server is busy. Callers should wait a while and retry the operation.\n */\n ServerBusyError = \"com.microsoft:server-busy\", // Retryable\n /**\n * Error is thrown when an incorrect argument was received.\n */\n ArgumentError = \"com.microsoft:argument-error\",\n /**\n * Error is thrown when server cancels the operation due to an internal issue.\n */\n OperationCancelledError = \"com.microsoft:operation-cancelled\", // Retryable\n /**\n * Error is thrown when the client sender does not have enough link credits to send the message.\n */\n SenderBusyError = \"client.sender:not-enough-link-credit\", // Retryable\n /**\n * Error is thrown when a low level system error is thrown by node.js.\n * {@link https://nodejs.org/api/errors.html#errors_class_systemerror}\n */\n SystemError = \"system:error\"\n}\n\n/**\n * Describes the fields on a Node.js SystemError.\n * Omits fields that are not related to network calls (e.g. file system calls).\n * See https://nodejs.org/dist/latest-v12.x/docs/api/errors.html#errors_class_systemerror\n */\nexport interface NetworkSystemError {\n address?: string;\n code: string;\n errno: string | number;\n info?: any;\n message: string;\n name: string;\n port?: number;\n stack: string;\n syscall: string;\n}\n\n/**\n * @internal\n */\nconst systemErrorFieldsToCopy: (keyof Omit<NetworkSystemError, \"name\" | \"message\">)[] = [\n \"address\",\n \"code\",\n \"errno\",\n \"info\",\n \"port\",\n \"stack\",\n \"syscall\"\n];\n\n/**\n * Determines if an error is a MessagingError.\n *\n * @param error - An error that can either be an Error or a MessagingError.\n */\nexport function isMessagingError(error: Error | MessagingError): error is MessagingError {\n return error.name === \"MessagingError\";\n}\n\n/**\n * Describes the base class for Messaging Error.\n */\nexport class MessagingError extends Error {\n /**\n * Address to which the network connection failed.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n address?: string;\n /**\n * A string label that identifies the error.\n */\n code?: string;\n /**\n * System-provided error number.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n errno?: number | string;\n /**\n * The error name. Default value: \"MessagingError\".\n */\n name: string = \"MessagingError\";\n /**\n * The unavailable network connection port.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n port?: number;\n /**\n * Name of the system call that triggered the error.\n * Only present if the `MessagingError` was instantiated with a Node.js `SystemError`.\n */\n syscall?: string;\n /**\n *\n * Describes whether the error is retryable. Default: true.\n */\n retryable: boolean = true;\n /**\n * Extra details about the error.\n */\n info?: any;\n /**\n * @param message - The error message that provides more information about the error.\n * @param originalError - An error whose properties will be copied to the MessagingError if the\n * property matches one found on the Node.js `SystemError`.\n */\n constructor(message: string, originalError?: Error) {\n super(message);\n\n if (!originalError) {\n return;\n }\n\n // copy properties from system error\n for (const propName of systemErrorFieldsToCopy) {\n if ((originalError as NetworkSystemError)[propName] != undefined) {\n this[propName] = (originalError as NetworkSystemError)[propName];\n }\n }\n }\n}\n\n/**\n * Provides a list of retryable AMQP errors.\n * \"InternalServerError\", \"ServerBusyError\", \"ServiceUnavailableError\", \"OperationCancelledError\",\n * \"SenderBusyError\", \"MessagingError\", \"DetachForcedError\", \"ConnectionForcedError\",\n * \"TransferLimitExceededError\"\n */\nexport const retryableErrors: string[] = [\n \"InternalServerError\",\n \"ServerBusyError\",\n \"ServiceUnavailableError\",\n \"OperationCancelledError\",\n\n // The service may throw UnauthorizedError if credentials have been rotated.\n // Attempt to retry in case the user has also rotated their credentials.\n \"UnauthorizedError\",\n\n // OperationTimeoutError occurs when the service fails to respond within a given timeframe.\n // Since reasons for such failures can be transient, this is treated as a retryable error.\n \"OperationTimeoutError\",\n\n \"SenderBusyError\",\n \"MessagingError\",\n \"DetachForcedError\",\n \"ConnectionForcedError\",\n \"TransferLimitExceededError\",\n\n // InsufficientCreditError occurs when the number of credits available on Rhea link is insufficient.\n // Since reasons for such shortage can be transient such as for pending delivery of messages, this is treated as a retryable error.\n \"InsufficientCreditError\"\n];\n\n/**\n * Maps some SystemErrors to amqp error conditions\n */\nexport enum SystemErrorConditionMapper {\n ENOTFOUND = \"amqp:not-found\",\n EBUSY = \"com.microsoft:server-busy\",\n ECONNREFUSED = \"amqp:connection:forced\",\n ETIMEDOUT = \"com.microsoft:timeout\",\n ECONNRESET = \"com.microsoft:timeout\",\n ENETDOWN = \"com.microsoft:timeout\",\n EHOSTDOWN = \"com.microsoft:timeout\",\n ENETRESET = \"com.microsoft:timeout\",\n ENETUNREACH = \"com.microsoft:timeout\",\n ENONET = \"com.microsoft:timeout\"\n}\n\n/**\n * Checks whether the provided error is a node.js SystemError.\n * @param err - An object that may contain error information.\n */\nexport function isSystemError(err: unknown): err is NetworkSystemError {\n if (!isObjectWithProperties(err, [\"code\", \"syscall\", \"errno\"])) {\n return false;\n }\n\n if (!isString(err.code) || !isString(err.syscall)) {\n return false;\n }\n\n if (!isString(err.errno) && !isNumber(err.errno)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * @internal\n * Since browser doesn't differentiate between the various kinds of service communication errors,\n * this utility is used to look at the error target to identify such category of errors.\n * For more information refer to - https://html.spec.whatwg.org/multipage/comms.html#feedback-from-the-protocol\n * @param err - object that may contain error information\n */\nfunction isBrowserWebsocketError(err: any): boolean {\n let result: boolean = false;\n if (!isNode && self && err.type === \"error\" && err.target instanceof (self as any).WebSocket) {\n result = true;\n }\n return result;\n}\n\n/**\n * @internal\n */\nconst rheaPromiseErrors = [\n // OperationTimeoutError occurs when the service fails to respond within a given timeframe.\n \"OperationTimeoutError\",\n\n // InsufficientCreditError occurs when the number of credits available on Rhea link is insufficient.\n \"InsufficientCreditError\",\n\n // Defines the error that occurs when the Sender fails to send a message.\n \"SendOperationFailedError\"\n];\n\n/**\n * Translates the AMQP error received at the protocol layer or a SystemError into a MessagingError.\n * All other errors are returned unaltered.\n *\n * @param err - The amqp error that was received.\n * @returns MessagingError object.\n */\nexport function translate(err: AmqpError | Error): MessagingError | Error {\n if (!isDefined(err)) {\n return new Error(`Unknown error encountered.`);\n } else if (typeof err !== \"object\") {\n // The error is a scalar type, make it the message of an actual error.\n return new Error(err);\n }\n // Built-in errors like TypeError and RangeError should not be retryable as these indicate issues\n // with user input and not an issue with the Messaging process.\n if (err instanceof TypeError || err instanceof RangeError) {\n return err;\n }\n\n if (isAmqpError(err)) {\n // translate\n const condition = err.condition;\n const description = err.description!;\n const error = new MessagingError(description);\n if ((err as any).stack) error.stack = (err as any).stack;\n error.info = err.info;\n if (condition) {\n error.code = ConditionErrorNameMapper[condition as keyof typeof ConditionErrorNameMapper];\n }\n if (\n description &&\n (description.includes(\"status-code: 404\") ||\n description.match(/The messaging entity .* could not be found.*/i) !== null)\n ) {\n error.code = \"MessagingEntityNotFoundError\";\n }\n if (error.code && retryableErrors.indexOf(error.code) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n if (err.name === \"MessagingError\") {\n // already translated\n return err;\n }\n\n if (isSystemError(err)) {\n // translate\n const condition = err.code;\n const description = err.message;\n const error = new MessagingError(description, err);\n let errorType = \"SystemError\";\n if (condition) {\n const amqpErrorCondition =\n SystemErrorConditionMapper[condition as keyof typeof SystemErrorConditionMapper];\n errorType =\n ConditionErrorNameMapper[amqpErrorCondition as keyof typeof ConditionErrorNameMapper];\n }\n if (retryableErrors.indexOf(errorType) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n if (isBrowserWebsocketError(err)) {\n // Translate browser communication errors during opening handshake to generic ServiceCommunicationError\n const error = new MessagingError(\"Websocket connection failed.\");\n error.code = ConditionErrorNameMapper[ErrorNameConditionMapper.ServiceCommunicationError];\n error.retryable = false;\n return error;\n }\n\n // Some errors come from rhea-promise and need to be converted to MessagingError.\n // A subset of these are also retryable.\n if (rheaPromiseErrors.indexOf(err.name) !== -1) {\n const error = new MessagingError(err.message, err);\n error.code = err.name;\n if (error.code && retryableErrors.indexOf(error.code) === -1) {\n // not found\n error.retryable = false;\n }\n return error;\n }\n\n return err;\n}\n\n/**\n * @internal\n */\nfunction isAmqpError(error: any): error is AmqpError {\n return rheaIsAmqpError(error);\n}\n"]}
|
package/dist-esm/src/index.js
CHANGED
|
@@ -10,8 +10,9 @@ export { Constants } from "./util/constants";
|
|
|
10
10
|
export { AmqpMessageHeader } from "./messageHeader";
|
|
11
11
|
export { AmqpMessageProperties } from "./messageProperties";
|
|
12
12
|
export { ConnectionContextBase } from "./ConnectionContextBase";
|
|
13
|
-
export { MessagingError, isMessagingError, ErrorNameConditionMapper, ConditionErrorNameMapper, translate, retryableErrors, isSystemError, SystemErrorConditionMapper } from "./errors";
|
|
14
|
-
export { delay, parseConnectionString,
|
|
13
|
+
export { MessagingError, isMessagingError, ErrorNameConditionMapper, ConditionErrorNameMapper, translate, retryableErrors, isSystemError, SystemErrorConditionMapper, StandardAbortMessage } from "./errors";
|
|
14
|
+
export { delay, parseConnectionString, defaultCancellableLock } from "./util/utils";
|
|
15
15
|
export { AmqpAnnotatedMessage } from "./amqpAnnotatedMessage";
|
|
16
16
|
export { logger } from "./log";
|
|
17
|
+
export * from "./internals";
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,8BAA8B;AAE9B,OAAO,EAAE,mBAAmB,EAAsB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,EAA6B,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAA2B,MAAM,qCAAqC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,qBAAqB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,eAAe,EACf,aAAa,EACb,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,8BAA8B;AAE9B,OAAO,EAAE,mBAAmB,EAAsB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,EAA6B,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAA2B,MAAM,qCAAqC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,qBAAqB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,eAAe,EACf,aAAa,EACb,0BAA0B,EAE1B,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// <reference lib=\"es2015\" />\n\nexport { RequestResponseLink, SendRequestOptions } from \"./requestResponseLink\";\nexport { retry, RetryOptions, RetryConfig, RetryOperationType, RetryMode } from \"./retry\";\nexport { TokenType } from \"./auth/token\";\n\nexport { ConnectionConfig, ConnectionConfigOptions } from \"./connectionConfig/connectionConfig\";\n\nexport { CbsClient, CbsResponse } from \"./cbs\";\nexport { Constants } from \"./util/constants\";\nexport { AmqpMessageHeader } from \"./messageHeader\";\nexport { AmqpMessageProperties } from \"./messageProperties\";\nexport {\n ConnectionContextBase,\n ConnectionProperties,\n CreateConnectionContextBaseParameters\n} from \"./ConnectionContextBase\";\nexport {\n MessagingError,\n isMessagingError,\n ErrorNameConditionMapper,\n ConditionErrorNameMapper,\n translate,\n retryableErrors,\n isSystemError,\n SystemErrorConditionMapper,\n NetworkSystemError,\n StandardAbortMessage\n} from \"./errors\";\nexport {\n delay,\n parseConnectionString,\n defaultCancellableLock,\n ParsedOutput,\n WebSocketOptions\n} from \"./util/utils\";\nexport { AmqpAnnotatedMessage } from \"./amqpAnnotatedMessage\";\nexport { logger } from \"./log\";\nexport * from \"./internals\";\nexport { AcquireLockProperties, CancellableAsyncLock } from \"./util/lock\";\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { createSasTokenProvider } from "./auth/tokenProvider";
|
|
4
|
+
import { isSasTokenProvider } from "./util/typeGuards";
|
|
5
|
+
export { createSasTokenProvider, isSasTokenProvider };
|
|
6
|
+
//# sourceMappingURL=internals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internals.js","sourceRoot":"","sources":["../../src/internals.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAoB,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAoB,sBAAsB,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SasTokenProvider, createSasTokenProvider } from \"./auth/tokenProvider\";\nimport { isSasTokenProvider } from \"./util/typeGuards\";\n\nexport { SasTokenProvider, createSasTokenProvider, isSasTokenProvider };\n"]}
|
|
@@ -15,7 +15,7 @@ export const AmqpMessageProperties = {
|
|
|
15
15
|
toRheaMessageProperties(props) {
|
|
16
16
|
const amqpProperties = {};
|
|
17
17
|
if (props.absoluteExpiryTime != undefined) {
|
|
18
|
-
amqpProperties.absolute_expiry_time = props.absoluteExpiryTime;
|
|
18
|
+
amqpProperties.absolute_expiry_time = new Date(props.absoluteExpiryTime);
|
|
19
19
|
}
|
|
20
20
|
if (props.contentEncoding != undefined) {
|
|
21
21
|
amqpProperties.content_encoding = props.contentEncoding;
|
|
@@ -27,7 +27,7 @@ export const AmqpMessageProperties = {
|
|
|
27
27
|
amqpProperties.correlation_id = props.correlationId;
|
|
28
28
|
}
|
|
29
29
|
if (props.creationTime != undefined) {
|
|
30
|
-
amqpProperties.creation_time = props.creationTime;
|
|
30
|
+
amqpProperties.creation_time = new Date(props.creationTime);
|
|
31
31
|
}
|
|
32
32
|
if (props.groupId != undefined) {
|
|
33
33
|
amqpProperties.group_id = props.groupId;
|
|
@@ -64,7 +64,7 @@ export const AmqpMessageProperties = {
|
|
|
64
64
|
fromRheaMessageProperties(props) {
|
|
65
65
|
const msgProperties = {};
|
|
66
66
|
if (props.absolute_expiry_time != undefined) {
|
|
67
|
-
msgProperties.absoluteExpiryTime = props.absolute_expiry_time;
|
|
67
|
+
msgProperties.absoluteExpiryTime = props.absolute_expiry_time.getTime();
|
|
68
68
|
}
|
|
69
69
|
if (props.content_encoding != undefined) {
|
|
70
70
|
msgProperties.contentEncoding = props.content_encoding;
|
|
@@ -76,7 +76,7 @@ export const AmqpMessageProperties = {
|
|
|
76
76
|
msgProperties.correlationId = props.correlation_id;
|
|
77
77
|
}
|
|
78
78
|
if (props.creation_time != undefined) {
|
|
79
|
-
msgProperties.creationTime = props.creation_time;
|
|
79
|
+
msgProperties.creationTime = props.creation_time.getTime();
|
|
80
80
|
}
|
|
81
81
|
if (props.group_id != undefined) {
|
|
82
82
|
msgProperties.groupId = props.group_id;
|