@apoyo/files-azure
Advanced tools
Comparing version 0.1.0 to 0.1.1
import { Drive, DriveFileStats } from '@apoyo/files'; | ||
import { CommonOptions, BlobServiceClient, BlockBlobClient, BlobSASSignatureValues, BlobDownloadToBufferOptions, BlobDownloadOptions, BlobExistsOptions, BlockBlobUploadOptions, BlockBlobUploadStreamOptions } from '@azure/storage-blob'; | ||
import { BlobServiceClient, BlockBlobClient, BlobSASSignatureValues, BlobDownloadToBufferOptions, BlobDownloadOptions, BlobExistsOptions, BlockBlobUploadOptions, BlockBlobUploadStreamOptions } from '@azure/storage-blob'; | ||
declare type AzureDriveConfig = CommonOptions & { | ||
declare type AzureDriveCommonConfig = { | ||
container: string; | ||
connectionString?: string; | ||
azureTenantId?: string; | ||
azureClientId?: string; | ||
azureClientSecret?: string; | ||
name?: string; | ||
key?: string; | ||
}; | ||
declare type AzureDriveAuthByConnectionString = { | ||
connectionString: string; | ||
}; | ||
declare type AzureDriveAuthByAccountKeyCredentials = { | ||
accountName: string; | ||
accountKey: string; | ||
localAddress?: string; | ||
}; | ||
/** | ||
* Use the {@link DefaultAzureCredential} to authenticate your AzureDrive. | ||
* | ||
* This credential provides a default {@link ChainedTokenCredential} configuration that should | ||
* work for most applications that use the Azure SDK. | ||
* | ||
* The following credential types will be tried, in order: | ||
* | ||
* - {@link EnvironmentCredential} | ||
* - {@link ManagedIdentityCredential} | ||
* - {@link VisualStudioCodeCredential} | ||
* - {@link AzureCliCredential} | ||
* - {@link AzurePowerShellCredential} | ||
*/ | ||
declare type AzureDriveAuthByAzureCredentials = { | ||
accountName: string; | ||
localAddress?: string; | ||
}; | ||
declare type AzureDriveAuth = AzureDriveAuthByConnectionString | AzureDriveAuthByAccountKeyCredentials | AzureDriveAuthByAzureCredentials; | ||
declare type AzureDriveConfig = AzureDriveCommonConfig & AzureDriveAuth; | ||
declare class AzureDrive implements Drive { | ||
@@ -15,0 +36,0 @@ private _config; |
@@ -33,15 +33,12 @@ var __defProp = Object.defineProperty; | ||
this._config = _config; | ||
if (_config.connectionString) { | ||
if ("connectionString" in _config) { | ||
this.adapter = import_storage_blob.BlobServiceClient.fromConnectionString(_config.connectionString); | ||
} else { | ||
let credential; | ||
if (_config.azureTenantId && _config.azureClientId && _config.azureClientSecret) { | ||
if ("accountKey" in _config) { | ||
credential = new import_storage_blob.StorageSharedKeyCredential(_config.accountName, _config.accountKey); | ||
} else { | ||
credential = new import_identity.DefaultAzureCredential(); | ||
} else if (_config.name && _config.key) { | ||
credential = new import_storage_blob.StorageSharedKeyCredential(_config.name, _config.key); | ||
} | ||
let url = `https://${this._config.name}.blob.core.windows.net`; | ||
if (typeof this._config.localAddress !== "undefined") { | ||
url = this._config.localAddress; | ||
} | ||
const url = _config.localAddress ?? `https://${_config.accountName}.blob.core.windows.net`; | ||
const azurePipeline = (0, import_storage_blob.newPipeline)(credential); | ||
@@ -48,0 +45,0 @@ this.adapter = new import_storage_blob.BlobServiceClient(url, azurePipeline); |
{ | ||
"name": "@apoyo/files-azure", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "File driver for Azure Storage", | ||
@@ -17,5 +17,2 @@ "main": "dist/index.js", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 14.0.0" | ||
}, | ||
"tags": [ | ||
@@ -46,3 +43,3 @@ "utils", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^14.18.21", | ||
"@types/node": "^16.18.0", | ||
"jest": "^26.4.2", | ||
@@ -49,0 +46,0 @@ "ts-jest": "^26.3.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18886
421