Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function newPipeline(
credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
pipelineOptions: StoragePipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
const factories: RequestPolicyFactory[] = [
tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
keepAlivePolicy(pipelineOptions.keepAliveOptions),
telemetryPolicy,
generateClientRequestIdPolicy(),
new StorageBrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new StorageRetryPolicyFactory(pipelineOptions.retryOptions),
logPolicy({
logger: logger.info,
allowedHeaderNames: StorageQueueLoggingAllowedHeaderNames,
allowedQueryParameters: StorageQueueLoggingAllowedQueryParameters
})
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
factories.push(proxyPolicy(pipelineOptions.proxyOptions));
}
factories.push(
isTokenCredential(credential)
? bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes)
: credential
export function newPipeline(
credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
pipelineOptions: StoragePipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
const factories: RequestPolicyFactory[] = [
tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
keepAlivePolicy(pipelineOptions.keepAliveOptions),
telemetryPolicy,
generateClientRequestIdPolicy(),
new StorageBrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new StorageRetryPolicyFactory(pipelineOptions.retryOptions),
logPolicy({
logger: logger.info,
allowedHeaderNames: StorageBlobLoggingAllowedHeaderNames,
allowedQueryParameters: StorageBlobLoggingAllowedQueryParameters
})
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
factories.push(proxyPolicy(pipelineOptions.proxyOptions));
}
factories.push(
isTokenCredential(credential)
? bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes)
: credential
export function newPipeline(
credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
pipelineOptions: StoragePipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
const factories: RequestPolicyFactory[] = [
tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
keepAlivePolicy(pipelineOptions.keepAliveOptions),
telemetryPolicy,
generateClientRequestIdPolicy(),
new StorageBrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new StorageRetryPolicyFactory(pipelineOptions.retryOptions),
logPolicy({
logger: logger.info,
allowedHeaderNames: StorageDataLakeLoggingAllowedHeaderNames,
allowedQueryParameters: StorageDataLakeLoggingAllowedQueryParameters
})
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
factories.push(proxyPolicy(pipelineOptions.proxyOptions));
}
factories.push(
isTokenCredential(credential)
? bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes)
: credential
export function newPipeline(
credential: SharedKeyCredential | AnonymousCredential | TokenCredential,
pipelineOptions: NewPipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const factories: RequestPolicyFactory[] = [
new KeepAlivePolicyFactory(pipelineOptions.keepAliveOptions),
new TelemetryPolicyFactory(pipelineOptions.telemetry),
new UniqueRequestIDPolicyFactory(),
new BrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new RetryPolicyFactory(pipelineOptions.retryOptions),
new LoggingPolicyFactory()
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
let proxySettings: ProxySettings | undefined;
if (typeof pipelineOptions.proxy === "string") {
proxySettings = getDefaultProxySettings(pipelineOptions.proxy);
} else {
proxySettings = pipelineOptions.proxy;
}
factories.push(proxyPolicy(proxySettings));
}
factories.push(
isTokenCredential(credential)
export function newPipeline(
credential: Credential,
pipelineOptions: StoragePipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const factories: RequestPolicyFactory[] = [
tracingPolicy(),
new KeepAlivePolicyFactory(pipelineOptions.keepAliveOptions),
new TelemetryPolicyFactory(pipelineOptions.telemetry),
new UniqueRequestIDPolicyFactory(),
new BrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new RetryPolicyFactory(pipelineOptions.retryOptions),
logPolicy({
logger: logger.info,
allowedHeaderNames: StorageFileLoggingAllowedHeaderNames,
allowedQueryParameters: StorageFileLoggingAllowedQueryParameters
})
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
let proxySettings: ProxySettings | undefined;
if (typeof pipelineOptions.proxy === "string" || !pipelineOptions.proxy) {
proxySettings = getDefaultProxySettings(pipelineOptions.proxy);
} else {
proxySettings = pipelineOptions.proxy;
}
export function newPipeline(
credential: Credential,
pipelineOptions: NewPipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const factories: RequestPolicyFactory[] = [
new KeepAlivePolicyFactory(pipelineOptions.keepAliveOptions),
new TelemetryPolicyFactory(pipelineOptions.telemetry),
new UniqueRequestIDPolicyFactory(),
new BrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new RetryPolicyFactory(pipelineOptions.retryOptions),
new LoggingPolicyFactory()
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
let proxySettings: ProxySettings | undefined;
if (typeof pipelineOptions.proxy === "string") {
proxySettings = getDefaultProxySettings(pipelineOptions.proxy);
} else {
proxySettings = pipelineOptions.proxy;
}
factories.push(proxyPolicy(proxySettings));
}
factories.push(credential);
async function main(): Promise {
// DefaultAzureCredential expects the following three environment variables:
// - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
// - AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
// - AZURE_CLIENT_SECRET: The client secret for the registered application
const credential = new DefaultAzureCredential();
const retryOptions: any = {};
const pipelineOptions: any = {};
const requestPolicyFactories: RequestPolicyFactory[] = [
proxyPolicy(getDefaultProxySettings((pipelineOptions.proxyOptions || {}).proxySettings)),
userAgentPolicy({ value: "" }),
generateClientRequestIdPolicy(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
throttlingRetryPolicy(),
systemErrorRetryPolicy(),
exponentialRetryPolicy(
retryOptions.retryCount,
retryOptions.retryIntervalInMS,
RetryConstants.MIN_RETRY_INTERVAL_MS, // Minimum retry interval to prevent frequent retries
retryOptions.maxRetryDelayInMs
),
redirectPolicy(),
challengeBasedAuthenticationPolicy(credential)
];
const pipeline: Pipeline = {
httpClient: pipelineOptions.HTTPClient,
httpPipelineLogger: pipelineOptions.logger,
export function newPipeline(
credential: Credential,
pipelineOptions: StoragePipelineOptions = {}
): Pipeline {
// Order is important. Closer to the API at the top & closer to the network at the bottom.
// The credential's policy factory must appear close to the wire so it can sign any
// changes made by other factories (like UniqueRequestIDPolicyFactory)
const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
const factories: RequestPolicyFactory[] = [
tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
keepAlivePolicy(pipelineOptions.keepAliveOptions),
telemetryPolicy,
generateClientRequestIdPolicy(),
new StorageBrowserPolicyFactory(),
deserializationPolicy(), // Default deserializationPolicy is provided by protocol layer
new StorageRetryPolicyFactory(pipelineOptions.retryOptions),
logPolicy({
logger: logger.info,
allowedHeaderNames: StorageFileLoggingAllowedHeaderNames,
allowedQueryParameters: StorageFileLoggingAllowedQueryParameters
})
];
if (isNode) {
// ProxyPolicy is only avaiable in Node.js runtime, not in browsers
factories.push(proxyPolicy(pipelineOptions.proxyOptions));
}
factories.push(credential);
return new Pipeline(factories, {
httpClient: pipelineOptions.httpClient