@ms-cloudpack/remote-cache 0.1.19 → 0.2.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.
Files changed (80) hide show
  1. package/lib/AzureRemoteCacheClient.d.ts +1 -1
  2. package/lib/AzureRemoteCacheClient.d.ts.map +1 -1
  3. package/lib/AzureRemoteCacheClient.js +4 -2
  4. package/lib/AzureRemoteCacheClient.js.map +1 -1
  5. package/lib/authentication/getAuthenticationRecord.d.ts +7 -0
  6. package/lib/authentication/getAuthenticationRecord.d.ts.map +1 -0
  7. package/lib/authentication/getAuthenticationRecord.js +17 -0
  8. package/lib/authentication/getAuthenticationRecord.js.map +1 -0
  9. package/lib/authentication/getAuthenticationRecordPath.d.ts +7 -0
  10. package/lib/authentication/getAuthenticationRecordPath.d.ts.map +1 -0
  11. package/lib/authentication/getAuthenticationRecordPath.js +10 -0
  12. package/lib/authentication/getAuthenticationRecordPath.js.map +1 -0
  13. package/lib/authentication/getCredential.d.ts +9 -2
  14. package/lib/authentication/getCredential.d.ts.map +1 -1
  15. package/lib/authentication/getCredential.js +48 -7
  16. package/lib/authentication/getCredential.js.map +1 -1
  17. package/lib/authentication/saveAuthenticationRecord.d.ts +9 -0
  18. package/lib/authentication/saveAuthenticationRecord.d.ts.map +1 -0
  19. package/lib/authentication/saveAuthenticationRecord.js +17 -0
  20. package/lib/authentication/saveAuthenticationRecord.js.map +1 -0
  21. package/lib/createBlobStorageUrl.d.ts +2 -0
  22. package/lib/createBlobStorageUrl.d.ts.map +1 -0
  23. package/lib/createBlobStorageUrl.js +4 -0
  24. package/lib/createBlobStorageUrl.js.map +1 -0
  25. package/lib/createRemoteCacheClient.d.ts +15 -5
  26. package/lib/createRemoteCacheClient.d.ts.map +1 -1
  27. package/lib/createRemoteCacheClient.js +11 -10
  28. package/lib/createRemoteCacheClient.js.map +1 -1
  29. package/lib/decorators/ReporterDecorator.d.ts +6 -2
  30. package/lib/decorators/ReporterDecorator.d.ts.map +1 -1
  31. package/lib/decorators/ReporterDecorator.js +26 -4
  32. package/lib/decorators/ReporterDecorator.js.map +1 -1
  33. package/lib/getListOfBlobs.d.ts +1 -1
  34. package/lib/getListOfBlobs.d.ts.map +1 -1
  35. package/lib/getListOfBlobs.js +3 -2
  36. package/lib/getListOfBlobs.js.map +1 -1
  37. package/lib/index.d.ts +2 -2
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/tsdoc-metadata.json +1 -1
  41. package/lib/types/LoginMethod.d.ts +2 -0
  42. package/lib/types/LoginMethod.d.ts.map +1 -0
  43. package/lib/types/LoginMethod.js +2 -0
  44. package/lib/types/LoginMethod.js.map +1 -0
  45. package/lib/types/RemoteCacheClientOptions.d.ts +3 -1
  46. package/lib/types/RemoteCacheClientOptions.d.ts.map +1 -1
  47. package/lib/types/RemoteCacheClientOptions.js.map +1 -1
  48. package/package.json +6 -5
  49. package/lib/authentication/KeyRingLocalTokenCache.d.ts +0 -14
  50. package/lib/authentication/KeyRingLocalTokenCache.d.ts.map +0 -1
  51. package/lib/authentication/KeyRingLocalTokenCache.js +0 -37
  52. package/lib/authentication/KeyRingLocalTokenCache.js.map +0 -1
  53. package/lib/authentication/acquireSasToken.d.ts +0 -3
  54. package/lib/authentication/acquireSasToken.d.ts.map +0 -1
  55. package/lib/authentication/acquireSasToken.js +0 -27
  56. package/lib/authentication/acquireSasToken.js.map +0 -1
  57. package/lib/authentication/createBlobStorageUrl.d.ts +0 -2
  58. package/lib/authentication/createBlobStorageUrl.d.ts.map +0 -1
  59. package/lib/authentication/createBlobStorageUrl.js +0 -4
  60. package/lib/authentication/createBlobStorageUrl.js.map +0 -1
  61. package/lib/authentication/getAuthenticatedConnectionString.d.ts +0 -3
  62. package/lib/authentication/getAuthenticatedConnectionString.d.ts.map +0 -1
  63. package/lib/authentication/getAuthenticatedConnectionString.js +0 -21
  64. package/lib/authentication/getAuthenticatedConnectionString.js.map +0 -1
  65. package/lib/authentication/getSasToken.d.ts +0 -12
  66. package/lib/authentication/getSasToken.d.ts.map +0 -1
  67. package/lib/authentication/getSasToken.js +0 -16
  68. package/lib/authentication/getSasToken.js.map +0 -1
  69. package/lib/authentication/isExpired.d.ts +0 -2
  70. package/lib/authentication/isExpired.d.ts.map +0 -1
  71. package/lib/authentication/isExpired.js +0 -10
  72. package/lib/authentication/isExpired.js.map +0 -1
  73. package/lib/types/ConnectionStringOptions.d.ts +0 -12
  74. package/lib/types/ConnectionStringOptions.d.ts.map +0 -1
  75. package/lib/types/ConnectionStringOptions.js +0 -2
  76. package/lib/types/ConnectionStringOptions.js.map +0 -1
  77. package/lib/types/LocalTokenCacheProvider.d.ts +0 -6
  78. package/lib/types/LocalTokenCacheProvider.d.ts.map +0 -1
  79. package/lib/types/LocalTokenCacheProvider.js +0 -2
  80. package/lib/types/LocalTokenCacheProvider.js.map +0 -1
