@fluid-internal/client-utils 2.0.0-dev.7.3.0.209174 → 2.0.0-dev.7.3.0.210328

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,12 @@
3
3
  This package is intended for sharing and promoting utility functions across packages in the Fluid Framework repo,
4
4
  primarily within the client release group.
5
5
 
6
- Use outside of the Fluid Framework repo is not supported or recommended.
6
+ <!-- AUTO-GENERATED-CONTENT:START (README_PACKAGE_SCOPE_NOTICE) -->
7
+
8
+ **IMPORTANT: This package is intended strictly as an implementation detail of the Fluid Framework and is not intended for public consumption.**
9
+ **We make no stability guarantees regarding its APIs.**
10
+
11
+ <!-- AUTO-GENERATED-CONTENT:END -->
7
12
 
8
13
  ## Adding code to this package
9
14
 
@@ -61,8 +66,7 @@ package for more information including tools to convert between version schemes.
61
66
 
62
67
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
63
68
 
64
- Use of these trademarks or logos must follow Microsoft's [Trademark & Brand
65
- Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
69
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
66
70
 
67
71
  Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
68
72
 
@@ -71,9 +71,9 @@ async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex") {
71
71
  // from the main chunk and will be of non-trivial size. It will not be served
72
72
  // under normal circumstances.
73
73
  if (crypto.subtle === undefined) {
74
- return Promise.resolve().then(() => __importStar(require(
74
+ return import(
75
75
  /* webpackChunkName: "FluidFramework-HashFallback" */
76
- "./hashFileNode"))).then(async (m) => m.hashFile(file, algorithm, hashEncoding));
76
+ "./hashFileNode.js").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
77
77
  }
78
78
  // This is split up this way to facilitate testing (see the test for more info)
79
79
  const hashArray = await digestBuffer(file, algorithm);
