@comate/zulu 0.0.9 → 0.0.12
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 +98 -0
- package/comate-engine/bin/comate.js +10 -0
- package/comate-engine/fallbackServer.js +1 -0
- package/comate-engine/node_modules/@comate/plugin-engine/dist/index.d.ts +188 -0
- package/comate-engine/node_modules/@comate/plugin-engine/dist/index.js +36 -0
- package/comate-engine/node_modules/@comate/plugin-engine/package.json +49 -0
- package/comate-engine/node_modules/@comate/plugin-host/bin.js +44 -0
- package/comate-engine/node_modules/@comate/plugin-host/dist/index.js +1 -0
- package/comate-engine/node_modules/@comate/plugin-host/dist/main.d.ts +14 -0
- package/comate-engine/node_modules/@comate/plugin-host/dist/main.js +9 -0
- package/comate-engine/node_modules/@comate/plugin-host/dist/user-Btg63hPI.js +36 -0
- package/comate-engine/node_modules/@comate/plugin-host/package.json +47 -0
- package/comate-engine/node_modules/@comate/plugin-shared-internals/dist/index.d.ts +2849 -0
- package/comate-engine/node_modules/@comate/plugin-shared-internals/dist/index.js +36 -0
- package/comate-engine/node_modules/@comate/plugin-shared-internals/package.json +72 -0
- package/comate-engine/node_modules/@comate/preview-proxy/bin/preview.js +13 -0
- package/comate-engine/node_modules/@comate/preview-proxy/dist/index.js +350 -0
- package/comate-engine/node_modules/@comate/preview-proxy/package.json +83 -0
- package/comate-engine/node_modules/@comate/preview-proxy/static/comate-preview-injector.css +1 -0
- package/comate-engine/node_modules/@comate/preview-proxy/static/comate-preview-injector.js +2 -0
- package/comate-engine/node_modules/@comate/preview-proxy/static/comate-preview-injector.js.LICENSE.txt +58 -0
- package/comate-engine/node_modules/compare-versions/LICENSE +21 -0
- package/comate-engine/node_modules/compare-versions/README.md +133 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compare.d.ts +19 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compare.js +44 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compare.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compareVersions.d.ts +8 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compareVersions.js +29 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/compareVersions.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/index.d.ts +5 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/index.js +5 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/index.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/satisfies.d.ts +14 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/satisfies.js +66 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/satisfies.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/utils.d.ts +7 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/utils.js +37 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/utils.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/validate.d.ts +28 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/validate.js +31 -0
- package/comate-engine/node_modules/compare-versions/lib/esm/validate.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/lib/umd/index.js +216 -0
- package/comate-engine/node_modules/compare-versions/lib/umd/index.js.map +1 -0
- package/comate-engine/node_modules/compare-versions/package.json +45 -0
- package/comate-engine/node_modules/compare-versions/src/compare.ts +54 -0
- package/comate-engine/node_modules/compare-versions/src/compareVersions.ts +31 -0
- package/comate-engine/node_modules/compare-versions/src/index.ts +5 -0
- package/comate-engine/node_modules/compare-versions/src/satisfies.ts +69 -0
- package/comate-engine/node_modules/compare-versions/src/utils.ts +50 -0
- package/comate-engine/node_modules/compare-versions/src/validate.ts +36 -0
- package/comate-engine/node_modules/pkce-challenge/LICENSE +21 -0
- package/comate-engine/node_modules/pkce-challenge/README.md +55 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.browser.d.ts +19 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.browser.js +72 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.node.cjs +80 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.node.d.cts +19 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.node.d.ts +19 -0
- package/comate-engine/node_modules/pkce-challenge/dist/index.node.js +75 -0
- package/comate-engine/node_modules/pkce-challenge/package.json +58 -0
- package/comate-engine/node_modules/web-streams-polyfill/LICENSE +22 -0
- package/comate-engine/node_modules/web-streams-polyfill/README.md +119 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/polyfill.es5.js +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/polyfill.js +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/ponyfill.es5.js +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/ponyfill.es5.mjs +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/ponyfill.js +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/dist/ponyfill.mjs +8 -0
- package/comate-engine/node_modules/web-streams-polyfill/package.json +98 -0
- package/comate-engine/node_modules/web-streams-polyfill/types/polyfill.d.ts +28 -0
- package/comate-engine/node_modules/web-streams-polyfill/types/ponyfill.d.ts +809 -0
- package/comate-engine/node_modules/web-streams-polyfill/types/tsdoc-metadata.json +11 -0
- package/comate-engine/package.json +94 -0
- package/comate-engine/plugins/aiscan/assets/icon.svg +12 -0
- package/comate-engine/plugins/aiscan/dist/index.js +53861 -0
- package/comate-engine/plugins/aiscan/package.json +67 -0
- package/comate-engine/plugins/appdev/assets/icon.png +0 -0
- package/comate-engine/plugins/appdev/dist/help.md +12 -0
- package/comate-engine/plugins/appdev/dist/index.d.ts +2 -0
- package/comate-engine/plugins/appdev/dist/index.js +194 -0
- package/comate-engine/plugins/appdev/dist/providers/err.d.ts +8 -0
- package/comate-engine/plugins/appdev/dist/providers/err.js +37 -0
- package/comate-engine/plugins/appdev/dist/providers/fallback.d.ts +5 -0
- package/comate-engine/plugins/appdev/dist/providers/fallback.js +28 -0
- package/comate-engine/plugins/appdev/dist/providers/help.d.ts +8 -0
- package/comate-engine/plugins/appdev/dist/providers/help.js +19 -0
- package/comate-engine/plugins/appdev/dist/providers/medusa.d.ts +8 -0
- package/comate-engine/plugins/appdev/dist/providers/medusa.js +39 -0
- package/comate-engine/plugins/appdev/dist/providers/qa.d.ts +8 -0
- package/comate-engine/plugins/appdev/dist/providers/qa.js +33 -0
- package/comate-engine/plugins/appdev/package.json +67 -0
- package/comate-engine/plugins/bfc/assets/bfc-icon.png +0 -0
- package/comate-engine/plugins/bfc/dist/config/config.d.ts +4 -0
- package/comate-engine/plugins/bfc/dist/config/config.js +4 -0
- package/comate-engine/plugins/bfc/dist/help.md +11 -0
- package/comate-engine/plugins/bfc/dist/index.d.ts +2 -0
- package/comate-engine/plugins/bfc/dist/index.js +452 -0
- package/comate-engine/plugins/bfc/dist/providers/bfcInstructMode.d.ts +8 -0
- package/comate-engine/plugins/bfc/dist/providers/bfcInstructMode.js +77 -0
- package/comate-engine/plugins/bfc/dist/providers/genAbnormalCode.d.ts +8 -0
- package/comate-engine/plugins/bfc/dist/providers/genAbnormalCode.js +71 -0
- package/comate-engine/plugins/bfc/dist/providers/genBfcCode.d.ts +8 -0
- package/comate-engine/plugins/bfc/dist/providers/genBfcCode.js +74 -0
- package/comate-engine/plugins/bfc/dist/providers/getBatchCases.d.ts +10 -0
- package/comate-engine/plugins/bfc/dist/providers/getBatchCases.js +71 -0
- package/comate-engine/plugins/bfc/dist/providers/help.d.ts +8 -0
- package/comate-engine/plugins/bfc/dist/providers/help.js +19 -0
- package/comate-engine/plugins/bfc/dist/service/generateService.d.ts +14 -0
- package/comate-engine/plugins/bfc/dist/service/generateService.js +27 -0
- package/comate-engine/plugins/bfc/package.json +85 -0
- package/comate-engine/plugins/bpm/assets/bpm.png +0 -0
- package/comate-engine/plugins/bpm/dist/index.js +313 -0
- package/comate-engine/plugins/bpm/package.json +65 -0
- package/comate-engine/plugins/casebuilder/assets/icon.svg +1 -0
- package/comate-engine/plugins/casebuilder/dist/help.md +33 -0
- package/comate-engine/plugins/casebuilder/dist/index.js +837 -0
- package/comate-engine/plugins/casebuilder/package.json +80 -0
- package/comate-engine/plugins/centrino/assets/icon.png +0 -0
- package/comate-engine/plugins/centrino/dist/help.md +30 -0
- package/comate-engine/plugins/centrino/dist/index.js +1046 -0
- package/comate-engine/plugins/centrino/package.json +68 -0
- package/comate-engine/plugins/cnap/assets/cnap.png +0 -0
- package/comate-engine/plugins/cnap/dist/help.md +11 -0
- package/comate-engine/plugins/cnap/dist/index.js +171 -0
- package/comate-engine/plugins/cnap/package.json +65 -0
- package/comate-engine/plugins/demo-feature/assets/icon.svg +1 -0
- package/comate-engine/plugins/demo-feature/dist/help.md +1 -0
- package/comate-engine/plugins/demo-feature/dist/index.d.ts +2 -0
- package/comate-engine/plugins/demo-feature/dist/index.js +36008 -0
- package/comate-engine/plugins/demo-feature/dist/providers/codeQuery.d.ts +12 -0
- package/comate-engine/plugins/demo-feature/dist/providers/codeQuery.js +23 -0
- package/comate-engine/plugins/demo-feature/dist/providers/codeSearch.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/codeSearch.js +26 -0
- package/comate-engine/plugins/demo-feature/dist/providers/config.d.ts +13 -0
- package/comate-engine/plugins/demo-feature/dist/providers/config.js +25 -0
- package/comate-engine/plugins/demo-feature/dist/providers/context.d.ts +10 -0
- package/comate-engine/plugins/demo-feature/dist/providers/context.js +49 -0
- package/comate-engine/plugins/demo-feature/dist/providers/debugAgent.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/debugAgent.js +65 -0
- package/comate-engine/plugins/demo-feature/dist/providers/explainCode.d.ts +9 -0
- package/comate-engine/plugins/demo-feature/dist/providers/explainCode.js +24 -0
- package/comate-engine/plugins/demo-feature/dist/providers/fallback.d.ts +5 -0
- package/comate-engine/plugins/demo-feature/dist/providers/fallback.js +23 -0
- package/comate-engine/plugins/demo-feature/dist/providers/file.d.ts +13 -0
- package/comate-engine/plugins/demo-feature/dist/providers/file.js +36 -0
- package/comate-engine/plugins/demo-feature/dist/providers/help.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/help.js +19 -0
- package/comate-engine/plugins/demo-feature/dist/providers/information.d.ts +13 -0
- package/comate-engine/plugins/demo-feature/dist/providers/information.js +23 -0
- package/comate-engine/plugins/demo-feature/dist/providers/knowledge.d.ts +15 -0
- package/comate-engine/plugins/demo-feature/dist/providers/knowledge.js +71 -0
- package/comate-engine/plugins/demo-feature/dist/providers/log.d.ts +12 -0
- package/comate-engine/plugins/demo-feature/dist/providers/log.js +21 -0
- package/comate-engine/plugins/demo-feature/dist/providers/onlyCode.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/onlyCode.js +23 -0
- package/comate-engine/plugins/demo-feature/dist/providers/pluginConfig.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/pluginConfig.js +47 -0
- package/comate-engine/plugins/demo-feature/dist/providers/prompt.d.ts +7 -0
- package/comate-engine/plugins/demo-feature/dist/providers/prompt.js +7 -0
- package/comate-engine/plugins/demo-feature/dist/providers/ragProvider.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/ragProvider.js +17 -0
- package/comate-engine/plugins/demo-feature/dist/providers/render.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/render.js +75 -0
- package/comate-engine/plugins/demo-feature/dist/providers/renderJsx.d.ts +10 -0
- package/comate-engine/plugins/demo-feature/dist/providers/renderJsx.js +173 -0
- package/comate-engine/plugins/demo-feature/dist/providers/section.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/section.js +136 -0
- package/comate-engine/plugins/demo-feature/dist/providers/selectedKnowledge.d.ts +12 -0
- package/comate-engine/plugins/demo-feature/dist/providers/selectedKnowledge.js +17 -0
- package/comate-engine/plugins/demo-feature/dist/providers/streaming.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/streaming.js +29 -0
- package/comate-engine/plugins/demo-feature/dist/providers/userDetail.d.ts +8 -0
- package/comate-engine/plugins/demo-feature/dist/providers/userDetail.js +28 -0
- package/comate-engine/plugins/demo-feature/package.json +214 -0
- package/comate-engine/plugins/demo-timer/assets/icon.svg +2 -0
- package/comate-engine/plugins/demo-timer/dist/index.js +463 -0
- package/comate-engine/plugins/demo-timer/package.json +73 -0
- package/comate-engine/plugins/dev-tools/assets/icon.png +0 -0
- package/comate-engine/plugins/dev-tools/dist/help.md +18 -0
- package/comate-engine/plugins/dev-tools/dist/index.js +166160 -0
- package/comate-engine/plugins/dev-tools/package.json +95 -0
- package/comate-engine/plugins/devaux/assets/icon.svg +1 -0
- package/comate-engine/plugins/devaux/dist/help.md +41 -0
- package/comate-engine/plugins/devaux/dist/index.js +73829 -0
- package/comate-engine/plugins/devaux/dist/static/tree-sitter-cpp.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/static/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/static/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/devaux/package.json +83 -0
- package/comate-engine/plugins/f2c/assets/icon.svg +11 -0
- package/comate-engine/plugins/f2c/dist/help.md +13 -0
- package/comate-engine/plugins/f2c/dist/index.js +64551 -0
- package/comate-engine/plugins/f2c/package.json +56 -0
- package/comate-engine/plugins/fcnap/assets/icon.png +0 -0
- package/comate-engine/plugins/fcnap/dist/help.md +9 -0
- package/comate-engine/plugins/fcnap/dist/index.js +105 -0
- package/comate-engine/plugins/fcnap/package.json +50 -0
- package/comate-engine/plugins/front-end-skills/assets/icon.svg +1 -0
- package/comate-engine/plugins/front-end-skills/dist/help.md +17 -0
- package/comate-engine/plugins/front-end-skills/dist/index.js +8172 -0
- package/comate-engine/plugins/front-end-skills/package.json +79 -0
- package/comate-engine/plugins/gdp/assets/icon.png +0 -0
- package/comate-engine/plugins/gdp/dist/help.md +11 -0
- package/comate-engine/plugins/gdp/dist/index.js +53065 -0
- package/comate-engine/plugins/gdp/package.json +79 -0
- package/comate-engine/plugins/git/assets/git.svg +1 -0
- package/comate-engine/plugins/git/assets/icon.svg +1 -0
- package/comate-engine/plugins/git/dist/help.md +7 -0
- package/comate-engine/plugins/git/dist/index.js +32675 -0
- package/comate-engine/plugins/git/package.json +91 -0
- package/comate-engine/plugins/harmonyos/assets/harmonyos.png +0 -0
- package/comate-engine/plugins/harmonyos/dist/index.js +78 -0
- package/comate-engine/plugins/harmonyos/package.json +37 -0
- package/comate-engine/plugins/iapi/assets/icon.png +0 -0
- package/comate-engine/plugins/iapi/dist/help.md +13 -0
- package/comate-engine/plugins/iapi/dist/index.js +458 -0
- package/comate-engine/plugins/iapi/dist/static/lang/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/lang/tree-sitter-java.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/tree-sitter-java.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/iapi/package.json +102 -0
- package/comate-engine/plugins/icafe/assets/icafe.svg +1 -0
- package/comate-engine/plugins/icafe/dist/help.md +5 -0
- package/comate-engine/plugins/icafe/dist/index.js +885 -0
- package/comate-engine/plugins/icafe/package.json +74 -0
- package/comate-engine/plugins/ievalue/assets/iEValue.svg +10 -0
- package/comate-engine/plugins/ievalue/dist/index.js +2920 -0
- package/comate-engine/plugins/ievalue/package.json +88 -0
- package/comate-engine/plugins/ipipe/assets/iPipePlugin.png +0 -0
- package/comate-engine/plugins/ipipe/dist/help.md +15 -0
- package/comate-engine/plugins/ipipe/dist/index.js +7264 -0
- package/comate-engine/plugins/ipipe/package.json +62 -0
- package/comate-engine/plugins/jarvis/assets/icon.svg +1 -0
- package/comate-engine/plugins/jarvis/dist/help.md +17 -0
- package/comate-engine/plugins/jarvis/dist/index.js +140416 -0
- package/comate-engine/plugins/jarvis/package.json +93 -0
- package/comate-engine/plugins/mapsearch/assets/mapsearchicon.png +0 -0
- package/comate-engine/plugins/mapsearch/dist/help.md +4 -0
- package/comate-engine/plugins/mapsearch/dist/index.js +145 -0
- package/comate-engine/plugins/mapsearch/package.json +53 -0
- package/comate-engine/plugins/paddle/assets/icon.png +0 -0
- package/comate-engine/plugins/paddle/assets/paconvert-3.0.1-py3-none-any.whl +0 -0
- package/comate-engine/plugins/paddle/dist/help.md +31 -0
- package/comate-engine/plugins/paddle/dist/index.js +1011 -0
- package/comate-engine/plugins/paddle/package.json +129 -0
- package/comate-engine/plugins/robot/assets/Robot.png +0 -0
- package/comate-engine/plugins/robot/dist/index.js +288 -0
- package/comate-engine/plugins/robot/package.json +67 -0
- package/comate-engine/plugins/security/assets/comate.png +0 -0
- package/comate-engine/plugins/security/dist/index.js +18393 -0
- package/comate-engine/plugins/security/package.json +82 -0
- package/comate-engine/plugins/smartapp/assets/icon.png +0 -0
- package/comate-engine/plugins/smartapp/dist/help.md +4 -0
- package/comate-engine/plugins/smartapp/dist/index.js +113 -0
- package/comate-engine/plugins/smartapp/package.json +54 -0
- package/comate-engine/plugins/springer/assets/icon.png +0 -0
- package/comate-engine/plugins/springer/dist/help.md +4 -0
- package/comate-engine/plugins/springer/dist/index.js +94525 -0
- package/comate-engine/plugins/springer/package.json +71 -0
- package/comate-engine/plugins/testmate/assets/icon.svg +1 -0
- package/comate-engine/plugins/testmate/dist/help.md +62 -0
- package/comate-engine/plugins/testmate/dist/index.js +21483 -0
- package/comate-engine/plugins/testmate/package.json +85 -0
- package/comate-engine/plugins/tor/assets/TorPlugin.png +0 -0
- package/comate-engine/plugins/tor/dist/help.md +22 -0
- package/comate-engine/plugins/tor/dist/index.js +807 -0
- package/comate-engine/plugins/tor/package.json +99 -0
- package/comate-engine/plugins/weiyun/assets/icon.png +0 -0
- package/comate-engine/plugins/weiyun/dist/help.md +11 -0
- package/comate-engine/plugins/weiyun/dist/index.js +100491 -0
- package/comate-engine/plugins/weiyun/package.json +55 -0
- package/comate-engine/plugins/wenku/assets/icon.svg +1 -0
- package/comate-engine/plugins/wenku/dist/index.js +249 -0
- package/comate-engine/plugins/wenku/package.json +55 -0
- package/comate-engine/plugins/workcard/assets/favicon.png +0 -0
- package/comate-engine/plugins/workcard/dist/help.md +30 -0
- package/comate-engine/plugins/workcard/dist/index.js +490 -0
- package/comate-engine/plugins/workcard/package.json +95 -0
- package/comate-engine/plugins/xiaomi-aiot/assets/icon.png +0 -0
- package/comate-engine/plugins/xiaomi-aiot/dist/help.md +6 -0
- package/comate-engine/plugins/xiaomi-aiot/dist/index.js +37466 -0
- package/comate-engine/plugins/xiaomi-aiot/package.json +63 -0
- package/comate-engine/server.d.ts +3 -0
- package/comate-engine/server.js +474 -0
- package/dist/bundle/index.js +29 -58174
- package/package.json +2 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
let crypto;
|
|
2
|
+
crypto = globalThis.crypto; // web browsers
|
|
3
|
+
/**
|
|
4
|
+
* Creates an array of length `size` of random bytes
|
|
5
|
+
* @param size
|
|
6
|
+
* @returns Array of random ints (0 to 255)
|
|
7
|
+
*/
|
|
8
|
+
async function getRandomValues(size) {
|
|
9
|
+
return (await crypto).getRandomValues(new Uint8Array(size));
|
|
10
|
+
}
|
|
11
|
+
/** Generate cryptographically strong random string
|
|
12
|
+
* @param size The desired length of the string
|
|
13
|
+
* @returns The random string
|
|
14
|
+
*/
|
|
15
|
+
async function random(size) {
|
|
16
|
+
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
|
17
|
+
let result = "";
|
|
18
|
+
const randomUints = await getRandomValues(size);
|
|
19
|
+
for (let i = 0; i < size; i++) {
|
|
20
|
+
// cap the value of the randomIndex to mask.length - 1
|
|
21
|
+
const randomIndex = randomUints[i] % mask.length;
|
|
22
|
+
result += mask[randomIndex];
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
/** Generate a PKCE challenge verifier
|
|
27
|
+
* @param length Length of the verifier
|
|
28
|
+
* @returns A random verifier `length` characters long
|
|
29
|
+
*/
|
|
30
|
+
async function generateVerifier(length) {
|
|
31
|
+
return await random(length);
|
|
32
|
+
}
|
|
33
|
+
/** Generate a PKCE code challenge from a code verifier
|
|
34
|
+
* @param code_verifier
|
|
35
|
+
* @returns The base64 url encoded code challenge
|
|
36
|
+
*/
|
|
37
|
+
export async function generateChallenge(code_verifier) {
|
|
38
|
+
const buffer = await (await crypto).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
39
|
+
// Generate base64url string
|
|
40
|
+
// btoa is deprecated in Node.js but is used here for web browser compatibility
|
|
41
|
+
// (which has no good replacement yet, see also https://github.com/whatwg/html/issues/6811)
|
|
42
|
+
return btoa(String.fromCharCode(...new Uint8Array(buffer)))
|
|
43
|
+
.replace(/\//g, '_')
|
|
44
|
+
.replace(/\+/g, '-')
|
|
45
|
+
.replace(/=/g, '');
|
|
46
|
+
}
|
|
47
|
+
/** Generate a PKCE challenge pair
|
|
48
|
+
* @param length Length of the verifer (between 43-128). Defaults to 43.
|
|
49
|
+
* @returns PKCE challenge pair
|
|
50
|
+
*/
|
|
51
|
+
export default async function pkceChallenge(length) {
|
|
52
|
+
if (!length)
|
|
53
|
+
length = 43;
|
|
54
|
+
if (length < 43 || length > 128) {
|
|
55
|
+
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
56
|
+
}
|
|
57
|
+
const verifier = await generateVerifier(length);
|
|
58
|
+
const challenge = await generateChallenge(verifier);
|
|
59
|
+
return {
|
|
60
|
+
code_verifier: verifier,
|
|
61
|
+
code_challenge: challenge,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Verify that a code_verifier produces the expected code challenge
|
|
65
|
+
* @param code_verifier
|
|
66
|
+
* @param expectedChallenge The code challenge to verify
|
|
67
|
+
* @returns True if challenges are equal. False otherwise.
|
|
68
|
+
*/
|
|
69
|
+
export async function verifyChallenge(code_verifier, expectedChallenge) {
|
|
70
|
+
const actualChallenge = await generateChallenge(code_verifier);
|
|
71
|
+
return actualChallenge === expectedChallenge;
|
|
72
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateChallenge = generateChallenge;
|
|
4
|
+
exports.default = pkceChallenge;
|
|
5
|
+
exports.verifyChallenge = verifyChallenge;
|
|
6
|
+
let crypto;
|
|
7
|
+
crypto =
|
|
8
|
+
globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
9
|
+
globalThis.crypto ?? // Node.js >18
|
|
10
|
+
import("node:crypto").then(m => m.webcrypto); // Node.js <18 Non-REPL
|
|
11
|
+
/**
|
|
12
|
+
* Creates an array of length `size` of random bytes
|
|
13
|
+
* @param size
|
|
14
|
+
* @returns Array of random ints (0 to 255)
|
|
15
|
+
*/
|
|
16
|
+
async function getRandomValues(size) {
|
|
17
|
+
return (await crypto).getRandomValues(new Uint8Array(size));
|
|
18
|
+
}
|
|
19
|
+
/** Generate cryptographically strong random string
|
|
20
|
+
* @param size The desired length of the string
|
|
21
|
+
* @returns The random string
|
|
22
|
+
*/
|
|
23
|
+
async function random(size) {
|
|
24
|
+
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
|
25
|
+
let result = "";
|
|
26
|
+
const randomUints = await getRandomValues(size);
|
|
27
|
+
for (let i = 0; i < size; i++) {
|
|
28
|
+
// cap the value of the randomIndex to mask.length - 1
|
|
29
|
+
const randomIndex = randomUints[i] % mask.length;
|
|
30
|
+
result += mask[randomIndex];
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/** Generate a PKCE challenge verifier
|
|
35
|
+
* @param length Length of the verifier
|
|
36
|
+
* @returns A random verifier `length` characters long
|
|
37
|
+
*/
|
|
38
|
+
async function generateVerifier(length) {
|
|
39
|
+
return await random(length);
|
|
40
|
+
}
|
|
41
|
+
/** Generate a PKCE code challenge from a code verifier
|
|
42
|
+
* @param code_verifier
|
|
43
|
+
* @returns The base64 url encoded code challenge
|
|
44
|
+
*/
|
|
45
|
+
async function generateChallenge(code_verifier) {
|
|
46
|
+
const buffer = await (await crypto).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
47
|
+
// Generate base64url string
|
|
48
|
+
// btoa is deprecated in Node.js but is used here for web browser compatibility
|
|
49
|
+
// (which has no good replacement yet, see also https://github.com/whatwg/html/issues/6811)
|
|
50
|
+
return btoa(String.fromCharCode(...new Uint8Array(buffer)))
|
|
51
|
+
.replace(/\//g, '_')
|
|
52
|
+
.replace(/\+/g, '-')
|
|
53
|
+
.replace(/=/g, '');
|
|
54
|
+
}
|
|
55
|
+
/** Generate a PKCE challenge pair
|
|
56
|
+
* @param length Length of the verifer (between 43-128). Defaults to 43.
|
|
57
|
+
* @returns PKCE challenge pair
|
|
58
|
+
*/
|
|
59
|
+
async function pkceChallenge(length) {
|
|
60
|
+
if (!length)
|
|
61
|
+
length = 43;
|
|
62
|
+
if (length < 43 || length > 128) {
|
|
63
|
+
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
64
|
+
}
|
|
65
|
+
const verifier = await generateVerifier(length);
|
|
66
|
+
const challenge = await generateChallenge(verifier);
|
|
67
|
+
return {
|
|
68
|
+
code_verifier: verifier,
|
|
69
|
+
code_challenge: challenge,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Verify that a code_verifier produces the expected code challenge
|
|
73
|
+
* @param code_verifier
|
|
74
|
+
* @param expectedChallenge The code challenge to verify
|
|
75
|
+
* @returns True if challenges are equal. False otherwise.
|
|
76
|
+
*/
|
|
77
|
+
async function verifyChallenge(code_verifier, expectedChallenge) {
|
|
78
|
+
const actualChallenge = await generateChallenge(code_verifier);
|
|
79
|
+
return actualChallenge === expectedChallenge;
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Generate a PKCE code challenge from a code verifier
|
|
2
|
+
* @param code_verifier
|
|
3
|
+
* @returns The base64 url encoded code challenge
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateChallenge(code_verifier: string): Promise<string>;
|
|
6
|
+
/** Generate a PKCE challenge pair
|
|
7
|
+
* @param length Length of the verifer (between 43-128). Defaults to 43.
|
|
8
|
+
* @returns PKCE challenge pair
|
|
9
|
+
*/
|
|
10
|
+
export default function pkceChallenge(length?: number): Promise<{
|
|
11
|
+
code_verifier: string;
|
|
12
|
+
code_challenge: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** Verify that a code_verifier produces the expected code challenge
|
|
15
|
+
* @param code_verifier
|
|
16
|
+
* @param expectedChallenge The code challenge to verify
|
|
17
|
+
* @returns True if challenges are equal. False otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function verifyChallenge(code_verifier: string, expectedChallenge: string): Promise<boolean>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Generate a PKCE code challenge from a code verifier
|
|
2
|
+
* @param code_verifier
|
|
3
|
+
* @returns The base64 url encoded code challenge
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateChallenge(code_verifier: string): Promise<string>;
|
|
6
|
+
/** Generate a PKCE challenge pair
|
|
7
|
+
* @param length Length of the verifer (between 43-128). Defaults to 43.
|
|
8
|
+
* @returns PKCE challenge pair
|
|
9
|
+
*/
|
|
10
|
+
export default function pkceChallenge(length?: number): Promise<{
|
|
11
|
+
code_verifier: string;
|
|
12
|
+
code_challenge: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** Verify that a code_verifier produces the expected code challenge
|
|
15
|
+
* @param code_verifier
|
|
16
|
+
* @param expectedChallenge The code challenge to verify
|
|
17
|
+
* @returns True if challenges are equal. False otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function verifyChallenge(code_verifier: string, expectedChallenge: string): Promise<boolean>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
let crypto;
|
|
2
|
+
crypto =
|
|
3
|
+
globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
4
|
+
globalThis.crypto ?? // Node.js >18
|
|
5
|
+
import("node:crypto").then(m => m.webcrypto); // Node.js <18 Non-REPL
|
|
6
|
+
/**
|
|
7
|
+
* Creates an array of length `size` of random bytes
|
|
8
|
+
* @param size
|
|
9
|
+
* @returns Array of random ints (0 to 255)
|
|
10
|
+
*/
|
|
11
|
+
async function getRandomValues(size) {
|
|
12
|
+
return (await crypto).getRandomValues(new Uint8Array(size));
|
|
13
|
+
}
|
|
14
|
+
/** Generate cryptographically strong random string
|
|
15
|
+
* @param size The desired length of the string
|
|
16
|
+
* @returns The random string
|
|
17
|
+
*/
|
|
18
|
+
async function random(size) {
|
|
19
|
+
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
|
20
|
+
let result = "";
|
|
21
|
+
const randomUints = await getRandomValues(size);
|
|
22
|
+
for (let i = 0; i < size; i++) {
|
|
23
|
+
// cap the value of the randomIndex to mask.length - 1
|
|
24
|
+
const randomIndex = randomUints[i] % mask.length;
|
|
25
|
+
result += mask[randomIndex];
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/** Generate a PKCE challenge verifier
|
|
30
|
+
* @param length Length of the verifier
|
|
31
|
+
* @returns A random verifier `length` characters long
|
|
32
|
+
*/
|
|
33
|
+
async function generateVerifier(length) {
|
|
34
|
+
return await random(length);
|
|
35
|
+
}
|
|
36
|
+
/** Generate a PKCE code challenge from a code verifier
|
|
37
|
+
* @param code_verifier
|
|
38
|
+
* @returns The base64 url encoded code challenge
|
|
39
|
+
*/
|
|
40
|
+
export async function generateChallenge(code_verifier) {
|
|
41
|
+
const buffer = await (await crypto).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
42
|
+
// Generate base64url string
|
|
43
|
+
// btoa is deprecated in Node.js but is used here for web browser compatibility
|
|
44
|
+
// (which has no good replacement yet, see also https://github.com/whatwg/html/issues/6811)
|
|
45
|
+
return btoa(String.fromCharCode(...new Uint8Array(buffer)))
|
|
46
|
+
.replace(/\//g, '_')
|
|
47
|
+
.replace(/\+/g, '-')
|
|
48
|
+
.replace(/=/g, '');
|
|
49
|
+
}
|
|
50
|
+
/** Generate a PKCE challenge pair
|
|
51
|
+
* @param length Length of the verifer (between 43-128). Defaults to 43.
|
|
52
|
+
* @returns PKCE challenge pair
|
|
53
|
+
*/
|
|
54
|
+
export default async function pkceChallenge(length) {
|
|
55
|
+
if (!length)
|
|
56
|
+
length = 43;
|
|
57
|
+
if (length < 43 || length > 128) {
|
|
58
|
+
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
59
|
+
}
|
|
60
|
+
const verifier = await generateVerifier(length);
|
|
61
|
+
const challenge = await generateChallenge(verifier);
|
|
62
|
+
return {
|
|
63
|
+
code_verifier: verifier,
|
|
64
|
+
code_challenge: challenge,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Verify that a code_verifier produces the expected code challenge
|
|
68
|
+
* @param code_verifier
|
|
69
|
+
* @param expectedChallenge The code challenge to verify
|
|
70
|
+
* @returns True if challenges are equal. False otherwise.
|
|
71
|
+
*/
|
|
72
|
+
export async function verifyChallenge(code_verifier, expectedChallenge) {
|
|
73
|
+
const actualChallenge = await generateChallenge(code_verifier);
|
|
74
|
+
return actualChallenge === expectedChallenge;
|
|
75
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pkce-challenge",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "Generate or verify a Proof Key for Code Exchange (PKCE) challenge pair",
|
|
5
|
+
"browser": "dist/index.browser.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": {
|
|
10
|
+
"require": "./dist/index.node.d.cts",
|
|
11
|
+
"import": "./dist/index.node.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"browser": {
|
|
14
|
+
"types": "./dist/index.browser.d.ts",
|
|
15
|
+
"default": "./dist/index.browser.js"
|
|
16
|
+
},
|
|
17
|
+
"node": {
|
|
18
|
+
"import": "./dist/index.node.js",
|
|
19
|
+
"require": "./dist/index.node.cjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --watch --declaration",
|
|
28
|
+
"preprocess": "env=browser diverge -f src/index.ts src/index.browser.ts && env=node diverge -f src/index.ts src/index.node.ts && env=node diverge -f src/index.ts src/index.node.cts",
|
|
29
|
+
"build": "npm run preprocess && tsc --declaration",
|
|
30
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
31
|
+
"test:bundle": "npm run --prefix browser-test build"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/crouchcd/pkce-challenge.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"PKCE",
|
|
39
|
+
"oauth2"
|
|
40
|
+
],
|
|
41
|
+
"author": "crouchcd",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/crouchcd/pkce-challenge/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/crouchcd/pkce-challenge#readme",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=16.20.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/jest": "^29.5.0",
|
|
52
|
+
"@types/node": "^18.15.11",
|
|
53
|
+
"diverge": "^1.0.2",
|
|
54
|
+
"esbuild": "^0.25.2",
|
|
55
|
+
"jest": "^29.5.0",
|
|
56
|
+
"typescript": "^5.0.3"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mattias Buelens
|
|
4
|
+
Copyright (c) 2016 Diwank Singh Tomer
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# web-streams-polyfill
|
|
2
|
+
|
|
3
|
+
Web Streams, based on the WHATWG spec reference implementation.
|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.com/MattiasBuelens/web-streams-polyfill)
|
|
6
|
+
[](https://www.npmjs.com/package/web-streams-polyfill)
|
|
7
|
+
[](https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/LICENSE)
|
|
8
|
+
|
|
9
|
+
## Links
|
|
10
|
+
|
|
11
|
+
- [Official spec][spec]
|
|
12
|
+
- [Reference implementation][ref-impl]
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
This library comes in multiple variants:
|
|
17
|
+
* `web-streams-polyfill`: a [ponyfill] that provides the stream implementations
|
|
18
|
+
without replacing any globals, targeting ES2015+ environments.
|
|
19
|
+
Recommended for use in Node 6+ applications, or in web libraries supporting modern browsers.
|
|
20
|
+
* `web-streams-polyfill/es5`: a ponyfill targeting ES5+ environments.
|
|
21
|
+
Recommended for use in legacy Node applications, or in web libraries supporting older browsers.
|
|
22
|
+
* `web-streams-polyfill/polyfill`: a polyfill that replaces the native stream implementations,
|
|
23
|
+
targeting ES2015+ environments.
|
|
24
|
+
Recommended for use in web apps supporting modern browsers through a `<script>` tag.
|
|
25
|
+
* `web-streams-polyfill/polyfill/es5`: a polyfill targeting ES5+ environments.
|
|
26
|
+
Recommended for use in web apps supporting older browsers through a `<script>` tag.
|
|
27
|
+
|
|
28
|
+
Each variant also includes TypeScript type definitions, compatible with the DOM type definitions for streams included in TypeScript.
|
|
29
|
+
These type definitions require TypeScript version 4.7 or higher.
|
|
30
|
+
|
|
31
|
+
In version 4, the list of variants was reworked to have more modern defaults and to reduce the download size of the package.
|
|
32
|
+
See the [migration guide][migrating] for more information.
|
|
33
|
+
|
|
34
|
+
Usage as a polyfill:
|
|
35
|
+
```html
|
|
36
|
+
<!-- option 1: hosted by unpkg CDN -->
|
|
37
|
+
<script src="https://unpkg.com/web-streams-polyfill/dist/polyfill.js"></script>
|
|
38
|
+
<!-- option 2: self hosted -->
|
|
39
|
+
<script src="/path/to/web-streams-polyfill/dist/polyfill.js"></script>
|
|
40
|
+
<script>
|
|
41
|
+
var readable = new ReadableStream();
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
Usage as a Node module:
|
|
45
|
+
```js
|
|
46
|
+
var streams = require("web-streams-polyfill");
|
|
47
|
+
var readable = new streams.ReadableStream();
|
|
48
|
+
```
|
|
49
|
+
Usage as a ponyfill from within a ES2015 module:
|
|
50
|
+
```js
|
|
51
|
+
import { ReadableStream } from "web-streams-polyfill";
|
|
52
|
+
const readable = new ReadableStream();
|
|
53
|
+
```
|
|
54
|
+
Usage as a polyfill from within an ES2015 module:
|
|
55
|
+
```js
|
|
56
|
+
import "web-streams-polyfill/polyfill";
|
|
57
|
+
const readable = new ReadableStream();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Compatibility
|
|
61
|
+
|
|
62
|
+
The `polyfill` and `ponyfill` variants work in any ES2015-compatible environment.
|
|
63
|
+
|
|
64
|
+
The `polyfill/es5` and `ponyfill/es5` variants work in any ES5-compatible environment that has a global `Promise`.
|
|
65
|
+
If you need to support older browsers or Node versions that do not have a native `Promise` implementation
|
|
66
|
+
(check the [support table][promise-support]), you must first include a `Promise` polyfill
|
|
67
|
+
(e.g. [promise-polyfill][promise-polyfill]).
|
|
68
|
+
|
|
69
|
+
[Async iterable support for `ReadableStream`][rs-asynciterator] is available in all variants, but requires an ES2018-compatible environment or a polyfill for `Symbol.asyncIterator`.
|
|
70
|
+
|
|
71
|
+
[`WritableStreamDefaultController.signal`][ws-controller-signal] is available in all variants, but requires a global `AbortController` constructor. If necessary, consider using a polyfill such as [abortcontroller-polyfill].
|
|
72
|
+
|
|
73
|
+
[Reading with a BYOB reader][mdn-byob-read] is available in all variants, but requires `ArrayBuffer.prototype.transfer()` or `structuredClone()` to exist in order to correctly transfer the given view's buffer. If not available, then the buffer won't be transferred during the read.
|
|
74
|
+
|
|
75
|
+
### Tooling compatibility
|
|
76
|
+
|
|
77
|
+
This package uses [subpath exports](https://nodejs.org/api/packages.html#subpath-exports) for its variants. As such, you need Node 12 or higher in order to `import` or `require()` such a variant.
|
|
78
|
+
|
|
79
|
+
When using TypeScript, make sure your [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) is set to `"node16"`, `"nodenext"` or `"bundler"`.
|
|
80
|
+
|
|
81
|
+
## Compliance
|
|
82
|
+
|
|
83
|
+
The polyfill implements [version `fa4891a` (3 Dec 2024)][spec-snapshot] of the streams specification.
|
|
84
|
+
|
|
85
|
+
The polyfill is tested against the same [web platform tests][wpt] that are used by browsers to test their native implementations.
|
|
86
|
+
The polyfill aims to pass all tests, although it allows some exceptions for practical reasons:
|
|
87
|
+
* The default (ES2015) variant passes all of the tests, except for the [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype].
|
|
88
|
+
Retrieving the correct `%AsyncIteratorPrototype%` requires using an async generator (`async function* () {}`), which is invalid syntax before ES2018.
|
|
89
|
+
Instead, the polyfill [creates its own version][stub-async-iterator-prototype] which is functionally equivalent to the real prototype.
|
|
90
|
+
* The ES5 variant passes the same tests as the ES2015 variant, except for various tests about specific characteristics of the constructors, properties and methods.
|
|
91
|
+
These test failures do not affect the run-time behavior of the polyfill.
|
|
92
|
+
For example:
|
|
93
|
+
* The `name` property of down-leveled constructors is incorrect.
|
|
94
|
+
* The `length` property of down-leveled constructors and methods with optional arguments is incorrect.
|
|
95
|
+
* Not all properties and methods are correctly marked as non-enumerable.
|
|
96
|
+
* Down-leveled class methods are not correctly marked as non-constructable.
|
|
97
|
+
|
|
98
|
+
## Contributors
|
|
99
|
+
|
|
100
|
+
Thanks to these people for their work on [the original polyfill][creatorrr-polyfill]:
|
|
101
|
+
|
|
102
|
+
- Diwank Singh Tomer ([creatorrr](https://github.com/creatorrr))
|
|
103
|
+
- Anders Riutta ([ariutta](https://github.com/ariutta))
|
|
104
|
+
|
|
105
|
+
[spec]: https://streams.spec.whatwg.org
|
|
106
|
+
[ref-impl]: https://github.com/whatwg/streams
|
|
107
|
+
[ponyfill]: https://github.com/sindresorhus/ponyfill
|
|
108
|
+
[migrating]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/MIGRATING.md
|
|
109
|
+
[promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise
|
|
110
|
+
[promise-polyfill]: https://www.npmjs.com/package/promise-polyfill
|
|
111
|
+
[rs-asynciterator]: https://streams.spec.whatwg.org/#rs-asynciterator
|
|
112
|
+
[ws-controller-signal]: https://streams.spec.whatwg.org/#ws-default-controller-signal
|
|
113
|
+
[abortcontroller-polyfill]: https://www.npmjs.com/package/abortcontroller-polyfill
|
|
114
|
+
[mdn-byob-read]: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader/read
|
|
115
|
+
[spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/fa4891a35ff05281ff8ed66f8ad447644ea7cec3/
|
|
116
|
+
[wpt]: https://github.com/web-platform-tests/wpt/tree/7ef95a1c3f1c178e455b21569eddb31af7c3691f/streams
|
|
117
|
+
[wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/7ef95a1c3f1c178e455b21569eddb31af7c3691f/streams/readable-streams/async-iterator.any.js#L24
|
|
118
|
+
[stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v4.0.0/src/lib/readable-stream/async-iterator.ts#L143-L147
|
|
119
|
+
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill
|