Skip to content

Commit c2bbbc5

Browse files
accept credential parameter
1 parent 4aab8d2 commit c2bbbc5

File tree

4 files changed

+2224
-2571
lines changed

4 files changed

+2224
-2571
lines changed

packages/oc-azure-storage-adapter/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import {
22
BlobServiceClient,
33
type ContainerClient,
44
StorageSharedKeyCredential,
5-
type BlockBlobUploadOptions
5+
type BlockBlobUploadOptions,
6+
AnonymousCredential
67
} from '@azure/storage-blob';
78
import Cache from 'nice-cache';
89
import fs from 'fs-extra';
9-
import { DefaultAzureCredential } from '@azure/identity';
10+
import { DefaultAzureCredential, TokenCredential } from '@azure/identity';
1011
import nodeDir, { type PathsResult } from 'node-dir';
1112
import { promisify } from 'util';
1213
import {
@@ -58,6 +59,11 @@ export interface AzureConfig extends StorageAdapterBaseConfig {
5859
* to Azure's default credential chain (`DefaultAzureCredential`). Optional.
5960
*/
6061
accountKey?: string;
62+
63+
credential?:
64+
| StorageSharedKeyCredential
65+
| AnonymousCredential
66+
| TokenCredential;
6167
}
6268

6369
export default function azureAdapter(conf: AzureConfig): StorageAdapter {
@@ -86,7 +92,9 @@ export default function azureAdapter(conf: AzureConfig): StorageAdapter {
8692
`https://${conf.accountName}.blob.core.windows.net`,
8793
conf.accountName && conf.accountKey
8894
? new StorageSharedKeyCredential(conf.accountName, conf.accountKey)
89-
: new DefaultAzureCredential()
95+
: conf.credential
96+
? conf.credential
97+
: new DefaultAzureCredential()
9098
);
9199
publicClient = client.getContainerClient(conf.publicContainerName);
92100
privateClient = client.getContainerClient(conf.privateContainerName);

0 commit comments

Comments
 (0)