@azure/data-tables 13.2.3-alpha.20240419.1 → 13.3.0-alpha.20240920.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +62 -57
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/TableClient.js +6 -4
  5. package/dist-esm/src/TableClient.js.map +1 -1
  6. package/dist-esm/src/TablePolicies.js +1 -1
  7. package/dist-esm/src/TablePolicies.js.map +1 -1
  8. package/dist-esm/src/TableServiceClient.js +6 -3
  9. package/dist-esm/src/TableServiceClient.js.map +1 -1
  10. package/dist-esm/src/TableTransaction.js +1 -1
  11. package/dist-esm/src/TableTransaction.js.map +1 -1
  12. package/dist-esm/src/cosmosPathPolicy.js +1 -1
  13. package/dist-esm/src/cosmosPathPolicy.js.map +1 -1
  14. package/dist-esm/src/generated/generatedClientContext.js +1 -1
  15. package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
  16. package/dist-esm/src/generatedModels.js +1 -1
  17. package/dist-esm/src/generatedModels.js.map +1 -1
  18. package/dist-esm/src/index.js +1 -1
  19. package/dist-esm/src/index.js.map +1 -1
  20. package/dist-esm/src/logger.js +1 -1
  21. package/dist-esm/src/logger.js.map +1 -1
  22. package/dist-esm/src/models.js +1 -1
  23. package/dist-esm/src/models.js.map +1 -1
  24. package/dist-esm/src/odata.js +1 -1
  25. package/dist-esm/src/odata.js.map +1 -1
  26. package/dist-esm/src/sas/accountSasPermissions.js +1 -1
  27. package/dist-esm/src/sas/accountSasPermissions.js.map +1 -1
  28. package/dist-esm/src/sas/accountSasResourceTypes.js +1 -1
  29. package/dist-esm/src/sas/accountSasResourceTypes.js.map +1 -1
  30. package/dist-esm/src/sas/accountSasServices.js +1 -1
  31. package/dist-esm/src/sas/accountSasServices.js.map +1 -1
  32. package/dist-esm/src/sas/accountSasSignatureValues.js +1 -1
  33. package/dist-esm/src/sas/accountSasSignatureValues.js.map +1 -1
  34. package/dist-esm/src/sas/generateAccountSas.js +1 -1
  35. package/dist-esm/src/sas/generateAccountSas.js.map +1 -1
  36. package/dist-esm/src/sas/generateTableSas.js +1 -1
  37. package/dist-esm/src/sas/generateTableSas.js.map +1 -1
  38. package/dist-esm/src/sas/index.js +1 -1
  39. package/dist-esm/src/sas/index.js.map +1 -1
  40. package/dist-esm/src/sas/models.js +1 -1
  41. package/dist-esm/src/sas/models.js.map +1 -1
  42. package/dist-esm/src/sas/sasIPRange.js +1 -1
  43. package/dist-esm/src/sas/sasIPRange.js.map +1 -1
  44. package/dist-esm/src/sas/sasQueryParameters.js +1 -1
  45. package/dist-esm/src/sas/sasQueryParameters.js.map +1 -1
  46. package/dist-esm/src/sas/tableSasPermisions.js +1 -1
  47. package/dist-esm/src/sas/tableSasPermisions.js.map +1 -1
  48. package/dist-esm/src/sas/tableSasSignatureValues.js +1 -1
  49. package/dist-esm/src/sas/tableSasSignatureValues.js.map +1 -1
  50. package/dist-esm/src/secondaryEndpointPolicy.js +1 -1
  51. package/dist-esm/src/secondaryEndpointPolicy.js.map +1 -1
  52. package/dist-esm/src/serialization.js +1 -1
  53. package/dist-esm/src/serialization.js.map +1 -1
  54. package/dist-esm/src/tablesNamedCredentialPolicy.browser.js +1 -1
  55. package/dist-esm/src/tablesNamedCredentialPolicy.browser.js.map +1 -1
  56. package/dist-esm/src/tablesNamedCredentialPolicy.js +1 -1
  57. package/dist-esm/src/tablesNamedCredentialPolicy.js.map +1 -1
  58. package/dist-esm/src/tablesSASTokenPolicy.js +1 -1
  59. package/dist-esm/src/tablesSASTokenPolicy.js.map +1 -1
  60. package/dist-esm/src/utils/accountConnectionString.browser.js +1 -1
  61. package/dist-esm/src/utils/accountConnectionString.browser.js.map +1 -1
  62. package/dist-esm/src/utils/accountConnectionString.js +1 -1
  63. package/dist-esm/src/utils/accountConnectionString.js.map +1 -1
  64. package/dist-esm/src/utils/apiVersionPolicy.js +1 -1
  65. package/dist-esm/src/utils/apiVersionPolicy.js.map +1 -1
  66. package/dist-esm/src/utils/baseTransactionHeaders.js +1 -1
  67. package/dist-esm/src/utils/baseTransactionHeaders.js.map +1 -1
  68. package/dist-esm/src/utils/bufferSerializer.browser.js +1 -1
  69. package/dist-esm/src/utils/bufferSerializer.browser.js.map +1 -1
  70. package/dist-esm/src/utils/bufferSerializer.js +1 -1
  71. package/dist-esm/src/utils/bufferSerializer.js.map +1 -1
  72. package/dist-esm/src/utils/challengeAuthenticationUtils.js +1 -1
  73. package/dist-esm/src/utils/challengeAuthenticationUtils.js.map +1 -1
  74. package/dist-esm/src/utils/computeHMACSHA256.browser.js +1 -1
  75. package/dist-esm/src/utils/computeHMACSHA256.browser.js.map +1 -1
  76. package/dist-esm/src/utils/computeHMACSHA256.js +1 -1
  77. package/dist-esm/src/utils/computeHMACSHA256.js.map +1 -1
  78. package/dist-esm/src/utils/connectionString.js +1 -1
  79. package/dist-esm/src/utils/connectionString.js.map +1 -1
  80. package/dist-esm/src/utils/constants.js +2 -1
  81. package/dist-esm/src/utils/constants.js.map +1 -1
  82. package/dist-esm/src/utils/continuationToken.js +1 -1
  83. package/dist-esm/src/utils/continuationToken.js.map +1 -1
  84. package/dist-esm/src/utils/errorHelpers.js +1 -1
  85. package/dist-esm/src/utils/errorHelpers.js.map +1 -1
  86. package/dist-esm/src/utils/internalModels.js +1 -1
  87. package/dist-esm/src/utils/internalModels.js.map +1 -1
  88. package/dist-esm/src/utils/isCosmosEndpoint.js +1 -1
  89. package/dist-esm/src/utils/isCosmosEndpoint.js.map +1 -1
  90. package/dist-esm/src/utils/isCredential.js +1 -1
  91. package/dist-esm/src/utils/isCredential.js.map +1 -1
  92. package/dist-esm/src/utils/tracing.js +2 -2
  93. package/dist-esm/src/utils/tracing.js.map +1 -1
  94. package/dist-esm/src/utils/transactionHeaders.browser.js +1 -1
  95. package/dist-esm/src/utils/transactionHeaders.browser.js.map +1 -1
  96. package/dist-esm/src/utils/transactionHeaders.js +1 -1
  97. package/dist-esm/src/utils/transactionHeaders.js.map +1 -1
  98. package/dist-esm/src/utils/transactionHelpers.js +1 -1
  99. package/dist-esm/src/utils/transactionHelpers.js.map +1 -1
  100. package/dist-esm/src/utils/truncateISO8061Date.js +1 -1
  101. package/dist-esm/src/utils/truncateISO8061Date.js.map +1 -1
  102. package/dist-esm/src/utils/uuid.js +1 -1
  103. package/dist-esm/src/utils/uuid.js.map +1 -1
  104. package/package.json +7 -7
  105. package/types/latest/tsdoc-metadata.json +1 -1