@@ -1 +1 @@
1
- {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,mDAA4C;AAE5C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,SAA8B;IAC1E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,SAAqB,EAAE,QAA0B;IACtE,wCAAwC;IACxC,QAAQ,QAAQ,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACX,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG;iBACjC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,yGAAyG;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,OAAO;QACN,qDAAqD;QACrD,gBAAgB,IACf,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/D;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AApBD,4BAoBC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,yBAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AARD,kCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\nimport { IsoBuffer } from \"./bufferBrowser\";\n\nasync function digestBuffer(file: IsoBuffer, algorithm: \"SHA-1\" | \"SHA-256\"): Promise<Uint8Array> {\n\tconst hash = await crypto.subtle.digest(algorithm, file);\n\treturn new Uint8Array(hash);\n}\n\nfunction encodeDigest(hashArray: Uint8Array, encoding: \"hex\" | \"base64\"): string {\n\t// eslint-disable-next-line default-case\n\tswitch (encoding) {\n\t\tcase \"hex\": {\n\t\t\tconst hashHex = Array.prototype.map\n\t\t\t\t.call(hashArray, (byte) => {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\t\treturn byte.toString(16).padStart(2, \"0\") as string;\n\t\t\t\t})\n\t\t\t\t.join(\"\");\n\t\t\treturn hashHex;\n\t\t}\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(hashArray);\n\t\t}\n\t}\n}\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n */\nexport async function hashFile(\n\tfile: IsoBuffer,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\t// Handle insecure contexts (e.g. running with local services)\n\t// by deferring to Node version, which uses a hash polyfill\n\t// When packed, this chunk will show as \"FluidFramework-HashFallback\" separately\n\t// from the main chunk and will be of non-trivial size. It will not be served\n\t// under normal circumstances.\n\tif (crypto.subtle === undefined) {\n\t\treturn import(\n\t\t\t/* webpackChunkName: \"FluidFramework-HashFallback\" */\n\t\t\t\"./hashFileNode\"\n\t\t).then(async (m) => m.hashFile(file, algorithm, hashEncoding));\n\t}\n\n\t// This is split up this way to facilitate testing (see the test for more info)\n\tconst hashArray = await digestBuffer(file, algorithm);\n\treturn encodeDigest(hashArray, hashEncoding);\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n */\nexport async function gitHashFile(file: IsoBuffer): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst hashBuffer = IsoBuffer.from(filePrefix + file.toString());\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
1
+ {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,mDAA4C;AAE5C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,SAA8B;IAC1E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,SAAqB,EAAE,QAA0B;IACtE,wCAAwC;IACxC,QAAQ,QAAQ,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACX,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG;iBACjC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,yGAAyG;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,OAAO,MAAM;QACZ,qDAAqD;QACrD,mBAAmB,CACnB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/D;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AApBD,4BAoBC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,yBAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AARD,kCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\nimport { IsoBuffer } from \"./bufferBrowser\";\n\nasync function digestBuffer(file: IsoBuffer, algorithm: \"SHA-1\" | \"SHA-256\"): Promise<Uint8Array> {\n\tconst hash = await crypto.subtle.digest(algorithm, file);\n\treturn new Uint8Array(hash);\n}\n\nfunction encodeDigest(hashArray: Uint8Array, encoding: \"hex\" | \"base64\"): string {\n\t// eslint-disable-next-line default-case\n\tswitch (encoding) {\n\t\tcase \"hex\": {\n\t\t\tconst hashHex = Array.prototype.map\n\t\t\t\t.call(hashArray, (byte) => {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\t\treturn byte.toString(16).padStart(2, \"0\") as string;\n\t\t\t\t})\n\t\t\t\t.join(\"\");\n\t\t\treturn hashHex;\n\t\t}\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(hashArray);\n\t\t}\n\t}\n}\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n */\nexport async function hashFile(\n\tfile: IsoBuffer,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\t// Handle insecure contexts (e.g. running with local services)\n\t// by deferring to Node version, which uses a hash polyfill\n\t// When packed, this chunk will show as \"FluidFramework-HashFallback\" separately\n\t// from the main chunk and will be of non-trivial size. It will not be served\n\t// under normal circumstances.\n\tif (crypto.subtle === undefined) {\n\t\treturn import(\n\t\t\t/* webpackChunkName: \"FluidFramework-HashFallback\" */\n\t\t\t\"./hashFileNode.js\"\n\t\t).then(async (m) => m.hashFile(file, algorithm, hashEncoding));\n\t}\n\n\t// This is split up this way to facilitate testing (see the test for more info)\n\tconst hashArray = await digestBuffer(file, algorithm);\n\treturn encodeDigest(hashArray, hashEncoding);\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n */\nexport async function gitHashFile(file: IsoBuffer): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst hashBuffer = IsoBuffer.from(filePrefix + file.toString());\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
@@ -47,7 +47,7 @@ export async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex")
47
47
  if (crypto.subtle === undefined) {
48
48
  return import(
49
49
  /* webpackChunkName: "FluidFramework-HashFallback" */
50
- "./hashFileNode").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
50
+ "./hashFileNode.js").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
51
51
  }
52
52
  // This is split up this way to facilitate testing (see the test for more info)
53
53
  const hashArray = await digestBuffer(file, algorithm);
@@ -1 +1 @@
1
- {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,SAA8B;IAC1E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,SAAqB,EAAE,QAA0B;IACtE,wCAAwC;IACxC,QAAQ,QAAQ,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACX,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG;iBACjC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,yGAAyG;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,OAAO,MAAM;QACZ,qDAAqD;QACrD,gBAAgB,CAChB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/D;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\nimport { IsoBuffer } from \"./bufferBrowser\";\n\nasync function digestBuffer(file: IsoBuffer, algorithm: \"SHA-1\" | \"SHA-256\"): Promise<Uint8Array> {\n\tconst hash = await crypto.subtle.digest(algorithm, file);\n\treturn new Uint8Array(hash);\n}\n\nfunction encodeDigest(hashArray: Uint8Array, encoding: \"hex\" | \"base64\"): string {\n\t// eslint-disable-next-line default-case\n\tswitch (encoding) {\n\t\tcase \"hex\": {\n\t\t\tconst hashHex = Array.prototype.map\n\t\t\t\t.call(hashArray, (byte) => {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\t\treturn byte.toString(16).padStart(2, \"0\") as string;\n\t\t\t\t})\n\t\t\t\t.join(\"\");\n\t\t\treturn hashHex;\n\t\t}\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(hashArray);\n\t\t}\n\t}\n}\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n */\nexport async function hashFile(\n\tfile: IsoBuffer,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\t// Handle insecure contexts (e.g. running with local services)\n\t// by deferring to Node version, which uses a hash polyfill\n\t// When packed, this chunk will show as \"FluidFramework-HashFallback\" separately\n\t// from the main chunk and will be of non-trivial size. It will not be served\n\t// under normal circumstances.\n\tif (crypto.subtle === undefined) {\n\t\treturn import(\n\t\t\t/* webpackChunkName: \"FluidFramework-HashFallback\" */\n\t\t\t\"./hashFileNode\"\n\t\t).then(async (m) => m.hashFile(file, algorithm, hashEncoding));\n\t}\n\n\t// This is split up this way to facilitate testing (see the test for more info)\n\tconst hashArray = await digestBuffer(file, algorithm);\n\treturn encodeDigest(hashArray, hashEncoding);\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n */\nexport async function gitHashFile(file: IsoBuffer): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst hashBuffer = IsoBuffer.from(filePrefix + file.toString());\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
1
+ {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,SAA8B;IAC1E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,SAAqB,EAAE,QAA0B;IACtE,wCAAwC;IACxC,QAAQ,QAAQ,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACX,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG;iBACjC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,yGAAyG;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,OAAO,MAAM;QACZ,qDAAqD;QACrD,mBAAmB,CACnB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/D;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\nimport { IsoBuffer } from \"./bufferBrowser\";\n\nasync function digestBuffer(file: IsoBuffer, algorithm: \"SHA-1\" | \"SHA-256\"): Promise<Uint8Array> {\n\tconst hash = await crypto.subtle.digest(algorithm, file);\n\treturn new Uint8Array(hash);\n}\n\nfunction encodeDigest(hashArray: Uint8Array, encoding: \"hex\" | \"base64\"): string {\n\t// eslint-disable-next-line default-case\n\tswitch (encoding) {\n\t\tcase \"hex\": {\n\t\t\tconst hashHex = Array.prototype.map\n\t\t\t\t.call(hashArray, (byte) => {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\t\treturn byte.toString(16).padStart(2, \"0\") as string;\n\t\t\t\t})\n\t\t\t\t.join(\"\");\n\t\t\treturn hashHex;\n\t\t}\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(hashArray);\n\t\t}\n\t}\n}\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n */\nexport async function hashFile(\n\tfile: IsoBuffer,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\t// Handle insecure contexts (e.g. running with local services)\n\t// by deferring to Node version, which uses a hash polyfill\n\t// When packed, this chunk will show as \"FluidFramework-HashFallback\" separately\n\t// from the main chunk and will be of non-trivial size. It will not be served\n\t// under normal circumstances.\n\tif (crypto.subtle === undefined) {\n\t\treturn import(\n\t\t\t/* webpackChunkName: \"FluidFramework-HashFallback\" */\n\t\t\t\"./hashFileNode.js\"\n\t\t).then(async (m) => m.hashFile(file, algorithm, hashEncoding));\n\t}\n\n\t// This is split up this way to facilitate testing (see the test for more info)\n\tconst hashArray = await digestBuffer(file, algorithm);\n\treturn encodeDigest(hashArray, hashEncoding);\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n */\nexport async function gitHashFile(file: IsoBuffer): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst hashBuffer = IsoBuffer.from(filePrefix + file.toString());\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-internal/client-utils",
3
- "version": "2.0.0-dev.7.3.0.209174",
3
+ "version": "2.0.0-dev.7.3.0.210328",
4
4
  "description": "Not intended for use outside the Fluid Framework.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "temp-directory": "nyc/.nyc_output"
40
40
  },
41
41
  "dependencies": {
42
- "@fluidframework/core-interfaces": "2.0.0-dev.7.3.0.209174",
43
- "@fluidframework/core-utils": "2.0.0-dev.7.3.0.209174",
42
+ "@fluidframework/core-interfaces": "2.0.0-dev.7.3.0.210328",
43
+ "@fluidframework/core-utils": "2.0.0-dev.7.3.0.210328",
44
44
  "@types/events": "^3.0.0",
45
45
  "base64-js": "^1.5.1",
46
46
  "buffer": "^6.0.3",
@@ -49,11 +49,11 @@
49
49
  "sha.js": "^2.4.11"
50
50
  },
51
51
  "devDependencies": {
52
- "@fluid-tools/build-cli": "^0.26.1",
52
+ "@fluid-tools/build-cli": "^0.27.0",
53
53
  "@fluidframework/build-common": "^2.0.3",
54
- "@fluidframework/build-tools": "^0.26.1",
54
+ "@fluidframework/build-tools": "^0.27.0",
55
55
  "@fluidframework/eslint-config-fluid": "^3.1.0",
56
- "@fluidframework/mocha-test-setup": "2.0.0-dev.7.3.0.209174",
56
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.7.3.0.210328",
57
57
  "@microsoft/api-extractor": "^7.37.0",
58
58
  "@types/base64-js": "^1.3.0",
59
59
  "@types/jest": "29.5.3",
@@ -55,7 +55,7 @@ export async function hashFile(
55
55
  if (crypto.subtle === undefined) {
56
56
  return import(
57
57
  /* webpackChunkName: "FluidFramework-HashFallback" */
58
- "./hashFileNode"
58
+ "./hashFileNode.js"
59
59
  ).then(async (m) => m.hashFile(file, algorithm, hashEncoding));
60
60
  }
61
61
 
@@ -1,7 +1,6 @@
1
1
  {
2
- "extends": "./tsconfig.json",
2
+ "extends": ["./tsconfig.json", "../../../common/build/build-common/tsconfig.esm.json"],
3
3
  "compilerOptions": {
4
4
  "outDir": "./lib",
5
- "module": "esnext",
6
5
  },
7
6
  }
package/tsconfig.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
2
+ "extends": [
3
+ "../../../common/build/build-common/tsconfig.base.json",
4
+ "../../../common/build/build-common/tsconfig.cjs.json",
5
+ ],
6
+ "include": ["src/**/*"],
7
+ "exclude": ["src/test/**/*"],
3
8
  "compilerOptions": {
4
9
  "rootDir": "./src",
5
10
  "outDir": "./dist",
6
- "composite": true,
7
11
  "baseUrl": ".",
8
12
  "paths": {
9
13
  "perf_hooks": ["types/perf_hooks.d.ts"],
10
14
  },
11
15
  "types": ["events"],
12
16
  },
13
- "include": ["src/**/*"],
14
- "exclude": ["src/test/**/*"],
15
17
  }