@ms-cloudpack/remote-cache 0.5.2 → 0.5.4-beta.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/dist/AzureRemoteCacheClient-R5HCIW6L.js +65 -0
- package/dist/ReporterDecorator-SNBYNGOT.js +134 -0
- package/dist/chunk-4P62L7ZZ.js +1530 -0
- package/dist/chunk-KFSFZYG6.js +49961 -0
- package/dist/chunk-R2VDVRDZ.js +15 -0
- package/dist/chunk-TQLTL4XO.js +65 -0
- package/dist/getCredential-QMMPE77Q.js +24525 -0
- package/dist/getListOfBlobs-E5OFG2MF.js +29 -0
- package/dist/index.js +109 -0
- package/lib/decorators/InMemoryDecorator.test.d.ts +2 -0
- package/lib/decorators/RetryDecorator.test.d.ts +2 -0
- package/package.json +13 -12
- package/lib/AzureRemoteCacheClient.d.ts.map +0 -1
- package/lib/AzureRemoteCacheClient.js +0 -51
- package/lib/AzureRemoteCacheClient.js.map +0 -1
- package/lib/Task.d.ts.map +0 -1
- package/lib/Task.js +0 -2
- package/lib/Task.js.map +0 -1
- package/lib/authentication/getAuthenticationRecord.d.ts.map +0 -1
- package/lib/authentication/getAuthenticationRecord.js +0 -17
- package/lib/authentication/getAuthenticationRecord.js.map +0 -1
- package/lib/authentication/getAuthenticationRecordPath.d.ts.map +0 -1
- package/lib/authentication/getAuthenticationRecordPath.js +0 -10
- package/lib/authentication/getAuthenticationRecordPath.js.map +0 -1
- package/lib/authentication/getCredential.d.ts.map +0 -1
- package/lib/authentication/getCredential.js +0 -61
- package/lib/authentication/getCredential.js.map +0 -1
- package/lib/authentication/saveAuthenticationRecord.d.ts.map +0 -1
- package/lib/authentication/saveAuthenticationRecord.js +0 -17
- package/lib/authentication/saveAuthenticationRecord.js.map +0 -1
- package/lib/cache-persistance/cachePersistencePlugin.d.ts +0 -32
- package/lib/cache-persistance/cachePersistencePlugin.d.ts.map +0 -1
- package/lib/cache-persistance/cachePersistencePlugin.js +0 -35
- package/lib/cache-persistance/cachePersistencePlugin.js.map +0 -1
- package/lib/cache-persistance/platforms.d.ts +0 -55
- package/lib/cache-persistance/platforms.d.ts.map +0 -1
- package/lib/cache-persistance/platforms.js +0 -109
- package/lib/cache-persistance/platforms.js.map +0 -1
- package/lib/cache-persistance/provider.d.ts +0 -15
- package/lib/cache-persistance/provider.d.ts.map +0 -1
- package/lib/cache-persistance/provider.js +0 -26
- package/lib/cache-persistance/provider.js.map +0 -1
- package/lib/createBlobStorageUrl.d.ts.map +0 -1
- package/lib/createBlobStorageUrl.js +0 -4
- package/lib/createBlobStorageUrl.js.map +0 -1
- package/lib/createRemoteCacheClient.d.ts.map +0 -1
- package/lib/createRemoteCacheClient.js +0 -27
- package/lib/createRemoteCacheClient.js.map +0 -1
- package/lib/decorators/InMemoryDecorator.d.ts.map +0 -1
- package/lib/decorators/InMemoryDecorator.js +0 -29
- package/lib/decorators/InMemoryDecorator.js.map +0 -1
- package/lib/decorators/ReporterDecorator.d.ts.map +0 -1
- package/lib/decorators/ReporterDecorator.js +0 -126
- package/lib/decorators/ReporterDecorator.js.map +0 -1
- package/lib/decorators/RetryDecorator.d.ts.map +0 -1
- package/lib/decorators/RetryDecorator.js +0 -27
- package/lib/decorators/RetryDecorator.js.map +0 -1
- package/lib/getListOfBlobs.d.ts.map +0 -1
- package/lib/getListOfBlobs.js +0 -15
- package/lib/getListOfBlobs.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/retry/blockListIsInvalidRetryPolicy.d.ts.map +0 -1
- package/lib/retry/blockListIsInvalidRetryPolicy.js +0 -8
- package/lib/retry/blockListIsInvalidRetryPolicy.js.map +0 -1
- package/lib/tsdoc-metadata.json +0 -11
- package/lib/types/LoginMethod.d.ts.map +0 -1
- package/lib/types/LoginMethod.js +0 -2
- package/lib/types/LoginMethod.js.map +0 -1
- package/lib/types/RemoteCacheClient.d.ts.map +0 -1
- package/lib/types/RemoteCacheClient.js +0 -2
- package/lib/types/RemoteCacheClient.js.map +0 -1
- package/lib/types/RemoteCacheClientOptions.d.ts.map +0 -1
- package/lib/types/RemoteCacheClientOptions.js +0 -2
- package/lib/types/RemoteCacheClientOptions.js.map +0 -1
- package/lib/types/RetryPolicy.d.ts.map +0 -1
- package/lib/types/RetryPolicy.js +0 -2
- package/lib/types/RetryPolicy.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBlobStorageUrl
|
|
3
|
+
} from "./chunk-R2VDVRDZ.js";
|
|
4
|
+
import {
|
|
5
|
+
require_dist
|
|
6
|
+
} from "./chunk-KFSFZYG6.js";
|
|
7
|
+
import "./chunk-4P62L7ZZ.js";
|
|
8
|
+
import {
|
|
9
|
+
__name,
|
|
10
|
+
__toESM,
|
|
11
|
+
init_esbuildCjsShims
|
|
12
|
+
} from "./chunk-TQLTL4XO.js";
|
|
13
|
+
|
|
14
|
+
// src/getListOfBlobs.ts
|
|
15
|
+
init_esbuildCjsShims();
|
|
16
|
+
var import_storage_blob = __toESM(require_dist(), 1);
|
|
17
|
+
async function getListOfBlobs({ container, storageAccount, credential }) {
|
|
18
|
+
const blobStorageClient = new import_storage_blob.BlobServiceClient(createBlobStorageUrl(storageAccount), credential);
|
|
19
|
+
const containerClient = blobStorageClient.getContainerClient(container);
|
|
20
|
+
const blobs = /* @__PURE__ */ new Set();
|
|
21
|
+
for await (const blob of containerClient.listBlobsFlat()) {
|
|
22
|
+
blobs.add(blob.name);
|
|
23
|
+
}
|
|
24
|
+
return blobs;
|
|
25
|
+
}
|
|
26
|
+
__name(getListOfBlobs, "getListOfBlobs");
|
|
27
|
+
export {
|
|
28
|
+
getListOfBlobs
|
|
29
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name,
|
|
3
|
+
init_esbuildCjsShims
|
|
4
|
+
} from "./chunk-TQLTL4XO.js";
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
init_esbuildCjsShims();
|
|
8
|
+
|
|
9
|
+
// src/createRemoteCacheClient.ts
|
|
10
|
+
init_esbuildCjsShims();
|
|
11
|
+
|
|
12
|
+
// src/decorators/InMemoryDecorator.ts
|
|
13
|
+
init_esbuildCjsShims();
|
|
14
|
+
var _InMemoryDecorator = class _InMemoryDecorator {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.cacheClient = options.cacheClient;
|
|
17
|
+
this.list = options.getList();
|
|
18
|
+
}
|
|
19
|
+
async uploadFolder(options) {
|
|
20
|
+
if ((await this.list).has(options.id)) {
|
|
21
|
+
return "already-exist";
|
|
22
|
+
}
|
|
23
|
+
const result = await this.cacheClient.uploadFolder(options);
|
|
24
|
+
if (result === "success") {
|
|
25
|
+
(await this.list).add(options.id);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
async downloadFolder(options) {
|
|
30
|
+
if (!(await this.list).has(options.id)) {
|
|
31
|
+
return "not-found";
|
|
32
|
+
}
|
|
33
|
+
return this.cacheClient.downloadFolder(options);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
__name(_InMemoryDecorator, "InMemoryDecorator");
|
|
37
|
+
var InMemoryDecorator = _InMemoryDecorator;
|
|
38
|
+
|
|
39
|
+
// src/decorators/RetryDecorator.ts
|
|
40
|
+
init_esbuildCjsShims();
|
|
41
|
+
var _RetryDecorator = class _RetryDecorator {
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.cacheClient = options.cacheClient;
|
|
44
|
+
this.retryManager = options.retryManager;
|
|
45
|
+
}
|
|
46
|
+
printRetryContext(operationName, options, retryContext) {
|
|
47
|
+
if (retryContext) {
|
|
48
|
+
console.warn(
|
|
49
|
+
`Retrying ${operationName} ${options.friendlyName} ... [${retryContext.retryAttempt}/${retryContext.maxRetries}]`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async uploadFolder(options) {
|
|
54
|
+
return this.retryManager.retry((retryContext) => {
|
|
55
|
+
this.printRetryContext("upload", options, retryContext);
|
|
56
|
+
return this.cacheClient.uploadFolder(options);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async downloadFolder(options) {
|
|
60
|
+
return this.retryManager.retry((retryContext) => {
|
|
61
|
+
this.printRetryContext("download", options, retryContext);
|
|
62
|
+
return this.cacheClient.downloadFolder(options);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__name(_RetryDecorator, "RetryDecorator");
|
|
67
|
+
var RetryDecorator = _RetryDecorator;
|
|
68
|
+
|
|
69
|
+
// src/retry/blockListIsInvalidRetryPolicy.ts
|
|
70
|
+
init_esbuildCjsShims();
|
|
71
|
+
var blockListIsInvalidRetryPolicy = {
|
|
72
|
+
maxRetries: 1,
|
|
73
|
+
handle: (error) => {
|
|
74
|
+
return error instanceof Error && error.message.indexOf("The specified block list is invalid.") > -1;
|
|
75
|
+
},
|
|
76
|
+
wait: () => 0
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/createRemoteCacheClient.ts
|
|
80
|
+
import { RetryManager } from "@ms-cloudpack/retry";
|
|
81
|
+
async function createRemoteCacheClient(params) {
|
|
82
|
+
const { context, options } = params;
|
|
83
|
+
const { container, loginMethod, storageAccount, cachePath } = options;
|
|
84
|
+
const { getCredential } = await import("./getCredential-QMMPE77Q.js");
|
|
85
|
+
const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-R5HCIW6L.js");
|
|
86
|
+
const { ReporterDecorator } = await import("./ReporterDecorator-SNBYNGOT.js");
|
|
87
|
+
const { getListOfBlobs } = await import("./getListOfBlobs-E5OFG2MF.js");
|
|
88
|
+
const credential = await getCredential(loginMethod, cachePath);
|
|
89
|
+
const remoteCacheClientOptions = {
|
|
90
|
+
storageAccount,
|
|
91
|
+
container,
|
|
92
|
+
credential
|
|
93
|
+
};
|
|
94
|
+
const client = new ReporterDecorator(
|
|
95
|
+
new RetryDecorator({
|
|
96
|
+
retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),
|
|
97
|
+
cacheClient: new InMemoryDecorator({
|
|
98
|
+
cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
|
|
99
|
+
getList: () => getListOfBlobs(remoteCacheClientOptions)
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
context
|
|
103
|
+
);
|
|
104
|
+
return client;
|
|
105
|
+
}
|
|
106
|
+
__name(createRemoteCacheClient, "createRemoteCacheClient");
|
|
107
|
+
export {
|
|
108
|
+
createRemoteCacheClient
|
|
109
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/remote-cache",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4-beta.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",
|
|
@@ -10,34 +10,35 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"source": "./src/index.ts",
|
|
12
12
|
"types": "./lib/index.d.ts",
|
|
13
|
-
"import": "./
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@ms-cloudpack/eslint-plugin-internal": "*",
|
|
18
|
-
"@ms-cloudpack/scripts": "*"
|
|
19
|
-
},
|
|
20
16
|
"scripts": {
|
|
21
17
|
"api": "cloudpack-scripts api",
|
|
22
18
|
"build:watch": "cloudpack-scripts build-watch",
|
|
23
|
-
"build": "cloudpack-scripts build",
|
|
19
|
+
"build": "cloudpack-scripts build && cloudpack-scripts bundle-node",
|
|
24
20
|
"lint:update": "cloudpack-scripts lint-update",
|
|
25
21
|
"lint": "cloudpack-scripts lint",
|
|
26
22
|
"test:watch": "cloudpack-scripts test-watch",
|
|
27
23
|
"test": "cloudpack-scripts test"
|
|
28
24
|
},
|
|
29
25
|
"files": [
|
|
30
|
-
"
|
|
26
|
+
"dist",
|
|
27
|
+
"lib/**/*.d.ts"
|
|
31
28
|
],
|
|
32
29
|
"dependencies": {
|
|
33
|
-
"@azure/identity": "^3.4.0",
|
|
34
|
-
"@azure/msal-node": "^2.6.0",
|
|
35
30
|
"@azure/msal-node-extensions": "^1.0.10",
|
|
36
|
-
"@azure/storage-blob": "^12.17.0",
|
|
37
31
|
"@ms-cloudpack/retry": "^0.1.1",
|
|
38
32
|
"@ms-cloudpack/task-reporter": "^0.11.2",
|
|
39
|
-
"@ms-cloudpack/telemetry": "^0.4.
|
|
33
|
+
"@ms-cloudpack/telemetry": "^0.4.9-beta.0",
|
|
40
34
|
"backfill": "^6.2.1",
|
|
41
35
|
"backfill-config": "^6.4.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@azure/identity": "^4.0.0",
|
|
39
|
+
"@azure/identity-cache-persistence": "^1.1.0",
|
|
40
|
+
"@azure/storage-blob": "^12.17.0",
|
|
41
|
+
"@ms-cloudpack/eslint-plugin-internal": "*",
|
|
42
|
+
"@ms-cloudpack/scripts": "*"
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AzureRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/AzureRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAGpF,OAAO,KAAK,EACV,iBAAiB,EACjB,iCAAiC,EACjC,uCAAuC,EACxC,MAAM,8BAA8B,CAAC;AAGtC,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAIrB;gBAEU,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,wBAAwB;IAe/E;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,uCAAuC;IASrF;;;;;OAKG;IACG,cAAc,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,iCAAiC;CAYrE"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { makeLogger, put, fetch } from 'backfill/lib/api.js';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { createBlobStorageUrl } from './createBlobStorageUrl.js';
|
|
4
|
-
export class AzureRemoteCacheClient {
|
|
5
|
-
constructor({ container, storageAccount, credential }) {
|
|
6
|
-
this.logger = makeLogger('mute', process.stdout, process.stderr);
|
|
7
|
-
this.config = {
|
|
8
|
-
incrementalCaching: true,
|
|
9
|
-
internalCacheFolder: '', // not used by azure-blob
|
|
10
|
-
cacheStorageConfig: {
|
|
11
|
-
provider: 'azure-blob',
|
|
12
|
-
options: {
|
|
13
|
-
connectionString: createBlobStorageUrl(storageAccount),
|
|
14
|
-
credential,
|
|
15
|
-
container,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Uploads the folder to the remote cache.
|
|
22
|
-
* @param id - The unique identifier of the asset to upload.
|
|
23
|
-
* @param path - The path to the folder to upload.
|
|
24
|
-
* @param globMatches - The glob pattern to use when uploading the folder.
|
|
25
|
-
* @returns - A promise that resolves when the folder has been uploaded.
|
|
26
|
-
*/
|
|
27
|
-
async uploadFolder({ id, path, globMatches }) {
|
|
28
|
-
if (!existsSync(path)) {
|
|
29
|
-
return 'not-found';
|
|
30
|
-
}
|
|
31
|
-
await put(path, id, this.logger, { ...this.config, outputGlob: globMatches });
|
|
32
|
-
return 'success';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Downloads the folder from the remote cache.
|
|
36
|
-
* @param id - The unique identifier of the asset to download.
|
|
37
|
-
* @param path - The path to download the folder to.
|
|
38
|
-
* @returns - A promise that resolves when the folder has been downloaded.
|
|
39
|
-
*/
|
|
40
|
-
async downloadFolder({ id, path }) {
|
|
41
|
-
if (existsSync(path)) {
|
|
42
|
-
return 'already-exist';
|
|
43
|
-
}
|
|
44
|
-
const result = await fetch(path, id, this.logger, this.config);
|
|
45
|
-
if (!result) {
|
|
46
|
-
return 'not-found';
|
|
47
|
-
}
|
|
48
|
-
return 'success';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=AzureRemoteCacheClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AzureRemoteCacheClient.js","sourceRoot":"","sources":["../src/AzureRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAMhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,sBAAsB;IAQjC,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAA4B;QAP9D,WAAM,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAQ3E,IAAI,CAAC,MAAM,GAAG;YACZ,kBAAkB,EAAE,IAAI;YACxB,mBAAmB,EAAE,EAAE,EAAE,yBAAyB;YAClD,kBAAkB,EAAE;gBAClB,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,gBAAgB,EAAE,oBAAoB,CAAC,cAAc,CAAC;oBACtD,UAAU;oBACV,SAAS;iBACV;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAA2C;QACnF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9E,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,IAAI,EAAqC;QAClE,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { makeLogger, put, fetch } from 'backfill/lib/api.js';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport type { AzureBlobCacheStorageConfig } from 'backfill-config';\nimport { existsSync } from 'fs';\nimport type {\n RemoteCacheClient,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientUploadOperationOptions,\n} from './types/RemoteCacheClient.js';\nimport { createBlobStorageUrl } from './createBlobStorageUrl.js';\n\nexport class AzureRemoteCacheClient implements RemoteCacheClient {\n private readonly logger = makeLogger('mute', process.stdout, process.stderr);\n private readonly config: {\n cacheStorageConfig: AzureBlobCacheStorageConfig;\n incrementalCaching: boolean;\n internalCacheFolder: string;\n };\n\n constructor({ container, storageAccount, credential }: RemoteCacheClientOptions) {\n this.config = {\n incrementalCaching: true,\n internalCacheFolder: '', // not used by azure-blob\n cacheStorageConfig: {\n provider: 'azure-blob',\n options: {\n connectionString: createBlobStorageUrl(storageAccount),\n credential,\n container,\n },\n },\n };\n }\n\n /**\n * Uploads the folder to the remote cache.\n * @param id - The unique identifier of the asset to upload.\n * @param path - The path to the folder to upload.\n * @param globMatches - The glob pattern to use when uploading the folder.\n * @returns - A promise that resolves when the folder has been uploaded.\n */\n async uploadFolder({ id, path, globMatches }: RemoteCacheClientUploadOperationOptions) {\n if (!existsSync(path)) {\n return 'not-found';\n }\n\n await put(path, id, this.logger, { ...this.config, outputGlob: globMatches });\n return 'success';\n }\n\n /**\n * Downloads the folder from the remote cache.\n * @param id - The unique identifier of the asset to download.\n * @param path - The path to download the folder to.\n * @returns - A promise that resolves when the folder has been downloaded.\n */\n async downloadFolder({ id, path }: RemoteCacheClientOperationOptions) {\n if (existsSync(path)) {\n return 'already-exist';\n }\n\n const result = await fetch(path, id, this.logger, this.config);\n if (!result) {\n return 'not-found';\n }\n\n return 'success';\n }\n}\n"]}
|
package/lib/Task.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../src/Task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAChD"}
|
package/lib/Task.js
DELETED
package/lib/Task.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Task.js","sourceRoot":"","sources":["../src/Task.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporterTaskResult } from '@ms-cloudpack/task-reporter';\n\nexport interface Task {\n name: string;\n execute: () => Promise<TaskReporterTaskResult>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticationRecord.d.ts","sourceRoot":"","sources":["../../src/authentication/getAuthenticationRecord.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,8DAQxD"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { deserializeAuthenticationRecord } from '@azure/identity';
|
|
2
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
-
import { getAuthenticationRecordPath } from './getAuthenticationRecordPath.js';
|
|
4
|
-
/**
|
|
5
|
-
* Retrieves the authentication record from Cloudpack's global cache folder.
|
|
6
|
-
* @param cachePath - The path to Cloudpack's cache folder.
|
|
7
|
-
* @returns - The authentication record if it exists; otherwise, returns `undefined`.
|
|
8
|
-
*/
|
|
9
|
-
export function getAuthenticationRecord(cachePath) {
|
|
10
|
-
const fullPath = getAuthenticationRecordPath(cachePath);
|
|
11
|
-
if (!existsSync(fullPath)) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
15
|
-
return deserializeAuthenticationRecord(content);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=getAuthenticationRecord.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticationRecord.js","sourceRoot":"","sources":["../../src/authentication/getAuthenticationRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACvD,MAAM,QAAQ,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import { deserializeAuthenticationRecord } from '@azure/identity';\nimport { existsSync, readFileSync } from 'fs';\nimport { getAuthenticationRecordPath } from './getAuthenticationRecordPath.js';\n\n/**\n * Retrieves the authentication record from Cloudpack's global cache folder.\n * @param cachePath - The path to Cloudpack's cache folder.\n * @returns - The authentication record if it exists; otherwise, returns `undefined`.\n */\nexport function getAuthenticationRecord(cachePath: string) {\n const fullPath = getAuthenticationRecordPath(cachePath);\n if (!existsSync(fullPath)) {\n return undefined;\n }\n\n const content = readFileSync(fullPath, 'utf-8');\n return deserializeAuthenticationRecord(content);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticationRecordPath.d.ts","sourceRoot":"","sources":["../../src/authentication/getAuthenticationRecordPath.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,UAE5D"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
/**
|
|
3
|
-
* Constructs and returns the full path to the authentication record file within the specified cache folder.
|
|
4
|
-
* @param cachePath - The path to Cloudpack's cache folder.
|
|
5
|
-
* @returns - The full path to the authentication record file.
|
|
6
|
-
*/
|
|
7
|
-
export function getAuthenticationRecordPath(cachePath) {
|
|
8
|
-
return path.join(cachePath, 'tokencache.bin');
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=getAuthenticationRecordPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthenticationRecordPath.js","sourceRoot":"","sources":["../../src/authentication/getAuthenticationRecordPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,SAAiB;IAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Constructs and returns the full path to the authentication record file within the specified cache folder.\n * @param cachePath - The path to Cloudpack's cache folder.\n * @returns - The full path to the authentication record file.\n */\nexport function getAuthenticationRecordPath(cachePath: string) {\n return path.join(cachePath, 'tokencache.bin');\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getCredential.d.ts","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA4B3D;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAwC9E"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { AzureCliCredential, DeviceCodeCredential, InteractiveBrowserCredential, useIdentityPlugin, } from '@azure/identity';
|
|
2
|
-
import { cachePersistencePlugin } from '../cache-persistance/cachePersistencePlugin.js';
|
|
3
|
-
import { getAuthenticationRecord } from './getAuthenticationRecord.js';
|
|
4
|
-
import { saveAuthenticationRecord } from './saveAuthenticationRecord.js';
|
|
5
|
-
const tokenCachePersistenceOptions = {
|
|
6
|
-
enabled: true,
|
|
7
|
-
name: 'cloudpack',
|
|
8
|
-
};
|
|
9
|
-
function getCredentialInternal(loginMethod, authenticationRecord) {
|
|
10
|
-
switch (loginMethod) {
|
|
11
|
-
case 'interactive':
|
|
12
|
-
return new InteractiveBrowserCredential({
|
|
13
|
-
redirectUri: 'http://localhost:1337',
|
|
14
|
-
authenticationRecord,
|
|
15
|
-
tokenCachePersistenceOptions,
|
|
16
|
-
});
|
|
17
|
-
case 'device-code':
|
|
18
|
-
return new DeviceCodeCredential({
|
|
19
|
-
authenticationRecord,
|
|
20
|
-
tokenCachePersistenceOptions,
|
|
21
|
-
});
|
|
22
|
-
default:
|
|
23
|
-
throw new Error(`Invalid login method: ${loginMethod}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Gets a credential for the given login method.
|
|
28
|
-
* If the login method is 'azure-cli', it will return an AzureCliCredential.
|
|
29
|
-
* Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.
|
|
30
|
-
* If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.
|
|
31
|
-
*/
|
|
32
|
-
export async function getCredential(loginMethod, cachePath) {
|
|
33
|
-
if (loginMethod == 'azure-cli') {
|
|
34
|
-
return new AzureCliCredential();
|
|
35
|
-
}
|
|
36
|
-
useIdentityPlugin(cachePersistencePlugin);
|
|
37
|
-
let authenticationRecord = getAuthenticationRecord(cachePath);
|
|
38
|
-
const credential = getCredentialInternal(loginMethod, authenticationRecord);
|
|
39
|
-
if (!authenticationRecord) {
|
|
40
|
-
console.warn('Cloudpack requires authentication to access Azure resources.');
|
|
41
|
-
if (loginMethod == 'interactive') {
|
|
42
|
-
console.warn("Prepare to sign in – we're launching a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process.");
|
|
43
|
-
}
|
|
44
|
-
const storageScope = 'https://storage.azure.com/.default';
|
|
45
|
-
authenticationRecord = await credential.authenticate(storageScope);
|
|
46
|
-
const token = await credential.getToken(storageScope);
|
|
47
|
-
// Creating a custom credential with the token from the authentication record.
|
|
48
|
-
// This ensures that we can use the token without having to authenticate again. Otherwise, we may have to authenticate again to get the token which can create concurrency issues.
|
|
49
|
-
const storageCustomCredential = {
|
|
50
|
-
getToken: async () => {
|
|
51
|
-
return Promise.resolve(token);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
if (authenticationRecord) {
|
|
55
|
-
saveAuthenticationRecord(cachePath, authenticationRecord);
|
|
56
|
-
}
|
|
57
|
-
return storageCustomCredential;
|
|
58
|
-
}
|
|
59
|
-
return credential;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=getCredential.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,4BAA4B,GAAiC;IACjE,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF,SAAS,qBAAqB,CAAC,WAAwB,EAAE,oBAA2C;IAClG,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,IAAI,4BAA4B,CAAC;gBACtC,WAAW,EAAE,uBAAuB;gBACpC,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL,KAAK,aAAa;YAChB,OAAO,IAAI,oBAAoB,CAAC;gBAC9B,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAwB,EAAE,SAAiB;IAC7E,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;IAE1C,IAAI,oBAAoB,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAE9D,MAAM,UAAU,GAAG,qBAAqB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAE5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAE7E,IAAI,WAAW,IAAI,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACV,kKAAkK,CACnK,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,oCAAoC,CAAC;QAC1D,oBAAoB,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACnE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEtD,8EAA8E;QAC9E,kLAAkL;QAClL,MAAM,uBAAuB,GAAoB;YAC/C,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;SACF,CAAC;QAEF,IAAI,oBAAoB,EAAE,CAAC;YACzB,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import {\n AzureCliCredential,\n DeviceCodeCredential,\n InteractiveBrowserCredential,\n useIdentityPlugin,\n type AuthenticationRecord,\n type TokenCachePersistenceOptions,\n type TokenCredential,\n} from '@azure/identity';\nimport type { LoginMethod } from '../types/LoginMethod.js';\nimport { cachePersistencePlugin } from '../cache-persistance/cachePersistencePlugin.js';\nimport { getAuthenticationRecord } from './getAuthenticationRecord.js';\nimport { saveAuthenticationRecord } from './saveAuthenticationRecord.js';\n\nconst tokenCachePersistenceOptions: TokenCachePersistenceOptions = {\n enabled: true,\n name: 'cloudpack',\n};\n\nfunction getCredentialInternal(loginMethod: LoginMethod, authenticationRecord?: AuthenticationRecord) {\n switch (loginMethod) {\n case 'interactive':\n return new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n case 'device-code':\n return new DeviceCodeCredential({\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n default:\n throw new Error(`Invalid login method: ${loginMethod}`);\n }\n}\n\n/**\n * Gets a credential for the given login method.\n * If the login method is 'azure-cli', it will return an AzureCliCredential.\n * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.\n * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.\n */\nexport async function getCredential(loginMethod: LoginMethod, cachePath: string) {\n if (loginMethod == 'azure-cli') {\n return new AzureCliCredential();\n }\n\n useIdentityPlugin(cachePersistencePlugin);\n\n let authenticationRecord = getAuthenticationRecord(cachePath);\n\n const credential = getCredentialInternal(loginMethod, authenticationRecord);\n\n if (!authenticationRecord) {\n console.warn('Cloudpack requires authentication to access Azure resources.');\n\n if (loginMethod == 'interactive') {\n console.warn(\n \"Prepare to sign in – we're launching a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process.\",\n );\n }\n\n const storageScope = 'https://storage.azure.com/.default';\n authenticationRecord = await credential.authenticate(storageScope);\n const token = await credential.getToken(storageScope);\n\n // Creating a custom credential with the token from the authentication record.\n // This ensures that we can use the token without having to authenticate again. Otherwise, we may have to authenticate again to get the token which can create concurrency issues.\n const storageCustomCredential: TokenCredential = {\n getToken: async () => {\n return Promise.resolve(token);\n },\n };\n\n if (authenticationRecord) {\n saveAuthenticationRecord(cachePath, authenticationRecord);\n }\n\n return storageCustomCredential;\n }\n\n return credential;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"saveAuthenticationRecord.d.ts","sourceRoot":"","sources":["../../src/authentication/saveAuthenticationRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI3F;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,QAQ3F"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { serializeAuthenticationRecord } from '@azure/identity';
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
|
-
import { getAuthenticationRecordPath } from './getAuthenticationRecordPath.js';
|
|
4
|
-
/**
|
|
5
|
-
* Saves the provided authentication record to Cloudpack's global cache folder.
|
|
6
|
-
* Creates the cache folder if it doesn't exist.
|
|
7
|
-
* @param cachePath - The path to Cloudpack's cache folder.
|
|
8
|
-
* @param authRecord - The authentication record to save.
|
|
9
|
-
*/
|
|
10
|
-
export function saveAuthenticationRecord(cachePath, authRecord) {
|
|
11
|
-
const content = serializeAuthenticationRecord(authRecord);
|
|
12
|
-
if (!existsSync(cachePath)) {
|
|
13
|
-
mkdirSync(cachePath, { recursive: true });
|
|
14
|
-
}
|
|
15
|
-
writeFileSync(getAuthenticationRecordPath(cachePath), content);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=saveAuthenticationRecord.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"saveAuthenticationRecord.js","sourceRoot":"","sources":["../../src/authentication/saveAuthenticationRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAA6B,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAiB,EAAE,UAAgC;IAC1F,MAAM,OAAO,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;IAE1D,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,aAAa,CAAC,2BAA2B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { serializeAuthenticationRecord, type AuthenticationRecord } from '@azure/identity';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { getAuthenticationRecordPath } from './getAuthenticationRecordPath.js';\n\n/**\n * Saves the provided authentication record to Cloudpack's global cache folder.\n * Creates the cache folder if it doesn't exist.\n * @param cachePath - The path to Cloudpack's cache folder.\n * @param authRecord - The authentication record to save.\n */\nexport function saveAuthenticationRecord(cachePath: string, authRecord: AuthenticationRecord) {\n const content = serializeAuthenticationRecord(authRecord);\n\n if (!existsSync(cachePath)) {\n mkdirSync(cachePath, { recursive: true });\n }\n\n writeFileSync(getAuthenticationRecordPath(cachePath), content);\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
|
|
3
|
-
*/
|
|
4
|
-
import type { IdentityPlugin } from '@azure/identity';
|
|
5
|
-
/**
|
|
6
|
-
* A plugin that provides persistent token caching for `@azure/identity`
|
|
7
|
-
* credentials. The plugin API is compatible with `@azure/identity` versions
|
|
8
|
-
* 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
|
|
9
|
-
* function, imported from `@azure/identity`.
|
|
10
|
-
*
|
|
11
|
-
* In order to enable this functionality, you must also pass
|
|
12
|
-
* `tokenCachePersistenceOptions` to your credential constructors with an
|
|
13
|
-
* `enabled` property set to true.
|
|
14
|
-
*
|
|
15
|
-
* Example:
|
|
16
|
-
*
|
|
17
|
-
* ```javascript
|
|
18
|
-
* import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
|
|
19
|
-
* import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
|
|
20
|
-
*
|
|
21
|
-
* // Load the plugin
|
|
22
|
-
* useIdentityPlugin(cachePersistencePlugin);
|
|
23
|
-
*
|
|
24
|
-
* const credential = new DeviceCodeCredential({
|
|
25
|
-
* tokenCachePersistenceOptions: {
|
|
26
|
-
* enabled: true
|
|
27
|
-
* }
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare const cachePersistencePlugin: IdentityPlugin;
|
|
32
|
-
//# sourceMappingURL=cachePersistencePlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cachePersistencePlugin.d.ts","sourceRoot":"","sources":["../../src/cache-persistance/cachePersistencePlugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,eAAO,MAAM,sBAAsB,EAAE,cAGpC,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
|
|
3
|
-
*/
|
|
4
|
-
import { createPersistenceCachePlugin } from './provider.js';
|
|
5
|
-
/**
|
|
6
|
-
* A plugin that provides persistent token caching for `@azure/identity`
|
|
7
|
-
* credentials. The plugin API is compatible with `@azure/identity` versions
|
|
8
|
-
* 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
|
|
9
|
-
* function, imported from `@azure/identity`.
|
|
10
|
-
*
|
|
11
|
-
* In order to enable this functionality, you must also pass
|
|
12
|
-
* `tokenCachePersistenceOptions` to your credential constructors with an
|
|
13
|
-
* `enabled` property set to true.
|
|
14
|
-
*
|
|
15
|
-
* Example:
|
|
16
|
-
*
|
|
17
|
-
* ```javascript
|
|
18
|
-
* import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
|
|
19
|
-
* import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
|
|
20
|
-
*
|
|
21
|
-
* // Load the plugin
|
|
22
|
-
* useIdentityPlugin(cachePersistencePlugin);
|
|
23
|
-
*
|
|
24
|
-
* const credential = new DeviceCodeCredential({
|
|
25
|
-
* tokenCachePersistenceOptions: {
|
|
26
|
-
* enabled: true
|
|
27
|
-
* }
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export const cachePersistencePlugin = (context) => {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
33
|
-
context.cachePluginControl.setPersistence(createPersistenceCachePlugin);
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=cachePersistencePlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cachePersistencePlugin.js","sourceRoot":"","sources":["../../src/cache-persistance/cachePersistencePlugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAmB,CAAC,OAAO,EAAE,EAAE;IAChE,6IAA6I;IAC5I,OAAe,CAAC,kBAAkB,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;AACnF,CAAC,CAAC","sourcesContent":["/**\n * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence\n */\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// import { AzurePluginContext } from '../../identity/src/plugins/provider';\nimport type { IdentityPlugin } from '@azure/identity';\nimport { createPersistenceCachePlugin } from './provider.js';\n\n/**\n * A plugin that provides persistent token caching for `@azure/identity`\n * credentials. The plugin API is compatible with `@azure/identity` versions\n * 2.0.0 and later. Load this plugin using the `useIdentityPlugin`\n * function, imported from `@azure/identity`.\n *\n * In order to enable this functionality, you must also pass\n * `tokenCachePersistenceOptions` to your credential constructors with an\n * `enabled` property set to true.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, DeviceCodeCredential } from \"@azure/identity\";\n * import { cachePersistencePlugin } from \"@azure/identity-cache-persistence\";\n *\n * // Load the plugin\n * useIdentityPlugin(cachePersistencePlugin);\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true\n * }\n * });\n * ```\n */\n\nexport const cachePersistencePlugin: IdentityPlugin = (context) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n (context as any).cachePluginControl.setPersistence(createPersistenceCachePlugin);\n};\n"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
5
|
-
import { type IPersistence as Persistence } from '@azure/msal-node-extensions';
|
|
6
|
-
import type { TokenCachePersistenceOptions } from '@azure/identity';
|
|
7
|
-
/**
|
|
8
|
-
* Dictionary of values that we use as default as we discover, pick and enable the persistence layer.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const defaultMsalValues: {
|
|
12
|
-
tokenCache: {
|
|
13
|
-
name: string;
|
|
14
|
-
directory: string;
|
|
15
|
-
};
|
|
16
|
-
keyRing: {
|
|
17
|
-
label: string;
|
|
18
|
-
schema: string;
|
|
19
|
-
collection: string;
|
|
20
|
-
attributes: {
|
|
21
|
-
MsalClientID: string;
|
|
22
|
-
'Microsoft.Developer.IdentityService': string;
|
|
23
|
-
};
|
|
24
|
-
service: string;
|
|
25
|
-
account: string;
|
|
26
|
-
};
|
|
27
|
-
keyChain: {
|
|
28
|
-
service: string;
|
|
29
|
-
account: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Options that are used by the underlying MSAL cache provider.
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export type MsalPersistenceOptions = Omit<TokenCachePersistenceOptions, 'enabled'>;
|
|
37
|
-
/**
|
|
38
|
-
* A function that returns a persistent token cache instance.
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
type MsalPersistenceFactory = (options?: MsalPersistenceOptions) => Promise<Persistence>;
|
|
42
|
-
/**
|
|
43
|
-
* Set of the platforms we attempt to deliver persistence on.
|
|
44
|
-
*
|
|
45
|
-
* - On Windows we use DPAPI.
|
|
46
|
-
* - On OSX (Darwin), we try to use the system's Keychain, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
|
|
47
|
-
* - On Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
|
|
48
|
-
*
|
|
49
|
-
* Other platforms _are not supported_ at this time.
|
|
50
|
-
*
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
export declare const msalPersistencePlatforms: Partial<Record<NodeJS.Platform, MsalPersistenceFactory>>;
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=platforms.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../../src/cache-persistance/platforms.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAKH,OAAO,EAML,KAAK,YAAY,IAAI,WAAW,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAapE;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;CAwB7B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;AAEnF;;;GAGG;AACH,KAAK,sBAAsB,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAazF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CA2C7F,CAAC"}
|