@azure/storage-file-datalake
Version:
Microsoft Azure Storage SDK for JavaScript - DataLake
205 lines • 9.43 kB
TypeScript
import { StorageSharedKeyCredential } from "../credentials/StorageSharedKeyCredential.js";
import { DataLakeSASPermissions } from "./DataLakeSASPermissions.js";
import { FileSystemSASPermissions } from "./FileSystemSASPermissions.js";
import type { UserDelegationKey } from "../models.js";
import type { SasIPRange } from "./SasIPRange.js";
import type { SASProtocol } from "./SASQueryParameters.js";
import { SASQueryParameters } from "./SASQueryParameters.js";
import { DirectorySASPermissions } from "./DirectorySASPermissions.js";
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* DataLakeSASSignatureValues is used to help generating Blob and DataLake service SAS tokens for containers, blobs, filesystem, directories and files.
*/
export interface DataLakeSASSignatureValues {
/**
* The version of the service this SAS will target. If not specified, it will default to the version targeted by the
* library.
*/
version?: string;
/**
* Optional. SAS protocols, HTTPS only or HTTPSandHTTP
*/
protocol?: SASProtocol;
/**
* Optional. When the SAS will take effect.
*/
startsOn?: Date;
/**
* Optional only when identifier is provided. The time after which the SAS will no longer work.
*/
expiresOn?: Date;
/**
* Optional only when identifier is provided.
* Please refer to {@link FileSystemSASPermissions}, {@link DirectorySASPermissions} or {@link DataLakeSASPermissions} depending on the resource
* being accessed for help constructing the permissions string.
*/
permissions?: DataLakeSASPermissions | DirectorySASPermissions | FileSystemSASPermissions;
/**
* Optional. IP ranges allowed in this SAS.
*/
ipRange?: SasIPRange;
/**
* The name of the file system the SAS user may access.
*/
fileSystemName: string;
/**
* Optional. The path name of the directory or file SAS user may access. Required if snapshotTime is provided.
*/
pathName?: string;
/**
* Optional. Beginning in version 2020-02-10, this value defines whether or not the {@link pathName} is a directory.
* If this value is set to true, the Path is a Directory for a Directory SAS. If set to false or default, the Path
* is a File Path for a File Path SAS.
*/
isDirectory?: boolean;
/**
* Optional. Beginning in version 2020-02-10, indicate the depth of the directory specified in the canonicalizedresource field of the string-to-sign.
* The depth of the directory is the number of directories beneath the root folder.
*/
directoryDepth?: number;
/**
* Optional. Beginning in version 2020-02-10, specifies the Authorized AAD Object Id in GUID format. The AAD Object ID of a user
* authorized by the owner of the user delegation key to perform the action granted by the SAS. The Azure Storage service will
* ensure that the owner of the user delegation key has the required permissions before granting access but no additional permission
* check for the user specified in this value will be performed. This cannot be used in conjuction with {@link agentObjectId}.
* This is only used for User Delegation SAS.
*/
preauthorizedAgentObjectId?: string;
/**
* Optional. Beginning in version 2020-02-10, specifies the Unauthorized AAD Object Id in GUID format. The AAD Object Id of a user that is assumed
* to be unauthorized by the owner of the user delegation key. The Azure Storage Service will perform an additional POSIX ACL check to determine
* if the user is authorized to perform the requested operation. This cannot be used in conjuction with {@link preauthorizedAgentObjectId}.
* This is only used for User Delegation SAS.
*/
agentObjectId?: string;
/**
* Optional. Beginning in version 2020-02-10, this is a GUID value that will be logged in the storage diagnostic logs and can be used to
* correlate SAS generation with storage resource access. This is only used for User Delegation SAS.
*/
correlationId?: string;
/**
* Optional. Snapshot timestamp string the SAS user may access. Only supported from API version 2018-11-09.
*/
snapshotTime?: string;
/**
* Optional. The name of the access policy on the file system this SAS references if any.
*
* @see https://learn.microsoft.com/rest/api/storageservices/establishing-a-stored-access-policy
*/
identifier?: string;
/**
* Optional. Encryption scope to use when sending requests authorized with this SAS URI.
*/
encryptionScope?: string;
/**
* Optional. The cache-control header for the SAS.
*/
cacheControl?: string;
/**
* Optional. The content-disposition header for the SAS.
*/
contentDisposition?: string;
/**
* Optional. The content-encoding header for the SAS.
*/
contentEncoding?: string;
/**
* Optional. The content-language header for the SAS.
*/
contentLanguage?: string;
/**
* Optional. The content-type header for the SAS.
*/
contentType?: string;
}
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Creates an instance of SASQueryParameters.
*
* Only accepts required settings needed to create a SAS. For optional settings please
* set corresponding properties directly, such as permissions, startsOn and identifier.
*
* WARNING: When identifier is not provided, permissions and expiresOn are required.
* You MUST assign value to identifier or expiresOn & permissions manually if you initial with
* this constructor.
*
* Fill in the required details before running the following snippets.
* @example
* ```ts snippet:ignore
* // Generate service level SAS for a file system
* const containerSAS = generateDataLakeSASQueryParameters({
* fileSystemName, // Required
* permissions: ContainerSASPermissions.parse("racwdl"), // Required
* startsOn: new Date(), // Optional
* expiresOn: new Date(new Date().valueOf() + 86400), // Required. Date type
* ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
* protocol: SASProtocol.HttpsAndHttp, // Optional
* version: "2016-05-31" // Optional
* },
* sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
* ).toString();
* ```
*
* // Fill in the required details before running the snippet.
* @example
* ```ts snippet:ignore
* // Generate service level SAS for a file
* const fileSAS = generateDataLakeSASQueryParameters({
* fileSystemName, // Required
* fileName, // Required
* permissions: DataLakeSASPermissions.parse("racwd"), // Required
* startsOn: new Date(), // Optional
* expiresOn: new Date(new Date().valueOf() + 86400), // Required. Date type
* cacheControl: "cache-control-override", // Optional
* contentDisposition: "content-disposition-override", // Optional
* contentEncoding: "content-encoding-override", // Optional
* contentLanguage: "content-language-override", // Optional
* contentType: "content-type-override", // Optional
* ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
* protocol: SASProtocol.HttpsAndHttp, // Optional
* version: "2016-05-31" // Optional
* },
* sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
* ).toString();
* ```
*
* @param dataLakeSASSignatureValues -
* @param sharedKeyCredential -
*/
export declare function generateDataLakeSASQueryParameters(dataLakeSASSignatureValues: DataLakeSASSignatureValues, sharedKeyCredential: StorageSharedKeyCredential): SASQueryParameters;
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Creates an instance of SASQueryParameters.
* WARNING: identifier will be ignored when generating user delegation SAS, permissions and expiresOn are required.
*
* @example
* ```ts snippet:ignore
* // Generate user delegation SAS for a file system
* const userDelegationKey = await dataLakeServiceClient.getUserDelegationKey(startsOn, expiresOn);
* const fileSystemSAS = generateDataLakeSASQueryParameters({
* fileSystemName, // Required
* permissions: FileSystemSASPermissions.parse("racwdl"), // Required
* startsOn, // Optional. Date type
* expiresOn, // Required. Date type
* ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
* protocol: SASProtocol.HttpsAndHttp, // Optional
* version: "2018-11-09" // Must greater than or equal to 2018-11-09 to generate user delegation SAS
* },
* userDelegationKey, // UserDelegationKey
* accountName
* ).toString();
* ```
*
* @param dataLakeSASSignatureValues -
* @param userDelegationKey - Return value of `blobServiceClient.getUserDelegationKey()`
* @param accountName -
*/
export declare function generateDataLakeSASQueryParameters(dataLakeSASSignatureValues: DataLakeSASSignatureValues, userDelegationKey: UserDelegationKey, accountName: string): SASQueryParameters;
export declare function generateDataLakeSASQueryParametersInternal(dataLakeSASSignatureValues: DataLakeSASSignatureValues, sharedKeyCredentialOrUserDelegationKey: StorageSharedKeyCredential | UserDelegationKey, accountName?: string): {
sasQueryParameter: SASQueryParameters;
stringToSign: string;
};
//# sourceMappingURL=DataLakeSASSignatureValues.d.ts.map