@fluid-internal/client-utils 2.118.1 → 3.0.1

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 (120) hide show
  1. package/CHANGELOG.md +1 -5
  2. package/README.md +13 -15
  3. package/dist/base64EncodingBrowser.d.ts +2 -1
  4. package/dist/base64EncodingBrowser.d.ts.map +1 -1
  5. package/dist/base64EncodingBrowser.js +1 -1
  6. package/dist/base64EncodingBrowser.js.map +1 -1
  7. package/dist/base64EncodingNode.d.ts +2 -1
  8. package/dist/base64EncodingNode.d.ts.map +1 -1
  9. package/dist/base64EncodingNode.js.map +1 -1
  10. package/dist/buffer.d.ts +93 -0
  11. package/dist/buffer.d.ts.map +1 -0
  12. package/dist/buffer.js +7 -0
  13. package/dist/buffer.js.map +1 -0
  14. package/dist/bufferBrowser.d.ts +18 -49
  15. package/dist/bufferBrowser.d.ts.map +1 -1
  16. package/dist/bufferBrowser.js +49 -52
  17. package/dist/bufferBrowser.js.map +1 -1
  18. package/dist/bufferNode.d.ts +67 -19
  19. package/dist/bufferNode.d.ts.map +1 -1
  20. package/dist/bufferNode.js +10 -12
  21. package/dist/bufferNode.js.map +1 -1
  22. package/dist/bufferShared.d.ts +38 -3
  23. package/dist/bufferShared.d.ts.map +1 -1
  24. package/dist/bufferShared.js +67 -5
  25. package/dist/bufferShared.js.map +1 -1
  26. package/dist/events/emitter.d.ts.map +1 -1
  27. package/dist/events/emitter.js +4 -3
  28. package/dist/events/emitter.js.map +1 -1
  29. package/dist/hashFileBrowser.d.ts +1 -1
  30. package/dist/hashFileBrowser.d.ts.map +1 -1
  31. package/dist/hashFileBrowser.js +23 -11
  32. package/dist/hashFileBrowser.js.map +1 -1
  33. package/dist/hashFileNode.d.ts +10 -2
  34. package/dist/hashFileNode.d.ts.map +1 -1
  35. package/dist/hashFileNode.js +10 -3
  36. package/dist/hashFileNode.js.map +1 -1
  37. package/dist/indexBrowser.d.ts +5 -3
  38. package/dist/indexBrowser.d.ts.map +1 -1
  39. package/dist/indexBrowser.js +5 -5
  40. package/dist/indexBrowser.js.map +1 -1
  41. package/dist/indexNode.d.ts +4 -3
  42. package/dist/indexNode.d.ts.map +1 -1
  43. package/dist/indexNode.js +5 -2
  44. package/dist/indexNode.js.map +1 -1
  45. package/dist/layerCompat.d.ts +37 -13
  46. package/dist/layerCompat.d.ts.map +1 -1
  47. package/dist/layerCompat.js +19 -14
  48. package/dist/layerCompat.js.map +1 -1
  49. package/dist/trace.js +2 -0
  50. package/dist/trace.js.map +1 -1
  51. package/dist/typedEventEmitter.js +7 -0
  52. package/dist/typedEventEmitter.js.map +1 -1
  53. package/eslint.config.mts +2 -2
  54. package/lib/base64EncodingBrowser.d.ts +2 -1
  55. package/lib/base64EncodingBrowser.d.ts.map +1 -1
  56. package/lib/base64EncodingBrowser.js +1 -1
  57. package/lib/base64EncodingBrowser.js.map +1 -1
  58. package/lib/base64EncodingNode.d.ts +2 -1
  59. package/lib/base64EncodingNode.d.ts.map +1 -1
  60. package/lib/base64EncodingNode.js.map +1 -1
  61. package/lib/buffer.d.ts +93 -0
  62. package/lib/buffer.d.ts.map +1 -0
  63. package/lib/buffer.js +6 -0
  64. package/lib/buffer.js.map +1 -0
  65. package/lib/bufferBrowser.d.ts +18 -49
  66. package/lib/bufferBrowser.d.ts.map +1 -1
  67. package/lib/bufferBrowser.js +29 -40
  68. package/lib/bufferBrowser.js.map +1 -1
  69. package/lib/bufferNode.d.ts +67 -19
  70. package/lib/bufferNode.d.ts.map +1 -1
  71. package/lib/bufferNode.js +7 -9
  72. package/lib/bufferNode.js.map +1 -1
  73. package/lib/bufferShared.d.ts +38 -3
  74. package/lib/bufferShared.d.ts.map +1 -1
  75. package/lib/bufferShared.js +64 -3
  76. package/lib/bufferShared.js.map +1 -1
  77. package/lib/events/emitter.d.ts.map +1 -1
  78. package/lib/events/emitter.js +2 -1
  79. package/lib/events/emitter.js.map +1 -1
  80. package/lib/hashFileBrowser.d.ts +1 -1
  81. package/lib/hashFileBrowser.d.ts.map +1 -1
  82. package/lib/hashFileBrowser.js +4 -1
  83. package/lib/hashFileBrowser.js.map +1 -1
  84. package/lib/hashFileNode.d.ts +10 -2
  85. package/lib/hashFileNode.d.ts.map +1 -1
  86. package/lib/hashFileNode.js +8 -0
  87. package/lib/hashFileNode.js.map +1 -1
  88. package/lib/indexBrowser.d.ts +5 -3
  89. package/lib/indexBrowser.d.ts.map +1 -1
  90. package/lib/indexBrowser.js +3 -5
  91. package/lib/indexBrowser.js.map +1 -1
  92. package/lib/indexNode.d.ts +4 -3
  93. package/lib/indexNode.d.ts.map +1 -1
  94. package/lib/indexNode.js +2 -2
  95. package/lib/indexNode.js.map +1 -1
  96. package/lib/layerCompat.d.ts +37 -13
  97. package/lib/layerCompat.d.ts.map +1 -1
  98. package/lib/layerCompat.js +17 -12
  99. package/lib/layerCompat.js.map +1 -1
  100. package/lib/trace.js +2 -0
  101. package/lib/trace.js.map +1 -1
  102. package/lib/typedEventEmitter.js +7 -0
  103. package/lib/typedEventEmitter.js.map +1 -1
  104. package/package.json +65 -62
  105. package/playwright.config.ts +23 -0
  106. package/src/base64EncodingBrowser.ts +3 -2
  107. package/src/base64EncodingNode.ts +2 -1
  108. package/src/buffer.ts +112 -0
  109. package/src/bufferBrowser.ts +98 -60
  110. package/src/bufferNode.ts +86 -30
  111. package/src/bufferShared.ts +74 -4
  112. package/src/hashFileBrowser.ts +6 -3
  113. package/src/hashFileNode.ts +10 -2
  114. package/src/indexBrowser.ts +13 -2
  115. package/src/indexNode.ts +13 -2
  116. package/src/layerCompat.ts +41 -13
  117. package/tsconfig.json +1 -2
  118. package/webpack.playwright.cjs +22 -0
  119. package/jest-puppeteer.config.cjs +0 -16
  120. package/jest.config.cjs +0 -21
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- // This file is a Node.js-specific implementation of the base64 encoding functions.
5
+ // This file is a browser-specific implementation of the base64 encoding functions.
6
6
  // Aside from the below import statement, this file should be identical to the