package/README.md CHANGED
@@ -202,7 +202,7 @@ const serviceClient = new TableServiceClient(
202
202
  );
203
203
 
204
204
  async function main() {
205
- let tablesIter = serviceClient.listTables();
205
+ const tablesIter = serviceClient.listTables();
206
206
  let i = 1;
207
207
  for await (const table of tablesIter) {
208
208
  console.log(`Table${i}: ${table.name}`);
@@ -389,7 +389,7 @@ const credential = new AzureNamedKeyCredential(account, accountKey);
389
389
  const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
390
390
 
391
391
  async function main() {
392
- let entitiesIter = client.listEntities();
392
+ const entitiesIter = client.listEntities();
393
393
  let i = 1;
394
394
  for await (const entity of entitiesIter) {
395
395
  console.log(`Entity${i}: PartitionKey: ${entity.partitionKey} RowKey: ${entity.rowKey}`);
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ exports.KnownGeoReplicationStatusType = void 0;
60
60
  })(exports.KnownGeoReplicationStatusType || (exports.KnownGeoReplicationStatusType = {}));
61
61
 
62
62
  // Copyright (c) Microsoft Corporation.
63
- // Licensed under the MIT license.
63
+ // Licensed under the MIT License.
64
64
  /**
65
65
  * Parse initializes the AccountSASPermissions fields from a string.
66
66
  *
@@ -131,7 +131,7 @@ function accountSasPermissionsToString(permissions) {
131
131
  }
132
132
 
133
133
  // Copyright (c) Microsoft Corporation.
134
- // Licensed under the MIT license.
134
+ // Licensed under the MIT License.
135
135
  /**
136
136
  * Creates an {@link AccountSasServices} from the specified services string. This method will throw an
137
137
  * Error if it encounters a character that does not correspond to a valid service.
@@ -182,7 +182,7 @@ function accountSasServicesToString(services = { table: true }) {
182
182
  }
183
183
 
184
184
  // Copyright (c) Microsoft Corporation.
185
- // Licensed under the MIT license.
185
+ // Licensed under the MIT License.
186
186
  /**
187
187
  * Generate SasIPRange format string. For example:
188
188
  *
@@ -198,7 +198,7 @@ function ipRangeToString(ipRange) {
198
198
  }
199
199
 
200
200
  // Copyright (c) Microsoft Corporation.
201
- // Licensed under the MIT license.
201
+ // Licensed under the MIT License.
202
202
  /**
203
203
  * Rounds a date off to seconds.
204
204
  *
@@ -216,7 +216,7 @@ function truncatedISO8061Date(date, withMilliseconds = true) {
216
216
  }
217
217
 
218
218
  // Copyright (c) Microsoft Corporation.
219
- // Licensed under the MIT license.
219
+ // Licensed under the MIT License.
220
220
  /**
221
221
  * Represents the components that make up an Azure SAS' query parameters. This type is not constructed directly
222
222
  * by the user; it is only generated by the {@link AccountSasSignatureValues} and {@link TableSasSignatureValues}
@@ -407,7 +407,7 @@ class SasQueryParameters {
407
407
  }
408
408
 
409
409
  // Copyright (c) Microsoft Corporation.
410
- // Licensed under the MIT license.
410
+ // Licensed under the MIT License.
411
411
  /**
412
412
  * Creates an {@link accountSasResourceTypesFromString} from the specified resource types string. This method will throw an
413
413
  * Error if it encounters a character that does not correspond to a valid resource type.
@@ -454,11 +454,12 @@ function accountSasResourceTypesToString(resourceTypes) {
454
454
  }
455
455
 
456
456
  // Copyright (c) Microsoft Corporation.
457
- // Licensed under the MIT license.
457
+ // Licensed under the MIT License.
458
458
  const SERVICE_VERSION = "2019-02-02";
459
459
  const TRANSACTION_HTTP_VERSION_1_1 = "HTTP/1.1";
460
460
  const TRANSACTION_HTTP_LINE_ENDING = "\r\n";
461
461
  const STORAGE_SCOPE = "https://storage.azure.com/.default";
462
+ const COSMOS_SCOPE = "https://cosmos.azure.com/.default";
462
463
  const HeaderConstants = {
463
464
  AUTHORIZATION: "authorization",
464
465
  CONTENT_LENGTH: "content-length",
@@ -554,14 +555,14 @@ const TablesLoggingAllowedHeaderNames = [
554
555
  ];
555
556
 
556
557
  // Copyright (c) Microsoft Corporation.
557
- // Licensed under the MIT license.
558
+ // Licensed under the MIT License.
558
559
  function computeHMACSHA256(stringToSign, accountKey) {
559
560
  const key = Buffer.from(accountKey, "base64");
560
561
  return crypto.createHmac("sha256", key).update(stringToSign, "utf8").digest("base64");
561
562
  }
562
563
 
563
564
  // Copyright (c) Microsoft Corporation.
564
- // Licensed under the MIT license.
565
+ // Licensed under the MIT License.
565
566
  /**
566
567
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
567
568
  *
@@ -608,7 +609,7 @@ function generateAccountSasQueryParameters(accountSasSignatureValues, credential
608
609
  }
609
610
 
610
611
  // Copyright (c) Microsoft Corporation.
611
- // Licensed under the MIT license.
612
+ // Licensed under the MIT License.
612
613
  /**
613
614
  * Generates a Table Account Shared Access Signature (SAS) URI based on the client properties
614
615
  * and parameters passed in. The SAS is signed by the shared key credential of the client.
@@ -633,7 +634,7 @@ function generateAccountSas(credential, options = {}) {
633
634
  }
634
635
 
635
636
  // Copyright (c) Microsoft Corporation.
636
- // Licensed under the MIT license.
637
+ // Licensed under the MIT License.
637
638
  /**
638
639
  * Creates a {@link TableSasPermissions} from the specified permissions string. This method will throw an
639
640
  * Error if it encounters a character that does not correspond to a valid permission.
@@ -689,7 +690,7 @@ function tableSasPermissionsToString(permissions) {
689
690
  }
690
691
 
691
692
  // Copyright (c) Microsoft Corporation.
692
- // Licensed under the MIT license.
693
+ // Licensed under the MIT License.
693
694
  /**
694
695
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
695
696
  *
@@ -762,7 +763,7 @@ function getCanonicalName(accountName, tableName) {
762
763
  }
763
764
 
764
765
  // Copyright (c) Microsoft Corporation.
765
- // Licensed under the MIT license.
766
+ // Licensed under the MIT License.
766
767
  /**
767
768
  * Generates a Table Service Shared Access Signature (SAS) URI based on the client properties
768
769
  * and parameters passed in. The SAS is signed by the shared key credential of the client.
@@ -794,7 +795,7 @@ function generateTableSas(tableName, credential, options = {}) {
794
795
  }
795
796
 
796
797
  // Copyright (c) Microsoft Corporation.
797
- // Licensed under the MIT license.
798
+ // Licensed under the MIT License.
798
799
  /**
799
800
  * The programmatic identifier of the tablesSecondaryEndpointPolicy.
800
801
  */
@@ -3187,7 +3188,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
3187
3188
  }
3188
3189
 
3189
3190
  // Copyright (c) Microsoft Corporation.
3190
- // Licensed under the MIT license.
3191
+ // Licensed under the MIT License.
3191
3192
  /**
3192
3193
  * Name of the apiVersion Policy
3193
3194
  * @internal
@@ -3208,7 +3209,7 @@ const apiVersionPolicy = (apiVersion) => {
3208
3209
  };
3209
3210
 
3210
3211
  // Copyright (c) Microsoft Corporation.
3211
- // Licensed under the MIT license.
3212
+ // Licensed under the MIT License.
3212
3213
  /**
3213
3214
  * Gets client parameters from an Account Connection String
3214
3215
  * Only supported in Node.js not supported for Browsers
@@ -3251,7 +3252,7 @@ function getAccountConnectionString(accountName, accountKey, defaultEndpointsPro
3251
3252
  }
3252
3253
 
3253
3254
  // Copyright (c) Microsoft Corporation.
3254
- // Licensed under the MIT license.
3255
+ // Licensed under the MIT License.
3255
3256
  const DevelopmentConnectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1";
3256
3257
  /**
3257
3258
  * This function parses a connection string into a set of
@@ -3381,7 +3382,7 @@ function getAccountNameFromUrl(url) {
3381
3382
  }
3382
3383
 
3383
3384
  // Copyright (c) Microsoft Corporation.
3384
- // Licensed under the MIT license.
3385
+ // Licensed under the MIT License.
3385
3386
  function handleTableAlreadyExists(error, options = {}) {
3386
3387
  var _a, _b;
3387
3388
  const responseError = getErrorResponse(error);
@@ -3415,20 +3416,20 @@ function isTableServiceErrorResponse(errorResponseBody) {
3415
3416
  }
3416
3417
 
3417
3418
  // Copyright (c) Microsoft Corporation.
3418
- // Licensed under the MIT license.
3419
+ // Licensed under the MIT License.
3419
3420
  function isCredential(credential) {
3420
3421
  return (coreAuth.isSASCredential(credential) || coreAuth.isNamedKeyCredential(credential) || coreAuth.isTokenCredential(credential));
3421
3422
  }
3422
3423
 
3423
3424
  // Copyright (c) Microsoft Corporation.
3424
- // Licensed under the MIT license.
3425
+ // Licensed under the MIT License.
3425
3426
  /**
3426
3427
  * The \@azure/logger configuration for this package.
3427
3428
  */
3428
3429
  const logger = logger$1.createClientLogger("data-tables");
3429
3430
 
3430
3431
  // Copyright (c) Microsoft Corporation.
3431
- // Licensed under the MIT license.
3432
+ // Licensed under the MIT License.
3432
3433
  /**
3433
3434
  * @internal
3434
3435
  * Setups the challenge authentication policy for the provided token credential.
@@ -3446,7 +3447,7 @@ function setTokenChallengeAuthenticationPolicy(pipeline, credential, scopes) {
3446
3447
  }
3447
3448
 
3448
3449
  // Copyright (c) Microsoft Corporation.
3449
- // Licensed under the MIT license.
3450
+ // Licensed under the MIT License.
3450
3451
  /**
3451
3452
  * The programmatic identifier of the tablesNamedKeyCredentialPolicy.
3452
3453
  */
@@ -3507,7 +3508,7 @@ function getCanonicalizedResourceString(request, credential) {
3507
3508
  }
3508
3509
 
3509
3510
  // Copyright (c) Microsoft Corporation.
3510
- // Licensed under the MIT license.
3511
+ // Licensed under the MIT License.
3511
3512
  /**
3512
3513
  * The programmatic identifier of the tablesSASTokenPolicy.
3513
3514
  */
@@ -3534,7 +3535,7 @@ function signURLWithSAS(request, credential) {
3534
3535
  }
3535
3536
 
3536
3537
  // Copyright (c) Microsoft Corporation.
3537
- // Licensed under the MIT license.
3538
+ // Licensed under the MIT License.
3538
3539
  /**
3539
3540
  * A tracing client that can be used to manage spans.
3540
3541
  * @internal
@@ -3542,11 +3543,27 @@ function signURLWithSAS(request, credential) {
3542
3543
  const tracingClient = coreTracing.createTracingClient({
3543
3544
  namespace: "Microsoft.Data.Tables",
3544
3545
  packageName: "@azure/data-tables",
3545
- packageVersion: "13.2.3",
3546
+ packageVersion: "13.3.0",
3546
3547
  });
3547
3548
 
3548
3549
  // Copyright (c) Microsoft Corporation.
3549
- // Licensed under the MIT license.
3550
+ // Licensed under the MIT License.
3551
+ function isCosmosEndpoint(url) {
3552
+ const parsedURL = new URL(url);
3553
+ if (parsedURL.hostname.indexOf(".table.cosmosdb.") !== -1) {
3554
+ return true;
3555
+ }
3556
+ if (parsedURL.hostname.indexOf(".table.cosmos.") !== -1) {
3557
+ return true;
3558
+ }
3559
+ if (parsedURL.hostname === "localhost" && parsedURL.port !== "10002") {
3560
+ return true;
3561
+ }
3562
+ return false;
3563
+ }
3564
+
3565
+ // Copyright (c) Microsoft Corporation.
3566
+ // Licensed under the MIT License.
3550
3567
  /**
3551
3568
  * A TableServiceClient represents a Client to the Azure Tables service allowing you
3552
3569
  * to perform operations on the tables and the entities.
@@ -3554,6 +3571,7 @@ const tracingClient = coreTracing.createTracingClient({
3554
3571
  class TableServiceClient {
3555
3572
  constructor(url, credentialOrOptions, options) {
3556
3573
  this.url = url;
3574
+ const isCosmos = isCosmosEndpoint(this.url);
3557
3575
  const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;
3558
3576
  const clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
3559
3577
  const internalPipelineOptions = Object.assign(Object.assign({}, clientOptions), { endpoint: clientOptions.endpoint || this.url, loggingOptions: {
@@ -3573,7 +3591,8 @@ class TableServiceClient {
3573
3591
  client.pipeline.addPolicy(tablesSASTokenPolicy(credential));
3574
3592
  }
3575
3593
  if (coreAuth.isTokenCredential(credential)) {
3576
- setTokenChallengeAuthenticationPolicy(client.pipeline, credential, STORAGE_SCOPE);
3594
+ const scope = isCosmos ? COSMOS_SCOPE : STORAGE_SCOPE;
3595
+ setTokenChallengeAuthenticationPolicy(client.pipeline, credential, scope);
3577
3596
  }
3578
3597
  if (options === null || options === void 0 ? void 0 : options.version) {
3579
3598
  client.pipeline.addPolicy(apiVersionPolicy(options.version));
@@ -3738,7 +3757,7 @@ class TableServiceClient {
3738
3757
  }
3739
3758
 
3740
3759
  // Copyright (c) Microsoft Corporation.
3741
- // Licensed under the MIT license.
3760
+ // Licensed under the MIT License.
3742
3761
  /**
3743
3762
  * Builds a transaction change set boundary to be added to the transaction request body
3744
3763
  * @param changesetId - Id of the transaction changeset
@@ -3780,7 +3799,7 @@ function getTransactionHttpRequestBody(bodyParts, transactionId, changesetId) {
3780
3799
  }
3781
3800
 
3782
3801
  // Copyright (c) Microsoft Corporation.
3783
- // Licensed under the MIT license.
3802
+ // Licensed under the MIT License.
3784
3803
  const transactionRequestAssemblePolicyName = "transactionRequestAssemblePolicy";
3785
3804
  const dummyResponse = {
3786
3805
  request: coreRestPipeline.createPipelineRequest({ url: "FAKE" }),
@@ -3839,7 +3858,7 @@ function getNextSubrequestBodyPart(request, changesetId) {
3839
3858
  }
3840
3859
 
3841
3860
  // Copyright (c) Microsoft Corporation.
3842
- // Licensed under the MIT license.
3861
+ // Licensed under the MIT License.
3843
3862
  const cosmosPatchPolicyName = "cosmosPatchPolicy";
3844
3863
  function cosmosPatchPolicy() {
3845
3864
  return {
@@ -3855,7 +3874,7 @@ function cosmosPatchPolicy() {
3855
3874
  }
3856
3875
 
3857
3876
  // Copyright (c) Microsoft Corporation.
3858
- // Licensed under the MIT license.
3877
+ // Licensed under the MIT License.
3859
3878
  /**
3860
3879
  * @internal
3861
3880
  * Builds an object with the required headers for a Transaction request. For both Node and Browser
@@ -3871,7 +3890,7 @@ function getBaseTransactionHeaders(transactionGuid) {
3871
3890
  }
3872
3891
 
3873
3892
  // Copyright (c) Microsoft Corporation.
3874
- // Licensed under the MIT license.
3893
+ // Licensed under the MIT License.
3875
3894
  /**
3876
3895
  * @internal
3877
3896
  * Builds an object with the required headers for a Transaction request. For Node
@@ -3884,23 +3903,7 @@ function getTransactionHeaders(transactionGuid) {
3884
3903
  }
3885
3904
 
3886
3905
  // Copyright (c) Microsoft Corporation.
3887
- // Licensed under the MIT license.
3888
- function isCosmosEndpoint(url) {
3889
- const parsedURL = new URL(url);
3890
- if (parsedURL.hostname.indexOf(".table.cosmosdb.") !== -1) {
3891
- return true;
3892
- }
3893
- if (parsedURL.hostname.indexOf(".table.cosmos.") !== -1) {
3894
- return true;
3895
- }
3896
- if (parsedURL.hostname === "localhost" && parsedURL.port !== "10002") {
3897
- return true;
3898
- }
3899
- return false;
3900
- }
3901
-
3902
- // Copyright (c) Microsoft Corporation.
3903
- // Licensed under the MIT license.
3906
+ // Licensed under the MIT License.
3904
3907
  /**
3905
3908
  * Helper to build a list of transaction actions
3906
3909
  */
@@ -4151,7 +4154,7 @@ function prepateTransactionPipeline(pipeline, bodyParts, changesetId, isCosmos)
4151
4154
  }