@@ -3,7 +3,7 @@ import type { RemoteCacheClient, RemoteCacheClientOperationOptions, RemoteCacheC
3
3
  export declare class AzureRemoteCacheClient implements RemoteCacheClient {
4
4
  private readonly logger;
5
5
  private readonly config;
6
- constructor({ container, connectionString }: RemoteCacheClientOptions);
6
+ constructor({ container, storageAccount, credential }: RemoteCacheClientOptions);
7
7
  /**
8
8
  * Uploads the folder to the remote cache.
9
9
  * @param folderName - The name of the folder to upload.
@@ -1 +1 @@
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,yCAAyC,EAC1C,MAAM,8BAA8B,CAAC;AAEtC,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAIrB;gBAEU,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,wBAAwB;IAcrE;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,yCAAyC;IAS/F;;;;;OAKG;IACG,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,iCAAiC;CAY7E"}
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,yCAAyC,EAC1C,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,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,yCAAyC;IAS/F;;;;;OAKG;IACG,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,iCAAiC;CAY7E"}
@@ -1,7 +1,8 @@
1
1
  import { makeLogger, put, fetch } from 'backfill/lib/api.js';
2
2
  import { existsSync } from 'fs';
3
+ import { createBlobStorageUrl } from './createBlobStorageUrl.js';
3
4
  export class AzureRemoteCacheClient {
4
- constructor({ container, connectionString }) {
5
+ constructor({ container, storageAccount, credential }) {
5
6
  this.logger = makeLogger('mute', process.stdout, process.stderr);
6
7
  this.config = {
7
8
  incrementalCaching: true,
@@ -9,7 +10,8 @@ export class AzureRemoteCacheClient {
9
10
  cacheStorageConfig: {
10
11
  provider: 'azure-blob',
11
12
  options: {
12
- connectionString,
13
+ connectionString: createBlobStorageUrl(storageAccount),
14
+ credential,
13
15
  container,
14
16
  },
15
17
  },
@@ -1 +1 @@
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;AAOhC,MAAM,OAAO,sBAAsB;IAQjC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAA4B;QAPpD,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;YACvB,kBAAkB,EAAE;gBAClB,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,gBAAgB;oBAChB,SAAS;iBACV;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAA6C;QAC7F,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACrB,OAAO,WAAW,CAAC;SACpB;QAED,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QACtF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAqC;QAC1E,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YACpB,OAAO,eAAe,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,WAAW,CAAC;SACpB;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 RemoteCacheClientDownloadOperationOptions,\n} from './types/RemoteCacheClient.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, connectionString }: RemoteCacheClientOptions) {\n this.config = {\n incrementalCaching: true,\n internalCacheFolder: '', // not used by azure-blob\n cacheStorageConfig: {\n provider: 'azure-blob',\n options: {\n connectionString,\n container,\n },\n },\n };\n }\n\n /**\n * Uploads the folder to the remote cache.\n * @param folderName - The name of the folder 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({ folderName, path, globMatches }: RemoteCacheClientDownloadOperationOptions) {\n if (!existsSync(path)) {\n return 'not-found';\n }\n\n await put(path, folderName, this.logger, { ...this.config, outputGlob: globMatches });\n return 'success';\n }\n\n /**\n * Downloads the folder from the remote cache.\n * @param folderName - The name of the folder 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({ folderName, path }: RemoteCacheClientOperationOptions) {\n if (existsSync(path)) {\n return 'already-exist';\n }\n\n const result = await fetch(path, folderName, this.logger, this.config);\n if (!result) {\n return 'not-found';\n }\n\n return 'success';\n }\n}\n"]}
1
+ {"version":3,"file":"AzureRemoteCacheClient.js","sour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AI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,WAAW,CAAC;SACpB;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 RemoteCacheClientDownloadOperationOptions,\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 folderName - The name of the folder 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({ folderName, path, globMatches }: RemoteCacheClientDownloadOperationOptions) {\n if (!existsSync(path)) {\n return 'not-found';\n }\n\n await put(path, folderName, this.logger, { ...this.config, outputGlob: globMatches });\n return 'success';\n }\n\n /**\n * Downloads the folder from the remote cache.\n * @param folderName - The name of the folder 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({ folderName, path }: RemoteCacheClientOperationOptions) {\n if (existsSync(path)) {\n return 'already-exist';\n }\n\n const result = await fetch(path, folderName, this.logger, this.config);\n if (!result) {\n return 'not-found';\n }\n\n return 'success';\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Retrieves the authentication record from Cloudpack's global cache folder.
3
+ * @param cachePath - The path to Cloudpack's cache folder.
4
+ * @returns - The authentication record if it exists; otherwise, returns `undefined`.
5
+ */
6
+ export declare function getAuthenticationRecord(cachePath: string): import("@azure/identity").AuthenticationRecord | undefined;
7
+ //# sourceMappingURL=getAuthenticationRecord.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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;QACzB,OAAO,SAAS,CAAC;KAClB;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"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Constructs and returns the full path to the authentication record file within the specified cache folder.
3
+ * @param cachePath - The path to Cloudpack's cache folder.
4
+ * @returns - The full path to the authentication record file.
5
+ */
6
+ export declare function getAuthenticationRecordPath(cachePath: string): string;
7
+ //# sourceMappingURL=getAuthenticationRecordPath.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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,3 +1,10 @@
1
- import { AzureCliCredential, InteractiveBrowserCredential } from '@azure/identity';
2
- export declare function getCredential(isInteractiveLogin: boolean): InteractiveBrowserCredential | AzureCliCredential;
1
+ import { AzureCliCredential, DeviceCodeCredential, InteractiveBrowserCredential } from '@azure/identity';
2
+ import type { LoginMethod } from '../types/LoginMethod.js';
3
+ /**
4
+ * Gets a credential for the given login method.
5
+ * If the login method is 'azure-cli', it will return an AzureCliCredential.
6
+ * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.
7
+ * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.
8
+ */
9
+ export declare function getCredential(loginMethod: LoginMethod, cachePath: string): Promise<InteractiveBrowserCredential | DeviceCodeCredential | AzureCliCredential>;
3
10
  //# sourceMappingURL=getCredential.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCredential.d.ts","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEnF,wBAAgB,aAAa,CAAC,kBAAkB,EAAE,OAAO,qDAOxD"}
1
+ {"version":3,"file":"getCredential.d.ts","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAI7B,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,qFA4B9E"}
@@ -1,10 +1,51 @@
1
- import { AzureCliCredential, InteractiveBrowserCredential } from '@azure/identity';
2
- export function getCredential(isInteractiveLogin) {
3
- if (isInteractiveLogin) {
4
- return new InteractiveBrowserCredential({
5
- redirectUri: 'http://localhost:1337',
6
- });
1
+ import { AzureCliCredential, DeviceCodeCredential, InteractiveBrowserCredential, useIdentityPlugin, } from '@azure/identity';
2
+ import { cachePersistencePlugin } from '@azure/identity-cache-persistence';
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}`);
7
24
  }
8
- return new AzureCliCredential();
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
+ authenticationRecord = await credential.authenticate('https://storage.azure.com/.default');
45
+ if (authenticationRecord) {
46
+ saveAuthenticationRecord(cachePath, authenticationRecord);
47
+ }
48
+ }
49
+ return credential;
9
50
  }
10
51
  //# sourceMappingURL=getCredential.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEnF,MAAM,UAAU,aAAa,CAAC,kBAA2B;IACvD,IAAI,kBAAkB,EAAE;QACtB,OAAO,IAAI,4BAA4B,CAAC;YACtC,WAAW,EAAE,uBAAuB;SACrC,CAAC,CAAC;KACJ;IACD,OAAO,IAAI,kBAAkB,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { AzureCliCredential, InteractiveBrowserCredential } from '@azure/identity';\n\nexport function getCredential(isInteractiveLogin: boolean) {\n if (isInteractiveLogin) {\n return new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n });\n }\n return new AzureCliCredential();\n}\n"]}
1
+ {"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB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C,YAAY,CAAC,oCAAoC,CAAC,CAAC;QAE3F,IAAI,oBAAoB,EAAE;YACxB,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;SAC3D;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import {\n AzureCliCredential,\n DeviceCodeCredential,\n InteractiveBrowserCredential,\n useIdentityPlugin,\n type AuthenticationRecord,\n type TokenCachePersistenceOptions,\n} from '@azure/identity';\nimport type { LoginMethod } from '../types/LoginMethod.js';\nimport { cachePersistencePlugin } from '@azure/identity-cache-persistence';\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 authenticationRecord = await credential.authenticate('https://storage.azure.com/.default');\n\n if (authenticationRecord) {\n saveAuthenticationRecord(cachePath, authenticationRecord);\n }\n }\n\n return credential;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { type AuthenticationRecord } from '@azure/identity';
2
+ /**
3
+ * Saves the provided authentication record to Cloudpack's global cache folder.
4
+ * Creates the cache folder if it doesn't exist.
5
+ * @param cachePath - The path to Cloudpack's cache folder.
6
+ * @param authRecord - The authentication record to save.
7
+ */
8
+ export declare function saveAuthenticationRecord(cachePath: string, authRecord: AuthenticationRecord): void;
9
+ //# sourceMappingURL=saveAuthenticationRecord.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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;QAC1B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAC3C;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"]}
@@ -0,0 +1,2 @@
1
+ export declare function createBlobStorageUrl(storageAccount: string): string;
2
+ //# sourceMappingURL=createBlobStorageUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBlobStorageUrl.d.ts","sourceRoot":"","sources":["../src/createBlobStorageUrl.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,UAE1D"}
@@ -0,0 +1,4 @@
1
+ export function createBlobStorageUrl(storageAccount) {
2
+ return `https://${storageAccount}.blob.core.windows.net`;
3
+ }
4
+ //# sourceMappingURL=createBlobStorageUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBlobStorageUrl.js","sourceRoot":"","sources":["../src/createBlobStorageUrl.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,cAAsB;IACzD,OAAO,WAAW,cAAc,wBAAwB,CAAC;AAC3D,CAAC","sourcesContent":["export function createBlobStorageUrl(storageAccount: string) {\n return `https://${storageAccount}.blob.core.windows.net`;\n}\n"]}
@@ -1,8 +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
- export declare function createRemoteCacheClient(options: {
5
- connectionStringOptions: ConnectionStringOptions;
6
- reporter: TaskReporter;
7
- }): Promise<RemoteCacheClient>;
3
+ import type { TelemetryClient } from '@ms-cloudpack/telemetry';
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
+ };
12
+ context: {
13
+ reporter: TaskReporter;
14
+ telemetryClient: TelemetryClient;
15
+ };
16
+ }
17
+ export declare function createRemoteCacheClient(params: CreateRemoteCacheClientParams): Promise<RemoteCacheClient>;
8
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;AAMhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKtE,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,QAAQ,EAAE,YAAY,CAAC;CACxB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuB7B"}
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,26 +1,27 @@
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 './retry/RetryManager.js';
9
- export async function createRemoteCacheClient(options) {
10
- const { connectionStringOptions, reporter } = options;
11
- const { container } = connectionStringOptions;
12
- const connectionString = await getAuthenticatedConnectionString(connectionStringOptions);
13
- const cacheClientOptions = {
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
- connectionString,
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(cacheClientOptions),
21
- getList: () => getListOfBlobs(cacheClientOptions),
21
+ cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
22
+ getList: () => getListOfBlobs(remoteCacheClientOptions),
22
23
  }),
