Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 43 additions & 94 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"@changesets/cli": "^2.29.2",
"typescript": "^5.8.2"
}
}
}
3 changes: 2 additions & 1 deletion packages/azure-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@tus/utils": "^0.6.0",
"@azure/core-auth": "^1.9.0",
"@azure/storage-blob": "^12.24.0",
"debug": "^4.3.4"
},
Expand All @@ -35,4 +36,4 @@
"engines": {
"node": ">=20.19.0"
}
}
}
38 changes: 20 additions & 18 deletions packages/azure-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ import {
type ContainerClient,
StorageSharedKeyCredential,
} from '@azure/storage-blob'

type Options = {
cache?: KvStore<Upload>
account: string
accountKey: string
containerName: string
}
import type {TokenCredential} from '@azure/core-auth'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a new dep just for this type? Would be great if this is not needed.

Copy link
Author

@sam-ayo sam-ayo Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree in general to not need to add a new dependency only to get a type, but I believe it's necessary in this case to show that a user could use other credential authentication to connect to the storage account.


type Options =
| {
cache?: KvStore<Upload>
account: string
containerName: string
accountKey: string
}
| {
cache?: KvStore<Upload>
account: string
containerName: string
credential: TokenCredential
}

const log = debug('tus-node-server:stores:azurestore')

Expand All @@ -44,23 +52,17 @@ export class AzureStore extends DataStore {
if (!options.account) {
throw new Error('Azure store must have a account')
}
if (!options.accountKey) {
throw new Error('Azure store must have a account key')
}
if (!options.containerName) {
throw new Error('Azure store must have a container name')
}

const storageAccountBaseUrl = `https://${options.account}.blob.core.windows.net`
const sharedKeyCredential = new StorageSharedKeyCredential(
options.account,
options.accountKey
)
const credential =
'credential' in options
? options.credential
: new StorageSharedKeyCredential(options.account, options.accountKey)

this.blobServiceClient = new BlobServiceClient(
storageAccountBaseUrl,
sharedKeyCredential
)
this.blobServiceClient = new BlobServiceClient(storageAccountBaseUrl, credential)
this.containerClient = this.blobServiceClient.getContainerClient(
options.containerName
)
Expand Down
Loading
Loading