@azure/data-tables 13.1.2-alpha.20220427.2 → 13.1.2-alpha.20220503.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ### Features Added
6
6
 
7
+ - Support cross tenant authentication [PR#21678](https://github.com/Azure/azure-sdk-for-js/pull/21678)
8
+
7
9
  ### Breaking Changes
8
10
 
9
11
  ### Bugs Fixed
@@ -16,6 +18,7 @@
16
18
  ## 13.1.1 (2022-04-14)
17
19
 
18
20
  ### Bugs Fixed
21
+
19
22
  - Fixed issue where `deleteTable()` doesn't throw any errors [21408](https://github.com/Azure/azure-sdk-for-js/pull/21408).
20
23
 
21
24
  ## 13.1.0 (2022-04-07)
package/dist/index.js CHANGED
@@ -8,9 +8,9 @@ var coreAuth = require('@azure/core-auth');
8
8
  var coreXml = require('@azure/core-xml');
9
9
  var coreClient = require('@azure/core-client');
10
10
  var logger$1 = require('@azure/logger');
11
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
11
12
  var crypto = require('crypto');
12
13
  var coreTracing = require('@azure/core-tracing');
13
- var coreRestPipeline = require('@azure/core-rest-pipeline');
14
14
  var uuid = require('uuid');
15
15
 
16
16
  function _interopNamespace(e) {
@@ -2553,7 +2553,7 @@ const comp2 = {
2553
2553
  * Code generated by Microsoft (R) AutoRest Code Generator.
2554
2554
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
2555
2555
  */
2556
- /** Class representing a Table. */
2556
+ /** Class containing Table operations. */
2557
2557
  class TableImpl {
2558
2558
  /**
2559
2559
  * Initialize a new instance of the class Table class.
@@ -3000,7 +3000,7 @@ const setAccessPolicyOperationSpec = {
3000
3000
  * Code generated by Microsoft (R) AutoRest Code Generator.
3001
3001
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
3002
3002
  */
3003
- /** Class representing a Service. */
3003
+ /** Class containing Service operations. */
3004
3004
  class ServiceImpl {
3005
3005
  /**
3006
3006
  * Initialize a new instance of the class Service class.
@@ -3118,13 +3118,14 @@ const getStatisticsOperationSpec = {
3118
3118
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
3119
3119
  */
3120
3120
  /** @internal */
3121
- class GeneratedClientContext extends coreClient__namespace.ServiceClient {
3121
+ class GeneratedClient extends coreClient__namespace.ServiceClient {
3122
3122
  /**
3123
- * Initializes a new instance of the GeneratedClientContext class.
3123
+ * Initializes a new instance of the GeneratedClient class.
3124
3124
  * @param url The URL of the service account or table that is the target of the desired operation.
3125
3125
  * @param options The parameter options
3126
3126
  */
3127
3127
  constructor(url, options) {
3128
+ var _a, _b;
3128
3129
  if (url === undefined) {
3129
3130
  throw new Error("'url' cannot be null");
3130
3131
  }
@@ -3141,36 +3142,38 @@ class GeneratedClientContext extends coreClient__namespace.ServiceClient {
3141
3142
  : `${packageDetails}`;
3142
3143
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
3143
3144
  userAgentPrefix
3144
- }, baseUri: options.endpoint || "{url}" });
3145
+ }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{url}" });
3145
3146
  super(optionsWithDefaults);
3146
3147
  // Parameter assignments
3147
3148
  this.url = url;
3148
3149
  // Assigning values to Constant parameters
3149
3150
  this.version = options.version || "2019-02-02";
3150
- }
3151
- }
3152
-
3153
- /*
3154
- * Copyright (c) Microsoft Corporation.
3155
- * Licensed under the MIT License.
3156
- *
3157
- * Code generated by Microsoft (R) AutoRest Code Generator.
3158
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
3159
- */
3160
- /** @internal */
3161
- class GeneratedClient extends GeneratedClientContext {
3162
- /**
3163
- * Initializes a new instance of the GeneratedClient class.
3164
- * @param url The URL of the service account or table that is the target of the desired operation.
3165
- * @param options The parameter options
3166
- */
3167
- constructor(url, options) {
3168
- super(url, options);
3169
3151
  this.table = new TableImpl(this);
3170
3152
  this.service = new ServiceImpl(this);
3171
3153
  }
3172
3154
  }
3173
3155
 
3156
+ // Copyright (c) Microsoft Corporation.
3157
+ // Licensed under the MIT license.
3158
+ /**
3159
+ * Name of the apiVersion Policy
3160
+ * @internal
3161
+ */
3162
+ const apiVersionPolicyName = "apiVersionPolicy";
3163
+ /**
3164
+ * Pipeline policy that enables users to override the default api version
3165
+ * @internal
3166
+ */
3167
+ const apiVersionPolicy = (apiVersion) => {
3168
+ return {
3169
+ name: apiVersionPolicyName,
3170
+ sendRequest: async (req, next) => {
3171
+ req.headers.set("x-ms-version", apiVersion);
3172
+ return next(req);
3173
+ },
3174
+ };
3175
+ };
3176
+
3174
3177
  // Copyright (c) Microsoft Corporation.
3175
3178
  /**
3176
3179
  * Gets client parameters from an Account Connection String
@@ -3387,6 +3390,23 @@ function isCredential(credential) {
3387
3390
  */
3388
3391
  const logger = logger$1.createClientLogger("data-tables");
3389
3392
 
3393
+ // Copyright (c) Microsoft Corporation.
3394
+ /**
3395
+ * @internal
3396
+ * Setups the challenge authentication policy for the provided token credential.
3397
+ */
3398
+ function setTokenChallengeAuthenticationPolicy(pipeline, credential, scopes) {
3399
+ // Make sure no bearerTokenPolicy is set.
3400
+ pipeline.removePolicy({ name: "bearerTokenPolicy" });
3401
+ pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
3402
+ credential,
3403
+ scopes,
3404
+ challengeCallbacks: { authorizeRequestOnChallenge: coreClient.authorizeRequestOnTenantChallenge },
3405
+ }), {
3406
+ phase: "Sign",
3407
+ });
3408
+ }
3409
+
3390
3410
  // Copyright (c) Microsoft Corporation.
3391
3411
  /**
3392
3412
  * The programmatic identifier of the tablesNamedKeyCredentialPolicy.
@@ -3496,7 +3516,7 @@ class TableServiceClient {
3496
3516
  const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;
3497
3517
  const clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
3498
3518
  clientOptions.endpoint = clientOptions.endpoint || this.url;
3499
- const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, clientOptions), {
3519
+ const internalPipelineOptions = Object.assign(Object.assign({}, clientOptions), {
3500
3520
  loggingOptions: {
3501
3521
  logger: logger.info,
3502
3522
  additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],
@@ -3507,7 +3527,7 @@ class TableServiceClient {
3507
3527
  serializationOptions: {
3508
3528
  stringifyXML: coreXml.stringifyXML,
3509
3529
  },
3510
- }), (coreAuth.isTokenCredential(credential) && { credential, credentialScopes: STORAGE_SCOPE }));
3530
+ });
3511
3531
  const client = new GeneratedClient(this.url, internalPipelineOptions);
3512
3532
  client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);
3513
3533
  if (coreAuth.isNamedKeyCredential(credential)) {
@@ -3516,6 +3536,12 @@ class TableServiceClient {
3516
3536
  else if (coreAuth.isSASCredential(credential)) {
3517
3537
  client.pipeline.addPolicy(tablesSASTokenPolicy(credential));
3518
3538
  }
3539
+ if (coreAuth.isTokenCredential(credential)) {
3540
+ setTokenChallengeAuthenticationPolicy(client.pipeline, credential, STORAGE_SCOPE);
3541
+ }
3542
+ if (options === null || options === void 0 ? void 0 : options.version) {
3543
+ client.pipeline.addPolicy(apiVersionPolicy(options.version));
3544
+ }
3519
3545
  this.pipeline = client.pipeline;
3520
3546
  this.table = client.table;
3521
3547
  this.service = client.service;
@@ -4396,17 +4422,14 @@ class TableClient {
4396
4422
  this.clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
4397
4423
  this.allowInsecureConnection = (_a = this.clientOptions.allowInsecureConnection) !== null && _a !== void 0 ? _a : false;
4398
4424
  this.clientOptions.endpoint = this.clientOptions.endpoint || this.url;
4399
- const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, this.clientOptions), { loggingOptions: {
4425
+ const internalPipelineOptions = Object.assign(Object.assign({}, this.clientOptions), { loggingOptions: {
4400
4426
  logger: logger.info,
4401
4427
  additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],
4402
4428
  }, deserializationOptions: {
4403
4429
  parseXML: coreXml.parseXML,
4404
4430
  }, serializationOptions: {
4405
4431
  stringifyXML: coreXml.stringifyXML,
4406
- } }), (coreAuth.isTokenCredential(this.credential) && {
4407
- credential: this.credential,
4408
- credentialScopes: STORAGE_SCOPE,
4409
- }));
4432
+ } });
4410
4433
  const generatedClient = new GeneratedClient(this.url, internalPipelineOptions);
4411
4434
  if (coreAuth.isNamedKeyCredential(credential)) {
4412
4435
  generatedClient.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));
@@ -4414,9 +4437,15 @@ class TableClient {
4414
4437
  else if (coreAuth.isSASCredential(credential)) {
4415
4438
  generatedClient.pipeline.addPolicy(tablesSASTokenPolicy(credential));
4416
4439
  }
4440
+ if (coreAuth.isTokenCredential(credential)) {
4441
+ setTokenChallengeAuthenticationPolicy(generatedClient.pipeline, credential, STORAGE_SCOPE);
4442
+ }
4417
4443
  if (isCosmosEndpoint(this.url)) {
4418
4444
  generatedClient.pipeline.addPolicy(cosmosPatchPolicy());
4419
4445
  }
4446
+ if (options.version) {
4447
+ generatedClient.pipeline.addPolicy(apiVersionPolicy(options.version));
4448
+ }
4420
4449
  this.generatedClient = generatedClient;
4421
4450
  this.table = generatedClient.table;
4422
4451
  this.pipeline = generatedClient.pipeline;