4152
4155
 
4153
4156
  // Copyright (c) Microsoft Corporation.
4154
- // Licensed under the MIT license.
4157
+ // Licensed under the MIT License.
4155
4158
  /**
4156
4159
  * Encodes a byte array in base64 format.
4157
4160
  * @param value - The Uint8Aray or string to encode
@@ -4174,7 +4177,7 @@ function base64Decode(value) {
4174
4177
  }
4175
4178
 
4176
4179
  // Copyright (c) Microsoft Corporation.
4177
- // Licensed under the MIT license.
4180
+ // Licensed under the MIT License.
4178
4181
  /**
4179
4182
  * Encodes the nextPartitionKey and nextRowKey into a single continuation token
4180
4183
  */
@@ -4199,7 +4202,7 @@ function decodeContinuationToken(encodedToken) {
4199
4202
  }
4200
4203
 
4201
4204
  // Copyright (c) Microsoft Corporation.
4202
- // Licensed under the MIT license.
4205
+ // Licensed under the MIT License.
4203
4206
  const propertyCaseMap = new Map([
4204
4207
  ["PartitionKey", "partitionKey"],
4205
4208
  ["RowKey", "rowKey"],
@@ -4411,7 +4414,7 @@ function serializeQueryOptions(query) {
4411
4414
  }
4412
4415
 
4413
4416
  // Copyright (c) Microsoft Corporation.
4414
- // Licensed under the MIT license.
4417
+ // Licensed under the MIT License.
4415
4418
  // This is used as a workaround to be able to stub generateUuid
4416
4419
  // during testing.
4417
4420
  class Uuid {
@@ -4421,7 +4424,7 @@ class Uuid {
4421
4424
  }
4422
4425
 
4423
4426
  // Copyright (c) Microsoft Corporation.
4424
- // Licensed under the MIT license.
4427
+ // Licensed under the MIT License.
4425
4428
  function escapeQuotesIfString(input, previous) {
4426
4429
  let result = input;
4427
4430
  if (typeof input === "string") {
@@ -4458,7 +4461,7 @@ function odata(strings, ...values) {
4458
4461
  }
4459
4462
 
4460
4463
  // Copyright (c) Microsoft Corporation.
4461
- // Licensed under the MIT license.
4464
+ // Licensed under the MIT License.
4462
4465
  /**
4463
4466
  * A TableClient represents a Client to the Azure Tables service allowing you
4464
4467
  * to perform operations on a single table.
@@ -4468,6 +4471,7 @@ class TableClient {
4468
4471
  var _a;
4469
4472
  this.url = url;
4470
4473
  this.tableName = tableName;
4474
+ const isCosmos = isCosmosEndpoint(this.url);
4471
4475
  const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;
4472
4476
  this.credential = credential;
4473
4477
  this.clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
@@ -4488,9 +4492,10 @@ class TableClient {
4488
4492
  generatedClient.pipeline.addPolicy(tablesSASTokenPolicy(credential));
4489
4493
  }
4490
4494
  if (coreAuth.isTokenCredential(credential)) {
4491
- setTokenChallengeAuthenticationPolicy(generatedClient.pipeline, credential, STORAGE_SCOPE);
4495
+ const scope = isCosmos ? COSMOS_SCOPE : STORAGE_SCOPE;
4496
+ setTokenChallengeAuthenticationPolicy(generatedClient.pipeline, credential, scope);
4492
4497
  }
4493
- if (isCosmosEndpoint(this.url)) {
4498
+ if (isCosmos) {
4494
4499
  generatedClient.pipeline.addPolicy(cosmosPatchPolicy());
4495
4500
  }
4496
4501
  if (options.version) {