7
7
  // base64EncodingNode.ts.
8
8
  //
@@ -1 +1 @@
1
- {"version":3,"file":"base64EncodingBrowser.js","sourceRoot":"","sources":["../src/base64EncodingBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mFAAmF;AACnF,8EAA8E;AAC9E,yBAAyB;AACzB,EAAE;AACF,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE;IACjE,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// This file is a Node.js-specific implementation of the base64 encoding functions.\n// Aside from the below import statement, this file should be identical to the\n// base64EncodingNode.ts.\n//\n// (See 'Isomorphic Code' section in the package README.md.)\nimport { IsoBuffer } from \"./bufferBrowser.js\";\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string\n * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.\n *\n * @internal\n */\nexport const fromBase64ToUtf8 = (input: string): string =>\n\tIsoBuffer.from(input, \"base64\").toString(\"utf8\");\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string\n * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.\n *\n * @internal\n */\nexport const fromUtf8ToBase64 = (input: string): string =>\n\tIsoBuffer.from(input, \"utf8\").toString(\"base64\");\n\n/**\n * Convenience function to convert unknown encoding to utf8 that avoids\n * buffer copies/encode ops when no conversion is needed.\n * @param input - The source string to convert.\n * @param encoding - The source string's encoding.\n *\n * @internal\n */\nexport const toUtf8 = (input: string, encoding: string): string => {\n\tswitch (encoding) {\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\": {\n\t\t\treturn input;\n\t\t}\n\t\tdefault: {\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t\t}\n\t}\n};\n"]}
1
+ {"version":3,"file":"base64EncodingBrowser.js","sourceRoot":"","sources":["../src/base64EncodingBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,mFAAmF;AACnF,8EAA8E;AAC9E,yBAAyB;AACzB,EAAE;AACF,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAA2B,EAAU,EAAE;IAC5E,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IsoBufferEncoding } from \"./buffer.js\";\n// This file is a browser-specific implementation of the base64 encoding functions.\n// Aside from the below import statement, this file should be identical to the\n// base64EncodingNode.ts.\n//\n// (See 'Isomorphic Code' section in the package README.md.)\nimport { IsoBuffer } from \"./bufferBrowser.js\";\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string\n * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.\n *\n * @internal\n */\nexport const fromBase64ToUtf8 = (input: string): string =>\n\tIsoBuffer.from(input, \"base64\").toString(\"utf8\");\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string\n * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.\n *\n * @internal\n */\nexport const fromUtf8ToBase64 = (input: string): string =>\n\tIsoBuffer.from(input, \"utf8\").toString(\"base64\");\n\n/**\n * Convenience function to convert unknown encoding to utf8 that avoids\n * buffer copies/encode ops when no conversion is needed.\n * @param input - The source string to convert.\n * @param encoding - The source string's encoding.\n *\n * @internal\n */\nexport const toUtf8 = (input: string, encoding: IsoBufferEncoding): string => {\n\tswitch (encoding) {\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\": {\n\t\t\treturn input;\n\t\t}\n\t\tdefault: {\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t\t}\n\t}\n};\n"]}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { IsoBufferEncoding } from "./buffer.js";
5
6
  /**
6
7
  * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
7
8
  * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
@@ -24,5 +25,5 @@ export declare const fromUtf8ToBase64: (input: string) => string;
24
25
  *
25
26
  * @internal
26
27
  */
27
- export declare const toUtf8: (input: string, encoding: string) => string;
28
+ export declare const toUtf8: (input: string, encoding: IsoBufferEncoding) => string;
28
29
  //# sourceMappingURL=base64EncodingNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base64EncodingNode.d.ts","sourceRoot":"","sources":["../src/base64EncodingNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACA,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACA,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,YAAY,MAAM,KAAG,MAWxD,CAAC"}
