@azure/core-amqp 4.4.2-alpha.20260311.2 → 4.4.2

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.
Files changed (76) hide show
  1. package/dist/browser/errors.js +14 -0
  2. package/dist/browser/errors.js.map +1 -1
  3. package/dist/browser/requestResponseLink.js +3 -1
  4. package/dist/browser/requestResponseLink.js.map +1 -1
  5. package/dist/browser/util/lock.js +1 -1
  6. package/dist/browser/util/lock.js.map +1 -1
  7. package/dist/browser/util/utils.d.ts +0 -76
  8. package/dist/browser/util/utils.js +0 -89
  9. package/dist/browser/util/utils.js.map +1 -1
  10. package/dist/commonjs/ConnectionContextBase.js +1 -0
  11. package/dist/commonjs/ConnectionContextBase.js.map +1 -1
  12. package/dist/commonjs/amqpAnnotatedMessage.js +1 -0
  13. package/dist/commonjs/amqpAnnotatedMessage.js.map +1 -1
  14. package/dist/commonjs/auth/token.js +1 -0
  15. package/dist/commonjs/auth/token.js.map +1 -1
  16. package/dist/commonjs/auth/tokenProvider.js +1 -0
  17. package/dist/commonjs/auth/tokenProvider.js.map +1 -1
  18. package/dist/commonjs/cbs.js +1 -0
  19. package/dist/commonjs/cbs.js.map +1 -1
  20. package/dist/commonjs/connectionConfig/connectionConfig.js +1 -0
  21. package/dist/commonjs/connectionConfig/connectionConfig.js.map +1 -1
  22. package/dist/commonjs/errors.js +9 -0
  23. package/dist/commonjs/errors.js.map +3 -3
  24. package/dist/commonjs/index.js +1 -0
  25. package/dist/commonjs/index.js.map +1 -1
  26. package/dist/commonjs/internals.js +1 -0
  27. package/dist/commonjs/internals.js.map +1 -1
  28. package/dist/commonjs/log.js +1 -0
  29. package/dist/commonjs/log.js.map +1 -1
  30. package/dist/commonjs/messageHeader.js +1 -0
  31. package/dist/commonjs/messageHeader.js.map +1 -1
  32. package/dist/commonjs/messageProperties.js +1 -0
  33. package/dist/commonjs/messageProperties.js.map +1 -1
  34. package/dist/commonjs/requestResponseLink.js +5 -1
  35. package/dist/commonjs/requestResponseLink.js.map +3 -3
  36. package/dist/commonjs/retry.js +1 -0
  37. package/dist/commonjs/retry.js.map +1 -1
  38. package/dist/commonjs/tsdoc-metadata.json +1 -1
  39. package/dist/commonjs/util/checkNetworkConnection.common.js +1 -0
  40. package/dist/commonjs/util/checkNetworkConnection.common.js.map +1 -1
  41. package/dist/commonjs/util/checkNetworkConnection.js +1 -0
  42. package/dist/commonjs/util/checkNetworkConnection.js.map +1 -1
  43. package/dist/commonjs/util/constants.js +1 -0
  44. package/dist/commonjs/util/constants.js.map +1 -1
  45. package/dist/commonjs/util/hmacSha256.common.js +1 -0
  46. package/dist/commonjs/util/hmacSha256.common.js.map +1 -1
  47. package/dist/commonjs/util/hmacSha256.js +1 -0
  48. package/dist/commonjs/util/hmacSha256.js.map +1 -1
  49. package/dist/commonjs/util/lock.js +10 -6
  50. package/dist/commonjs/util/lock.js.map +3 -3
  51. package/dist/commonjs/util/runtimeInfo.js +1 -0
  52. package/dist/commonjs/util/runtimeInfo.js.map +1 -1
  53. package/dist/commonjs/util/typeGuards.js +1 -0
  54. package/dist/commonjs/util/typeGuards.js.map +1 -1
  55. package/dist/commonjs/util/utils.d.ts +0 -76
  56. package/dist/commonjs/util/utils.js +3 -66
  57. package/dist/commonjs/util/utils.js.map +3 -3
  58. package/dist/esm/errors.js +14 -0
  59. package/dist/esm/errors.js.map +1 -1
  60. package/dist/esm/requestResponseLink.js +3 -1
  61. package/dist/esm/requestResponseLink.js.map +1 -1
  62. package/dist/esm/util/lock.js +1 -1
  63. package/dist/esm/util/lock.js.map +1 -1
  64. package/dist/esm/util/utils.d.ts +0 -76
  65. package/dist/esm/util/utils.js +0 -89
  66. package/dist/esm/util/utils.js.map +1 -1
  67. package/dist/react-native/errors.js +14 -0
  68. package/dist/react-native/errors.js.map +1 -1
  69. package/dist/react-native/requestResponseLink.js +3 -1
  70. package/dist/react-native/requestResponseLink.js.map +1 -1
  71. package/dist/react-native/util/lock.js +1 -1
  72. package/dist/react-native/util/lock.js.map +1 -1
  73. package/dist/react-native/util/utils.d.ts +0 -76
  74. package/dist/react-native/util/utils.js +0 -89
  75. package/dist/react-native/util/utils.js.map +1 -1
  76. package/package.json +14 -12
