commit
a5338ba05d
1825 changed files with 328614 additions and 0 deletions
@ -0,0 +1,14 @@ |
|||||
|
services: |
||||
|
mongo-db: |
||||
|
image: mongo:latest |
||||
|
container_name: mongo-db |
||||
|
ports: |
||||
|
- "27017:27017" |
||||
|
environment: |
||||
|
MONGO_INITDB_ROOT_USERNAME: root |
||||
|
MONGO_INITDB_ROOT_PASSWORD: toor |
||||
|
volumes: |
||||
|
- mongo-data:/data/db |
||||
|
|
||||
|
volumes: |
||||
|
mongo-data: |
||||
@ -0,0 +1 @@ |
|||||
|
../mkdirp/bin/cmd.js |
||||
@ -0,0 +1 @@ |
|||||
|
../node-gyp-build/bin.js |
||||
@ -0,0 +1 @@ |
|||||
|
../node-gyp-build/optional.js |
||||
@ -0,0 +1 @@ |
|||||
|
../node-gyp-build/build-test.js |
||||
@ -0,0 +1 @@ |
|||||
|
../nodemon/bin/nodemon.js |
||||
@ -0,0 +1 @@ |
|||||
|
../touch/bin/nodetouch.js |
||||
@ -0,0 +1 @@ |
|||||
|
../prettier/bin/prettier.cjs |
||||
@ -0,0 +1 @@ |
|||||
|
../semver/bin/semver.js |
||||
File diff suppressed because it is too large
@ -0,0 +1,22 @@ |
|||||
|
Copyright (c) 2014 Dmitry Tsvettsikh |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person |
||||
|
obtaining a copy of this software and associated documentation |
||||
|
files (the "Software"), to deal in the Software without |
||||
|
restriction, including without limitation the rights to use, |
||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the |
||||
|
Software is furnished to do so, subject to the following |
||||
|
conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be |
||||
|
included in all copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||
|
OTHER DEALINGS IN THE SOFTWARE. |
||||
@ -0,0 +1,4 @@ |
|||||
|
import mod from "./node.js"; |
||||
|
|
||||
|
export default mod; |
||||
|
export const saslprep = mod.saslprep; |
||||
@ -0,0 +1,5 @@ |
|||||
|
declare const saslprep: (input: string, opts?: { |
||||
|
allowUnassigned?: boolean; |
||||
|
} | undefined) => string; |
||||
|
export = saslprep; |
||||
|
//# sourceMappingURL=browser.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,QAAQ;;wBAAmC,CAAC;AAIlD,SAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,12 @@ |
|||||
|
"use strict"; |
||||
|
var __importDefault = (this && this.__importDefault) || function (mod) { |
||||
|
return (mod && mod.__esModule) ? mod : { "default": mod }; |
||||
|
}; |
||||
|
const index_1 = __importDefault(require("./index")); |
||||
|
const memory_code_points_1 = require("./memory-code-points"); |
||||
|
const code_points_data_browser_1 = __importDefault(require("./code-points-data-browser")); |
||||
|
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_browser_1.default); |
||||
|
const saslprep = index_1.default.bind(null, codePoints); |
||||
|
Object.assign(saslprep, { saslprep, default: saslprep }); |
||||
|
module.exports = saslprep; |
||||
|
//# sourceMappingURL=browser.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0FAA8C;AAE9C,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,kCAAI,CAAC,CAAC;AAEhD,MAAM,QAAQ,GAAG,eAAS,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzD,iBAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,3 @@ |
|||||
|
declare const data: Buffer<ArrayBuffer>; |
||||
|
export default data; |
||||
|
//# sourceMappingURL=code-points-data-browser.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"code-points-data-browser.d.ts","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,IAAI,qBAGT,CAAC;AACF,eAAe,IAAI,CAAC"} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"code-points-data-browser.js","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CACtB,8sliBAA8sliB,EAC9sliB,QAAQ,CACT,CAAC;AACF,kBAAe,IAAI,CAAC"} |
||||
@ -0,0 +1,3 @@ |
|||||
|
declare const _default: Buffer<ArrayBufferLike>; |
||||
|
export default _default; |
||||
|
//# sourceMappingURL=code-points-data.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"code-points-data.d.ts","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";AAEA,wBAKE"} |
||||
@ -0,0 +1,5 @@ |
|||||
|
"use strict"; |
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
const zlib_1 = require("zlib"); |
||||
|
exports.default = (0, zlib_1.gunzipSync)(Buffer.from('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', 'base64')); |
||||
|
//# sourceMappingURL=code-points-data.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"code-points-data.js","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAAA,+BAAkC;AAElC,kBAAe,IAAA,iBAAU,EACvB,MAAM,CAAC,IAAI,CACT,knFAAknF,EAClnF,QAAQ,CACT,CACF,CAAC"} |
||||
@ -0,0 +1,7 @@ |
|||||
|
export declare const unassigned_code_points: Set<number>; |
||||
|
export declare const commonly_mapped_to_nothing: Set<number>; |
||||
|
export declare const non_ASCII_space_characters: Set<number>; |
||||
|
export declare const prohibited_characters: Set<number>; |
||||
|
export declare const bidirectional_r_al: Set<number>; |
||||
|
export declare const bidirectional_l: Set<number>; |
||||
|
//# sourceMappingURL=code-points-src.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"code-points-src.d.ts","sourceRoot":"","sources":["../src/code-points-src.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,aA6YjC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aAIrC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aASrC,CAAC;AAMH,eAAO,MAAM,qBAAqB,aA6GhC,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAmC7B,CAAC;AAMH,eAAO,MAAM,eAAe,aAyW1B,CAAC"} |
||||
@ -0,0 +1,881 @@ |
|||||
|
"use strict"; |
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
exports.bidirectional_l = exports.bidirectional_r_al = exports.prohibited_characters = exports.non_ASCII_space_characters = exports.commonly_mapped_to_nothing = exports.unassigned_code_points = void 0; |
||||
|
const util_1 = require("./util"); |
||||
|
exports.unassigned_code_points = new Set([ |
||||
|
0x0221, |
||||
|
...(0, util_1.range)(0x0234, 0x024f), |
||||
|
...(0, util_1.range)(0x02ae, 0x02af), |
||||
|
...(0, util_1.range)(0x02ef, 0x02ff), |
||||
|
...(0, util_1.range)(0x0350, 0x035f), |
||||
|
...(0, util_1.range)(0x0370, 0x0373), |
||||
|
...(0, util_1.range)(0x0376, 0x0379), |
||||
|
...(0, util_1.range)(0x037b, 0x037d), |
||||
|
...(0, util_1.range)(0x037f, 0x0383), |
||||
|
0x038b, |
||||
|
0x038d, |
||||
|
0x03a2, |
||||
|
0x03cf, |
||||
|
...(0, util_1.range)(0x03f7, 0x03ff), |
||||
|
0x0487, |
||||
|
0x04cf, |
||||
|
...(0, util_1.range)(0x04f6, 0x04f7), |
||||
|
...(0, util_1.range)(0x04fa, 0x04ff), |
||||
|
...(0, util_1.range)(0x0510, 0x0530), |
||||
|
...(0, util_1.range)(0x0557, 0x0558), |
||||
|
0x0560, |
||||
|
0x0588, |
||||
|
...(0, util_1.range)(0x058b, 0x0590), |
||||
|
0x05a2, |
||||
|
0x05ba, |
||||
|
...(0, util_1.range)(0x05c5, 0x05cf), |
||||
|
...(0, util_1.range)(0x05eb, 0x05ef), |
||||
|
...(0, util_1.range)(0x05f5, 0x060b), |
||||
|
...(0, util_1.range)(0x060d, 0x061a), |
||||
|
...(0, util_1.range)(0x061c, 0x061e), |
||||
|
0x0620, |
||||
|
...(0, util_1.range)(0x063b, 0x063f), |
||||
|
...(0, util_1.range)(0x0656, 0x065f), |
||||
|
...(0, util_1.range)(0x06ee, 0x06ef), |
||||
|
0x06ff, |
||||
|
0x070e, |
||||
|
...(0, util_1.range)(0x072d, 0x072f), |
||||
|
...(0, util_1.range)(0x074b, 0x077f), |
||||
|
...(0, util_1.range)(0x07b2, 0x0900), |
||||
|
0x0904, |
||||
|
...(0, util_1.range)(0x093a, 0x093b), |
||||
|
...(0, util_1.range)(0x094e, 0x094f), |
||||
|
...(0, util_1.range)(0x0955, 0x0957), |
||||
|
...(0, util_1.range)(0x0971, 0x0980), |
||||
|
0x0984, |
||||
|
...(0, util_1.range)(0x098d, 0x098e), |
||||
|
...(0, util_1.range)(0x0991, 0x0992), |
||||
|
0x09a9, |
||||
|
0x09b1, |
||||
|
...(0, util_1.range)(0x09b3, 0x09b5), |
||||
|
...(0, util_1.range)(0x09ba, 0x09bb), |
||||
|
0x09bd, |
||||
|
...(0, util_1.range)(0x09c5, 0x09c6), |
||||
|
...(0, util_1.range)(0x09c9, 0x09ca), |
||||
|
...(0, util_1.range)(0x09ce, 0x09d6), |
||||
|
...(0, util_1.range)(0x09d8, 0x09db), |
||||
|
0x09de, |
||||
|
...(0, util_1.range)(0x09e4, 0x09e5), |
||||
|
...(0, util_1.range)(0x09fb, 0x0a01), |
||||
|
...(0, util_1.range)(0x0a03, 0x0a04), |
||||
|
...(0, util_1.range)(0x0a0b, 0x0a0e), |
||||
|
...(0, util_1.range)(0x0a11, 0x0a12), |
||||
|
0x0a29, |
||||
|
0x0a31, |
||||
|
0x0a34, |
||||
|
0x0a37, |
||||
|
...(0, util_1.range)(0x0a3a, 0x0a3b), |
||||
|
0x0a3d, |
||||
|
...(0, util_1.range)(0x0a43, 0x0a46), |
||||
|
...(0, util_1.range)(0x0a49, 0x0a4a), |
||||
|
...(0, util_1.range)(0x0a4e, 0x0a58), |
||||
|
0x0a5d, |
||||
|
...(0, util_1.range)(0x0a5f, 0x0a65), |
||||
|
...(0, util_1.range)(0x0a75, 0x0a80), |
||||
|
0x0a84, |
||||
|
0x0a8c, |
||||
|
0x0a8e, |
||||
|
0x0a92, |
||||
|
0x0aa9, |
||||
|
0x0ab1, |
||||
|
0x0ab4, |
||||
|
...(0, util_1.range)(0x0aba, 0x0abb), |
||||
|
0x0ac6, |
||||
|
0x0aca, |
||||
|
...(0, util_1.range)(0x0ace, 0x0acf), |
||||
|
...(0, util_1.range)(0x0ad1, 0x0adf), |
||||
|
...(0, util_1.range)(0x0ae1, 0x0ae5), |
||||
|
...(0, util_1.range)(0x0af0, 0x0b00), |
||||
|
0x0b04, |
||||
|
...(0, util_1.range)(0x0b0d, 0x0b0e), |
||||
|
...(0, util_1.range)(0x0b11, 0x0b12), |
||||
|
0x0b29, |
||||
|
0x0b31, |
||||
|
...(0, util_1.range)(0x0b34, 0x0b35), |
||||
|
...(0, util_1.range)(0x0b3a, 0x0b3b), |
||||
|
...(0, util_1.range)(0x0b44, 0x0b46), |
||||
|
...(0, util_1.range)(0x0b49, 0x0b4a), |
||||
|
...(0, util_1.range)(0x0b4e, 0x0b55), |
||||
|
...(0, util_1.range)(0x0b58, 0x0b5b), |
||||
|
0x0b5e, |
||||
|
...(0, util_1.range)(0x0b62, 0x0b65), |
||||
|
...(0, util_1.range)(0x0b71, 0x0b81), |
||||
|
0x0b84, |
||||
|
...(0, util_1.range)(0x0b8b, 0x0b8d), |
||||
|
0x0b91, |
||||
|
...(0, util_1.range)(0x0b96, 0x0b98), |
||||
|
0x0b9b, |
||||
|
0x0b9d, |
||||
|
...(0, util_1.range)(0x0ba0, 0x0ba2), |
||||
|
...(0, util_1.range)(0x0ba5, 0x0ba7), |
||||
|
...(0, util_1.range)(0x0bab, 0x0bad), |
||||
|
0x0bb6, |
||||
|
...(0, util_1.range)(0x0bba, 0x0bbd), |
||||
|
...(0, util_1.range)(0x0bc3, 0x0bc5), |
||||
|
0x0bc9, |
||||
|
...(0, util_1.range)(0x0bce, 0x0bd6), |
||||
|
...(0, util_1.range)(0x0bd8, 0x0be6), |
||||
|
...(0, util_1.range)(0x0bf3, 0x0c00), |
||||
|
0x0c04, |
||||
|
0x0c0d, |
||||
|
0x0c11, |
||||
|
0x0c29, |
||||
|
0x0c34, |
||||
|
...(0, util_1.range)(0x0c3a, 0x0c3d), |
||||
|
0x0c45, |
||||
|
0x0c49, |
||||
|
...(0, util_1.range)(0x0c4e, 0x0c54), |
||||
|
...(0, util_1.range)(0x0c57, 0x0c5f), |
||||
|
...(0, util_1.range)(0x0c62, 0x0c65), |
||||
|
...(0, util_1.range)(0x0c70, 0x0c81), |
||||
|
0x0c84, |
||||
|
0x0c8d, |
||||
|
0x0c91, |
||||
|
0x0ca9, |
||||
|
0x0cb4, |
||||
|
...(0, util_1.range)(0x0cba, 0x0cbd), |
||||
|
0x0cc5, |
||||
|
0x0cc9, |
||||
|
...(0, util_1.range)(0x0cce, 0x0cd4), |
||||
|
...(0, util_1.range)(0x0cd7, 0x0cdd), |
||||
|
0x0cdf, |
||||
|
...(0, util_1.range)(0x0ce2, 0x0ce5), |
||||
|
...(0, util_1.range)(0x0cf0, 0x0d01), |
||||
|
0x0d04, |
||||
|
0x0d0d, |
||||
|
0x0d11, |
||||
|
0x0d29, |
||||
|
...(0, util_1.range)(0x0d3a, 0x0d3d), |
||||
|
...(0, util_1.range)(0x0d44, 0x0d45), |
||||
|
0x0d49, |
||||
|
...(0, util_1.range)(0x0d4e, 0x0d56), |
||||
|
...(0, util_1.range)(0x0d58, 0x0d5f), |
||||
|
...(0, util_1.range)(0x0d62, 0x0d65), |
||||
|
...(0, util_1.range)(0x0d70, 0x0d81), |
||||
|
0x0d84, |
||||
|
...(0, util_1.range)(0x0d97, 0x0d99), |
||||
|
0x0db2, |
||||
|
0x0dbc, |
||||
|
...(0, util_1.range)(0x0dbe, 0x0dbf), |
||||
|
...(0, util_1.range)(0x0dc7, 0x0dc9), |
||||
|
...(0, util_1.range)(0x0dcb, 0x0dce), |
||||
|
0x0dd5, |
||||
|
0x0dd7, |
||||
|
...(0, util_1.range)(0x0de0, 0x0df1), |
||||
|
...(0, util_1.range)(0x0df5, 0x0e00), |
||||
|
...(0, util_1.range)(0x0e3b, 0x0e3e), |
||||
|
...(0, util_1.range)(0x0e5c, 0x0e80), |
||||
|
0x0e83, |
||||
|
...(0, util_1.range)(0x0e85, 0x0e86), |
||||
|
0x0e89, |
||||
|
...(0, util_1.range)(0x0e8b, 0x0e8c), |
||||
|
...(0, util_1.range)(0x0e8e, 0x0e93), |
||||
|
0x0e98, |
||||
|
0x0ea0, |
||||
|
0x0ea4, |
||||
|
0x0ea6, |
||||
|
...(0, util_1.range)(0x0ea8, 0x0ea9), |
||||
|
0x0eac, |
||||
|
0x0eba, |
||||
|
...(0, util_1.range)(0x0ebe, 0x0ebf), |
||||
|
0x0ec5, |
||||
|
0x0ec7, |
||||
|
...(0, util_1.range)(0x0ece, 0x0ecf), |
||||
|
...(0, util_1.range)(0x0eda, 0x0edb), |
||||
|
...(0, util_1.range)(0x0ede, 0x0eff), |
||||
|
0x0f48, |
||||
|
...(0, util_1.range)(0x0f6b, 0x0f70), |
||||
|
...(0, util_1.range)(0x0f8c, 0x0f8f), |
||||
|
0x0f98, |
||||
|
0x0fbd, |
||||
|
...(0, util_1.range)(0x0fcd, 0x0fce), |
||||
|
...(0, util_1.range)(0x0fd0, 0x0fff), |
||||
|
0x1022, |
||||
|
0x1028, |
||||
|
0x102b, |
||||
|
...(0, util_1.range)(0x1033, 0x1035), |
||||
|
...(0, util_1.range)(0x103a, 0x103f), |
||||
|
...(0, util_1.range)(0x105a, 0x109f), |
||||
|
...(0, util_1.range)(0x10c6, 0x10cf), |
||||
|
...(0, util_1.range)(0x10f9, 0x10fa), |
||||
|
...(0, util_1.range)(0x10fc, 0x10ff), |
||||
|
...(0, util_1.range)(0x115a, 0x115e), |
||||
|
...(0, util_1.range)(0x11a3, 0x11a7), |
||||
|
...(0, util_1.range)(0x11fa, 0x11ff), |
||||
|
0x1207, |
||||
|
0x1247, |
||||
|
0x1249, |
||||
|
...(0, util_1.range)(0x124e, 0x124f), |
||||
|
0x1257, |
||||
|
0x1259, |
||||
|
...(0, util_1.range)(0x125e, 0x125f), |
||||
|
0x1287, |
||||
|
0x1289, |
||||
|
...(0, util_1.range)(0x128e, 0x128f), |
||||
|
0x12af, |
||||
|
0x12b1, |
||||
|
...(0, util_1.range)(0x12b6, 0x12b7), |
||||
|
0x12bf, |
||||
|
0x12c1, |
||||
|
...(0, util_1.range)(0x12c6, 0x12c7), |
||||
|
0x12cf, |
||||
|
0x12d7, |
||||
|
0x12ef, |
||||
|
0x130f, |
||||
|
0x1311, |
||||
|
...(0, util_1.range)(0x1316, 0x1317), |
||||
|
0x131f, |
||||
|
0x1347, |
||||
|
...(0, util_1.range)(0x135b, 0x1360), |
||||
|
...(0, util_1.range)(0x137d, 0x139f), |
||||
|
...(0, util_1.range)(0x13f5, 0x1400), |
||||
|
...(0, util_1.range)(0x1677, 0x167f), |
||||
|
...(0, util_1.range)(0x169d, 0x169f), |
||||
|
...(0, util_1.range)(0x16f1, 0x16ff), |
||||
|
0x170d, |
||||
|
...(0, util_1.range)(0x1715, 0x171f), |
||||
|
...(0, util_1.range)(0x1737, 0x173f), |
||||
|
...(0, util_1.range)(0x1754, 0x175f), |
||||
|
0x176d, |
||||
|
0x1771, |
||||
|
...(0, util_1.range)(0x1774, 0x177f), |
||||
|
...(0, util_1.range)(0x17dd, 0x17df), |
||||
|
...(0, util_1.range)(0x17ea, 0x17ff), |
||||
|
0x180f, |
||||
|
...(0, util_1.range)(0x181a, 0x181f), |
||||
|
...(0, util_1.range)(0x1878, 0x187f), |
||||
|
...(0, util_1.range)(0x18aa, 0x1dff), |
||||
|
...(0, util_1.range)(0x1e9c, 0x1e9f), |
||||
|
...(0, util_1.range)(0x1efa, 0x1eff), |
||||
|
...(0, util_1.range)(0x1f16, 0x1f17), |
||||
|
...(0, util_1.range)(0x1f1e, 0x1f1f), |
||||
|
...(0, util_1.range)(0x1f46, 0x1f47), |
||||
|
...(0, util_1.range)(0x1f4e, 0x1f4f), |
||||
|
0x1f58, |
||||
|
0x1f5a, |
||||
|
0x1f5c, |
||||
|
0x1f5e, |
||||
|
...(0, util_1.range)(0x1f7e, 0x1f7f), |
||||
|
0x1fb5, |
||||
|
0x1fc5, |
||||
|
...(0, util_1.range)(0x1fd4, 0x1fd5), |
||||
|
0x1fdc, |
||||
|
...(0, util_1.range)(0x1ff0, 0x1ff1), |
||||
|
0x1ff5, |
||||
|
0x1fff, |
||||
|
...(0, util_1.range)(0x2053, 0x2056), |
||||
|
...(0, util_1.range)(0x2058, 0x205e), |
||||
|
...(0, util_1.range)(0x2064, 0x2069), |
||||
|
...(0, util_1.range)(0x2072, 0x2073), |
||||
|
...(0, util_1.range)(0x208f, 0x209f), |
||||
|
...(0, util_1.range)(0x20b2, 0x20cf), |
||||
|
...(0, util_1.range)(0x20eb, 0x20ff), |
||||
|
...(0, util_1.range)(0x213b, 0x213c), |
||||
|
...(0, util_1.range)(0x214c, 0x2152), |
||||
|
...(0, util_1.range)(0x2184, 0x218f), |
||||
|
...(0, util_1.range)(0x23cf, 0x23ff), |
||||
|
...(0, util_1.range)(0x2427, 0x243f), |
||||
|
...(0, util_1.range)(0x244b, 0x245f), |
||||
|
0x24ff, |
||||
|
...(0, util_1.range)(0x2614, 0x2615), |
||||
|
0x2618, |
||||
|
...(0, util_1.range)(0x267e, 0x267f), |
||||
|
...(0, util_1.range)(0x268a, 0x2700), |
||||
|
0x2705, |
||||
|
...(0, util_1.range)(0x270a, 0x270b), |
||||
|
0x2728, |
||||
|
0x274c, |
||||
|
0x274e, |
||||
|
...(0, util_1.range)(0x2753, 0x2755), |
||||
|
0x2757, |
||||
|
...(0, util_1.range)(0x275f, 0x2760), |
||||
|
...(0, util_1.range)(0x2795, 0x2797), |
||||
|
0x27b0, |
||||
|
...(0, util_1.range)(0x27bf, 0x27cf), |
||||
|
...(0, util_1.range)(0x27ec, 0x27ef), |
||||
|
...(0, util_1.range)(0x2b00, 0x2e7f), |
||||
|
0x2e9a, |
||||
|
...(0, util_1.range)(0x2ef4, 0x2eff), |
||||
|
...(0, util_1.range)(0x2fd6, 0x2fef), |
||||
|
...(0, util_1.range)(0x2ffc, 0x2fff), |
||||
|
0x3040, |
||||
|
...(0, util_1.range)(0x3097, 0x3098), |
||||
|
...(0, util_1.range)(0x3100, 0x3104), |
||||
|
...(0, util_1.range)(0x312d, 0x3130), |
||||
|
0x318f, |
||||
|
...(0, util_1.range)(0x31b8, 0x31ef), |
||||
|
...(0, util_1.range)(0x321d, 0x321f), |
||||
|
...(0, util_1.range)(0x3244, 0x3250), |
||||
|
...(0, util_1.range)(0x327c, 0x327e), |
||||
|
...(0, util_1.range)(0x32cc, 0x32cf), |
||||
|
0x32ff, |
||||
|
...(0, util_1.range)(0x3377, 0x337a), |
||||
|
...(0, util_1.range)(0x33de, 0x33df), |
||||
|
0x33ff, |
||||
|
...(0, util_1.range)(0x4db6, 0x4dff), |
||||
|
...(0, util_1.range)(0x9fa6, 0x9fff), |
||||
|
...(0, util_1.range)(0xa48d, 0xa48f), |
||||
|
...(0, util_1.range)(0xa4c7, 0xabff), |
||||
|
...(0, util_1.range)(0xd7a4, 0xd7ff), |
||||
|
...(0, util_1.range)(0xfa2e, 0xfa2f), |
||||
|
...(0, util_1.range)(0xfa6b, 0xfaff), |
||||
|
...(0, util_1.range)(0xfb07, 0xfb12), |
||||
|
...(0, util_1.range)(0xfb18, 0xfb1c), |
||||
|
0xfb37, |
||||
|
0xfb3d, |
||||
|
0xfb3f, |
||||
|
0xfb42, |
||||
|
0xfb45, |
||||
|
...(0, util_1.range)(0xfbb2, 0xfbd2), |
||||
|
...(0, util_1.range)(0xfd40, 0xfd4f), |
||||
|
...(0, util_1.range)(0xfd90, 0xfd91), |
||||
|
...(0, util_1.range)(0xfdc8, 0xfdcf), |
||||
|
...(0, util_1.range)(0xfdfd, 0xfdff), |
||||
|
...(0, util_1.range)(0xfe10, 0xfe1f), |
||||
|
...(0, util_1.range)(0xfe24, 0xfe2f), |
||||
|
...(0, util_1.range)(0xfe47, 0xfe48), |
||||
|
0xfe53, |
||||
|
0xfe67, |
||||
|
...(0, util_1.range)(0xfe6c, 0xfe6f), |
||||
|
0xfe75, |
||||
|
...(0, util_1.range)(0xfefd, 0xfefe), |
||||
|
0xff00, |
||||
|
...(0, util_1.range)(0xffbf, 0xffc1), |
||||
|
...(0, util_1.range)(0xffc8, 0xffc9), |
||||
|
...(0, util_1.range)(0xffd0, 0xffd1), |
||||
|
...(0, util_1.range)(0xffd8, 0xffd9), |
||||
|
...(0, util_1.range)(0xffdd, 0xffdf), |
||||
|
0xffe7, |
||||
|
...(0, util_1.range)(0xffef, 0xfff8), |
||||
|
...(0, util_1.range)(0x10000, 0x102ff), |
||||
|
0x1031f, |
||||
|
...(0, util_1.range)(0x10324, 0x1032f), |
||||
|
...(0, util_1.range)(0x1034b, 0x103ff), |
||||
|
...(0, util_1.range)(0x10426, 0x10427), |
||||
|
...(0, util_1.range)(0x1044e, 0x1cfff), |
||||
|
...(0, util_1.range)(0x1d0f6, 0x1d0ff), |
||||
|
...(0, util_1.range)(0x1d127, 0x1d129), |
||||
|
...(0, util_1.range)(0x1d1de, 0x1d3ff), |
||||
|
0x1d455, |
||||
|
0x1d49d, |
||||
|
...(0, util_1.range)(0x1d4a0, 0x1d4a1), |
||||
|
...(0, util_1.range)(0x1d4a3, 0x1d4a4), |
||||
|
...(0, util_1.range)(0x1d4a7, 0x1d4a8), |
||||
|
0x1d4ad, |
||||
|
0x1d4ba, |
||||
|
0x1d4bc, |
||||
|
0x1d4c1, |
||||
|
0x1d4c4, |
||||
|
0x1d506, |
||||
|
...(0, util_1.range)(0x1d50b, 0x1d50c), |
||||
|
0x1d515, |
||||
|
0x1d51d, |
||||
|
0x1d53a, |
||||
|
0x1d53f, |
||||
|
0x1d545, |
||||
|
...(0, util_1.range)(0x1d547, 0x1d549), |
||||
|
0x1d551, |
||||
|
...(0, util_1.range)(0x1d6a4, 0x1d6a7), |
||||
|
...(0, util_1.range)(0x1d7ca, 0x1d7cd), |
||||
|
...(0, util_1.range)(0x1d800, 0x1fffd), |
||||
|
...(0, util_1.range)(0x2a6d7, 0x2f7ff), |
||||
|
...(0, util_1.range)(0x2fa1e, 0x2fffd), |
||||
|
...(0, util_1.range)(0x30000, 0x3fffd), |
||||
|
...(0, util_1.range)(0x40000, 0x4fffd), |
||||
|
...(0, util_1.range)(0x50000, 0x5fffd), |
||||
|
...(0, util_1.range)(0x60000, 0x6fffd), |
||||
|
...(0, util_1.range)(0x70000, 0x7fffd), |
||||
|
...(0, util_1.range)(0x80000, 0x8fffd), |
||||
|
...(0, util_1.range)(0x90000, 0x9fffd), |
||||
|
...(0, util_1.range)(0xa0000, 0xafffd), |
||||
|
...(0, util_1.range)(0xb0000, 0xbfffd), |
||||
|
...(0, util_1.range)(0xc0000, 0xcfffd), |
||||
|
...(0, util_1.range)(0xd0000, 0xdfffd), |
||||
|
0xe0000, |
||||
|
...(0, util_1.range)(0xe0002, 0xe001f), |
||||
|
...(0, util_1.range)(0xe0080, 0xefffd), |
||||
|
]); |
||||
|
exports.commonly_mapped_to_nothing = new Set([ |
||||
|
0x00ad, 0x034f, 0x1806, 0x180b, 0x180c, 0x180d, 0x200b, 0x200c, 0x200d, |
||||
|
0x2060, 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04, 0xfe05, 0xfe06, 0xfe07, |
||||
|
0xfe08, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e, 0xfe0f, 0xfeff, |
||||
|
]); |
||||
|
exports.non_ASCII_space_characters = new Set([ |
||||
|
0x00a0, 0x1680, |
||||
|
0x2000, 0x2001, 0x2002, |
||||
|
0x2003, 0x2004, |
||||
|
0x2005, 0x2006, |
||||
|
0x2007, 0x2008, |
||||
|
0x2009, 0x200a, |
||||
|
0x200b, 0x202f, |
||||
|
0x205f, 0x3000, |
||||
|
]); |
||||
|
exports.prohibited_characters = new Set([ |
||||
|
...exports.non_ASCII_space_characters, |
||||
|
...(0, util_1.range)(0, 0x001f), |
||||
|
0x007f, |
||||
|
...(0, util_1.range)(0x0080, 0x009f), |
||||
|
0x06dd, |
||||
|
0x070f, |
||||
|
0x180e, |
||||
|
0x200c, |
||||
|
0x200d, |
||||
|
0x2028, |
||||
|
0x2029, |
||||
|
0x2060, |
||||
|
0x2061, |
||||
|
0x2062, |
||||
|
0x2063, |
||||
|
...(0, util_1.range)(0x206a, 0x206f), |
||||
|
0xfeff, |
||||
|
...(0, util_1.range)(0xfff9, 0xfffc), |
||||
|
...(0, util_1.range)(0x1d173, 0x1d17a), |
||||
|
...(0, util_1.range)(0xe000, 0xf8ff), |
||||
|
...(0, util_1.range)(0xf0000, 0xffffd), |
||||
|
...(0, util_1.range)(0x100000, 0x10fffd), |
||||
|
...(0, util_1.range)(0xfdd0, 0xfdef), |
||||
|
...(0, util_1.range)(0xfffe, 0xffff), |
||||
|
...(0, util_1.range)(0x1fffe, 0x1ffff), |
||||
|
...(0, util_1.range)(0x2fffe, 0x2ffff), |
||||
|
...(0, util_1.range)(0x3fffe, 0x3ffff), |
||||
|
...(0, util_1.range)(0x4fffe, 0x4ffff), |
||||
|
...(0, util_1.range)(0x5fffe, 0x5ffff), |
||||
|
...(0, util_1.range)(0x6fffe, 0x6ffff), |
||||
|
...(0, util_1.range)(0x7fffe, 0x7ffff), |
||||
|
...(0, util_1.range)(0x8fffe, 0x8ffff), |
||||
|
...(0, util_1.range)(0x9fffe, 0x9ffff), |
||||
|
...(0, util_1.range)(0xafffe, 0xaffff), |
||||
|
...(0, util_1.range)(0xbfffe, 0xbffff), |
||||
|
...(0, util_1.range)(0xcfffe, 0xcffff), |
||||
|
...(0, util_1.range)(0xdfffe, 0xdffff), |
||||
|
...(0, util_1.range)(0xefffe, 0xeffff), |
||||
|
...(0, util_1.range)(0x10fffe, 0x10ffff), |
||||
|
...(0, util_1.range)(0xd800, 0xdfff), |
||||
|
0xfff9, |
||||
|
0xfffa, |
||||
|
0xfffb, |
||||
|
0xfffc, |
||||
|
0xfffd, |
||||
|
...(0, util_1.range)(0x2ff0, 0x2ffb), |
||||
|
0x0340, |
||||
|
0x0341, |
||||
|
0x200e, |
||||
|
0x200f, |
||||
|
0x202a, |
||||
|
0x202b, |
||||
|
0x202c, |
||||
|
0x202d, |
||||
|
0x202e, |
||||
|
0x206a, |
||||
|
0x206b, |
||||
|
0x206c, |
||||
|
0x206d, |
||||
|
0x206e, |
||||
|
0x206f, |
||||
|
0xe0001, |
||||
|
...(0, util_1.range)(0xe0020, 0xe007f), |
||||
|
]); |
||||
|
exports.bidirectional_r_al = new Set([ |
||||
|
0x05be, |
||||
|
0x05c0, |
||||
|
0x05c3, |
||||
|
...(0, util_1.range)(0x05d0, 0x05ea), |
||||
|
...(0, util_1.range)(0x05f0, 0x05f4), |
||||
|
0x061b, |
||||
|
0x061f, |
||||
|
...(0, util_1.range)(0x0621, 0x063a), |
||||
|
...(0, util_1.range)(0x0640, 0x064a), |
||||
|
...(0, util_1.range)(0x066d, 0x066f), |
||||
|
...(0, util_1.range)(0x0671, 0x06d5), |
||||
|
0x06dd, |
||||
|
...(0, util_1.range)(0x06e5, 0x06e6), |
||||
|
...(0, util_1.range)(0x06fa, 0x06fe), |
||||
|
...(0, util_1.range)(0x0700, 0x070d), |
||||
|
0x0710, |
||||
|
...(0, util_1.range)(0x0712, 0x072c), |
||||
|
...(0, util_1.range)(0x0780, 0x07a5), |
||||
|
0x07b1, |
||||
|
0x200f, |
||||
|
0xfb1d, |
||||
|
...(0, util_1.range)(0xfb1f, 0xfb28), |
||||
|
...(0, util_1.range)(0xfb2a, 0xfb36), |
||||
|
...(0, util_1.range)(0xfb38, 0xfb3c), |
||||
|
0xfb3e, |
||||
|
...(0, util_1.range)(0xfb40, 0xfb41), |
||||
|
...(0, util_1.range)(0xfb43, 0xfb44), |
||||
|
...(0, util_1.range)(0xfb46, 0xfbb1), |
||||
|
...(0, util_1.range)(0xfbd3, 0xfd3d), |
||||
|
...(0, util_1.range)(0xfd50, 0xfd8f), |
||||
|
...(0, util_1.range)(0xfd92, 0xfdc7), |
||||
|
...(0, util_1.range)(0xfdf0, 0xfdfc), |
||||
|
...(0, util_1.range)(0xfe70, 0xfe74), |
||||
|
...(0, util_1.range)(0xfe76, 0xfefc), |
||||
|
]); |
||||
|
exports.bidirectional_l = new Set([ |
||||
|
...(0, util_1.range)(0x0041, 0x005a), |
||||
|
...(0, util_1.range)(0x0061, 0x007a), |
||||
|
0x00aa, |
||||
|
0x00b5, |
||||
|
0x00ba, |
||||
|
...(0, util_1.range)(0x00c0, 0x00d6), |
||||
|
...(0, util_1.range)(0x00d8, 0x00f6), |
||||
|
...(0, util_1.range)(0x00f8, 0x0220), |
||||
|
...(0, util_1.range)(0x0222, 0x0233), |
||||
|
...(0, util_1.range)(0x0250, 0x02ad), |
||||
|
...(0, util_1.range)(0x02b0, 0x02b8), |
||||
|
...(0, util_1.range)(0x02bb, 0x02c1), |
||||
|
...(0, util_1.range)(0x02d0, 0x02d1), |
||||
|
...(0, util_1.range)(0x02e0, 0x02e4), |
||||
|
0x02ee, |
||||
|
0x037a, |
||||
|
0x0386, |
||||
|
...(0, util_1.range)(0x0388, 0x038a), |
||||
|
0x038c, |
||||
|
...(0, util_1.range)(0x038e, 0x03a1), |
||||
|
...(0, util_1.range)(0x03a3, 0x03ce), |
||||
|
...(0, util_1.range)(0x03d0, 0x03f5), |
||||
|
...(0, util_1.range)(0x0400, 0x0482), |
||||
|
...(0, util_1.range)(0x048a, 0x04ce), |
||||
|
...(0, util_1.range)(0x04d0, 0x04f5), |
||||
|
...(0, util_1.range)(0x04f8, 0x04f9), |
||||
|
...(0, util_1.range)(0x0500, 0x050f), |
||||
|
...(0, util_1.range)(0x0531, 0x0556), |
||||
|
...(0, util_1.range)(0x0559, 0x055f), |
||||
|
...(0, util_1.range)(0x0561, 0x0587), |
||||
|
0x0589, |
||||
|
0x0903, |
||||
|
...(0, util_1.range)(0x0905, 0x0939), |
||||
|
...(0, util_1.range)(0x093d, 0x0940), |
||||
|
...(0, util_1.range)(0x0949, 0x094c), |
||||
|
0x0950, |
||||
|
...(0, util_1.range)(0x0958, 0x0961), |
||||
|
...(0, util_1.range)(0x0964, 0x0970), |
||||
|
...(0, util_1.range)(0x0982, 0x0983), |
||||
|
...(0, util_1.range)(0x0985, 0x098c), |
||||
|
...(0, util_1.range)(0x098f, 0x0990), |
||||
|
...(0, util_1.range)(0x0993, 0x09a8), |
||||
|
...(0, util_1.range)(0x09aa, 0x09b0), |
||||
|
0x09b2, |
||||
|
...(0, util_1.range)(0x09b6, 0x09b9), |
||||
|
...(0, util_1.range)(0x09be, 0x09c0), |
||||
|
...(0, util_1.range)(0x09c7, 0x09c8), |
||||
|
...(0, util_1.range)(0x09cb, 0x09cc), |
||||
|
0x09d7, |
||||
|
...(0, util_1.range)(0x09dc, 0x09dd), |
||||
|
...(0, util_1.range)(0x09df, 0x09e1), |
||||
|
...(0, util_1.range)(0x09e6, 0x09f1), |
||||
|
...(0, util_1.range)(0x09f4, 0x09fa), |
||||
|
...(0, util_1.range)(0x0a05, 0x0a0a), |
||||
|
...(0, util_1.range)(0x0a0f, 0x0a10), |
||||
|
...(0, util_1.range)(0x0a13, 0x0a28), |
||||
|
...(0, util_1.range)(0x0a2a, 0x0a30), |
||||
|
...(0, util_1.range)(0x0a32, 0x0a33), |
||||
|
...(0, util_1.range)(0x0a35, 0x0a36), |
||||
|
...(0, util_1.range)(0x0a38, 0x0a39), |
||||
|
...(0, util_1.range)(0x0a3e, 0x0a40), |
||||
|
...(0, util_1.range)(0x0a59, 0x0a5c), |
||||
|
0x0a5e, |
||||
|
...(0, util_1.range)(0x0a66, 0x0a6f), |
||||
|
...(0, util_1.range)(0x0a72, 0x0a74), |
||||
|
0x0a83, |
||||
|
...(0, util_1.range)(0x0a85, 0x0a8b), |
||||
|
0x0a8d, |
||||
|
...(0, util_1.range)(0x0a8f, 0x0a91), |
||||
|
...(0, util_1.range)(0x0a93, 0x0aa8), |
||||
|
...(0, util_1.range)(0x0aaa, 0x0ab0), |
||||
|
...(0, util_1.range)(0x0ab2, 0x0ab3), |
||||
|
...(0, util_1.range)(0x0ab5, 0x0ab9), |
||||
|
...(0, util_1.range)(0x0abd, 0x0ac0), |
||||
|
0x0ac9, |
||||
|
...(0, util_1.range)(0x0acb, 0x0acc), |
||||
|
0x0ad0, |
||||
|
0x0ae0, |
||||
|
...(0, util_1.range)(0x0ae6, 0x0aef), |
||||
|
...(0, util_1.range)(0x0b02, 0x0b03), |
||||
|
...(0, util_1.range)(0x0b05, 0x0b0c), |
||||
|
...(0, util_1.range)(0x0b0f, 0x0b10), |
||||
|
...(0, util_1.range)(0x0b13, 0x0b28), |
||||
|
...(0, util_1.range)(0x0b2a, 0x0b30), |
||||
|
...(0, util_1.range)(0x0b32, 0x0b33), |
||||
|
...(0, util_1.range)(0x0b36, 0x0b39), |
||||
|
...(0, util_1.range)(0x0b3d, 0x0b3e), |
||||
|
0x0b40, |
||||
|
...(0, util_1.range)(0x0b47, 0x0b48), |
||||
|
...(0, util_1.range)(0x0b4b, 0x0b4c), |
||||
|
0x0b57, |
||||
|
...(0, util_1.range)(0x0b5c, 0x0b5d), |
||||
|
...(0, util_1.range)(0x0b5f, 0x0b61), |
||||
|
...(0, util_1.range)(0x0b66, 0x0b70), |
||||
|
0x0b83, |
||||
|
...(0, util_1.range)(0x0b85, 0x0b8a), |
||||
|
...(0, util_1.range)(0x0b8e, 0x0b90), |
||||
|
...(0, util_1.range)(0x0b92, 0x0b95), |
||||
|
...(0, util_1.range)(0x0b99, 0x0b9a), |
||||
|
0x0b9c, |
||||
|
...(0, util_1.range)(0x0b9e, 0x0b9f), |
||||
|
...(0, util_1.range)(0x0ba3, 0x0ba4), |
||||
|
...(0, util_1.range)(0x0ba8, 0x0baa), |
||||
|
...(0, util_1.range)(0x0bae, 0x0bb5), |
||||
|
...(0, util_1.range)(0x0bb7, 0x0bb9), |
||||
|
...(0, util_1.range)(0x0bbe, 0x0bbf), |
||||
|
...(0, util_1.range)(0x0bc1, 0x0bc2), |
||||
|
...(0, util_1.range)(0x0bc6, 0x0bc8), |
||||
|
...(0, util_1.range)(0x0bca, 0x0bcc), |
||||
|
0x0bd7, |
||||
|
...(0, util_1.range)(0x0be7, 0x0bf2), |
||||
|
...(0, util_1.range)(0x0c01, 0x0c03), |
||||
|
...(0, util_1.range)(0x0c05, 0x0c0c), |
||||
|
...(0, util_1.range)(0x0c0e, 0x0c10), |
||||
|
...(0, util_1.range)(0x0c12, 0x0c28), |
||||
|
...(0, util_1.range)(0x0c2a, 0x0c33), |
||||
|
...(0, util_1.range)(0x0c35, 0x0c39), |
||||
|
...(0, util_1.range)(0x0c41, 0x0c44), |
||||
|
...(0, util_1.range)(0x0c60, 0x0c61), |
||||
|
...(0, util_1.range)(0x0c66, 0x0c6f), |
||||
|
...(0, util_1.range)(0x0c82, 0x0c83), |
||||
|
...(0, util_1.range)(0x0c85, 0x0c8c), |
||||
|
...(0, util_1.range)(0x0c8e, 0x0c90), |
||||
|
...(0, util_1.range)(0x0c92, 0x0ca8), |
||||
|
...(0, util_1.range)(0x0caa, 0x0cb3), |
||||
|
...(0, util_1.range)(0x0cb5, 0x0cb9), |
||||
|
0x0cbe, |
||||
|
...(0, util_1.range)(0x0cc0, 0x0cc4), |
||||
|
...(0, util_1.range)(0x0cc7, 0x0cc8), |
||||
|
...(0, util_1.range)(0x0cca, 0x0ccb), |
||||
|
...(0, util_1.range)(0x0cd5, 0x0cd6), |
||||
|
0x0cde, |
||||
|
...(0, util_1.range)(0x0ce0, 0x0ce1), |
||||
|
...(0, util_1.range)(0x0ce6, 0x0cef), |
||||
|
...(0, util_1.range)(0x0d02, 0x0d03), |
||||
|
...(0, util_1.range)(0x0d05, 0x0d0c), |
||||
|
...(0, util_1.range)(0x0d0e, 0x0d10), |
||||
|
...(0, util_1.range)(0x0d12, 0x0d28), |
||||
|
...(0, util_1.range)(0x0d2a, 0x0d39), |
||||
|
...(0, util_1.range)(0x0d3e, 0x0d40), |
||||
|
...(0, util_1.range)(0x0d46, 0x0d48), |
||||
|
...(0, util_1.range)(0x0d4a, 0x0d4c), |
||||
|
0x0d57, |
||||
|
...(0, util_1.range)(0x0d60, 0x0d61), |
||||
|
...(0, util_1.range)(0x0d66, 0x0d6f), |
||||
|
...(0, util_1.range)(0x0d82, 0x0d83), |
||||
|
...(0, util_1.range)(0x0d85, 0x0d96), |
||||
|
...(0, util_1.range)(0x0d9a, 0x0db1), |
||||
|
...(0, util_1.range)(0x0db3, 0x0dbb), |
||||
|
0x0dbd, |
||||
|
...(0, util_1.range)(0x0dc0, 0x0dc6), |
||||
|
...(0, util_1.range)(0x0dcf, 0x0dd1), |
||||
|
...(0, util_1.range)(0x0dd8, 0x0ddf), |
||||
|
...(0, util_1.range)(0x0df2, 0x0df4), |
||||
|
...(0, util_1.range)(0x0e01, 0x0e30), |
||||
|
...(0, util_1.range)(0x0e32, 0x0e33), |
||||
|
...(0, util_1.range)(0x0e40, 0x0e46), |
||||
|
...(0, util_1.range)(0x0e4f, 0x0e5b), |
||||
|
...(0, util_1.range)(0x0e81, 0x0e82), |
||||
|
0x0e84, |
||||
|
...(0, util_1.range)(0x0e87, 0x0e88), |
||||
|
0x0e8a, |
||||
|
0x0e8d, |
||||
|
...(0, util_1.range)(0x0e94, 0x0e97), |
||||
|
...(0, util_1.range)(0x0e99, 0x0e9f), |
||||
|
...(0, util_1.range)(0x0ea1, 0x0ea3), |
||||
|
0x0ea5, |
||||
|
0x0ea7, |
||||
|
...(0, util_1.range)(0x0eaa, 0x0eab), |
||||
|
...(0, util_1.range)(0x0ead, 0x0eb0), |
||||
|
...(0, util_1.range)(0x0eb2, 0x0eb3), |
||||
|
0x0ebd, |
||||
|
...(0, util_1.range)(0x0ec0, 0x0ec4), |
||||
|
0x0ec6, |
||||
|
...(0, util_1.range)(0x0ed0, 0x0ed9), |
||||
|
...(0, util_1.range)(0x0edc, 0x0edd), |
||||
|
...(0, util_1.range)(0x0f00, 0x0f17), |
||||
|
...(0, util_1.range)(0x0f1a, 0x0f34), |
||||
|
0x0f36, |
||||
|
0x0f38, |
||||
|
...(0, util_1.range)(0x0f3e, 0x0f47), |
||||
|
...(0, util_1.range)(0x0f49, 0x0f6a), |
||||
|
0x0f7f, |
||||
|
0x0f85, |
||||
|
...(0, util_1.range)(0x0f88, 0x0f8b), |
||||
|
...(0, util_1.range)(0x0fbe, 0x0fc5), |
||||
|
...(0, util_1.range)(0x0fc7, 0x0fcc), |
||||
|
0x0fcf, |
||||
|
...(0, util_1.range)(0x1000, 0x1021), |
||||
|
...(0, util_1.range)(0x1023, 0x1027), |
||||
|
...(0, util_1.range)(0x1029, 0x102a), |
||||
|
0x102c, |
||||
|
0x1031, |
||||
|
0x1038, |
||||
|
...(0, util_1.range)(0x1040, 0x1057), |
||||
|
...(0, util_1.range)(0x10a0, 0x10c5), |
||||
|
...(0, util_1.range)(0x10d0, 0x10f8), |
||||
|
0x10fb, |
||||
|
...(0, util_1.range)(0x1100, 0x1159), |
||||
|
...(0, util_1.range)(0x115f, 0x11a2), |
||||
|
...(0, util_1.range)(0x11a8, 0x11f9), |
||||
|
...(0, util_1.range)(0x1200, 0x1206), |
||||
|
...(0, util_1.range)(0x1208, 0x1246), |
||||
|
0x1248, |
||||
|
...(0, util_1.range)(0x124a, 0x124d), |
||||
|
...(0, util_1.range)(0x1250, 0x1256), |
||||
|
0x1258, |
||||
|
...(0, util_1.range)(0x125a, 0x125d), |
||||
|
...(0, util_1.range)(0x1260, 0x1286), |
||||
|
0x1288, |
||||
|
...(0, util_1.range)(0x128a, 0x128d), |
||||
|
...(0, util_1.range)(0x1290, 0x12ae), |
||||
|
0x12b0, |
||||
|
...(0, util_1.range)(0x12b2, 0x12b5), |
||||
|
...(0, util_1.range)(0x12b8, 0x12be), |
||||
|
0x12c0, |
||||
|
...(0, util_1.range)(0x12c2, 0x12c5), |
||||
|
...(0, util_1.range)(0x12c8, 0x12ce), |
||||
|
...(0, util_1.range)(0x12d0, 0x12d6), |
||||
|
...(0, util_1.range)(0x12d8, 0x12ee), |
||||
|
...(0, util_1.range)(0x12f0, 0x130e), |
||||
|
0x1310, |
||||
|
...(0, util_1.range)(0x1312, 0x1315), |
||||
|
...(0, util_1.range)(0x1318, 0x131e), |
||||
|
...(0, util_1.range)(0x1320, 0x1346), |
||||
|
...(0, util_1.range)(0x1348, 0x135a), |
||||
|
...(0, util_1.range)(0x1361, 0x137c), |
||||
|
...(0, util_1.range)(0x13a0, 0x13f4), |
||||
|
...(0, util_1.range)(0x1401, 0x1676), |
||||
|
...(0, util_1.range)(0x1681, 0x169a), |
||||
|
...(0, util_1.range)(0x16a0, 0x16f0), |
||||
|
...(0, util_1.range)(0x1700, 0x170c), |
||||
|
...(0, util_1.range)(0x170e, 0x1711), |
||||
|
...(0, util_1.range)(0x1720, 0x1731), |
||||
|
...(0, util_1.range)(0x1735, 0x1736), |
||||
|
...(0, util_1.range)(0x1740, 0x1751), |
||||
|
...(0, util_1.range)(0x1760, 0x176c), |
||||
|
...(0, util_1.range)(0x176e, 0x1770), |
||||
|
...(0, util_1.range)(0x1780, 0x17b6), |
||||
|
...(0, util_1.range)(0x17be, 0x17c5), |
||||
|
...(0, util_1.range)(0x17c7, 0x17c8), |
||||
|
...(0, util_1.range)(0x17d4, 0x17da), |
||||
|
0x17dc, |
||||
|
...(0, util_1.range)(0x17e0, 0x17e9), |
||||
|
...(0, util_1.range)(0x1810, 0x1819), |
||||
|
...(0, util_1.range)(0x1820, 0x1877), |
||||
|
...(0, util_1.range)(0x1880, 0x18a8), |
||||
|
...(0, util_1.range)(0x1e00, 0x1e9b), |
||||
|
...(0, util_1.range)(0x1ea0, 0x1ef9), |
||||
|
...(0, util_1.range)(0x1f00, 0x1f15), |
||||
|
...(0, util_1.range)(0x1f18, 0x1f1d), |
||||
|
...(0, util_1.range)(0x1f20, 0x1f45), |
||||
|
...(0, util_1.range)(0x1f48, 0x1f4d), |
||||
|
...(0, util_1.range)(0x1f50, 0x1f57), |
||||
|
0x1f59, |
||||
|
0x1f5b, |
||||
|
0x1f5d, |
||||
|
...(0, util_1.range)(0x1f5f, 0x1f7d), |
||||
|
...(0, util_1.range)(0x1f80, 0x1fb4), |
||||
|
...(0, util_1.range)(0x1fb6, 0x1fbc), |
||||
|
0x1fbe, |
||||
|
...(0, util_1.range)(0x1fc2, 0x1fc4), |
||||
|
...(0, util_1.range)(0x1fc6, 0x1fcc), |
||||
|
...(0, util_1.range)(0x1fd0, 0x1fd3), |
||||
|
...(0, util_1.range)(0x1fd6, 0x1fdb), |
||||
|
...(0, util_1.range)(0x1fe0, 0x1fec), |
||||
|
...(0, util_1.range)(0x1ff2, 0x1ff4), |
||||
|
...(0, util_1.range)(0x1ff6, 0x1ffc), |
||||
|
0x200e, |
||||
|
0x2071, |
||||
|
0x207f, |
||||
|
0x2102, |
||||
|
0x2107, |
||||
|
...(0, util_1.range)(0x210a, 0x2113), |
||||
|
0x2115, |
||||
|
...(0, util_1.range)(0x2119, 0x211d), |
||||
|
0x2124, |
||||
|
0x2126, |
||||
|
0x2128, |
||||
|
...(0, util_1.range)(0x212a, 0x212d), |
||||
|
...(0, util_1.range)(0x212f, 0x2131), |
||||
|
...(0, util_1.range)(0x2133, 0x2139), |
||||
|
...(0, util_1.range)(0x213d, 0x213f), |
||||
|
...(0, util_1.range)(0x2145, 0x2149), |
||||
|
...(0, util_1.range)(0x2160, 0x2183), |
||||
|
...(0, util_1.range)(0x2336, 0x237a), |
||||
|
0x2395, |
||||
|
...(0, util_1.range)(0x249c, 0x24e9), |
||||
|
...(0, util_1.range)(0x3005, 0x3007), |
||||
|
...(0, util_1.range)(0x3021, 0x3029), |
||||
|
...(0, util_1.range)(0x3031, 0x3035), |
||||
|
...(0, util_1.range)(0x3038, 0x303c), |
||||
|
...(0, util_1.range)(0x3041, 0x3096), |
||||
|
...(0, util_1.range)(0x309d, 0x309f), |
||||
|
...(0, util_1.range)(0x30a1, 0x30fa), |
||||
|
...(0, util_1.range)(0x30fc, 0x30ff), |
||||
|
...(0, util_1.range)(0x3105, 0x312c), |
||||
|
...(0, util_1.range)(0x3131, 0x318e), |
||||
|
...(0, util_1.range)(0x3190, 0x31b7), |
||||
|
...(0, util_1.range)(0x31f0, 0x321c), |
||||
|
...(0, util_1.range)(0x3220, 0x3243), |
||||
|
...(0, util_1.range)(0x3260, 0x327b), |
||||
|
...(0, util_1.range)(0x327f, 0x32b0), |
||||
|
...(0, util_1.range)(0x32c0, 0x32cb), |
||||
|
...(0, util_1.range)(0x32d0, 0x32fe), |
||||
|
...(0, util_1.range)(0x3300, 0x3376), |
||||
|
...(0, util_1.range)(0x337b, 0x33dd), |
||||
|
...(0, util_1.range)(0x33e0, 0x33fe), |
||||
|
...(0, util_1.range)(0x3400, 0x4db5), |
||||
|
...(0, util_1.range)(0x4e00, 0x9fa5), |
||||
|
...(0, util_1.range)(0xa000, 0xa48c), |
||||
|
...(0, util_1.range)(0xac00, 0xd7a3), |
||||
|
...(0, util_1.range)(0xd800, 0xfa2d), |
||||
|
...(0, util_1.range)(0xfa30, 0xfa6a), |
||||
|
...(0, util_1.range)(0xfb00, 0xfb06), |
||||
|
...(0, util_1.range)(0xfb13, 0xfb17), |
||||
|
...(0, util_1.range)(0xff21, 0xff3a), |
||||
|
...(0, util_1.range)(0xff41, 0xff5a), |
||||
|
...(0, util_1.range)(0xff66, 0xffbe), |
||||
|
...(0, util_1.range)(0xffc2, 0xffc7), |
||||
|
...(0, util_1.range)(0xffca, 0xffcf), |
||||
|
...(0, util_1.range)(0xffd2, 0xffd7), |
||||
|
...(0, util_1.range)(0xffda, 0xffdc), |
||||
|
...(0, util_1.range)(0x10300, 0x1031e), |
||||
|
...(0, util_1.range)(0x10320, 0x10323), |
||||
|
...(0, util_1.range)(0x10330, 0x1034a), |
||||
|
...(0, util_1.range)(0x10400, 0x10425), |
||||
|
...(0, util_1.range)(0x10428, 0x1044d), |
||||
|
...(0, util_1.range)(0x1d000, 0x1d0f5), |
||||
|
...(0, util_1.range)(0x1d100, 0x1d126), |
||||
|
...(0, util_1.range)(0x1d12a, 0x1d166), |
||||
|
...(0, util_1.range)(0x1d16a, 0x1d172), |
||||
|
...(0, util_1.range)(0x1d183, 0x1d184), |
||||
|
...(0, util_1.range)(0x1d18c, 0x1d1a9), |
||||
|
...(0, util_1.range)(0x1d1ae, 0x1d1dd), |
||||
|
...(0, util_1.range)(0x1d400, 0x1d454), |
||||
|
...(0, util_1.range)(0x1d456, 0x1d49c), |
||||
|
...(0, util_1.range)(0x1d49e, 0x1d49f), |
||||
|
0x1d4a2, |
||||
|
...(0, util_1.range)(0x1d4a5, 0x1d4a6), |
||||
|
...(0, util_1.range)(0x1d4a9, 0x1d4ac), |
||||
|
...(0, util_1.range)(0x1d4ae, 0x1d4b9), |
||||
|
0x1d4bb, |
||||
|
...(0, util_1.range)(0x1d4bd, 0x1d4c0), |
||||
|
...(0, util_1.range)(0x1d4c2, 0x1d4c3), |
||||
|
...(0, util_1.range)(0x1d4c5, 0x1d505), |
||||
|
...(0, util_1.range)(0x1d507, 0x1d50a), |
||||
|
...(0, util_1.range)(0x1d50d, 0x1d514), |
||||
|
...(0, util_1.range)(0x1d516, 0x1d51c), |
||||
|
...(0, util_1.range)(0x1d51e, 0x1d539), |
||||
|
...(0, util_1.range)(0x1d53b, 0x1d53e), |
||||
|
...(0, util_1.range)(0x1d540, 0x1d544), |
||||
|
0x1d546, |
||||
|
...(0, util_1.range)(0x1d54a, 0x1d550), |
||||
|
...(0, util_1.range)(0x1d552, 0x1d6a3), |
||||
|
...(0, util_1.range)(0x1d6a8, 0x1d7c9), |
||||
|
...(0, util_1.range)(0x20000, 0x2a6d6), |
||||
|
...(0, util_1.range)(0x2f800, 0x2fa1d), |
||||
|
...(0, util_1.range)(0xf0000, 0xffffd), |
||||
|
...(0, util_1.range)(0x100000, 0x10fffd), |
||||
|
]); |
||||
|
//# sourceMappingURL=code-points-src.js.map
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@ |
|||||
|
export {}; |
||||
|
//# sourceMappingURL=generate-code-points.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"generate-code-points.d.ts","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":""} |
||||
@ -0,0 +1,83 @@ |
|||||
|
"use strict"; |
||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
||||
|
if (k2 === undefined) k2 = k; |
||||
|
var desc = Object.getOwnPropertyDescriptor(m, k); |
||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
||||
|
desc = { enumerable: true, get: function() { return m[k]; } }; |
||||
|
} |
||||
|
Object.defineProperty(o, k2, desc); |
||||
|
}) : (function(o, m, k, k2) { |
||||
|
if (k2 === undefined) k2 = k; |
||||
|
o[k2] = m[k]; |
||||
|
})); |
||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v }); |
||||
|
}) : function(o, v) { |
||||
|
o["default"] = v; |
||||
|
}); |
||||
|
var __importStar = (this && this.__importStar) || (function () { |
||||
|
var ownKeys = function(o) { |
||||
|
ownKeys = Object.getOwnPropertyNames || function (o) { |
||||
|
var ar = []; |
||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; |
||||
|
return ar; |
||||
|
}; |
||||
|
return ownKeys(o); |
||||
|
}; |
||||
|
return function (mod) { |
||||
|
if (mod && mod.__esModule) return mod; |
||||
|
var result = {}; |
||||
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); |
||||
|
__setModuleDefault(result, mod); |
||||
|
return result; |
||||
|
}; |
||||
|
})(); |
||||
|
var __importDefault = (this && this.__importDefault) || function (mod) { |
||||
|
return (mod && mod.__esModule) ? mod : { "default": mod }; |
||||
|
}; |
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
const zlib_1 = require("zlib"); |
||||
|
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield")); |
||||
|
const codePoints = __importStar(require("./code-points-src")); |
||||
|
const fs_1 = require("fs"); |
||||
|
const prettier = __importStar(require("prettier")); |
||||
|
const unassigned_code_points = (0, sparse_bitfield_1.default)(); |
||||
|
const commonly_mapped_to_nothing = (0, sparse_bitfield_1.default)(); |
||||
|
const non_ascii_space_characters = (0, sparse_bitfield_1.default)(); |
||||
|
const prohibited_characters = (0, sparse_bitfield_1.default)(); |
||||
|
const bidirectional_r_al = (0, sparse_bitfield_1.default)(); |
||||
|
const bidirectional_l = (0, sparse_bitfield_1.default)(); |
||||
|
function traverse(bits, src) { |
||||
|
for (const code of src.keys()) { |
||||
|
bits.set(code, true); |
||||
|
} |
||||
|
const buffer = bits.toBuffer(); |
||||
|
return Buffer.concat([createSize(buffer), buffer]); |
||||
|
} |
||||
|
function createSize(buffer) { |
||||
|
const buf = Buffer.alloc(4); |
||||
|
buf.writeUInt32BE(buffer.length); |
||||
|
return buf; |
||||
|
} |
||||
|
const memory = []; |
||||
|
memory.push(traverse(unassigned_code_points, codePoints.unassigned_code_points), traverse(commonly_mapped_to_nothing, codePoints.commonly_mapped_to_nothing), traverse(non_ascii_space_characters, codePoints.non_ASCII_space_characters), traverse(prohibited_characters, codePoints.prohibited_characters), traverse(bidirectional_r_al, codePoints.bidirectional_r_al), traverse(bidirectional_l, codePoints.bidirectional_l)); |
||||
|
async function writeCodepoints() { |
||||
|
const config = await prettier.resolveConfig(__dirname); |
||||
|
const formatOptions = { ...config, parser: 'typescript' }; |
||||
|
function write(stream, chunk) { |
||||
|
return new Promise((resolve) => stream.write(chunk, () => resolve())); |
||||
|
} |
||||
|
await write((0, fs_1.createWriteStream)(process.argv[2]), await prettier.format(`import { gunzipSync } from 'zlib';
|
||||
|
|
||||
|
export default gunzipSync( |
||||
|
Buffer.from( |
||||
|
'${(0, zlib_1.gzipSync)(Buffer.concat(memory), { level: 9 }).toString('base64')}', |
||||
|
'base64' |
||||
|
) |
||||
|
); |
||||
|
`, formatOptions));
|
||||
|
const fsStreamUncompressedData = (0, fs_1.createWriteStream)(process.argv[3]); |
||||
|
await write(fsStreamUncompressedData, await prettier.format(`const data = Buffer.from('${Buffer.concat(memory).toString('base64')}', 'base64');\nexport default data;\n`, formatOptions)); |
||||
|
} |
||||
|
writeCodepoints().catch((error) => console.error('error occurred generating saslprep codepoint data', { error })); |
||||
|
//# sourceMappingURL=generate-code-points.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"generate-code-points.js","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAgC;AAChC,sEAAuC;AACvC,8DAAgD;AAChD,2BAAuC;AACvC,mDAAqC;AAGrC,MAAM,sBAAsB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC1C,MAAM,0BAA0B,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC9C,MAAM,0BAA0B,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC9C,MAAM,qBAAqB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AACzC,MAAM,kBAAkB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AACtC,MAAM,eAAe,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAMnC,SAAS,QAAQ,CAAC,IAA+B,EAAE,GAAgB;IACjE,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,MAAM,GAAa,EAAE,CAAC;AAE5B,MAAM,CAAC,IAAI,CACT,QAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC,sBAAsB,CAAC,EACnE,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,0BAA0B,CAAC,EAC3E,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,0BAA0B,CAAC,EAC3E,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,qBAAqB,CAAC,EACjE,QAAQ,CAAC,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC3D,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,CACtD,CAAC;AAEF,KAAK,UAAU,eAAe;IAC5B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAE1D,SAAS,KAAK,CAAC,MAAgB,EAAE,KAAa;QAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,KAAK,CACT,IAAA,sBAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAClC,MAAM,QAAQ,CAAC,MAAM,CACnB;;;;SAIG,IAAA,eAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;;GAItE,EACG,aAAa,CACd,CACF,CAAC;IAEF,MAAM,wBAAwB,GAAG,IAAA,sBAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpE,MAAM,KAAK,CACT,wBAAwB,EACxB,MAAM,QAAQ,CAAC,MAAM,CACnB,6BAA6B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CACzD,QAAQ,CACT,uCAAuC,EACxC,aAAa,CACd,CACF,CAAC;AACJ,CAAC;AAED,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAEhC,OAAO,CAAC,KAAK,CAAC,mDAAmD,EAAE,EAAE,KAAK,EAAE,CAAC,CAC9E,CAAC"} |
||||
@ -0,0 +1,11 @@ |
|||||
|
import type { createMemoryCodePoints } from './memory-code-points'; |
||||
|
declare function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }: ReturnType<typeof createMemoryCodePoints>, input: string, opts?: { |
||||
|
allowUnassigned?: boolean; |
||||
|
}): string; |
||||
|
declare namespace saslprep { |
||||
|
export var saslprep: typeof import("."); |
||||
|
var _a: typeof import("."); |
||||
|
export { _a as default }; |
||||
|
} |
||||
|
export = saslprep; |
||||
|
//# sourceMappingURL=index.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAsCnE,iBAAS,QAAQ,CACf,EACE,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EAC5C,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,MAAM,CAqGR;kBAhHQ,QAAQ;;;;;AAoHjB,SAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,65 @@ |
|||||
|
"use strict"; |
||||
|
const getCodePoint = (character) => character.codePointAt(0); |
||||
|
const first = (x) => x[0]; |
||||
|
const last = (x) => x[x.length - 1]; |
||||
|
function toCodePoints(input) { |
||||
|
const codepoints = []; |
||||
|
const size = input.length; |
||||
|
for (let i = 0; i < size; i += 1) { |
||||
|
const before = input.charCodeAt(i); |
||||
|
if (before >= 0xd800 && before <= 0xdbff && size > i + 1) { |
||||
|
const next = input.charCodeAt(i + 1); |
||||
|
if (next >= 0xdc00 && next <= 0xdfff) { |
||||
|
codepoints.push((before - 0xd800) * 0x400 + next - 0xdc00 + 0x10000); |
||||
|
i += 1; |
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
codepoints.push(before); |
||||
|
} |
||||
|
return codepoints; |
||||
|
} |
||||
|
function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }, input, opts = {}) { |
||||
|
const mapping2space = non_ASCII_space_characters; |
||||
|
const mapping2nothing = commonly_mapped_to_nothing; |
||||
|
if (typeof input !== 'string') { |
||||
|
throw new TypeError('Expected string.'); |
||||
|
} |
||||
|
if (input.length === 0) { |
||||
|
return ''; |
||||
|
} |
||||
|
const mapped_input = toCodePoints(input) |
||||
|
.map((character) => (mapping2space.get(character) ? 0x20 : character)) |
||||
|
.filter((character) => !mapping2nothing.get(character)); |
||||
|
const normalized_input = String.fromCodePoint |
||||
|
.apply(null, mapped_input) |
||||
|
.normalize('NFKC'); |
||||
|
const normalized_map = toCodePoints(normalized_input); |
||||
|
const hasProhibited = normalized_map.some((character) => prohibited_characters.get(character)); |
||||
|
if (hasProhibited) { |
||||
|
throw new Error('Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3'); |
||||
|
} |
||||
|
if (opts.allowUnassigned !== true) { |
||||
|
const hasUnassigned = normalized_map.some((character) => unassigned_code_points.get(character)); |
||||
|
if (hasUnassigned) { |
||||
|
throw new Error('Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5'); |
||||
|
} |
||||
|
} |
||||
|
const hasBidiRAL = normalized_map.some((character) => bidirectional_r_al.get(character)); |
||||
|
const hasBidiL = normalized_map.some((character) => bidirectional_l.get(character)); |
||||
|
if (hasBidiRAL && hasBidiL) { |
||||
|
throw new Error('String must not contain RandALCat and LCat at the same time,' + |
||||
|
' see https://tools.ietf.org/html/rfc3454#section-6'); |
||||
|
} |
||||
|
const isFirstBidiRAL = bidirectional_r_al.get(getCodePoint(first(normalized_input))); |
||||
|
const isLastBidiRAL = bidirectional_r_al.get(getCodePoint(last(normalized_input))); |
||||
|
if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) { |
||||
|
throw new Error('Bidirectional RandALCat character must be the first and the last' + |
||||
|
' character of the string, see https://tools.ietf.org/html/rfc3454#section-6'); |
||||
|
} |
||||
|
return normalized_input; |
||||
|
} |
||||
|
saslprep.saslprep = saslprep; |
||||
|
saslprep.default = saslprep; |
||||
|
module.exports = saslprep; |
||||
|
//# sourceMappingURL=index.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,KAAK,GAAG,CAA2B,CAAI,EAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,MAAM,IAAI,GAAG,CAA2B,CAAI,EAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAO5E,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEnC,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAErC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACrC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;gBACrE,CAAC,IAAI,CAAC,CAAC;gBACP,SAAS;YACX,CAAC;QACH,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAKD,SAAS,QAAQ,CACf,EACE,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAC2B,EAC5C,KAAa,EACb,OAAsC,EAAE;IAQxC,MAAM,aAAa,GAAG,0BAA0B,CAAC;IAMjD,MAAM,eAAe,GAAG,0BAA0B,CAAC;IAEnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAGD,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC;SAErC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAErE,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAG1D,MAAM,gBAAgB,GAAG,MAAM,CAAC,aAAa;SAC1C,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC;SACzB,SAAS,CAAC,MAAM,CAAC,CAAC;IAErB,MAAM,cAAc,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAGtD,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACtD,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CACrC,CAAC;IAEF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IAGD,IAAI,IAAI,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;QAClC,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACtD,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,CACtC,CAAC;QAEF,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;QACJ,CAAC;IACH,CAAC;IAID,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACnD,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAClC,CAAC;IAEF,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACjD,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAC/B,CAAC;IAIF,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,8DAA8D;YAC5D,oDAAoD,CACvD,CAAC;IACJ,CAAC;IAQD,MAAM,cAAc,GAAG,kBAAkB,CAAC,GAAG,CAC3C,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAE,CACvC,CAAC;IACF,MAAM,aAAa,GAAG,kBAAkB,CAAC,GAAG,CAC1C,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAE,CACtC,CAAC;IAEF,IAAI,UAAU,IAAI,CAAC,CAAC,cAAc,IAAI,aAAa,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACb,kEAAkE;YAChE,6EAA6E,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC;AAC5B,iBAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,10 @@ |
|||||
|
import bitfield from 'sparse-bitfield'; |
||||
|
export declare function createMemoryCodePoints(data: Buffer): { |
||||
|
unassigned_code_points: bitfield.BitFieldInstance; |
||||
|
commonly_mapped_to_nothing: bitfield.BitFieldInstance; |
||||
|
non_ASCII_space_characters: bitfield.BitFieldInstance; |
||||
|
prohibited_characters: bitfield.BitFieldInstance; |
||||
|
bidirectional_r_al: bitfield.BitFieldInstance; |
||||
|
bidirectional_l: bitfield.BitFieldInstance; |
||||
|
}; |
||||
|
//# sourceMappingURL=memory-code-points.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"memory-code-points.d.ts","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM;;;;;;;EA+BlD"} |
||||
@ -0,0 +1,32 @@ |
|||||
|
"use strict"; |
||||
|
var __importDefault = (this && this.__importDefault) || function (mod) { |
||||
|
return (mod && mod.__esModule) ? mod : { "default": mod }; |
||||
|
}; |
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
exports.createMemoryCodePoints = createMemoryCodePoints; |
||||
|
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield")); |
||||
|
function createMemoryCodePoints(data) { |
||||
|
let offset = 0; |
||||
|
function read() { |
||||
|
const size = data.readUInt32BE(offset); |
||||
|
offset += 4; |
||||
|
const codepoints = data.slice(offset, offset + size); |
||||
|
offset += size; |
||||
|
return (0, sparse_bitfield_1.default)({ buffer: codepoints }); |
||||
|
} |
||||
|
const unassigned_code_points = read(); |
||||
|
const commonly_mapped_to_nothing = read(); |
||||
|
const non_ASCII_space_characters = read(); |
||||
|
const prohibited_characters = read(); |
||||
|
const bidirectional_r_al = read(); |
||||
|
const bidirectional_l = read(); |
||||
|
return { |
||||
|
unassigned_code_points, |
||||
|
commonly_mapped_to_nothing, |
||||
|
non_ASCII_space_characters, |
||||
|
prohibited_characters, |
||||
|
bidirectional_r_al, |
||||
|
bidirectional_l, |
||||
|
}; |
||||
|
} |
||||
|
//# sourceMappingURL=memory-code-points.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"memory-code-points.js","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":";;;;;AAEA,wDA+BC;AAjCD,sEAAuC;AAEvC,SAAgB,sBAAsB,CAAC,IAAY;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IAKf,SAAS,IAAI;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACrD,MAAM,IAAI,IAAI,CAAC;QAEf,OAAO,IAAA,yBAAQ,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,EAAE,CAAC;IACtC,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,qBAAqB,GAAG,IAAI,EAAE,CAAC;IACrC,MAAM,kBAAkB,GAAG,IAAI,EAAE,CAAC;IAClC,MAAM,eAAe,GAAG,IAAI,EAAE,CAAC;IAE/B,OAAO;QACL,sBAAsB;QACtB,0BAA0B;QAC1B,0BAA0B;QAC1B,qBAAqB;QACrB,kBAAkB;QAClB,eAAe;KAChB,CAAC;AACJ,CAAC"} |
||||
@ -0,0 +1,10 @@ |
|||||
|
declare function saslprep(input: string, opts?: { |
||||
|
allowUnassigned?: boolean; |
||||
|
}): string; |
||||
|
declare namespace saslprep { |
||||
|
export var saslprep: typeof import("./node"); |
||||
|
var _a: typeof import("./node"); |
||||
|
export { _a as default }; |
||||
|
} |
||||
|
export = saslprep; |
||||
|
//# sourceMappingURL=node.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAMA,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAE7E;kBAFQ,QAAQ;;;;;AAOjB,SAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,15 @@ |
|||||
|
"use strict"; |
||||
|
var __importDefault = (this && this.__importDefault) || function (mod) { |
||||
|
return (mod && mod.__esModule) ? mod : { "default": mod }; |
||||
|
}; |
||||
|
const index_1 = __importDefault(require("./index")); |
||||
|
const memory_code_points_1 = require("./memory-code-points"); |
||||
|
const code_points_data_1 = __importDefault(require("./code-points-data")); |
||||
|
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_1.default); |
||||
|
function saslprep(input, opts) { |
||||
|
return (0, index_1.default)(codePoints, input, opts); |
||||
|
} |
||||
|
saslprep.saslprep = saslprep; |
||||
|
saslprep.default = saslprep; |
||||
|
module.exports = saslprep; |
||||
|
//# sourceMappingURL=node.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0EAAsC;AAEtC,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,0BAAI,CAAC,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAoC;IACnE,OAAO,IAAA,eAAS,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC;AAE5B,iBAAS,QAAQ,CAAC"} |
||||
@ -0,0 +1,2 @@ |
|||||
|
export declare function range(from: number, to: number): number[]; |
||||
|
//# sourceMappingURL=util.d.ts.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAQxD"} |
||||
@ -0,0 +1,11 @@ |
|||||
|
"use strict"; |
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
exports.range = range; |
||||
|
function range(from, to) { |
||||
|
const list = new Array(to - from + 1); |
||||
|
for (let i = 0; i < list.length; i += 1) { |
||||
|
list[i] = from + i; |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
//# sourceMappingURL=util.js.map
|
||||
@ -0,0 +1 @@ |
|||||
|
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAGA,sBAQC;AARD,SAAgB,KAAK,CAAC,IAAY,EAAE,EAAU;IAE5C,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"} |
||||
@ -0,0 +1,87 @@ |
|||||
|
{ |
||||
|
"name": "@mongodb-js/saslprep", |
||||
|
"description": "SASLprep: Stringprep Profile for User Names and Passwords, rfc4013", |
||||
|
"keywords": [ |
||||
|
"sasl", |
||||
|
"saslprep", |
||||
|
"stringprep", |
||||
|
"rfc4013", |
||||
|
"4013" |
||||
|
], |
||||
|
"author": "Dmitry Tsvettsikh <me@reklatsmasters.com>", |
||||
|
"publishConfig": { |
||||
|
"access": "public" |
||||
|
}, |
||||
|
"main": "dist/node.js", |
||||
|
"bugs": { |
||||
|
"url": "https://jira.mongodb.org/projects/COMPASS/issues", |
||||
|
"email": "compass@mongodb.com" |
||||
|
}, |
||||
|
"homepage": "https://github.com/mongodb-js/devtools-shared/tree/main/packages/saslprep", |
||||
|
"version": "1.3.0", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/mongodb-js/devtools-shared.git" |
||||
|
}, |
||||
|
"files": [ |
||||
|
"dist" |
||||
|
], |
||||
|
"license": "MIT", |
||||
|
"exports": { |
||||
|
"browser": { |
||||
|
"types": "./dist/browser.d.ts", |
||||
|
"default": "./dist/browser.js" |
||||
|
}, |
||||
|
"import": { |
||||
|
"types": "./dist/node.d.ts", |
||||
|
"default": "./dist/.esm-wrapper.mjs" |
||||
|
}, |
||||
|
"require": { |
||||
|
"types": "./dist/node.d.ts", |
||||
|
"default": "./dist/node.js" |
||||
|
} |
||||
|
}, |
||||
|
"types": "./dist/node.d.ts", |
||||
|
"scripts": { |
||||
|
"gen-code-points": "ts-node src/generate-code-points.ts src/code-points-data.ts src/code-points-data-browser.ts", |
||||
|
"bootstrap": "npm run compile", |
||||
|
"prepublishOnly": "npm run compile", |
||||
|
"compile": "npm run gen-code-points && tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", |
||||
|
"typecheck": "tsc --noEmit", |
||||
|
"eslint": "eslint", |
||||
|
"prettier": "prettier", |
||||
|
"lint": "npm run eslint . && npm run prettier -- --check .", |
||||
|
"depcheck": "depcheck", |
||||
|
"check": "npm run typecheck && npm run lint && npm run depcheck", |
||||
|
"check-ci": "npm run check", |
||||
|
"test": "mocha", |
||||
|
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", |
||||
|
"test-watch": "npm run test -- --watch", |
||||
|
"test-ci": "npm run test-cov", |
||||
|
"reformat": "npm run prettier -- --write ." |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"sparse-bitfield": "^3.0.3" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"@mongodb-js/eslint-config-devtools": "0.9.11", |
||||
|
"@mongodb-js/mocha-config-devtools": "^1.0.5", |
||||
|
"@mongodb-js/prettier-config-devtools": "^1.0.2", |
||||
|
"@mongodb-js/tsconfig-devtools": "^1.0.3", |
||||
|
"@types/chai": "^4.2.21", |
||||
|
"@types/mocha": "^9.1.1", |
||||
|
"@types/node": "^22.15.30", |
||||
|
"@types/sinon-chai": "^3.2.5", |
||||
|
"@types/sparse-bitfield": "^3.0.1", |
||||
|
"chai": "^4.5.0", |
||||
|
"depcheck": "^1.4.7", |
||||
|
"eslint": "^7.25.0", |
||||
|
"gen-esm-wrapper": "^1.1.3", |
||||
|
"mocha": "^8.4.0", |
||||
|
"nyc": "^15.1.0", |
||||
|
"prettier": "^3.5.3", |
||||
|
"sinon": "^9.2.3", |
||||
|
"typescript": "^5.0.4" |
||||
|
}, |
||||
|
"gitHead": "005f6263e3a329d916f6936c9adcf35db47cfe9f" |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
# saslprep |
||||
|
|
||||
|
_Note: This is a fork of the original [`saslprep`](https://www.npmjs.com/package/saslprep) npm package |
||||
|
and provides equivalent functionality._ |
||||
|
|
||||
|
Stringprep Profile for User Names and Passwords, [rfc4013](https://tools.ietf.org/html/rfc4013) |
||||
|
|
||||
|
### Usage |
||||
|
|
||||
|
```js |
||||
|
const saslprep = require('@mongodb-js/saslprep'); |
||||
|
|
||||
|
saslprep('password\u00AD'); // password |
||||
|
saslprep('password\u0007'); // Error: prohibited character |
||||
|
``` |
||||
|
|
||||
|
### API |
||||
|
|
||||
|
##### `saslprep(input: String, opts: Options): String` |
||||
|
|
||||
|
Normalize user name or password. |
||||
|
|
||||
|
##### `Options.allowUnassigned: bool` |
||||
|
|
||||
|
A special behavior for unassigned code points, see https://tools.ietf.org/html/rfc4013#section-2.5. Disabled by default. |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
MIT, 2017-2019 (c) Dmitriy Tsvettsikh |
||||
@ -0,0 +1,21 @@ |
|||||
|
MIT License |
||||
|
|
||||
|
Copyright (c) Microsoft Corporation. |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE |
||||
@ -0,0 +1,15 @@ |
|||||
|
# Installation |
||||
|
> `npm install --save @types/webidl-conversions` |
||||
|
|
||||
|
# Summary |
||||
|
This package contains type definitions for webidl-conversions (https://github.com/jsdom/webidl-conversions#readme). |
||||
|
|
||||
|
# Details |
||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions. |
||||
|
|
||||
|
### Additional Details |
||||
|
* Last updated: Tue, 07 Nov 2023 15:11:36 GMT |
||||
|
* Dependencies: none |
||||
|
|
||||
|
# Credits |
||||
|
These definitions were written by [ExE Boss](https://github.com/ExE-Boss), and [BendingBender](https://github.com/BendingBender). |
||||
@ -0,0 +1,91 @@ |
|||||
|
declare namespace WebIDLConversions { |
||||
|
interface Globals { |
||||
|
[key: string]: unknown; |
||||
|
|
||||
|
Number: (value?: unknown) => number; |
||||
|
String: (value?: unknown) => string; |
||||
|
TypeError: new(message?: string) => TypeError; |
||||
|
} |
||||
|
|
||||
|
interface Options { |
||||
|
context?: string | undefined; |
||||
|
globals?: Globals | undefined; |
||||
|
} |
||||
|
|
||||
|
interface IntegerOptions extends Options { |
||||
|
enforceRange?: boolean | undefined; |
||||
|
clamp?: boolean | undefined; |
||||
|
} |
||||
|
|
||||
|
interface StringOptions extends Options { |
||||
|
treatNullAsEmptyString?: boolean | undefined; |
||||
|
} |
||||
|
|
||||
|
interface BufferSourceOptions extends Options { |
||||
|
allowShared?: boolean | undefined; |
||||
|
} |
||||
|
|
||||
|
type IntegerConversion = (V: unknown, opts?: IntegerOptions) => number; |
||||
|
type StringConversion = (V: unknown, opts?: StringOptions) => string; |
||||
|
type NumberConversion = (V: unknown, opts?: Options) => number; |
||||
|
} |
||||
|
|
||||
|
declare const WebIDLConversions: { |
||||
|
any<V>(V: V, opts?: WebIDLConversions.Options): V; |
||||
|
undefined(V?: unknown, opts?: WebIDLConversions.Options): void; |
||||
|
boolean(V: unknown, opts?: WebIDLConversions.Options): boolean; |
||||
|
|
||||
|
byte(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
octet(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
|
||||
|
short(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
["unsigned short"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
|
||||
|
long(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
["unsigned long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
|
||||
|
["long long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
["unsigned long long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; |
||||
|
|
||||
|
double(V: unknown, opts?: WebIDLConversions.Options): number; |
||||
|
["unrestricted double"](V: unknown, opts?: WebIDLConversions.Options): number; |
||||
|
|
||||
|
float(V: unknown, opts?: WebIDLConversions.Options): number; |
||||
|
["unrestricted float"](V: unknown, opts?: WebIDLConversions.Options): number; |
||||
|
|
||||
|
DOMString(V: unknown, opts?: WebIDLConversions.StringOptions): string; |
||||
|
ByteString(V: unknown, opts?: WebIDLConversions.StringOptions): string; |
||||
|
USVString(V: unknown, opts?: WebIDLConversions.StringOptions): string; |
||||
|
|
||||
|
object<V>(V: V, opts?: WebIDLConversions.Options): V extends object ? V : V & object; |
||||
|
ArrayBuffer( |
||||
|
V: unknown, |
||||
|
opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined }, |
||||
|
): ArrayBuffer; |
||||
|
ArrayBuffer(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike; |
||||
|
DataView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): DataView; |
||||
|
|
||||
|
Int8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int8Array; |
||||
|
Int16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int16Array; |
||||
|
Int32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int32Array; |
||||
|
|
||||
|
Uint8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8Array; |
||||
|
Uint16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint16Array; |
||||
|
Uint32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint32Array; |
||||
|
Uint8ClampedArray(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8ClampedArray; |
||||
|
|
||||
|
Float32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float32Array; |
||||
|
Float64Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float64Array; |
||||
|
|
||||
|
ArrayBufferView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferView; |
||||
|
BufferSource( |
||||
|
V: unknown, |
||||
|
opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined }, |
||||
|
): ArrayBuffer | ArrayBufferView; |
||||
|
BufferSource(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike | ArrayBufferView; |
||||
|
|
||||
|
DOMTimeStamp(V: unknown, opts?: WebIDLConversions.Options): number; |
||||
|
}; |
||||
|
|
||||
|
// This can't use ES6 style exports, as those can't have spaces in export names.
|
||||
|
export = WebIDLConversions; |
||||
@ -0,0 +1,30 @@ |
|||||
|
{ |
||||
|
"name": "@types/webidl-conversions", |
||||
|
"version": "7.0.3", |
||||
|
"description": "TypeScript definitions for webidl-conversions", |
||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions", |
||||
|
"license": "MIT", |
||||
|
"contributors": [ |
||||
|
{ |
||||
|
"name": "ExE Boss", |
||||
|
"githubUsername": "ExE-Boss", |
||||
|
"url": "https://github.com/ExE-Boss" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "BendingBender", |
||||
|
"githubUsername": "BendingBender", |
||||
|
"url": "https://github.com/BendingBender" |
||||
|
} |
||||
|
], |
||||
|
"main": "", |
||||
|
"types": "index.d.ts", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", |
||||
|
"directory": "types/webidl-conversions" |
||||
|
}, |
||||
|
"scripts": {}, |
||||
|
"dependencies": {}, |
||||
|
"typesPublisherContentHash": "ff1514e10869784e8b7cca9c4099a4213d3f14b48c198b1bf116300df94bf608", |
||||
|
"typeScriptVersion": "4.5" |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
MIT License |
||||
|
|
||||
|
Copyright (c) Microsoft Corporation. |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE |
||||
@ -0,0 +1,15 @@ |
|||||
|
# Installation |
||||
|
> `npm install --save @types/whatwg-url` |
||||
|
|
||||
|
# Summary |
||||
|
This package contains type definitions for whatwg-url (https://github.com/jsdom/whatwg-url#readme). |
||||
|
|
||||
|
# Details |
||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-url. |
||||
|
|
||||
|
### Additional Details |
||||
|
* Last updated: Sat, 18 May 2024 21:06:54 GMT |
||||
|
* Dependencies: [@types/webidl-conversions](https://npmjs.com/package/@types/webidl-conversions) |
||||
|
|
||||
|
# Credits |
||||
|
These definitions were written by [Alexander Marks](https://github.com/aomarks), [ExE Boss](https://github.com/ExE-Boss), and [BendingBender](https://github.com/BendingBender). |
||||
@ -0,0 +1,169 @@ |
|||||
|
/// <reference lib="es2020"/>
|
||||
|
/** https://url.spec.whatwg.org/#url-representation */ |
||||
|
export interface URLRecord { |
||||
|
scheme: string; |
||||
|
username: string; |
||||
|
password: string; |
||||
|
host: string | number | IPv6Address | null; |
||||
|
port: number | null; |
||||
|
path: string | string[]; |
||||
|
query: string | null; |
||||
|
fragment: string | null; |
||||
|
} |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#concept-ipv6 */ |
||||
|
export type IPv6Address = [number, number, number, number, number, number, number, number]; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#url-class */ |
||||
|
export class URL { |
||||
|
constructor(url: string, base?: string | URL); |
||||
|
|
||||
|
get href(): string; |
||||
|
set href(V: string); |
||||
|
|
||||
|
get origin(): string; |
||||
|
|
||||
|
get protocol(): string; |
||||
|
set protocol(V: string); |
||||
|
|
||||
|
get username(): string; |
||||
|
set username(V: string); |
||||
|
|
||||
|
get password(): string; |
||||
|
set password(V: string); |
||||
|
|
||||
|
get host(): string; |
||||
|
set host(V: string); |
||||
|
|
||||
|
get hostname(): string; |
||||
|
set hostname(V: string); |
||||
|
|
||||
|
get port(): string; |
||||
|
set port(V: string); |
||||
|
|
||||
|
get pathname(): string; |
||||
|
set pathname(V: string); |
||||
|
|
||||
|
get search(): string; |
||||
|
set search(V: string); |
||||
|
|
||||
|
get searchParams(): URLSearchParams; |
||||
|
|
||||
|
get hash(): string; |
||||
|
set hash(V: string); |
||||
|
|
||||
|
toJSON(): string; |
||||
|
|
||||
|
readonly [Symbol.toStringTag]: "URL"; |
||||
|
} |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#interface-urlsearchparams */ |
||||
|
export class URLSearchParams { |
||||
|
constructor( |
||||
|
init?: |
||||
|
| ReadonlyArray<readonly [name: string, value: string]> |
||||
|
| Iterable<readonly [name: string, value: string]> |
||||
|
| { readonly [name: string]: string } |
||||
|
| string, |
||||
|
); |
||||
|
|
||||
|
append(name: string, value: string): void; |
||||
|
delete(name: string): void; |
||||
|
get(name: string): string | null; |
||||
|
getAll(name: string): string[]; |
||||
|
has(name: string): boolean; |
||||
|
set(name: string, value: string): void; |
||||
|
sort(): void; |
||||
|
|
||||
|
keys(): IterableIterator<string>; |
||||
|
values(): IterableIterator<string>; |
||||
|
entries(): IterableIterator<[name: string, value: string]>; |
||||
|
forEach<THIS_ARG = void>( |
||||
|
callback: (this: THIS_ARG, value: string, name: string, searchParams: this) => void, |
||||
|
thisArg?: THIS_ARG, |
||||
|
): void; |
||||
|
|
||||
|
readonly [Symbol.toStringTag]: "URLSearchParams"; |
||||
|
[Symbol.iterator](): IterableIterator<[name: string, value: string]>; |
||||
|
} |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#concept-url-parser */ |
||||
|
export function parseURL(input: string, options?: { readonly baseURL?: URLRecord | undefined }): URLRecord | null; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#concept-basic-url-parser */ |
||||
|
export function basicURLParse( |
||||
|
input: string, |
||||
|
options?: { |
||||
|
baseURL?: URLRecord | undefined; |
||||
|
url?: URLRecord | undefined; |
||||
|
stateOverride?: StateOverride | undefined; |
||||
|
}, |
||||
|
): URLRecord | null; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#scheme-start-state */ |
||||
|
export type StateOverride = |
||||
|
| "scheme start" |
||||
|
| "scheme" |
||||
|
| "no scheme" |
||||
|
| "special relative or authority" |
||||
|
| "path or authority" |
||||
|
| "relative" |
||||
|
| "relative slash" |
||||
|
| "special authority slashes" |
||||
|
| "special authority ignore slashes" |
||||
|
| "authority" |
||||
|
| "host" |
||||
|
| "hostname" |
||||
|
| "port" |
||||
|
| "file" |
||||
|
| "file slash" |
||||
|
| "file host" |
||||
|
| "path start" |
||||
|
| "path" |
||||
|
| "opaque path" |
||||
|
| "query" |
||||
|
| "fragment"; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#concept-url-serializer */ |
||||
|
export function serializeURL(urlRecord: URLRecord, excludeFragment?: boolean): string; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#concept-host-serializer */ |
||||
|
export function serializeHost(host: string | number | IPv6Address): string; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#url-path-serializer */ |
||||
|
export function serializePath(urlRecord: URLRecord): string; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#serialize-an-integer */ |
||||
|
export function serializeInteger(number: number): string; |
||||
|
|
||||
|
/** https://html.spec.whatwg.org#ascii-serialisation-of-an-origin */ |
||||
|
export function serializeURLOrigin(urlRecord: URLRecord): string; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#set-the-username */ |
||||
|
export function setTheUsername(urlRecord: URLRecord, username: string): void; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#set-the-password */ |
||||
|
export function setThePassword(urlRecord: URLRecord, password: string): void; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#url-opaque-path */ |
||||
|
export function hasAnOpaquePath(urlRecord: URLRecord): boolean; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#cannot-have-a-username-password-port */ |
||||
|
export function cannotHaveAUsernamePasswordPort(urlRecord: URLRecord): boolean; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#percent-decode */ |
||||
|
export function percentDecodeBytes(buffer: TypedArray): Uint8Array; |
||||
|
|
||||
|
/** https://url.spec.whatwg.org/#string-percent-decode */ |
||||
|
export function percentDecodeString(string: string): Uint8Array; |
||||
|
|
||||
|
export type TypedArray = |
||||
|
| Uint8Array |
||||
|
| Uint8ClampedArray |
||||
|
| Uint16Array |
||||
|
| Uint32Array |
||||
|
| Int8Array |
||||
|
| Int16Array |
||||
|
| Int32Array |
||||
|
| Float32Array |
||||
|
| Float64Array; |
||||
@ -0,0 +1,22 @@ |
|||||
|
import { Globals } from "webidl-conversions"; |
||||
|
import { implementation as URLSearchParamsImpl } from "./URLSearchParams-impl"; |
||||
|
|
||||
|
declare class URLImpl { |
||||
|
constructor(globalObject: Globals, constructorArgs: readonly [url: string, base?: string]); |
||||
|
|
||||
|
href: string; |
||||
|
readonly origin: string; |
||||
|
protocol: string; |
||||
|
username: string; |
||||
|
password: string; |
||||
|
host: string; |
||||
|
hostname: string; |
||||
|
port: string; |
||||
|
pathname: string; |
||||
|
search: string; |
||||
|
readonly searchParams: URLSearchParamsImpl; |
||||
|
hash: string; |
||||
|
|
||||
|
toJSON(): string; |
||||
|
} |
||||
|
export { URLImpl as implementation }; |
||||
@ -0,0 +1,66 @@ |
|||||
|
import { URL } from "../index"; |
||||
|
import { implementation as URLImpl } from "./URL-impl"; |
||||
|
|
||||
|
/** |
||||
|
* Checks whether `obj` is a `URL` object with an implementation |
||||
|
* provided by this package. |
||||
|
*/ |
||||
|
export function is(obj: unknown): obj is URL; |
||||
|
|
||||
|
/** |
||||
|
* Checks whether `obj` is a `URLImpl` WebIDL2JS implementation object |
||||
|
* provided by this package. |
||||
|
*/ |
||||
|
export function isImpl(obj: unknown): obj is URLImpl; |
||||
|
|
||||
|
/** |
||||
|
* Converts the `URL` wrapper into a `URLImpl` object. |
||||
|
* |
||||
|
* @throws {TypeError} If `obj` is not a `URL` wrapper instance provided by this package. |
||||
|
*/ |
||||
|
export function convert(globalObject: object, obj: unknown, { context }?: { context: string }): URLImpl; |
||||
|
|
||||
|
/** |
||||
|
* Creates a new `URL` instance. |
||||
|
* |
||||
|
* @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor |
||||
|
* registry or a `URL` constructor provided by this package |
||||
|
* in the WebIDL2JS constructor registry. |
||||
|
*/ |
||||
|
export function create(globalObject: object, constructorArgs: readonly [url: string, base?: string]): URL; |
||||
|
|
||||
|
/** |
||||
|
* Calls `create()` and returns the internal `URLImpl`. |
||||
|
* |
||||
|
* @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor |
||||
|
* registry or a `URL` constructor provided by this package |
||||
|
* in the WebIDL2JS constructor registry. |
||||
|
*/ |
||||
|
export function createImpl(globalObject: object, constructorArgs: readonly [url: string, base?: string]): URLImpl; |
||||
|
|
||||
|
/** |
||||
|
* Initializes the `URL` instance, called by `create()`. |
||||
|
* |
||||
|
* Useful when manually sub-classing a non-constructable wrapper object. |
||||
|
*/ |
||||
|
export function setup<T extends URL>( |
||||
|
obj: T, |
||||
|
globalObject: object, |
||||
|
constructorArgs: readonly [url: string, base?: string], |
||||
|
): T; |
||||
|
|
||||
|
/** |
||||
|
* Creates a new `URL` object without runing the constructor steps. |
||||
|
* |
||||
|
* Useful when implementing specifications that initialize objects |
||||
|
* in different ways than their constructors do. |
||||
|
*/ |
||||
|
declare function _new(globalObject: object, newTarget?: new(url: string, base?: string) => URL): URLImpl; |
||||
|
export { _new as new }; |
||||
|
|
||||
|
/** |
||||
|
* Installs the `URL` constructor onto the `globalObject`. |
||||
|
* |
||||
|
* @throws {Error} If the target `globalObject` doesn't have an `Error` constructor. |
||||
|
*/ |
||||
|
export function install(globalObject: object, globalNames: readonly string[]): void; |
||||
@ -0,0 +1,20 @@ |
|||||
|
declare class URLSearchParamsImpl { |
||||
|
constructor( |
||||
|
globalObject: object, |
||||
|
constructorArgs: readonly [ |
||||
|
init?: ReadonlyArray<readonly [name: string, value: string]> | { readonly [name: string]: string } | string, |
||||
|
], |
||||
|
privateData: { readonly doNotStripQMark?: boolean | undefined }, |
||||
|
); |
||||
|
|
||||
|
append(name: string, value: string): void; |
||||
|
delete(name: string): void; |
||||
|
get(name: string): string | null; |
||||
|
getAll(name: string): string[]; |
||||
|
has(name: string): boolean; |
||||
|
set(name: string, value: string): void; |
||||
|
sort(): void; |
||||
|
|
||||
|
[Symbol.iterator](): IterableIterator<[name: string, value: string]>; |
||||
|
} |
||||
|
export { URLSearchParamsImpl as implementation }; |
||||
@ -0,0 +1,92 @@ |
|||||
|
import { URLSearchParams } from "../index"; |
||||
|
import { implementation as URLSearchParamsImpl } from "./URLSearchParams-impl"; |
||||
|
|
||||
|
/** |
||||
|
* Checks whether `obj` is a `URLSearchParams` object with an implementation |
||||
|
* provided by this package. |
||||
|
*/ |
||||
|
export function is(obj: unknown): obj is URLSearchParams; |
||||
|
|
||||
|
/** |
||||
|
* Checks whether `obj` is a `URLSearchParamsImpl` WebIDL2JS implementation object |
||||
|
* provided by this package. |
||||
|
*/ |
||||
|
export function isImpl(obj: unknown): obj is URLSearchParamsImpl; |
||||
|
|
||||
|
/** |
||||
|
* Converts the `URLSearchParams` wrapper into a `URLSearchParamsImpl` object. |
||||
|
* |
||||
|
* @throws {TypeError} If `obj` is not a `URLSearchParams` wrapper instance provided by this package. |
||||
|
*/ |
||||
|
export function convert(globalObject: object, obj: unknown, { context }?: { context: string }): URLSearchParamsImpl; |
||||
|
|
||||
|
export function createDefaultIterator<TIteratorKind extends "key" | "value" | "key+value">( |
||||
|
globalObject: object, |
||||
|
target: URLSearchParamsImpl, |
||||
|
kind: TIteratorKind, |
||||
|
): IterableIterator<TIteratorKind extends "key" | "value" ? string : [name: string, value: string]>; |
||||
|
|
||||
|
/** |
||||
|
* Creates a new `URLSearchParams` instance. |
||||
|
* |
||||
|
* @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor |
||||
|
* registry or a `URLSearchParams` constructor provided by this package |
||||
|
* in the WebIDL2JS constructor registry. |
||||
|
*/ |
||||
|
export function create( |
||||
|
globalObject: object, |
||||
|
constructorArgs?: readonly [ |
||||
|
init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string, |
||||
|
], |
||||
|
privateData?: { doNotStripQMark?: boolean | undefined }, |
||||
|
): URLSearchParams; |
||||
|
|
||||
|
/** |
||||
|
* Calls `create()` and returns the internal `URLSearchParamsImpl`. |
||||
|
* |
||||
|
* @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor |
||||
|
* registry or a `URLSearchParams` constructor provided by this package |
||||
|
* in the WebIDL2JS constructor registry. |
||||
|
*/ |
||||
|
export function createImpl( |
||||
|
globalObject: object, |
||||
|
constructorArgs?: readonly [ |
||||
|
init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string, |
||||
|
], |
||||
|
privateData?: { doNotStripQMark?: boolean | undefined }, |
||||
|
): URLSearchParamsImpl; |
||||
|
|
||||
|
/** |
||||
|
* Initializes the `URLSearchParams` instance, called by `create()`. |
||||
|
* |
||||
|
* Useful when manually sub-classing a non-constructable wrapper object. |
||||
|
*/ |
||||
|
export function setup<T extends URLSearchParams>( |
||||
|
obj: T, |
||||
|
globalObject: object, |
||||
|
constructorArgs?: readonly [ |
||||
|
init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string, |
||||
|
], |
||||
|
privateData?: { doNotStripQMark?: boolean | undefined }, |
||||
|
): T; |
||||
|
|
||||
|
/** |
||||
|
* Creates a new `URLSearchParams` object without runing the constructor steps. |
||||
|
* |
||||
|
* Useful when implementing specifications that initialize objects |
||||
|
* in different ways than their constructors do. |
||||
|
*/ |
||||
|
declare function _new( |
||||
|
globalObject: object, |
||||
|
newTarget?: new( |
||||
|
init: ReadonlyArray<[name: string, value: string]> | { readonly [name: string]: string } | string, |
||||
|
) => URLSearchParams, |
||||
|
): URLSearchParamsImpl; |
||||
|
export { _new as new }; |
||||
|
|
||||
|
/** |
||||
|
* Installs the `URLSearchParams` constructor onto the `globalObject`. |
||||
|
* |
||||
|
* @throws {Error} If the target `globalObject` doesn't have an `Error` constructor. |
||||
|
*/ |
||||
|
export function install(globalObject: object, globalNames: readonly string[]): void; |
||||
@ -0,0 +1,37 @@ |
|||||
|
{ |
||||
|
"name": "@types/whatwg-url", |
||||
|
"version": "11.0.5", |
||||
|
"description": "TypeScript definitions for whatwg-url", |
||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-url", |
||||
|
"license": "MIT", |
||||
|
"contributors": [ |
||||
|
{ |
||||
|
"name": "Alexander Marks", |
||||
|
"githubUsername": "aomarks", |
||||
|
"url": "https://github.com/aomarks" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "ExE Boss", |
||||
|
"githubUsername": "ExE-Boss", |
||||
|
"url": "https://github.com/ExE-Boss" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "BendingBender", |
||||
|
"githubUsername": "BendingBender", |
||||
|
"url": "https://github.com/BendingBender" |
||||
|
} |
||||
|
], |
||||
|
"main": "", |
||||
|
"types": "index.d.ts", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", |
||||
|
"directory": "types/whatwg-url" |
||||
|
}, |
||||
|
"scripts": {}, |
||||
|
"dependencies": { |
||||
|
"@types/webidl-conversions": "*" |
||||
|
}, |
||||
|
"typesPublisherContentHash": "c6cfac1bbd7b2ef315fdad11fc9bdb6a8f0ae2b1c3ff057cfca7bc9880eeaa9d", |
||||
|
"typeScriptVersion": "4.7" |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
import * as URL from "./lib/URL"; |
||||
|
import * as URLSearchParams from "./lib/URLSearchParams"; |
||||
|
|
||||
|
export { URL, URLSearchParams }; |
||||
@ -0,0 +1,250 @@ |
|||||
|
2.0.0 / 2024-08-31 |
||||
|
================== |
||||
|
|
||||
|
* Drop node <18 support |
||||
|
* deps: mime-types@^3.0.0 |
||||
|
* deps: negotiator@^1.0.0 |
||||
|
|
||||
|
1.3.8 / 2022-02-02 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.34 |
||||
|
- deps: mime-db@~1.51.0 |
||||
|
* deps: negotiator@0.6.3 |
||||
|
|
||||
|
1.3.7 / 2019-04-29 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.6.2 |
||||
|
- Fix sorting charset, encoding, and language with extra parameters |
||||
|
|
||||
|
1.3.6 / 2019-04-28 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.24 |
||||
|
- deps: mime-db@~1.40.0 |
||||
|
|
||||
|
1.3.5 / 2018-02-28 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.18 |
||||
|
- deps: mime-db@~1.33.0 |
||||
|
|
||||
|
1.3.4 / 2017-08-22 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.16 |
||||
|
- deps: mime-db@~1.29.0 |
||||
|
|
||||
|
1.3.3 / 2016-05-02 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.11 |
||||
|
- deps: mime-db@~1.23.0 |
||||
|
* deps: negotiator@0.6.1 |
||||
|
- perf: improve `Accept` parsing speed |
||||
|
- perf: improve `Accept-Charset` parsing speed |
||||
|
- perf: improve `Accept-Encoding` parsing speed |
||||
|
- perf: improve `Accept-Language` parsing speed |
||||
|
|
||||
|
1.3.2 / 2016-03-08 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.10 |
||||
|
- Fix extension of `application/dash+xml` |
||||
|
- Update primary extension for `audio/mp4` |
||||
|
- deps: mime-db@~1.22.0 |
||||
|
|
||||
|
1.3.1 / 2016-01-19 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.9 |
||||
|
- deps: mime-db@~1.21.0 |
||||
|
|
||||
|
1.3.0 / 2015-09-29 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.7 |
||||
|
- deps: mime-db@~1.19.0 |
||||
|
* deps: negotiator@0.6.0 |
||||
|
- Fix including type extensions in parameters in `Accept` parsing |
||||
|
- Fix parsing `Accept` parameters with quoted equals |
||||
|
- Fix parsing `Accept` parameters with quoted semicolons |
||||
|
- Lazy-load modules from main entry point |
||||
|
- perf: delay type concatenation until needed |
||||
|
- perf: enable strict mode |
||||
|
- perf: hoist regular expressions |
||||
|
- perf: remove closures getting spec properties |
||||
|
- perf: remove a closure from media type parsing |
||||
|
- perf: remove property delete from media type parsing |
||||
|
|
||||
|
1.2.13 / 2015-09-06 |
||||
|
=================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.6 |
||||
|
- deps: mime-db@~1.18.0 |
||||
|
|
||||
|
1.2.12 / 2015-07-30 |
||||
|
=================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.4 |
||||
|
- deps: mime-db@~1.16.0 |
||||
|
|
||||
|
1.2.11 / 2015-07-16 |
||||
|
=================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.3 |
||||
|
- deps: mime-db@~1.15.0 |
||||
|
|
||||
|
1.2.10 / 2015-07-01 |
||||
|
=================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.2 |
||||
|
- deps: mime-db@~1.14.0 |
||||
|
|
||||
|
1.2.9 / 2015-06-08 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.1 |
||||
|
- perf: fix deopt during mapping |
||||
|
|
||||
|
1.2.8 / 2015-06-07 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.1.0 |
||||
|
- deps: mime-db@~1.13.0 |
||||
|
* perf: avoid argument reassignment & argument slice |
||||
|
* perf: avoid negotiator recursive construction |
||||
|
* perf: enable strict mode |
||||
|
* perf: remove unnecessary bitwise operator |
||||
|
|
||||
|
1.2.7 / 2015-05-10 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.5.3 |
||||
|
- Fix media type parameter matching to be case-insensitive |
||||
|
|
||||
|
1.2.6 / 2015-05-07 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.11 |
||||
|
- deps: mime-db@~1.9.1 |
||||
|
* deps: negotiator@0.5.2 |
||||
|
- Fix comparing media types with quoted values |
||||
|
- Fix splitting media types with quoted commas |
||||
|
|
||||
|
1.2.5 / 2015-03-13 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.10 |
||||
|
- deps: mime-db@~1.8.0 |
||||
|
|
||||
|
1.2.4 / 2015-02-14 |
||||
|
================== |
||||
|
|
||||
|
* Support Node.js 0.6 |
||||
|
* deps: mime-types@~2.0.9 |
||||
|
- deps: mime-db@~1.7.0 |
||||
|
* deps: negotiator@0.5.1 |
||||
|
- Fix preference sorting to be stable for long acceptable lists |
||||
|
|
||||
|
1.2.3 / 2015-01-31 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.8 |
||||
|
- deps: mime-db@~1.6.0 |
||||
|
|
||||
|
1.2.2 / 2014-12-30 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.7 |
||||
|
- deps: mime-db@~1.5.0 |
||||
|
|
||||
|
1.2.1 / 2014-12-30 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.5 |
||||
|
- deps: mime-db@~1.3.1 |
||||
|
|
||||
|
1.2.0 / 2014-12-19 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.5.0 |
||||
|
- Fix list return order when large accepted list |
||||
|
- Fix missing identity encoding when q=0 exists |
||||
|
- Remove dynamic building of Negotiator class |
||||
|
|
||||
|
1.1.4 / 2014-12-10 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.4 |
||||
|
- deps: mime-db@~1.3.0 |
||||
|
|
||||
|
1.1.3 / 2014-11-09 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.3 |
||||
|
- deps: mime-db@~1.2.0 |
||||
|
|
||||
|
1.1.2 / 2014-10-14 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.4.9 |
||||
|
- Fix error when media type has invalid parameter |
||||
|
|
||||
|
1.1.1 / 2014-09-28 |
||||
|
================== |
||||
|
|
||||
|
* deps: mime-types@~2.0.2 |
||||
|
- deps: mime-db@~1.1.0 |
||||
|
* deps: negotiator@0.4.8 |
||||
|
- Fix all negotiations to be case-insensitive |
||||
|
- Stable sort preferences of same quality according to client order |
||||
|
|
||||
|
1.1.0 / 2014-09-02 |
||||
|
================== |
||||
|
|
||||
|
* update `mime-types` |
||||
|
|
||||
|
1.0.7 / 2014-07-04 |
||||
|
================== |
||||
|
|
||||
|
* Fix wrong type returned from `type` when match after unknown extension |
||||
|
|
||||
|
1.0.6 / 2014-06-24 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.4.7 |
||||
|
|
||||
|
1.0.5 / 2014-06-20 |
||||
|
================== |
||||
|
|
||||
|
* fix crash when unknown extension given |
||||
|
|
||||
|
1.0.4 / 2014-06-19 |
||||
|
================== |
||||
|
|
||||
|
* use `mime-types` |
||||
|
|
||||
|
1.0.3 / 2014-06-11 |
||||
|
================== |
||||
|
|
||||
|
* deps: negotiator@0.4.6 |
||||
|
- Order by specificity when quality is the same |
||||
|
|
||||
|
1.0.2 / 2014-05-29 |
||||
|
================== |
||||
|
|
||||
|
* Fix interpretation when header not in request |
||||
|
* deps: pin negotiator@0.4.5 |
||||
|
|
||||
|
1.0.1 / 2014-01-18 |
||||
|
================== |
||||
|
|
||||
|
* Identity encoding isn't always acceptable |
||||
|
* deps: negotiator@~0.4.0 |
||||
|
|
||||
|
1.0.0 / 2013-12-27 |
||||
|
================== |
||||
|
|
||||
|
* Genesis |
||||
@ -0,0 +1,23 @@ |
|||||
|
(The MIT License) |
||||
|
|
||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> |
||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||
|
a copy of this software and associated documentation files (the |
||||
|
'Software'), to deal in the Software without restriction, including |
||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||
|
the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be |
||||
|
included in all copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
@ -0,0 +1,140 @@ |
|||||
|
# accepts |
||||
|
|
||||
|
[![NPM Version][npm-version-image]][npm-url] |
||||
|
[![NPM Downloads][npm-downloads-image]][npm-url] |
||||
|
[![Node.js Version][node-version-image]][node-version-url] |
||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url] |
||||
|
[![Test Coverage][coveralls-image]][coveralls-url] |
||||
|
|
||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). |
||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use. |
||||
|
|
||||
|
In addition to negotiator, it allows: |
||||
|
|
||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` |
||||
|
as well as `('text/html', 'application/json')`. |
||||
|
- Allows type shorthands such as `json`. |
||||
|
- Returns `false` when no types match |
||||
|
- Treats non-existent headers as `*` |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the |
||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the |
||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): |
||||
|
|
||||
|
```sh |
||||
|
$ npm install accepts |
||||
|
``` |
||||
|
|
||||
|
## API |
||||
|
|
||||
|
```js |
||||
|
var accepts = require('accepts') |
||||
|
``` |
||||
|
|
||||
|
### accepts(req) |
||||
|
|
||||
|
Create a new `Accepts` object for the given `req`. |
||||
|
|
||||
|
#### .charset(charsets) |
||||
|
|
||||
|
Return the first accepted charset. If nothing in `charsets` is accepted, |
||||
|
then `false` is returned. |
||||
|
|
||||
|
#### .charsets() |
||||
|
|
||||
|
Return the charsets that the request accepts, in the order of the client's |
||||
|
preference (most preferred first). |
||||
|
|
||||
|
#### .encoding(encodings) |
||||
|
|
||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted, |
||||
|
then `false` is returned. |
||||
|
|
||||
|
#### .encodings() |
||||
|
|
||||
|
Return the encodings that the request accepts, in the order of the client's |
||||
|
preference (most preferred first). |
||||
|
|
||||
|
#### .language(languages) |
||||
|
|
||||
|
Return the first accepted language. If nothing in `languages` is accepted, |
||||
|
then `false` is returned. |
||||
|
|
||||
|
#### .languages() |
||||
|
|
||||
|
Return the languages that the request accepts, in the order of the client's |
||||
|
preference (most preferred first). |
||||
|
|
||||
|
#### .type(types) |
||||
|
|
||||
|
Return the first accepted type (and it is returned as the same text as what |
||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false` |
||||
|
is returned. |
||||
|
|
||||
|
The `types` array can contain full MIME types or file extensions. Any value |
||||
|
that is not a full MIME type is passed to `require('mime-types').lookup`. |
||||
|
|
||||
|
#### .types() |
||||
|
|
||||
|
Return the types that the request accepts, in the order of the client's |
||||
|
preference (most preferred first). |
||||
|
|
||||
|
## Examples |
||||
|
|
||||
|
### Simple type negotiation |
||||
|
|
||||
|
This simple example shows how to use `accepts` to return a different typed |
||||
|
respond body based on what the client wants to accept. The server lists it's |
||||
|
preferences in order and will get back the best match between the client and |
||||
|
server. |
||||
|
|
||||
|
```js |
||||
|
var accepts = require('accepts') |
||||
|
var http = require('http') |
||||
|
|
||||
|
function app (req, res) { |
||||
|
var accept = accepts(req) |
||||
|
|
||||
|
// the order of this list is significant; should be server preferred order |
||||
|
switch (accept.type(['json', 'html'])) { |
||||
|
case 'json': |
||||
|
res.setHeader('Content-Type', 'application/json') |
||||
|
res.write('{"hello":"world!"}') |
||||
|
break |
||||
|
case 'html': |
||||
|
res.setHeader('Content-Type', 'text/html') |
||||
|
res.write('<b>hello, world!</b>') |
||||
|
break |
||||
|
default: |
||||
|
// the fallback is text/plain, so no need to specify it above |
||||
|
res.setHeader('Content-Type', 'text/plain') |
||||
|
res.write('hello, world!') |
||||
|
break |
||||
|
} |
||||
|
|
||||
|
res.end() |
||||
|
} |
||||
|
|
||||
|
http.createServer(app).listen(3000) |
||||
|
``` |
||||
|
|
||||
|
You can test this out with the cURL program: |
||||
|
```sh |
||||
|
curl -I -H'Accept: text/html' http://localhost:3000/ |
||||
|
``` |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
[MIT](LICENSE) |
||||
|
|
||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master |
||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master |
||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci |
||||
|
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml |
||||
|
[node-version-image]: https://badgen.net/npm/node/accepts |
||||
|
[node-version-url]: https://nodejs.org/en/download |
||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts |
||||
|
[npm-url]: https://npmjs.org/package/accepts |
||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts |
||||
@ -0,0 +1,238 @@ |
|||||
|
/*! |
||||
|
* accepts |
||||
|
* Copyright(c) 2014 Jonathan Ong |
||||
|
* Copyright(c) 2015 Douglas Christopher Wilson |
||||
|
* MIT Licensed |
||||
|
*/ |
||||
|
|
||||
|
'use strict' |
||||
|
|
||||
|
/** |
||||
|
* Module dependencies. |
||||
|
* @private |
||||
|
*/ |
||||
|
|
||||
|
var Negotiator = require('negotiator') |
||||
|
var mime = require('mime-types') |
||||
|
|
||||
|
/** |
||||
|
* Module exports. |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
module.exports = Accepts |
||||
|
|
||||
|
/** |
||||
|
* Create a new Accepts object for the given req. |
||||
|
* |
||||
|
* @param {object} req |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
function Accepts (req) { |
||||
|
if (!(this instanceof Accepts)) { |
||||
|
return new Accepts(req) |
||||
|
} |
||||
|
|
||||
|
this.headers = req.headers |
||||
|
this.negotiator = new Negotiator(req) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check if the given `type(s)` is acceptable, returning |
||||
|
* the best match when true, otherwise `undefined`, in which |
||||
|
* case you should respond with 406 "Not Acceptable". |
||||
|
* |
||||
|
* The `type` value may be a single mime type string |
||||
|
* such as "application/json", the extension name |
||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list |
||||
|
* or array is given the _best_ match, if any is returned. |
||||
|
* |
||||
|
* Examples: |
||||
|
* |
||||
|
* // Accept: text/html
|
||||
|
* this.types('html'); |
||||
|
* // => "html"
|
||||
|
* |
||||
|
* // Accept: text/*, application/json
|
||||
|
* this.types('html'); |
||||
|
* // => "html"
|
||||
|
* this.types('text/html'); |
||||
|
* // => "text/html"
|
||||
|
* this.types('json', 'text'); |
||||
|
* // => "json"
|
||||
|
* this.types('application/json'); |
||||
|
* // => "application/json"
|
||||
|
* |
||||
|
* // Accept: text/*, application/json
|
||||
|
* this.types('image/png'); |
||||
|
* this.types('png'); |
||||
|
* // => undefined
|
||||
|
* |
||||
|
* // Accept: text/*;q=.5, application/json
|
||||
|
* this.types(['html', 'json']); |
||||
|
* this.types('html', 'json'); |
||||
|
* // => "json"
|
||||
|
* |
||||
|
* @param {String|Array} types... |
||||
|
* @return {String|Array|Boolean} |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
Accepts.prototype.type = |
||||
|
Accepts.prototype.types = function (types_) { |
||||
|
var types = types_ |
||||
|
|
||||
|
// support flattened arguments
|
||||
|
if (types && !Array.isArray(types)) { |
||||
|
types = new Array(arguments.length) |
||||
|
for (var i = 0; i < types.length; i++) { |
||||
|
types[i] = arguments[i] |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// no types, return all requested types
|
||||
|
if (!types || types.length === 0) { |
||||
|
return this.negotiator.mediaTypes() |
||||
|
} |
||||
|
|
||||
|
// no accept header, return first given type
|
||||
|
if (!this.headers.accept) { |
||||
|
return types[0] |
||||
|
} |
||||
|
|
||||
|
var mimes = types.map(extToMime) |
||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) |
||||
|
var first = accepts[0] |
||||
|
|
||||
|
return first |
||||
|
? types[mimes.indexOf(first)] |
||||
|
: false |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Return accepted encodings or best fit based on `encodings`. |
||||
|
* |
||||
|
* Given `Accept-Encoding: gzip, deflate` |
||||
|
* an array sorted by quality is returned: |
||||
|
* |
||||
|
* ['gzip', 'deflate'] |
||||
|
* |
||||
|
* @param {String|Array} encodings... |
||||
|
* @return {String|Array} |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
Accepts.prototype.encoding = |
||||
|
Accepts.prototype.encodings = function (encodings_) { |
||||
|
var encodings = encodings_ |
||||
|
|
||||
|
// support flattened arguments
|
||||
|
if (encodings && !Array.isArray(encodings)) { |
||||
|
encodings = new Array(arguments.length) |
||||
|
for (var i = 0; i < encodings.length; i++) { |
||||
|
encodings[i] = arguments[i] |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// no encodings, return all requested encodings
|
||||
|
if (!encodings || encodings.length === 0) { |
||||
|
return this.negotiator.encodings() |
||||
|
} |
||||
|
|
||||
|
return this.negotiator.encodings(encodings)[0] || false |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Return accepted charsets or best fit based on `charsets`. |
||||
|
* |
||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` |
||||
|
* an array sorted by quality is returned: |
||||
|
* |
||||
|
* ['utf-8', 'utf-7', 'iso-8859-1'] |
||||
|
* |
||||
|
* @param {String|Array} charsets... |
||||
|
* @return {String|Array} |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
Accepts.prototype.charset = |
||||
|
Accepts.prototype.charsets = function (charsets_) { |
||||
|
var charsets = charsets_ |
||||
|
|
||||
|
// support flattened arguments
|
||||
|
if (charsets && !Array.isArray(charsets)) { |
||||
|
charsets = new Array(arguments.length) |
||||
|
for (var i = 0; i < charsets.length; i++) { |
||||
|
charsets[i] = arguments[i] |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// no charsets, return all requested charsets
|
||||
|
if (!charsets || charsets.length === 0) { |
||||
|
return this.negotiator.charsets() |
||||
|
} |
||||
|
|
||||
|
return this.negotiator.charsets(charsets)[0] || false |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Return accepted languages or best fit based on `langs`. |
||||
|
* |
||||
|
* Given `Accept-Language: en;q=0.8, es, pt` |
||||
|
* an array sorted by quality is returned: |
||||
|
* |
||||
|
* ['es', 'pt', 'en'] |
||||
|
* |
||||
|
* @param {String|Array} langs... |
||||
|
* @return {Array|String} |
||||
|
* @public |
||||
|
*/ |
||||
|
|
||||
|
Accepts.prototype.lang = |
||||
|
Accepts.prototype.langs = |
||||
|
Accepts.prototype.language = |
||||
|
Accepts.prototype.languages = function (languages_) { |
||||
|
var languages = languages_ |
||||
|
|
||||
|
// support flattened arguments
|
||||
|
if (languages && !Array.isArray(languages)) { |
||||
|
languages = new Array(arguments.length) |
||||
|
for (var i = 0; i < languages.length; i++) { |
||||
|
languages[i] = arguments[i] |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// no languages, return all requested languages
|
||||
|
if (!languages || languages.length === 0) { |
||||
|
return this.negotiator.languages() |
||||
|
} |
||||
|
|
||||
|
return this.negotiator.languages(languages)[0] || false |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Convert extnames to mime. |
||||
|
* |
||||
|
* @param {String} type |
||||
|
* @return {String} |
||||
|
* @private |
||||
|
*/ |
||||
|
|
||||
|
function extToMime (type) { |
||||
|
return type.indexOf('/') === -1 |
||||
|
? mime.lookup(type) |
||||
|
: type |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check if mime is valid. |
||||
|
* |
||||
|
* @param {String} type |
||||
|
* @return {Boolean} |
||||
|
* @private |
||||
|
*/ |
||||
|
|
||||
|
function validMime (type) { |
||||
|
return typeof type === 'string' |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
{ |
||||
|
"name": "accepts", |
||||
|
"description": "Higher-level content negotiation", |
||||
|
"version": "2.0.0", |
||||
|
"contributors": [ |
||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>", |
||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)" |
||||
|
], |
||||
|
"license": "MIT", |
||||
|
"repository": "jshttp/accepts", |
||||
|
"dependencies": { |
||||
|
"mime-types": "^3.0.0", |
||||
|
"negotiator": "^1.0.0" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"deep-equal": "1.0.1", |
||||
|
"eslint": "7.32.0", |
||||
|
"eslint-config-standard": "14.1.1", |
||||
|
"eslint-plugin-import": "2.25.4", |
||||
|
"eslint-plugin-markdown": "2.2.1", |
||||
|
"eslint-plugin-node": "11.1.0", |
||||
|
"eslint-plugin-promise": "4.3.1", |
||||
|
"eslint-plugin-standard": "4.1.0", |
||||
|
"mocha": "9.2.0", |
||||
|
"nyc": "15.1.0" |
||||
|
}, |
||||
|
"files": [ |
||||
|
"LICENSE", |
||||
|
"HISTORY.md", |
||||
|
"index.js" |
||||
|
], |
||||
|
"engines": { |
||||
|
"node": ">= 0.6" |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"lint": "eslint .", |
||||
|
"test": "mocha --reporter spec --check-leaks --bail test/", |
||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test", |
||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test" |
||||
|
}, |
||||
|
"keywords": [ |
||||
|
"content", |
||||
|
"negotiation", |
||||
|
"accept", |
||||
|
"accepts" |
||||
|
] |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
The ISC License |
||||
|
|
||||
|
Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com) |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR |
||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
@ -0,0 +1,87 @@ |
|||||
|
anymatch [](https://travis-ci.org/micromatch/anymatch) [](https://coveralls.io/r/micromatch/anymatch?branch=master) |
||||
|
====== |
||||
|
Javascript module to match a string against a regular expression, glob, string, |
||||
|
or function that takes the string as an argument and returns a truthy or falsy |
||||
|
value. The matcher can also be an array of any or all of these. Useful for |
||||
|
allowing a very flexible user-defined config to define things like file paths. |
||||
|
|
||||
|
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__ |
||||
|
|
||||
|
|
||||
|
Usage |
||||
|
----- |
||||
|
```sh |
||||
|
npm install anymatch |
||||
|
``` |
||||
|
|
||||
|
#### anymatch(matchers, testString, [returnIndex], [options]) |
||||
|
* __matchers__: (_Array|String|RegExp|Function_) |
||||
|
String to be directly matched, string with glob patterns, regular expression |
||||
|
test, function that takes the testString as an argument and returns a truthy |
||||
|
value if it should be matched, or an array of any number and mix of these types. |
||||
|
* __testString__: (_String|Array_) The string to test against the matchers. If |
||||
|
passed as an array, the first element of the array will be used as the |
||||
|
`testString` for non-function matchers, while the entire array will be applied |
||||
|
as the arguments for function matchers. |
||||
|
* __options__: (_Object_ [optional]_) Any of the [picomatch](https://github.com/micromatch/picomatch#options) options. |
||||
|
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of |
||||
|
the first matcher that that testString matched, or -1 if no match, instead of a |
||||
|
boolean result. |
||||
|
|
||||
|
```js |
||||
|
const anymatch = require('anymatch'); |
||||
|
|
||||
|
const matchers = [ 'path/to/file.js', 'path/anyjs/**/*.js', /foo.js$/, string => string.includes('bar') && string.length > 10 ] ; |
||||
|
|
||||
|
anymatch(matchers, 'path/to/file.js'); // true |
||||
|
anymatch(matchers, 'path/anyjs/baz.js'); // true |
||||
|
anymatch(matchers, 'path/to/foo.js'); // true |
||||
|
anymatch(matchers, 'path/to/bar.js'); // true |
||||
|
anymatch(matchers, 'bar.js'); // false |
||||
|
|
||||
|
// returnIndex = true |
||||
|
anymatch(matchers, 'foo.js', {returnIndex: true}); // 2 |
||||
|
anymatch(matchers, 'path/anyjs/foo.js', {returnIndex: true}); // 1 |
||||
|
|
||||
|
// any picomatc |
||||
|
|
||||
|
// using globs to match directories and their children |
||||
|
anymatch('node_modules', 'node_modules'); // true |
||||
|
anymatch('node_modules', 'node_modules/somelib/index.js'); // false |
||||
|
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true |
||||
|
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false |
||||
|
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true |
||||
|
|
||||
|
const matcher = anymatch(matchers); |
||||
|
['foo.js', 'bar.js'].filter(matcher); // [ 'foo.js' ] |
||||
|
anymatch master* ❯ |
||||
|
|
||||
|
``` |
||||
|
|
||||
|
#### anymatch(matchers) |
||||
|
You can also pass in only your matcher(s) to get a curried function that has |
||||
|
already been bound to the provided matching criteria. This can be used as an |
||||
|
`Array#filter` callback. |
||||
|
|
||||
|
```js |
||||
|
var matcher = anymatch(matchers); |
||||
|
|
||||
|
matcher('path/to/file.js'); // true |
||||
|
matcher('path/anyjs/baz.js', true); // 1 |
||||
|
|
||||
|
['foo.js', 'bar.js'].filter(matcher); // ['foo.js'] |
||||
|
``` |
||||
|
|
||||
|
Changelog |
||||
|
---------- |
||||
|
[See release notes page on GitHub](https://github.com/micromatch/anymatch/releases) |
||||
|
|
||||
|
- **v3.0:** Removed `startIndex` and `endIndex` arguments. Node 8.x-only. |
||||
|
- **v2.0:** [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information). |
||||
|
- **v1.2:** anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch) |
||||
|
for glob pattern matching. Issues with glob pattern matching should be |
||||
|
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues). |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
[ISC](https://raw.github.com/micromatch/anymatch/master/LICENSE) |
||||
@ -0,0 +1,20 @@ |
|||||
|
type AnymatchFn = (testString: string) => boolean; |
||||
|
type AnymatchPattern = string|RegExp|AnymatchFn; |
||||
|
type AnymatchMatcher = AnymatchPattern|AnymatchPattern[] |
||||
|
type AnymatchTester = { |
||||
|
(testString: string|any[], returnIndex: true): number; |
||||
|
(testString: string|any[]): boolean; |
||||
|
} |
||||
|
|
||||
|
type PicomatchOptions = {dot: boolean}; |
||||
|
|
||||
|
declare const anymatch: { |
||||
|
(matchers: AnymatchMatcher): AnymatchTester; |
||||
|
(matchers: AnymatchMatcher, testString: null, returnIndex: true | PicomatchOptions): AnymatchTester; |
||||
|
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number; |
||||
|
(matchers: AnymatchMatcher, testString: string|any[]): boolean; |
||||
|
} |
||||
|
|
||||
|
export {AnymatchMatcher as Matcher} |
||||
|
export {AnymatchTester as Tester} |
||||
|
export default anymatch |
||||
@ -0,0 +1,104 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||
|
|
||||
|
const picomatch = require('picomatch'); |
||||
|
const normalizePath = require('normalize-path'); |
||||
|
|
||||
|
/** |
||||
|
* @typedef {(testString: string) => boolean} AnymatchFn |
||||
|
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern |
||||
|
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher |
||||
|
*/ |
||||
|
const BANG = '!'; |
||||
|
const DEFAULT_OPTIONS = {returnIndex: false}; |
||||
|
const arrify = (item) => Array.isArray(item) ? item : [item]; |
||||
|
|
||||
|
/** |
||||
|
* @param {AnymatchPattern} matcher |
||||
|
* @param {object} options |
||||
|
* @returns {AnymatchFn} |
||||
|
*/ |
||||
|
const createPattern = (matcher, options) => { |
||||
|
if (typeof matcher === 'function') { |
||||
|
return matcher; |
||||
|
} |
||||
|
if (typeof matcher === 'string') { |
||||
|
const glob = picomatch(matcher, options); |
||||
|
return (string) => matcher === string || glob(string); |
||||
|
} |
||||
|
if (matcher instanceof RegExp) { |
||||
|
return (string) => matcher.test(string); |
||||
|
} |
||||
|
return (string) => false; |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
* @param {Array<Function>} patterns |
||||
|
* @param {Array<Function>} negPatterns |
||||
|
* @param {String|Array} args |
||||
|
* @param {Boolean} returnIndex |
||||
|
* @returns {boolean|number} |
||||
|
*/ |
||||
|
const matchPatterns = (patterns, negPatterns, args, returnIndex) => { |
||||
|
const isList = Array.isArray(args); |
||||
|
const _path = isList ? args[0] : args; |
||||
|
if (!isList && typeof _path !== 'string') { |
||||
|
throw new TypeError('anymatch: second argument must be a string: got ' + |
||||
|
Object.prototype.toString.call(_path)) |
||||
|
} |
||||
|
const path = normalizePath(_path, false); |
||||
|
|
||||
|
for (let index = 0; index < negPatterns.length; index++) { |
||||
|
const nglob = negPatterns[index]; |
||||
|
if (nglob(path)) { |
||||
|
return returnIndex ? -1 : false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const applied = isList && [path].concat(args.slice(1)); |
||||
|
for (let index = 0; index < patterns.length; index++) { |
||||
|
const pattern = patterns[index]; |
||||
|
if (isList ? pattern(...applied) : pattern(path)) { |
||||
|
return returnIndex ? index : true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return returnIndex ? -1 : false; |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
* @param {AnymatchMatcher} matchers |
||||
|
* @param {Array|string} testString |
||||
|
* @param {object} options |
||||
|
* @returns {boolean|number|Function} |
||||
|
*/ |
||||
|
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => { |
||||
|
if (matchers == null) { |
||||
|
throw new TypeError('anymatch: specify first argument'); |
||||
|
} |
||||
|
const opts = typeof options === 'boolean' ? {returnIndex: options} : options; |
||||
|
const returnIndex = opts.returnIndex || false; |
||||
|
|
||||
|
// Early cache for matchers.
|
||||
|
const mtchers = arrify(matchers); |
||||
|
const negatedGlobs = mtchers |
||||
|
.filter(item => typeof item === 'string' && item.charAt(0) === BANG) |
||||
|
.map(item => item.slice(1)) |
||||
|
.map(item => picomatch(item, opts)); |
||||
|
const patterns = mtchers |
||||
|
.filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG)) |
||||
|
.map(matcher => createPattern(matcher, opts)); |
||||
|
|
||||
|
if (testString == null) { |
||||
|
return (testString, ri = false) => { |
||||
|
const returnIndex = typeof ri === 'boolean' ? ri : false; |
||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex); |
||||
|
}; |
||||
|
|
||||
|
anymatch.default = anymatch; |
||||
|
module.exports = anymatch; |
||||
@ -0,0 +1,48 @@ |
|||||
|
{ |
||||
|
"name": "anymatch", |
||||
|
"version": "3.1.3", |
||||
|
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions", |
||||
|
"files": [ |
||||
|
"index.js", |
||||
|
"index.d.ts" |
||||
|
], |
||||
|
"dependencies": { |
||||
|
"normalize-path": "^3.0.0", |
||||
|
"picomatch": "^2.0.4" |
||||
|
}, |
||||
|
"author": { |
||||
|
"name": "Elan Shanker", |
||||
|
"url": "https://github.com/es128" |
||||
|
}, |
||||
|
"license": "ISC", |
||||
|
"homepage": "https://github.com/micromatch/anymatch", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/micromatch/anymatch" |
||||
|
}, |
||||
|
"keywords": [ |
||||
|
"match", |
||||
|
"any", |
||||
|
"string", |
||||
|
"file", |
||||
|
"fs", |
||||
|
"list", |
||||
|
"glob", |
||||
|
"regex", |
||||
|
"regexp", |
||||
|
"regular", |
||||
|
"expression", |
||||
|
"function" |
||||
|
], |
||||
|
"scripts": { |
||||
|
"test": "nyc mocha", |
||||
|
"mocha": "mocha" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"mocha": "^6.1.3", |
||||
|
"nyc": "^14.0.0" |
||||
|
}, |
||||
|
"engines": { |
||||
|
"node": ">= 8" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
node_modules/ |
||||
@ -0,0 +1,21 @@ |
|||||
|
The MIT License (MIT) |
||||
|
|
||||
|
Copyright (c) 2015 Linus Unnebäck |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
||||
@ -0,0 +1,44 @@ |
|||||
|
# `append-field` |
||||
|
|
||||
|
A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant |
||||
|
field appender (for lack of a better name). Useful for people implementing |
||||
|
`application/x-www-form-urlencoded` and `multipart/form-data` parsers. |
||||
|
|
||||
|
It works best on objects created with `Object.create(null)`. Otherwise it might |
||||
|
conflict with variables from the prototype (e.g. `hasOwnProperty`). |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
```sh |
||||
|
npm install --save append-field |
||||
|
``` |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
```javascript |
||||
|
var appendField = require('append-field') |
||||
|
var obj = Object.create(null) |
||||
|
|
||||
|
appendField(obj, 'pets[0][species]', 'Dahut') |
||||
|
appendField(obj, 'pets[0][name]', 'Hypatia') |
||||
|
appendField(obj, 'pets[1][species]', 'Felis Stultus') |
||||
|
appendField(obj, 'pets[1][name]', 'Billie') |
||||
|
|
||||
|
console.log(obj) |
||||
|
``` |
||||
|
|
||||
|
```text |
||||
|
{ pets: |
||||
|
[ { species: 'Dahut', name: 'Hypatia' }, |
||||
|
{ species: 'Felis Stultus', name: 'Billie' } ] } |
||||
|
``` |
||||
|
|
||||
|
## API |
||||
|
|
||||
|
### `appendField(store, key, value)` |
||||
|
|
||||
|
Adds the field named `key` with the value `value` to the object `store`. |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
MIT |
||||
@ -0,0 +1,12 @@ |
|||||
|
var parsePath = require('./lib/parse-path') |
||||
|
var setValue = require('./lib/set-value') |
||||
|
|
||||
|
function appendField (store, key, value) { |
||||
|
var steps = parsePath(key) |
||||
|
|
||||
|
steps.reduce(function (context, step) { |
||||
|
return setValue(context, step, context[step.key], value) |
||||
|
}, store) |
||||
|
} |
||||
|
|
||||
|
module.exports = appendField |
||||
@ -0,0 +1,53 @@ |
|||||
|
var reFirstKey = /^[^\[]*/ |
||||
|
var reDigitPath = /^\[(\d+)\]/ |
||||
|
var reNormalPath = /^\[([^\]]+)\]/ |
||||
|
|
||||
|
function parsePath (key) { |
||||
|
function failure () { |
||||
|
return [{ type: 'object', key: key, last: true }] |
||||
|
} |
||||
|
|
||||
|
var firstKey = reFirstKey.exec(key)[0] |
||||
|
if (!firstKey) return failure() |
||||
|
|
||||
|
var len = key.length |
||||
|
var pos = firstKey.length |
||||
|
var tail = { type: 'object', key: firstKey } |
||||
|
var steps = [tail] |
||||
|
|
||||
|
while (pos < len) { |
||||
|
var m |
||||
|
|
||||
|
if (key[pos] === '[' && key[pos + 1] === ']') { |
||||
|
pos += 2 |
||||
|
tail.append = true |
||||
|
if (pos !== len) return failure() |
||||
|
continue |
||||
|
} |
||||
|
|
||||
|
m = reDigitPath.exec(key.substring(pos)) |
||||
|
if (m !== null) { |
||||
|
pos += m[0].length |
||||
|
tail.nextType = 'array' |
||||
|
tail = { type: 'array', key: parseInt(m[1], 10) } |
||||
|
steps.push(tail) |
||||
|
continue |
||||
|
} |
||||
|
|
||||
|
m = reNormalPath.exec(key.substring(pos)) |
||||
|
if (m !== null) { |
||||
|
pos += m[0].length |
||||
|
tail.nextType = 'object' |
||||
|
tail = { type: 'object', key: m[1] } |
||||
|
steps.push(tail) |
||||
|
continue |
||||
|
} |
||||
|
|
||||
|
return failure() |
||||
|
} |
||||
|
|
||||
|
tail.last = true |
||||
|
return steps |
||||
|
} |
||||
|
|
||||
|
module.exports = parsePath |
||||
@ -0,0 +1,64 @@ |
|||||
|
function valueType (value) { |
||||
|
if (value === undefined) return 'undefined' |
||||
|
if (Array.isArray(value)) return 'array' |
||||
|
if (typeof value === 'object') return 'object' |
||||
|
return 'scalar' |
||||
|
} |
||||
|
|
||||
|
function setLastValue (context, step, currentValue, entryValue) { |
||||
|
switch (valueType(currentValue)) { |
||||
|
case 'undefined': |
||||
|
if (step.append) { |
||||
|
context[step.key] = [entryValue] |
||||
|
} else { |
||||
|
context[step.key] = entryValue |
||||
|
} |
||||
|
break |
||||
|
case 'array': |
||||
|
context[step.key].push(entryValue) |
||||
|
break |
||||
|
case 'object': |
||||
|
return setLastValue(currentValue, { type: 'object', key: '', last: true }, currentValue[''], entryValue) |
||||
|
case 'scalar': |
||||
|
context[step.key] = [context[step.key], entryValue] |
||||
|
break |
||||
|
} |
||||
|
|
||||
|
return context |
||||
|
} |
||||
|
|
||||
|
function setValue (context, step, currentValue, entryValue) { |
||||
|
if (step.last) return setLastValue(context, step, currentValue, entryValue) |
||||
|
|
||||
|
var obj |
||||
|
switch (valueType(currentValue)) { |
||||
|
case 'undefined': |
||||
|
if (step.nextType === 'array') { |
||||
|
context[step.key] = [] |
||||
|
} else { |
||||
|
context[step.key] = Object.create(null) |
||||
|
} |
||||
|
return context[step.key] |
||||
|
case 'object': |
||||
|
return context[step.key] |
||||
|
case 'array': |
||||
|
if (step.nextType === 'array') { |
||||
|
return currentValue |
||||
|
} |
||||
|
|
||||
|
obj = Object.create(null) |
||||
|
context[step.key] = obj |
||||
|
currentValue.forEach(function (item, i) { |
||||
|
if (item !== undefined) obj['' + i] = item |
||||
|
}) |
||||
|
|
||||
|
return obj |
||||
|
case 'scalar': |
||||
|
obj = Object.create(null) |
||||
|
obj[''] = currentValue |
||||
|
context[step.key] = obj |
||||
|
return obj |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = setValue |
||||
@ -0,0 +1,19 @@ |
|||||
|
{ |
||||
|
"name": "append-field", |
||||
|
"version": "1.0.0", |
||||
|
"license": "MIT", |
||||
|
"author": "Linus Unnebäck <linus@folkdatorn.se>", |
||||
|
"main": "index.js", |
||||
|
"devDependencies": { |
||||
|
"mocha": "^2.2.4", |
||||
|
"standard": "^6.0.5", |
||||
|
"testdata-w3c-json-form": "^0.2.0" |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"test": "standard && mocha" |
||||
|
}, |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "http://github.com/LinusU/node-append-field.git" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
/* eslint-env mocha */ |
||||
|
|
||||
|
var assert = require('assert') |
||||
|
var appendField = require('../') |
||||
|
var testData = require('testdata-w3c-json-form') |
||||
|
|
||||
|
describe('Append Field', function () { |
||||
|
for (var test of testData) { |
||||
|
it('handles ' + test.name, function () { |
||||
|
var store = Object.create(null) |
||||
|
|
||||
|
for (var field of test.fields) { |
||||
|
appendField(store, field.key, field.value) |
||||
|
} |
||||
|
|
||||
|
assert.deepEqual(store, test.expected) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,2 @@ |
|||||
|
tidelift: "npm/balanced-match" |
||||
|
patreon: juliangruber |
||||
@ -0,0 +1,21 @@ |
|||||
|
(MIT) |
||||
|
|
||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of |
||||
|
this software and associated documentation files (the "Software"), to deal in |
||||
|
the Software without restriction, including without limitation the rights to |
||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
||||
|
of the Software, and to permit persons to whom the Software is furnished to do |
||||
|
so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
||||
@ -0,0 +1,97 @@ |
|||||
|
# balanced-match |
||||
|
|
||||
|
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well! |
||||
|
|
||||
|
[](http://travis-ci.org/juliangruber/balanced-match) |
||||
|
[](https://www.npmjs.org/package/balanced-match) |
||||
|
|
||||
|
[](https://ci.testling.com/juliangruber/balanced-match) |
||||
|
|
||||
|
## Example |
||||
|
|
||||
|
Get the first matching pair of braces: |
||||
|
|
||||
|
```js |
||||
|
var balanced = require('balanced-match'); |
||||
|
|
||||
|
console.log(balanced('{', '}', 'pre{in{nested}}post')); |
||||
|
console.log(balanced('{', '}', 'pre{first}between{second}post')); |
||||
|
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); |
||||
|
``` |
||||
|
|
||||
|
The matches are: |
||||
|
|
||||
|
```bash |
||||
|
$ node example.js |
||||
|
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } |
||||
|
{ start: 3, |
||||
|
end: 9, |
||||
|
pre: 'pre', |
||||
|
body: 'first', |
||||
|
post: 'between{second}post' } |
||||
|
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' } |
||||
|
``` |
||||
|
|
||||
|
## API |
||||
|
|
||||
|
### var m = balanced(a, b, str) |
||||
|
|
||||
|
For the first non-nested matching pair of `a` and `b` in `str`, return an |
||||
|
object with those keys: |
||||
|
|
||||
|
* **start** the index of the first match of `a` |
||||
|
* **end** the index of the matching `b` |
||||
|
* **pre** the preamble, `a` and `b` not included |
||||
|
* **body** the match, `a` and `b` not included |
||||
|
* **post** the postscript, `a` and `b` not included |
||||
|
|
||||
|
If there's no match, `undefined` will be returned. |
||||
|
|
||||
|
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`. |
||||
|
|
||||
|
### var r = balanced.range(a, b, str) |
||||
|
|
||||
|
For the first non-nested matching pair of `a` and `b` in `str`, return an |
||||
|
array with indexes: `[ <a index>, <b index> ]`. |
||||
|
|
||||
|
If there's no match, `undefined` will be returned. |
||||
|
|
||||
|
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`. |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
With [npm](https://npmjs.org) do: |
||||
|
|
||||
|
```bash |
||||
|
npm install balanced-match |
||||
|
``` |
||||
|
|
||||
|
## Security contact information |
||||
|
|
||||
|
To report a security vulnerability, please use the |
||||
|
[Tidelift security contact](https://tidelift.com/security). |
||||
|
Tidelift will coordinate the fix and disclosure. |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
(MIT) |
||||
|
|
||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of |
||||
|
this software and associated documentation files (the "Software"), to deal in |
||||
|
the Software without restriction, including without limitation the rights to |
||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
||||
|
of the Software, and to permit persons to whom the Software is furnished to do |
||||
|
so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
||||
@ -0,0 +1,62 @@ |
|||||
|
'use strict'; |
||||
|
module.exports = balanced; |
||||
|
function balanced(a, b, str) { |
||||
|
if (a instanceof RegExp) a = maybeMatch(a, str); |
||||
|
if (b instanceof RegExp) b = maybeMatch(b, str); |
||||
|
|
||||
|
var r = range(a, b, str); |
||||
|
|
||||
|
return r && { |
||||
|
start: r[0], |
||||
|
end: r[1], |
||||
|
pre: str.slice(0, r[0]), |
||||
|
body: str.slice(r[0] + a.length, r[1]), |
||||
|
post: str.slice(r[1] + b.length) |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
function maybeMatch(reg, str) { |
||||
|
var m = str.match(reg); |
||||
|
return m ? m[0] : null; |
||||
|
} |
||||
|
|
||||
|
balanced.range = range; |
||||
|
function range(a, b, str) { |
||||
|
var begs, beg, left, right, result; |
||||
|
var ai = str.indexOf(a); |
||||
|
var bi = str.indexOf(b, ai + 1); |
||||
|
var i = ai; |
||||
|
|
||||
|
if (ai >= 0 && bi > 0) { |
||||
|
if(a===b) { |
||||
|
return [ai, bi]; |
||||
|
} |
||||
|
begs = []; |
||||
|
left = str.length; |
||||
|
|
||||
|
while (i >= 0 && !result) { |
||||
|
if (i == ai) { |
||||
|
begs.push(i); |
||||
|
ai = str.indexOf(a, i + 1); |
||||
|
} else if (begs.length == 1) { |
||||
|
result = [ begs.pop(), bi ]; |
||||
|
} else { |
||||
|
beg = begs.pop(); |
||||
|
if (beg < left) { |
||||
|
left = beg; |
||||
|
right = bi; |
||||
|
} |
||||
|
|
||||
|
bi = str.indexOf(b, i + 1); |
||||
|
} |
||||
|
|
||||
|
i = ai < bi && ai >= 0 ? ai : bi; |
||||
|
} |
||||
|
|
||||
|
if (begs.length) { |
||||
|
result = [ left, right ]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
{ |
||||
|
"name": "balanced-match", |
||||
|
"description": "Match balanced character pairs, like \"{\" and \"}\"", |
||||
|
"version": "1.0.2", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "git://github.com/juliangruber/balanced-match.git" |
||||
|
}, |
||||
|
"homepage": "https://github.com/juliangruber/balanced-match", |
||||
|
"main": "index.js", |
||||
|
"scripts": { |
||||
|
"test": "tape test/test.js", |
||||
|
"bench": "matcha test/bench.js" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"matcha": "^0.7.0", |
||||
|
"tape": "^4.6.0" |
||||
|
}, |
||||
|
"keywords": [ |
||||
|
"match", |
||||
|
"regexp", |
||||
|
"test", |
||||
|
"balanced", |
||||
|
"parse" |
||||
|
], |
||||
|
"author": { |
||||
|
"name": "Julian Gruber", |
||||
|
"email": "mail@juliangruber.com", |
||||
|
"url": "http://juliangruber.com" |
||||
|
}, |
||||
|
"license": "MIT", |
||||
|
"testling": { |
||||
|
"files": "test/*.js", |
||||
|
"browsers": [ |
||||
|
"ie/8..latest", |
||||
|
"firefox/20..latest", |
||||
|
"firefox/nightly", |
||||
|
"chrome/25..latest", |
||||
|
"chrome/canary", |
||||
|
"opera/12..latest", |
||||
|
"opera/next", |
||||
|
"safari/5.1..latest", |
||||
|
"ipad/6.0..latest", |
||||
|
"iphone/6.0..latest", |
||||
|
"android-browser/4.2..latest" |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
.git/ |
||||
|
.vscode/ |
||||
|
Dockerfile* |
||||
|
prebuilds/ |
||||
|
node_modules/ |
||||
|
build*/ |
||||
@ -0,0 +1,19 @@ |
|||||
|
root = true |
||||
|
|
||||
|
[*] |
||||
|
indent_style = space |
||||
|
indent_size = 4 |
||||
|
end_of_line = lf |
||||
|
charset = utf-8 |
||||
|
trim_trailing_whitespace = true |
||||
|
insert_final_newline = true |
||||
|
|
||||
|
[{package.json,*.yml}] |
||||
|
indent_style = space |
||||
|
indent_size = 2 |
||||
|
|
||||
|
[appveyor.yml] |
||||
|
end_of_line = crlf |
||||
|
|
||||
|
[*.md] |
||||
|
trim_trailing_whitespace = false |
||||
@ -0,0 +1,110 @@ |
|||||
|
name: Prebuildify, package, publish |
||||
|
|
||||
|
on: |
||||
|
push: |
||||
|
branches: [ master ] |
||||
|
pull_request: |
||||
|
branches: [ master ] |
||||
|
release: |
||||
|
types: [ prereleased, released ] |
||||
|
|
||||
|
jobs: |
||||
|
build-linux: |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
# This is unsafe, but we really don't use any other native dependencies |
||||
|
- run: npm ci |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/almalinux-devtoolset11 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/alpine npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-armv7 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-armv7l-musl npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-arm64 npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: docker run -u $(id -u):$(id -g) -v `pwd`:/input -w /input ghcr.io/prebuild/linux-arm64-musl npx prebuildify --napi --tag-libc --strip --target=node@18.0.0 |
||||
|
- run: find prebuilds |
||||
|
- uses: actions/upload-artifact@v4 |
||||
|
with: |
||||
|
name: prebuild-linux |
||||
|
path: ./prebuilds/ |
||||
|
|
||||
|
build-windows: |
||||
|
runs-on: windows-latest |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
- uses: actions/setup-node@v4 |
||||
|
with: |
||||
|
node-version: 20 |
||||
|
registry-url: 'https://registry.npmjs.org' |
||||
|
- run: npm ci |
||||
|
- run: npx prebuildify --napi --strip --arch=x64 --target=node@18.0.0 |
||||
|
- run: npx prebuildify --napi --strip --arch=arm64 --target=node@20.0.0 |
||||
|
- run: dir prebuilds |
||||
|
- uses: actions/upload-artifact@v4 |
||||
|
with: |
||||
|
name: prebuild-windows |
||||
|
path: ./prebuilds/ |
||||
|
|
||||
|
build-macos: |
||||
|
runs-on: macos-latest |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
- uses: actions/setup-node@v4 |
||||
|
with: |
||||
|
node-version: 18 |
||||
|
registry-url: 'https://registry.npmjs.org' |
||||
|
- run: npm ci |
||||
|
- run: npx prebuildify --napi --strip --arch=arm64 --target=node@18.0.0 |
||||
|
- run: npx prebuildify --napi --strip --arch=x64 --target=node@18.0.0 |
||||
|
- run: find prebuilds |
||||
|
- uses: actions/upload-artifact@v4 |
||||
|
with: |
||||
|
name: prebuild-macos |
||||
|
path: ./prebuilds/ |
||||
|
|
||||
|
pack: |
||||
|
needs: |
||||
|
- build-linux |
||||
|
- build-windows |
||||
|
- build-macos |
||||
|
runs-on: ubuntu-latest |
||||
|
outputs: |
||||
|
PACK_FILE: ${{ steps.pack.outputs.PACK_FILE }} |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
- uses: actions/download-artifact@v4 |
||||
|
with: |
||||
|
path: /tmp/prebuilds/ |
||||
|
- name: Coalesce prebuilds from build matrix |
||||
|
run: | |
||||
|
mkdir prebuilds |
||||
|
for d in /tmp/prebuilds/*; do |
||||
|
cp -Rav $d/* prebuilds/ |
||||
|
done |
||||
|
- run: chmod a+x prebuilds/*/*.node && find prebuilds -executable -type f |
||||
|
- id: pack |
||||
|
name: Prepare NPM package |
||||
|
run: | |
||||
|
echo "PACK_FILE=$(npm pack)" >> "$GITHUB_OUTPUT" |
||||
|
- uses: actions/upload-artifact@v4 |
||||
|
with: |
||||
|
name: package-tgz |
||||
|
path: ${{ steps.pack.outputs.PACK_FILE }} |
||||
|
if-no-files-found: 'error' |
||||
|
|
||||
|
test-package: |
||||
|
needs: pack |
||||
|
strategy: |
||||
|
matrix: |
||||
|
node-version: [ 18, 20, 22, 23 ] |
||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ] |
||||
|
runs-on: ${{ matrix.os }} |
||||
|
steps: |
||||
|
- uses: actions/setup-node@v4 |
||||
|
with: |
||||
|
node-version: ${{ matrix.node-version }} |
||||
|
registry-url: 'https://registry.npmjs.org' |
||||
|
- uses: actions/download-artifact@v4 |
||||
|
with: |
||||
|
name: package-tgz |
||||
|
- run: npm install ${{ needs.pack.outputs.PACK_FILE }} |
||||
|
- run: node -e "const b = require('bcrypt'); const h = b.hashSync('hello', 10); console.log(h, b.compareSync('hello', h))" |
||||
@ -0,0 +1,42 @@ |
|||||
|
name: ci |
||||
|
|
||||
|
on: |
||||
|
push: |
||||
|
branches: |
||||
|
- master |
||||
|
pull_request: |
||||
|
branches: |
||||
|
- master |
||||
|
|
||||
|
jobs: |
||||
|
build: |
||||
|
runs-on: ubuntu-latest |
||||
|
strategy: |
||||
|
matrix: |
||||
|
node-version: [18, 20, 22] |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
- name: Use Node.js ${{ matrix.node-version }} |
||||
|
uses: actions/setup-node@v4 |
||||
|
with: |
||||
|
node-version: ${{ matrix.node-version }} |
||||
|
- run: npm ci |
||||
|
- name: Test |
||||
|
run: npm test |
||||
|
|
||||
|
build-alpine: |
||||
|
runs-on: ubuntu-latest |
||||
|
strategy: |
||||
|
matrix: |
||||
|
node-version: [18, 20, 22] |
||||
|
container: |
||||
|
image: node:${{ matrix.node-version }}-alpine |
||||
|
steps: |
||||
|
- uses: actions/checkout@v4 |
||||
|
- name: Install dependencies |
||||
|
run: | |
||||
|
apk add make g++ python3 |
||||
|
- run: npm ci |
||||
|
- name: Test |
||||
|
run: | |
||||
|
npm test --unsafe-perm |
||||
@ -0,0 +1,184 @@ |
|||||
|
# 6.0.0 (2025-02-28) |
||||
|
* Drop support for NodeJS <= 16 |
||||
|
* Remove `node-pre-gyp` in favor of `prebuildify`, prebuilt binaries are now shipped with the package |
||||
|
* Update `node-addon-api` to 8.3.0 |
||||
|
* Update JS code to newer ES syntax |
||||
|
|
||||
|
# 5.1.0 (2022-10-06) |
||||
|
* Update `node-pre-gyp` to 1.0.11 |
||||
|
|
||||
|
# 5.1.0 (2022-10-06) |
||||
|
* Update `node-pre-gyp` to 1.0.10 |
||||
|
* Replace `nodeunit` with `jest` as the testing library |
||||
|
|
||||
|
# 5.0.1 (2021-02-22) |
||||
|
|
||||
|
* Update `node-pre-gyp` to 1.0.0 |
||||
|
|
||||
|
# 5.0.0 (2020-06-02) |
||||
|
|
||||
|
* Fix the bcrypt "wrap-around" bug. It affects passwords with lengths >= 255. |
||||
|
It is uncommon but it's a bug nevertheless. Previous attempts to fix the bug |
||||
|
was unsuccessful. |
||||
|
* Experimental support for z/OS |
||||
|
* Fix a bug related to NUL in password input |
||||
|
* Update `node-pre-gyp` to 0.15.0 |
||||
|
|
||||
|
# 4.0.1 (2020-02-27) |
||||
|
|
||||
|
* Fix compilation errors in Alpine linux |
||||
|
|
||||
|
# 4.0.0 (2020-02-17) |
||||
|
|
||||
|
* Switch to NAPI bcrypt |
||||
|
* Drop support for NodeJS 8 |
||||
|
|
||||
|
# 3.0.8 (2019-12-31) |
||||
|
|
||||
|
* Update `node-pre-gyp` to 0.14 |
||||
|
* Pre-built binaries for NodeJS 13 |
||||
|
|
||||
|
# 3.0.7 (2019-10-18) |
||||
|
|
||||
|
* Update `nan` to 2.14.0 |
||||
|
* Update `node-pre-gyp` to 0.13 |
||||
|
|
||||
|
# 3.0.6 (2019-04-11) |
||||
|
|
||||
|
* Update `nan` to 2.13.2 |
||||
|
|
||||
|
# 3.0.5 (2019-03-19) |
||||
|
|
||||
|
* Update `nan` to 2.13.1 |
||||
|
* NodeJS 12 compatibility |
||||
|
* Remove `node-pre-gyp` from bundled dependencies |
||||
|
|
||||
|
# 3.0.4-napi (2019-03-08) |
||||
|
|
||||
|
* Sync N-API bcrypt with NAN bcrypt |
||||
|
|
||||
|
# 3.0.4 (2019-02-07) |
||||
|
|
||||
|
* Fix GCC, NAN and V8 deprecation warnings |
||||
|
|
||||
|
# 3.0.3 (2018-12-19) |
||||
|
|
||||
|
* Update `nan` to 2.12.1 |
||||
|
|
||||
|
# 3.0.2 (2018-10-18) |
||||
|
|
||||
|
* Update `nan` to 2.11.1 |
||||
|
|
||||
|
# 3.0.1 (2018-09-20) |
||||
|
|
||||
|
* Update `nan` to 2.11.0 |
||||
|
|
||||
|
# 3.0.0 (2018-07-06) |
||||
|
|
||||
|
* Drop support for NodeJS <= 4 |
||||
|
|
||||
|
# 2.0.1 (2018-04-20) |
||||
|
|
||||
|
* Update `node-pre-gyp` to allow downloading prebuilt modules |
||||
|
|
||||
|
# 2.0.0 (2018-04-07) |
||||
|
|
||||
|
* Make `2b` the default bcrypt version |
||||
|
|
||||
|
# 1.1.0-napi (2018-01-21) |
||||
|
|
||||
|
* Initial support for [N-API](https://nodejs.org/api/n-api.html) |
||||
|
|
||||
|
# 1.0.3 (2016-08-23) |
||||
|
|
||||
|
* update to nan v2.6.2 for NodeJS 8 support |
||||
|
* Fix: use npm scripts instead of node-gyp directly. |
||||
|
|
||||
|
# 1.0.2 (2016-12-31) |
||||
|
|
||||
|
* Fix `compare` promise rejection with invalid arguments |
||||
|
|
||||
|
# 1.0.1 (2016-12-07) |
||||
|
|
||||
|
* Fix destructuring imports with promises |
||||
|
|
||||
|
# 1.0.0 (2016-12-04) |
||||
|
|
||||
|
* add Promise support (commit 2488473) |
||||
|
|
||||
|
# 0.8.7 (2016-06-09) |
||||
|
|
||||
|
* update nan to 2.3.5 for improved node v6 support |
||||
|
|
||||
|
# 0.8.6 (2016-04-20) |
||||
|
|
||||
|
* update nan for node v6 support |
||||
|
|
||||
|
# 0.8.5 (2015-08-12) |
||||
|
|
||||
|
* update to nan v2 (adds support for iojs 3) |
||||
|
|
||||
|
# 0.8.4 (2015-07-24) |
||||
|
|
||||
|
* fix deprecation warning for the Encode API |
||||
|
|
||||
|
# 0.8.3 (2015-05-06) |
||||
|
|
||||
|
* update nan to 1.8.4 for iojs 2.x support |
||||
|
|
||||
|
# 0.8.2 (2015-03-28) |
||||
|
|
||||
|
* always use callback for generating random bytes to avoid blocking |
||||
|
|
||||
|
# 0.8.1 (2015-01-18) |
||||
|
* update NaN to 1.5.0 for iojs support |
||||
|
|
||||
|
# 0.8.0 (2014-08-03) |
||||
|
* migrate to NAN for bindings |
||||
|
|
||||
|
# v0.5.0 |
||||
|
* Fix for issue around empty string params throwing Errors. |
||||
|
* Method deprecation. |
||||
|
* Upgrade from libeio/ev to libuv. (shtylman) |
||||
|
** --- NOTE --- Breaks 0.4.x compatability |
||||
|
* EV_MULTIPLICITY compile flag. |
||||
|
|
||||
|
# v0.4.1 |
||||
|
* Thread safety fix around OpenSSL (GH-32). (bnoordhuis - through node) |
||||
|
* C++ code changes using delete and new instead of malloc and free. (shtylman) |
||||
|
* Compile options for speed, zoom. (shtylman) |
||||
|
* Move much of the type and variable checking to the JS. (shtylman) |
||||
|
|
||||
|
# v0.4.0 |
||||
|
* Added getRounds function that will tell you the number of rounds within a hash/salt |
||||
|
|
||||
|
# v0.3.2 |
||||
|
* Fix api issue with async salt gen first param |
||||
|
|
||||
|
# v0.3.1 |
||||
|
* Compile under node 0.5.x |
||||
|
|
||||
|
# v0.3.0 |
||||
|
* Internal Refactoring |
||||
|
* Remove pthread dependencies and locking |
||||
|
* Fix compiler warnings and a memory bug |
||||
|
|
||||
|
# v0.2.4 |
||||
|
* Use threadsafe functions instead of pthread mutexes |
||||
|
* salt validation to make sure the salt is of the correct size and format |
||||
|
|
||||
|
# v0.2.3 |
||||
|
* cygwin support |
||||
|
|
||||
|
# v0.2.2 |
||||
|
* Remove dependency on libbsd, use libssl instead |
||||
|
|
||||
|
# v0.2.0 |
||||
|
* Added async functionality |
||||
|
* API changes |
||||
|
* hashpw -> encrypt |
||||
|
* all old sync methods now end with _sync |
||||
|
* Removed libbsd(arc4random) dependency...now uses openssl which is more widely spread |
||||
|
|
||||
|
# v0.1.2 |
||||
|
* Security fix. Wasn't reading rounds in properly and was always only using 4 rounds |
||||
@ -0,0 +1,57 @@ |
|||||
|
# Usage: |
||||
|
# |
||||
|
# docker build -t bcryptjs-builder . |
||||
|
# CONTAINER=$(docker create bcryptjs-builder) |
||||
|
# # Then copy the artifact to your host: |
||||
|
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . |
||||
|
# docker rm "$CONTAINER" |
||||
|
# |
||||
|
# Use --platform to build cross-platform i.e. for ARM: |
||||
|
# |
||||
|
# docker build -t bcryptjs-builder --platform "linux/arm64/v8" . |
||||
|
# CONTAINER=$docker create --platform "linux/arm64/v8" bcryptjs-builder) |
||||
|
# # this copies the prebuilds/linux-arm artifacts |
||||
|
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . |
||||
|
# docker rm "$CONTAINER" |
||||
|
|
||||
|
|
||||
|
ARG FROM_IMAGE=node:18-bullseye |
||||
|
#ARG FROM_IMAGE=arm32v7/node:16-bullseye |
||||
|
#ARG FROM_IMAGE=arm64v8/node:16-bullseye |
||||
|
FROM ${FROM_IMAGE} |
||||
|
|
||||
|
ENV project bcrypt-js |
||||
|
ENV DEBIAN_FRONTEND noninteractive |
||||
|
ENV LC_ALL en_US.UTF-8 |
||||
|
ENV LANG ${LC_ALL} |
||||
|
|
||||
|
RUN echo "#log: ${project}: Setup system" \ |
||||
|
&& set -x \ |
||||
|
&& apt-get update -y \ |
||||
|
&& apt-get install -y \ |
||||
|
build-essential \ |
||||
|
python3 \ |
||||
|
&& apt-get clean \ |
||||
|
&& update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \ |
||||
|
&& npm i -g prebuildify@5 node-gyp@9 \ |
||||
|
&& sync |
||||
|
|
||||
|
ADD . /usr/local/opt/${project} |
||||
|
WORKDIR /usr/local/opt/${project} |
||||
|
|
||||
|
RUN echo "#log: ${project}: Running build" \ |
||||
|
&& set -x \ |
||||
|
&& npm ci \ |
||||
|
&& npm run build |
||||
|
|
||||
|
ARG RUN_TESTS=true |
||||
|
ARG TEST_TIMEOUT_SECONDS= |
||||
|
|
||||
|
RUN if "${RUN_TESTS}"; then \ |
||||
|
echo "#log ${project}: Running tests" \ |
||||
|
&& npm test; \ |
||||
|
else \ |
||||
|
echo "#log ${project}: Tests were skipped!"; \ |
||||
|
fi |
||||
|
|
||||
|
CMD /bin/bash -l |
||||
@ -0,0 +1,41 @@ |
|||||
|
# Usage: |
||||
|
# |
||||
|
# docker build -t bcryptjs-linux-alpine-builder -f Dockerfile-alpine . |
||||
|
# CONTAINER=$(docker create bcryptjs-linux-alpine-builder) |
||||
|
# # Then copy the artifact to your host: |
||||
|
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . |
||||
|
# docker rm "$CONTAINER" |
||||
|
|
||||
|
ARG FROM_IMAGE=node:18-alpine |
||||
|
FROM ${FROM_IMAGE} |
||||
|
|
||||
|
ENV project bcrypt-js |
||||
|
ENV DEBIAN_FRONTEND noninteractive |
||||
|
ENV LC_ALL en_US.UTF-8 |
||||
|
ENV LANG ${LC_ALL} |
||||
|
|
||||
|
RUN echo "#log: ${project}: Setup system" \ |
||||
|
&& set -x \ |
||||
|
&& apk add --update build-base python3 \ |
||||
|
&& npm i -g prebuildify@5 node-gyp@9 \ |
||||
|
&& sync |
||||
|
|
||||
|
ADD . /usr/local/opt/${project} |
||||
|
WORKDIR /usr/local/opt/${project} |
||||
|
|
||||
|
RUN echo "#log: ${project}: Running build" \ |
||||
|
&& set -x \ |
||||
|
&& npm ci \ |
||||
|
&& npm run build |
||||
|
|
||||
|
ARG RUN_TESTS=true |
||||
|
ARG TEST_TIMEOUT_SECONDS= |
||||
|
|
||||
|
RUN if "${RUN_TESTS}"; then \ |
||||
|
echo "#log ${project}: Running tests" \ |
||||
|
&& npm test; \ |
||||
|
else \ |
||||
|
echo "#log ${project}: Tests were skipped!"; \ |
||||
|
fi |
||||
|
|
||||
|
CMD /bin/bash -l |
||||
@ -0,0 +1,18 @@ |
|||||
|
Thanks for reporting a new issue with the node bcrypt module! |
||||
|
|
||||
|
To help you resolve your issue faster please make sure you have done the following: |
||||
|
|
||||
|
* Searched existing issues (even closed ones) for your same problem |
||||
|
* Make sure you have installed the required dependencies listed on the readme |
||||
|
* Read your npm error log for lines telling you what failed, usually it is a problem with not having the correct dependencies installed to build the native module |
||||
|
|
||||
|
Once you have done the above and are still confident that the issue is with the module, please describe it below. Some things that really help get your issue resolved faster are: |
||||
|
|
||||
|
* What went wrong? |
||||
|
* What did you expect to happen? |
||||
|
* Which version of nodejs and OS? |
||||
|
* If you find a bug, please write a failing test. |
||||
|
|
||||
|
Thanks! |
||||
|
|
||||
|
P.S. If it doesn't look like you read the above then your issue will likely be closed without further explanation. Sorry, but there are just too many issues opened with no useful information or questions which have been previously addressed. |
||||
@ -0,0 +1,19 @@ |
|||||
|
Copyright (c) 2010 Nicholas Campbell |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in |
||||
|
all copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
THE SOFTWARE. |
||||
@ -0,0 +1,19 @@ |
|||||
|
TESTS = test/*.js |
||||
|
|
||||
|
all: test |
||||
|
|
||||
|
build: clean compile |
||||
|
|
||||
|
compile: |
||||
|
npm install . |
||||
|
npm run install |
||||
|
|
||||
|
test: build |
||||
|
@./node_modules/.bin/jest \
|
||||
|
$(TESTS) |
||||
|
|
||||
|
clean: |
||||
|
rm -Rf lib/bindings/ |
||||
|
|
||||
|
|
||||
|
.PHONY: clean test build |
||||
@ -0,0 +1,388 @@ |
|||||
|
# node.bcrypt.js |
||||
|
|
||||
|
[](https://github.com/kelektiv/node.bcrypt.js/actions/workflows/ci.yaml) |
||||
|
|
||||
|
[](https://ci.appveyor.com/project/defunctzombie/node-bcrypt-js-pgo26/branch/master) |
||||
|
|
||||
|
A library to help you hash passwords. |
||||
|
|
||||
|
You can read about [bcrypt in Wikipedia][bcryptwiki] as well as in the following article: |
||||
|
[How To Safely Store A Password][codahale] |
||||
|
|
||||
|
## If You Are Submitting Bugs or Issues |
||||
|
|
||||
|
Please verify that the NodeJS version you are using is a _stable_ version; Unstable versions are currently not supported and issues created while using an unstable version will be closed. |
||||
|
|
||||
|
If you are on a stable version of NodeJS, please provide a sufficient code snippet or log files for installation issues. The code snippet does not require you to include confidential information. However, it must provide enough information so the problem can be replicable, or it may be closed without an explanation. |
||||
|
|
||||
|
|
||||
|
## Version Compatibility |
||||
|
|
||||
|
_Please upgrade to atleast v5.0.0 to avoid security issues mentioned below._ |
||||
|
|
||||
|
| Node Version | Bcrypt Version | |
||||
|
| -------------- | ------------------| |
||||
|
| 0.4 | <= 0.4 | |
||||
|
| 0.6, 0.8, 0.10 | >= 0.5 | |
||||
|
| 0.11 | >= 0.8 | |
||||
|
| 4 | <= 2.1.0 | |
||||
|
| 8 | >= 1.0.3 < 4.0.0 | |
||||
|
| 10, 11 | >= 3 | |
||||
|
| 12 onwards | >= 3.0.6 | |
||||
|
|
||||
|
`node-gyp` only works with stable/released versions of node. Since the `bcrypt` module uses `node-gyp` to build and install, you'll need a stable version of node to use bcrypt. If you do not, you'll likely see an error that starts with: |
||||
|
|
||||
|
``` |
||||
|
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead |
||||
|
``` |
||||
|
|
||||
|
## Security Issues And Concerns |
||||
|
|
||||
|
> Per bcrypt implementation, only the first 72 bytes of a string are used. Any extra bytes are ignored when matching passwords. Note that this is not the first 72 *characters*. It is possible for a string to contain less than 72 characters, while taking up more than 72 bytes (e.g. a UTF-8 encoded string containing emojis). If a string is provided, it will be encoded using UTF-8. |
||||
|
|
||||
|
As should be the case with any security tool, anyone using this library should scrutinise it. If you find or suspect an issue with the code, please bring it to the maintainers' attention. We will spend some time ensuring that this library is as secure as possible. |
||||
|
|
||||
|
Here is a list of BCrypt-related security issues/concerns that have come up over the years. |
||||
|
|
||||
|
* An [issue with passwords][jtr] was found with a version of the Blowfish algorithm developed for John the Ripper. This is not present in the OpenBSD version and is thus not a problem for this module. HT [zooko][zooko]. |
||||
|
* Versions `< 5.0.0` suffer from bcrypt wrap-around bug and _will truncate passwords >= 255 characters leading to severely weakened passwords_. Please upgrade at earliest. See [this wiki page][wrap-around-bug] for more details. |
||||
|
* Versions `< 5.0.0` _do not handle NUL characters inside passwords properly leading to all subsequent characters being dropped and thus resulting in severely weakened passwords_. Please upgrade at earliest. See [this wiki page][improper-nuls] for more details. |
||||
|
|
||||
|
## Compatibility Note |
||||
|
|
||||
|
This library supports `$2a$` and `$2b$` prefix bcrypt hashes. `$2x$` and `$2y$` hashes are specific to bcrypt implementation developed for John the Ripper. In theory, they should be compatible with `$2b$` prefix. |
||||
|
|
||||
|
Compatibility with hashes generated by other languages is not 100% guaranteed due to difference in character encodings. However, it should not be an issue for most cases. |
||||
|
|
||||
|
### Migrating from v1.0.x |
||||
|
|
||||
|
Hashes generated in earlier version of `bcrypt` remain 100% supported in `v2.x.x` and later versions. In most cases, the migration should be a bump in the `package.json`. |
||||
|
|
||||
|
Hashes generated in `v2.x.x` using the defaults parameters will not work in earlier versions. |
||||
|
|
||||
|
## Dependencies |
||||
|
|
||||
|
* NodeJS |
||||
|
* `node-gyp` |
||||
|
* Please check the dependencies for this tool at: https://github.com/nodejs/node-gyp |
||||
|
* Windows users will need the options for c# and c++ installed with their visual studio instance. |
||||
|
* Python 2.x/3.x |
||||
|
* `OpenSSL` - This is only required to build the `bcrypt` project if you are using versions <= 0.7.7. Otherwise, we're using the builtin node crypto bindings for seed data (which use the same OpenSSL code paths we were, but don't have the external dependency). |
||||
|
|
||||
|
## Install via NPM |
||||
|
|
||||
|
``` |
||||
|
npm install bcrypt |
||||
|
``` |
||||
|
***Note:*** OS X users using Xcode 4.3.1 or above may need to run the following command in their terminal prior to installing if errors occur regarding xcodebuild: ```sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer``` |
||||
|
|
||||
|
_Pre-built binaries for various NodeJS versions are made available on a best-effort basis._ |
||||
|
|
||||
|
Only the current stable and supported LTS releases are actively tested against. |
||||
|
|
||||
|
_There may be an interval between the release of the module and the availabilty of the compiled modules._ |
||||
|
|
||||
|
Currently, we have pre-built binaries that support the following platforms: |
||||
|
|
||||
|
1. Windows x32 and x64 |
||||
|
2. Linux x64 (GlibC and musl) |
||||
|
3. macOS |
||||
|
|
||||
|
If you face an error like this: |
||||
|
|
||||
|
``` |
||||
|
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-linux-x64.tar.gz |
||||
|
``` |
||||
|
|
||||
|
make sure you have the appropriate dependencies installed and configured for your platform. You can find installation instructions for the dependencies for some common platforms [in this page][depsinstall]. |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
### async (recommended) |
||||
|
|
||||
|
```javascript |
||||
|
const bcrypt = require('bcrypt'); |
||||
|
const saltRounds = 10; |
||||
|
const myPlaintextPassword = 's0/\/\P4$$w0rD'; |
||||
|
const someOtherPlaintextPassword = 'not_bacon'; |
||||
|
``` |
||||
|
|
||||
|
#### To hash a password: |
||||
|
|
||||
|
Technique 1 (generate a salt and hash on separate function calls): |
||||
|
|
||||
|
```javascript |
||||
|
bcrypt.genSalt(saltRounds, function(err, salt) { |
||||
|
bcrypt.hash(myPlaintextPassword, salt, function(err, hash) { |
||||
|
// Store hash in your password DB. |
||||
|
}); |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
Technique 2 (auto-gen a salt and hash): |
||||
|
|
||||
|
```javascript |
||||
|
bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) { |
||||
|
// Store hash in your password DB. |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
Note that both techniques achieve the same end-result. |
||||
|
|
||||
|
#### To check a password: |
||||
|
|
||||
|
```javascript |
||||
|
// Load hash from your password DB. |
||||
|
bcrypt.compare(myPlaintextPassword, hash, function(err, result) { |
||||
|
// result == true |
||||
|
}); |
||||
|
bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) { |
||||
|
// result == false |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
[A Note on Timing Attacks](#a-note-on-timing-attacks) |
||||
|
|
||||
|
### with promises |
||||
|
|
||||
|
bcrypt uses whatever `Promise` implementation is available in `global.Promise`. NodeJS >= 0.12 has a native `Promise` implementation built in. However, this should work in any Promises/A+ compliant implementation. |
||||
|
|
||||
|
Async methods that accept a callback, return a `Promise` when callback is not specified if Promise support is available. |
||||
|
|
||||
|
```javascript |
||||
|
bcrypt.hash(myPlaintextPassword, saltRounds).then(function(hash) { |
||||
|
// Store hash in your password DB. |
||||
|
}); |
||||
|
``` |
||||
|
```javascript |
||||
|
// Load hash from your password DB. |
||||
|
bcrypt.compare(myPlaintextPassword, hash).then(function(result) { |
||||
|
// result == true |
||||
|
}); |
||||
|
bcrypt.compare(someOtherPlaintextPassword, hash).then(function(result) { |
||||
|
// result == false |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
This is also compatible with `async/await` |
||||
|
|
||||
|
```javascript |
||||
|
async function checkUser(username, password) { |
||||
|
//... fetch user from a db etc. |
||||
|
|
||||
|
const match = await bcrypt.compare(password, user.passwordHash); |
||||
|
|
||||
|
if(match) { |
||||
|
//login |
||||
|
} |
||||
|
|
||||
|
//... |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### ESM import |
||||
|
```javascript |
||||
|
import bcrypt from "bcrypt"; |
||||
|
|
||||
|
// later |
||||
|
await bcrypt.compare(password, hash); |
||||
|
``` |
||||
|
|
||||
|
### sync |
||||
|
|
||||
|
```javascript |
||||
|
const bcrypt = require('bcrypt'); |
||||
|
const saltRounds = 10; |
||||
|
const myPlaintextPassword = 's0/\/\P4$$w0rD'; |
||||
|
const someOtherPlaintextPassword = 'not_bacon'; |
||||
|
``` |
||||
|
|
||||
|
#### To hash a password: |
||||
|
|
||||
|
Technique 1 (generate a salt and hash on separate function calls): |
||||
|
|
||||
|
```javascript |
||||
|
const salt = bcrypt.genSaltSync(saltRounds); |
||||
|
const hash = bcrypt.hashSync(myPlaintextPassword, salt); |
||||
|
// Store hash in your password DB. |
||||
|
``` |
||||
|
|
||||
|
Technique 2 (auto-gen a salt and hash): |
||||
|
|
||||
|
```javascript |
||||
|
const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds); |
||||
|
// Store hash in your password DB. |
||||
|
``` |
||||
|
|
||||
|
As with async, both techniques achieve the same end-result. |
||||
|
|
||||
|
#### To check a password: |
||||
|
|
||||
|
```javascript |
||||
|
// Load hash from your password DB. |
||||
|
bcrypt.compareSync(myPlaintextPassword, hash); // true |
||||
|
bcrypt.compareSync(someOtherPlaintextPassword, hash); // false |
||||
|
``` |
||||
|
|
||||
|
[A Note on Timing Attacks](#a-note-on-timing-attacks) |
||||
|
|
||||
|
### Why is async mode recommended over sync mode? |
||||
|
We recommend using async API if you use `bcrypt` on a server. Bcrypt hashing is CPU intensive which will cause the sync APIs to block the event loop and prevent your application from servicing any inbound requests or events. The async version uses a thread pool which does not block the main event loop. |
||||
|
|
||||
|
## API |
||||
|
|
||||
|
`BCrypt.` |
||||
|
|
||||
|
* `genSaltSync(rounds, minor)` |
||||
|
* `rounds` - [OPTIONAL] - the cost of processing the data. (default - 10) |
||||
|
* `minor` - [OPTIONAL] - minor version of bcrypt to use. (default - b) |
||||
|
* `genSalt(rounds, minor, cb)` |
||||
|
* `rounds` - [OPTIONAL] - the cost of processing the data. (default - 10) |
||||
|
* `minor` - [OPTIONAL] - minor version of bcrypt to use. (default - b) |
||||
|
* `cb` - [OPTIONAL] - a callback to be fired once the salt has been generated. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available. |
||||
|
* `err` - First parameter to the callback detailing any errors. |
||||
|
* `salt` - Second parameter to the callback providing the generated salt. |
||||
|
* `hashSync(data, salt)` |
||||
|
* `data` - [REQUIRED] - the data to be encrypted. |
||||
|
* `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**). |
||||
|
* `hash(data, salt, cb)` |
||||
|
* `data` - [REQUIRED] - the data to be encrypted. |
||||
|
* `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**). |
||||
|
* `cb` - [OPTIONAL] - a callback to be fired once the data has been encrypted. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available. |
||||
|
* `err` - First parameter to the callback detailing any errors. |
||||
|
* `encrypted` - Second parameter to the callback providing the encrypted form. |
||||
|
* `compareSync(data, encrypted)` |
||||
|
* `data` - [REQUIRED] - data to compare. |
||||
|
* `encrypted` - [REQUIRED] - data to be compared to. |
||||
|
* `compare(data, encrypted, cb)` |
||||
|
* `data` - [REQUIRED] - data to compare. |
||||
|
* `encrypted` - [REQUIRED] - data to be compared to. |
||||
|
* `cb` - [OPTIONAL] - a callback to be fired once the data has been compared. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available. |
||||
|
* `err` - First parameter to the callback detailing any errors. |
||||
|
* `same` - Second parameter to the callback providing whether the data and encrypted forms match [true | false]. |
||||
|
* `getRounds(encrypted)` - return the number of rounds used to encrypt a given hash |
||||
|
* `encrypted` - [REQUIRED] - hash from which the number of rounds used should be extracted. |
||||
|
|
||||
|
## A Note on Rounds |
||||
|
|
||||
|
A note about the cost: when you are hashing your data, the module will go through a series of rounds to give you a secure hash. The value you submit is not just the number of rounds the module will go through to hash your data. The module will use the value you enter and go through `2^rounds` hashing iterations. |
||||
|
|
||||
|
From @garthk, on a 2GHz core you can roughly expect: |
||||
|
|
||||
|
rounds=8 : ~40 hashes/sec |
||||
|
rounds=9 : ~20 hashes/sec |
||||
|
rounds=10: ~10 hashes/sec |
||||
|
rounds=11: ~5 hashes/sec |
||||
|
rounds=12: 2-3 hashes/sec |
||||
|
rounds=13: ~1 sec/hash |
||||
|
rounds=14: ~1.5 sec/hash |
||||
|
rounds=15: ~3 sec/hash |
||||
|
rounds=25: ~1 hour/hash |
||||
|
rounds=31: 2-3 days/hash |
||||
|
|
||||
|
|
||||
|
## A Note on Timing Attacks |
||||
|
|
||||
|
Because it's come up multiple times in this project and other bcrypt projects, it needs to be said. The `bcrypt` library is not susceptible to timing attacks. From codahale/bcrypt-ruby#42: |
||||
|
|
||||
|
> One of the desired properties of a cryptographic hash function is preimage attack resistance, which means there is no shortcut for generating a message which, when hashed, produces a specific digest. |
||||
|
|
||||
|
A great thread on this, in much more detail can be found @ codahale/bcrypt-ruby#43 |
||||
|
|
||||
|
If you're unfamiliar with timing attacks and want to learn more you can find a great writeup @ [A Lesson In Timing Attacks][timingatk] |
||||
|
|
||||
|
However, timing attacks are real. And the comparison function is _not_ time safe. That means that it may exit the function early in the comparison process. Timing attacks happen because of the above. We don't need to be careful that an attacker will learn anything, and our comparison function provides a comparison of hashes. It is a utility to the overall purpose of the library. If you end up using it for something else, we cannot guarantee the security of the comparator. Keep that in mind as you use the library. |
||||
|
|
||||
|
## Hash Info |
||||
|
|
||||
|
The characters that comprise the resultant hash are `./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$`. |
||||
|
|
||||
|
Resultant hashes will be 60 characters long and they will include the salt among other parameters, as follows: |
||||
|
|
||||
|
`$[algorithm]$[cost]$[salt][hash]` |
||||
|
|
||||
|
- 2 chars hash algorithm identifier prefix. `"$2a$" or "$2b$"` indicates BCrypt |
||||
|
- Cost-factor (n). Represents the exponent used to determine how many iterations 2^n |
||||
|
- 16-byte (128-bit) salt, base64 encoded to 22 characters |
||||
|
- 24-byte (192-bit) hash, base64 encoded to 31 characters |
||||
|
|
||||
|
Example: |
||||
|
``` |
||||
|
$2b$10$nOUIs5kJ7naTuTFkBy1veuK0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa |
||||
|
| | | | |
||||
|
| | | hash-value = K0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa |
||||
|
| | | |
||||
|
| | salt = nOUIs5kJ7naTuTFkBy1veu |
||||
|
| | |
||||
|
| cost-factor => 10 = 2^10 rounds |
||||
|
| |
||||
|
hash-algorithm identifier => 2b = BCrypt |
||||
|
``` |
||||
|
|
||||
|
## Testing |
||||
|
|
||||
|
If you create a pull request, tests better pass :) |
||||
|
|
||||
|
``` |
||||
|
npm install |
||||
|
npm test |
||||
|
``` |
||||
|
|
||||
|
## Credits |
||||
|
|
||||
|
The code for this comes from a few sources: |
||||
|
|
||||
|
* blowfish.cc - OpenBSD |
||||
|
* bcrypt.cc - OpenBSD |
||||
|
* bcrypt::gen_salt - [gen_salt inclusion to bcrypt][bcryptgs] |
||||
|
* bcrypt_node.cc - me |
||||
|
|
||||
|
## Contributors |
||||
|
|
||||
|
* [Antonio Salazar Cardozo][shadowfiend] - Early MacOS X support (when we used libbsd) |
||||
|
* [Ben Glow][pixelglow] - Fixes for thread safety with async calls |
||||
|
* [Van Nguyen][thegoleffect] - Found a timing attack in the comparator |
||||
|
* [NewITFarmer][newitfarmer] - Initial Cygwin support |
||||
|
* [David Trejo][dtrejo] - packaging fixes |
||||
|
* [Alfred Westerveld][alfredwesterveld] - packaging fixes |
||||
|
* [Vincent Côté-Roy][vincentr] - Testing around concurrency issues |
||||
|
* [Lloyd Hilaiel][lloyd] - Documentation fixes |
||||
|
* [Roman Shtylman][shtylman] - Code refactoring, general rot reduction, compile options, better memory management with delete and new, and an upgrade to libuv over eio/ev. |
||||
|
* [Vadim Graboys][vadimg] - Code changes to support 0.5.5+ |
||||
|
* [Ben Noordhuis][bnoordhuis] - Fixed a thread safety issue in nodejs that was perfectly mappable to this module. |
||||
|
* [Nate Rajlich][tootallnate] - Bindings and build process. |
||||
|
* [Sean McArthur][seanmonstar] - Windows Support |
||||
|
* [Fanie Oosthuysen][weareu] - Windows Support |
||||
|
* [Amitosh Swain Mahapatra][recrsn] - $2b$ hash support, ES6 Promise support |
||||
|
* [Nicola Del Gobbo][NickNaso] - Initial implementation with N-API |
||||
|
|
||||
|
## License |
||||
|
Unless stated elsewhere, file headers or otherwise, the license as stated in the LICENSE file. |
||||
|
|
||||
|
[bcryptwiki]: https://en.wikipedia.org/wiki/Bcrypt |
||||
|
[bcryptgs]: http://mail-index.netbsd.org/tech-crypto/2002/05/24/msg000204.html |
||||
|
[codahale]: http://codahale.com/how-to-safely-store-a-password/ |
||||
|
[gh13]: https://github.com/ncb000gt/node.bcrypt.js/issues/13 |
||||
|
[jtr]: http://www.openwall.com/lists/oss-security/2011/06/20/2 |
||||
|
[depsinstall]: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions |
||||
|
[timingatk]: https://codahale.com/a-lesson-in-timing-attacks/ |
||||
|
[wrap-around-bug]: https://github.com/kelektiv/node.bcrypt.js/wiki/Security-Issues-and-Concerns#bcrypt-wrap-around-bug-medium-severity |
||||
|
[improper-nuls]: https://github.com/kelektiv/node.bcrypt.js/wiki/Security-Issues-and-Concerns#improper-nul-handling-medium-severity |
||||
|
|
||||
|
[shadowfiend]:https://github.com/Shadowfiend |
||||
|
[thegoleffect]:https://github.com/thegoleffect |
||||
|
[pixelglow]:https://github.com/pixelglow |
||||
|
[dtrejo]:https://github.com/dtrejo |
||||
|
[alfredwesterveld]:https://github.com/alfredwesterveld |
||||
|
[newitfarmer]:https://github.com/newitfarmer |
||||
|
[zooko]:https://twitter.com/zooko |
||||
|
[vincentr]:https://twitter.com/vincentcr |
||||
|
[lloyd]:https://github.com/lloyd |
||||
|
[shtylman]:https://github.com/shtylman |
||||
|
[vadimg]:https://github.com/vadimg |
||||
|
[bnoordhuis]:https://github.com/bnoordhuis |
||||
|
[tootallnate]:https://github.com/tootallnate |
||||
|
[seanmonstar]:https://github.com/seanmonstar |
||||
|
[weareu]:https://github.com/weareu |
||||
|
[recrsn]:https://github.com/recrsn |
||||
|
[NickNaso]: https://github.com/NickNaso |
||||
@ -0,0 +1,15 @@ |
|||||
|
# Security Policy |
||||
|
|
||||
|
As with any software, `bcrypt` is likely to have bugs. Please report any security vulnerabilities responsibly |
||||
|
|
||||
|
## Supported Versions |
||||
|
|
||||
|
| Version | Supported | |
||||
|
| ------- | ------------------ | |
||||
|
| 5.0.x | :white_check_mark: | |
||||
|
| < 5.0 | :x: | |
||||
|
|
||||
|
## Reporting a Vulnerability |
||||
|
|
||||
|
If you are reporting a security vulnerability, please refrain from opening a GitHub issue and instead mail it to |
||||
|
one of the maintainers listed in the README. |
||||
@ -0,0 +1,242 @@ |
|||||
|
const path = require('path'); |
||||
|
const bindings = require('node-gyp-build')(path.resolve(__dirname)); |
||||
|
|
||||
|
const crypto = require('crypto'); |
||||
|
|
||||
|
const promises = require('./promises'); |
||||
|
|
||||
|
/// generate a salt (sync)
|
||||
|
/// @param {Number} [rounds] number of rounds (default 10)
|
||||
|
/// @return {String} salt
|
||||
|
function genSaltSync(rounds, minor) { |
||||
|
// default 10 rounds
|
||||
|
if (!rounds) { |
||||
|
rounds = 10; |
||||
|
} else if (typeof rounds !== 'number') { |
||||
|
throw new Error('rounds must be a number'); |
||||
|
} |
||||
|
|
||||
|
if (!minor) { |
||||
|
minor = 'b'; |
||||
|
} else if (minor !== 'b' && minor !== 'a') { |
||||
|
throw new Error('minor must be either "a" or "b"'); |
||||
|
} |
||||
|
|
||||
|
return bindings.gen_salt_sync(minor, rounds, crypto.randomBytes(16)); |
||||
|
} |
||||
|
|
||||
|
/// generate a salt
|
||||
|
/// @param {Number} [rounds] number of rounds (default 10)
|
||||
|
/// @param {Function} cb callback(err, salt)
|
||||
|
function genSalt(rounds, minor, cb) { |
||||
|
let error; |
||||
|
|
||||
|
// if callback is first argument, then use defaults for others
|
||||
|
if (typeof arguments[0] === 'function') { |
||||
|
// have to set callback first otherwise arguments are overridden
|
||||
|
cb = arguments[0]; |
||||
|
rounds = 10; |
||||
|
minor = 'b'; |
||||
|
// callback is second argument
|
||||
|
} else if (typeof arguments[1] === 'function') { |
||||
|
// have to set callback first otherwise arguments are overridden
|
||||
|
cb = arguments[1]; |
||||
|
minor = 'b'; |
||||
|
} |
||||
|
|
||||
|
if (!cb) { |
||||
|
return promises.promise(genSalt, this, [rounds, minor]); |
||||
|
} |
||||
|
|
||||
|
// default 10 rounds
|
||||
|
if (!rounds) { |
||||
|
rounds = 10; |
||||
|
} else if (typeof rounds !== 'number') { |
||||
|
// callback error asynchronously
|
||||
|
error = new Error('rounds must be a number'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (!minor) { |
||||
|
minor = 'b' |
||||
|
} else if (minor !== 'b' && minor !== 'a') { |
||||
|
error = new Error('minor must be either "a" or "b"'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
crypto.randomBytes(16, function (error, randomBytes) { |
||||
|
if (error) { |
||||
|
cb(error); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
bindings.gen_salt(minor, rounds, randomBytes, cb); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/// hash data using a salt
|
||||
|
/// @param {String|Buffer} data the data to encrypt
|
||||
|
/// @param {String} salt the salt to use when hashing
|
||||
|
/// @return {String} hash
|
||||
|
function hashSync(data, salt) { |
||||
|
if (data == null || salt == null) { |
||||
|
throw new Error('data and salt arguments required'); |
||||
|
} |
||||
|
|
||||
|
if (!(typeof data === 'string' || data instanceof Buffer) || (typeof salt !== 'string' && typeof salt !== 'number')) { |
||||
|
throw new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds'); |
||||
|
} |
||||
|
|
||||
|
if (typeof salt === 'number') { |
||||
|
salt = module.exports.genSaltSync(salt); |
||||
|
} |
||||
|
|
||||
|
return bindings.encrypt_sync(data, salt); |
||||
|
} |
||||
|
|
||||
|
/// hash data using a salt
|
||||
|
/// @param {String|Buffer} data the data to encrypt
|
||||
|
/// @param {String} salt the salt to use when hashing
|
||||
|
/// @param {Function} cb callback(err, hash)
|
||||
|
function hash(data, salt, cb) { |
||||
|
let error; |
||||
|
|
||||
|
if (typeof data === 'function') { |
||||
|
error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds'); |
||||
|
return process.nextTick(function () { |
||||
|
data(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (typeof salt === 'function') { |
||||
|
error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds'); |
||||
|
return process.nextTick(function () { |
||||
|
salt(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// cb exists but is not a function
|
||||
|
// return a rejecting promise
|
||||
|
if (cb && typeof cb !== 'function') { |
||||
|
return promises.reject(new Error('cb must be a function or null to return a Promise')); |
||||
|
} |
||||
|
|
||||
|
if (!cb) { |
||||
|
return promises.promise(hash, this, [data, salt]); |
||||
|
} |
||||
|
|
||||
|
if (data == null || salt == null) { |
||||
|
error = new Error('data and salt arguments required'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (!(typeof data === 'string' || data instanceof Buffer) || (typeof salt !== 'string' && typeof salt !== 'number')) { |
||||
|
error = new Error('data must be a string or Buffer and salt must either be a salt string or a number of rounds'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
if (typeof salt === 'number') { |
||||
|
return module.exports.genSalt(salt, function (err, salt) { |
||||
|
return bindings.encrypt(data, salt, cb); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return bindings.encrypt(data, salt, cb); |
||||
|
} |
||||
|
|
||||
|
/// compare raw data to hash
|
||||
|
/// @param {String|Buffer} data the data to hash and compare
|
||||
|
/// @param {String} hash expected hash
|
||||
|
/// @return {bool} true if hashed data matches hash
|
||||
|
function compareSync(data, hash) { |
||||
|
if (data == null || hash == null) { |
||||
|
throw new Error('data and hash arguments required'); |
||||
|
} |
||||
|
|
||||
|
if (!(typeof data === 'string' || data instanceof Buffer) || typeof hash !== 'string') { |
||||
|
throw new Error('data must be a string or Buffer and hash must be a string'); |
||||
|
} |
||||
|
|
||||
|
return bindings.compare_sync(data, hash); |
||||
|
} |
||||
|
|
||||
|
/// compare raw data to hash
|
||||
|
/// @param {String|Buffer} data the data to hash and compare
|
||||
|
/// @param {String} hash expected hash
|
||||
|
/// @param {Function} cb callback(err, matched) - matched is true if hashed data matches hash
|
||||
|
function compare(data, hash, cb) { |
||||
|
let error; |
||||
|
|
||||
|
if (typeof data === 'function') { |
||||
|
error = new Error('data and hash arguments required'); |
||||
|
return process.nextTick(function () { |
||||
|
data(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (typeof hash === 'function') { |
||||
|
error = new Error('data and hash arguments required'); |
||||
|
return process.nextTick(function () { |
||||
|
hash(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// cb exists but is not a function
|
||||
|
// return a rejecting promise
|
||||
|
if (cb && typeof cb !== 'function') { |
||||
|
return promises.reject(new Error('cb must be a function or null to return a Promise')); |
||||
|
} |
||||
|
|
||||
|
if (!cb) { |
||||
|
return promises.promise(compare, this, [data, hash]); |
||||
|
} |
||||
|
|
||||
|
if (data == null || hash == null) { |
||||
|
error = new Error('data and hash arguments required'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (!(typeof data === 'string' || data instanceof Buffer) || typeof hash !== 'string') { |
||||
|
error = new Error('data and hash must be strings'); |
||||
|
return process.nextTick(function () { |
||||
|
cb(error); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return bindings.compare(data, hash, cb); |
||||
|
} |
||||
|
|
||||
|
/// @param {String} hash extract rounds from this hash
|
||||
|
/// @return {Number} the number of rounds used to encrypt a given hash
|
||||
|
function getRounds(hash) { |
||||
|
if (hash == null) { |
||||
|
throw new Error('hash argument required'); |
||||
|
} |
||||
|
|
||||
|
if (typeof hash !== 'string') { |
||||
|
throw new Error('hash must be a string'); |
||||
|
} |
||||
|
|
||||
|
return bindings.get_rounds(hash); |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
genSaltSync, |
||||
|
genSalt, |
||||
|
hashSync, |
||||
|
hash, |
||||
|
compareSync, |
||||
|
compare, |
||||
|
getRounds, |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
{ |
||||
|
"variables": { |
||||
|
"NODE_VERSION%":"<!(node -p \"process.versions.node.split(\\\".\\\")[0]\")" |
||||
|
}, |
||||
|
'targets': [ |
||||
|
{ |
||||
|
'target_name': 'bcrypt_lib', |
||||
|
'sources': [ |
||||
|
'src/blowfish.cc', |
||||
|
'src/bcrypt.cc', |
||||
|
'src/bcrypt_node.cc' |
||||
|
], |
||||
|
'defines': [ |
||||
|
'_GNU_SOURCE', |
||||
|
], |
||||
|
'cflags!': [ '-fno-exceptions' ], |
||||
|
'cflags_cc!': [ '-fno-exceptions' ], |
||||
|
'dependencies': [ |
||||
|
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except", |
||||
|
], |
||||
|
'conditions': [ |
||||
|
['OS=="win"', { |
||||
|
"msvs_settings": { |
||||
|
"VCCLCompilerTool": { |
||||
|
"ExceptionHandling": 1 |
||||
|
} |
||||
|
}, |
||||
|
'defines': [ |
||||
|
'uint=unsigned int', |
||||
|
] |
||||
|
}], |
||||
|
['OS=="mac"', { |
||||
|
'cflags+': ['-fvisibility=hidden'], |
||||
|
"xcode_settings": { |
||||
|
"CLANG_CXX_LIBRARY": "libc++", |
||||
|
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', |
||||
|
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden |
||||
|
} |
||||
|
}], |
||||
|
['OS=="zos" and NODE_VERSION <= 16',{ |
||||
|
'cflags': [ |
||||
|
'-qascii', |
||||
|
], |
||||
|
'defines': ["NAPI_DISABLE_CPP_EXCEPTIONS"], |
||||
|
}], |
||||
|
], |
||||
|
}, |
||||
|
] |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue