text: // Copyright (c) Microsoft Corporation.
  // Licensed under the MIT license.
  import { AccountSASPermissions } from "./AccountSASPermissions";
  import { AccountSASResourceTypes } from "./AccountSASResourceTypes";
  import { AccountSASServices } from "./AccountSASServices";
  import { ipRangeToString } from "./SasIPRange";
  import { SASQueryParameters } from "./SASQueryParameters";
  import { SERVICE_VERSION } from "../utils/constants";
  import { truncatedISO8061Date } from "../utils/utils.common";
  /**
   * ONLY AVAILABLE IN NODE.JS RUNTIME.
   *
   * Generates a {@link SASQueryParameters} object which contains all SAS query parameters needed to make an actual
   * REST request.
   *
   * @see https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas
   *
   * @param accountSASSignatureValues -
   * @param sharedKeyCredential -
   */
  export function generateAccountSASQueryParameters(accountSASSignatureValues, sharedKeyCredential) {
      var version = accountSASSignatureValues.version
          ? accountSASSignatureValues.version
          : SERVICE_VERSION;
      if (accountSASSignatureValues.permissions &&
          accountSASSignatureValues.permissions.deleteVersion &&
          version < "2019-10-10") {
          throw RangeError("'version' must be >= '2019-10-10' when provided 'x' permission.");
      }
      if (accountSASSignatureValues.permissions &&
          accountSASSignatureValues.permissions.tag &&
          version < "2019-12-12") {
          throw RangeError("'version' must be >= '2019-12-12' when provided 't' permission.");
      }
      if (accountSASSignatureValues.permissions &&
          accountSASSignatureValues.permissions.filter &&
          version < "2019-12-12") {
          throw RangeError("'version' must be >= '2019-12-12' when provided 'f' permission.");
      }
      var parsedPermissions = AccountSASPermissions.parse(accountSASSignatureValues.permissions.toString());
      var parsedServices = AccountSASServices.parse(accountSASSignatureValues.services).toString();
      var parsedResourceTypes = AccountSASResourceTypes.parse(accountSASSignatureValues.resourceTypes).toString();
      var stringToSign = [
          sharedKeyCredential.accountName,
          parsedPermissions,
          parsedServices,
          parsedResourceTypes,
          accountSASSignatureValues.startsOn
              ? truncatedISO8061Date(accountSASSignatureValues.startsOn, false)
              : "",
          truncatedISO8061Date(accountSASSignatureValues.expiresOn, false),
          accountSASSignatureValues.ipRange ? ipRangeToString(accountSASSignatureValues.ipRange) : "",
          accountSASSignatureValues.protocol ? accountSASSignatureValues.protocol : "",
          version,
          "" // Account SAS requires an additional newline character
      ].join("\n");
      var signature = sharedKeyCredential.computeHMACSHA256(stringToSign);
      return new SASQueryParameters(version, signature, parsedPermissions.toString(), parsedServices, parsedResourceTypes, accountSASSignatureValues.protocol, accountSASSignatureValues.startsOn, accountSASSignatureValues.expiresOn, accountSASSignatureValues.ipRange);
  }
  //# sourceMappingURL=AccountSASSignatureValues.js.map