azure-blob-wrapper 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +7 -0
- package/dist/blob-client.d.ts +3 -0
- package/dist/blob-client.js +11 -0
- package/dist/blob-service-client.d.ts +1 -1
- package/dist/blob-service-client.js +6 -14
- package/dist/block-blob-client.d.ts +3 -0
- package/dist/block-blob-client.js +11 -0
- package/dist/container-client.d.ts +3 -0
- package/dist/container-client.js +11 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +6 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/types.d.ts +0 -3
- package/package.json +2 -4
package/dist/auth.d.ts
ADDED
package/dist/auth.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStorageSharedKeyCredential = getStorageSharedKeyCredential;
|
|
4
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
+
function getStorageSharedKeyCredential(accountName, accountKey) {
|
|
6
|
+
return new storage_blob_1.StorageSharedKeyCredential(accountName, accountKey);
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBlobClient = createBlobClient;
|
|
4
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
+
const auth_1 = require("./auth");
|
|
6
|
+
function createBlobClient(blobUrl, auth) {
|
|
7
|
+
if ('accountName' in auth && 'accountKey' in auth) {
|
|
8
|
+
return new storage_blob_1.BlobClient(blobUrl, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
|
|
9
|
+
}
|
|
10
|
+
throw new Error('Invalid authentication configuration');
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
2
|
import { BlobServiceAuth } from './types';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function createBlobServiceClient(auth: BlobServiceAuth): BlobServiceClient;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createBlobServiceClient = createBlobServiceClient;
|
|
4
4
|
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function buildUrl(accountName) {
|
|
9
|
-
return `https://${accountName}.blob.core.windows.net`;
|
|
10
|
-
}
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
const auth_1 = require("./auth");
|
|
11
7
|
function createBlobServiceClient(auth) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return new storage_blob_1.BlobServiceClient(buildUrl(auth.accountName), new storage_blob_1.StorageSharedKeyCredential(auth.accountName, auth.accountKey));
|
|
15
|
-
case 'connectionString':
|
|
16
|
-
return storage_blob_1.BlobServiceClient.fromConnectionString(auth.connectionString);
|
|
17
|
-
case 'tokenCredential':
|
|
18
|
-
return new storage_blob_1.BlobServiceClient(buildUrl(auth.accountName), auth.credential);
|
|
8
|
+
if ('accountName' in auth && 'accountKey' in auth) {
|
|
9
|
+
return new storage_blob_1.BlobServiceClient((0, helpers_1.buildUrl)(auth.accountName), (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
|
|
19
10
|
}
|
|
11
|
+
throw new Error('Invalid authentication configuration');
|
|
20
12
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBlockBlobClient = createBlockBlobClient;
|
|
4
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
+
const auth_1 = require("./auth");
|
|
6
|
+
function createBlockBlobClient(blobUrl, auth) {
|
|
7
|
+
if ('accountName' in auth && 'accountKey' in auth) {
|
|
8
|
+
return new storage_blob_1.BlockBlobClient(blobUrl, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
|
|
9
|
+
}
|
|
10
|
+
throw new Error('Invalid authentication configuration');
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContainerClient = createContainerClient;
|
|
4
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
+
const auth_1 = require("./auth");
|
|
6
|
+
function createContainerClient(container, auth) {
|
|
7
|
+
if ('accountName' in auth && 'accountKey' in auth) {
|
|
8
|
+
return new storage_blob_1.ContainerClient(container, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
|
|
9
|
+
}
|
|
10
|
+
throw new Error('Invalid authentication configuration');
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildUrl(accountName: string): string;
|
package/dist/helpers.js
ADDED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,3 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./types"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./blob-service-client"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./blob-client"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./container-client"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./block-blob-client"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./helpers"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./auth"), exports);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { TokenCredential } from '@azure/core-auth';
|
|
2
2
|
interface SharedKeyAuth {
|
|
3
|
-
type: 'sharedKey';
|
|
4
3
|
accountName: string;
|
|
5
4
|
accountKey: string;
|
|
6
5
|
}
|
|
7
6
|
interface ConnectionStringAuth {
|
|
8
|
-
type: 'connectionString';
|
|
9
7
|
connectionString: string;
|
|
10
8
|
}
|
|
11
9
|
interface TokenCredentialAuth {
|
|
12
|
-
type: 'tokenCredential';
|
|
13
10
|
accountName: string;
|
|
14
11
|
credential: TokenCredential;
|
|
15
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-blob-wrapper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Wrapper for @azure/storage-blob",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@azure/core-auth": "^1.10.1",
|
|
16
16
|
"@azure/core-paging": "^1.6.2",
|
|
17
|
-
"@azure/storage-blob": "^12.24.0"
|
|
18
|
-
"dotenv": "^16.4.5",
|
|
19
|
-
"list-data-reader": "github:moxalibudbud/list-data-reader#main"
|
|
17
|
+
"@azure/storage-blob": "^12.24.0"
|
|
20
18
|
},
|
|
21
19
|
"devDependencies": {
|
|
22
20
|
"@babel/cli": "^7.24.8",
|