1
+ {"version":3,"file":"base64EncodingNode.d.ts","sourceRoot":"","sources":["../src/base64EncodingNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQrD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MACA,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MACA,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,UAAU,iBAAiB,KAAG,MAWnE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64EncodingNode.js","sourceRoot":"","sources":["../src/base64EncodingNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mFAAmF;AACnF,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE;IACjE,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// This file is a Node.js-specific implementation of the base64 encoding functions.\n// Aside from the below import statement, this file should be identical to the\n// base64EncodingBrowser.ts.\n//\n// (See 'Isomorphic Code' section in the package README.md.)\nimport { IsoBuffer } from \"./bufferNode.js\";\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string\n * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.\n *\n * @internal\n */\nexport const fromBase64ToUtf8 = (input: string): string =>\n\tIsoBuffer.from(input, \"base64\").toString(\"utf8\");\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string\n * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.\n *\n * @internal\n */\nexport const fromUtf8ToBase64 = (input: string): string =>\n\tIsoBuffer.from(input, \"utf8\").toString(\"base64\");\n\n/**\n * Convenience function to convert unknown encoding to utf8 that avoids\n * buffer copies/encode ops when no conversion is needed.\n * @param input - The source string to convert.\n * @param encoding - The source string's encoding.\n *\n * @internal\n */\nexport const toUtf8 = (input: string, encoding: string): string => {\n\tswitch (encoding) {\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\": {\n\t\t\treturn input;\n\t\t}\n\t\tdefault: {\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t\t}\n\t}\n};\n"]}
1
+ {"version":3,"file":"base64EncodingNode.js","sourceRoot":"","sources":["../src/base64EncodingNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,mFAAmF;AACnF,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAA2B,EAAU,EAAE;IAC5E,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IsoBufferEncoding } from \"./buffer.js\";\n// This file is a Node.js-specific implementation of the base64 encoding functions.\n// Aside from the below import statement, this file should be identical to the\n// base64EncodingBrowser.ts.\n//\n// (See 'Isomorphic Code' section in the package README.md.)\nimport { IsoBuffer } from \"./bufferNode.js\";\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string\n * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.\n *\n * @internal\n */\nexport const fromBase64ToUtf8 = (input: string): string =>\n\tIsoBuffer.from(input, \"base64\").toString(\"utf8\");\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string\n * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.\n *\n * @internal\n */\nexport const fromUtf8ToBase64 = (input: string): string =>\n\tIsoBuffer.from(input, \"utf8\").toString(\"base64\");\n\n/**\n * Convenience function to convert unknown encoding to utf8 that avoids\n * buffer copies/encode ops when no conversion is needed.\n * @param input - The source string to convert.\n * @param encoding - The source string's encoding.\n *\n * @internal\n */\nexport const toUtf8 = (input: string, encoding: IsoBufferEncoding): string => {\n\tswitch (encoding) {\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\": {\n\t\t\treturn input;\n\t\t}\n\t\tdefault: {\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t\t}\n\t}\n};\n"]}
@@ -0,0 +1,93 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Declare the subset of node:Buffer functionality we want to make available instead of
7
+ * exposing the entirely of Node's typings. These serve as the public interface
8
+ * of the browser and node implementation.
9
+ */
10
+ /**
11
+ * Set of supported encodings for string to buffer conversion.
12
+ *
13
+ * @internal
14
+ */
15
+ export type IsoBufferEncoding = "utf8" | "utf-8" | "base64";
16
+ /**
17
+ * Minimal Buffer interface for our usages in the browser or Node environments.
18
+ *
19
+ * @internal
20
+ */
21
+ export interface IsoBuffer<TArrayBuffer extends ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
22
+ /**
23
+ * Convert the buffer to a string.
24
+ * Only supports encoding the whole string (unlike the Node `Buffer` equivalent)
25
+ * and only utf8 and base64 encodings.
26
+ *
27
+ * @param encoding - The encoding to use.
28
+ */
29
+ toString(encoding?: IsoBufferEncoding): string;
30
+ }
31
+ /**
32
+ * Constructor for {@link (IsoBuffer:type)}.
33
+ *
34
+ * @internal
35
+ */
36
+ export interface IsoBufferConstructor {
37
+ readonly prototype: IsoBuffer<ArrayBufferLike>;
38
+ new (length: number): IsoBuffer<ArrayBuffer>;
39
+ new (array: ArrayLike<number>): IsoBuffer<ArrayBuffer>;
40
+ new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): IsoBuffer<TArrayBuffer>;
41
+ /**
42
+ * Creates a new `IsoBuffer` containing `string`. The `encoding` parameter identifies
43
+ * the character encoding to be used when converting `string` into bytes.
44
+ *
45
+ * @param string - A string to encode.
46
+ * @param encoding - The encoding of `string`. **Default:** `'utf8'`.
47
+ *
48
+ * @privateRemarks
49
+ * Node buffer.buffer.d.ts declaration:
50
+ * `from(string: WithImplicitCoercion<string>, encoding?: IsoBufferEncoding): Buffer<ArrayBuffer>;`
51
+ */
52
+ from(string: string, encoding?: IsoBufferEncoding): IsoBuffer<ArrayBuffer>;
53
+ /**
54
+ * Allocates a new `IsoBuffer` using an `array` of bytes in the range `0` – `255`.
55
+ * Array entries outside that range will be truncated to fit into it.
56
+ *
57
+ * @param value - `Uint8Array`.
58
+ *
59
+ * @remarks
60
+ * This is limited to `Uint8Array` input to match Node implementation that
61
+ * takes `ArrayLike<number>` and returns `IsoBuffer<ArrayBuffer>`.
62
+ *
63
+ * @privateRemarks
64
+ * Node buffer.buffer.d.ts declaration:
65
+ * `from(array: WithImplicitCoercion<ArrayLike<number>>): IsoBuffer<ArrayBuffer>;`
66
+ */
67
+ from(array: Uint8Array): IsoBuffer<ArrayBuffer>;
68
+ /**
69
+ * This creates a view of the `ArrayBuffer` without copying the underlying
70
+ * memory. For example, when passed a reference to the `.buffer` property of a
71
+ * `TypedArray` instance, the newly created `Buffer` will share the same
72
+ * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
73
+ *
74
+ * @param arrayBuffer - An `ArrayBuffer`, `SharedArrayBuffer`, for example the
75
+ * `.buffer` property of a `TypedArray`.
76
+ * @param byteOffset - Index of first byte to expose. **Default:** `0`.
77
+ * @param length - Number of bytes to expose. **Default:**
78
+ * `arrayBuffer.byteLength - byteOffset`.
79
+ *
80
+ * @privateRemarks
81
+ * Node buffer.buffer.d.ts declaration:
82
+ * ```
83
+ * public static from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(
84
+ * arrayBuffer: TArrayBuffer,
85
+ * byteOffset?: number,
86
+ * length?: number,
87
+ * ): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;
88
+ * ```
89
+ */
90
+ from<TArrayBuffer extends ArrayBufferLike>(arrayBuffer: TArrayBuffer, byteOffset?: number, length?: number): IsoBuffer<TArrayBuffer>;
91
+ isBuffer(obj: unknown): obj is IsoBuffer<ArrayBufferLike>;
92
+ }
93
+ //# sourceMappingURL=buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAC1B,MAAM,GAEN,OAAO,GACP,QAAQ,CAAC;AAEZ;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,YAAY,SAAS,eAAe,CAC9D,SAAQ,UAAU,CAAC,YAAY,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;CAC/C;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAE/C,KAAK,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAC7C,KAAK,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACvD,KAAK,YAAY,SAAS,eAAe,GAAG,WAAW,EACtD,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GACb,SAAS,CAAC,YAAY,CAAC,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3E;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAChD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAI,CAAC,YAAY,SAAS,eAAe,EACxC,WAAW,EAAE,YAAY,EACzB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GACb,SAAS,CAAC,YAAY,CAAC,CAAC;IAE3B,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC;CAC1D"}
package/lib/buffer.js ADDED
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Declare the subset of node:Buffer functionality we want to make available instead of\n * exposing the entirely of Node's typings. These serve as the public interface\n * of the browser and node implementation.\n */\n\n/**\n * Set of supported encodings for string to buffer conversion.\n *\n * @internal\n */\nexport type IsoBufferEncoding =\n\t| \"utf8\"\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- \"utf-8\" value is supported, just discouraged\n\t| \"utf-8\"\n\t| \"base64\";\n\n/**\n * Minimal Buffer interface for our usages in the browser or Node environments.\n *\n * @internal\n */\nexport interface IsoBuffer<TArrayBuffer extends ArrayBufferLike>\n\textends Uint8Array<TArrayBuffer> {\n\t/**\n\t * Convert the buffer to a string.\n\t * Only supports encoding the whole string (unlike the Node `Buffer` equivalent)\n\t * and only utf8 and base64 encodings.\n\t *\n\t * @param encoding - The encoding to use.\n\t */\n\ttoString(encoding?: IsoBufferEncoding): string;\n}\n\n/**\n * Constructor for {@link (IsoBuffer:type)}.\n *\n * @internal\n */\nexport interface IsoBufferConstructor {\n\treadonly prototype: IsoBuffer<ArrayBufferLike>;\n\n\tnew (length: number): IsoBuffer<ArrayBuffer>;\n\tnew (array: ArrayLike<number>): IsoBuffer<ArrayBuffer>;\n\tnew <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(\n\t\tbuffer: TArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tlength?: number,\n\t): IsoBuffer<TArrayBuffer>;\n\n\t/**\n\t * Creates a new `IsoBuffer` containing `string`. The `encoding` parameter identifies\n\t * the character encoding to be used when converting `string` into bytes.\n\t *\n\t * @param string - A string to encode.\n\t * @param encoding - The encoding of `string`. **Default:** `'utf8'`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * `from(string: WithImplicitCoercion<string>, encoding?: IsoBufferEncoding): Buffer<ArrayBuffer>;`\n\t */\n\tfrom(string: string, encoding?: IsoBufferEncoding): IsoBuffer<ArrayBuffer>;\n\t/**\n\t * Allocates a new `IsoBuffer` using an `array` of bytes in the range `0` – `255`.\n\t * Array entries outside that range will be truncated to fit into it.\n\t *\n\t * @param value - `Uint8Array`.\n\t *\n\t * @remarks\n\t * This is limited to `Uint8Array` input to match Node implementation that\n\t * takes `ArrayLike<number>` and returns `IsoBuffer<ArrayBuffer>`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * `from(array: WithImplicitCoercion<ArrayLike<number>>): IsoBuffer<ArrayBuffer>;`\n\t */\n\tfrom(array: Uint8Array): IsoBuffer<ArrayBuffer>;\n\t/**\n\t * This creates a view of the `ArrayBuffer` without copying the underlying\n\t * memory. For example, when passed a reference to the `.buffer` property of a\n\t * `TypedArray` instance, the newly created `Buffer` will share the same\n\t * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.\n\t *\n\t * @param arrayBuffer - An `ArrayBuffer`, `SharedArrayBuffer`, for example the\n\t * `.buffer` property of a `TypedArray`.\n\t * @param byteOffset - Index of first byte to expose. **Default:** `0`.\n\t * @param length - Number of bytes to expose. **Default:**\n\t * `arrayBuffer.byteLength - byteOffset`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * ```\n\t * public static from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(\n\t * \t\tarrayBuffer: TArrayBuffer,\n\t * \t\tbyteOffset?: number,\n\t * \t\tlength?: number,\n\t * ): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;\n\t * ```\n\t */\n\tfrom<TArrayBuffer extends ArrayBufferLike>(\n\t\tarrayBuffer: TArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tlength?: number,\n\t): IsoBuffer<TArrayBuffer>;\n\n\tisBuffer(obj: unknown): obj is IsoBuffer<ArrayBufferLike>;\n}\n"]}
@@ -2,9 +2,20 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { IsoBufferConstructor, IsoBufferEncoding, IsoBuffer as IsoBufferInterface } from "./buffer.js";
6
+ export type { IsoBufferConstructor, IsoBufferEncoding, } from "./buffer.js";
5
7
  /**
6
- * Converts a Uint8Array to a string of the provided encoding
7
- * Useful when the array might be an {@link IsoBuffer}.
8
+ * Minimal `Buffer` interface for our usages in the browser or Node.js environments.
9
+ *
10
+ * @internal
11
+ *
12
+ * @privateRemarks
13
+ * This type is exported specifically from here to respect combo type+value of same name rules.
14
+ */
15
+ export type IsoBuffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> = IsoBufferInterface<TArrayBuffer>;
16
+ /**
17
+ * Converts a `Uint8Array` to a string of the provided encoding
18
+ * Useful when the array might be an {@link (IsoBuffer:type)}.
8
19
  *
9
20
  * @param arr - The array to convert.
10
21
  * @param encoding - Optional target encoding; only "utf8" and "base64" are
@@ -13,7 +24,7 @@
13
24
  *
14
25
  * @internal
15
26
  */
