@ms-cloudpack/remote-cache 0.3.1 → 0.4.0
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/lib/AzureRemoteCacheClient.d.ts +1 -1
- package/lib/AzureRemoteCacheClient.d.ts.map +1 -1
- package/lib/AzureRemoteCacheClient.js +4 -2
- package/lib/AzureRemoteCacheClient.js.map +1 -1
- package/lib/authentication/getAuthenticationRecord.d.ts +7 -0
- package/lib/authentication/getAuthenticationRecord.d.ts.map +1 -0
- package/lib/authentication/getAuthenticationRecord.js +17 -0
- package/lib/authentication/getAuthenticationRecord.js.map +1 -0
- package/lib/authentication/getAuthenticationRecordPath.d.ts +7 -0
- package/lib/authentication/getAuthenticationRecordPath.d.ts.map +1 -0
- package/lib/authentication/getAuthenticationRecordPath.js +10 -0
- package/lib/authentication/getAuthenticationRecordPath.js.map +1 -0
- package/lib/authentication/getCredential.d.ts +7 -1
- package/lib/authentication/getCredential.d.ts.map +1 -1
- package/lib/authentication/getCredential.js +41 -7
- package/lib/authentication/getCredential.js.map +1 -1
- package/lib/authentication/saveAuthenticationRecord.d.ts +9 -0
- package/lib/authentication/saveAuthenticationRecord.d.ts.map +1 -0
- package/lib/authentication/saveAuthenticationRecord.js +17 -0
- package/lib/authentication/saveAuthenticationRecord.js.map +1 -0
- package/lib/cache-persistance/cachePersistencePlugin.d.ts +32 -0
- package/lib/cache-persistance/cachePersistencePlugin.d.ts.map +1 -0
- package/lib/cache-persistance/cachePersistencePlugin.js +35 -0
- package/lib/cache-persistance/cachePersistencePlugin.js.map +1 -0
- package/lib/cache-persistance/platforms.d.ts +55 -0
- package/lib/cache-persistance/platforms.d.ts.map +1 -0
- package/lib/cache-persistance/platforms.js +109 -0
- package/lib/cache-persistance/platforms.js.map +1 -0
- package/lib/cache-persistance/provider.d.ts +15 -0
- package/lib/cache-persistance/provider.d.ts.map +1 -0
- package/lib/cache-persistance/provider.js +26 -0
- package/lib/cache-persistance/provider.js.map +1 -0
- package/lib/createBlobStorageUrl.d.ts +2 -0
- package/lib/createBlobStorageUrl.d.ts.map +1 -0
- package/lib/createBlobStorageUrl.js +4 -0
- package/lib/createBlobStorageUrl.js.map +1 -0
- package/lib/createRemoteCacheClient.d.ts +10 -4
- package/lib/createRemoteCacheClient.d.ts.map +1 -1
- package/lib/createRemoteCacheClient.js +10 -9
- package/lib/createRemoteCacheClient.js.map +1 -1
- package/lib/getListOfBlobs.d.ts +1 -1
- package/lib/getListOfBlobs.d.ts.map +1 -1
- package/lib/getListOfBlobs.js +3 -2
- package/lib/getListOfBlobs.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types/RemoteCacheClientOptions.d.ts +3 -1
- package/lib/types/RemoteCacheClientOptions.d.ts.map +1 -1
- package/lib/types/RemoteCacheClientOptions.js.map +1 -1
- package/package.json +3 -2
- package/lib/authentication/KeyRingLocalTokenCache.d.ts +0 -14
- package/lib/authentication/KeyRingLocalTokenCache.d.ts.map +0 -1
- package/lib/authentication/KeyRingLocalTokenCache.js +0 -37
- package/lib/authentication/KeyRingLocalTokenCache.js.map +0 -1
- package/lib/authentication/acquireSasToken.d.ts +0 -3
- package/lib/authentication/acquireSasToken.d.ts.map +0 -1
- package/lib/authentication/acquireSasToken.js +0 -27
- package/lib/authentication/acquireSasToken.js.map +0 -1
- package/lib/authentication/createBlobStorageUrl.d.ts +0 -2
- package/lib/authentication/createBlobStorageUrl.d.ts.map +0 -1
- package/lib/authentication/createBlobStorageUrl.js +0 -4
- package/lib/authentication/createBlobStorageUrl.js.map +0 -1
- package/lib/authentication/getAuthenticatedConnectionString.d.ts +0 -3
- package/lib/authentication/getAuthenticatedConnectionString.d.ts.map +0 -1
- package/lib/authentication/getAuthenticatedConnectionString.js +0 -21
- package/lib/authentication/getAuthenticatedConnectionString.js.map +0 -1
- package/lib/authentication/getSasToken.d.ts +0 -12
- package/lib/authentication/getSasToken.d.ts.map +0 -1
- package/lib/authentication/getSasToken.js +0 -16
- package/lib/authentication/getSasToken.js.map +0 -1
- package/lib/authentication/isExpired.d.ts +0 -2
- package/lib/authentication/isExpired.d.ts.map +0 -1
- package/lib/authentication/isExpired.js +0 -10
- package/lib/authentication/isExpired.js.map +0 -1
- package/lib/types/ConnectionStringOptions.d.ts +0 -13
- package/lib/types/ConnectionStringOptions.d.ts.map +0 -1
- package/lib/types/ConnectionStringOptions.js +0 -2
- package/lib/types/ConnectionStringOptions.js.map +0 -1
- package/lib/types/LocalTokenCacheProvider.d.ts +0 -6
- package/lib/types/LocalTokenCacheProvider.d.ts.map +0 -1
- package/lib/types/LocalTokenCacheProvider.js +0 -2
- package/lib/types/LocalTokenCacheProvider.js.map +0 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
|
-
import type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';
|
|
3
2
|
import type { RemoteCacheClient } from './types/RemoteCacheClient.js';
|
|
4
3
|
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import type { LoginMethod } from './types/LoginMethod.js';
|
|
5
|
+
export interface CreateRemoteCacheClientParams {
|
|
6
|
+
options: {
|
|
7
|
+
storageAccount: string;
|
|
8
|
+
container: string;
|
|
9
|
+
loginMethod: LoginMethod;
|
|
10
|
+
cachePath: string;
|
|
11
|
+
};
|
|
7
12
|
context: {
|
|
8
13
|
reporter: TaskReporter;
|
|
9
14
|
telemetryClient: TelemetryClient;
|
|
10
15
|
};
|
|
11
|
-
}
|
|
16
|
+
}
|
|
17
|
+
export declare function createRemoteCacheClient(params: CreateRemoteCacheClientParams): Promise<RemoteCacheClient>;
|
|
12
18
|
//# sourceMappingURL=createRemoteCacheClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,WAAW,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,YAAY,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;KAClC,CAAC;CACH;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwB/G"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { AzureRemoteCacheClient } from './AzureRemoteCacheClient.js';
|
|
2
|
-
import { getAuthenticatedConnectionString } from './authentication/getAuthenticatedConnectionString.js';
|
|
3
2
|
import { InMemoryDecorator } from './decorators/InMemoryDecorator.js';
|
|
4
3
|
import { ReporterDecorator } from './decorators/ReporterDecorator.js';
|
|
5
4
|
import { getListOfBlobs } from './getListOfBlobs.js';
|
|
6
5
|
import { RetryDecorator } from './decorators/RetryDecorator.js';
|
|
7
6
|
import { blockListIsInvalidRetryPolicy } from './retry/blockListIsInvalidRetryPolicy.js';
|
|
8
7
|
import { RetryManager } from '@ms-cloudpack/retry';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
import { getCredential } from './authentication/getCredential.js';
|
|
9
|
+
export async function createRemoteCacheClient(params) {
|
|
10
|
+
const { context, options } = params;
|
|
11
|
+
const { container, loginMethod, storageAccount, cachePath } = options;
|
|
12
|
+
const credential = await getCredential(loginMethod, cachePath);
|
|
13
|
+
const remoteCacheClientOptions = {
|
|
14
|
+
storageAccount,
|
|
14
15
|
container,
|
|
15
|
-
|
|
16
|
+
credential,
|
|
16
17
|
};
|
|
17
18
|
const client = new ReporterDecorator(new RetryDecorator({
|
|
18
19
|
retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),
|
|
19
20
|
cacheClient: new InMemoryDecorator({
|
|
20
|
-
cacheClient: new AzureRemoteCacheClient(
|
|
21
|
-
getList: () => getListOfBlobs(
|
|
21
|
+
cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
|
|
22
|
+
getList: () => getListOfBlobs(remoteCacheClientOptions),
|
|
22
23
|
}),
|
|
23
24
|
}), context);
|
|
24
25
|
return client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAiBlE,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,MAAqC;IACjF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEtE,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAE/D,MAAM,wBAAwB,GAA6B;QACzD,cAAc;QACd,SAAS;QACT,UAAU;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAClC,IAAI,cAAc,CAAC;QACjB,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,6BAA6B,CAAC,CAAC;QAC/D,WAAW,EAAE,IAAI,iBAAiB,CAAC;YACjC,WAAW,EAAE,IAAI,sBAAsB,CAAC,wBAAwB,CAAC;YACjE,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,wBAAwB,CAAC;SACxD,CAAC;KACH,CAAC,EACF,OAAO,CACR,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { AzureRemoteCacheClient } from './AzureRemoteCacheClient.js';\nimport { InMemoryDecorator } from './decorators/InMemoryDecorator.js';\nimport { ReporterDecorator } from './decorators/ReporterDecorator.js';\nimport { getListOfBlobs } from './getListOfBlobs.js';\nimport type { RemoteCacheClient } from './types/RemoteCacheClient.js';\nimport { RetryDecorator } from './decorators/RetryDecorator.js';\nimport { blockListIsInvalidRetryPolicy } from './retry/blockListIsInvalidRetryPolicy.js';\nimport { RetryManager } from '@ms-cloudpack/retry';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport { getCredential } from './authentication/getCredential.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { LoginMethod } from './types/LoginMethod.js';\n\nexport interface CreateRemoteCacheClientParams {\n options: {\n storageAccount: string;\n container: string;\n loginMethod: LoginMethod;\n cachePath: string;\n };\n context: {\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n };\n}\n\nexport async function createRemoteCacheClient(params: CreateRemoteCacheClientParams): Promise<RemoteCacheClient> {\n const { context, options } = params;\n const { container, loginMethod, storageAccount, cachePath } = options;\n\n const credential = await getCredential(loginMethod, cachePath);\n\n const remoteCacheClientOptions: RemoteCacheClientOptions = {\n storageAccount,\n container,\n credential,\n };\n\n const client = new ReporterDecorator(\n new RetryDecorator({\n retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),\n cacheClient: new InMemoryDecorator({\n cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),\n getList: () => getListOfBlobs(remoteCacheClientOptions),\n }),\n }),\n context,\n );\n\n return client;\n}\n"]}
|
package/lib/getListOfBlobs.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.
|
|
|
2
2
|
/**
|
|
3
3
|
* Gets all the blobs in the remote cache.
|
|
4
4
|
*/
|
|
5
|
-
export declare function getListOfBlobs({ container,
|
|
5
|
+
export declare function getListOfBlobs({ container, storageAccount, credential }: RemoteCacheClientOptions): Promise<Set<string>>;
|
|
6
6
|
//# sourceMappingURL=getListOfBlobs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListOfBlobs.d.ts","sourceRoot":"","sources":["../src/getListOfBlobs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getListOfBlobs.d.ts","sourceRoot":"","sources":["../src/getListOfBlobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAGpF;;GAEG;AACH,wBAAsB,cAAc,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,wBAAwB,wBAQvG"}
|
package/lib/getListOfBlobs.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { createBlobStorageUrl } from './createBlobStorageUrl.js';
|
|
1
2
|
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
3
|
/**
|
|
3
4
|
* Gets all the blobs in the remote cache.
|
|
4
5
|
*/
|
|
5
|
-
export async function getListOfBlobs({ container,
|
|
6
|
-
const blobStorageClient = BlobServiceClient
|
|
6
|
+
export async function getListOfBlobs({ container, storageAccount, credential }) {
|
|
7
|
+
const blobStorageClient = new BlobServiceClient(createBlobStorageUrl(storageAccount), credential);
|
|
7
8
|
const containerClient = blobStorageClient.getContainerClient(container);
|
|
8
9
|
const blobs = new Set();
|
|
9
10
|
for await (const blob of containerClient.listBlobsFlat()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListOfBlobs.js","sourceRoot":"","sources":["../src/getListOfBlobs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getListOfBlobs.js","sourceRoot":"","sources":["../src/getListOfBlobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAA4B;IACtG,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;IAClG,MAAM,eAAe,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,eAAe,CAAC,aAAa,EAAE,EAAE;QACxD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtB;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport { BlobServiceClient } from '@azure/storage-blob';\n\n/**\n * Gets all the blobs in the remote cache.\n */\nexport async function getListOfBlobs({ container, storageAccount, credential }: RemoteCacheClientOptions) {\n const blobStorageClient = new BlobServiceClient(createBlobStorageUrl(storageAccount), credential);\n const containerClient = blobStorageClient.getContainerClient(container);\n const blobs = new Set<string>();\n for await (const blob of containerClient.listBlobsFlat()) {\n blobs.add(blob.name);\n }\n return blobs;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { createRemoteCacheClient } from './createRemoteCacheClient.js';
|
|
1
|
+
export { createRemoteCacheClient, type CreateRemoteCacheClientParams } from './createRemoteCacheClient.js';
|
|
2
2
|
export type { RemoteCacheClient, RemoteCacheClientDownloadOperationOptions, RemoteCacheClientOperationOptions, RemoteCacheClientOperationResult, } from './types/RemoteCacheClient.js';
|
|
3
|
-
export type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';
|
|
4
3
|
export type { LoginMethod } from './types/LoginMethod.js';
|
|
5
4
|
export type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,KAAK,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE3G,YAAY,EACV,iBAAiB,EACjB,yCAAyC,EACzC,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAsC,MAAM,8BAA8B,CAAC","sourcesContent":["export { createRemoteCacheClient, type CreateRemoteCacheClientParams } from './createRemoteCacheClient.js';\n\nexport type {\n RemoteCacheClient,\n RemoteCacheClientDownloadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from './types/RemoteCacheClient.js';\nexport type { LoginMethod } from './types/LoginMethod.js';\nexport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { TokenCredential } from '@azure/identity';
|
|
1
2
|
export interface RemoteCacheClientOptions {
|
|
2
|
-
|
|
3
|
+
storageAccount: string;
|
|
3
4
|
container: string;
|
|
5
|
+
credential: TokenCredential;
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=RemoteCacheClientOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteCacheClientOptions.d.ts","sourceRoot":"","sources":["../../src/types/RemoteCacheClientOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,
|
|
1
|
+
{"version":3,"file":"RemoteCacheClientOptions.d.ts","sourceRoot":"","sources":["../../src/types/RemoteCacheClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,eAAe,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteCacheClientOptions.js","sourceRoot":"","sources":["../../src/types/RemoteCacheClientOptions.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"RemoteCacheClientOptions.js","sourceRoot":"","sources":["../../src/types/RemoteCacheClientOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { TokenCredential } from '@azure/identity';\n\nexport interface RemoteCacheClientOptions {\n storageAccount: string;\n container: string;\n credential: TokenCredential;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/remote-cache",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
"lib/**/!(*.test.*)"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@azure/msal-node": "^2.6.0",
|
|
35
|
+
"@azure/msal-node-extensions": "^1.0.8",
|
|
34
36
|
"@ms-cloudpack/task-reporter": "^0.10.2",
|
|
35
37
|
"@ms-cloudpack/telemetry": "^0.4.4",
|
|
36
38
|
"@ms-cloudpack/retry": "^0.1.1",
|
|
37
39
|
"@azure/identity": "^3.4.0",
|
|
38
40
|
"@azure/storage-blob": "^12.17.0",
|
|
39
|
-
"@napi-rs/keyring": "^1.1.3",
|
|
40
41
|
"backfill": "^6.2.1",
|
|
41
42
|
"backfill-config": "^6.4.1"
|
|
42
43
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';
|
|
2
|
-
/**
|
|
3
|
-
* This class is responsible to read and store tokens in a key ring provided by operating system.
|
|
4
|
-
*/
|
|
5
|
-
export declare class KeyRingLocalTokenCache implements LocalTokenCacheProvider {
|
|
6
|
-
private readonly service;
|
|
7
|
-
private readonly key;
|
|
8
|
-
private readonly entry;
|
|
9
|
-
constructor(service: string, key: string);
|
|
10
|
-
get(): string | undefined;
|
|
11
|
-
set(value: string): void;
|
|
12
|
-
delete(): void;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=KeyRingLocalTokenCache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KeyRingLocalTokenCache.d.ts","sourceRoot":"","sources":["../../src/authentication/KeyRingLocalTokenCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAGnF;;GAEG;AACH,qBAAa,sBAAuB,YAAW,uBAAuB;IAIlE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;gBAGX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM;IAK9B,GAAG;IAiBH,GAAG,CAAC,KAAK,EAAE,MAAM;IAIjB,MAAM;CAOP"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Entry } from '@napi-rs/keyring';
|
|
2
|
-
/**
|
|
3
|
-
* This class is responsible to read and store tokens in a key ring provided by operating system.
|
|
4
|
-
*/
|
|
5
|
-
export class KeyRingLocalTokenCache {
|
|
6
|
-
constructor(service, key) {
|
|
7
|
-
this.service = service;
|
|
8
|
-
this.key = key;
|
|
9
|
-
this.entry = new Entry(service, key);
|
|
10
|
-
}
|
|
11
|
-
get() {
|
|
12
|
-
try {
|
|
13
|
-
const result = this.entry.getPassword();
|
|
14
|
-
console.debug(`KeyRingLocalTokenCache.get service:${this.service} key:${this.key} result:${result}`);
|
|
15
|
-
if (!result) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
// If the entry does not exist getPassword might throw an error, return undefined.
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
set(value) {
|
|
26
|
-
this.entry.setPassword(value);
|
|
27
|
-
}
|
|
28
|
-
delete() {
|
|
29
|
-
try {
|
|
30
|
-
this.entry.deletePassword();
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
// If the entry does not exist deletePassword might throw an error, do nothing.
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=KeyRingLocalTokenCache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KeyRingLocalTokenCache.js","sourceRoot":"","sources":["../../src/authentication/KeyRingLocalTokenCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YACmB,OAAe,EACf,GAAW;QADX,YAAO,GAAP,OAAO,CAAQ;QACf,QAAG,GAAH,GAAG,CAAQ;QAE5B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,GAAG;QACD,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAExC,OAAO,CAAC,KAAK,CAAC,sCAAsC,IAAI,CAAC,OAAO,QAAQ,IAAI,CAAC,GAAG,WAAW,MAAM,EAAE,CAAC,CAAC;YAErG,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,SAAS,CAAC;aAClB;YAED,OAAO,MAAM,CAAC;SACf;QAAC,MAAM;YACN,kFAAkF;YAClF,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;IAED,GAAG,CAAC,KAAa;QACf,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,MAAM;QACJ,IAAI;YACF,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;SAC7B;QAAC,MAAM;YACN,+EAA+E;SAChF;IACH,CAAC;CACF","sourcesContent":["import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';\nimport { Entry } from '@napi-rs/keyring';\n\n/**\n * This class is responsible to read and store tokens in a key ring provided by operating system.\n */\nexport class KeyRingLocalTokenCache implements LocalTokenCacheProvider {\n private readonly entry: Entry;\n\n constructor(\n private readonly service: string,\n private readonly key: string,\n ) {\n this.entry = new Entry(service, key);\n }\n\n get() {\n try {\n const result = this.entry.getPassword();\n\n console.debug(`KeyRingLocalTokenCache.get service:${this.service} key:${this.key} result:${result}`);\n\n if (!result) {\n return undefined;\n }\n\n return result;\n } catch {\n // If the entry does not exist getPassword might throw an error, return undefined.\n return undefined;\n }\n }\n\n set(value: string) {\n this.entry.setPassword(value);\n }\n\n delete() {\n try {\n this.entry.deletePassword();\n } catch {\n // If the entry does not exist deletePassword might throw an error, do nothing.\n }\n }\n}\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';
|
|
2
|
-
export declare function acquireSasToken({ storageAccount: account, container, permissions, loginMethod, tokenExpiresInMs, }: ConnectionStringOptions): Promise<string>;
|
|
3
|
-
//# sourceMappingURL=acquireSasToken.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acquireSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,wBAAsB,eAAe,CAAC,EACpC,cAAc,EAAE,OAAO,EACvB,SAAS,EACT,WAAW,EACX,WAAW,EACX,gBAAgB,GACjB,EAAE,uBAAuB,mBAgCzB"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BlobServiceClient, ContainerSASPermissions, SASProtocol, generateBlobSASQueryParameters, } from '@azure/storage-blob';
|
|
2
|
-
import { createBlobStorageUrl } from './createBlobStorageUrl.js';
|
|
3
|
-
import { getCredential } from './getCredential.js';
|
|
4
|
-
export async function acquireSasToken({ storageAccount: account, container, permissions, loginMethod, tokenExpiresInMs, }) {
|
|
5
|
-
const credential = getCredential(loginMethod);
|
|
6
|
-
const blobStorage = new BlobServiceClient(createBlobStorageUrl(account), credential);
|
|
7
|
-
const containerClient = blobStorage.getContainerClient(container);
|
|
8
|
-
const startsOn = new Date(); // now
|
|
9
|
-
const hourInMs = 3600000;
|
|
10
|
-
const dayInMs = 24 * hourInMs;
|
|
11
|
-
const expiresInMs = 7 * dayInMs; // 7 days (maximum allowed by Azure)
|
|
12
|
-
if (tokenExpiresInMs && tokenExpiresInMs > expiresInMs) {
|
|
13
|
-
console.warn('Maximum allowed token expiration is 7 days. Using 7 days instead.');
|
|
14
|
-
tokenExpiresInMs = expiresInMs;
|
|
15
|
-
}
|
|
16
|
-
const expiresOn = new Date(startsOn.valueOf() + (tokenExpiresInMs ?? expiresInMs));
|
|
17
|
-
const userDelegationKey = await blobStorage.getUserDelegationKey(startsOn, expiresOn);
|
|
18
|
-
const sasQueryParams = generateBlobSASQueryParameters({
|
|
19
|
-
containerName: containerClient.containerName,
|
|
20
|
-
permissions: ContainerSASPermissions.from(permissions),
|
|
21
|
-
expiresOn,
|
|
22
|
-
startsOn,
|
|
23
|
-
protocol: SASProtocol.Https,
|
|
24
|
-
}, userDelegationKey, account);
|
|
25
|
-
return sasQueryParams.toString();
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=acquireSasToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acquireSasToken.js","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,cAAc,EAAE,OAAO,EACvB,SAAS,EACT,WAAW,EACX,WAAW,EACX,gBAAgB,GACQ;IACxB,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IACrF,MAAM,eAAe,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,MAAM,OAAO,GAAG,EAAE,GAAG,QAAQ,CAAC;IAC9B,MAAM,WAAW,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,oCAAoC;IAErE,IAAI,gBAAgB,IAAI,gBAAgB,GAAG,WAAW,EAAE;QACtD,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QAClF,gBAAgB,GAAG,WAAW,CAAC;KAChC;IAED,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,gBAAgB,IAAI,WAAW,CAAC,CAAC,CAAC;IAEnF,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEtF,MAAM,cAAc,GAAG,8BAA8B,CACnD;QACE,aAAa,EAAE,eAAe,CAAC,aAAa;QAC5C,WAAW,EAAE,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC;QACtD,SAAS;QACT,QAAQ;QACR,QAAQ,EAAE,WAAW,CAAC,KAAK;KAC5B,EACD,iBAAiB,EACjB,OAAO,CACR,CAAC;IAEF,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n BlobServiceClient,\n ContainerSASPermissions,\n SASProtocol,\n generateBlobSASQueryParameters,\n} from '@azure/storage-blob';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport { getCredential } from './getCredential.js';\n\nexport async function acquireSasToken({\n storageAccount: account,\n container,\n permissions,\n loginMethod,\n tokenExpiresInMs,\n}: ConnectionStringOptions) {\n const credential = getCredential(loginMethod);\n const blobStorage = new BlobServiceClient(createBlobStorageUrl(account), credential);\n const containerClient = blobStorage.getContainerClient(container);\n\n const startsOn = new Date(); // now\n const hourInMs = 3600000;\n const dayInMs = 24 * hourInMs;\n const expiresInMs = 7 * dayInMs; // 7 days (maximum allowed by Azure)\n\n if (tokenExpiresInMs && tokenExpiresInMs > expiresInMs) {\n console.warn('Maximum allowed token expiration is 7 days. Using 7 days instead.');\n tokenExpiresInMs = expiresInMs;\n }\n\n const expiresOn = new Date(startsOn.valueOf() + (tokenExpiresInMs ?? expiresInMs));\n\n const userDelegationKey = await blobStorage.getUserDelegationKey(startsOn, expiresOn);\n\n const sasQueryParams = generateBlobSASQueryParameters(\n {\n containerName: containerClient.containerName,\n permissions: ContainerSASPermissions.from(permissions),\n expiresOn,\n startsOn,\n protocol: SASProtocol.Https,\n },\n userDelegationKey,\n account,\n );\n\n return sasQueryParams.toString();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBlobStorageUrl.d.ts","sourceRoot":"","sources":["../../src/authentication/createBlobStorageUrl.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,UAEnD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBlobStorageUrl.js","sourceRoot":"","sources":["../../src/authentication/createBlobStorageUrl.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,OAAO,WAAW,OAAO,wBAAwB,CAAC;AACpD,CAAC","sourcesContent":["export function createBlobStorageUrl(account: string) {\n return `https://${account}.blob.core.windows.net`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticatedConnectionString.d.ts","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAenF,wBAAsB,gCAAgC,CAAC,uBAAuB,EAAE,uBAAuB,mBAWtG"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createBlobStorageUrl } from './createBlobStorageUrl.js';
|
|
2
|
-
import { getSasToken } from './getSasToken.js';
|
|
3
|
-
import { acquireSasToken } from './acquireSasToken.js';
|
|
4
|
-
import { isExpired } from './isExpired.js';
|
|
5
|
-
import { ContainerSASPermissions } from '@azure/storage-blob';
|
|
6
|
-
async function createLocalTokenCacheLazy({ storageAccount, container, permissions }) {
|
|
7
|
-
const { KeyRingLocalTokenCache } = await import('./KeyRingLocalTokenCache.js');
|
|
8
|
-
const service = `cloudpack-cache-${storageAccount}`;
|
|
9
|
-
const key = `container:${container};permission:${ContainerSASPermissions.from(permissions).toString()}`;
|
|
10
|
-
return new KeyRingLocalTokenCache(service, key);
|
|
11
|
-
}
|
|
12
|
-
export async function getAuthenticatedConnectionString(connectionStringOptions) {
|
|
13
|
-
// No need to cache tokens if the user is NOT running in interactive mode.
|
|
14
|
-
const tokenCache = connectionStringOptions.loginMethod == 'interactive' || connectionStringOptions.loginMethod == 'azure-cli'
|
|
15
|
-
? await createLocalTokenCacheLazy(connectionStringOptions)
|
|
16
|
-
: undefined;
|
|
17
|
-
const sasToken = await getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired });
|
|
18
|
-
const { storageAccount } = connectionStringOptions;
|
|
19
|
-
return `BlobEndpoint=${createBlobStorageUrl(storageAccount)};SharedAccessSignature=${sasToken}`;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=getAuthenticatedConnectionString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticatedConnectionString.js","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,KAAK,UAAU,yBAAyB,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAA2B;IAC1G,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAE/E,MAAM,OAAO,GAAG,mBAAmB,cAAc,EAAE,CAAC;IACpD,MAAM,GAAG,GAAG,aAAa,SAAS,eAAe,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;IAExG,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,uBAAgD;IACrG,0EAA0E;IAC1E,MAAM,UAAU,GACd,uBAAuB,CAAC,WAAW,IAAI,aAAa,IAAI,uBAAuB,CAAC,WAAW,IAAI,WAAW;QACxG,CAAC,CAAC,MAAM,yBAAyB,CAAC,uBAAuB,CAAC;QAC1D,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAE5G,MAAM,EAAE,cAAc,EAAE,GAAG,uBAAuB,CAAC;IACnD,OAAO,gBAAgB,oBAAoB,CAAC,cAAc,CAAC,0BAA0B,QAAQ,EAAE,CAAC;AAClG,CAAC","sourcesContent":["import { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { getSasToken } from './getSasToken.js';\nimport { acquireSasToken } from './acquireSasToken.js';\nimport { isExpired } from './isExpired.js';\nimport { ContainerSASPermissions } from '@azure/storage-blob';\n\nasync function createLocalTokenCacheLazy({ storageAccount, container, permissions }: ConnectionStringOptions) {\n const { KeyRingLocalTokenCache } = await import('./KeyRingLocalTokenCache.js');\n\n const service = `cloudpack-cache-${storageAccount}`;\n const key = `container:${container};permission:${ContainerSASPermissions.from(permissions).toString()}`;\n\n return new KeyRingLocalTokenCache(service, key);\n}\n\nexport async function getAuthenticatedConnectionString(connectionStringOptions: ConnectionStringOptions) {\n // No need to cache tokens if the user is NOT running in interactive mode.\n const tokenCache =\n connectionStringOptions.loginMethod == 'interactive' || connectionStringOptions.loginMethod == 'azure-cli'\n ? await createLocalTokenCacheLazy(connectionStringOptions)\n : undefined;\n\n const sasToken = await getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired });\n\n const { storageAccount } = connectionStringOptions;\n return `BlobEndpoint=${createBlobStorageUrl(storageAccount)};SharedAccessSignature=${sasToken}`;\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';
|
|
2
|
-
import type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';
|
|
3
|
-
export interface GetSasTokenOptions {
|
|
4
|
-
connectionStringOptions: ConnectionStringOptions;
|
|
5
|
-
}
|
|
6
|
-
export interface GetSasTokenDependencies {
|
|
7
|
-
tokenCache?: LocalTokenCacheProvider;
|
|
8
|
-
acquireSasToken: (options: ConnectionStringOptions) => Promise<string>;
|
|
9
|
-
isExpired: (token: string) => boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function getSasToken({ connectionStringOptions }: GetSasTokenOptions, { tokenCache, acquireSasToken, isExpired }: GetSasTokenDependencies): Promise<string>;
|
|
12
|
-
//# sourceMappingURL=getSasToken.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEnF,MAAM,WAAW,kBAAkB;IACjC,uBAAuB,EAAE,uBAAuB,CAAC;CAClD;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED,wBAAsB,WAAW,CAC/B,EAAE,uBAAuB,EAAE,EAAE,kBAAkB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,uBAAuB,mBAepE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export async function getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired }) {
|
|
2
|
-
try {
|
|
3
|
-
const localToken = tokenCache?.get();
|
|
4
|
-
if (localToken && !isExpired(localToken)) {
|
|
5
|
-
return localToken;
|
|
6
|
-
}
|
|
7
|
-
const token = await acquireSasToken(connectionStringOptions);
|
|
8
|
-
tokenCache?.set(token);
|
|
9
|
-
return token;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
console.error(`Failed to get SAS token for storage account.`, error);
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=getSasToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSasToken.js","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,EAAE,uBAAuB,EAAsB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAA2B;IAEnE,IAAI;QACF,MAAM,UAAU,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC;QACrC,IAAI,UAAU,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;YACxC,OAAO,UAAU,CAAC;SACnB;QAED,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,uBAAuB,CAAC,CAAC;QAC7D,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;QACrE,MAAM,KAAK,CAAC;KACb;AACH,CAAC","sourcesContent":["import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\n\nexport interface GetSasTokenOptions {\n connectionStringOptions: ConnectionStringOptions;\n}\n\nexport interface GetSasTokenDependencies {\n tokenCache?: LocalTokenCacheProvider;\n acquireSasToken: (options: ConnectionStringOptions) => Promise<string>;\n isExpired: (token: string) => boolean;\n}\n\nexport async function getSasToken(\n { connectionStringOptions }: GetSasTokenOptions,\n { tokenCache, acquireSasToken, isExpired }: GetSasTokenDependencies,\n) {\n try {\n const localToken = tokenCache?.get();\n if (localToken && !isExpired(localToken)) {\n return localToken;\n }\n\n const token = await acquireSasToken(connectionStringOptions);\n tokenCache?.set(token);\n return token;\n } catch (error) {\n console.error(`Failed to get SAS token for storage account.`, error);\n throw error;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isExpired.d.ts","sourceRoot":"","sources":["../../src/authentication/isExpired.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,WAQzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isExpired.js","sourceRoot":"","sources":["../../src/authentication/isExpired.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,MAAM,EAAE,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,EAAE,EAAE;QACP,OAAO,IAAI,CAAC;KACb;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,MAAM,GAAG,GAAG,CAAC;AACtB,CAAC","sourcesContent":["export function isExpired(sasToken: string) {\n const se = new URLSearchParams(sasToken).get('se');\n if (!se) {\n return true;\n }\n const expiry = new Date(se);\n const now = new Date();\n return expiry < now;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { LoginMethod } from './LoginMethod.js';
|
|
2
|
-
export interface ConnectionStringOptions {
|
|
3
|
-
storageAccount: string;
|
|
4
|
-
container: string;
|
|
5
|
-
permissions: {
|
|
6
|
-
read: boolean;
|
|
7
|
-
write: boolean;
|
|
8
|
-
list: boolean;
|
|
9
|
-
};
|
|
10
|
-
tokenExpiresInMs?: number;
|
|
11
|
-
loginMethod: LoginMethod;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=ConnectionStringOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStringOptions.d.ts","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;QACf,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;CAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStringOptions.js","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { LoginMethod } from './LoginMethod.js';\n\nexport interface ConnectionStringOptions {\n storageAccount: string;\n container: string;\n permissions: {\n read: boolean;\n write: boolean;\n list: boolean;\n };\n tokenExpiresInMs?: number;\n loginMethod: LoginMethod;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalTokenCacheProvider.d.ts","sourceRoot":"","sources":["../../src/types/LocalTokenCacheProvider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalTokenCacheProvider.js","sourceRoot":"","sources":["../../src/types/LocalTokenCacheProvider.ts"],"names":[],"mappings":"","sourcesContent":["export interface LocalTokenCacheProvider {\n get(): string | undefined;\n set(value: string): void;\n delete(): void;\n}\n"]}
|