@fluidframework/tool-utils 2.0.2 → 2.1.0-276326

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 (70) hide show
  1. package/.eslintrc.cjs +2 -15
  2. package/api-report/tool-utils.alpha.api.md +0 -4
  3. package/api-report/tool-utils.beta.api.md +0 -4
  4. package/api-report/tool-utils.public.api.md +0 -4
  5. package/dist/debug.d.ts.map +1 -1
  6. package/dist/debug.js +2 -0
  7. package/dist/debug.js.map +1 -1
  8. package/dist/{fluidToolRC.d.ts → fluidToolRc.d.ts} +7 -9
  9. package/dist/fluidToolRc.d.ts.map +1 -0
  10. package/dist/{fluidToolRC.js → fluidToolRc.js} +16 -11
  11. package/dist/fluidToolRc.js.map +1 -0
  12. package/dist/httpHelpers.d.ts +2 -2
  13. package/dist/httpHelpers.d.ts.map +1 -1
  14. package/dist/httpHelpers.js +16 -4
  15. package/dist/httpHelpers.js.map +1 -1
  16. package/dist/index.d.ts +6 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +4 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/odspTokenManager.d.ts +2 -2
  21. package/dist/odspTokenManager.d.ts.map +1 -1
  22. package/dist/odspTokenManager.js +18 -11
  23. package/dist/odspTokenManager.js.map +1 -1
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.d.ts.map +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/snapshotNormalizer.d.ts +1 -1
  29. package/dist/snapshotNormalizer.d.ts.map +1 -1
  30. package/dist/snapshotNormalizer.js +24 -12
  31. package/dist/snapshotNormalizer.js.map +1 -1
  32. package/lib/debug.d.ts.map +1 -1
  33. package/lib/debug.js +2 -0
  34. package/lib/debug.js.map +1 -1
  35. package/lib/{fluidToolRC.d.ts → fluidToolRc.d.ts} +7 -9
  36. package/lib/fluidToolRc.d.ts.map +1 -0
  37. package/lib/{fluidToolRC.js → fluidToolRc.js} +12 -7
  38. package/lib/fluidToolRc.js.map +1 -0
  39. package/lib/httpHelpers.d.ts +2 -2
  40. package/lib/httpHelpers.d.ts.map +1 -1
  41. package/lib/httpHelpers.js +15 -3
  42. package/lib/httpHelpers.js.map +1 -1
  43. package/lib/index.d.ts +6 -3
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +2 -2
  46. package/lib/index.js.map +1 -1
  47. package/lib/odspTokenManager.d.ts +2 -2
  48. package/lib/odspTokenManager.d.ts.map +1 -1
  49. package/lib/odspTokenManager.js +15 -8
  50. package/lib/odspTokenManager.js.map +1 -1
  51. package/lib/packageVersion.d.ts +1 -1
  52. package/lib/packageVersion.d.ts.map +1 -1
  53. package/lib/packageVersion.js +1 -1
  54. package/lib/packageVersion.js.map +1 -1
  55. package/lib/snapshotNormalizer.d.ts +1 -1
  56. package/lib/snapshotNormalizer.d.ts.map +1 -1
  57. package/lib/snapshotNormalizer.js +24 -12
  58. package/lib/snapshotNormalizer.js.map +1 -1
  59. package/package.json +11 -10
  60. package/src/debug.ts +2 -0
  61. package/src/{fluidToolRC.ts → fluidToolRc.ts} +20 -14
  62. package/src/httpHelpers.ts +27 -5
  63. package/src/index.ts +5 -8
  64. package/src/odspTokenManager.ts +41 -23
  65. package/src/packageVersion.ts +1 -1
  66. package/src/snapshotNormalizer.ts +40 -19
  67. package/dist/fluidToolRC.d.ts.map +0 -1
  68. package/dist/fluidToolRC.js.map +0 -1
  69. package/lib/fluidToolRC.d.ts.map +0 -1
  70. package/lib/fluidToolRC.js.map +0 -1
@@ -4,10 +4,12 @@
4
4
  */
5
5
 
6
6
  import { unreachableCase } from "@fluidframework/core-utils/internal";