16
- export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
27
+ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: IsoBufferEncoding): string;
17
28
  /**
18
29
  * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or
19
30
  * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.
@@ -22,7 +33,7 @@ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" |
22
33
  *
23
34
  * @internal
24
35
  */
25
- export declare const stringToBuffer: (input: string, encoding: string) => ArrayBuffer;
36
+ export declare const stringToBuffer: (input: string, encoding: IsoBufferEncoding) => ArrayBuffer;
26
37
  /**
27
38
  * Convert binary blob to string format
28
39
  *
@@ -32,53 +43,11 @@ export declare const stringToBuffer: (input: string, encoding: string) => ArrayB
32
43
  *
33
44
  * @internal
34
45
  */
35
- export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
36
- /**
37
- * Determines if an object is an array buffer.
38
- *
39
- * @remarks Will detect and reject TypedArrays, like Uint8Array.
40
- * Reason - they can be viewport into Array, they can be accepted, but caller has to deal with
41
- * math properly (i.e. Take into account byteOffset at minimum).
42
- * For example, construction of new TypedArray can be in the form of new TypedArray(typedArray) or
43
- * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and
44
- * ignoring byteOffice, length).
45
- *
46
- * @param obj - The object to determine if it is an ArrayBuffer.
47
- *
48
- * @internal
49
- */
50
- export declare function isArrayBuffer(obj: unknown): obj is ArrayBuffer;
46
+ export declare const bufferToString: (blob: ArrayBufferLike | Uint8Array, encoding: IsoBufferEncoding) => string;
51
47
  /**
52
- * Minimal implementation of Buffer for our usages in the browser environment.
48
+ * Minimal implementation of `Buffer` for our usages in the browser environment.
53
49
  *
54
50
  * @internal
55
51
  */
56
- export declare class IsoBuffer extends Uint8Array {
57
- /**
58
- * Convert the buffer to a string.
59
- * Only supports encoding the whole string (unlike the Node Buffer equivalent)
60
- * and only utf8 and base64 encodings.
61
- *
62
- * @param encoding - The encoding to use.
63
- */
64
- toString(encoding?: "utf8" | "utf-8" | "base64"): string;
65
- /**
66
- * Static constructor
67
- * @param value - (string | ArrayBuffer)
68
- * @param encodingOrOffset - (string | number)
69
- * @param length - (number)
70
- *
71
- * @privateRemarks TODO: Use actual types
72
- */
73
- static from(value: any, encodingOrOffset?: any, length?: any): IsoBuffer;
74
- static fromArrayBuffer(arrayBuffer: ArrayBuffer, byteOffset?: number, byteLength?: number): IsoBuffer;
75
- static fromString(str: string, encoding?: string): IsoBuffer;
76
- static isBuffer(obj: unknown): boolean;
77
- /**
78
- * Sanitize a base64 string to provide to base64-js library.
79
- * {@link https://www.npmjs.com/package/base64-js} is not as tolerant of the same malformed base64 as Node'
80
- * Buffer is.
81
- */
82
- private static sanitizeBase64;
83
- }
52
+ export declare const IsoBuffer: IsoBufferConstructor;
84
53
  //# sourceMappingURL=bufferBrowser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bufferBrowser.d.ts","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,UAAU,EAEf,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GACpC,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,YAAY,MAAM,KAAG,WAC1B,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,SACpB,eAAe,YAEX,MAAM,GAAG,OAAO,GAAG,QAAQ,KACnC,MAAiD,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAW9D;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACxC;;;;;;OAMG;IAEI,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,M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
4
  */
5
5
  import * as base64js from "base64-js";
6
6
  /**
7
- * Converts a Uint8Array to a string of the provided encoding
8
- * Useful when the array might be an {@link IsoBuffer}.
7
+ * Converts a `Uint8Array` to a string of the provided encoding
8
+ * Useful when the array might be an {@link (IsoBuffer:type)}.
9
9
  *
10
10
  * @param arr - The array to convert.
11
11
  * @param encoding - Optional target encoding; only "utf8" and "base64" are
@@ -14,9 +14,7 @@ import * as base64js from "base64-js";
14
14
  *
15
15
  * @internal
16
16
  */