23
- }), reporter);
24
+ }), context);
24
25
  return client;
25
26
  }
26
27
  //# sourceMappingURL=createRemoteCacheClient.js.map
@@ -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,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAG7C;IACC,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC;IAE9C,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAAC,uBAAuB,CAAC,CAAC;IAEzF,MAAM,kBAAkB,GAAG;QACzB,SAAS;QACT,gBAAgB;KACjB,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,kBAAkB,CAAC;YAC3D,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,kBAAkB,CAAC;SAClD,CAAC;KACH,CAAC,EACF,QAAQ,CACT,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { AzureRemoteCacheClient } from './AzureRemoteCacheClient.js';\nimport { getAuthenticatedConnectionString } from './authentication/getAuthenticatedConnectionString.js';\nimport { InMemoryDecorator } from './decorators/InMemoryDecorator.js';\nimport { ReporterDecorator } from './decorators/ReporterDecorator.js';\nimport { getListOfBlobs } from './getListOfBlobs.js';\nimport type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';\nimport type { RemoteCacheClient } from './types/RemoteCacheClient.js';\nimport { RetryDecorator } from './decorators/RetryDecorator.js';\nimport { blockListIsInvalidRetryPolicy } from './retry/blockListIsInvalidRetryPolicy.js';\nimport { RetryManager } from './retry/RetryManager.js';\n\nexport async function createRemoteCacheClient(options: {\n connectionStringOptions: ConnectionStringOptions;\n reporter: TaskReporter;\n}): Promise<RemoteCacheClient> {\n const { connectionStringOptions, reporter } = options;\n const { container } = connectionStringOptions;\n\n const connectionString = await getAuthenticatedConnectionString(connectionStringOptions);\n\n const cacheClientOptions = {\n container,\n connectionString,\n };\n\n const client = new ReporterDecorator(\n new RetryDecorator({\n retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),\n cacheClient: new InMemoryDecorator({\n cacheClient: new AzureRemoteCacheClient(cacheClientOptions),\n getList: () => getListOfBlobs(cacheClientOptions),\n }),\n }),\n reporter,\n );\n\n return client;\n}\n"]}
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,yBAAyB,CAAC;AAEvD,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 './retry/RetryManager.js';\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"]}
@@ -1,9 +1,13 @@
1
1
  import { type TaskReporter } from '@ms-cloudpack/task-reporter';