7
- import {
7
+ import type {
8
8
  IPublicClientConfig,
9
9
  IOdspTokens,
10
10
  TokenRequestCredentials,
11
+ } from "@fluidframework/odsp-doclib-utils/internal";
12
+ import {
11
13
  fetchTokens,
12
14
  getLoginPageUrl,
13
15
  getOdspScope,
@@ -18,18 +20,22 @@ import { Mutex } from "async-mutex";
18
20
  import { jwtDecode } from "jwt-decode";
19
21
 
20
22
  import { debug } from "./debug.js";
21
- import { IAsyncCache, loadRC, lockRC, saveRC } from "./fluidToolRC.js";
23
+ import type { IAsyncCache, IResources } from "./fluidToolRc.js";
24
+ import { loadRC, lockRC, saveRC } from "./fluidToolRc.js";
22
25
  import { endResponse, serverListenAndHandle } from "./httpHelpers.js";
23
26
 
24
27
  const odspAuthRedirectPort = 7000;
25
28
  const odspAuthRedirectOrigin = `http://localhost:${odspAuthRedirectPort}`;
26
29
  const odspAuthRedirectUri = new URL("/auth/callback", odspAuthRedirectOrigin).href;
27
30
 
31
+ // TODO: Add documentation
32
+ // eslint-disable-next-line jsdoc/require-description
28
33
  /**
29
34
  * @internal
30
35
  */
31
36
  export const getMicrosoftConfiguration = (): IPublicClientConfig => ({
32
- get clientId() {
37
+ get clientId(): string {
38
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
33
39
  if (!process.env.login__microsoft__clientId) {
34
40
  throw new Error("Client ID environment variable not set: login__microsoft__clientId.");
35
41
  }
@@ -60,18 +66,18 @@ export interface IOdspTokenManagerCacheKey {
60
66
  readonly userOrServer: string;
61
67
  }
62
68
 
63
- const isValidToken = (token: string) => {
69
+ const isValidToken = (token: string): boolean => {
64
70
  // Return false for undefined or empty tokens.
65
71
  if (!token || token.length === 0) {
66
72
  return false;
67
73
  }
68
74
 
69
- const decodedToken = jwtDecode<any>(token);
75
+ const decodedToken = jwtDecode<{ exp: number }>(token);
70
76
  // Give it a 60s buffer
71
- return decodedToken.exp - 60 >= new Date().getTime() / 1000;
77
+ return decodedToken.exp - 60 >= Date.now() / 1000;
72
78
  };
73
79
 
74
- const cacheKeyToString = (key: IOdspTokenManagerCacheKey) => {
80
+ const cacheKeyToString = (key: IOdspTokenManagerCacheKey): string => {
75
81
  return `${key.userOrServer}${key.isPush ? "[Push]" : ""}`;
76
82
  };
77
83
 
@@ -82,11 +88,14 @@ export class OdspTokenManager {
82
88
  private readonly storageCache = new Map<string, IOdspTokens>();
83
89
  private readonly pushCache = new Map<string, IOdspTokens>();
84
90
  private readonly cacheMutex = new Mutex();
85
- constructor(
91
+ public constructor(
86
92
  private readonly tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>,
87
93
  ) {}
88
94
 
89
- public async updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens) {
95
+ public async updateTokensCache(
96
+ key: IOdspTokenManagerCacheKey,
97
+ value: IOdspTokens,
98
+ ): Promise<void> {
90
99
  await this.cacheMutex.runExclusive(async () => {
91
100
  await this.updateTokensCacheWithoutLock(key, value);
92
101
  });
@@ -95,7 +104,7 @@ export class OdspTokenManager {
95
104
  private async updateTokensCacheWithoutLock(
96
105
  key: IOdspTokenManagerCacheKey,
97
106
  value: IOdspTokens,
98
- ) {
107
+ ): Promise<void> {
99
108
  debug(`${cacheKeyToString(key)}: Saving tokens`);
100
109
  const memoryCache = key.isPush ? this.pushCache : this.storageCache;
101
110
  memoryCache.set(key.userOrServer, value);
@@ -124,7 +133,9 @@ export class OdspTokenManager {
124
133
  return this.getTokens(true, server, clientConfig, tokenConfig, forceRefresh, forceReauth);
125
134
  }
126
135
 
127
- private async getTokenFromCache(cacheKey: IOdspTokenManagerCacheKey) {
136
+ private async getTokenFromCache(
137
+ cacheKey: IOdspTokenManagerCacheKey,
138
+ ): Promise<IOdspTokens | undefined> {
128
139
  const memoryCache = cacheKey.isPush ? this.pushCache : this.storageCache;
129
140
  const memoryToken = memoryCache.get(cacheKey.userOrServer);
130
141
  if (memoryToken) {
@@ -159,7 +170,7 @@ export class OdspTokenManager {
159
170
  forceRefresh: boolean,
160
171
  forceReauth: boolean,
161
172
  ): Promise<IOdspTokens> {
162
- const invokeGetTokensCore = async () => {
173
+ const invokeGetTokensCore = async (): Promise<IOdspTokens> => {
163
174
  // Don't solely rely on tokenCache lock, ensure serialized execution of
164
175
  // cache update to avoid multiple fetch.
165
176
  return this.cacheMutex.runExclusive(async () => {
@@ -198,8 +209,8 @@ export class OdspTokenManager {
198
209
  server: string,
199
210
  clientConfig: IPublicClientConfig,
200
211
  tokenConfig: OdspTokenConfig,
201
- forceRefresh,
202
- forceReauth,
212
+ forceRefresh: boolean,
213
+ forceReauth: boolean,
203
214
  ): Promise<IOdspTokens> {
204
215
  const scope = isPush ? pushScope : getOdspScope(server);
205
216
  const cacheKey = OdspTokenManager.getCacheKey(isPush, tokenConfig, server);
@@ -229,7 +240,7 @@ export class OdspTokenManager {
229
240
  }
230
241
 
231
242
  switch (tokenConfig.type) {
232
- case "password":
243
+ case "password": {
233
244
  tokens = await this.acquireTokensWithPassword(
234
245
  server,
235
246
  scope,
@@ -238,7 +249,8 @@ export class OdspTokenManager {
238
249
  tokenConfig.password,
239
250
  );
240
251
  break;
241
- case "browserLogin":
252
+ }
253
+ case "browserLogin": {
242
254
  tokens = await this.acquireTokensViaBrowserLogin(
243
255
  getLoginPageUrl(server, clientConfig, scope, odspAuthRedirectUri),
244
256
  server,
@@ -248,8 +260,10 @@ export class OdspTokenManager {
248
260
  tokenConfig.redirectUriCallback,
249
261
  );
250
262
  break;
251
- default:
263
+ }
264
+ default: {
252
265
  unreachableCase(tokenConfig);
266
+ }
253
267
  }
254
268
 
255
269
  await this.updateTokensCacheWithoutLock(cacheKey, tokens);
@@ -310,7 +324,10 @@ export class OdspTokenManager {
310
324
  return odspTokens;
311
325
  }
312
326
 
313
- private async onTokenRetrievalFromCache(config: OdspTokenConfig, tokens: IOdspTokens) {
327
+ private async onTokenRetrievalFromCache(
328
+ config: OdspTokenConfig,
329
+ tokens: IOdspTokens,
330
+ ): Promise<void> {
314
331
  if (config.type === "browserLogin" && config.redirectUriCallback) {
315
332
  config.navigator(await config.redirectUriCallback(tokens));
316
333
  }
@@ -318,22 +335,23 @@ export class OdspTokenManager {
318
335
 
319
336
  private extractAuthorizationCode(relativeUrl: string | undefined): string {
320
337
  if (relativeUrl === undefined) {
321
- throw Error("Failed to get authorization");
338
+ throw new Error("Failed to get authorization");
322
339
  }
323
340
  const parsedUrl = new URL(relativeUrl, odspAuthRedirectOrigin);
324
341
  const code = parsedUrl.searchParams.get("code");
325
- if (!code) {
326
- throw Error("Failed to get authorization");
342
+ if (code === null || code === undefined) {
343
+ throw new Error("Failed to get authorization");
327
344
  }
328
345
  return code;
329
346
  }
330
347
  }
331
348
 
332
- async function loadAndPatchRC() {
349
+ async function loadAndPatchRC(): Promise<IResources> {
333
350
  const rc = await loadRC();
334
351
  if (rc.tokens && rc.tokens.version === undefined) {
335
352
  // Clean up older versions
336
- delete (rc as any).tokens;
353
+ delete rc.tokens;
354
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
337
355
  delete (rc as any).pushTokens;
338
356
  }
339
357
  return rc;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tool-utils";
9
- export const pkgVersion = "2.0.2";
9
+ export const pkgVersion = "2.1.0-276326";
@@ -3,15 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITree, ITreeEntry, TreeEntry } from "@fluidframework/driver-definitions/internal";
6
+ import type { ITree, ITreeEntry } from "@fluidframework/driver-definitions/internal";
7
+ import { TreeEntry } from "@fluidframework/driver-definitions/internal";
7
8
  import {
8
9
  AttachmentTreeEntry,
9
10
  BlobTreeEntry,
10
11
  TreeTreeEntry,
11
12
  } from "@fluidframework/driver-utils/internal";
12
13
 
13
- /** The name of the metadata blob added to the root of the container runtime. */
14
+ /**
15
+ * The name of the metadata blob added to the root of the container runtime.
16
+ */
14
17
  const metadataBlobName = ".metadata";
18
+
15
19
  /**
16
20
  * The prefix that all GC blob names start with.
17
21
  *
@@ -33,12 +37,18 @@ export interface ISnapshotNormalizerConfig {
33
37
  excludedChannelContentTypes?: string[];
34
38
  }
35
39
 
40
+ const sortStringified = (elem1: unknown, elem2: unknown): number => {
41
+ const serializedElem1 = JSON.stringify(elem1);
42
+ const serializedElem2 = JSON.stringify(elem2);
43
+ return serializedElem1.localeCompare(serializedElem2);
44
+ };
45
+
36
46
  /**
37
47
  * Function that deep sorts an array. It handles cases where array elements are objects or arrays.
38
48
  * @returns the sorted array.
39
49
  */
40
- function getDeepSortedArray(array: any[]): any[] {
41
- const sortedArray: any[] = [];
50
+ function getDeepSortedArray(array: unknown[]): unknown[] {
51
+ const sortedArray: unknown[] = [];
42
52
  // Sort arrays and objects, if any, in the array.
43
53
  for (const element of array) {
44
54
  if (Array.isArray(element)) {
@@ -52,25 +62,20 @@ function getDeepSortedArray(array: any[]): any[] {
52
62
 
53
63
  // Now that all the arrays and objects in this array's elements have been sorted, sort it by comparing each
54
64
  // element's stringified version.
55
- const sortFn = (elem1: any, elem2: any) => {
56
- const serializedElem1 = JSON.stringify(elem1);
57
- const serializedElem2 = JSON.stringify(elem2);
58
- return serializedElem1.localeCompare(serializedElem2);
59
- };
60
-
61
- return sortedArray.sort(sortFn);
65
+ return sortedArray.sort(sortStringified);
62
66
  }
63
67
 
64
68
  /**
65
69
  * Function that deep sorts an object. It handles cases where object properties are arrays or objects.
66
70
  * @returns the sorted object.
67
71
  */
68
- function getDeepSortedObject(obj: any): any {
69
- const sortedObj: any = {};
72
+ function getDeepSortedObject<T extends object>(obj: T): T {
73
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
74
+ const sortedObj: T = {} as T;
70
75
  // Sort the object keys first. Then sort arrays and objects, if any, in the object.
71
76
  const keys = Object.keys(obj).sort();
72
77
  for (const key of keys) {
73
- const value = obj[key];
78
+ const value: unknown = obj[key];
74
79
  if (Array.isArray(value)) {
75
80
  sortedObj[key] = getDeepSortedArray(value);
76
81
  } else if (value instanceof Object) {
@@ -91,10 +96,16 @@ function getDeepSortedObject(obj: any): any {
91
96
  function getNormalizedBlobContent(blobContent: string, blobName: string): string {
92
97
  let content = blobContent;
93
98
  if (blobName.startsWith(gcBlobPrefix)) {
99
+ // The following code parses JSON and makes some assumptions about the type of data within. There does not appear to
100
+ // be a better type than `any` to use here, so the lint rules are disabled.
101
+
102
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
103
+
94
104
  // GC blobs may contain `unreferencedTimestampMs` for node that became unreferenced. This is the timestamp
95
105
  // of the last op processed or current timestamp and can differ between clients depending on when GC was run.
96
106
  // So, remove it for the purposes of comparing snapshots.
97
- const gcState = JSON.parse(content);
107
+ const gcState: any = JSON.parse(content);
108
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
98
109
  for (const [, data] of Object.entries(gcState.gcNodes)) {
99
110
  delete (data as any).unreferencedTimestampMs;
100
111
  }
@@ -135,7 +146,12 @@ function getNormalizedBlobContent(blobContent: string, blobName: string): string
135
146
  contentObj = getDeepSortedObject(contentObj);
136
147
  }
137
148
  content = JSON.stringify(contentObj);
138
- } catch {}
149
+ } catch {
150
+ // Do nothing
151
+ }
152
+
153
+ /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
154
+
139
155
  return content;
140
156
  }
141
157
 
@@ -195,6 +211,8 @@ function normalizeMatrix(value: ITree): ITree {
195
211
  return value;
196
212
  }
197
213
 
214
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
215
+
198
216
  const contents = JSON.parse(header?.value.contents);
199
217
 
200
218
  for (const segment of contents.segments) {
@@ -209,6 +227,8 @@ function normalizeMatrix(value: ITree): ITree {
209
227
 
210
228
  header.value.contents = JSON.stringify(contents);
211
229
 
230
+ /* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
231
+
212
232
  return value;
213
233
  }
214
234
 
@@ -221,8 +241,7 @@ function normalizeEntry(
221
241
  let contents = entry.value.contents;
222
242
  // If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.
223
243
  if (
224
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.
225
- config?.blobsToNormalize?.includes(entry.path) ||
244
+ (config?.blobsToNormalize?.includes(entry.path) ?? false) ||
226
245
  entry.path.startsWith(gcBlobPrefix)
227
246
  ) {
228
247
  contents = getNormalizedBlobContent(contents, entry.path);
@@ -236,6 +255,7 @@ function normalizeEntry(
236
255
  maybeAttributes.type === TreeEntry.Blob &&
237
256
  maybeAttributes.path === ".attributes"
238
257
  ) {
258
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
239
259
  const parsed: { type?: string } = JSON.parse(maybeAttributes.value.contents);
240
260
  if (parsed.type === "https://graph.microsoft.com/types/sharedmatrix") {
241
261
  return new TreeTreeEntry(
@@ -260,7 +280,8 @@ function normalizeEntry(
260
280
  return new AttachmentTreeEntry(entry.path, entry.value.id);
261
281
  }
262
282
 
263
- default:
283
+ default: {
264
284
  throw new Error("Unknown entry type");
285
+ }
265
286
  }
266
287
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluidToolRC.d.ts","sourceRoot":"","sources":["../src/fluidToolRC.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGzE;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,MAAM;IACxC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE;YACL,CA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I,KAAK,UAAU,MAAM,CAAC,EAAc;IAC1C,MAAM,SAAS,GAAG,cAAI,CAAC,SAAS,CAAC,YAAE,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC,aAAa,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC;AAJD,wBAIC;AAED;;GAEG;AACI,KAAK,UAAU,MAAM;IAC3B,+DAA+D;IAC/D,OAAO,IAAA,sBAAI,EAAC,aAAa,EAAE,EAAE;QAC5B,OAAO,EAAE;YACR,OAAO,EAAE,IAAI;SACb;QACD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAK;KACf,CAAC,CAAC;AACJ,CAAC;AATD,wBASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\nimport util from \"util\";\n\nimport { IOdspTokens } from \"@fluidframework/odsp-doclib-utils/internal\";\nimport { lock } from \"proper-lockfile\";\n\n/**\n * @internal\n */\nexport interface IAsyncCache<TKey, TValue> {\n\tget(key: TKey): Promise<TValue | undefined>;\n\tsave(key: TKey, value: TValue): Promise<void>;\n\tlock<T>(callback: () => Promise<T>): Promise<T>;\n}\n\n/**\n * @internal\n */\nexport interface IResources {\n\ttokens?: {\n\t\tversion?: number;\n\t\tdata: {\n\t\t\t[key: string]: {\n\t\t\t\tstorage?: IOdspTokens;\n\t\t\t\tpush?: IOdspTokens;\n\t\t\t};\n\t\t};\n\t};\n}\n\nconst getRCFileName = () => path.join(os.homedir(), \".fluidtoolrc\");\n\n/**\n * @internal\n */\nexport async function loadRC(): Promise<IResources> {\n\tconst readFile = util.promisify(fs.readFile);\n\tconst exists = util.promisify(fs.exists);\n\tconst fileName = getRCFileName();\n\tif (await exists(fileName)) {\n\t\tconst buf = await readFile(fileName);\n\t\ttry {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn JSON.parse(buf.toString(\"utf8\"));\n\t\t} catch (e) {\n\t\t\t// Nothing\n\t\t}\n\t}\n\treturn {};\n}\n\n/**\n * @internal\n */\nexport async function saveRC(rc: IResources) {\n\tconst writeFile = util.promisify(fs.writeFile);\n\tconst content = JSON.stringify(rc, undefined, 2);\n\treturn writeFile(getRCFileName(), Buffer.from(content, \"utf8\"));\n}\n\n/**\n * @internal\n */\nexport async function lockRC() {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn lock(getRCFileName(), {\n\t\tretries: {\n\t\t\tforever: true,\n\t\t},\n\t\tstale: 60000,\n\t\trealpath: false,\n\t});\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluidToolRC.d.ts","sourceRoot":"","sources":["../src/fluidToolRC.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGzE;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,MAAM;IACxC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE;YACL,CAAC,GAAG,EAAE,MAAM,GAAG;gBACd,OAAO,CAAC,EAAE,WAAW,CA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,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,EAAc;IAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC,aAAa,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC3B,+DAA+D;IAC/D,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE;QAC5B,OAAO,EAAE;YACR,OAAO,EAAE,IAAI;SACb;QACD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAK;KACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\nimport util from \"util\";\n\nimport { IOdspTokens } from \"@fluidframework/odsp-doclib-utils/internal\";\nimport { lock } from \"proper-lockfile\";\n\n/**\n * @internal\n */\nexport interface IAsyncCache<TKey, TValue> {\n\tget(key: TKey): Promise<TValue | undefined>;\n\tsave(key: TKey, value: TValue): Promise<void>;\n\tlock<T>(callback: () => Promise<T>): Promise<T>;\n}\n\n/**\n * @internal\n */\nexport interface IResources {\n\ttokens?: {\n\t\tversion?: number;\n\t\tdata: {\n\t\t\t[key: string]: {\n\t\t\t\tstorage?: IOdspTokens;\n\t\t\t\tpush?: IOdspTokens;\n\t\t\t};\n\t\t};\n\t};\n}\n\nconst getRCFileName = () => path.join(os.homedir(), \".fluidtoolrc\");\n\n/**\n * @internal\n */\nexport async function loadRC(): Promise<IResources> {\n\tconst readFile = util.promisify(fs.readFile);\n\tconst exists = util.promisify(fs.exists);\n\tconst fileName = getRCFileName();\n\tif (await exists(fileName)) {\n\t\tconst buf = await readFile(fileName);\n\t\ttry {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn JSON.parse(buf.toString(\"utf8\"));\n\t\t} catch (e) {\n\t\t\t// Nothing\n\t\t}\n\t}\n\treturn {};\n}\n\n/**\n * @internal\n */\nexport async function saveRC(rc: IResources) {\n\tconst writeFile = util.promisify(fs.writeFile);\n\tconst content = JSON.stringify(rc, undefined, 2);\n\treturn writeFile(getRCFileName(), Buffer.from(content, \"utf8\"));\n}\n\n/**\n * @internal\n */\nexport async function lockRC() {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn lock(getRCFileName(), {\n\t\tretries: {\n\t\t\tforever: true,\n\t\t},\n\t\tstale: 60000,\n\t\trealpath: false,\n\t});\n}\n"]}