17
- export function Uint8ArrayToString(arr,
18
- // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
19
- encoding) {
17
+ export function Uint8ArrayToString(arr, encoding) {
20
18
  switch (encoding) {
21
19
  case "base64": {
22
20
  return base64js.fromByteArray(arr);
@@ -50,9 +48,7 @@ export const stringToBuffer = (input, encoding) => IsoBuffer.from(input, encodin
50
48
  *
51
49
  * @internal
52
50
  */
53
- export const bufferToString = (blob,
54
- // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
55
- encoding) => IsoBuffer.from(blob).toString(encoding);
51
+ export const bufferToString = (blob, encoding) => Uint8ArrayToString(blob instanceof Uint8Array ? blob : IsoBuffer.from(blob), encoding);
56
52
  /**
57
53
  * Determines if an object is an array buffer.
58
54
  *
@@ -63,11 +59,15 @@ encoding) => IsoBuffer.from(blob).toString(encoding);
63
59
  * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and
64
60
  * ignoring byteOffice, length).
65
61
  *
66
- * @param obj - The object to determine if it is an ArrayBuffer.
62
+ * @param obj - The object to determine if it is `ArrayBufferLike`.
67
63
  *
68
- * @internal
64
+ * @privateRemarks
65
+ * This function preserves runtime functionality as it has been in the past.
66
+ * Typing has been adjusted to reflect the only use that remains and (assuming
67
+ * is called as expected) will always return true as the input is already
68
+ * expected to be `ArrayBufferLike`.
69
69
  */
70
- export function isArrayBuffer(obj) {
70
+ function isArrayBufferLike(obj) {
71
71
  const maybe = obj;
72
72
  return (obj instanceof ArrayBuffer ||
73
73
  (typeof maybe === "object" &&
@@ -78,49 +78,36 @@ export function isArrayBuffer(obj) {
78
78
  maybe.buffer === undefined));
79
79
  }
80
80
  /**
81
- * Minimal implementation of Buffer for our usages in the browser environment.
81
+ * Minimal implementation of `Buffer` for our usages in the browser environment.
82
82
  *
83
83
  * @internal
84
84
  */
85
- export class IsoBuffer extends Uint8Array {
86
- /**
87
- * Convert the buffer to a string.
88
- * Only supports encoding the whole string (unlike the Node Buffer equivalent)
89
- * and only utf8 and base64 encodings.
90
- *
91
- * @param encoding - The encoding to use.
92
- */
93
- // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
85
+ // eslint-disable-next-line @typescript-eslint/no-shadow -- Preserve the public constructor name at runtime.
86
+ export const IsoBuffer = class IsoBuffer extends Uint8Array {
87
+ constructor(value, byteOffset, length) {
88
+ super(value, byteOffset, length);
89
+ }
94
90
  toString(encoding) {
95
91
  return Uint8ArrayToString(this, encoding);
96
92
  }
97
- /**
98
- * Static constructor
99
- * @param value - (string | ArrayBuffer)
100
- * @param encodingOrOffset - (string | number)
101
- * @param length - (number)
102
- *
103
- * @privateRemarks TODO: Use actual types
104
- */
105
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
106
93
  static from(value, encodingOrOffset, length) {
107
94
  if (typeof value === "string") {
108
95
  return IsoBuffer.fromString(value, encodingOrOffset);
109
96
  // Capture any typed arrays, including Uint8Array (and thus - IsoBuffer!)
110
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
111
97
  }
112
- else if (value !== null && typeof value === "object" && isArrayBuffer(value.buffer)) {
98
+ else if (value instanceof Uint8Array) {
113
99
  // The version of the from function for the node buffer, which takes a buffer or typed array
114
100
  // as first parameter, does not have any offset or length parameters. Those are just silently
115
101
  // ignored and not taken into account
116
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
117
- return IsoBuffer.fromArrayBuffer(value.buffer, value.byteOffset, value.byteLength);
102
+ const copy = new Uint8Array(value.byteLength);
103
+ copy.set(value);
104
+ return new IsoBuffer(copy.buffer);
118
105
  }
119
- else if (isArrayBuffer(value)) {
106
+ else if (isArrayBufferLike(value)) {
120
107
  return IsoBuffer.fromArrayBuffer(value, encodingOrOffset, length);
121
108
  }
122
109
  else {
123
- throw new TypeError("Input value was neither a string nor an ArrayBuffer.");
110
+ throw new TypeError("Input value was neither a string, a Uint8Array, nor an ArrayBuffer.");
124
111
  }
125
112
  }
126
113
  static fromArrayBuffer(arrayBuffer, byteOffset, byteLength) {
@@ -138,15 +125,17 @@ export class IsoBuffer extends Uint8Array {
138
125
  switch (encoding) {
139
126
  case "base64": {
140
127
  const sanitizedString = this.sanitizeBase64(str);
128
+ // base64-js will always return a Uint8Array<ArrayBuffer>, but typing has not
129
+ // been updated to reflect that yet. Cast to the correct type here.
141
130
  const encoded = base64js.toByteArray(sanitizedString);
142
- return new IsoBuffer(encoded.buffer);
131
+ return new IsoBuffer(encoded.buffer, encoded.byteOffset, encoded.byteLength);
143
132
  }
144
133
  case "utf8":
145
134
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
146
135
  case "utf-8":
147
136
  case undefined: {
148
137
  const encoded = new TextEncoder().encode(str);
149
- return new IsoBuffer(encoded.buffer);
138
+ return new IsoBuffer(encoded.buffer, encoded.byteOffset, encoded.byteLength);
150
139
  }
151
140
  default: {
152
141
  throw new Error("invalid/unsupported encoding");
@@ -154,7 +143,7 @@ export class IsoBuffer extends Uint8Array {
154
143
  }
155
144
  }
156
145
  static isBuffer(obj) {
157
- throw new Error("unimplemented");
146
+ return obj instanceof IsoBuffer;
158
147
  }
159
148
  /**
160
149
  * Sanitize a base64 string to provide to base64-js library.
@@ -177,5 +166,5 @@ export class IsoBuffer extends Uint8Array {
177
166
  }
178
167
  return sanitizedStr;
179
168
  }
180
- }
169
+ };
181
170
  //# sourceMappingURL=bufferBrowser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xC,IAAI,YAAY,GAAG,GAAG,CAAC;QACvB,mEAAmE;QACnE,+CAA+C;QAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,oEAAoE;QACpE,2CAA2C;QAC3C,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAErD,oEAAoE;QACpE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5C,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;CACD","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\";\n\n/**\n * Converts a Uint8Array to a string of the provided encoding\n * Useful when the array might be an {@link IsoBuffer}.\n *\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(\n\tarr: Uint8Array,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding?: \"utf8\" | \"utf-8\" | \"base64\",\n): string {\n\tswitch (encoding) {\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(arr);\n\t\t}\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\":\n\t\tcase undefined: {\n\t\t\treturn new TextDecoder().decode(arr);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or\n * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.\n *\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport const stringToBuffer = (input: string, encoding: string): ArrayBuffer =>\n\tIsoBuffer.from(input, encoding).buffer;\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - the binary blob\n * @param encoding - output string's encoding\n * @returns the blob in string format\n *\n * @internal\n */\nexport const bufferToString = (\n\tblob: ArrayBufferLike,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding: \"utf8\" | \"utf-8\" | \"base64\",\n): string => IsoBuffer.from(blob).toString(encoding);\n\n/**\n * Determines if an object is an array buffer.\n *\n * @remarks Will detect and reject TypedArrays, like Uint8Array.\n * Reason - they can be viewport into Array, they can be accepted, but caller has to deal with\n * math properly (i.e. Take into account byteOffset at minimum).\n * For example, construction of new TypedArray can be in the form of new TypedArray(typedArray) or\n * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and\n * ignoring byteOffice, length).\n *\n * @param obj - The object to determine if it is an ArrayBuffer.\n *\n * @internal\n */\nexport function isArrayBuffer(obj: unknown): obj is ArrayBuffer {\n\tconst maybe = obj as (Partial<ArrayBuffer> & Partial<Uint8Array>) | undefined;\n\treturn (\n\t\tobj instanceof ArrayBuffer ||\n\t\t(typeof maybe === \"object\" &&\n\t\t\tmaybe !== null &&\n\t\t\ttypeof maybe.byteLength === \"number\" &&\n\t\t\ttypeof maybe.slice === \"function\" &&\n\t\t\tmaybe.byteOffset === undefined &&\n\t\t\tmaybe.buffer === undefined)\n\t);\n}\n\n/**\n * Minimal implementation of Buffer for our usages in the browser environment.\n *\n * @internal\n */\nexport class IsoBuffer extends Uint8Array {\n\t/**\n\t * Convert the buffer to a string.\n\t * Only supports encoding the whole string (unlike the Node Buffer equivalent)\n\t * and only utf8 and base64 encodings.\n\t *\n\t * @param encoding - The encoding to use.\n\t */\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tpublic toString(encoding?: \"utf8\" | \"utf-8\" | \"base64\"): string {\n\t\treturn Uint8ArrayToString(this, encoding);\n\t}\n\n\t/**\n\t * Static constructor\n\t * @param value - (string | ArrayBuffer)\n\t * @param encodingOrOffset - (string | number)\n\t * @param length - (number)\n\t *\n\t * @privateRemarks TODO: Use actual types\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tpublic static from(value: any, encodingOrOffset?: any, length?: any): IsoBuffer {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn IsoBuffer.fromString(value, encodingOrOffset as string | undefined);\n\t\t\t// Capture any typed arrays, including Uint8Array (and thus - IsoBuffer!)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t} else if (value !== null && typeof value === \"object\" && isArrayBuffer(value.buffer)) {\n\t\t\t// The version of the from function for the node buffer, which takes a buffer or typed array\n\t\t\t// as first parameter, does not have any offset or length parameters. Those are just silently\n\t\t\t// ignored and not taken into account\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n\t\t\treturn IsoBuffer.fromArrayBuffer(value.buffer, value.byteOffset, value.byteLength);\n\t\t} else if (isArrayBuffer(value)) {\n\t\t\treturn IsoBuffer.fromArrayBuffer(\n\t\t\t\tvalue,\n\t\t\t\tencodingOrOffset as number | undefined,\n\t\t\t\tlength as number,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new TypeError(\"Input value was neither a string nor an ArrayBuffer.\");\n\t\t}\n\t}\n\n\tpublic static fromArrayBuffer(\n\t\tarrayBuffer: ArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tbyteLength?: number,\n\t): IsoBuffer {\n\t\tconst offset = byteOffset ?? 0;\n\t\tconst validLength = byteLength ?? arrayBuffer.byteLength - offset;\n\t\tif (\n\t\t\toffset < 0 ||\n\t\t\toffset > arrayBuffer.byteLength ||\n\t\t\tvalidLength < 0 ||\n\t\t\tvalidLength + offset > arrayBuffer.byteLength\n\t\t) {\n\t\t\tthrow new RangeError(\"Invalid range specified.\");\n\t\t}\n\n\t\treturn new IsoBuffer(arrayBuffer, offset, validLength);\n\t}\n\n\tpublic static fromString(str: string, encoding?: string): IsoBuffer {\n\t\tswitch (encoding) {\n\t\t\tcase \"base64\": {\n\t\t\t\tconst sanitizedString = this.sanitizeBase64(str);\n\t\t\t\tconst encoded = base64js.toByteArray(sanitizedString);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tcase \"utf8\":\n\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\t\tcase \"utf-8\":\n\t\t\tcase undefined: {\n\t\t\t\tconst encoded = new TextEncoder().encode(str);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static isBuffer(obj: unknown): boolean {\n\t\tthrow new Error(\"unimplemented\");\n\t}\n\n\t/**\n\t * Sanitize a base64 string to provide to base64-js library.\n\t * {@link https://www.npmjs.com/package/base64-js} is not as tolerant of the same malformed base64 as Node'\n\t * Buffer is.\n\t */\n\tprivate static sanitizeBase64(str: string): string {\n\t\tlet sanitizedStr = str;\n\t\t// Remove everything after padding - Node buffer ignores everything\n\t\t// after any padding whereas base64-js does not\n\t\tsanitizedStr = sanitizedStr.split(\"=\")[0];\n\n\t\t// Remove invalid characters - Node buffer strips invalid characters\n\t\t// whereas base64-js replaces them with \"A\"\n\t\tsanitizedStr = sanitizedStr.replace(/[^\\w+-/]/g, \"\");\n\n\t\t// Check for missing padding - Node buffer tolerates missing padding\n\t\t// whereas base64-js does not\n\t\tif (sanitizedStr.length % 4 !== 0) {\n\t\t\tconst paddingArray = [\"\", \"===\", \"==\", \"=\"];\n\t\t\tsanitizedStr += paddingArray[sanitizedStr.length % 4];\n\t\t}\n\t\treturn sanitizedStr;\n\t}\n}\n"]}
1
+ {"version":3,"file":"bufferBrowser.js","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAuBtC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAe,EAAE,QAA4B;IAC/E,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC;QACb,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,QAA2B,EAAe,EAAE,CACzF,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,IAAkC,EAClC,QAA2B,EAClB,EAAE,CACX,kBAAkB,CAAC,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AAExF;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,iBAAiB,CAAC,GAAoB;IAC9C,MAAM,KAAK,GAAG,GAAm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C,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC9E,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACjD,CAAC;QACF,CAAC;IACF,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,GAAY;QAClC,OAAO,GAAG,YAAY,SAAS,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,cAAc,CAAC,GAAW;QACxC,IAAI,YAAY,GAAG,GAAG,CAAC;QACvB,mEAAmE;QACnE,+CAA+C;QAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,oEAAoE;QACpE,2CAA2C;QAC3C,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAErD,oEAAoE;QACpE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5C,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;CAC8B,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\";\n\nimport type {\n\tIsoBufferConstructor,\n\tIsoBufferEncoding,\n\tIsoBuffer as IsoBufferInterface,\n} from \"./buffer.js\";\n\nexport type {\n\tIsoBufferConstructor,\n\tIsoBufferEncoding,\n} from \"./buffer.js\";\n/**\n * Minimal `Buffer` interface for our usages in the browser or Node.js environments.\n *\n * @internal\n *\n * @privateRemarks\n * This type is exported specifically from here to respect combo type+value of same name rules.\n */\nexport type IsoBuffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =\n\tIsoBufferInterface<TArrayBuffer>;\n\n/**\n * Converts a `Uint8Array` to a string of the provided encoding\n * Useful when the array might be an {@link (IsoBuffer:type)}.\n *\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(arr: Uint8Array, encoding?: IsoBufferEncoding): string {\n\tswitch (encoding) {\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(arr);\n\t\t}\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\":\n\t\tcase undefined: {\n\t\t\treturn new TextDecoder().decode(arr);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or\n * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.\n *\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport const stringToBuffer = (input: string, encoding: IsoBufferEncoding): ArrayBuffer =>\n\tIsoBuffer.from(input, encoding).buffer;\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - the binary blob\n * @param encoding - output string's encoding\n * @returns the blob in string format\n *\n * @internal\n */\nexport const bufferToString = (\n\tblob: ArrayBufferLike | Uint8Array,\n\tencoding: IsoBufferEncoding,\n): string =>\n\tUint8ArrayToString(blob instanceof Uint8Array ? blob : IsoBuffer.from(blob), encoding);\n\n/**\n * Determines if an object is an array buffer.\n *\n * @remarks Will detect and reject TypedArrays, like Uint8Array.\n * Reason - they can be viewport into Array, they can be accepted, but caller has to deal with\n * math properly (i.e. Take into account byteOffset at minimum).\n * For example, construction of new TypedArray can be in the form of new TypedArray(typedArray) or\n * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and\n * ignoring byteOffice, length).\n *\n * @param obj - The object to determine if it is `ArrayBufferLike`.\n *\n * @privateRemarks\n * This function preserves runtime functionality as it has been in the past.\n * Typing has been adjusted to reflect the only use that remains and (assuming\n * is called as expected) will always return true as the input is already\n * expected to be `ArrayBufferLike`.\n */\nfunction isArrayBufferLike(obj: ArrayBufferLike): obj is ArrayBufferLike {\n\tconst maybe = obj as (Partial<ArrayBufferLike> & Partial<Uint8Array>) | undefined;\n\treturn (\n\t\tobj instanceof ArrayBuffer ||\n\t\t(typeof maybe === \"object\" &&\n\t\t\tmaybe !== null &&\n\t\t\ttypeof maybe.byteLength === \"number\" &&\n\t\t\ttypeof maybe.slice === \"function\" &&\n\t\t\tmaybe.byteOffset === undefined &&\n\t\t\tmaybe.buffer === undefined)\n\t);\n}\n\n/**\n * Minimal implementation of `Buffer` for our usages in the browser environment.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-shadow -- Preserve the public constructor name at runtime.\nexport const IsoBuffer: IsoBufferConstructor = class IsoBuffer<\n\t\tTArrayBuffer extends ArrayBufferLike = ArrayBufferLike,\n\t>\n\textends Uint8Array<TArrayBuffer>\n\timplements IsoBufferInterface<TArrayBuffer>\n{\n\tpublic constructor(\n\t\tvalue: number | ArrayLike<number> | TArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tlength?: number,\n\t) {\n\t\tsuper(value as TArrayBuffer, byteOffset, length);\n\t}\n\n\tpublic toString(encoding?: IsoBufferEncoding): string {\n\t\treturn Uint8ArrayToString(this, encoding);\n\t}\n\n\tpublic static from(\n\t\tvalue: string,\n\t\tencoding?: IsoBufferEncoding,\n\t): IsoBufferInterface<ArrayBuffer>;\n\tpublic static from(value: Uint8Array): IsoBufferInterface<ArrayBuffer>;\n\tpublic static from<TFArrayBuffer extends ArrayBufferLike>(\n\t\tvalue: TFArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tlength?: number,\n\t): IsoBufferInterface<TFArrayBuffer>;\n\tpublic static from<TFArrayBuffer extends ArrayBufferLike>(\n\t\tvalue: string | Uint8Array | TFArrayBuffer,\n\t\tencodingOrOffset?: IsoBufferEncoding | number,\n\t\tlength?: number,\n\t): IsoBufferInterface<ArrayBufferLike> {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn IsoBuffer.fromString(\n\t\t\t\tvalue,\n\t\t\t\tencodingOrOffset as IsoBufferEncoding | undefined,\n\t\t\t) satisfies IsoBufferInterface<ArrayBuffer>;\n\t\t\t// Capture any typed arrays, including Uint8Array (and thus - IsoBuffer!)\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\t// The version of the from function for the node buffer, which takes a buffer or typed array\n\t\t\t// as first parameter, does not have any offset or length parameters. Those are just silently\n\t\t\t// ignored and not taken into account\n\t\t\tconst copy = new Uint8Array(value.byteLength);\n\t\t\tcopy.set(value);\n\t\t\treturn new IsoBuffer<ArrayBuffer>(copy.buffer) satisfies IsoBufferInterface<ArrayBuffer>;\n\t\t} else if (isArrayBufferLike(value)) {\n\t\t\treturn IsoBuffer.fromArrayBuffer(value, encodingOrOffset as number | undefined, length);\n\t\t} else {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Input value was neither a string, a Uint8Array, nor an ArrayBuffer.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static fromArrayBuffer<TFArrayBuffer extends ArrayBufferLike>(\n\t\tarrayBuffer: TFArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tbyteLength?: number,\n\t): IsoBufferInterface<TFArrayBuffer> {\n\t\tconst offset = byteOffset ?? 0;\n\t\tconst validLength = byteLength ?? arrayBuffer.byteLength - offset;\n\t\tif (\n\t\t\toffset < 0 ||\n\t\t\toffset > arrayBuffer.byteLength ||\n\t\t\tvalidLength < 0 ||\n\t\t\tvalidLength + offset > arrayBuffer.byteLength\n\t\t) {\n\t\t\tthrow new RangeError(\"Invalid range specified.\");\n\t\t}\n\n\t\treturn new IsoBuffer<TFArrayBuffer>(arrayBuffer, offset, validLength);\n\t}\n\n\tpublic static fromString(\n\t\tstr: string,\n\t\tencoding?: IsoBufferEncoding,\n\t): IsoBufferInterface<ArrayBuffer> {\n\t\tswitch (encoding) {\n\t\t\tcase \"base64\": {\n\t\t\t\tconst sanitizedString = this.sanitizeBase64(str);\n\t\t\t\t// base64-js will always return a Uint8Array<ArrayBuffer>, but typing has not\n\t\t\t\t// been updated to reflect that yet. Cast to the correct type here.\n\t\t\t\tconst encoded = base64js.toByteArray(sanitizedString) as Uint8Array<ArrayBuffer>;\n\t\t\t\treturn new IsoBuffer(encoded.buffer, encoded.byteOffset, encoded.byteLength);\n\t\t\t}\n\t\t\tcase \"utf8\":\n\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\t\tcase \"utf-8\":\n\t\t\tcase undefined: {\n\t\t\t\tconst encoded = new TextEncoder().encode(str);\n\t\t\t\treturn new IsoBuffer(encoded.buffer, encoded.byteOffset, encoded.byteLength);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static isBuffer(obj: unknown): obj is IsoBuffer {\n\t\treturn obj instanceof IsoBuffer;\n\t}\n\n\t/**\n\t * Sanitize a base64 string to provide to base64-js library.\n\t * {@link https://www.npmjs.com/package/base64-js} is not as tolerant of the same malformed base64 as Node'\n\t * Buffer is.\n\t */\n\tprivate static sanitizeBase64(str: string): string {\n\t\tlet sanitizedStr = str;\n\t\t// Remove everything after padding - Node buffer ignores everything\n\t\t// after any padding whereas base64-js does not\n\t\tsanitizedStr = sanitizedStr.split(\"=\")[0];\n\n\t\t// Remove invalid characters - Node buffer strips invalid characters\n\t\t// whereas base64-js replaces them with \"A\"\n\t\tsanitizedStr = sanitizedStr.replace(/[^\\w+-/]/g, \"\");\n\n\t\t// Check for missing padding - Node buffer tolerates missing padding\n\t\t// whereas base64-js does not\n\t\tif (sanitizedStr.length % 4 !== 0) {\n\t\t\tconst paddingArray = [\"\", \"===\", \"==\", \"=\"];\n\t\t\tsanitizedStr += paddingArray[sanitizedStr.length % 4];\n\t\t}\n\t\treturn sanitizedStr;\n\t}\n} satisfies IsoBufferConstructor;\n"]}
@@ -2,38 +2,86 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { IsoBufferConstructor, IsoBufferEncoding, IsoBuffer as IsoBufferInterface } from "./buffer.js";
6
+ export type { IsoBufferConstructor, IsoBufferEncoding } from "./buffer.js";
7
+ /**
8
+ * Minimal `Buffer` interface for our usages in the browser or Node.js environments.
9
+ *
10
+ * @internal
11
+ *
12
+ * @privateRemarks
13
+ * This type is exported specifically from here to respect combo type+value of same name rules.
14
+ */
15
+ export type IsoBuffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> = IsoBufferInterface<TArrayBuffer>;
5
16
  /**
6
17
  * Declare the subset of Buffer functionality we want to make available instead of
7
18
  * exposing the entirely of Node's typings. This should match the public interface
8
- * of the browser implementation, so any changes made in one should be made in both.
19
+ * of the browser implementation -- see {@link (IsoBuffer:type)} and {@link IsoBufferConstructor}.
9
20
  *
10
21
  * @internal
11
22
  */
12
- export declare class Buffer extends Uint8Array {
13
- toString(encoding?: "utf8" | "utf-8" | "base64"): string;
23
+ export declare class Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> implements IsoBuffer<TArrayBuffer> {
24
+ /**
25
+ * Creates a new `IsoBuffer` containing `string`. The `encoding` parameter identifies
26
+ * the character encoding to be used when converting `string` into bytes.
27
+ *
28
+ * @param string - A string to encode.
29
+ * @param encoding - The encoding of `string`. **Default:** `'utf8'`.
30
+ *
31
+ * @privateRemarks
32
+ * Node buffer.buffer.d.ts declaration:
33
+ * `from(string: WithImplicitCoercion<string>, encoding?: IsoBufferEncoding): Buffer<ArrayBuffer>;`
34
+ */
35
+ static from(string: string, encoding?: IsoBufferEncoding): IsoBuffer<ArrayBuffer>;
14
36
  /**
15
- * Static constructor
37
+ * Allocates a new `IsoBuffer` using an `array` of bytes in the range `0` – `255`.
38
+ * Array entries outside that range will be truncated to fit into it.
16
39
  *
17
- * @param value - (string | ArrayBuffer).
18
- * @param encodingOrOffset - (string | number).
19
- * @param length - (number).
40
+ * @param value - `Uint8Array`.
20
41
  *
21
- * @privateRemarks TODO: Use actual types
42
+ * @remarks
43
+ * This is limited to `Uint8Array` input to match Node implementation that
44
+ * takes `ArrayLike<number>` and returns `IsoBuffer<ArrayBuffer>`.
45
+ *
46
+ * @privateRemarks
47
+ * Node buffer.buffer.d.ts declaration:
48
+ * `from(array: WithImplicitCoercion<ArrayLike<number>>): IsoBuffer<ArrayBuffer>;`
49
+ */
50
+ static from(array: Uint8Array): IsoBuffer<ArrayBuffer>;
51
+ /**
52
+ * This creates a view of the `ArrayBuffer` without copying the underlying
53
+ * memory. For example, when passed a reference to the `.buffer` property of a
54
+ * `TypedArray` instance, the newly created `Buffer` will share the same
55
+ * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
56
+ *
57
+ * @param arrayBuffer - An `ArrayBuffer`, `SharedArrayBuffer`, for example the
58
+ * `.buffer` property of a `TypedArray`.
59
+ * @param byteOffset - Index of first byte to expose. **Default:** `0`.
60
+ * @param length - Number of bytes to expose. **Default:**
61
+ * `arrayBuffer.byteLength - byteOffset`.
62
+ *
63
+ * @privateRemarks
64
+ * Node buffer.buffer.d.ts declaration:
65
+ * ```
66
+ * public static from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(
67
+ * arrayBuffer: TArrayBuffer,
68
+ * byteOffset?: number,
69
+ * length?: number,
70
+ * ): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;
71
+ * ```
22
72
  */
23
- static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
73
+ static from<TArrayBuffer extends ArrayBufferLike>(arrayBuffer: TArrayBuffer, byteOffset?: number, length?: number): IsoBuffer<TArrayBuffer>;
24
74
  static isBuffer(obj: unknown): obj is Buffer;
25
75
  }
26
76
  /**
77
+ * The native Node.js Buffer implementation.
78
+ *
27
79
  * @internal
28
80
  */
29
- export declare const IsoBuffer: typeof Buffer;
30
- /**
31
- * @internal
32
- */
33
- export type IsoBuffer = Buffer;
81
+ export declare const IsoBuffer: IsoBufferConstructor;
34
82
  /**
35
- * Converts a Uint8Array to a string of the provided encoding.
36
- * @remarks Useful when the array might be an IsoBuffer.
83
+ * Converts a `Uint8Array` to a string of the provided encoding.
84
+ * @remarks Useful when the array might be an `IsoBuffer`.
37
85
  * @param arr - The array to convert.
38
86
  * @param encoding - Optional target encoding; only "utf8" and "base64" are
39
87
  * supported, with "utf8" being default.
@@ -41,14 +89,14 @@ export type IsoBuffer = Buffer;
41
89
  *
42
90
  * @internal
43
91
  */
44
- export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
92
+ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: IsoBufferEncoding): string;
45
93
  /**
46
94
  * Convert base64 or utf8 string to array buffer.
47
95
  * @param encoding - The input string's encoding.
48
96
  *
49
97
  * @internal
50
98
  */
51
- export declare function stringToBuffer(input: string, encoding: string): ArrayBuffer;
99
+ export declare function stringToBuffer(input: string, encoding: IsoBufferEncoding): ArrayBuffer;
52
100
  /**
53
101
  * Convert binary blob to string format
54
102
  *
@@ -58,5 +106,5 @@ export declare function stringToBuffer(input: string, encoding: string): ArrayBu
58
106
  *
59
107
  * @internal
60
108
  */
61
- export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
109
+ export declare const bufferToString: (blob: ArrayBufferLike | Uint8Array, encoding: IsoBufferEncoding) => string;
62
110
  //# sourceMappingURL=bufferNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bufferNode.d.ts","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,MA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