2
2
  import type { RemoteCacheClient, RemoteCacheClientDownloadOperationOptions, RemoteCacheClientOperationOptions, RemoteCacheClientOperationResult } from '../types/RemoteCacheClient.js';
3
+ import type { TelemetryClient } from '@ms-cloudpack/telemetry';
3
4
  export declare class ReporterDecorator implements RemoteCacheClient {
4
5
  private readonly client;
5
- private readonly reporter;
6
- constructor(client: RemoteCacheClient, reporter: TaskReporter);
6
+ private readonly context;
7
+ constructor(client: RemoteCacheClient, context: {
8
+ reporter: TaskReporter;
9
+ telemetryClient: TelemetryClient;
10
+ });
7
11
  private buildFailureMessage;
8
12
  uploadFolder(options: RemoteCacheClientDownloadOperationOptions): Promise<RemoteCacheClientOperationResult>;
9
13
  downloadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"ReporterDecorator.d.ts","sourceRoot":"","sources":["../../src/decorators/ReporterDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EACV,iBAAiB,EACjB,yCAAyC,EACzC,iCAAiC,EACjC,gCAAgC,EACjC,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,iBAAkB,YAAW,iBAAiB;IAEvD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,YAAY;IAGzC,OAAO,CAAC,mBAAmB;IAWrB,YAAY,CAAC,OAAO,EAAE,yCAAyC;IA0C/D,cAAc,CAAC,OAAO,EAAE,iCAAiC;CAyChE"}
1
+ {"version":3,"file":"ReporterDecorator.d.ts","sourceRoot":"","sources":["../../src/decorators/ReporterDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EACV,iBAAiB,EACjB,yCAAyC,EACzC,iCAAiC,EACjC,gCAAgC,EACjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAuB/D,qBAAa,iBAAkB,YAAW,iBAAiB;IAEvD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE;QACxB,QAAQ,EAAE,YAAY,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;KAClC;IAGH,OAAO,CAAC,mBAAmB;IAWrB,YAAY,CAAC,OAAO,EAAE,yCAAyC;IA6C/D,cAAc,CAAC,OAAO,EAAE,iCAAiC;CA6ChE"}
@@ -1,8 +1,24 @@
1
1
  import { bulletedList } from '@ms-cloudpack/task-reporter';
2
+ import { RestError } from '@azure/storage-blob';
3
+ let isAuthErrorReported = false;
4
+ /**
5
+ * Reports an error to the telemetry client. If the error is an auth error, it will be reported only once.
6
+ * @param telemetryClient - The telemetry client to report the error to.
7
+ * @param error - The error to report.
8
+ */
9
+ function reportError(telemetryClient, error) {
10
+ const isAuthError = error instanceof RestError && error.statusCode === 403;
11
+ if (isAuthError && isAuthErrorReported) {
12
+ return; // No need to proceed if auth error is already reported
13
+ }
14
+ telemetryClient.rootSpan.recordException(error);
15
+ // Set isAuthErrorReported only if it's an auth error
16
+ isAuthErrorReported = isAuthError;
17
+ }
2
18
  export class ReporterDecorator {
3
- constructor(client, reporter) {
19
+ constructor(client, context) {
4
20
  this.client = client;
5
- this.reporter = reporter;
21
+ this.context = context;
6
22
  }
7
23
  buildFailureMessage({ folderName, friendlyName, path }, error) {
8
24
  const list = bulletedList([
@@ -15,12 +31,15 @@ export class ReporterDecorator {
15
31
  }
16
32
  async uploadFolder(options) {
17
33
  const { folderName, path, friendlyName } = options;
18
- const task = this.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);
34
+ const task = this.context.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);
19
35
  let uploadResult;
20
36
  try {
21
37
  uploadResult = await this.client.uploadFolder(options);
22
38
  }
23
39
  catch (e) {
40
+ if (e instanceof Error) {
41
+ reportError(this.context.telemetryClient, e);
42
+ }
24
43
  task.complete({
25
44
  status: 'fail',
26
45
  message: this.buildFailureMessage(options, e),
@@ -53,12 +72,15 @@ export class ReporterDecorator {
53
72
  }
54
73
  async downloadFolder(options) {
55
74
  const { folderName, path, friendlyName } = options;
56
- const task = this.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);
75
+ const task = this.context.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);
57
76
  let downloadResult;
58
77
  try {
59
78
  downloadResult = await this.client.downloadFolder(options);
60
79
  }
61
80
  catch (e) {
81
+ if (e instanceof Error) {
82
+ reportError(this.context.telemetryClient, e);
83
+ }
62
84
  task.complete({
63
85
  status: 'fail',
64
86
  message: this.buildFailureMessage(options, e),
@@ -1 +1 @@
1
- {"version":3,"file":"ReporterDecorator.js","sourceRoot":"","sources":["../../src/decorators/ReporterDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAQ9E,MAAM,OAAO,iBAAiB;IAC5B,YACmB,MAAyB,EACzB,QAAsB;QADtB,WAAM,GAAN,MAAM,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAc;IACtC,CAAC;IAEI,mBAAmB,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAqC,EAAE,KAAc;QAC/G,MAAM,IAAI,GAAG,YAAY,CAAC;YACxB,eAAe,UAAU,EAAE;YAC3B,SAAS,IAAI,EAAE;YACf,SAAS,YAAY,EAAE;YACvB,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CA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\n RemoteCacheClientDownloadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from '../types/RemoteCacheClient.js';\n\nexport class ReporterDecorator implements RemoteCacheClient {\n constructor(\n private readonly client: RemoteCacheClient,\n private readonly reporter: TaskReporter,\n ) {}\n\n private buildFailureMessage({ folderName, friendlyName, path }: RemoteCacheClientOperationOptions, error: unknown) {\n const list = bulletedList([\n `FolderName: ${folderName}`,\n `Path: ${path}`,\n `Name: ${friendlyName}`,\n `Error: ${error instanceof Error ? error.message : '<Unknown>'}`,\n ]);\n\n return `\\n${list}`;\n }\n\n async uploadFolder(options: RemoteCacheClientDownloadOperationOptions) {\n const { folderName, path, friendlyName } = options;\n const task = this.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);\n\n let uploadResult: RemoteCacheClientOperationResult;\n\n try {\n uploadResult = await this.client.uploadFolder(options);\n } catch (e) {\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n switch (uploadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the local cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the remote cache.`,\n });\n break;\n default:\n throw new Error(`Unknown upload result: ${uploadResult}`);\n }\n\n return uploadResult;\n }\n\n async downloadFolder(options: RemoteCacheClientOperationOptions) {\n const { folderName, path, friendlyName } = options;\n const task = this.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);\n\n let downloadResult: RemoteCacheClientOperationResult;\n\n try {\n downloadResult = await this.client.downloadFolder(options);\n } catch (e) {\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n switch (downloadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the remote cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the local cache.`,\n });\n break;\n default:\n throw new Error(`Unknown download result: ${downloadResult}`);\n }\n\n return downloadResult;\n }\n}\n"]}
1
+ {"version":3,"file":"ReporterDecorator.js","sourceRoot":"","sources":["../../src/decorators/ReporterDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAQ9E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,IAAI,mBAAmB,GAAY,KAAK,CAAC;AAEzC;;;;GAIG;AACH,SAAS,WAAW,CAAC,eAAgC,EAAE,KAAY;IACjE,MAAM,WAAW,GAAG,KAAK,YAAY,SAAS,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,CAAC;IAE3E,IAAI,WAAW,IAAI,mBAAmB,EAAE;QACtC,OAAO,CAAC,uDAAuD;KAChE;IAED,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAEhD,qDAAqD;IACrD,mBAAmB,GAAG,WAAW,CAAC;AACpC,CAAC;AAED,MAAM,OAAO,iBAAiB;IAC5B,YACmB,MAAyB,EACzB,OAGhB;QAJgB,WAAM,GAAN,MAAM,CAAmB;QACzB,YAAO,GAAP,OAAO,CAGvB;IACA,CAAC;IAEI,mBAAmB,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAqC,EAAE,KAAc;QAC/G,MAAM,IAAI,GAAG,YAAY,CAAC;YACxB,eAAe,UAAU,EAAE;YAC3B,SAAS,IAAI,EAAE;YACf,SAAS,YAAY,EAAE;YACvB,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE;SACjE,CAAC,CAAC;QAEH,OAAO,KAAK,IAAI,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MAAM,IAAI,KAAK,CAAC,4BAA4B,cAAc,EAAE,CAAC,CAAC;SACjE;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { bulletedList, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type {\n RemoteCacheClient,\n RemoteCacheClientDownloadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from '../types/RemoteCacheClient.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { RestError } from '@azure/storage-blob';\n\nlet isAuthErrorReported: boolean = false;\n\n/**\n * Reports an error to the telemetry client. If the error is an auth error, it will be reported only once.\n * @param telemetryClient - The telemetry client to report the error to.\n * @param error - The error to report.\n */\nfunction reportError(telemetryClient: TelemetryClient, error: Error) {\n const isAuthError = error instanceof RestError && error.statusCode === 403;\n\n if (isAuthError && isAuthErrorReported) {\n return; // No need to proceed if auth error is already reported\n }\n\n telemetryClient.rootSpan.recordException(error);\n\n // Set isAuthErrorReported only if it's an auth error\n isAuthErrorReported = isAuthError;\n}\n\nexport class ReporterDecorator implements RemoteCacheClient {\n constructor(\n private readonly client: RemoteCacheClient,\n private readonly context: {\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n },\n ) {}\n\n private buildFailureMessage({ folderName, friendlyName, path }: RemoteCacheClientOperationOptions, error: unknown) {\n const list = bulletedList([\n `FolderName: ${folderName}`,\n `Path: ${path}`,\n `Name: ${friendlyName}`,\n `Error: ${error instanceof Error ? error.message : '<Unknown>'}`,\n ]);\n\n return `\\n${list}`;\n }\n\n async uploadFolder(options: RemoteCacheClientDownloadOperationOptions) {\n const { folderName, path, friendlyName } = options;\n const task = this.context.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);\n\n let uploadResult: RemoteCacheClientOperationResult;\n\n try {\n uploadResult = await this.client.uploadFolder(options);\n } catch (e) {\n if (e instanceof Error) {\n reportError(this.context.telemetryClient, e);\n }\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n switch (uploadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the local cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the remote cache.`,\n });\n break;\n default:\n throw new Error(`Unknown upload result: ${uploadResult}`);\n }\n\n return uploadResult;\n }\n\n async downloadFolder(options: RemoteCacheClientOperationOptions) {\n const { folderName, path, friendlyName } = options;\n const task = this.context.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);\n\n let downloadResult: RemoteCacheClientOperationResult;\n\n try {\n downloadResult = await this.client.downloadFolder(options);\n } catch (e) {\n if (e instanceof Error) {\n reportError(this.context.telemetryClient, e);\n }\n\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n switch (downloadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the remote cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the local cache.`,\n });\n break;\n default:\n throw new Error(`Unknown download result: ${downloadResult}`);\n }\n\n return downloadResult;\n }\n}\n"]}
@@ -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, connectionString }: RemoteCacheClientOptions): Promise<Set<string>>;
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":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAGpF;;GAEG;AACH,wBAAsB,cAAc,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,wBAAwB,wBAQ7F"}
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"}
@@ -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, connectionString }) {
6
- const blobStorageClient = BlobServiceClient.fromConnectionString(connectionString);
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":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAA4B;IAC5F,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACnF,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 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, connectionString }: RemoteCacheClientOptions) {\n const blobStorageClient = BlobServiceClient.fromConnectionString(connectionString);\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"]}
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,5 +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';
3
+ export type { LoginMethod } from './types/LoginMethod.js';
4
4
  export type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,YAAY,EACV,iBAAiB,EACjB,yCAAyC,EACzC,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,YAAY,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,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,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { createRemoteCacheClient } from './createRemoteCacheClient.js';\n\nexport type {\n RemoteCacheClient,\n RemoteCacheClientDownloadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from './types/RemoteCacheClient.js';\nexport type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';\nexport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\n"]}
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"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.1"
8
+ "packageVersion": "7.38.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,2 @@
1
+ export type LoginMethod = 'interactive' | 'azure-cli' | 'device-code';
2
+ //# sourceMappingURL=LoginMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginMethod.d.ts","sourceRoot":"","sources":["../../src/types/LoginMethod.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LoginMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginMethod.js","sourceRoot":"","sources":["../../src/types/LoginMethod.ts"],"names":[],"mappings":"","sourcesContent":["export type LoginMethod = 'interactive' | 'azure-cli' | 'device-code';\n"]}
@@ -1,5 +1,7 @@
1
+ import type { TokenCredential } from '@azure/identity';
1
2
  export interface RemoteCacheClientOptions {
2
- connectionString: string;
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,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB"}
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":["export interface RemoteCacheClientOptions {\n connectionString: string;\n container: string;\n}\n"]}
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.1.19",
3
+ "version": "0.2.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,11 +31,12 @@
31
31
  "lib/**/!(*.test.*)"
32
32
  ],
33
33
  "dependencies": {
34
- "@ms-cloudpack/task-reporter": "^0.10.2",
35
34
  "@azure/identity": "^3.4.0",
35
+ "@azure/identity-cache-persistence": "^1.0.0",
36
36
  "@azure/storage-blob": "^12.17.0",
37
- "@napi-rs/keyring": "^1.1.3",
38
- "backfill": "^6.2.1",
39
- "backfill-config": "^6.4.1"
37
+ "@ms-cloudpack/task-reporter": "^0.10.2",
38
+ "@ms-cloudpack/telemetry": "^0.4.4",
39
+ "backfill": "^6.2.2",
40
+ "backfill-config": "^6.4.2"
40
41
  }
41
42
  }
@@ -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, isInteractiveLogin, 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,kBAAkB,EAClB,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, isInteractiveLogin, tokenExpiresInMs, }) {
5
- const credential = getCredential(isInteractiveLogin);
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":["../../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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 isInteractiveLogin,\n tokenExpiresInMs,\n}: ConnectionStringOptions) {\n const credential = getCredential(isInteractiveLogin);\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,2 +0,0 @@
1
- export declare function createBlobStorageUrl(account: string): string;
2
- //# sourceMappingURL=createBlobStorageUrl.d.ts.map
@@ -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,4 +0,0 @@
1
- export function createBlobStorageUrl(account) {
2
- return `https://${account}.blob.core.windows.net`;
3
- }
4
- //# sourceMappingURL=createBlobStorageUrl.js.map
@@ -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,3 +0,0 @@
1
- import type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';
2
- export declare function getAuthenticatedConnectionString(connectionStringOptions: ConnectionStringOptions): Promise<string>;
3
- //# sourceMappingURL=getAuthenticatedConnectionString.d.ts.map
@@ -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,mBAUtG"}
@@ -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.isInteractiveLogin
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,GAAG,uBAAuB,CAAC,kBAAkB;QAC3D,CAAC,CAAC,MAAM,yBAAyB,CAAC,uBAAuB,CAAC;QAC1D,CAAC,CAAC,SAAS,CAAC;IAEd,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 = connectionStringOptions.isInteractiveLogin\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,2 +0,0 @@
1
- export declare function isExpired(sasToken: string): boolean;
2
- //# sourceMappingURL=isExpired.d.ts.map
@@ -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,10 +0,0 @@
1
- export function isExpired(sasToken) {
2
- const se = new URLSearchParams(sasToken).get('se');
3
- if (!se) {
4
- return true;
5
- }
6
- const expiry = new Date(se);
7
- const now = new Date();
8
- return expiry < now;
9
- }
10
- //# sourceMappingURL=isExpired.js.map
@@ -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,12 +0,0 @@
1
- export interface ConnectionStringOptions {
2
- storageAccount: string;
3
- container: string;
4
- permissions: {
5
- read: boolean;
6
- write: boolean;
7
- list: boolean;
8
- };
9
- tokenExpiresInMs?: number;
10
- isInteractiveLogin: boolean;
11
- }
12
- //# sourceMappingURL=ConnectionStringOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConnectionStringOptions.d.ts","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"AAAA,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,kBAAkB,EAAE,OAAO,CAAC;CAC7B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ConnectionStringOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConnectionStringOptions.js","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConnectionStringOptions {\n storageAccount: string;\n container: string;\n permissions: {\n read: boolean;\n write: boolean;\n list: boolean;\n };\n tokenExpiresInMs?: number;\n isInteractiveLogin: boolean;\n}\n"]}
@@ -1,6 +0,0 @@
1
- export interface LocalTokenCacheProvider {
2
- get(): string | undefined;
3
- set(value: string): void;
4
- delete(): void;
5
- }
6
- //# sourceMappingURL=LocalTokenCacheProvider.d.ts.map
@@ -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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LocalTokenCacheProvider.js.map
@@ -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"]}