Skip to content

Commit 7c9cc1f

Browse files
Merge pull request #341 from opencomponents/azure-credential
accept credential parameter
2 parents 4aab8d2 + be8309d commit 7c9cc1f

File tree

5 files changed

+2228
-2575
lines changed

5 files changed

+2228
-2575
lines changed

.github/workflows/node.js.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
33

44
name: Node.js CI
55

@@ -15,13 +15,13 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [18.x, 20.x, 22.x]
18+
node-version: [20.x, 22.x, 24.x]
1919
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v2
24+
uses: actions/setup-node@v4
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727
cache: 'npm'

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+
type 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)