@@ -1,30 +1,6 @@
1
1
  import type { CancellableAsyncLock } from "./lock.js";
2
2
  import type { AbortSignalLike } from "@azure/abort-controller";
3
3
  import type { WebSocketImpl } from "rhea-promise";
4
- /**
5
- * @internal
6
- *
7
- * Describes the options that can be provided to create an async lock.
8
- */
9
- export interface AsyncLockOptions {
10
- /**
11
- * The max timeout. Default is: 0 (never timeout).
12
- */
13
- timeout?: number;
14
- /**
15
- * Maximum pending tasks. Default is: 1000.
16
- */
17
- maxPending?: number;
18
- /**
19
- * Whether lock can reenter in the same domain.
20
- * Default is: false.
21
- */
22
- domainReentrant?: boolean;
23
- /**
24
- * Your implementation of the promise. Default is: global promise.
25
- */
26
- Promise?: any;
27
- }
28
4
  /**
29
5
  * Options to configure the channelling of the AMQP connection over Web Sockets.
30
6
  */
@@ -69,21 +45,6 @@ export declare function parseConnectionString<T>(connectionString: string): Pars
69
45
  * The cancellable async lock instance.
70
46
  */
71
47
  export declare const defaultCancellableLock: CancellableAsyncLock;
72
- /**
73
- * @internal
74
- *
75
- * Describes a Timeout class that can wait for the specified amount of time and then resolve/reject
76
- * the promise with the given value.
77
- */
78
- export declare class Timeout {
79
- private _timer?;
80
- set<T>(t: number, value?: T): Promise<T>;
81
- clear(): void;
82
- wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T>;
83
- private _promiseFinally;
84
- static set<T>(t: number, value?: T): Promise<T>;
85
- static wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T>;
86
- }
87
48
  /**
88
49
  * A wrapper for setTimeout that resolves a promise after t milliseconds.
89
50
  * @param delayInMs - The number of milliseconds to be delayed.
@@ -99,43 +60,6 @@ export declare function delay<T>(delayInMs: number, abortSignal?: AbortSignalLik
99
60
  * @returns true if the address is localhost, false otherwise.
100
61
  */
101
62
  export declare function isLoopbackAddress(address: string): boolean;
102
- /**
103
- * @internal
104
- *
105
- * Generates a random number between the given interval
106
- * @param min - Min number of the range (inclusive).
107
- * @param max - Max number of the range (inclusive).
108
- */
109
- export declare function randomNumberFromInterval(min: number, max: number): number;
110
- /**
111
- * @internal
112
- *
113
- * Type declaration for a Function type where T is the input to the function and V is the output
114
- * of the function.
115
- */
116
- export type Func<T, V> = (a: T) => V;
117
- /**
118
- * @internal
119
- *
120
- * Executes an array of promises sequentially. Inspiration of this method is here:
121
- * https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html. An awesome blog on promises!
122
- *
123
- * @param promiseFactories - An array of promise factories(A function that return a promise)
124
- *
125
- * @param kickstart - Input to the first promise that is used to kickstart the promise chain.
126
- * If not provided then the promise chain starts with undefined.
127
- *
128
- * @returns A chain of resolved or rejected promises
129
- */
130
- export declare function executePromisesSequentially(promiseFactories: Array<any>, kickstart?: unknown): Promise<any>;
131
- /**
132
- * @internal
133
- *
134
- * Determines whether the given connection string is an iothub connection string.
135
- * @param connectionString - The connection string.
136
- * @returns boolean.
137
- */
138
- export declare function isIotHubConnectionString(connectionString: string): boolean;
139
63
  /**
140
64
  * @internal
141
65
  */
@@ -42,49 +42,6 @@ export function parseConnectionString(connectionString) {
42
42
  * The cancellable async lock instance.
43
43
  */
44
44
  export const defaultCancellableLock = new CancellableAsyncLockImpl();
45
- /**
46
- * @internal
47
- *
48
- * Describes a Timeout class that can wait for the specified amount of time and then resolve/reject
49
- * the promise with the given value.
50
- */
51
- export class Timeout {
52
- _timer;
53
- set(t, value) {
54
- return new Promise((resolve, reject) => {
55
- this.clear();
56
- const callback = value ? () => reject(new Error(`${value}`)) : resolve;
57
- this._timer = setTimeout(callback, t);
58
- });
59
- }
60
- clear() {
61
- if (this._timer) {
62
- clearTimeout(this._timer);
63
- }
64
- }
65
- wrap(promise, t, value) {
66
- const wrappedPromise = this._promiseFinally(promise, () => this.clear());
67
- const timer = this.set(t, value);
68
- return Promise.race([wrappedPromise, timer]);
69
- }
70
- _promiseFinally(promise, fn) {
71
- const success = (result) => {
72
- fn();
73
- return result;
74
- };
75
- const error = (e) => {
76
- fn();
77
- return Promise.reject(e);
78
- };
79
- return Promise.resolve(promise).then(success, error);
80
- }
81
- static set(t, value) {
82
- return new Timeout().set(t, value);
83
- }
84
- static wrap(promise, t, value) {
85
- return new Timeout().wrap(promise, t, value);
86
- }
87
- }
88
45
  /**
89
46
  * A wrapper for setTimeout that resolves a promise after t milliseconds.
90
47
  * @param delayInMs - The number of milliseconds to be delayed.
@@ -110,52 +67,6 @@ export async function delay(delayInMs, abortSignal, abortErrorMsg, value) {
110
67
  export function isLoopbackAddress(address) {
111
68
  return /^(.*:\/\/)?(127\.[\d.]+|[0:]+1|localhost)/.test(address.toLowerCase());
112
69
  }
113
- /**
114
- * @internal
115
- *
116
- * Generates a random number between the given interval
117
- * @param min - Min number of the range (inclusive).
118
- * @param max - Max number of the range (inclusive).
119
- */
120
- export function randomNumberFromInterval(min, max) {
121
- return Math.floor(Math.random() * (max - min + 1) + min);
122
- }
123
- /**
124
- * @internal
125
- *
126
- * Executes an array of promises sequentially. Inspiration of this method is here:
127
- * https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html. An awesome blog on promises!
128
- *
129
- * @param promiseFactories - An array of promise factories(A function that return a promise)
130
- *
131
- * @param kickstart - Input to the first promise that is used to kickstart the promise chain.
132
- * If not provided then the promise chain starts with undefined.
133
- *
134
- * @returns A chain of resolved or rejected promises
135
- */
136
- export function executePromisesSequentially(promiseFactories, kickstart) {
137
- let result = Promise.resolve(kickstart);
138
- promiseFactories.forEach((promiseFactory) => {
139
- result = result.then(promiseFactory);
140
- });
141
- return result;
142
- }
143
- /**
144
- * @internal
145
- *
146
- * Determines whether the given connection string is an iothub connection string.
147
- * @param connectionString - The connection string.
148
- * @returns boolean.
149
- */
150
- export function isIotHubConnectionString(connectionString) {
151
- const cs = String(connectionString);
152
- let result = false;
153
- const model = parseConnectionString(cs);
154
- if (model && model.HostName && model.SharedAccessKey && model.SharedAccessKeyName) {
155
- result = true;
156
- }
157
- return result;
158
- }
159
70
  /**
160
71
  * @internal
161
72
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoDzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAI,gBAAwB;IAC/D,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEnB,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAChB,qBAAqB;YACrB,SAAS;QACX,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;QACJ,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEpD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;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5B,SAAmB;IAEnB,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC,gBAAgB,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;QAC1C,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAAwB;IAC/D,MAAM,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEpC,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAQ,qBAAqB,CAAM,EAAE,CAAC,CAAC;IAClD,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAClF,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAU,GAAW;IACpD,IAAI,CAAC;QACH,MAAM,CAAC,GAAQ,UAAiB,CAAC;QACjC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAkB,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CancellableAsyncLock } from \"./lock.js\";\nimport { CancellableAsyncLockImpl } from \"./lock.js\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { WebSocketImpl } from \"rhea-promise\";\nimport { delay as wrapperDelay } from \"@azure/core-util\";\n\n/**\n * @internal\n *\n * Describes the options that can be provided to create an async lock.\n */\nexport interface AsyncLockOptions {\n /**\n * The max timeout. Default is: 0 (never timeout).\n */\n timeout?: number;\n /**\n * Maximum pending tasks. Default is: 1000.\n */\n maxPending?: number;\n /**\n * Whether lock can reenter in the same domain.\n * Default is: false.\n */\n domainReentrant?: boolean;\n /**\n * Your implementation of the promise. Default is: global promise.\n */\n Promise?: any;\n}\n\n/**\n * Options to configure the channelling of the AMQP connection over Web Sockets.\n */\nexport interface WebSocketOptions {\n /**\n * The WebSocket constructor used to create an AMQP connection over a WebSocket.\n * This option should be provided in the below scenarios:\n * - The TCP port 5671 which is that is used by the AMQP connection to Event Hubs is blocked in your environment.\n * - Your application needs to be run behind a proxy server.\n * - Your application needs to run in the browser and you want to provide your own choice of Websocket implementation\n * instead of the built-in WebSocket in the browser.\n */\n webSocket?: WebSocketImpl;\n /**\n * Options to be passed to the WebSocket constructor when the underlying `rhea` library instantiates\n * the WebSocket.\n */\n webSocketConstructorOptions?: any;\n}\n\n/**\n * Defines an object with possible properties defined in T.\n */\nexport type ParsedOutput<T> = { [P in keyof T]: T[P] };\n\n/**\n * Parses the connection string and returns an object of type T.\n *\n * Connection strings have the following syntax:\n *\n * ConnectionString ::= `Part { \";\" Part } [ \";\" ] [ WhiteSpace ]`\n * Part ::= [ PartLiteral [ \"=\" PartLiteral ] ]\n * PartLiteral ::= [ WhiteSpace ] Literal [ WhiteSpace ]\n * Literal ::= ? any sequence of characters except ; or = or WhiteSpace ?\n * WhiteSpace ::= ? all whitespace characters including `\\r` and `\\n` ?\n *\n * @param connectionString - The connection string to be parsed.\n * @returns ParsedOutput<T>.\n */\nexport function parseConnectionString<T>(connectionString: string): ParsedOutput<T> {\n const output: { [k: string]: string } = {};\n const parts = connectionString.trim().split(\";\");\n\n for (let part of parts) {\n part = part.trim();\n\n if (part === \"\") {\n // parts can be empty\n continue;\n }\n\n const splitIndex = part.indexOf(\"=\");\n if (splitIndex === -1) {\n throw new Error(\n \"Connection string malformed: each part of the connection string must have an `=` assignment.\",\n );\n }\n\n const key = part.substring(0, splitIndex).trim();\n if (key === \"\") {\n throw new Error(\"Connection string malformed: missing key for assignment\");\n }\n\n const value = part.substring(splitIndex + 1).trim();\n\n output[key] = value;\n }\n\n return output as any;\n}\n\n/**\n * The cancellable async lock instance.\n */\nexport const defaultCancellableLock: CancellableAsyncLock = new CancellableAsyncLockImpl();\n\n/**\n * @internal\n *\n * Describes a Timeout class that can wait for the specified amount of time and then resolve/reject\n * the promise with the given value.\n */\nexport class Timeout {\n private _timer?: ReturnType<typeof setTimeout>;\n\n set<T>(t: number, value?: T): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n this.clear();\n const callback: (args: any) => void = value ? () => reject(new Error(`${value}`)) : resolve;\n this._timer = setTimeout(callback, t);\n });\n }\n\n clear(): void {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n }\n\n wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T> {\n const wrappedPromise = this._promiseFinally(promise, () => this.clear());\n const timer = this.set(t, value);\n return Promise.race([wrappedPromise, timer]);\n }\n\n private _promiseFinally<T>(promise: Promise<T>, fn: (...args: any[]) => void): Promise<T> {\n const success = (result: T): T => {\n fn();\n return result;\n };\n const error = (e: Error): Promise<never> => {\n fn();\n return Promise.reject(e);\n };\n return Promise.resolve(promise).then(success, error);\n }\n\n static set<T>(t: number, value?: T): Promise<T> {\n return new Timeout().set(t, value);\n }\n\n static wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T> {\n return new Timeout().wrap(promise, t, value);\n }\n}\n\n/**\n * A wrapper for setTimeout that resolves a promise after t milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param abortSignal - The abortSignal associated with containing operation.\n * @param abortErrorMsg - The abort error message associated with containing operation.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @returns - Resolved promise\n */\nexport async function delay<T>(\n delayInMs: number,\n abortSignal?: AbortSignalLike,\n abortErrorMsg?: string,\n value?: T,\n): Promise<T | void> {\n await wrapperDelay(delayInMs, {\n abortSignal: abortSignal,\n abortErrorMsg: abortErrorMsg,\n });\n if (value !== undefined) {\n return value;\n }\n}\n\n/**\n * Checks if an address is localhost.\n * @param address - The address to check.\n * @returns true if the address is localhost, false otherwise.\n */\nexport function isLoopbackAddress(address: string): boolean {\n return /^(.*:\\/\\/)?(127\\.[\\d.]+|[0:]+1|localhost)/.test(address.toLowerCase());\n}\n\n/**\n * @internal\n *\n * Generates a random number between the given interval\n * @param min - Min number of the range (inclusive).\n * @param max - Max number of the range (inclusive).\n */\nexport function randomNumberFromInterval(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n\n/**\n * @internal\n *\n * Type declaration for a Function type where T is the input to the function and V is the output\n * of the function.\n */\nexport type Func<T, V> = (a: T) => V;\n\n/**\n * @internal\n *\n * Executes an array of promises sequentially. Inspiration of this method is here:\n * https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html. An awesome blog on promises!\n *\n * @param promiseFactories - An array of promise factories(A function that return a promise)\n *\n * @param kickstart - Input to the first promise that is used to kickstart the promise chain.\n * If not provided then the promise chain starts with undefined.\n *\n * @returns A chain of resolved or rejected promises\n */\nexport function executePromisesSequentially(\n promiseFactories: Array<any>,\n kickstart?: unknown,\n): Promise<any> {\n let result = Promise.resolve(kickstart);\n promiseFactories.forEach((promiseFactory) => {\n result = result.then(promiseFactory);\n });\n return result;\n}\n\n/**\n * @internal\n *\n * Determines whether the given connection string is an iothub connection string.\n * @param connectionString - The connection string.\n * @returns boolean.\n */\nexport function isIotHubConnectionString(connectionString: string): boolean {\n const cs = String(connectionString);\n\n let result: boolean = false;\n const model: any = parseConnectionString<any>(cs);\n if (model && model.HostName && model.SharedAccessKey && model.SharedAccessKeyName) {\n result = true;\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport function isString(s: unknown): s is string {\n return typeof s === \"string\";\n}\n\n/**\n * @internal\n */\nexport function isNumber(n: unknown): n is number {\n return typeof n === \"number\";\n}\n\n/**\n * @internal\n * Safely read a property from the global object by key.\n * Returns undefined if the property or global object is unavailable.\n */\nexport function getGlobalProperty<T = any>(key: string): T | undefined {\n try {\n const g: any = globalThis as any;\n return g?.[key] as T | undefined;\n } catch {\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA2BzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAI,gBAAwB;IAC/D,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEnB,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAChB,qBAAqB;YACrB,SAAS;QACX,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;QACJ,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEpD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,MAAyB,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAyB,IAAI,wBAAwB,EAAE,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,SAAiB,EACjB,WAA6B,EAC7B,aAAsB,EACtB,KAAS;IAET,MAAM,YAAY,CAAC,SAAS,EAAE;QAC5B,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,aAAa;KAC7B,CAAC,CAAC;IACH,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,2CAA2C,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAU,GAAW;IACpD,IAAI,CAAC;QACH,MAAM,CAAC,GAAQ,UAAiB,CAAC;QACjC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAkB,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CancellableAsyncLock } from \"./lock.js\";\nimport { CancellableAsyncLockImpl } from \"./lock.js\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { WebSocketImpl } from \"rhea-promise\";\nimport { delay as wrapperDelay } from \"@azure/core-util\";\n\n/**\n * Options to configure the channelling of the AMQP connection over Web Sockets.\n */\nexport interface WebSocketOptions {\n /**\n * The WebSocket constructor used to create an AMQP connection over a WebSocket.\n * This option should be provided in the below scenarios:\n * - The TCP port 5671 which is that is used by the AMQP connection to Event Hubs is blocked in your environment.\n * - Your application needs to be run behind a proxy server.\n * - Your application needs to run in the browser and you want to provide your own choice of Websocket implementation\n * instead of the built-in WebSocket in the browser.\n */\n webSocket?: WebSocketImpl;\n /**\n * Options to be passed to the WebSocket constructor when the underlying `rhea` library instantiates\n * the WebSocket.\n */\n webSocketConstructorOptions?: any;\n}\n\n/**\n * Defines an object with possible properties defined in T.\n */\nexport type ParsedOutput<T> = { [P in keyof T]: T[P] };\n\n/**\n * Parses the connection string and returns an object of type T.\n *\n * Connection strings have the following syntax:\n *\n * ConnectionString ::= `Part { \";\" Part } [ \";\" ] [ WhiteSpace ]`\n * Part ::= [ PartLiteral [ \"=\" PartLiteral ] ]\n * PartLiteral ::= [ WhiteSpace ] Literal [ WhiteSpace ]\n * Literal ::= ? any sequence of characters except ; or = or WhiteSpace ?\n * WhiteSpace ::= ? all whitespace characters including `\\r` and `\\n` ?\n *\n * @param connectionString - The connection string to be parsed.\n * @returns ParsedOutput<T>.\n */\nexport function parseConnectionString<T>(connectionString: string): ParsedOutput<T> {\n const output: Record<string, string> = {};\n const parts = connectionString.trim().split(\";\");\n\n for (let part of parts) {\n part = part.trim();\n\n if (part === \"\") {\n // parts can be empty\n continue;\n }\n\n const splitIndex = part.indexOf(\"=\");\n if (splitIndex === -1) {\n throw new Error(\n \"Connection string malformed: each part of the connection string must have an `=` assignment.\",\n );\n }\n\n const key = part.substring(0, splitIndex).trim();\n if (key === \"\") {\n throw new Error(\"Connection string malformed: missing key for assignment\");\n }\n\n const value = part.substring(splitIndex + 1).trim();\n\n output[key] = value;\n }\n\n return output as ParsedOutput<T>;\n}\n\n/**\n * The cancellable async lock instance.\n */\nexport const defaultCancellableLock: CancellableAsyncLock = new CancellableAsyncLockImpl();\n\n/**\n * A wrapper for setTimeout that resolves a promise after t milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param abortSignal - The abortSignal associated with containing operation.\n * @param abortErrorMsg - The abort error message associated with containing operation.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @returns - Resolved promise\n */\nexport async function delay<T>(\n delayInMs: number,\n abortSignal?: AbortSignalLike,\n abortErrorMsg?: string,\n value?: T,\n): Promise<T | void> {\n await wrapperDelay(delayInMs, {\n abortSignal: abortSignal,\n abortErrorMsg: abortErrorMsg,\n });\n if (value !== undefined) {\n return value;\n }\n}\n\n/**\n * Checks if an address is localhost.\n * @param address - The address to check.\n * @returns true if the address is localhost, false otherwise.\n */\nexport function isLoopbackAddress(address: string): boolean {\n return /^(.*:\\/\\/)?(127\\.[\\d.]+|[0:]+1|localhost)/.test(address.toLowerCase());\n}\n\n/**\n * @internal\n */\nexport function isString(s: unknown): s is string {\n return typeof s === \"string\";\n}\n\n/**\n * @internal\n */\nexport function isNumber(n: unknown): n is number {\n return typeof n === \"number\";\n}\n\n/**\n * @internal\n * Safely read a property from the global object by key.\n * Returns undefined if the property or global object is unavailable.\n */\nexport function getGlobalProperty<T = any>(key: string): T | undefined {\n try {\n const g: any = globalThis as any;\n return g?.[key] as T | undefined;\n } catch {\n return undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azure/core-amqp",
3
3
  "sdk-type": "client",
4
- "version": "4.4.2-alpha.20260311.2",
4
+ "version": "4.4.2",
5
5
  "description": "Common library for amqp based azure sdks like @azure/event-hubs.",
6
6
  "author": "Microsoft Corporation",
7
7
  "license": "MIT",
@@ -52,10 +52,10 @@
52
52
  "url": "https://github.com/Azure/azure-sdk-for-js/issues"
53
53
  },
54
54
  "dependencies": {
55
- "@azure/abort-controller": ">=2.1.3-alpha <2.1.3-alphb",
56
- "@azure/core-auth": ">=1.10.2-alpha <1.10.2-alphb",
57
- "@azure/core-util": ">=1.13.2-alpha <1.13.2-alphb",
58
- "@azure/logger": ">=1.3.1-alpha <1.3.1-alphb",
55
+ "@azure/abort-controller": "^2.1.2",
56
+ "@azure/core-auth": "^1.10.0",
57
+ "@azure/core-util": "^1.13.0",
58
+ "@azure/logger": "^1.3.0",
59
59
  "buffer": "^6.0.3",
60
60
  "events": "^3.3.0",
61
61
  "process": "^0.11.10",
@@ -68,21 +68,23 @@
68
68
  "@rollup/plugin-inject": "^5.0.5",
69
69
  "@types/debug": "^4.1.12",
70
70
  "@types/node": "^20.19.25",
71
+ "@types/react": "^19.2.14",
71
72
  "@types/ws": "^8.5.10",
72
- "@vitest/browser-playwright": "^4.0.8",
73
- "@vitest/coverage-istanbul": "^4.0.8",
73
+ "@vitest/browser-playwright": "^4.1.2",
74
+ "@vitest/coverage-istanbul": "^4.1.2",
74
75
  "cross-env": "^10.1.0",
75
76
  "debug": "^4.3.4",
76
77
  "eslint": "^9.39.1",
77
- "playwright": "^1.56.1",
78
+ "playwright": "^1.58.2",
78
79
  "prettier": "^3.6.2",
80
+ "react-native": "^0.84.1",
79
81
  "rimraf": "^6.1.0",
80
- "typescript": "~5.9.3",
81
- "vitest": "^4.0.8",
82
+ "typescript": "~6.0.2",
83
+ "vitest": "^4.1.2",
82
84
  "ws": "^8.17.0",
83
- "@azure-tools/vite-plugin-browser-test-map": "^1.0.0",
85
+ "@azure/dev-tool": "^1.0.0",
84
86
  "@azure/eslint-plugin-azure-sdk": "^3.0.0",
85
- "@azure/dev-tool": "^1.0.0"
87
+ "@azure-tools/vite-plugin-browser-test-map": "^1.0.0"
86
88
  },
87
89
  "//metadata": {
88
90
  "migrationDate": "2023-03-08T18:36:03.000Z"