@azure/core-amqp 4.4.0-alpha.20241008.3 → 4.4.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/LICENSE +3 -3
- package/README.md +3 -5
- package/dist/browser/ConnectionContextBase.js.map +1 -1
- package/dist/browser/amqpAnnotatedMessage.d.ts +1 -1
- package/dist/browser/amqpAnnotatedMessage.js +0 -1
- package/dist/browser/amqpAnnotatedMessage.js.map +1 -1
- package/dist/browser/auth/tokenProvider.d.ts +1 -1
- package/dist/browser/auth/tokenProvider.js +1 -1
- package/dist/browser/auth/tokenProvider.js.map +1 -1
- package/dist/browser/cbs.d.ts +3 -3
- package/dist/browser/cbs.js +1 -1
- package/dist/browser/cbs.js.map +1 -1
- package/dist/browser/connectionConfig/connectionConfig.d.ts +1 -1
- package/dist/browser/connectionConfig/connectionConfig.js +28 -9
- package/dist/browser/connectionConfig/connectionConfig.js.map +1 -1
- package/dist/browser/errors.d.ts +3 -1
- package/dist/browser/errors.js +2 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/index.js +0 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/messageHeader.d.ts +1 -1
- package/dist/browser/messageHeader.js.map +1 -1
- package/dist/browser/messageProperties.d.ts +1 -1
- package/dist/browser/messageProperties.js.map +1 -1
- package/dist/browser/requestResponseLink.d.ts +2 -2
- package/dist/browser/requestResponseLink.js +2 -2
- package/dist/browser/requestResponseLink.js.map +1 -1
- package/dist/browser/retry.d.ts +1 -1
- package/dist/browser/retry.js +4 -11
- package/dist/browser/retry.js.map +1 -1
- package/dist/browser/util/constants.d.ts +0 -1
- package/dist/browser/util/constants.js +0 -1
- package/dist/browser/util/constants.js.map +1 -1
- package/dist/browser/util/hmacSha256.common.d.ts +0 -15
- package/dist/browser/util/hmacSha256.common.js.map +1 -1
- package/dist/browser/util/lock.d.ts +1 -1
- package/dist/browser/util/lock.js.map +1 -1
- package/dist/browser/util/runtimeInfo-browser.mjs.map +1 -1
- package/dist/browser/util/typeGuards.d.ts +1 -1
- package/dist/browser/util/typeGuards.js.map +1 -1
- package/dist/browser/util/utils.d.ts +3 -3
- package/dist/browser/util/utils.js.map +1 -1
- package/dist/commonjs/ConnectionContextBase.js.map +1 -1
- package/dist/commonjs/amqpAnnotatedMessage.d.ts +1 -1
- package/dist/commonjs/amqpAnnotatedMessage.js +0 -1
- package/dist/commonjs/amqpAnnotatedMessage.js.map +1 -1
- package/dist/commonjs/auth/tokenProvider.d.ts +1 -1
- package/dist/commonjs/auth/tokenProvider.js.map +1 -1
- package/dist/commonjs/cbs.d.ts +3 -3
- package/dist/commonjs/cbs.js.map +1 -1
- package/dist/commonjs/connectionConfig/connectionConfig.d.ts +1 -1
- package/dist/commonjs/connectionConfig/connectionConfig.js +28 -9
- package/dist/commonjs/connectionConfig/connectionConfig.js.map +1 -1
- package/dist/commonjs/errors.d.ts +3 -1
- package/dist/commonjs/errors.js +2 -0
- package/dist/commonjs/errors.js.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/messageHeader.d.ts +1 -1
- package/dist/commonjs/messageHeader.js.map +1 -1
- package/dist/commonjs/messageProperties.d.ts +1 -1
- package/dist/commonjs/messageProperties.js.map +1 -1
- package/dist/commonjs/requestResponseLink.d.ts +2 -2
- package/dist/commonjs/requestResponseLink.js +1 -1
- package/dist/commonjs/requestResponseLink.js.map +1 -1
- package/dist/commonjs/retry.d.ts +1 -1
- package/dist/commonjs/retry.js +4 -11
- package/dist/commonjs/retry.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/constants.d.ts +0 -1
- package/dist/commonjs/util/constants.js +0 -1
- package/dist/commonjs/util/constants.js.map +1 -1
- package/dist/commonjs/util/hmacSha256.common.d.ts +0 -15
- package/dist/commonjs/util/hmacSha256.common.js.map +1 -1
- package/dist/commonjs/util/lock.d.ts +1 -1
- package/dist/commonjs/util/lock.js.map +1 -1
- package/dist/commonjs/util/typeGuards.d.ts +1 -1
- package/dist/commonjs/util/typeGuards.js.map +1 -1
- package/dist/commonjs/util/utils.d.ts +3 -3
- package/dist/commonjs/util/utils.js.map +1 -1
- package/dist/esm/ConnectionContextBase.js.map +1 -1
- package/dist/esm/amqpAnnotatedMessage.d.ts +1 -1
- package/dist/esm/amqpAnnotatedMessage.js +0 -1
- package/dist/esm/amqpAnnotatedMessage.js.map +1 -1
- package/dist/esm/auth/tokenProvider.d.ts +1 -1
- package/dist/esm/auth/tokenProvider.js +1 -1
- package/dist/esm/auth/tokenProvider.js.map +1 -1
- package/dist/esm/cbs.d.ts +3 -3
- package/dist/esm/cbs.js +1 -1
- package/dist/esm/cbs.js.map +1 -1
- package/dist/esm/connectionConfig/connectionConfig.d.ts +1 -1
- package/dist/esm/connectionConfig/connectionConfig.js +28 -9
- package/dist/esm/connectionConfig/connectionConfig.js.map +1 -1
- package/dist/esm/errors.d.ts +3 -1
- package/dist/esm/errors.js +2 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/messageHeader.d.ts +1 -1
- package/dist/esm/messageHeader.js.map +1 -1
- package/dist/esm/messageProperties.d.ts +1 -1
- package/dist/esm/messageProperties.js.map +1 -1
- package/dist/esm/requestResponseLink.d.ts +2 -2
- package/dist/esm/requestResponseLink.js +2 -2
- package/dist/esm/requestResponseLink.js.map +1 -1
- package/dist/esm/retry.d.ts +1 -1
- package/dist/esm/retry.js +4 -11
- package/dist/esm/retry.js.map +1 -1
- package/dist/esm/util/constants.d.ts +0 -1
- package/dist/esm/util/constants.js +0 -1
- package/dist/esm/util/constants.js.map +1 -1
- package/dist/esm/util/hmacSha256.common.d.ts +0 -15
- package/dist/esm/util/hmacSha256.common.js.map +1 -1
- package/dist/esm/util/lock.d.ts +1 -1
- package/dist/esm/util/lock.js.map +1 -1
- package/dist/esm/util/typeGuards.d.ts +1 -1
- package/dist/esm/util/typeGuards.js.map +1 -1
- package/dist/esm/util/utils.d.ts +3 -3
- package/dist/esm/util/utils.js.map +1 -1
- package/dist/react-native/ConnectionContextBase.js.map +1 -1
- package/dist/react-native/amqpAnnotatedMessage.d.ts +1 -1
- package/dist/react-native/amqpAnnotatedMessage.js +0 -1
- package/dist/react-native/amqpAnnotatedMessage.js.map +1 -1
- package/dist/react-native/auth/tokenProvider.d.ts +1 -1
- package/dist/react-native/auth/tokenProvider.js +1 -1
- package/dist/react-native/auth/tokenProvider.js.map +1 -1
- package/dist/react-native/cbs.d.ts +3 -3
- package/dist/react-native/cbs.js +1 -1
- package/dist/react-native/cbs.js.map +1 -1
- package/dist/react-native/connectionConfig/connectionConfig.d.ts +1 -1
- package/dist/react-native/connectionConfig/connectionConfig.js +28 -9
- package/dist/react-native/connectionConfig/connectionConfig.js.map +1 -1
- package/dist/react-native/errors.d.ts +3 -1
- package/dist/react-native/errors.js +2 -0
- package/dist/react-native/errors.js.map +1 -1
- package/dist/react-native/index.js +0 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/messageHeader.d.ts +1 -1
- package/dist/react-native/messageHeader.js.map +1 -1
- package/dist/react-native/messageProperties.d.ts +1 -1
- package/dist/react-native/messageProperties.js.map +1 -1
- package/dist/react-native/requestResponseLink.d.ts +2 -2
- package/dist/react-native/requestResponseLink.js +2 -2
- package/dist/react-native/requestResponseLink.js.map +1 -1
- package/dist/react-native/retry.d.ts +1 -1
- package/dist/react-native/retry.js +4 -11
- package/dist/react-native/retry.js.map +1 -1
- package/dist/react-native/util/constants.d.ts +0 -1
- package/dist/react-native/util/constants.js +0 -1
- package/dist/react-native/util/constants.js.map +1 -1
- package/dist/react-native/util/hmacSha256.common.d.ts +0 -15
- package/dist/react-native/util/hmacSha256.common.js.map +1 -1
- package/dist/react-native/util/lock.d.ts +1 -1
- package/dist/react-native/util/lock.js.map +1 -1
- package/dist/react-native/util/typeGuards.d.ts +1 -1
- package/dist/react-native/util/typeGuards.js.map +1 -1
- package/dist/react-native/util/utils.d.ts +3 -3
- package/dist/react-native/util/utils.js.map +1 -1
- package/package.json +23 -29
- package/dist/browser/ConnectionContextBase.d.ts.map +0 -1
- package/dist/browser/amqpAnnotatedMessage.d.ts.map +0 -1
- package/dist/browser/auth/token.d.ts.map +0 -1
- package/dist/browser/auth/tokenProvider.d.ts.map +0 -1
- package/dist/browser/cbs.d.ts.map +0 -1
- package/dist/browser/connectionConfig/connectionConfig.d.ts.map +0 -1
- package/dist/browser/errors.d.ts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/internals.d.ts.map +0 -1
- package/dist/browser/log.d.ts.map +0 -1
- package/dist/browser/messageHeader.d.ts.map +0 -1
- package/dist/browser/messageProperties.d.ts.map +0 -1
- package/dist/browser/requestResponseLink.d.ts.map +0 -1
- package/dist/browser/retry.d.ts.map +0 -1
- package/dist/browser/util/checkNetworkConnection-browser.d.mts.map +0 -1
- package/dist/browser/util/checkNetworkConnection.common.d.ts.map +0 -1
- package/dist/browser/util/constants.d.ts.map +0 -1
- package/dist/browser/util/hmacSha256-browser.d.mts.map +0 -1
- package/dist/browser/util/hmacSha256.common.d.ts.map +0 -1
- package/dist/browser/util/lock.d.ts.map +0 -1
- package/dist/browser/util/runtimeInfo-browser.d.mts.map +0 -1
- package/dist/browser/util/typeGuards.d.ts.map +0 -1
- package/dist/browser/util/utils.d.ts.map +0 -1
- package/dist/commonjs/ConnectionContextBase.d.ts.map +0 -1
- package/dist/commonjs/amqpAnnotatedMessage.d.ts.map +0 -1
- package/dist/commonjs/auth/token.d.ts.map +0 -1
- package/dist/commonjs/auth/tokenProvider.d.ts.map +0 -1
- package/dist/commonjs/cbs.d.ts.map +0 -1
- package/dist/commonjs/connectionConfig/connectionConfig.d.ts.map +0 -1
- package/dist/commonjs/errors.d.ts.map +0 -1
- package/dist/commonjs/index.d.ts.map +0 -1
- package/dist/commonjs/internals.d.ts.map +0 -1
- package/dist/commonjs/log.d.ts.map +0 -1
- package/dist/commonjs/messageHeader.d.ts.map +0 -1
- package/dist/commonjs/messageProperties.d.ts.map +0 -1
- package/dist/commonjs/requestResponseLink.d.ts.map +0 -1
- package/dist/commonjs/retry.d.ts.map +0 -1
- package/dist/commonjs/util/checkNetworkConnection.common.d.ts.map +0 -1
- package/dist/commonjs/util/checkNetworkConnection.d.ts.map +0 -1
- package/dist/commonjs/util/constants.d.ts.map +0 -1
- package/dist/commonjs/util/hmacSha256.common.d.ts.map +0 -1
- package/dist/commonjs/util/hmacSha256.d.ts.map +0 -1
- package/dist/commonjs/util/lock.d.ts.map +0 -1
- package/dist/commonjs/util/runtimeInfo.d.ts.map +0 -1
- package/dist/commonjs/util/typeGuards.d.ts.map +0 -1
- package/dist/commonjs/util/utils.d.ts.map +0 -1
- package/dist/core-amqp.d.ts +0 -1519
- package/dist/esm/ConnectionContextBase.d.ts.map +0 -1
- package/dist/esm/amqpAnnotatedMessage.d.ts.map +0 -1
- package/dist/esm/auth/token.d.ts.map +0 -1
- package/dist/esm/auth/tokenProvider.d.ts.map +0 -1
- package/dist/esm/cbs.d.ts.map +0 -1
- package/dist/esm/connectionConfig/connectionConfig.d.ts.map +0 -1
- package/dist/esm/errors.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/internals.d.ts.map +0 -1
- package/dist/esm/log.d.ts.map +0 -1
- package/dist/esm/messageHeader.d.ts.map +0 -1
- package/dist/esm/messageProperties.d.ts.map +0 -1
- package/dist/esm/requestResponseLink.d.ts.map +0 -1
- package/dist/esm/retry.d.ts.map +0 -1
- package/dist/esm/util/checkNetworkConnection.common.d.ts.map +0 -1
- package/dist/esm/util/checkNetworkConnection.d.ts.map +0 -1
- package/dist/esm/util/constants.d.ts.map +0 -1
- package/dist/esm/util/hmacSha256.common.d.ts.map +0 -1
- package/dist/esm/util/hmacSha256.d.ts.map +0 -1
- package/dist/esm/util/lock.d.ts.map +0 -1
- package/dist/esm/util/runtimeInfo.d.ts.map +0 -1
- package/dist/esm/util/typeGuards.d.ts.map +0 -1
- package/dist/esm/util/utils.d.ts.map +0 -1
- package/dist/react-native/ConnectionContextBase.d.ts.map +0 -1
- package/dist/react-native/amqpAnnotatedMessage.d.ts.map +0 -1
- package/dist/react-native/auth/token.d.ts.map +0 -1
- package/dist/react-native/auth/tokenProvider.d.ts.map +0 -1
- package/dist/react-native/cbs.d.ts.map +0 -1
- package/dist/react-native/connectionConfig/connectionConfig.d.ts.map +0 -1
- package/dist/react-native/errors.d.ts.map +0 -1
- package/dist/react-native/index.d.ts.map +0 -1
- package/dist/react-native/internals.d.ts.map +0 -1
- package/dist/react-native/log.d.ts.map +0 -1
- package/dist/react-native/messageHeader.d.ts.map +0 -1
- package/dist/react-native/messageProperties.d.ts.map +0 -1
- package/dist/react-native/requestResponseLink.d.ts.map +0 -1
- package/dist/react-native/retry.d.ts.map +0 -1
- package/dist/react-native/util/checkNetworkConnection-react-native.d.mts.map +0 -1
- package/dist/react-native/util/checkNetworkConnection.common.d.ts.map +0 -1
- package/dist/react-native/util/constants.d.ts.map +0 -1
- package/dist/react-native/util/hmacSha256-react-native.d.mts.map +0 -1
- package/dist/react-native/util/hmacSha256.common.d.ts.map +0 -1
- package/dist/react-native/util/lock.d.ts.map +0 -1
- package/dist/react-native/util/runtimeInfo-react-native.d.mts.map +0 -1
- package/dist/react-native/util/typeGuards.d.ts.map +0 -1
- package/dist/react-native/util/utils.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/util/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,kBAAkB,EAAE,sBAAsB;IAC1C,YAAY,EAAE,qBAAqB;IACnC,cAAc,EAAE,uBAAuB;IACvC,qBAAqB,EAAE,+BAA+B;IACtD,YAAY,EAAE,qBAAqB;IACnC,oBAAoB,EAAE,8BAA8B;IACpD,MAAM,EAAE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AE,2BAA2B;IACvC,aAAa,EAAE,8BAA8B;IAC7C,UAAU,EAAE;QACV,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,MAAM;QACZ,sBAAsB,EAAE,wCAAwC;QAChE,eAAe,EAAE,gCAAgC;QACjD,SAAS,EAAE,0BAA0B;QACrC,WAAW,EAAE,4BAA4B;QACzC,uBAAuB,EAAE,0CAA0C;QACnE,cAAc,EAAE,qCAAqC;QACrD,iBAAiB,EAAE,kCAAkC;QACrD,gBAAgB,EAAE,kCAAkC;QACpD,eAAe,EAAE,iCAAiC;QAClD,eAAe,EAAE,iCAAiC;QAClD,iBAAiB,EAAE,oCAAoC;QACvD,OAAO,EAAE,wBAAwB;QACjC,UAAU,EAAE,2BAA2B;QACvC,cAAc,EAAE,+BAA+B;KAChD;IACD,eAAe,EAAE;QACf,mBAAmB,EAAE,aAAa;QAClC,aAAa,EAAE,WAAW;QAC1B,qBAAqB,EAAE,WAAW;QAClC,iBAAiB,EAAE,aAAa;QAChC,cAAc,EAAE,WAAW;QAC3B,eAAe,EAAE,WAAW;KAC7B;CACO,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const Constants = {\n associatedLinkName: \"associated-link-name\",\n partitionKey: \"x-opt-partition-key\",\n sequenceNumber: \"x-opt-sequence-number\",\n enqueueSequenceNumber: \"x-opt-enqueue-sequence-number\",\n enqueuedTime: \"x-opt-enqueued-time\",\n scheduledEnqueueTime: \"x-opt-scheduled-enqueue-time\",\n offset: \"x-opt-offset\",\n lockedUntil: \"x-opt-locked-until\",\n partitionIdName: \"x-opt-partition-id\",\n publisher: \"x-opt-publisher-name\",\n viaPartitionKey: \"x-opt-via-partition-key\",\n deadLetterSource: \"x-opt-deadletter-source\",\n messageState: \"x-opt-message-state\",\n enqueuedTimeAnnotation: `amqp.annotation.x-opt-enqueued-time`,\n offsetAnnotation: `amqp.annotation.x-opt-offset`,\n sequenceNumberAnnotation: `amqp.annotation.x-opt-sequence-number`,\n guidSize: 16,\n message: \"message\",\n error: \"error\",\n statusCode: \"status-code\",\n statusDescription: \"status-description\",\n errorCondition: \"error-condition\",\n management: \"$management\",\n partition: \"partition\",\n partitionId: \"partitionId\",\n readOperation: \"READ\",\n TLS: \"tls\",\n TCP: \"tcp\",\n establishConnection: \"establishConnection\",\n defaultConsumerGroup: \"$default\",\n eventHub: \"eventhub\",\n cbsEndpoint: \"$cbs\",\n cbsReplyTo: \"cbs\",\n operationPutToken: \"put-token\",\n aadEventHubsAudience: \"https://eventhubs.azure.net/\",\n aadEventHubsScope: \"https://eventhubs.azure.net//.default\",\n aadServiceBusAudience: \"https://servicebus.azure.net/\",\n aadServiceBusScope: \"https://servicebus.azure.net//.default\",\n maxUserAgentLength: 512,\n vendorString: \"com.microsoft\",\n attachEpoch: `com.microsoft:epoch`,\n receiverIdentifierName: `com.microsoft:receiver-name`,\n enableReceiverRuntimeMetricName: `com.microsoft:enable-receiver-runtime-metric`,\n timespan: `com.microsoft:timespan`,\n uri: `com.microsoft:uri`,\n dateTimeOffset: `com.microsoft:datetime-offset`,\n sessionFilterName: `com.microsoft:session-filter`,\n receiverError: \"receiver_error\",\n senderError: \"sender_error\",\n sessionError: \"session_error\",\n connectionError: \"connection_error\",\n defaultOperationTimeoutInMs: 60000,\n defaultConnectionIdleTimeoutInMs: 60000,\n managementRequestKey: \"managementRequest\",\n negotiateCbsKey: \"negotiateCbs\",\n negotiateClaim: \"negotiateClaim\",\n ensureContainerAndBlob: \"ensureContainerAndBlob\",\n defaultPrefetchCount: 1000,\n reconnectLimit: 100,\n maxMessageIdLength: 128,\n maxPartitionKeyLength: 128,\n maxSessionIdLength: 128,\n pathDelimiter: \"/\",\n ruleNameMaximumLength: 50,\n maximumSqlFilterStatementLength: 1024,\n maximumSqlRuleActionStatementLength: 1024,\n maxDeadLetterReasonLength: 4096,\n // https://stackoverflow.com/questions/11526504/minimum-and-maximum-date for js\n // However we are setting this to the TimeSpan.MaxValue of C#.\n maxDurationValue: 922337203685477,\n minDurationValue: -922337203685477,\n // https://github.com/Azure/azure-amqp/blob/master/Microsoft.Azure.Amqp/Amqp/AmqpConstants.cs#L47\n maxAbsoluteExpiryTime: new Date(\"9999-12-31T07:59:59.000Z\").getTime(),\n maxUint32Value: 4294967295,\n aadTokenValidityMarginInMs: 5000,\n connectionReconnectDelay: 300,\n defaultMaxRetries: 3,\n defaultMaxRetriesForConnection: 150,\n defaultDelayBetweenOperationRetriesInMs: 30000,\n defaultMaxDelayForExponentialRetryInMs: 90000,\n receiverSettleMode: \"receiver-settle-mode\",\n dispositionStatus: \"disposition-status\",\n fromSequenceNumber: \"from-sequence-number\",\n messageCount: \"message-count\",\n enqueuedTimeUtc: \"enqueued-time-utc\",\n lockTokens: \"lock-tokens\",\n messageIdMapKey: \"message-id\",\n sequenceNumberMapKey: \"sequence-number\",\n lockTokenMapKey: \"lock-token\",\n sessionIdMapKey: \"session-id\",\n sequenceNumbers: \"sequence-numbers\",\n deadLetterReason: \"deadletter-reason\",\n deadLetterDescription: \"deadletter-description\",\n propertiesToModify: \"properties-to-modify\",\n deadLetterName: \"com.microsoft:dead-letter\",\n trackingId: \"com.microsoft:tracking-id\",\n serverTimeout: \"com.microsoft:server-timeout\",\n operations: {\n putToken: \"put-token\",\n read: \"READ\",\n cancelScheduledMessage: \"com.microsoft:cancel-scheduled-message\",\n scheduleMessage: \"com.microsoft:schedule-message\",\n renewLock: \"com.microsoft:renew-lock\",\n peekMessage: \"com.microsoft:peek-message\",\n receiveBySequenceNumber: \"com.microsoft:receive-by-sequence-number\",\n deleteMessages: \"com.microsoft:batch-delete-messages\",\n updateDisposition: \"com.microsoft:update-disposition\",\n renewSessionLock: \"com.microsoft:renew-session-lock\",\n setSessionState: \"com.microsoft:set-session-state\",\n getSessionState: \"com.microsoft:get-session-state\",\n enumerateSessions: \"com.microsoft:get-message-sessions\",\n addRule: \"com.microsoft:add-rule\",\n removeRule: \"com.microsoft:remove-rule\",\n enumerateRules: \"com.microsoft:enumerate-rules\",\n },\n descriptorCodes: {\n ruleDescriptionList: 1335734829060,\n sqlFilterList: 83483426822,\n correlationFilterList: 83483426825,\n sqlRuleActionList: 1335734829062,\n trueFilterList: 83483426823,\n falseFilterList: 83483426824,\n },\n} as const;\n\n/**\n * The standard error message accompanying an AbortError.\n * @hidden\n */\nexport const StandardAbortMessage = \"The operation was aborted.\";\n"]}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface HmacImportParams {
|
|
3
|
-
name: string;
|
|
4
|
-
hash: {
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
interface CryptoKey {
|
|
9
|
-
algorithm: HmacImportParams;
|
|
10
|
-
type: string;
|
|
11
|
-
extractable: boolean;
|
|
12
|
-
usages: string[];
|
|
13
|
-
}
|
|
14
|
-
function btoa(input: string): string;
|
|
15
|
-
}
|
|
16
1
|
export declare function signString(key: string, toSign: string): Promise<string>;
|
|
17
2
|
//# sourceMappingURL=hmacSha256.common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacSha256.common.js","sourceRoot":"","sources":["../../../src/util/hmacSha256.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"hmacSha256.common.js","sourceRoot":"","sources":["../../../src/util/hmacSha256.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,MAAc;IAC1D,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IAEhF,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC3D,KAAK,EACL,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EACf,SAAS,EACT,KAAK,EACL,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CACnD,SAAS,EACT,YAAY,EACZ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CACnB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEvE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport async function signString(key: string, toSign: string): Promise<string> {\n const enc = new TextEncoder();\n const algorithm: HmacImportParams = { name: \"HMAC\", hash: { name: \"SHA-256\" } };\n\n const extractedKey = await globalThis.crypto.subtle.importKey(\n \"raw\",\n enc.encode(key),\n algorithm,\n false,\n [\"sign\", \"verify\"],\n );\n const signature = await globalThis.crypto.subtle.sign(\n algorithm,\n extractedKey,\n enc.encode(toSign),\n );\n const digest = btoa(String.fromCharCode(...new Uint8Array(signature)));\n\n return encodeURIComponent(digest);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../src/util/lock.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAkEnC;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAArC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AEtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACvD,QAAQ,GAAG,OAAO,CAAC;QACnB,QAAQ,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,QAAS;QACnB,QAAQ,EAAE,QAAS;KACpB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,WAAwB;IAClD,yCAAyC;IACzC,IAAI,WAAW,CAAC,GAAG;QAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;QACzD,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IAClF,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationTimeoutError } from \"rhea-promise\";\nimport { StandardAbortMessage } from \"./constants.js\";\nimport { logger } from \"../log.js\";\n\n/**\n * Describes the properties that must be provided while acquiring a lock.\n */\nexport interface AcquireLockProperties {\n /**\n * An implementation of the `AbortSignalLike` interface to signal the request to cancel lock acquisition.\n * This only applies to the acquisition of a lock. Once the lock is acquired, the task is invoked and `acquire`\n * can no longer be cancelled.\n * This does not cancel running the task passed to `acquire()` if the lock has been acquired,\n * but will prevent it from running if cancelled before the task is invoked.\n */\n abortSignal: AbortSignalLike | undefined;\n /**\n * The allowed amount of time in milliseconds to acquire a lock.\n * If a lock isn't acquired within this time, the promise returned\n * by `acquire()` will be rejected with an Error.\n */\n timeoutInMs: number | undefined;\n}\n\n/**\n * Describes the components related to a specific task.\n * @internal\n */\ninterface TaskDetails {\n abortListener?: () => void;\n abortSignal?: AbortSignalLike;\n resolve: (value: unknown) => void;\n reject: (reason: Error) => void;\n task: (...args: any[]) => Promise<unknown>;\n tid?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * CancellableAsyncLock provides a mechanism for forcing tasks using the same\n * 'key' to be executed serially.\n *\n * Pending tasks can be manually cancelled via an abortSignal or automatically\n * cancelled by reach a provided timeout value.\n */\nexport interface CancellableAsyncLock {\n /**\n * Returns a promise that resolves to the value returned by the provided task function.\n * Only 1 task can be invoked at a time for a given `key` value.\n *\n * An acquire call can be cancelled via an `abortSignal`.\n * If cancelled, the promise will be rejected with an `AbortError`.\n *\n * `acquireTimeoutInMs` can also be provided to properties.\n * If the timeout is reached before the provided `task` is invoked,\n * then the promise will be rejected with an Error stating the task\n * timed out waiting to acquire a lock.\n *\n * @param key - All `acquire` calls are grouped by the provided `key`.\n * @param task - The function to invoke once the lock has been acquired.\n * @param properties - Additional properties to control the behavior of `acquire`.\n */\n acquire<T = void>(\n key: string,\n task: (...args: any[]) => Promise<T>,\n properties: AcquireLockProperties,\n ): Promise<T>;\n}\n\n/**\n * This class is used to coordinate executing tasks that should not be run in parallel.\n * @internal\n */\nexport class CancellableAsyncLockImpl {\n private _keyMap = new Map<string, TaskDetails[]>();\n private _executionRunningSet = new Set<string>();\n /**\n * Returns a promise that resolves to the value returned by the provided task function.\n * Only 1 task can be invoked at a time for a given `key` value.\n *\n * An acquire call can be cancelled via an `abortSignal`.\n * If cancelled, the promise will be rejected with an `AbortError`.\n *\n * `acquireTimeoutInMs` can also be provided to properties.\n * If the timeout is reached before the provided `task` is invoked,\n * then the promise will be rejected with an Error stating the task\n * timed out waiting to acquire a lock.\n *\n * @param key - All `acquire` calls are grouped by the provided `key`.\n * @param task - The function to invoke once the lock has been acquired.\n * @param properties - Additional properties to control the behavior of `acquire`.\n */\n acquire<T = void>(\n key: string,\n task: (...args: any[]) => Promise<T>,\n properties: AcquireLockProperties,\n ): Promise<T> {\n const { abortSignal, timeoutInMs } = properties;\n // Fast exit if the operation is already cancelled.\n if (abortSignal?.aborted) {\n return Promise.reject(new AbortError(StandardAbortMessage));\n }\n\n // Ensure we've got a task queue for the given key.\n const taskQueue = this._keyMap.get(key) ?? [];\n this._keyMap.set(key, taskQueue);\n\n // This method will return a promise that will be fulfilled outside this function.\n const { promise, rejecter, resolver } = getPromiseParts();\n\n const taskDetails: TaskDetails = {\n reject: rejecter,\n resolve: resolver,\n task,\n };\n\n // Handle timeouts by removing the task from the queue when hit.\n if (typeof timeoutInMs === \"number\") {\n const tid = setTimeout(() => {\n this._removeTaskDetails(key, taskDetails);\n rejecter(\n new OperationTimeoutError(`The task timed out waiting to acquire a lock for ${key}`),\n );\n }, timeoutInMs);\n taskDetails.tid = tid;\n }\n\n // Handle cancellation by removing the task from the queue when cancelled.\n if (abortSignal) {\n const abortListener = (): void => {\n this._removeTaskDetails(key, taskDetails);\n rejecter(new AbortError(StandardAbortMessage));\n };\n abortSignal.addEventListener(\"abort\", abortListener);\n taskDetails.abortSignal = abortSignal;\n taskDetails.abortListener = abortListener;\n }\n\n // Enqueue the task!\n taskQueue.push(taskDetails);\n logger.verbose(\n `Called acquire() for lock \"${key}\". Lock \"${key}\" has ${taskQueue.length} pending tasks.`,\n );\n\n // Start a loop to iterate over the task queue.\n // This will run asynchronously and won't allow\n // more than 1 concurrent execution per key at a time.\n this._execute(key);\n\n return promise as Promise<T>;\n }\n\n /**\n * Iterates over all the pending tasks for a given `key` serially.\n *\n * Note: If the pending tasks are already being iterated by an early\n * _execute invocation, this returns immediately.\n * @returns\n */\n private async _execute(key: string): Promise<void> {\n // If the key already exists in the set, then exit because\n // tasks are already being processed.\n if (this._executionRunningSet.has(key)) {\n return;\n }\n\n const taskQueue = this._keyMap.get(key);\n // If the queue is empty, exit early!\n if (!taskQueue || !taskQueue.length) {\n return;\n }\n\n // Add the key to the set so we can tell the\n // task queue is already being processed.\n this._executionRunningSet.add(key);\n while (taskQueue.length) {\n // Remove tasks from the front of the queue.\n // Order matters!\n const taskDetails = taskQueue.shift();\n if (!taskDetails) {\n continue;\n }\n\n try {\n logger.verbose(`Acquired lock for \"${key}\", invoking task.`);\n cleanupTaskDetails(taskDetails);\n const value = await taskDetails.task();\n taskDetails.resolve(value);\n } catch (err: any) {\n taskDetails.reject(err);\n }\n logger.verbose(\n `Task completed for lock \"${key}\". Lock \"${key}\" has ${taskQueue.length} pending tasks.`,\n );\n }\n\n // Indicate that the task queue for the key is empty\n // and we're done processing it.\n this._executionRunningSet.delete(key);\n // clean up the key map\n this._keyMap.delete(key);\n }\n\n private _removeTaskDetails(key: string, taskDetails: TaskDetails): void {\n const taskQueue = this._keyMap.get(key);\n if (!taskQueue || !taskQueue.length) {\n // The task is already gone from the queue, so our work here is done!\n return;\n }\n\n const index = taskQueue.indexOf(taskDetails);\n if (index !== -1) {\n const [details] = taskQueue.splice(index, 1);\n // Cleanup the task rejection code paths.\n cleanupTaskDetails(details);\n }\n }\n}\n\n/**\n * @internal\n * Returns a promise and the promise's resolve and reject methods.\n */\nfunction getPromiseParts(): {\n promise: Promise<unknown>;\n resolver: (value: unknown) => void;\n rejecter: (reason: Error) => void;\n} {\n let resolver: (value: unknown) => void;\n let rejecter: (reason: Error) => void;\n\n const promise = new Promise<unknown>((resolve, reject) => {\n resolver = resolve;\n rejecter = reject;\n });\n\n return {\n promise,\n resolver: resolver!,\n rejecter: rejecter!,\n };\n}\n\n/**\n * @internal\n * Removes any abort listener or pending timeout from a task.\n */\nfunction cleanupTaskDetails(taskDetails: TaskDetails): void {\n // Cleanup the task rejection code paths.\n if (taskDetails.tid) clearTimeout(taskDetails.tid);\n if (taskDetails.abortSignal && taskDetails.abortListener) {\n taskDetails.abortSignal.removeEventListener(\"abort\", taskDetails.abortListener);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../src/util/lock.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EA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AC;YAC7C,yCAAyC;YACzC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,eAAe;IAKtB,IAAI,QAAkC,CAAC;IACvC,IAAI,QAAiC,CAAC;IAEtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACvD,QAAQ,GAAG,OAAO,CAAC;QACnB,QAAQ,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,QAAS;QACnB,QAAQ,EAAE,QAAS;KACpB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,WAAwB;IAClD,yCAAyC;IACzC,IAAI,WAAW,CAAC,GAAG;QAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;QACzD,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IAClF,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport { OperationTimeoutError } from \"rhea-promise\";\nimport { StandardAbortMessage } from \"./constants.js\";\nimport { logger } from \"../log.js\";\n\n/**\n * Describes the properties that must be provided while acquiring a lock.\n */\nexport interface AcquireLockProperties {\n /**\n * An implementation of the `AbortSignalLike` interface to signal the request to cancel lock acquisition.\n * This only applies to the acquisition of a lock. Once the lock is acquired, the task is invoked and `acquire`\n * can no longer be cancelled.\n * This does not cancel running the task passed to `acquire()` if the lock has been acquired,\n * but will prevent it from running if cancelled before the task is invoked.\n */\n abortSignal: AbortSignalLike | undefined;\n /**\n * The allowed amount of time in milliseconds to acquire a lock.\n * If a lock isn't acquired within this time, the promise returned\n * by `acquire()` will be rejected with an Error.\n */\n timeoutInMs: number | undefined;\n}\n\n/**\n * Describes the components related to a specific task.\n * @internal\n */\ninterface TaskDetails {\n abortListener?: () => void;\n abortSignal?: AbortSignalLike;\n resolve: (value: unknown) => void;\n reject: (reason: Error) => void;\n task: (...args: any[]) => Promise<unknown>;\n tid?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * CancellableAsyncLock provides a mechanism for forcing tasks using the same\n * 'key' to be executed serially.\n *\n * Pending tasks can be manually cancelled via an abortSignal or automatically\n * cancelled by reach a provided timeout value.\n */\nexport interface CancellableAsyncLock {\n /**\n * Returns a promise that resolves to the value returned by the provided task function.\n * Only 1 task can be invoked at a time for a given `key` value.\n *\n * An acquire call can be cancelled via an `abortSignal`.\n * If cancelled, the promise will be rejected with an `AbortError`.\n *\n * `acquireTimeoutInMs` can also be provided to properties.\n * If the timeout is reached before the provided `task` is invoked,\n * then the promise will be rejected with an Error stating the task\n * timed out waiting to acquire a lock.\n *\n * @param key - All `acquire` calls are grouped by the provided `key`.\n * @param task - The function to invoke once the lock has been acquired.\n * @param properties - Additional properties to control the behavior of `acquire`.\n */\n acquire<T = void>(\n key: string,\n task: (...args: any[]) => Promise<T>,\n properties: AcquireLockProperties,\n ): Promise<T>;\n}\n\n/**\n * This class is used to coordinate executing tasks that should not be run in parallel.\n * @internal\n */\nexport class CancellableAsyncLockImpl {\n private _keyMap = new Map<string, TaskDetails[]>();\n private _executionRunningSet = new Set<string>();\n /**\n * Returns a promise that resolves to the value returned by the provided task function.\n * Only 1 task can be invoked at a time for a given `key` value.\n *\n * An acquire call can be cancelled via an `abortSignal`.\n * If cancelled, the promise will be rejected with an `AbortError`.\n *\n * `acquireTimeoutInMs` can also be provided to properties.\n * If the timeout is reached before the provided `task` is invoked,\n * then the promise will be rejected with an Error stating the task\n * timed out waiting to acquire a lock.\n *\n * @param key - All `acquire` calls are grouped by the provided `key`.\n * @param task - The function to invoke once the lock has been acquired.\n * @param properties - Additional properties to control the behavior of `acquire`.\n */\n acquire<T = void>(\n key: string,\n task: (...args: any[]) => Promise<T>,\n properties: AcquireLockProperties,\n ): Promise<T> {\n const { abortSignal, timeoutInMs } = properties;\n // Fast exit if the operation is already cancelled.\n if (abortSignal?.aborted) {\n return Promise.reject(new AbortError(StandardAbortMessage));\n }\n\n // Ensure we've got a task queue for the given key.\n const taskQueue = this._keyMap.get(key) ?? [];\n this._keyMap.set(key, taskQueue);\n\n // This method will return a promise that will be fulfilled outside this function.\n const { promise, rejecter, resolver } = getPromiseParts();\n\n const taskDetails: TaskDetails = {\n reject: rejecter,\n resolve: resolver,\n task,\n };\n\n // Handle timeouts by removing the task from the queue when hit.\n if (typeof timeoutInMs === \"number\") {\n const tid = setTimeout(() => {\n this._removeTaskDetails(key, taskDetails);\n rejecter(\n new OperationTimeoutError(`The task timed out waiting to acquire a lock for ${key}`),\n );\n }, timeoutInMs);\n taskDetails.tid = tid;\n }\n\n // Handle cancellation by removing the task from the queue when cancelled.\n if (abortSignal) {\n const abortListener = (): void => {\n this._removeTaskDetails(key, taskDetails);\n rejecter(new AbortError(StandardAbortMessage));\n };\n abortSignal.addEventListener(\"abort\", abortListener);\n taskDetails.abortSignal = abortSignal;\n taskDetails.abortListener = abortListener;\n }\n\n // Enqueue the task!\n taskQueue.push(taskDetails);\n logger.verbose(\n `Called acquire() for lock \"${key}\". Lock \"${key}\" has ${taskQueue.length} pending tasks.`,\n );\n\n // Start a loop to iterate over the task queue.\n // This will run asynchronously and won't allow\n // more than 1 concurrent execution per key at a time.\n this._execute(key);\n\n return promise as Promise<T>;\n }\n\n /**\n * Iterates over all the pending tasks for a given `key` serially.\n *\n * Note: If the pending tasks are already being iterated by an early\n * _execute invocation, this returns immediately.\n * @returns\n */\n private async _execute(key: string): Promise<void> {\n // If the key already exists in the set, then exit because\n // tasks are already being processed.\n if (this._executionRunningSet.has(key)) {\n return;\n }\n\n const taskQueue = this._keyMap.get(key);\n // If the queue is empty, exit early!\n if (!taskQueue || !taskQueue.length) {\n return;\n }\n\n // Add the key to the set so we can tell the\n // task queue is already being processed.\n this._executionRunningSet.add(key);\n while (taskQueue.length) {\n // Remove tasks from the front of the queue.\n // Order matters!\n const taskDetails = taskQueue.shift();\n if (!taskDetails) {\n continue;\n }\n\n try {\n logger.verbose(`Acquired lock for \"${key}\", invoking task.`);\n cleanupTaskDetails(taskDetails);\n const value = await taskDetails.task();\n taskDetails.resolve(value);\n } catch (err: any) {\n taskDetails.reject(err);\n }\n logger.verbose(\n `Task completed for lock \"${key}\". Lock \"${key}\" has ${taskQueue.length} pending tasks.`,\n );\n }\n\n // Indicate that the task queue for the key is empty\n // and we're done processing it.\n this._executionRunningSet.delete(key);\n // clean up the key map\n this._keyMap.delete(key);\n }\n\n private _removeTaskDetails(key: string, taskDetails: TaskDetails): void {\n const taskQueue = this._keyMap.get(key);\n if (!taskQueue || !taskQueue.length) {\n // The task is already gone from the queue, so our work here is done!\n return;\n }\n\n const index = taskQueue.indexOf(taskDetails);\n if (index !== -1) {\n const [details] = taskQueue.splice(index, 1);\n // Cleanup the task rejection code paths.\n cleanupTaskDetails(details);\n }\n }\n}\n\n/**\n * @internal\n * Returns a promise and the promise's resolve and reject methods.\n */\nfunction getPromiseParts(): {\n promise: Promise<unknown>;\n resolver: (value: unknown) => void;\n rejecter: (reason: Error) => void;\n} {\n let resolver: (value: unknown) => void;\n let rejecter: (reason: Error) => void;\n\n const promise = new Promise<unknown>((resolve, reject) => {\n resolver = resolve;\n rejecter = reject;\n });\n\n return {\n promise,\n resolver: resolver!,\n rejecter: rejecter!,\n };\n}\n\n/**\n * @internal\n * Removes any abort listener or pending timeout from a task.\n */\nfunction cleanupTaskDetails(taskDetails: TaskDetails): void {\n // Cleanup the task rejection code paths.\n if (taskDetails.tid) clearTimeout(taskDetails.tid);\n if (taskDetails.abortSignal && taskDetails.abortListener) {\n taskDetails.abortSignal.removeEventListener(\"abort\", taskDetails.abortListener);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeInfo-browser.mjs","sourceRoot":"","sources":["../../../src/util/runtimeInfo-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"runtimeInfo-browser.mjs","sourceRoot":"","sources":["../../../src/util/runtimeInfo-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,uBAAuB,cAAc,EAAE,GAAG,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,WAAW,cAAc,EAAE,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc;IACrB,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,OAAO,SAAS,CAAC,UAAU,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Returns information about the platform this function is being run on.\n * @internal\n */\nexport function getPlatformInfo(): string {\n return `(javascript-Browser-${getReleaseInfo()})`;\n}\n\n/**\n * Returns information about Node.js this function is being run on.\n * @internal\n */\nexport function getFrameworkInfo(): string {\n return `Browser/${getReleaseInfo()}`;\n}\n\n/**\n * @internal\n *\n * @returns\n */\nfunction getReleaseInfo(): string {\n if (typeof self === \"undefined\") {\n return \"\";\n }\n\n const navigator = self.navigator;\n return navigator.appVersion;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,sBAAsB,CAAC,KAAK,EAAE,CAAC,oBAAoB,CAAC,CAAC,IAAI,KAAK,CAAC,kBAAkB,KAAK,IAAI,CAAC;AACpG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { SasTokenProvider } from \"../auth/tokenProvider.js\";\nimport { isObjectWithProperties } from \"@azure/core-util\";\n\n/**\n * Typeguard that checks if the input is a SasTokenProvider.\n * @param thing - Any object.\n * @hidden\n */\nexport function isSasTokenProvider(thing: unknown): thing is SasTokenProvider {\n return isObjectWithProperties(thing, [\"isSasTokenProvider\"]) && thing.isSasTokenProvider === true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,sBAAsB,CAAC,KAAK,EAAE,CAAC,oBAAoB,CAAC,CAAC,IAAI,KAAK,CAAC,kBAAkB,KAAK,IAAI,CAAC;AACpG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { SasTokenProvider } from \"../auth/tokenProvider.js\";\nimport { isObjectWithProperties } from \"@azure/core-util\";\n\n/**\n * Typeguard that checks if the input is a SasTokenProvider.\n * @param thing - Any object.\n * @hidden\n */\nexport function isSasTokenProvider(thing: unknown): thing is SasTokenProvider {\n return isObjectWithProperties(thing, [\"isSasTokenProvider\"]) && thing.isSasTokenProvider === true;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CancellableAsyncLock } from "./lock.js";
|
|
2
|
-
import { AbortSignalLike } from "@azure/abort-controller";
|
|
3
|
-
import { WebSocketImpl } from "rhea-promise";
|
|
1
|
+
import type { CancellableAsyncLock } from "./lock.js";
|
|
2
|
+
import type { AbortSignalLike } from "@azure/abort-controller";
|
|
3
|
+
import type { WebSocketImpl } from "rhea-promise";
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAwB,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAG3E,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,G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C;AAC3D,CAAC;AAUD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CACzC,gBAA4B,EAC5B,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,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE5C,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAQ,qBAAqB,CAAM,gBAAgB,CAAC,CAAC;IAChE,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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CancellableAsyncLock, CancellableAsyncLockImpl } from \"./lock.js\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { 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 connectionString = String(connectionString);\n\n let result: boolean = false;\n const model: any = parseConnectionString<any>(connectionString);\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"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],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C;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAAwB;IAC/D,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE5C,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAQ,qBAAqB,CAAM,gBAAgB,CAAC,CAAC;IAChE,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","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 connectionString = String(connectionString);\n\n let result: boolean = false;\n const model: any = parseConnectionString<any>(connectionString);\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionContextBase.js","sourceRoot":"","sources":["../../src/ConnectionContextBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+CAUsB;AACtB,0DAA0E;AAC1E,qCAAqC;AACrC,gFAA0E;AAC1E,sDAAgD;AAChD,gDAA8C;AA8F9C,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,MAAM,kBAAmB,SAAQ,yBAAU;IACzC;;;;;OAKG;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YAAY,GAAG,aAAa,CAAC,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAS,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;YACpE,CAAC;SACF,CAAC;QAEF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n AwaitableSender,\n Connection,\n type ConnectionOptions,\n type CreateAwaitableSenderOptions,\n type CreateReceiverOptions,\n type CreateSenderOptions,\n Receiver,\n Sender,\n generate_uuid,\n} from \"rhea-promise\";\nimport { getFrameworkInfo, getPlatformInfo } from \"./util/runtimeInfo.js\";\nimport { CbsClient } from \"./cbs.js\";\nimport { ConnectionConfig } from \"./connectionConfig/connectionConfig.js\";\nimport { Constants } from \"./util/constants.js\";\nimport { isNodeLike } from \"@azure/core-util\";\n\n/**\n * Provides contextual information like the underlying amqp connection, cbs session, tokenProvider,\n * Connection config, data transformer, etc.\n */\nexport interface ConnectionContextBase {\n /**\n * The EventHub connection config that is created after\n * parsing the connection string.\n */\n readonly config: ConnectionConfig;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for establishing an amqp connection per client if one does not exist.\n */\n connectionLock: string;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for negotiating cbs claim by an entity on that connection.\n */\n negotiateClaimLock: string;\n /**\n * The underlying AMQP connection.\n */\n connection: Connection;\n /**\n * The amqp connection id that uniquely identifies the\n * connection within a process.\n */\n connectionId: string;\n /**\n * Indicates whether the close() method was\n * called on the connection object.\n */\n wasConnectionCloseCalled: boolean;\n /**\n * A reference to the cbs session ($cbs endpoint) on the\n * underlying AMQP connection for the EventHub Client.\n */\n cbsSession: CbsClient;\n /**\n * Updates the context to use a new underlying AMQP connection and new cbs session.\n */\n refreshConnection: () => void;\n}\n\n/**\n * Defines the properties that need to be set while establishing the AMQP connection.\n */\nexport interface ConnectionProperties {\n /**\n * The name of the product that will be populated as the AMQP\n * connection property. Example: \"MSJSClient\".\n */\n product: string;\n /**\n * The version of the package/sdk that is making the AMQP connection.\n */\n version: string;\n /**\n * The userAgent that needs to be set as the AMQP connection\n * property. Example: `\"/js-service-bus\"` or `\"/js-event-hubs,/js-event-processor-host=1.0.0\"`.\n */\n userAgent: string;\n}\n\n/**\n * Describes the parameters that can be provided to create the base connection context.\n */\nexport interface CreateConnectionContextBaseParameters {\n /**\n * The connection config that is created by parsing the\n * connection string.\n */\n config: ConnectionConfig;\n /**\n * Properties to be provided while creating\n * the AMQP connection.\n */\n connectionProperties: ConnectionProperties;\n /**\n * Determines whether entity path should be a part of\n * the connection config. If `true` it must be present, `false` otherwise. Default value false.\n */\n isEntityPathRequired?: boolean;\n /**\n * The duration in which the promise should\n * complete (resolve/reject). If it is not completed, then the Promise will be rejected after\n * timeout occurs. Default: `60000 milliseconds`.\n */\n operationTimeoutInMs?: number;\n}\n\nconst maxListenerLimit = 1000;\n\nclass CoreAmqpConnection extends Connection {\n /**\n * Creates an amqp sender link. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create a sender link.\n * @returns Promise<Sender>.\n */\n async createSender(options?: CreateSenderOptions): Promise<Sender> {\n const sender = await super.createSender(options);\n sender.setMaxListeners(maxListenerLimit);\n return sender;\n }\n\n /**\n * Creates an awaitable amqp sender. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create an awaitable sender link.\n * - If `onError` and `onSessionError` handlers are not provided then the `AwaitableSender` will\n * clear the timer and reject the Promise for all the entries of inflight send operation in its\n * `deliveryDispositionMap`.\n * - If the user is handling the reconnection of sender link or the underlying connection in it's\n * app, then the `onError` and `onSessionError` handlers must be provided by the user and (s)he\n * shall be responsible of clearing the `deliveryDispositionMap` of inflight `send()` operation.\n *\n * @returns Promise<AwaitableSender>.\n */\n async createAwaitableSender(options?: CreateAwaitableSenderOptions): Promise<AwaitableSender> {\n const sender = await super.createAwaitableSender(options);\n sender.setMaxListeners(maxListenerLimit);\n return sender;\n }\n\n /**\n * Creates an amqp receiver link. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create a receiver link.\n * @returns Promise<Receiver>.\n */\n async createReceiver(options?: CreateReceiverOptions): Promise<Receiver> {\n const receiver = await super.createReceiver(options);\n receiver.setMaxListeners(maxListenerLimit);\n return receiver;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- renaming constant would be a breaking change.\nexport const ConnectionContextBase = {\n /**\n * Creates the base connection context.\n * @param parameters - Parameters to be provided to create\n * the base connection context.\n */\n create(parameters: CreateConnectionContextBaseParameters): ConnectionContextBase {\n ConnectionConfig.validate(parameters.config, {\n isEntityPathRequired: parameters.isEntityPathRequired || false,\n });\n const userAgent = parameters.connectionProperties.userAgent;\n if (userAgent.length > Constants.maxUserAgentLength) {\n throw new Error(\n `The user-agent string cannot be more than ${Constants.maxUserAgentLength} characters in length.` +\n `The given user-agent string is: ${userAgent} with length: ${userAgent.length}`,\n );\n }\n\n const connectionOptions: ConnectionOptions = {\n transport: (parameters.config.useDevelopmentEmulator ? Constants.TCP : Constants.TLS) as any,\n host: parameters.config.host,\n hostname: parameters.config.amqpHostname ?? parameters.config.host,\n username: parameters.config.sharedAccessKeyName,\n port: parameters.config.port ?? (parameters.config.useDevelopmentEmulator ? 5672 : 5671),\n reconnect: false,\n properties: {\n product: parameters.connectionProperties.product,\n version: parameters.connectionProperties.version,\n \"user-agent\": userAgent,\n platform: getPlatformInfo(),\n framework: getFrameworkInfo(),\n },\n idle_time_out: Constants.defaultConnectionIdleTimeoutInMs,\n operationTimeoutInSeconds: parameters.operationTimeoutInMs\n ? parameters.operationTimeoutInMs / 1000\n : undefined,\n };\n\n if (\n parameters.config.webSocket ||\n (!isNodeLike && typeof self !== \"undefined\" && (self as any).WebSocket)\n ) {\n const socket = parameters.config.webSocket || (self as any).WebSocket;\n const host = parameters.config.host;\n const endpoint = parameters.config.webSocketEndpointPath || \"\";\n const socketOptions = parameters.config.webSocketConstructorOptions || {};\n const port = parameters.config.port ?? 443;\n\n connectionOptions.webSocketOptions = {\n webSocket: socket,\n url: `wss://${host}:${port}/${endpoint}`,\n protocol: [\"AMQPWSB10\"],\n options: socketOptions,\n };\n }\n\n const connection = new CoreAmqpConnection(connectionOptions);\n const connectionLock = `${Constants.establishConnection}-${generate_uuid()}`;\n const connectionContextBase: ConnectionContextBase = {\n wasConnectionCloseCalled: false,\n connectionLock: connectionLock,\n negotiateClaimLock: `${Constants.negotiateClaim}-${generate_uuid()}`,\n connection: connection,\n connectionId: connection.id,\n cbsSession: new CbsClient(connection, connectionLock),\n config: parameters.config,\n refreshConnection() {\n const newConnection = new CoreAmqpConnection(connectionOptions);\n const newConnectionLock = `${Constants.establishConnection}-${generate_uuid()}`;\n this.wasConnectionCloseCalled = false;\n this.connectionLock = newConnectionLock;\n this.negotiateClaimLock = `${Constants.negotiateClaim} - ${generate_uuid()}`;\n this.connection = newConnection;\n this.connectionId = newConnection.id;\n this.cbsSession = new CbsClient(newConnection, newConnectionLock);\n },\n };\n\n return connectionContextBase;\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ConnectionContextBase.js","sourceRoot":"","sources":["../../src/ConnectionContextBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,+CAOsB;AACtB,0DAA0E;AAC1E,qCAAqC;AACrC,gFAA0E;AAC1E,sDAAgD;AAChD,gDAA8C;AA8F9C,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,MAAM,kBAAmB,SAAQ,yBAAU;IACzC;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,OAA6B;QAC9C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;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copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AwaitableSender, Receiver, Sender } from \"rhea-promise\";\nimport {\n Connection,\n type ConnectionOptions,\n type CreateAwaitableSenderOptions,\n type CreateReceiverOptions,\n type CreateSenderOptions,\n generate_uuid,\n} from \"rhea-promise\";\nimport { getFrameworkInfo, getPlatformInfo } from \"./util/runtimeInfo.js\";\nimport { CbsClient } from \"./cbs.js\";\nimport { ConnectionConfig } from \"./connectionConfig/connectionConfig.js\";\nimport { Constants } from \"./util/constants.js\";\nimport { isNodeLike } from \"@azure/core-util\";\n\n/**\n * Provides contextual information like the underlying amqp connection, cbs session, tokenProvider,\n * Connection config, data transformer, etc.\n */\nexport interface ConnectionContextBase {\n /**\n * The EventHub connection config that is created after\n * parsing the connection string.\n */\n readonly config: ConnectionConfig;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for establishing an amqp connection per client if one does not exist.\n */\n connectionLock: string;\n /**\n * The unique lock name per connection that is used to\n * acquire the lock for negotiating cbs claim by an entity on that connection.\n */\n negotiateClaimLock: string;\n /**\n * The underlying AMQP connection.\n */\n connection: Connection;\n /**\n * The amqp connection id that uniquely identifies the\n * connection within a process.\n */\n connectionId: string;\n /**\n * Indicates whether the close() method was\n * called on the connection object.\n */\n wasConnectionCloseCalled: boolean;\n /**\n * A reference to the cbs session ($cbs endpoint) on the\n * underlying AMQP connection for the EventHub Client.\n */\n cbsSession: CbsClient;\n /**\n * Updates the context to use a new underlying AMQP connection and new cbs session.\n */\n refreshConnection: () => void;\n}\n\n/**\n * Defines the properties that need to be set while establishing the AMQP connection.\n */\nexport interface ConnectionProperties {\n /**\n * The name of the product that will be populated as the AMQP\n * connection property. Example: \"MSJSClient\".\n */\n product: string;\n /**\n * The version of the package/sdk that is making the AMQP connection.\n */\n version: string;\n /**\n * The userAgent that needs to be set as the AMQP connection\n * property. Example: `\"/js-service-bus\"` or `\"/js-event-hubs,/js-event-processor-host=1.0.0\"`.\n */\n userAgent: string;\n}\n\n/**\n * Describes the parameters that can be provided to create the base connection context.\n */\nexport interface CreateConnectionContextBaseParameters {\n /**\n * The connection config that is created by parsing the\n * connection string.\n */\n config: ConnectionConfig;\n /**\n * Properties to be provided while creating\n * the AMQP connection.\n */\n connectionProperties: ConnectionProperties;\n /**\n * Determines whether entity path should be a part of\n * the connection config. If `true` it must be present, `false` otherwise. Default value false.\n */\n isEntityPathRequired?: boolean;\n /**\n * The duration in which the promise should\n * complete (resolve/reject). If it is not completed, then the Promise will be rejected after\n * timeout occurs. Default: `60000 milliseconds`.\n */\n operationTimeoutInMs?: number;\n}\n\nconst maxListenerLimit = 1000;\n\nclass CoreAmqpConnection extends Connection {\n /**\n * Creates an amqp sender link. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create a sender link.\n * @returns Promise<Sender>.\n */\n async createSender(options?: CreateSenderOptions): Promise<Sender> {\n const sender = await super.createSender(options);\n sender.setMaxListeners(maxListenerLimit);\n return sender;\n }\n\n /**\n * Creates an awaitable amqp sender. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create an awaitable sender link.\n * - If `onError` and `onSessionError` handlers are not provided then the `AwaitableSender` will\n * clear the timer and reject the Promise for all the entries of inflight send operation in its\n * `deliveryDispositionMap`.\n * - If the user is handling the reconnection of sender link or the underlying connection in it's\n * app, then the `onError` and `onSessionError` handlers must be provided by the user and (s)he\n * shall be responsible of clearing the `deliveryDispositionMap` of inflight `send()` operation.\n *\n * @returns Promise<AwaitableSender>.\n */\n async createAwaitableSender(options?: CreateAwaitableSenderOptions): Promise<AwaitableSender> {\n const sender = await super.createAwaitableSender(options);\n sender.setMaxListeners(maxListenerLimit);\n return sender;\n }\n\n /**\n * Creates an amqp receiver link. Max listener limit on the sender is set to 1000 because the\n * default value of 10 in NodeJS is too low.\n * @param options - Optional parameters to create a receiver link.\n * @returns Promise<Receiver>.\n */\n async createReceiver(options?: CreateReceiverOptions): Promise<Receiver> {\n const receiver = await super.createReceiver(options);\n receiver.setMaxListeners(maxListenerLimit);\n return receiver;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- renaming constant would be a breaking change.\nexport const ConnectionContextBase = {\n /**\n * Creates the base connection context.\n * @param parameters - Parameters to be provided to create\n * the base connection context.\n */\n create(parameters: CreateConnectionContextBaseParameters): ConnectionContextBase {\n ConnectionConfig.validate(parameters.config, {\n isEntityPathRequired: parameters.isEntityPathRequired || false,\n });\n const userAgent = parameters.connectionProperties.userAgent;\n if (userAgent.length > Constants.maxUserAgentLength) {\n throw new Error(\n `The user-agent string cannot be more than ${Constants.maxUserAgentLength} characters in length.` +\n `The given user-agent string is: ${userAgent} with length: ${userAgent.length}`,\n );\n }\n\n const connectionOptions: ConnectionOptions = {\n transport: (parameters.config.useDevelopmentEmulator ? Constants.TCP : Constants.TLS) as any,\n host: parameters.config.host,\n hostname: parameters.config.amqpHostname ?? parameters.config.host,\n username: parameters.config.sharedAccessKeyName,\n port: parameters.config.port ?? (parameters.config.useDevelopmentEmulator ? 5672 : 5671),\n reconnect: false,\n properties: {\n product: parameters.connectionProperties.product,\n version: parameters.connectionProperties.version,\n \"user-agent\": userAgent,\n platform: getPlatformInfo(),\n framework: getFrameworkInfo(),\n },\n idle_time_out: Constants.defaultConnectionIdleTimeoutInMs,\n operationTimeoutInSeconds: parameters.operationTimeoutInMs\n ? parameters.operationTimeoutInMs / 1000\n : undefined,\n };\n\n if (\n parameters.config.webSocket ||\n (!isNodeLike && typeof self !== \"undefined\" && (self as any).WebSocket)\n ) {\n const socket = parameters.config.webSocket || (self as any).WebSocket;\n const host = parameters.config.host;\n const endpoint = parameters.config.webSocketEndpointPath || \"\";\n const socketOptions = parameters.config.webSocketConstructorOptions || {};\n const port = parameters.config.port ?? 443;\n\n connectionOptions.webSocketOptions = {\n webSocket: socket,\n url: `wss://${host}:${port}/${endpoint}`,\n protocol: [\"AMQPWSB10\"],\n options: socketOptions,\n };\n }\n\n const connection = new CoreAmqpConnection(connectionOptions);\n const connectionLock = `${Constants.establishConnection}-${generate_uuid()}`;\n const connectionContextBase: ConnectionContextBase = {\n wasConnectionCloseCalled: false,\n connectionLock: connectionLock,\n negotiateClaimLock: `${Constants.negotiateClaim}-${generate_uuid()}`,\n connection: connection,\n connectionId: connection.id,\n cbsSession: new CbsClient(connection, connectionLock),\n config: parameters.config,\n refreshConnection() {\n const newConnection = new CoreAmqpConnection(connectionOptions);\n const newConnectionLock = `${Constants.establishConnection}-${generate_uuid()}`;\n this.wasConnectionCloseCalled = false;\n this.connectionLock = newConnectionLock;\n this.negotiateClaimLock = `${Constants.negotiateClaim} - ${generate_uuid()}`;\n this.connection = newConnection;\n this.connectionId = newConnection.id;\n this.cbsSession = new CbsClient(newConnection, newConnectionLock);\n },\n };\n\n return connectionContextBase;\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AmqpMessageHeader } from "./messageHeader.js";
|
|
2
2
|
import { AmqpMessageProperties } from "./messageProperties.js";
|
|
3
|
-
import { Message as RheaMessage } from "rhea-promise";
|
|
3
|
+
import type { Message as RheaMessage } from "rhea-promise";
|
|
4
4
|
/**
|
|
5
5
|
* Describes the AmqpAnnotatedMessage, part of the ServiceBusReceivedMessage(as `amqpAnnotatedMessage` property).
|
|
6
6
|
*/
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AmqpAnnotatedMessage = void 0;
|
|
4
4
|
// Copyright (c) Microsoft Corporation.
|
|
5
5
|
// Licensed under the MIT License.
|
|
6
|
-
/* eslint-disable eqeqeq */
|
|
7
6
|
const messageHeader_js_1 = require("./messageHeader.js");
|
|
8
7
|
const messageProperties_js_1 = require("./messageProperties.js");
|
|
9
8
|
const constants_js_1 = require("./util/constants.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqpAnnotatedMessage.js","sourceRoot":"","sources":["../../src/amqpAnnotatedMessage.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"amqpAnnotatedMessage.js","sourceRoot":"","sources":["../../src/amqpAnnotatedMessage.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,yDAAuD;AACvD,iEAA+D;AAE/D,sDAAgD;AAyChD;;GAEG;AACH,4GAA4G;AAC/F,QAAA,oBAAoB,GAAG;IAClC;;OAEG;IACH,eAAe,CAAC,GAAgB;QAC9B,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,oCAAiB,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,4CAAqB,CAAC,yBAAyB,CAAC,GAAG,CAAC;YAChE,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC;QACF,IAAI,GAAG,CAAC,oBAAoB,EAAE,CAAC;YAC7B,MAAM,kBAAkB,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;YAC9D,OAAO,CAAC,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAC9C,kBAAkB,EAClB,wBAAS,CAAC,qBAAqB,CAChC,CAAC;YAEF,uEAAuE;YACvE,sEAAsE;YACtE,6DAA6D;YAC7D,6EAA6E;YAC7E,wEAAwE;YACxE,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;gBACtB,OAAO,CAAC,MAAM,CAAC,UAAU;oBACvB,OAAO,CAAC,UAAU,CAAC,kBAAkB,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YACxE,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;OAEG;IACH,aAAa,CAAC,GAAyB;;QACrC,MAAM,KAAK,iDACN,4CAAqB,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,GACnE,oCAAiB,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;QAEF,iGAAiG;QACjG,2FAA2F;QAC3F,8EAA8E;QAC9E,IAAI,MAAA,GAAG,CAAC,MAAM,0CAAE,UAAU,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;YAClC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,wBAAS,CAAC,cAAc,CAAC,CAAC;YACpD,KAAK,CAAC,aAAa,GAAG,MAAA,KAAK,CAAC,aAAa,mCAAI,IAAI,IAAI,EAAE,CAAC;YACxD,KAAK,CAAC,oBAAoB,GAAG,IAAI,IAAI,CACnC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,EAAE,wBAAS,CAAC,qBAAqB,CAAC,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { AmqpMessageHeader } from \"./messageHeader.js\";\nimport { AmqpMessageProperties } from \"./messageProperties.js\";\nimport type { Message as RheaMessage } from \"rhea-promise\";\nimport { Constants } from \"./util/constants.js\";\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 const amqpMsg = {\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 if (msg.absolute_expiry_time) {\n const absoluteExpiryTime = msg.absolute_expiry_time.getTime();\n amqpMsg.properties.absoluteExpiryTime = Math.min(\n absoluteExpiryTime,\n Constants.maxAbsoluteExpiryTime,\n );\n\n // The TTL from the header can be at most approximately 49 days (uint32\n // max value milliseconds) due to the AMQP spec. In order to allow for\n // larger TTLs set by the user, we take the difference of the\n // absolute_expiry_time and the creation_time (if both are set). If either of\n // those properties is not set, we fall back to the TTL from the header.\n if (msg.creation_time) {\n amqpMsg.header.timeToLive =\n amqpMsg.properties.absoluteExpiryTime - msg.creation_time.getTime();\n }\n }\n\n return amqpMsg;\n },\n /**\n * Takes AmqpAnnotatedMessage and returns it in the RheaMessage(`Message` type from \"rhea\") format.\n */\n toRheaMessage(msg: AmqpAnnotatedMessage): RheaMessage {\n const rhMsg = {\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\n // There is a loss of fidelity in the TTL header if larger than uint32 max value. As a workaround\n // we set the absolute_expiry_time and creation_time on the message based on the TTL. These\n // values are then used to reconstruct the accurate TTL for received messages.\n if (msg.header?.timeToLive) {\n const ttl = msg.header.timeToLive;\n rhMsg.ttl = Math.min(ttl, Constants.maxUint32Value);\n rhMsg.creation_time = rhMsg.creation_time ?? new Date();\n rhMsg.absolute_expiry_time = new Date(\n Math.min(rhMsg.creation_time.getTime() + ttl, Constants.maxAbsoluteExpiryTime),\n );\n }\n\n return rhMsg;\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessToken, NamedKeyCredential, SASCredential } from "@azure/core-auth";
|
|
1
|
+
import type { AccessToken, NamedKeyCredential, SASCredential } from "@azure/core-auth";
|
|
2
2
|
/**
|
|
3
3
|
* A SasTokenProvider provides an alternative to TokenCredential for providing an `AccessToken`.
|
|
4
4
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenProvider.js","sourceRoot":"","sources":["../../../src/auth/tokenProvider.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"tokenProvider.js","sourceRoot":"","sources":["../../../src/auth/tokenProvider.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA8BlC,wDAcC;AAzCD,gDAAyE;AACzE,yDAAmD;AAqBnD;;;;GAIG;AACH,SAAgB,sBAAsB,C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ACf,GAAW,EACX,MAAc,EACd,QAAgB;IAEhB,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;IAE9C,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAU,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAChD,OAAO;QACL,KAAK,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 type { AccessToken, NamedKeyCredential, SASCredential } from \"@azure/core-auth\";\nimport { isNamedKeyCredential, isSASCredential } from \"@azure/core-auth\";\nimport { signString } from \"../util/hmacSha256.js\";\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): Promise<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 (\"sharedAccessKeyName\" in data && \"sharedAccessKey\" in data) {\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 async getToken(audience: string): Promise<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 */\nasync function createToken(\n keyName: string,\n key: string,\n expiry: number,\n audience: string,\n): Promise<AccessToken> {\n audience = encodeURIComponent(audience);\n keyName = encodeURIComponent(keyName);\n const stringToSign = audience + \"\\n\" + expiry;\n\n const sig = await signString(key, stringToSign);\n return {\n token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,\n expiresOnTimestamp: expiry,\n };\n}\n"]}
|
package/dist/commonjs/cbs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbortSignalLike } from "@azure/abort-controller";
|
|
2
|
-
import { Connection } from "rhea-promise";
|
|
3
|
-
import { TokenType } from "./auth/token.js";
|
|
1
|
+
import type { AbortSignalLike } from "@azure/abort-controller";
|
|
2
|
+
import type { Connection } from "rhea-promise";
|
|
3
|
+
import type { TokenType } from "./auth/token.js";
|
|
4
4
|
/**
|
|
5
5
|
* Describes the CBS Response.
|
|
6
6
|
*/
|
package/dist/commonjs/cbs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cbs.js","sourceRoot":"","sources":["../../src/cbs.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,8DAAsE;AACtE,+CASsB;AACtB,qCAAsD;AACtD,sDAAgD;AAChD,qEAA+D;AAC/D,sDAA2D;AAE3D,8CAAyD;AACzD,gDAA2C;AAC3C,2CAAwC;AAWxC;;GAEG;AACH,MAAa,SAAS;IA6BpB;;;OAGG;IACH,YAAY,UAAsB,EAAE,cAAsB;QAhC1D;;WAEG;QACM,aAAQ,GAAW,wBAAS,CAAC,WAAW,CAAC;QAClD;;WAEG;QACM,YAAO,GAAW,GAAG,wBAAS,CAAC,UAAU,IAAI,IAAA,4BAAa,GAAE,EAAE,CAAC;QACxE;;;WAGG;QACM,YAAO,GAAW,GAAG,wBAAS,CAAC,eAAe,IAAI,IAAA,4BAAa,GAAE,EAAE,CAAC;QAqB3E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,UAAmE,EAAE;QAC9E,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAE7C,IAAI,CAAC;YACH,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,6BAAU,CAAC,mCAAoB,CAAC,CAAC;YAC7C,CAAC;YAED,0EAA0E;YAC1E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC9B,eAAM,CAAC,OAAO,CAAC,2DAA2D,CAA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AnRD,8BAmRC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n Connection,\n EventContext,\n ReceiverEvents,\n ReceiverOptions,\n Message as RheaMessage,\n SenderEvents,\n SenderOptions,\n generate_uuid,\n} from \"rhea-promise\";\nimport { logErrorStackTrace, logger } from \"./log.js\";\nimport { Constants } from \"./util/constants.js\";\nimport { RequestResponseLink } from \"./requestResponseLink.js\";\nimport { StandardAbortMessage } from \"./util/constants.js\";\nimport { TokenType } from \"./auth/token.js\";\nimport { defaultCancellableLock } from \"./util/utils.js\";\nimport { isError } from \"@azure/core-util\";\nimport { translate } from \"./errors.js\";\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 isError(err) ? `${err.name}: ${err.message}` : String(err),\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: ${\n isError(err) && err.stack ? err.stack : JSON.stringify(err)\n }.`;\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: ${\n isError(err) && err.stack ? err.stack : JSON.stringify(err)\n }.`;\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"]}
|
|
1
|
+
{"version":3,"file":"cbs.js","sourceRoot":"","sources":["../../src/cbs.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,8DAAqD;AAQrD,+CAA2E;AAC3E,qCAAsD;AACtD,sDAAgD;AAChD,qEAA+D;AAC/D,sDAA2D;AAE3D,8CAAyD;AACzD,gDAA2C;AAC3C,2CAAwC;AAWxC;;GAEG;AACH,MAAa,SAAS;IA6BpB;;;OAGG;IACH,YAAY,UAAsB,EAAE,cAAsB;QAhC1D;;WAEG;QACM,aAAQ,GAAW,wBAAS,CAAC,WAAW,CAAC;QAClD;;WAEG;QACM,YAAO,GAAW,GAAG,wBAAS,CAAC,UAAU,IAAI,IAAA,4BAAa,GAAE,EAAE,CAAC;QACxE;;;WAGG;QACM,YAAO,GAAW,GAAG,wBAAS,CAAC,eAAe,IAAI,IAAA,4BAAa,GAAE,EAAE,CAAC;QAqB3E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;I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,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,eAAM,CAAC,OAAO,CAAC,2CAA2C,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7F,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAnRD,8BAmRC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type {\n Connection,\n EventContext,\n ReceiverOptions,\n Message as RheaMessage,\n SenderOptions,\n} from \"rhea-promise\";\nimport { ReceiverEvents, SenderEvents, generate_uuid } from \"rhea-promise\";\nimport { logErrorStackTrace, logger } from \"./log.js\";\nimport { Constants } from \"./util/constants.js\";\nimport { RequestResponseLink } from \"./requestResponseLink.js\";\nimport { StandardAbortMessage } from \"./util/constants.js\";\nimport type { TokenType } from \"./auth/token.js\";\nimport { defaultCancellableLock } from \"./util/utils.js\";\nimport { isError } from \"@azure/core-util\";\nimport { translate } from \"./errors.js\";\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 isError(err) ? `${err.name}: ${err.message}` : String(err),\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: ${\n isError(err) && err.stack ? err.stack : JSON.stringify(err)\n }.`;\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: ${\n isError(err) && err.stack ? err.stack : JSON.stringify(err)\n }.`;\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"]}
|
|
@@ -6,11 +6,30 @@ exports.ConnectionConfig = void 0;
|
|
|
6
6
|
exports.isSharedAccessSignature = isSharedAccessSignature;
|
|
7
7
|
const core_util_1 = require("@azure/core-util");
|
|
8
8
|
const utils_js_1 = require("../util/utils.js");
|
|
9
|
+
const specialLocalIPs = ["::1", "0:0:0:0:0:0:0:1"];
|
|
9
10
|
function getHost(endpoint) {
|
|
10
|
-
const
|
|
11
|
+
for (const ip of specialLocalIPs) {
|
|
12
|
+
if (endpoint.includes(ip)) {
|
|
13
|
+
return ip;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const matches = /.*:\/\/([^/:]*)/.exec(endpoint);
|
|
11
17
|
const match = matches === null || matches === void 0 ? void 0 : matches[1];
|
|
12
18
|
return !match ? endpoint : match;
|
|
13
19
|
}
|
|
20
|
+
function extractPort(ep) {
|
|
21
|
+
const matches = /.*:(\d*)/.exec(ep);
|
|
22
|
+
const match = matches === null || matches === void 0 ? void 0 : matches[1];
|
|
23
|
+
return match ? parseInt(match, 10) : undefined;
|
|
24
|
+
}
|
|
25
|
+
function getPort(endpoint) {
|
|
26
|
+
for (const ip of specialLocalIPs) {
|
|
27
|
+
if (endpoint.includes(ip)) {
|
|
28
|
+
return extractPort(endpoint.replace(ip, ""));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return extractPort(endpoint);
|
|
32
|
+
}
|
|
14
33
|
/**
|
|
15
34
|
* Describes the ConnectionConfig module
|
|
16
35
|
*/
|
|
@@ -33,14 +52,11 @@ exports.ConnectionConfig = {
|
|
|
33
52
|
}
|
|
34
53
|
if (!parsedCS.Endpoint.endsWith("/"))
|
|
35
54
|
parsedCS.Endpoint += "/";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
sharedAccessKey: parsedCS.SharedAccessKey,
|
|
42
|
-
useDevelopmentEmulator: parsedCS.UseDevelopmentEmulator === "true",
|
|
43
|
-
};
|
|
55
|
+
let port;
|
|
56
|
+
if (parsedCS.Endpoint.includes(":")) {
|
|
57
|
+
port = getPort(parsedCS.Endpoint);
|
|
58
|
+
}
|
|
59
|
+
const result = Object.assign({ connectionString: connectionString, endpoint: parsedCS.Endpoint, host: getHost(parsedCS.Endpoint), sharedAccessKeyName: parsedCS.SharedAccessKeyName, sharedAccessKey: parsedCS.SharedAccessKey, useDevelopmentEmulator: parsedCS.UseDevelopmentEmulator === "true" }, (port !== undefined ? { port } : undefined));
|
|
44
60
|
if (path || parsedCS.EntityPath) {
|
|
45
61
|
result.entityPath = path || parsedCS.EntityPath;
|
|
46
62
|
}
|
|
@@ -65,6 +81,9 @@ exports.ConnectionConfig = {
|
|
|
65
81
|
throw new TypeError("Missing 'host' in configuration");
|
|
66
82
|
}
|
|
67
83
|
config.host = String(config.host);
|
|
84
|
+
if (config.port !== undefined && !(config.port >= 0 && config.port <= 65535)) {
|
|
85
|
+
throw new TypeError(`Invalid 'port' of ${config.port} in configuration`);
|
|
86
|
+
}
|
|
68
87
|
if (options.isEntityPathRequired && !config.entityPath) {
|
|
69
88
|
throw new TypeError("Missing 'entityPath' in configuration");
|
|
70
89
|
}
|