This commit is contained in:
batche
2022-11-07 17:12:06 +01:00
parent 7fd8147140
commit 24b68dc767
328 changed files with 52116 additions and 724 deletions

631
package-lock.json generated
View File

@@ -1,631 +0,0 @@
{
"name": "15_ft_transcendence",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"@nestjs/jwt": "^9.0.0",
"passport-jwt": "^4.0.0"
},
"devDependencies": {
"@types/passport-jwt": "^3.0.7"
}
},
"node_modules/@nestjs/common": {
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-9.1.6.tgz",
"integrity": "sha512-9Ttk9va/BwEab36RSXLZdRoPUX3DZHUpzseKEfqHVhnaUIsIMt7lVd79GQ1FroQ2FZqoCwcLyBowevXhrE1Wnw==",
"peer": true,
"dependencies": {
"iterare": "1.2.1",
"tslib": "2.4.0",
"uuid": "9.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nest"
},
"peerDependencies": {
"cache-manager": "<=5",
"class-transformer": "*",
"class-validator": "*",
"reflect-metadata": "^0.1.12",
"rxjs": "^7.1.0"
},
"peerDependenciesMeta": {
"cache-manager": {
"optional": true
},
"class-transformer": {
"optional": true
},
"class-validator": {
"optional": true
}
}
},
"node_modules/@nestjs/jwt": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/jwt/-/jwt-9.0.0.tgz",
"integrity": "sha512-ZsXGY/wMYKzEhymw2+dxiwrHTRKIKrGszx6r2EjQqNLypdXMQu0QrujwZJ8k3+XQV4snmuJwwNakQoA2ILfq8w==",
"dependencies": {
"@types/jsonwebtoken": "8.5.8",
"jsonwebtoken": "8.5.1"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0"
}
},
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"dependencies": {
"@types/connect": "*",
"@types/node": "*"
}
},
"node_modules/@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/express": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz",
"integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==",
"dev": true,
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.18",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.31",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
"dev": true,
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"node_modules/@types/jsonwebtoken": {
"version": "8.5.8",
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.8.tgz",
"integrity": "sha512-zm6xBQpFDIDM6o9r6HSgDeIcLy82TKWctCXEPbJJcXb5AKmi5BNNdLXneixK4lplX3PqIVcwLBCGE/kAGnlD4A==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg=="
},
"node_modules/@types/passport": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.11.tgz",
"integrity": "sha512-pz1cx9ptZvozyGKKKIPLcVDVHwae4hrH5d6g5J+DkMRRjR3cVETb4jMabhXAUbg3Ov7T22nFHEgaK2jj+5CBpw==",
"dev": true,
"dependencies": {
"@types/express": "*"
}
},
"node_modules/@types/passport-jwt": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@types/passport-jwt/-/passport-jwt-3.0.7.tgz",
"integrity": "sha512-qRQ4qlww1Yhs3IaioDKrsDNmKy6gLDLgFsGwpCnc2YqWovO2Oxu9yCQdWHMJafQ7UIuOba4C4/TNXcGkQfEjlQ==",
"dev": true,
"dependencies": {
"@types/express": "*",
"@types/jsonwebtoken": "*",
"@types/passport-strategy": "*"
}
},
"node_modules/@types/passport-strategy": {
"version": "0.2.35",
"resolved": "https://registry.npmjs.org/@types/passport-strategy/-/passport-strategy-0.2.35.tgz",
"integrity": "sha512-o5D19Jy2XPFoX2rKApykY15et3Apgax00RRLf0RUotPDUsYrQa7x4howLYr9El2mlUApHmCMv5CZ1IXqKFQ2+g==",
"dev": true,
"dependencies": {
"@types/express": "*",
"@types/passport": "*"
}
},
"node_modules/@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"node_modules/@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"node_modules/@types/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==",
"dev": true,
"dependencies": {
"@types/mime": "*",
"@types/node": "*"
}
},
"node_modules/buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"node_modules/ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/iterare": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz",
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==",
"peer": true,
"engines": {
"node": ">=6"
}
},
"node_modules/jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"dependencies": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
},
"engines": {
"node": ">=4",
"npm": ">=1.4.28"
}
},
"node_modules/jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"dependencies": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"dependencies": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
},
"node_modules/lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
},
"node_modules/lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
},
"node_modules/lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
},
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
},
"node_modules/lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
},
"node_modules/lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/passport-jwt": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/passport-jwt/-/passport-jwt-4.0.0.tgz",
"integrity": "sha512-BwC0n2GP/1hMVjR4QpnvqA61TxenUMlmfNjYNgK0ZAs0HK4SOQkHcSv4L328blNTLtHq7DbmvyNJiH+bn6C5Mg==",
"dependencies": {
"jsonwebtoken": "^8.2.0",
"passport-strategy": "^1.0.0"
}
},
"node_modules/passport-strategy": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
"integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
"peer": true
},
"node_modules/rxjs": {
"version": "7.5.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz",
"integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==",
"peer": true,
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
"peer": true
},
"node_modules/uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"peer": true,
"bin": {
"uuid": "dist/bin/uuid"
}
}
},
"dependencies": {
"@nestjs/common": {
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-9.1.6.tgz",
"integrity": "sha512-9Ttk9va/BwEab36RSXLZdRoPUX3DZHUpzseKEfqHVhnaUIsIMt7lVd79GQ1FroQ2FZqoCwcLyBowevXhrE1Wnw==",
"peer": true,
"requires": {
"iterare": "1.2.1",
"tslib": "2.4.0",
"uuid": "9.0.0"
}
},
"@nestjs/jwt": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/jwt/-/jwt-9.0.0.tgz",
"integrity": "sha512-ZsXGY/wMYKzEhymw2+dxiwrHTRKIKrGszx6r2EjQqNLypdXMQu0QrujwZJ8k3+XQV4snmuJwwNakQoA2ILfq8w==",
"requires": {
"@types/jsonwebtoken": "8.5.8",
"jsonwebtoken": "8.5.1"
}
},
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"requires": {
"@types/connect": "*",
"@types/node": "*"
}
},
"@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/express": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz",
"integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==",
"dev": true,
"requires": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.18",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"@types/express-serve-static-core": {
"version": "4.17.31",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"@types/jsonwebtoken": {
"version": "8.5.8",
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.8.tgz",
"integrity": "sha512-zm6xBQpFDIDM6o9r6HSgDeIcLy82TKWctCXEPbJJcXb5AKmi5BNNdLXneixK4lplX3PqIVcwLBCGE/kAGnlD4A==",
"requires": {
"@types/node": "*"
}
},
"@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg=="
},
"@types/passport": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.11.tgz",
"integrity": "sha512-pz1cx9ptZvozyGKKKIPLcVDVHwae4hrH5d6g5J+DkMRRjR3cVETb4jMabhXAUbg3Ov7T22nFHEgaK2jj+5CBpw==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/passport-jwt": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@types/passport-jwt/-/passport-jwt-3.0.7.tgz",
"integrity": "sha512-qRQ4qlww1Yhs3IaioDKrsDNmKy6gLDLgFsGwpCnc2YqWovO2Oxu9yCQdWHMJafQ7UIuOba4C4/TNXcGkQfEjlQ==",
"dev": true,
"requires": {
"@types/express": "*",
"@types/jsonwebtoken": "*",
"@types/passport-strategy": "*"
}
},
"@types/passport-strategy": {
"version": "0.2.35",
"resolved": "https://registry.npmjs.org/@types/passport-strategy/-/passport-strategy-0.2.35.tgz",
"integrity": "sha512-o5D19Jy2XPFoX2rKApykY15et3Apgax00RRLf0RUotPDUsYrQa7x4howLYr9El2mlUApHmCMv5CZ1IXqKFQ2+g==",
"dev": true,
"requires": {
"@types/express": "*",
"@types/passport": "*"
}
},
"@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"@types/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==",
"dev": true,
"requires": {
"@types/mime": "*",
"@types/node": "*"
}
},
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"iterare": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz",
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==",
"peer": true
},
"jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"requires": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
}
},
"jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"requires": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
},
"lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
},
"lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
},
"lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
},
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
},
"lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
},
"lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"passport-jwt": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/passport-jwt/-/passport-jwt-4.0.0.tgz",
"integrity": "sha512-BwC0n2GP/1hMVjR4QpnvqA61TxenUMlmfNjYNgK0ZAs0HK4SOQkHcSv4L328blNTLtHq7DbmvyNJiH+bn6C5Mg==",
"requires": {
"jsonwebtoken": "^8.2.0",
"passport-strategy": "^1.0.0"
}
},
"passport-strategy": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
"integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA=="
},
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
"peer": true
},
"rxjs": {
"version": "7.5.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz",
"integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==",
"peer": true,
"requires": {
"tslib": "^2.1.0"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
"peer": true
},
"uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"peer": true
}
}
}

View File

@@ -1,9 +0,0 @@
{
"dependencies": {
"@nestjs/jwt": "^9.0.0",
"passport-jwt": "^4.0.0"
},
"devDependencies": {
"@types/passport-jwt": "^3.0.7"
}
}

View File

@@ -1,10 +1,17 @@
import { AuthenticationService } from './authentication.service'; import { AuthenticationService } from './authentication.service';
import { Response } from 'express'; import { Response } from 'express';
import { TwoFaDto } from './dto/2fa.dto';
import { UsersService } from 'src/users/users.service';
export declare class AuthenticationController { export declare class AuthenticationController {
private authService; private authService;
constructor(authService: AuthenticationService); private userService;
constructor(authService: AuthenticationService, userService: UsersService);
login(): void; login(): void;
redirect(response: Response): Promise<void>; redirect(response: Response, request: any): Promise<void>;
status(): string; status(): string;
logout(): string; logout(request: any): {
msg: string;
};
register(request: any, response: any): Promise<any>;
verify(request: any, { twoFaCode }: TwoFaDto): Promise<void>;
} }

View File

@@ -16,21 +16,41 @@ exports.AuthenticationController = void 0;
const common_1 = require("@nestjs/common"); const common_1 = require("@nestjs/common");
const _42guards_1 = require("./guards/42guards"); const _42guards_1 = require("./guards/42guards");
const authentication_service_1 = require("./authentication.service"); const authentication_service_1 = require("./authentication.service");
const _2fa_dto_1 = require("./dto/2fa.dto");
const users_service_1 = require("../../users/users.service");
let AuthenticationController = class AuthenticationController { let AuthenticationController = class AuthenticationController {
constructor(authService) { constructor(authService, userService) {
this.authService = authService; this.authService = authService;
this.userService = userService;
} }
login() { login() {
console.log('ON EST DANS LOGIN AUTH CONTROLLER');
return; return;
} }
async redirect(response) { async redirect(response, request) {
response.send(200); response.sendStatus(200);
} }
status() { status() {
return 'status'; return 'status';
} }
logout() { logout(request) {
return 'logout'; console.log('ON EST DANS LOGOUT AUTH CONTROLLER');
request.session.destroy();
return { msg: 'You are now logged out' };
}
async register(request, response) {
console.log('ON EST DANS REGISTER POUR 2FA AUTH CONTROLLER');
const { otpauth } = await this.authService.generate2FaSecret(request.user);
return this.authService.pipeQrCodeStream(response, otpauth);
}
async verify(request, { twoFaCode }) {
console.log('ON EST DANS VERIFY POUR 2FA AUTH CONTROLLER');
const isCodeIsValid = await this.authService.verify2FaCode(request.user, twoFaCode);
if (isCodeIsValid === false) {
request.session.destroy();
throw new common_1.UnauthorizedException('Wrong Code.');
}
await this.userService.enableTwoFactorAuth(request.user.id);
} }
}; };
__decorate([ __decorate([
@@ -44,8 +64,9 @@ __decorate([
(0, common_1.Get)('redirect'), (0, common_1.Get)('redirect'),
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard), (0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Res)()), __param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function), __metadata("design:type", Function),
__metadata("design:paramtypes", [Object]), __metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise) __metadata("design:returntype", Promise)
], AuthenticationController.prototype, "redirect", null); ], AuthenticationController.prototype, "redirect", null);
__decorate([ __decorate([
@@ -57,13 +78,33 @@ __decorate([
], AuthenticationController.prototype, "status", null); ], AuthenticationController.prototype, "status", null);
__decorate([ __decorate([
(0, common_1.Get)('logout'), (0, common_1.Get)('logout'),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function), __metadata("design:type", Function),
__metadata("design:paramtypes", []), __metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0) __metadata("design:returntype", void 0)
], AuthenticationController.prototype, "logout", null); ], AuthenticationController.prototype, "logout", null);
__decorate([
(0, common_1.Post)('2fa/generate'),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], AuthenticationController.prototype, "register", null);
__decorate([
(0, common_1.Post)('2fa/turn-on'),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, _2fa_dto_1.TwoFaDto]),
__metadata("design:returntype", Promise)
], AuthenticationController.prototype, "verify", null);
AuthenticationController = __decorate([ AuthenticationController = __decorate([
(0, common_1.Controller)('auth'), (0, common_1.Controller)('auth'),
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService]) __metadata("design:paramtypes", [authentication_service_1.AuthenticationService,
users_service_1.UsersService])
], AuthenticationController); ], AuthenticationController);
exports.AuthenticationController = AuthenticationController; exports.AuthenticationController = AuthenticationController;
//# sourceMappingURL=authentication.controller.js.map //# sourceMappingURL=authentication.controller.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,iDAAyE;AACzE,qEAAiE;AAK1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAAoB,WAAkC;QAAlC,gBAAW,GAAX,WAAW,CAAuB;IAEhD,CAAC;IAQP,KAAK;QACJ,OAAQ;IACT,CAAC;IASK,AAAN,KAAK,CAAC,QAAQ,CAAQ,QAAmB;QACxC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IASD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AApCA;IAAC,IAAA,YAAG,GAAE;IACL,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;qDAG5B;AASK;IAFL,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAEpB;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;sDAG5B;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AA7CW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,8CAAqB;GAF1C,wBAAwB,CA8CpC;AA9CY,4DAAwB"} {"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyG;AACzG,iDAAyE;AACzE,qEAAiE;AAEjE,4CAAyC;AACzC,6DAAuD;AAKhD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAAoB,WAAkC,EAC3C,WAAyB;QADhB,gBAAW,GAAX,WAAW,CAAuB;QAC3C,gBAAW,GAAX,WAAW,CAAc;IAE9B,CAAC;IAQP,KAAK;QACJ,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAQ;IACT,CAAC;IASK,AAAN,KAAK,CAAC,QAAQ,CAAQ,QAAmB,EAAS,OAAO;QACxD,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IASD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM,CAAQ,OAAO;QACpB,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;QACjD,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO,EAAC,GAAG,EAAG,wBAAwB,EAAC,CAAC;IACzC,CAAC;IAIK,AAAN,KAAK,CAAC,QAAQ,CAAQ,OAAO,EAAS,QAAQ;QAC7C,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;QAC5D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CAAQ,OAAO,EAAU,EAAC,SAAS,EAAY;QAC1D,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAA;QAC1D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpF,IAAI,aAAa,KAAK,KAAK,EAC3B;YACC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1B,MAAM,IAAI,8BAAqB,CAAC,aAAa,CAAC,CAAC;SAC/C;QACD,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE7D,CAAC;CACD,CAAA;AA7DA;IAAC,IAAA,YAAG,GAAE;IACL,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;qDAI5B;AASK;IAFL,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAEhD;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;sDAG5B;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;;;sDAIZ;AAIK;IAFL,IAAA,aAAI,EAAC,cAAc,CAAC;IACpB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAIpC;AAIK;IAFL,IAAA,aAAI,EAAC,aAAa,CAAC;IACnB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACf,WAAA,IAAA,YAAG,GAAE,CAAA;IAAW,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAe,mBAAQ;;sDAU1D;AAvEW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,8CAAqB;QAC9B,4BAAY;GAHxB,wBAAwB,CAwEpC;AAxEY,4DAAwB"}

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAGxC,6CAAgD;AAChD,mFAAuE;AACvE,kEAAsD;AACtD,2DAAqD;AACrD,6DAAuD;AACvD,2EAAuE;AACvE,qEAAiE;AACjE,uDAAyD;AAEzD,mDAAuD;AAmBhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAjBhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,CAAC,CAAC,EAAE,0BAAW;SASpE;QACC,SAAS,EAAE,CAAC,8CAAqB,EAAE,8BAAgB,EAAE,4BAAY,EAAE,8BAAiB;SAEtF;QACE,OAAO,EAAE,CAAC,8CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,oDAAwB,CAAC;KACzC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"} {"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,mFAAuE;AACvE,kEAAsD;AACtD,2DAAqD;AACrD,6DAAuD;AACvD,2EAAuE;AACvE,qEAAiE;AACjE,uDAAyD;AACzD,mDAAuD;AAmBhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAjBhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,CAAC,CAAC,EAAE,0BAAW;SASpE;QACC,SAAS,EAAE,CAAC,8CAAqB,EAAE,8BAAgB,EAAE,4BAAY,EAAE,8BAAiB;SAEtF;QACE,OAAO,EAAE,CAAC,8CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,oDAAwB,CAAC;KACzC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}

View File

@@ -6,4 +6,10 @@ export declare class AuthenticationService {
constructor(userService: UsersService); constructor(userService: UsersService);
validateUser(createUsersDto: CreateUsersDto): Promise<User>; validateUser(createUsersDto: CreateUsersDto): Promise<User>;
findUser(fourtytwo_id: string): Promise<User | undefined>; findUser(fourtytwo_id: string): Promise<User | undefined>;
verify2FaCode(user: User, code: string): Promise<boolean>;
generate2FaSecret(user: User): Promise<{
secret: string;
otpauth: string;
}>;
pipeQrCodeStream(stream: Response, otpauthUrl: string): Promise<any>;
} }

View File

@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthenticationService = void 0; exports.AuthenticationService = void 0;
const common_1 = require("@nestjs/common"); const common_1 = require("@nestjs/common");
const users_service_1 = require("../../users/users.service"); const users_service_1 = require("../../users/users.service");
const qrcode_1 = require("qrcode");
const otplib_1 = require("otplib");
let AuthenticationService = class AuthenticationService { let AuthenticationService = class AuthenticationService {
constructor(userService) { constructor(userService) {
this.userService = userService; this.userService = userService;
@@ -26,6 +28,18 @@ let AuthenticationService = class AuthenticationService {
async findUser(fourtytwo_id) { async findUser(fourtytwo_id) {
return await this.userService.findOneByFourtyTwoId(fourtytwo_id); return await this.userService.findOneByFourtyTwoId(fourtytwo_id);
} }
async verify2FaCode(user, code) {
return otplib_1.authenticator.verify({ token: code, secret: user.secretTwoFactorAuth });
}
async generate2FaSecret(user) {
const secret = otplib_1.authenticator.generateSecret();
const otpauth = otplib_1.authenticator.keyuri(user.email, process.env.TWO_FACTOR_AUTHENTICATION_APP_NAME, secret);
await this.userService.setAuthenticatorSecret(user.id, secret);
return { secret, otpauth };
}
async pipeQrCodeStream(stream, otpauthUrl) {
return (0, qrcode_1.toFileStream)(stream, otpauthUrl);
}
}; };
AuthenticationService = __decorate([ AuthenticationService = __decorate([
(0, common_1.Injectable)(), (0, common_1.Injectable)(),

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6DAAuD;AAIhD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACjC,YACmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IAExC,CAAC;IAEL,KAAK,CAAC,YAAY,CAAC,cAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpF,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAqB;QACnC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;CAMD,CAAA;AAtBY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGoB,4BAAY;GAFhC,qBAAqB,CAsBjC;AAtBY,sDAAqB"} {"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6DAAuD;AACvD,mCAAsC;AACtC,mCAAuC;AAGhC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACjC,YACmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IACxC,CAAC;IAEL,KAAK,CAAC,YAAY,CAAC,cAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpF,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAqB;QACnC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAW,EAAE,IAAa;QAC7C,OAAO,sBAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAW;QAClC,MAAM,MAAM,GAAG,sBAAa,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,sBAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;QACzG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,MAAiB,EAAE,UAAmB;QAC5D,OAAO,IAAA,qBAAY,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;CAED,CAAA;AAhCY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGoB,4BAAY;GAFhC,qBAAqB,CAgCjC;AAhCY,sDAAqB"}

View File

@@ -0,0 +1,3 @@
export declare class TwoFaDto {
readonly twoFaCode: string;
}

View File

@@ -0,0 +1,21 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TwoFaDto = void 0;
const class_validator_1 = require("class-validator");
class TwoFaDto {
}
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], TwoFaDto.prototype, "twoFaCode", void 0);
exports.TwoFaDto = TwoFaDto;
//# sourceMappingURL=2fa.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"2fa.dto.js","sourceRoot":"","sources":["../../../../src/auth/42/dto/2fa.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AAEpD,MAAa,QAAQ;CAGpB;AAFA;IAAC,IAAA,0BAAQ,GAAE;;2CACgB;AAF5B,4BAGC"}

View File

@@ -0,0 +1,3 @@
export declare class TwoFaDto {
readonly twoFaCode: string;
}

View File

@@ -0,0 +1,21 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TwoFaDto = void 0;
const class_validator_1 = require("class-validator");
class TwoFaDto {
}
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], TwoFaDto.prototype, "twoFaCode", void 0);
exports.TwoFaDto = TwoFaDto;
//# sourceMappingURL=2faDto.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"2faDto.dto.js","sourceRoot":"","sources":["../../../../src/auth/42/dto/2faDto.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2C;AAE3C,MAAa,QAAQ;CAGpB;AAFA;IAAC,IAAA,0BAAQ,GAAE;;2CACgB;AAF5B,4BAGC"}

View File

@@ -27,11 +27,14 @@ let FortyTwoStrategy = class FortyTwoStrategy extends (0, passport_1.PassportStr
async validate(accessToken, refreshToken, profile, callbackURL) { async validate(accessToken, refreshToken, profile, callbackURL) {
console.log("Validate inside strategy.ts"); console.log("Validate inside strategy.ts");
console.log(profile.id, profile.username, profile.phoneNumbers[0].value, profile.emails[0].value, profile.photos[0].value); console.log(profile.id, profile.username, profile.phoneNumbers[0].value, profile.emails[0].value, profile.photos[0].value);
const userDTO = { fortyTwoId: profile.id, username: profile.username, email: profile.emails[0].value, image_url: profile.photos[0].value }; const userDTO = { fortyTwoId: profile.id, username: profile.username, email: profile.emails[0].value, image_url: profile.photos[0].value, isEnabledTwoFactorAuth: false };
const user = await this.authenticationService.validateUser(userDTO); const user = await this.authenticationService.validateUser(userDTO);
if (!user) if (!user)
throw new common_1.UnauthorizedException(); throw new common_1.UnauthorizedException();
return user; if (!user.isEnabledTwoFactorAuth)
return user;
if (userDTO.isEnabledTwoFactorAuth)
return user;
} }
}; };
FortyTwoStrategy = __decorate([ FortyTwoStrategy = __decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"42strategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/42strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AACnE,sEAAkE;AAI3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,cAAQ,EAAE,IAAI,CAAC;IACrE,YAAoB,qBAA4C;QAChE,KAAK,CAAC;YACJ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAChD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QANiB,0BAAqB,GAArB,qBAAqB,CAAuB;IAO/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB,EAAE,WAAmB;QAChG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3H,MAAM,OAAO,GAAoB,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAC5J,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACX,CAAC;CACF,CAAA;AAnBY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE+B,8CAAqB;GADpD,gBAAgB,CAmB5B;AAnBY,4CAAgB"} {"version":3,"file":"42strategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/42strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AACnE,sEAAkE;AAI3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,cAAQ,EAAE,IAAI,CAAC;IACrE,YAAoB,qBAA4C;QAChE,KAAK,CAAC;YACJ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAChD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QANiB,0BAAqB,GAArB,qBAAqB,CAAuB;IAO/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB,EAAE,WAAmB;QAChG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3H,MAAM,OAAO,GAAoB,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;QAC3L,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,sBAAsB;YAC/B,OAAO,IAAI,CAAC;QACb,IAAI,OAAO,CAAC,sBAAsB;YACjC,OAAO,IAAI,CAAC;IACZ,CAAC;CACF,CAAA;AAtBY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE+B,8CAAqB;GADpD,gBAAgB,CAsB5B;AAtBY,4CAAgB"}

View File

@@ -6,7 +6,7 @@ export declare class FriendshipController {
constructor(friendshipService: FriendshipService); constructor(friendshipService: FriendshipService);
findEmpty(req: any): Promise<import("./entities/friendship.entity").Friendship[]>; findEmpty(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
findOneFriend(relationshipId: string, req: any): Promise<import("./entities/friendship.entity").Friendship[]>; findOneFriend(relationshipId: string, req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
create(createFriendshipDto: CreateFriendshipDto, req: any): HttpException | Promise<import("./entities/friendship.entity").Friendship>; create(createFriendshipDto: CreateFriendshipDto, req: any): Promise<import("./entities/friendship.entity").Friendship> | HttpException;
update(relationshipId: string, status: string, req: any): Promise<import("./entities/friendship.entity").Friendship>; update(relationshipId: string, status: string, req: any): Promise<import("./entities/friendship.entity").Friendship>;
remove(relationshipId: string): Promise<import("./entities/friendship.entity").Friendship>; remove(relationshipId: string): Promise<import("./entities/friendship.entity").Friendship>;
findAllBlocked(req: any): Promise<import("./entities/friendship.entity").Friendship[]>; findAllBlocked(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;

View File

@@ -1 +1 @@
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+I;AAC/I,0DAAgE;AAEhE,uEAAkE;AAGlE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;IAKtE,SAAS,CAAQ,GAAG;QACnB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IAKD,aAAa,CAA0B,cAAsB,EAAS,GAAG;QACxE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAMD,MAAM,CAAS,mBAAwC,EAAS,GAAG;QAClE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,EAAE,iBAAiB,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,WAAW;YAC/C,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACjE,OAAO,IAAI,sBAAa,CAAC,iDAAiD,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;IACnG,CAAC;IAKD,MAAM,CAA0B,cAAsB,EAAmB,MAAe,EAAS,GAAG;QAEnG,MAAM,IAAI,GAAU,GAAG,CAAC,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9E,CAAC;IAKD,MAAM,CAA0B,cAAsB;QACrD,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAMD,cAAc,CAAQ,GAAG;QACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IAKD,iCAAiC,CAAQ,GAAG;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAKD,gCAAgC,CAAQ,GAAG;QAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;CACD,CAAA;AAnEA;IAAC,IAAA,YAAG,EAAC,WAAW,CAAC;IAChB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IAClB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;qDAGf;AAGD;IAAC,IAAA,YAAG,EAAC,2BAA2B,CAAC;IAChC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACd,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;IAA0B,WAAA,IAAA,YAAG,GAAE,CAAA;;;;yDAGpE;AAGD;IAAC,IAAA,aAAI,EAAC,WAAW,CAAC;IACjB,IAAA,iBAAQ,EAAC,mBAAU,CAAC,OAAO,CAAC;IAC5B,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;IAA4C,WAAA,IAAA,YAAG,GAAE,CAAA;;qCAA3B,2CAAmB;;kDAMtD;AAGD;IAAC,IAAA,cAAK,EAAC,2BAA2B,CAAC;IAClC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;IAA0B,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IAAmB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kDAI/F;AAGD;IAAC,IAAA,eAAM,EAAC,2BAA2B,CAAC;IACnC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;;;;kDAE9B;AAID;IAAC,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;;;;0DAGpB;AAGD;IAAC,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACM,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6EAGvC;AAGD;IAAC,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACK,WAAA,IAAA,YAAG,GAAE,CAAA;;;;4EAGtC;AAtEW,oBAAoB;IADhC,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAE2B,sCAAiB;GADrD,oBAAoB,CAuEhC;AAvEY,oDAAoB"} {"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+I;AAC/I,0DAAgE;AAEhE,uEAAkE;AAClE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;IAKtE,SAAS,CAAQ,GAAG;QACnB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IAKD,aAAa,CAA0B,cAAsB,EAAS,GAAG;QACxE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAMD,MAAM,CAAS,mBAAwC,EAAS,GAAG;QAClE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,EAAE,iBAAiB,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,WAAW;YAC/C,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACjE,OAAO,IAAI,sBAAa,CAAC,iDAAiD,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;IACnG,CAAC;IAKD,MAAM,CAA0B,cAAsB,EAAmB,MAAe,EAAS,GAAG;QAEnG,MAAM,IAAI,GAAU,GAAG,CAAC,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9E,CAAC;IAKD,MAAM,CAA0B,cAAsB;QACrD,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAMD,cAAc,CAAQ,GAAG;QACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IAKD,iCAAiC,CAAQ,GAAG;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAKD,gCAAgC,CAAQ,GAAG;QAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;CACD,CAAA;AAnEA;IAAC,IAAA,YAAG,EAAC,WAAW,CAAC;IAChB,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IAClB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;qDAGf;AAGD;IAAC,IAAA,YAAG,EAAC,2BAA2B,CAAC;IAChC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACd,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;IAA0B,WAAA,IAAA,YAAG,GAAE,CAAA;;;;yDAGpE;AAGD;IAAC,IAAA,aAAI,EAAC,WAAW,CAAC;IACjB,IAAA,iBAAQ,EAAC,mBAAU,CAAC,OAAO,CAAC;IAC5B,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;IAA4C,WAAA,IAAA,YAAG,GAAE,CAAA;;qCAA3B,2CAAmB;;kDAMtD;AAGD;IAAC,IAAA,cAAK,EAAC,2BAA2B,CAAC;IAClC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;IAA0B,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IAAmB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kDAI/F;AAGD;IAAC,IAAA,eAAM,EAAC,2BAA2B,CAAC;IACnC,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACrB,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;;;;kDAE9B;AAID;IAAC,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;;;;0DAGpB;AAGD;IAAC,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACM,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6EAGvC;AAGD;IAAC,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACK,WAAA,IAAA,YAAG,GAAE,CAAA;;;;4EAGtC;AAtEW,oBAAoB;IADhC,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAE2B,sCAAiB;GADrD,oBAAoB,CAuEhC;AAvEY,oDAAoB"}

File diff suppressed because one or more lines are too long

View File

@@ -3,4 +3,5 @@ export declare class CreateUsersDto {
readonly fortyTwoId: string; readonly fortyTwoId: string;
readonly email: string; readonly email: string;
readonly image_url: string; readonly image_url: string;
readonly isEnabledTwoFactorAuth: boolean;
} }

View File

@@ -29,5 +29,10 @@ __decorate([
(0, class_validator_1.IsString)(), (0, class_validator_1.IsString)(),
__metadata("design:type", String) __metadata("design:type", String)
], CreateUsersDto.prototype, "image_url", void 0); ], CreateUsersDto.prototype, "image_url", void 0);
__decorate([
(0, class_validator_1.IsBoolean)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], CreateUsersDto.prototype, "isEnabledTwoFactorAuth", void 0);
exports.CreateUsersDto = CreateUsersDto; exports.CreateUsersDto = CreateUsersDto;
//# sourceMappingURL=create-users.dto.js.map //# sourceMappingURL=create-users.dto.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AAGpD,MAAa,cAAc;CAS1B;AARA;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;kDACiB;AAC5B;IAAC,IAAA,yBAAO,GAAE;;6CACa;AACvB;IAAC,IAAA,0BAAQ,GAAE;;iDACgB;AAR5B,wCASC"} {"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2E;AAG3E,MAAa,cAAc;CAY1B;AAXA;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;kDACiB;AAC5B;IAAC,IAAA,yBAAO,GAAE;;6CACa;AACvB;IAAC,IAAA,0BAAQ,GAAE;;iDACgB;AAC3B;IAAC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;8DAC4B;AAX1C,wCAYC"}

View File

@@ -7,6 +7,8 @@ export declare class User {
image_url: string; image_url: string;
phone: string; phone: string;
status: [string]; status: [string];
isEnabledTwoFactorAuth: boolean;
secretTwoFactorAuth: string;
requesterId: Friendship[]; requesterId: Friendship[];
addresseeId: Friendship[]; addresseeId: Friendship[];
} }

View File

@@ -44,6 +44,14 @@ __decorate([
(0, typeorm_1.Column)('json', { nullable: true }), (0, typeorm_1.Column)('json', { nullable: true }),
__metadata("design:type", Array) __metadata("design:type", Array)
], User.prototype, "status", void 0); ], User.prototype, "status", void 0);
__decorate([
(0, typeorm_1.Column)({ default: false, nullable: true }),
__metadata("design:type", Boolean)
], User.prototype, "isEnabledTwoFactorAuth", void 0);
__decorate([
(0, typeorm_1.Column)({ nullable: true }),
__metadata("design:type", String)
], User.prototype, "secretTwoFactorAuth", void 0);
__decorate([ __decorate([
(0, typeorm_1.JoinTable)(), (0, typeorm_1.JoinTable)(),
(0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.requesterId), (0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.requesterId),

View File

@@ -1 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAkD;AAClD,qCAA2G;AAC3G,mFAAyE;AAKlE,IAAM,IAAI,GAAV,MAAM,IAAI;CA+BhB,CAAA;AA7BA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,EAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;;wCACJ;AAEnB;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAO,GAAE;;mCACI;AAEd;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACR;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mCACb;AAEd;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AA9Bd,IAAI;IAFhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,gBAAM,EAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GACjB,IAAI,CA+BhB;AA/BY,oBAAI"} {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAkD;AAClD,qCAA2G;AAC3G,mFAAyE;AAKlE,IAAM,IAAI,GAAV,MAAM,IAAI;CAqChB,CAAA;AAnCA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,EAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;;wCACJ;AAEnB;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAO,GAAE;;mCACI;AAEd;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACR;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mCACb;AAEd;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACX;AAEhC;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACC;AAE5B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AApCd,IAAI;IAFhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,gBAAM,EAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GACjB,IAAI,CAqChB;AArCY,oBAAI"}

View File

@@ -14,4 +14,6 @@ export declare class UsersService {
create(createUserDto: CreateUsersDto): Promise<User>; create(createUserDto: CreateUsersDto): Promise<User>;
update(id: string, updateUserDto: UpdateUsersDto): Promise<User>; update(id: string, updateUserDto: UpdateUsersDto): Promise<User>;
remove(id: string): Promise<User>; remove(id: string): Promise<User>;
enableTwoFactorAuth(id: string): Promise<import("typeorm").UpdateResult>;
setAuthenticatorSecret(id: number, secret: string): Promise<import("typeorm").UpdateResult>;
} }

View File

@@ -66,6 +66,12 @@ let UsersService = class UsersService {
throw new common_1.HttpException(`The user could not be deleted.`, common_1.HttpStatus.NOT_FOUND); throw new common_1.HttpException(`The user could not be deleted.`, common_1.HttpStatus.NOT_FOUND);
return this.userRepository.remove(user); return this.userRepository.remove(user);
} }
async enableTwoFactorAuth(id) {
return this.userRepository.update(id, { isEnabledTwoFactorAuth: true });
}
async setAuthenticatorSecret(id, secret) {
return this.userRepository.update(id, { secretTwoFactorAuth: secret });
}
}; };
UsersService = __decorate([ UsersService = __decorate([
(0, common_1.Injectable)(), (0, common_1.Injectable)(),

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsG;AACtG,6CAAmD;AAEnD,wDAA8C;AAC9C,qCAA8D;AAG9D,gFAAsE;AAO/D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAExB,YAEiB,cAAgC,EAEhC,oBAA4C;QAF5C,mBAAc,GAAd,cAAc,CAAkB;QAEhC,yBAAoB,GAApB,oBAAoB,CAAwB;IAC1D,CAAC;IAEJ,KAAK,CAAC,oBAAoB,CAAC,WAAmB;QAC7C,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,EACT;YACC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,0BAAiB,CAAC,+BAA+B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC;IAGD,OAAO,CAAC,eAAoC;QAC3C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,KAAK;SACX,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,aAA6B;QACzC,IAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,UAAU,EAAE,aAAa,CAAC,UAAU,EAAC,CAAC;YAC9E,MAAM,IAAI,sBAAa,CAAC,0BAA0B,EAAC,mBAAU,CAAC,QAAQ,CAAC,CAAC;QACzE,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,aAA6B;QACrD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,aAAa,EAAE,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,iBAC5C,EAAE,EAAE,CAAC,EAAE,IACL,aAAa,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACD,CAAA;AA7DY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAIX,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IAEtB,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;qCADI,oBAAU;QAEJ,oBAAU;GANrC,YAAY,CA6DxB;AA7DY,oCAAY"} {"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsG;AACtG,6CAAmD;AAEnD,wDAA8C;AAC9C,qCAA8D;AAG9D,gFAAsE;AAO/D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAExB,YAEiB,cAAgC,EAEhC,oBAA4C;QAF5C,mBAAc,GAAd,cAAc,CAAkB;QAEhC,yBAAoB,GAApB,oBAAoB,CAAwB;IAC1D,CAAC;IAEJ,KAAK,CAAC,oBAAoB,CAAC,WAAmB;QAC7C,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,EACT;YACC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,0BAAiB,CAAC,+BAA+B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC;IAGD,OAAO,CAAC,eAAoC;QAC3C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,KAAK;SACX,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,aAA6B;QACzC,IAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,UAAU,EAAE,aAAa,CAAC,UAAU,EAAC,CAAC;YAC9E,MAAM,IAAI,sBAAa,CAAC,0BAA0B,EAAC,mBAAU,CAAC,QAAQ,CAAC,CAAC;QACzE,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,aAA6B;QACrD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,aAAa,EAAE,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,iBAC5C,EAAE,EAAE,CAAC,EAAE,IACL,aAAa,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,EAAU;QACnC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,EAAC,sBAAsB,EAAE,IAAI,EAAC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,EAAU,EAAE,MAAc;QACtD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,EAAC,mBAAmB,EAAE,MAAM,EAAC,CAAC,CAAC;IACtE,CAAC;CACD,CAAA;AArEY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAIX,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IAEtB,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;qCADI,oBAAU;QAEJ,oBAAU;GANrC,YAAY,CAqExB;AArEY,oCAAY"}

View File

@@ -0,0 +1 @@
../qrcode/bin/qrcode

View File

@@ -1877,6 +1877,48 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/@otplib/core": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/core/-/core-12.0.1.tgz",
"integrity": "sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA=="
},
"node_modules/@otplib/plugin-crypto": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/plugin-crypto/-/plugin-crypto-12.0.1.tgz",
"integrity": "sha512-qPuhN3QrT7ZZLcLCyKOSNhuijUi9G5guMRVrxq63r9YNOxxQjPm59gVxLM+7xGnHnM6cimY57tuKsjK7y9LM1g==",
"dependencies": {
"@otplib/core": "^12.0.1"
}
},
"node_modules/@otplib/plugin-thirty-two": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/plugin-thirty-two/-/plugin-thirty-two-12.0.1.tgz",
"integrity": "sha512-MtT+uqRso909UkbrrYpJ6XFjj9D+x2Py7KjTO9JDPhL0bJUYVu5kFP4TFZW4NFAywrAtFRxOVY261u0qwb93gA==",
"dependencies": {
"@otplib/core": "^12.0.1",
"thirty-two": "^1.0.2"
}
},
"node_modules/@otplib/preset-default": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/preset-default/-/preset-default-12.0.1.tgz",
"integrity": "sha512-xf1v9oOJRyXfluBhMdpOkr+bsE+Irt+0D5uHtvg6x1eosfmHCsCC6ej/m7FXiWqdo0+ZUI6xSKDhJwc8yfiOPQ==",
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/plugin-crypto": "^12.0.1",
"@otplib/plugin-thirty-two": "^12.0.1"
}
},
"node_modules/@otplib/preset-v11": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/preset-v11/-/preset-v11-12.0.1.tgz",
"integrity": "sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg==",
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/plugin-crypto": "^12.0.1",
"@otplib/plugin-thirty-two": "^12.0.1"
}
},
"node_modules/@redis/bloom": { "node_modules/@redis/bloom": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.1.0.tgz",
@@ -3221,7 +3263,6 @@
"version": "5.3.1", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
@@ -3696,6 +3737,14 @@
} }
} }
}, },
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/dedent": { "node_modules/dedent": {
"version": "0.7.0", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
@@ -3792,6 +3841,11 @@
"node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
} }
}, },
"node_modules/dijkstrajs": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.2.tgz",
"integrity": "sha512-QV6PMaHTCNmKSeP6QoXhVTw9snc9VD8MulTT0Bd99Pacp4SS1cjcrYPgBPmibqKVtMJJfqC6XvOXgPMEEPH/fg=="
},
"node_modules/dir-glob": { "node_modules/dir-glob": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -3868,6 +3922,11 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
}, },
"node_modules/encode-utf8": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz",
"integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw=="
},
"node_modules/encodeurl": { "node_modules/encodeurl": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@@ -6935,6 +6994,16 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/otplib": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/otplib/-/otplib-12.0.1.tgz",
"integrity": "sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg==",
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/preset-default": "^12.0.1",
"@otplib/preset-v11": "^12.0.1"
}
},
"node_modules/p-limit": { "node_modules/p-limit": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
@@ -6969,7 +7038,6 @@
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
@@ -7114,7 +7182,6 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"engines": { "engines": {
"node": ">=8" "node": ">=8"
} }
@@ -7335,6 +7402,14 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/postgres-array": { "node_modules/postgres-array": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
@@ -7482,6 +7557,132 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/qrcode": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.1.tgz",
"integrity": "sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==",
"dependencies": {
"dijkstrajs": "^1.0.1",
"encode-utf8": "^1.0.3",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"bin": {
"qrcode": "bin/qrcode"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/qrcode/node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/qrcode/node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/qrcode/node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"node_modules/qrcode/node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/qs": { "node_modules/qs": {
"version": "6.10.3", "version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
@@ -7651,6 +7852,11 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"node_modules/resolve": { "node_modules/resolve": {
"version": "1.22.1", "version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
@@ -7941,6 +8147,11 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw=="
},
"node_modules/setprototypeof": { "node_modules/setprototypeof": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
@@ -8453,6 +8664,14 @@
"node": ">=0.8" "node": ">=0.8"
} }
}, },
"node_modules/thirty-two": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz",
"integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==",
"engines": {
"node": ">=0.2.6"
}
},
"node_modules/through": { "node_modules/through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@@ -9197,6 +9416,11 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q=="
},
"node_modules/windows-release": { "node_modules/windows-release": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/windows-release/-/windows-release-4.0.0.tgz", "resolved": "https://registry.npmjs.org/windows-release/-/windows-release-4.0.0.tgz",

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,131 @@
# @otplib/core
> Provides core methods for hotp, totp and authenticator.
<!-- TOC depthFrom:2 -->
- [Getting Started](#getting-started)
- [Install the Package](#install-the-package)
- [Choose Your Plugins](#choose-your-plugins)
- [Adding Crypto](#adding-crypto)
- [Adding Base32](#adding-base32)
- [Initialise your Instance](#initialise-your-instance)
- [Using Classes](#using-classes)
- [Using Functions](#using-functions)
- [Available Options](#available-options)
- [License](#license)
<!-- /TOC -->
## Getting Started
This is the full setup guide for installing, configuring and customising
your dependencies for the library.
> Check out the [Quick Start Guide][docs-quick-start] instead for easier
> setup especially if you do not need to use any custom base32 / crypto libraries.
### Install the Package
```bash
npm install @otplib/core
```
### Choose Your Plugins
#### Adding Crypto
The crypto modules are used to generate the digest used to derive the OTP tokens from.
By default, Node.js has inbuilt `crypto` functionality, but you might want to replace it
for certain environments that do not support it.
Currently there are a few crypto plugins available from this project.
Install one of them. eg: `npm install @otplib/plugin-crypto`
Refer to the [crypto plugins list][docs-plugins-crypto],
or search for [otplib-plugin crypto][link-npm-search-crypto] on `npm`.
#### Adding Base32
If you're using `Google Authenticator`, you'll need a base32 module for
encoding and decoding your secrets.
Currently, there are a few base32 plugins available from this project.
Install one of them. eg: `npm install @otplib/plugin-thirty-two`
Refer to the [base32 plugin list][docs-plugins-base32],
or search for [otplib-plugin base32][link-npm-search-base32] on `npm`.
### Initialise your Instance
#### Using Classes
```js
import { HOTP, TOTP, Authenticator } from '@otplib/core';
import { keyDecoder, keyEncoder } from '@otplib/plugin-thirty-two'; // use your chosen base32 plugin
import { createDigest, createRandomBytes } from '@otplib/plugin-crypto'; // use your chosen crypto plugin
// Setup an OTP instance which you need
const hotp = new HOTP({ createDigest });
const totp = new TOTP({ createDigest });
const authenticator = new Authenticator({
createDigest,
createRandomBytes,
keyDecoder,
keyEncoder
});
// Go forth and generate tokens
const token = hotp.generate(YOUR_SECRET, 0);
const token = totp.generate(YOUR_SECRET);
const token = authenticator.generate(YOUR_SECRET);
```
#### Using Functions
Alternatively, if you are using the functions directly instead of the classes,
pass these as options into the functions.
```js
import {
hotpOptions,
hotpToken,
totpOptions,
totpToken,
authenticatorOptions,
authenticatorToken
} from 'otplib/core';
// As with classes, import your desired Base32 Plugin and Crypto Plugin.
// import ...
// Go forth and generate tokens
const token = hotpToken(YOUR_SECRET, 0, hotpOptions({ createDigest }));
const token = totpToken(YOUR_SECRET, totpOptions({ createDigest }));
const token = authenticatorToken(
YOUR_SECRET,
authenticatorOptions({
createDigest,
createRandomBytes,
keyDecoder,
keyEncoder
})
);
```
## Available Options
Please refer to the [Options Guide][docs-options].
## License
`@otplib/core` is [MIT licensed][project-license]
[link-npm-search-base32]: https://www.npmjs.com/search?q=otplib-plugin%20base32
[link-npm-search-crypto]: https://www.npmjs.com/search?q=otplib-plugin%20crypto
[docs-options]: https://github.com/yeojz/otplib/blob/master/README.md#available-options
[docs-plugins-base32]: https://github.com/yeojz/otplib/blob/master/packages/README.md#plugins---base32
[docs-plugins-crypto]: https://github.com/yeojz/otplib/blob/master/packages/README.md#plugins---crypto
[docs-quick-start]: https://github.com/yeojz/otplib/blob/master/README.md#quick-start
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE

View File

@@ -0,0 +1,145 @@
import { KeyEncodings, SecretKey } from './utils';
import { TOTP, TOTPOptions } from './totp';
/**
* RFC4648 / RFC3548 Base32 String.
*
* Other Base32 encoding methods like Crockford's Base32
* will not be compatible with Google Authenticator.
*/
export declare type Base32SecretKey = SecretKey;
/**
* Interface method for [[AuthenticatorOptions.keyEncoder]].
*/
export interface KeyEncoder<T = Base32SecretKey> {
(secret: SecretKey, encoding: KeyEncodings): T;
}
/**
* Interface method for [[AuthenticatorOptions.keyDecoder]].
*/
export interface KeyDecoder<T = SecretKey> {
(encodedSecret: Base32SecretKey, encoding: KeyEncodings): T;
}
/**
* Interface method for [[AuthenticatorOptions.createRandomBytes]].
*/
export interface CreateRandomBytes<T = string> {
(size: number, encoding: KeyEncodings): T;
}
/**
* Interface for options used in Authenticator.
*
* Contains additional options in addition to
* those within TOTP.
*/
export interface AuthenticatorOptions<T = string> extends TOTPOptions<T> {
/**
* Encodes a secret key into a Base32 string before it is
* sent to the user (in QR Code etc).
*/
keyEncoder: KeyEncoder<T>;
/**
* Decodes the Base32 string given by the user into a secret.
* */
keyDecoder: KeyDecoder<T>;
/**
* Creates a random string containing the defined number of
* bytes to be used in generating a secret key.
*/
createRandomBytes: CreateRandomBytes<T>;
}
/**
* Validates the given [[AuthenticatorOptions]].
*/
export declare function authenticatorOptionValidator<T extends AuthenticatorOptions<unknown> = AuthenticatorOptions<unknown>>(options: Partial<T>): void;
/**
* Returns a set of default options for authenticator at the current epoch.
*/
export declare function authenticatorDefaultOptions<T extends AuthenticatorOptions<unknown> = AuthenticatorOptions<unknown>>(): Partial<T>;
/**
* Takes an Authenticator Option object and provides presets for
* some of the missing required Authenticator option fields and validates
* the resultant options.
*/
export declare function authenticatorOptions<T extends AuthenticatorOptions<unknown> = AuthenticatorOptions<unknown>>(opt: Partial<T>): Readonly<T>;
/**
* Encodes a given secret key into a Base32 secret
* using a [[KeyEncoder]] method set in the options.
*
* @param secret - The [[SecretKey]] to encode into a [[Base32SecretKey]]
* @param options - An [[AuthenticatorOptions]] object
*/
export declare function authenticatorEncoder<T extends AuthenticatorOptions<unknown> = AuthenticatorOptions<unknown>>(secret: SecretKey, options: Pick<T, 'keyEncoder' | 'encoding'>): ReturnType<T['keyEncoder']>;
/**
* Decodes a given Base32 secret to a secret key
* using a [[KeyDecoder]] method set in the options.
*
* @param secret - The [[Base32SecretKey]] to decode
* @param options - An [[AuthenticatorOptions]] object
*/
export declare function authenticatorDecoder<T extends AuthenticatorOptions<unknown> = AuthenticatorOptions<unknown>>(secret: Base32SecretKey, options: Pick<T, 'keyDecoder' | 'encoding'>): ReturnType<T['keyDecoder']>;
/**
* Generates a random Base32 Secret Key.
*
* @param numberOfBytes - Number of bytes per secret key
* @param options.createRandomBytes
* @param options.encoding
* @param options.keyEncoder
*/
export declare function authenticatorGenerateSecret<T extends AuthenticatorOptions = AuthenticatorOptions>(numberOfBytes: number, options: Pick<T, 'keyEncoder' | 'encoding' | 'createRandomBytes'>): Base32SecretKey;
/**
* Generates the Authenticator based token.
*
* tl;dr: Authenticator = TOTP + Base32 Secret
*
* **References**
*
* - https://en.wikipedia.org/wiki/Google_Authenticator
*
* @param secret - [[Base32SecretKey]]
* @param options - An [[AuthenticatorOptions]] object.
*/
export declare function authenticatorToken<T extends AuthenticatorOptions = AuthenticatorOptions>(secret: Base32SecretKey, options: Readonly<T>): string;
/**
* Decodes the encodedSecret and passes it to [[totpCheckWithWindow]]
*
* @param token - The token to check
* @param secret - The [[Base32SecretKey]]
* @param options - An [[AuthenticatorOptions]] object.
*/
export declare function authenticatorCheckWithWindow<T extends AuthenticatorOptions = AuthenticatorOptions>(token: string, secret: Base32SecretKey, options: Readonly<T>): number | null;
/**
* A class wrapper containing all Authenticator methods.
*/
export declare class Authenticator<T extends AuthenticatorOptions<string> = AuthenticatorOptions<string>> extends TOTP<T> {
/**
* Creates a new instance with all defaultOptions and options reset.
*/
create(defaultOptions?: Partial<T>): Authenticator<T>;
/**
* Returns a set of options at the current moment,
* polyfilled with some of the missing required options.
*
* Refer to [[authenticatorOptions]]
*/
allOptions(): Readonly<T>;
/**
* Reference: [[authenticatorToken]]
*/
generate(secret: Base32SecretKey): string;
/**
* Reference: [[authenticatorCheckWithWindow]]
*/
checkDelta(token: string, secret: Base32SecretKey): number | null;
/**
* Reference: [[authenticatorEncoder]]
*/
encode(secret: SecretKey): Base32SecretKey;
/**
* Reference: [[authenticatorDecoder]]
*/
decode(secret: Base32SecretKey): SecretKey;
/**
* Reference: [[authenticatorGenerateSecret]]
*/
generateSecret(numberOfBytes?: number): Base32SecretKey;
}

View File

@@ -0,0 +1,128 @@
import { CreateDigest, CreateHmacKey, HashAlgorithms, HexString, KeyEncodings, OTP, OTPOptions, SecretKey } from './utils';
/**
* Interface for options used in HOTP.
*/
export interface HOTPOptions<T = string> extends OTPOptions {
/**
* Creates the digest which token is derived from.
*/
createDigest: CreateDigest<T>;
/**
* Formats the secret into a HMAC key, applying transformations (like padding) where needed
*/
createHmacKey: CreateHmacKey<T>;
/**
* The algorithm used for calculating the HMAC.
*/
algorithm: HashAlgorithms;
/**
* **USE WITH CAUTION:** Given the same digest, the same token will be received.
*
* This is provided for unique use cases. For example, digest generation might
* depend on an async API.
*/
digest?: HexString;
/**
* The number of digits a token will have. Usually 6 or 8.
*/
digits: number;
/**
* The encoding that was used on the secret.
*/
encoding: KeyEncodings;
}
/**
* Validates the given [[HOTPOptions]]
*/
export declare function hotpOptionsValidator<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(options: Readonly<Partial<T>>): void;
/**
* Takes a HOTP secret and derives the HMAC key
* for use in token generation.
*
* @param algorithm - Reference: [[HOTPOptions.algorithm]]
* @param secret
* @param encoding - Reference: [[HOTPOptions.encoding]]
*/
export declare const hotpCreateHmacKey: CreateHmacKey;
/**
* Returns the default options for HOTP
*/
export declare function hotpDefaultOptions<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(): Partial<T>;
/**
* Takes an HOTP Option object and provides presets for
* some of the missing required HOTP option fields and validates
* the resultant options.
*/
export declare function hotpOptions<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(opt: Readonly<Partial<T>>): Readonly<T>;
/**
* Formats a given counter into a string counter.
*/
export declare function hotpCounter(counter: number): HexString;
/**
* Converts a digest to a token of a specified length.
*/
export declare function hotpDigestToToken(hexDigest: HexString, digits: number): string;
/**
* Generates a HMAC-based One-time Token (HOTP)
*
* **References**
*
* - http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm
* - http://tools.ietf.org/html/rfc4226
*
* **Note**: If options.digest is provided, it will skip digest generation.
* Use options.digest with caution. Same digest = Same token.
*
* @param secret - Your secret key.
* @param counter - the OTP counter (usually it's an incremental count)
* @param options - A HOTPOptions object.
*/
export declare function hotpToken<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(secret: SecretKey, counter: number, options: Readonly<T>): string;
/**
* Checks the given token against the system generated token.
*
* **Note**: Token is valid only if it is a number string
*/
export declare function hotpCheck<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(token: string, secret: SecretKey, counter: number, options: Readonly<T>): boolean;
/**
* Generates a [keyuri](../#keyuri) from options provided
* and it's type set to HOTP.
*/
export declare function hotpKeyuri<T extends HOTPOptions<unknown> = HOTPOptions<unknown>>(accountName: string, issuer: string, secret: SecretKey, counter: number, options: Readonly<T>): string;
/**
* A class wrapper containing all HOTP methods.
*/
export declare class HOTP<T extends HOTPOptions = HOTPOptions> extends OTP<T> {
/**
* Creates a new instance with all defaultOptions and options reset.
*/
create(defaultOptions?: Partial<T>): HOTP<T>;
/**
* Returns class options polyfilled with some of
* the missing required options.
*
* Reference: [[hotpOptions]]
*/
allOptions(): Readonly<T>;
/**
* Reference: [[hotpToken]]
*/
generate(secret: SecretKey, counter: number): string;
/**
* Reference: [[hotpCheck]]
*/
check(token: string, secret: SecretKey, counter: number): boolean;
/**
* Same as [[check]] but accepts a single object based argument.
*/
verify(opts: {
token: string;
secret: SecretKey;
counter: number;
}): boolean;
/**
* Calls [keyuri](../#keyuri) with class options and type
* set to HOTP.
*/
keyuri(accountName: string, issuer: string, secret: SecretKey, counter: number): string;
}

View File

@@ -0,0 +1,4 @@
export * from './utils';
export * from './hotp';
export * from './totp';
export * from './authenticator';

View File

@@ -0,0 +1,491 @@
/**
* @otplib/core
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function objectValues(value) {
return Object.keys(value).map(key => value[key]);
}
(function (HashAlgorithms) {
HashAlgorithms["SHA1"] = "sha1";
HashAlgorithms["SHA256"] = "sha256";
HashAlgorithms["SHA512"] = "sha512";
})(exports.HashAlgorithms || (exports.HashAlgorithms = {}));
const HASH_ALGORITHMS = objectValues(exports.HashAlgorithms);
(function (KeyEncodings) {
KeyEncodings["ASCII"] = "ascii";
KeyEncodings["BASE64"] = "base64";
KeyEncodings["HEX"] = "hex";
KeyEncodings["LATIN1"] = "latin1";
KeyEncodings["UTF8"] = "utf8";
})(exports.KeyEncodings || (exports.KeyEncodings = {}));
const KEY_ENCODINGS = objectValues(exports.KeyEncodings);
(function (Strategy) {
Strategy["HOTP"] = "hotp";
Strategy["TOTP"] = "totp";
})(exports.Strategy || (exports.Strategy = {}));
const STRATEGY = objectValues(exports.Strategy);
const createDigestPlaceholder = () => {
throw new Error('Please provide an options.createDigest implementation.');
};
function isTokenValid(value) {
return /^(\d+)$/.test(value);
}
function padStart(value, maxLength, fillString) {
if (value.length >= maxLength) {
return value;
}
const padding = Array(maxLength + 1).join(fillString);
return `${padding}${value}`.slice(-1 * maxLength);
}
function keyuri(options) {
const tmpl = `otpauth://${options.type}/{labelPrefix}:{accountName}?secret={secret}{query}`;
const params = [];
if (STRATEGY.indexOf(options.type) < 0) {
throw new Error(`Expecting options.type to be one of ${STRATEGY.join(', ')}. Received ${options.type}.`);
}
if (options.type === 'hotp') {
if (options.counter == null || typeof options.counter !== 'number') {
throw new Error('Expecting options.counter to be a number when options.type is "hotp".');
}
params.push(`&counter=${options.counter}`);
}
if (options.type === 'totp' && options.step) {
params.push(`&period=${options.step}`);
}
if (options.digits) {
params.push(`&digits=${options.digits}`);
}
if (options.algorithm) {
params.push(`&algorithm=${options.algorithm.toUpperCase()}`);
}
if (options.issuer) {
params.push(`&issuer=${encodeURIComponent(options.issuer)}`);
}
return tmpl.replace('{labelPrefix}', encodeURIComponent(options.issuer || options.accountName)).replace('{accountName}', encodeURIComponent(options.accountName)).replace('{secret}', options.secret).replace('{query}', params.join(''));
}
class OTP {
constructor(defaultOptions = {}) {
this._defaultOptions = Object.freeze({ ...defaultOptions
});
this._options = Object.freeze({});
}
create(defaultOptions = {}) {
return new OTP(defaultOptions);
}
clone(defaultOptions = {}) {
const instance = this.create({ ...this._defaultOptions,
...defaultOptions
});
instance.options = this._options;
return instance;
}
get options() {
return Object.freeze({ ...this._defaultOptions,
...this._options
});
}
set options(options) {
this._options = Object.freeze({ ...this._options,
...options
});
}
allOptions() {
return this.options;
}
resetOptions() {
this._options = Object.freeze({});
}
}
function hotpOptionsValidator(options) {
if (typeof options.createDigest !== 'function') {
throw new Error('Expecting options.createDigest to be a function.');
}
if (typeof options.createHmacKey !== 'function') {
throw new Error('Expecting options.createHmacKey to be a function.');
}
if (typeof options.digits !== 'number') {
throw new Error('Expecting options.digits to be a number.');
}
if (!options.algorithm || HASH_ALGORITHMS.indexOf(options.algorithm) < 0) {
throw new Error(`Expecting options.algorithm to be one of ${HASH_ALGORITHMS.join(', ')}. Received ${options.algorithm}.`);
}
if (!options.encoding || KEY_ENCODINGS.indexOf(options.encoding) < 0) {
throw new Error(`Expecting options.encoding to be one of ${KEY_ENCODINGS.join(', ')}. Received ${options.encoding}.`);
}
}
const hotpCreateHmacKey = (algorithm, secret, encoding) => {
return Buffer.from(secret, encoding).toString('hex');
};
function hotpDefaultOptions() {
const options = {
algorithm: exports.HashAlgorithms.SHA1,
createHmacKey: hotpCreateHmacKey,
createDigest: createDigestPlaceholder,
digits: 6,
encoding: exports.KeyEncodings.ASCII
};
return options;
}
function hotpOptions(opt) {
const options = { ...hotpDefaultOptions(),
...opt
};
hotpOptionsValidator(options);
return Object.freeze(options);
}
function hotpCounter(counter) {
const hexCounter = counter.toString(16);
return padStart(hexCounter, 16, '0');
}
function hotpDigestToToken(hexDigest, digits) {
const digest = Buffer.from(hexDigest, 'hex');
const offset = digest[digest.length - 1] & 0xf;
const binary = (digest[offset] & 0x7f) << 24 | (digest[offset + 1] & 0xff) << 16 | (digest[offset + 2] & 0xff) << 8 | digest[offset + 3] & 0xff;
const token = binary % Math.pow(10, digits);
return padStart(String(token), digits, '0');
}
function hotpDigest(secret, counter, options) {
const hexCounter = hotpCounter(counter);
const hmacKey = options.createHmacKey(options.algorithm, secret, options.encoding);
return options.createDigest(options.algorithm, hmacKey, hexCounter);
}
function hotpToken(secret, counter, options) {
const hexDigest = options.digest || hotpDigest(secret, counter, options);
return hotpDigestToToken(hexDigest, options.digits);
}
function hotpCheck(token, secret, counter, options) {
if (!isTokenValid(token)) {
return false;
}
const systemToken = hotpToken(secret, counter, options);
return token === systemToken;
}
function hotpKeyuri(accountName, issuer, secret, counter, options) {
return keyuri({
algorithm: options.algorithm,
digits: options.digits,
type: exports.Strategy.HOTP,
accountName,
counter,
issuer,
secret
});
}
class HOTP extends OTP {
create(defaultOptions = {}) {
return new HOTP(defaultOptions);
}
allOptions() {
return hotpOptions(this.options);
}
generate(secret, counter) {
return hotpToken(secret, counter, this.allOptions());
}
check(token, secret, counter) {
return hotpCheck(token, secret, counter, this.allOptions());
}
verify(opts) {
if (typeof opts !== 'object') {
throw new Error('Expecting argument 0 of verify to be an object');
}
return this.check(opts.token, opts.secret, opts.counter);
}
keyuri(accountName, issuer, secret, counter) {
return hotpKeyuri(accountName, issuer, secret, counter, this.allOptions());
}
}
function parseWindowBounds(win) {
if (typeof win === 'number') {
return [Math.abs(win), Math.abs(win)];
}
if (Array.isArray(win)) {
const [past, future] = win;
if (typeof past === 'number' && typeof future === 'number') {
return [Math.abs(past), Math.abs(future)];
}
}
throw new Error('Expecting options.window to be an number or [number, number].');
}
function totpOptionsValidator(options) {
hotpOptionsValidator(options);
parseWindowBounds(options.window);
if (typeof options.epoch !== 'number') {
throw new Error('Expecting options.epoch to be a number.');
}
if (typeof options.step !== 'number') {
throw new Error('Expecting options.step to be a number.');
}
}
const totpPadSecret = (secret, encoding, minLength) => {
const currentLength = secret.length;
const hexSecret = Buffer.from(secret, encoding).toString('hex');
if (currentLength < minLength) {
const newSecret = new Array(minLength - currentLength + 1).join(hexSecret);
return Buffer.from(newSecret, 'hex').slice(0, minLength).toString('hex');
}
return hexSecret;
};
const totpCreateHmacKey = (algorithm, secret, encoding) => {
switch (algorithm) {
case exports.HashAlgorithms.SHA1:
return totpPadSecret(secret, encoding, 20);
case exports.HashAlgorithms.SHA256:
return totpPadSecret(secret, encoding, 32);
case exports.HashAlgorithms.SHA512:
return totpPadSecret(secret, encoding, 64);
default:
throw new Error(`Expecting algorithm to be one of ${HASH_ALGORITHMS.join(', ')}. Received ${algorithm}.`);
}
};
function totpDefaultOptions() {
const options = {
algorithm: exports.HashAlgorithms.SHA1,
createDigest: createDigestPlaceholder,
createHmacKey: totpCreateHmacKey,
digits: 6,
encoding: exports.KeyEncodings.ASCII,
epoch: Date.now(),
step: 30,
window: 0
};
return options;
}
function totpOptions(opt) {
const options = { ...totpDefaultOptions(),
...opt
};
totpOptionsValidator(options);
return Object.freeze(options);
}
function totpCounter(epoch, step) {
return Math.floor(epoch / step / 1000);
}
function totpToken(secret, options) {
const counter = totpCounter(options.epoch, options.step);
return hotpToken(secret, counter, options);
}
function totpEpochsInWindow(epoch, direction, deltaPerEpoch, numOfEpoches) {
const result = [];
if (numOfEpoches === 0) {
return result;
}
for (let i = 1; i <= numOfEpoches; i++) {
const delta = direction * i * deltaPerEpoch;
result.push(epoch + delta);
}
return result;
}
function totpEpochAvailable(epoch, step, win) {
const bounds = parseWindowBounds(win);
const delta = step * 1000;
return {
current: epoch,
past: totpEpochsInWindow(epoch, -1, delta, bounds[0]),
future: totpEpochsInWindow(epoch, 1, delta, bounds[1])
};
}
function totpCheck(token, secret, options) {
if (!isTokenValid(token)) {
return false;
}
const systemToken = totpToken(secret, options);
return token === systemToken;
}
function totpCheckByEpoch(epochs, token, secret, options) {
let position = null;
epochs.some((epoch, idx) => {
if (totpCheck(token, secret, { ...options,
epoch
})) {
position = idx + 1;
return true;
}
return false;
});
return position;
}
function totpCheckWithWindow(token, secret, options) {
if (totpCheck(token, secret, options)) {
return 0;
}
const epochs = totpEpochAvailable(options.epoch, options.step, options.window);
const backward = totpCheckByEpoch(epochs.past, token, secret, options);
if (backward !== null) {
return backward * -1;
}
return totpCheckByEpoch(epochs.future, token, secret, options);
}
function totpTimeUsed(epoch, step) {
return Math.floor(epoch / 1000) % step;
}
function totpTimeRemaining(epoch, step) {
return step - totpTimeUsed(epoch, step);
}
function totpKeyuri(accountName, issuer, secret, options) {
return keyuri({
algorithm: options.algorithm,
digits: options.digits,
step: options.step,
type: exports.Strategy.TOTP,
accountName,
issuer,
secret
});
}
class TOTP extends HOTP {
create(defaultOptions = {}) {
return new TOTP(defaultOptions);
}
allOptions() {
return totpOptions(this.options);
}
generate(secret) {
return totpToken(secret, this.allOptions());
}
checkDelta(token, secret) {
return totpCheckWithWindow(token, secret, this.allOptions());
}
check(token, secret) {
const delta = this.checkDelta(token, secret);
return typeof delta === 'number';
}
verify(opts) {
if (typeof opts !== 'object') {
throw new Error('Expecting argument 0 of verify to be an object');
}
return this.check(opts.token, opts.secret);
}
timeRemaining() {
const options = this.allOptions();
return totpTimeRemaining(options.epoch, options.step);
}
timeUsed() {
const options = this.allOptions();
return totpTimeUsed(options.epoch, options.step);
}
keyuri(accountName, issuer, secret) {
return totpKeyuri(accountName, issuer, secret, this.allOptions());
}
}
function authenticatorOptionValidator(options) {
totpOptionsValidator(options);
if (typeof options.keyDecoder !== 'function') {
throw new Error('Expecting options.keyDecoder to be a function.');
}
if (options.keyEncoder && typeof options.keyEncoder !== 'function') {
throw new Error('Expecting options.keyEncoder to be a function.');
}
}
function authenticatorDefaultOptions() {
const options = {
algorithm: exports.HashAlgorithms.SHA1,
createDigest: createDigestPlaceholder,
createHmacKey: totpCreateHmacKey,
digits: 6,
encoding: exports.KeyEncodings.HEX,
epoch: Date.now(),
step: 30,
window: 0
};
return options;
}
function authenticatorOptions(opt) {
const options = { ...authenticatorDefaultOptions(),
...opt
};
authenticatorOptionValidator(options);
return Object.freeze(options);
}
function authenticatorEncoder(secret, options) {
return options.keyEncoder(secret, options.encoding);
}
function authenticatorDecoder(secret, options) {
return options.keyDecoder(secret, options.encoding);
}
function authenticatorGenerateSecret(numberOfBytes, options) {
const key = options.createRandomBytes(numberOfBytes, options.encoding);
return authenticatorEncoder(key, options);
}
function authenticatorToken(secret, options) {
return totpToken(authenticatorDecoder(secret, options), options);
}
function authenticatorCheckWithWindow(token, secret, options) {
return totpCheckWithWindow(token, authenticatorDecoder(secret, options), options);
}
class Authenticator extends TOTP {
create(defaultOptions = {}) {
return new Authenticator(defaultOptions);
}
allOptions() {
return authenticatorOptions(this.options);
}
generate(secret) {
return authenticatorToken(secret, this.allOptions());
}
checkDelta(token, secret) {
return authenticatorCheckWithWindow(token, secret, this.allOptions());
}
encode(secret) {
return authenticatorEncoder(secret, this.allOptions());
}
decode(secret) {
return authenticatorDecoder(secret, this.allOptions());
}
generateSecret(numberOfBytes = 10) {
return authenticatorGenerateSecret(numberOfBytes, this.allOptions());
}
}
exports.Authenticator = Authenticator;
exports.HASH_ALGORITHMS = HASH_ALGORITHMS;
exports.HOTP = HOTP;
exports.KEY_ENCODINGS = KEY_ENCODINGS;
exports.OTP = OTP;
exports.STRATEGY = STRATEGY;
exports.TOTP = TOTP;
exports.authenticatorCheckWithWindow = authenticatorCheckWithWindow;
exports.authenticatorDecoder = authenticatorDecoder;
exports.authenticatorDefaultOptions = authenticatorDefaultOptions;
exports.authenticatorEncoder = authenticatorEncoder;
exports.authenticatorGenerateSecret = authenticatorGenerateSecret;
exports.authenticatorOptionValidator = authenticatorOptionValidator;
exports.authenticatorOptions = authenticatorOptions;
exports.authenticatorToken = authenticatorToken;
exports.createDigestPlaceholder = createDigestPlaceholder;
exports.hotpCheck = hotpCheck;
exports.hotpCounter = hotpCounter;
exports.hotpCreateHmacKey = hotpCreateHmacKey;
exports.hotpDefaultOptions = hotpDefaultOptions;
exports.hotpDigestToToken = hotpDigestToToken;
exports.hotpKeyuri = hotpKeyuri;
exports.hotpOptions = hotpOptions;
exports.hotpOptionsValidator = hotpOptionsValidator;
exports.hotpToken = hotpToken;
exports.isTokenValid = isTokenValid;
exports.keyuri = keyuri;
exports.objectValues = objectValues;
exports.padStart = padStart;
exports.totpCheck = totpCheck;
exports.totpCheckByEpoch = totpCheckByEpoch;
exports.totpCheckWithWindow = totpCheckWithWindow;
exports.totpCounter = totpCounter;
exports.totpCreateHmacKey = totpCreateHmacKey;
exports.totpDefaultOptions = totpDefaultOptions;
exports.totpEpochAvailable = totpEpochAvailable;
exports.totpKeyuri = totpKeyuri;
exports.totpOptions = totpOptions;
exports.totpOptionsValidator = totpOptionsValidator;
exports.totpPadSecret = totpPadSecret;
exports.totpTimeRemaining = totpTimeRemaining;
exports.totpTimeUsed = totpTimeUsed;
exports.totpToken = totpToken;

View File

@@ -0,0 +1,19 @@
{
"name": "@otplib/core",
"description": "core method for otplib",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"keywords": [
"otplib-core"
],
"otplib": {},
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-core",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,202 @@
import { CreateHmacKey, KeyEncodings, SecretKey } from './utils';
import { HOTP, HOTPOptions } from './hotp';
/**
* Interface for options used in TOTP.
*
* Contains additional options in addition to
* those within HOTP.
*/
export interface TOTPOptions<T = string> extends HOTPOptions<T> {
/**
* The starting time since the JavasSript epoch (seconds) (UNIX epoch * 1000).
*/
epoch: number;
/**
* Time step (seconds).
*/
step: number;
/**
* How many windows (x * step) past and future do we consider as valid during check.
*/
window: number | [number, number];
}
/**
* Interface for available epoches derived from
* the current epoch.
*/
export interface EpochAvailable {
current: number;
future: number[];
past: number[];
}
/**
* Validates the given [[TOTPOptions]].
*/
export declare function totpOptionsValidator<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(options: Readonly<Partial<T>>): void;
/**
* Pads the secret to the expected minimum length
* and returns a hex representation of the string.
*/
export declare const totpPadSecret: (secret: string, encoding: KeyEncodings, minLength: number) => string;
/**
* Takes a TOTP secret and derives the HMAC key
* for use in token generation.
*
* In RFC 6238, the secret / seed length for different algorithms
* are predefined.
*
* - HMAC-SHA1 (20 bytes)
* - HMAC-SHA256 (32 bytes)
* - HMAC-SHA512 (64 bytes)
*
* @param algorithm - Reference: [[TOTPOptions.algorithm]]
* @param secret
* @param encoding - Reference: [[TOTPOptions.encoding]]
*/
export declare const totpCreateHmacKey: CreateHmacKey;
/**
* Returns a set of default options for TOTP at the current epoch.
*/
export declare function totpDefaultOptions<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(): Partial<T>;
/**
* Takes an TOTP Option object and provides presets for
* some of the missing required TOTP option fields and validates
* the resultant options.
*/
export declare function totpOptions<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(opt: Partial<T>): Readonly<T>;
/**
* Generates the counter based on the current epoch and step.
* This dynamic counter is used in the HOTP algorithm.
*
* @param epoch - Reference: [[TOTPOptions.epoch]]
* @param step - Reference: [[TOTPOptions.step]]
*/
export declare function totpCounter(epoch: number, step: number): number;
/**
* Generates a Time-based One-time Token (TOTP)
*
* tl;dr: TOTP = HOTP + counter based on current time.
*
* **References**
*
* - http://tools.ietf.org/html/rfc6238
* - http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
*
*/
export declare function totpToken<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(secret: SecretKey, options: Readonly<T>): string;
/**
* Gets a set of epoches derived from
* the current epoch and the acceptable window.
*
* @param epoch - Reference: [[TOTPOptions.epoch]]
* @param step - Reference: [[TOTPOptions.step]]
* @param win - Reference: [[TOTPOptions.window]]
*/
export declare function totpEpochAvailable(epoch: number, step: number, win: number | [number, number]): EpochAvailable;
/**
* Checks the given token against the system generated token.
*
* **Note**: Token is valid only if it is a number string.
*/
export declare function totpCheck<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(token: string, secret: SecretKey, options: Readonly<T>): boolean;
/**
* Checks if there is a valid TOTP token in a given list of epoches.
* Returns the (index + 1) of a valid epoch in the list.
*
* @param epochs - List of epochs to check token against
* @param token - The token to check
* @param secret - Your secret key.
* @param options - A TOTPOptions object.
*/
export declare function totpCheckByEpoch<T extends TOTPOptions = TOTPOptions>(epochs: number[], token: string, secret: SecretKey, options: Readonly<T>): number | null;
/**
* Checks the provided OTP token against system generated token
* with support for checking past or future x * step windows.
*
* Return values:
*
* - null = check failed
* - positive number = token at future x * step
* - negative number = token at past x * step
*
* @param token - The token to check
* @param secret - Your secret key.
* @param options - A TOTPOptions object.
*/
export declare function totpCheckWithWindow<T extends TOTPOptions = TOTPOptions>(token: string, secret: SecretKey, options: Readonly<T>): number | null;
/**
* Calculates the number of seconds used in the current tick for TOTP.
*
* The start of a new token: `timeUsed() === 0`
*
* @param epoch - Reference: [[TOTPOptions.epoch]]
* @param step - Reference: [[TOTPOptions.step]]
*/
export declare function totpTimeUsed(epoch: number, step: number): number;
/**
* Calculates the number of seconds till next tick for TOTP.
*
* The start of a new token: `timeRemaining() === step`
*
* @param epoch - Reference: [[TOTPOptions.epoch]]
* @param step - Reference: [[TOTPOptions.step]]
*/
export declare function totpTimeRemaining(epoch: number, step: number): number;
/**
* Generates a [keyuri](../#keyuri) from options provided
* and it's type set to TOTP.
*/
export declare function totpKeyuri<T extends TOTPOptions<unknown> = TOTPOptions<unknown>>(accountName: string, issuer: string, secret: SecretKey, options: Readonly<T>): string;
/**
* A class wrapper containing all TOTP methods.
*/
export declare class TOTP<T extends TOTPOptions = TOTPOptions> extends HOTP<T> {
/**
* Creates a new instance with all defaultOptions and options reset.
*/
create(defaultOptions?: Partial<T>): TOTP<T>;
/**
* Returns class options polyfilled with some of
* the missing required options.
*
* Reference: [[totpOptions]]
*/
allOptions(): Readonly<T>;
/**
* Reference: [[totpToken]]
*/
generate(secret: SecretKey): string;
/**
* Reference: [[totpCheckWithWindow]]
*/
checkDelta(token: string, secret: SecretKey): number | null;
/**
* Checks if a given TOTP token matches the generated
* token at the given epoch (default to current time).
*
* This method will return true as long as the token is
* still within the acceptable time window defined.
*
* i.e when [[checkDelta]] returns a number.
*/
check(token: string, secret: SecretKey): boolean;
/**
* Same as [[check]] but accepts a single object based argument.
*/
verify(opts: {
token: string;
secret: SecretKey;
}): boolean;
/**
* Reference: [[totpTimeRemaining]]
*/
timeRemaining(): number;
/**
* Reference: [[totpTimeUsed]]
*/
timeUsed(): number;
/**
* Reference: [[totpKeyuri]]
*/
keyuri(accountName: string, issuer: string, secret: SecretKey): string;
}

View File

@@ -0,0 +1,209 @@
/**
* Secret Key used for OTP generation.
*/
export declare type SecretKey = string;
/**
* A hex encoded string.
*/
export declare type HexString = string;
/**
* Base interface for all option interfaces.
* eg: [[HOTPOptions]].
*/
export interface OTPOptions {
[key: string]: unknown;
}
/**
* Returns an array of values of the enumerable properties of an object.
* This is used in place of Object.values for wider platform support.
*
* @ignore
*
* @param value Object that contains the properties and methods.
*/
export declare function objectValues<T>(value: T): string[];
/**
* Algorithms that are available to be used for
* calculating the HMAC value
*/
export declare enum HashAlgorithms {
'SHA1' = "sha1",
'SHA256' = "sha256",
'SHA512' = "sha512"
}
/**
* Array of [[HashAlgorithms]] enum values
*
* @ignore
*/
export declare const HASH_ALGORITHMS: string[];
/**
* The encoding format for the [[SecretKey]].
* This is mostly used for converting the
* provided secret into a Buffer.
*/
export declare enum KeyEncodings {
'ASCII' = "ascii",
'BASE64' = "base64",
'HEX' = "hex",
'LATIN1' = "latin1",
'UTF8' = "utf8"
}
/**
* Array of [[KeyEncodings]] enum values
*
* @ignore
*/
export declare const KEY_ENCODINGS: string[];
/**
* The OTP generation strategies.
* Either HMAC or Time based.
*/
export declare enum Strategy {
'HOTP' = "hotp",
'TOTP' = "totp"
}
/**
* Array of [[Strategy]] enum values
*
* @ignore
*/
export declare const STRATEGY: string[];
/**
* Interface method for formatting the [[SecretKey]] with
* the algorithm constraints before it is given to [[CreateDigest]].
*/
export interface CreateHmacKey<T = HexString> {
(algorithm: HashAlgorithms, secret: SecretKey, encoding: KeyEncodings): T;
}
/**
* Interface method for generating a HMAC digest
* which is then used to generate the token.
*/
export interface CreateDigest<T = HexString> {
(algorithm: HashAlgorithms, hmacKey: HexString, counter: HexString): T;
}
/**
* Inteface for options accepted by keyuri
*/
export interface KeyURIOptions {
accountName: string;
algorithm?: HashAlgorithms;
counter?: number;
digits?: number;
issuer?: string;
label?: string;
secret: SecretKey;
step?: number;
type: Strategy;
}
/**
* createDigest placholder function which throws an error
* when it is not replaced with an actual implementation.
*
* @ignore
*/
export declare const createDigestPlaceholder: CreateDigest;
/**
* Checks if a string contains a valid token format.
*
* @param value - a number string.
*/
export declare function isTokenValid(value: string): boolean;
/**
* Left pad the current string with a given string to a given length.
*
* This behaves similarly to String.prototype.padStart
*
* @ignore
*
* @param value The string to pad.
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current
* string will be returned as it is.
* @param fillString The string to pad the current string with.
*/
export declare function padStart(value: string, maxLength: number, fillString: string): string;
/**
* Generates an otpauth uri which can be used in a QR Code.
*
* Reference: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
*
* Sample Output: otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
*
* **Example**
*
* ```js
* import qrcode from 'qrcode';
*
* const otpauth = keyuri({ ... })
*
* qrcode.toDataURL(otpauth, (err, imageUrl) => {
* if (err) {
* console.log('Error with QR');
* return;
* }
* console.log(imageUrl);
* });
* ```
*/
export declare function keyuri(options: KeyURIOptions): string;
/**
* Base OTP class which provides options management
* All OTP classes should be extended from this class.
*/
export declare class OTP<T extends OTPOptions = OTPOptions> {
/**
* Default options for an instance.
*
* These options **WILL PERSIST** even when [[resetOptions]] is called.
*/
protected _defaultOptions: Readonly<Partial<T>>;
/**
* Transient options for an instance.
*
* Values set here will take precedence over the same options that
* are set in [[_defaultOptions]].
*
* These options **WILL NOT PERSIST** upon calling [[resetOptions]].
*/
protected _options: Readonly<Partial<T>>;
/**
* Constructs the class with defaultOptions set.
*
* @param defaultOptions used to override or add existing defaultOptions.
*/
constructor(defaultOptions?: Partial<T>);
/**
* Creates a new instance with all defaultOptions and options reset.
*/
create(defaultOptions?: Partial<T>): OTP<T>;
/**
* Copies the defaultOptions and options from the current
* instance and applies the provided defaultOptions.
*/
clone(defaultOptions?: Partial<T>): ReturnType<this['create']>;
/**
* - The options **getter** will return all [[_options]],
* including those set into [[_defaultOptions]].
*/
get options(): Partial<T>;
/**
* - The options **setter** sets values into [[_options]].
*/
set options(options: Partial<T>);
/**
* Returns class options polyfilled with some of
* the missing required options.
*
* Reference: [[hotpOptions]]
*/
allOptions(): Readonly<T>;
/**
* Resets the current options. Does not reset default options.
*
* Default options are those that are specified during class
* inititialisation, when calling [[clone]] or when calling [[create]]
*/
resetOptions(): void;
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,20 @@
# @otplib/plugin-crypto
> node native crypto adapter for otplib
See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].
## Install
```bash
npm install --save @otplib/plugin-crypto
```
## License
`@otplib/plugin-crypto` is [MIT licensed][project-license]
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev

View File

@@ -0,0 +1,3 @@
import { CreateDigest, CreateRandomBytes } from '@otplib/core';
export declare const createDigest: CreateDigest;
export declare const createRandomBytes: CreateRandomBytes;

View File

@@ -0,0 +1,26 @@
/**
* @otplib/plugin-crypto
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var crypto = _interopDefault(require('crypto'));
const createDigest = (algorithm, hmacKey, counter) => {
const hmac = crypto.createHmac(algorithm, Buffer.from(hmacKey, 'hex'));
const digest = hmac.update(Buffer.from(counter, 'hex')).digest();
return digest.toString('hex');
};
const createRandomBytes = (size, encoding) => {
return crypto.randomBytes(size).toString(encoding);
};
exports.createDigest = createDigest;
exports.createRandomBytes = createRandomBytes;

View File

@@ -0,0 +1,26 @@
{
"name": "@otplib/plugin-crypto",
"description": "node crypto plugin for otplib",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"keywords": [
"otplib-plugin",
"crypto"
],
"dependencies": {
"@otplib/core": "^12.0.1"
},
"devDependencies": {
"@types/node": "^12.7.2"
},
"otplib": {},
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-plugin-crypto",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,20 @@
# @otplib/plugin-thirty-two
> thirty-two adapter for otplib
See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].
## Install
```bash
npm install --save @otplib/plugin-thirty-two
```
## License
`@otplib/plugin-thirty-two` is [MIT licensed][project-license]
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev

View File

@@ -0,0 +1,9 @@
import { KeyDecoder, KeyEncoder } from '@otplib/core';
/**
* - Key decoder using npm `thirty-two`
*/
export declare const keyDecoder: KeyDecoder;
/**
* - Key encoder using npm `thirty-two`
*/
export declare const keyEncoder: KeyEncoder;

View File

@@ -0,0 +1,24 @@
/**
* @otplib/plugin-thirty-two
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var thirtyTwo = _interopDefault(require('thirty-two'));
const keyDecoder = (encodedSecret, encoding) => {
return thirtyTwo.decode(encodedSecret).toString(encoding);
};
const keyEncoder = (secret, encoding) => {
return thirtyTwo.encode(Buffer.from(secret, encoding).toString('ascii')).toString().replace(/=/g, '');
};
exports.keyDecoder = keyDecoder;
exports.keyEncoder = keyEncoder;

View File

@@ -0,0 +1,24 @@
{
"name": "@otplib/plugin-thirty-two",
"description": "thirty-two plugin for otplib",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"keywords": [
"otplib-plugin",
"base32"
],
"dependencies": {
"@otplib/core": "^12.0.1",
"thirty-two": "^1.0.2"
},
"otplib": {},
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-plugin-thirty-two",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,20 @@
# @otplib/preset-default
> otplib node bundle with pre-configured plugins to get started quickly.
See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].
## Install
```bash
npm install --save @otplib/preset-default
```
## License
`@otplib/preset-default` is [MIT licensed][project-license]
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev

View File

@@ -0,0 +1,4 @@
import { Authenticator, AuthenticatorOptions, HOTP, HOTPOptions, TOTP, TOTPOptions } from '@otplib/core';
export declare const hotp: HOTP<HOTPOptions<string>>;
export declare const totp: TOTP<TOTPOptions<string>>;
export declare const authenticator: Authenticator<AuthenticatorOptions<string>>;

View File

@@ -0,0 +1,31 @@
/**
* @otplib/preset-default
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var pluginCrypto = require('@otplib/plugin-crypto');
var pluginThirtyTwo = require('@otplib/plugin-thirty-two');
var core = require('@otplib/core');
const hotp = new core.HOTP({
createDigest: pluginCrypto.createDigest
});
const totp = new core.TOTP({
createDigest: pluginCrypto.createDigest
});
const authenticator = new core.Authenticator({
createDigest: pluginCrypto.createDigest,
createRandomBytes: pluginCrypto.createRandomBytes,
keyDecoder: pluginThirtyTwo.keyDecoder,
keyEncoder: pluginThirtyTwo.keyEncoder
});
exports.authenticator = authenticator;
exports.hotp = hotp;
exports.totp = totp;

View File

@@ -0,0 +1,25 @@
{
"name": "@otplib/preset-default",
"description": "basic preset for otplib",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"keywords": [
"otplib-preset",
"node"
],
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/plugin-crypto": "^12.0.1",
"@otplib/plugin-thirty-two": "^12.0.1"
},
"otplib": {},
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-preset-default",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,20 @@
# @otplib/preset-v11
> Preset with v11.x compatibility adapter for otplib@v12.x
See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].
## Install
```bash
npm install --save @otplib/preset-v11
```
## License
`@otplib/preset-v11` is [MIT licensed][project-license]
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev

View File

@@ -0,0 +1,126 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
interface HmacOptions {
algorithm?: string;
encoding?: string;
}
type createHmacSecret = (secret: string, options: HmacOptions) => Buffer;
interface HotpOptionsInterface extends HmacOptions {
createHmacSecret?: createHmacSecret;
crypto?: any;
digits?: number;
}
interface HotpVerifyOptionsInterface {
token?: string;
secret?: string;
counter?: number;
}
type hotpCheck = (
token: string,
secret: string,
counter: number,
options: HotpOptionsInterface
) => boolean;
type hotpCounter = (counter: number) => string;
type hotpDigest = (
secret: string,
counter: number,
options: HotpOptionsInterface
) => string;
type hotpOptions = (options: any) => HotpOptionsInterface;
type hotpSecret = createHmacSecret;
type hotpToken = (
secret: string,
counter: number,
options: HotpOptionsInterface
) => string;
interface TotpOptionsInterface extends HotpOptionsInterface {
epoch?: any;
step?: number;
window?: number | number[];
}
interface TotpVerifyOptionsInterface {
token?: string;
secret?: string;
}
type totpCheck = (
token: string,
secret: string,
options: TotpOptionsInterface
) => boolean;
type totpCheckWithWindow = (
token: string,
secret: string,
options: TotpOptionsInterface
) => number | null;
type totpCounter = (epoch: number, step: number) => number;
type totpOptions = (options: any) => TotpOptionsInterface;
type totpSecret = createHmacSecret;
type totpTimeRemaining = (epoch: number, step: number) => number;
type totpTimeUsed = (epoch: number, step: number) => number;
type totpToken = (secret: string, options: TotpOptionsInterface) => string;
declare class HOTP {
HOTP: typeof HOTP;
getClass(): typeof HOTP;
defaultOptions: HotpOptionsInterface;
options: HotpOptionsInterface;
optionsAll: HotpOptionsInterface;
resetOptions(): this;
generate(secret: string, counter: number): string;
check(token: string, secret: string, counter: number): boolean;
verify(opts: HotpVerifyOptionsInterface): boolean;
}
declare class TOTP extends HOTP {
TOTP: typeof TOTP;
getClass(): typeof TOTP;
defaultOptions: TotpOptionsInterface;
options: TotpOptionsInterface;
optionsAll: TotpOptionsInterface;
generate(secret: string): string;
check(token: string, secret: string): boolean;
checkDelta(token: string, secret: string): number | null;
verify(opts: TotpVerifyOptionsInterface): boolean;
timeUsed(): number;
timeRemaining(): number;
}
declare class Authenticator extends TOTP {
Authenticator: typeof Authenticator;
getClass(): typeof Authenticator;
check(token: string, secret: string): boolean;
checkDelta(token: string, secret: string): number | null;
decode(encodedKey: string): string;
encode(secret: string): string;
generate(secret: string): string;
generateSecret(len?: number): string;
keyuri(user: string, service: string, secret: string): string;
}
declare module '@otplib/preset-v11' {
const authenticator: Authenticator;
const hotp: HOTP;
const totp: TOTP;
}

View File

@@ -0,0 +1,133 @@
/**
* @otplib/preset-v11
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var pluginCrypto = require('@otplib/plugin-crypto');
var pluginThirtyTwo = require('@otplib/plugin-thirty-two');
var core = require('@otplib/core');
function epochUnixToJS(opt = {}) {
if (!opt || typeof opt !== 'object') {
return {};
}
const {
epoch,
...others
} = opt;
if (epoch === null) {
return others;
}
if (typeof epoch === 'number') {
return { ...opt,
epoch: opt.epoch * 1000
};
}
return opt;
}
function epochJSToUnix(opt = {}) {
if (!opt || typeof opt !== 'object') {
return {};
}
const {
epoch,
...others
} = opt;
if (epoch === null) {
return others;
}
if (typeof epoch === 'number') {
return { ...opt,
epoch: epoch / 1000
};
}
return opt;
}
function createV11(Base, legacyOptions) {
class Legacy extends Base {
constructor(defaultOptions = {}) {
super(epochUnixToJS({ ...legacyOptions,
...defaultOptions
}));
console.warn(Base.name, 'initialised with v11.x adapter');
}
static get name() {
return Base.name;
}
set options(opt = {}) {
console.warn(Base.name, '.options setter will remove UNIX epoch if it is set to null.' + '\n Do note that library versions above v11.x uses JavaScript epoch.');
super.options = epochUnixToJS(opt);
}
get options() {
console.warn(Base.name, '.options getter will remove epoch if it is set to null' + '\n Do note that library versions above v11.x uses JavaScript epoch.');
return epochJSToUnix(super.options);
}
get defaultOptions() {
console.warn(Base.name, '.defaultOptions getter has been deprecated in favour of the .options getter' + '\n\n The .options getter now returns the combined defaultOptions and options values' + 'instead of setting options when adding defaultOptions.');
return Object.freeze(epochJSToUnix(this._defaultOptions));
}
set defaultOptions(opt) {
console.warn(Base.name, '.defaultOptions setter has been deprecated in favour of the .clone(defaultOptions) method');
this._defaultOptions = Object.freeze({ ...this._defaultOptions,
...epochUnixToJS(opt)
});
}
get optionsAll() {
console.warn(Base.name, '.optionsAll getter has been deprecated in favour of the .allOptions() method.' + '\n That epoch returned here will be in Unix Epoch, while .allOptions()' + ' will return JavaScript epoch.' + '\n Do note that library versions above v11.x uses JavaScript epoch.');
return epochJSToUnix(this.allOptions());
}
allOptions() {
return epochUnixToJS(super.allOptions());
}
getClass() {
return Legacy;
}
verify(opts) {
if (!opts || typeof opts !== 'object') {
return false;
}
try {
return super.verify(opts);
} catch (err) {
return false;
}
}
}
Legacy.prototype[Base.name] = Legacy;
return Legacy;
}
const HOTP = createV11(core.HOTP, {});
const TOTP = createV11(core.TOTP, {
epoch: null,
step: 30,
window: 0
});
const Authenticator = createV11(core.Authenticator, {
encoding: 'hex',
epoch: null,
step: 30,
window: 0
});
const hotp = new HOTP({
createDigest: pluginCrypto.createDigest
});
const totp = new TOTP({
createDigest: pluginCrypto.createDigest
});
const authenticator = new Authenticator({
createDigest: pluginCrypto.createDigest,
createRandomBytes: pluginCrypto.createRandomBytes,
keyEncoder: pluginThirtyTwo.keyEncoder,
keyDecoder: pluginThirtyTwo.keyDecoder
});
exports.authenticator = authenticator;
exports.hotp = hotp;
exports.totp = totp;

View File

@@ -0,0 +1,25 @@
{
"name": "@otplib/preset-v11",
"description": "v11.x compatible interface preset for otplib",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"keywords": [
"otplib-preset",
"node"
],
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/plugin-crypto": "^12.0.1",
"@otplib/plugin-thirty-two": "^12.0.1"
},
"otplib": {},
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-preset-v11",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,13 @@
'use strict';
module.exports = function (str, sep) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
sep = typeof sep === 'undefined' ? '_' : sep;
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
.toLowerCase();
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -0,0 +1,38 @@
{
"name": "decamelize",
"version": "1.2.0",
"description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
"license": "MIT",
"repository": "sindresorhus/decamelize",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"decamelize",
"decamelcase",
"camelcase",
"lowercase",
"case",
"dash",
"hyphen",
"string",
"str",
"text",
"convert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

View File

@@ -0,0 +1,48 @@
# decamelize [![Build Status](https://travis-ci.org/sindresorhus/decamelize.svg?branch=master)](https://travis-ci.org/sindresorhus/decamelize)
> Convert a camelized string into a lowercased one with a custom separator<br>
> Example: `unicornRainbow` → `unicorn_rainbow`
## Install
```
$ npm install --save decamelize
```
## Usage
```js
const decamelize = require('decamelize');
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'
```
## API
### decamelize(input, [separator])
#### input
Type: `string`
#### separator
Type: `string`<br>
Default: `_`
## Related
See [`camelcase`](https://github.com/sindresorhus/camelcase) for the inverse.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "stable"
sudo: false

View File

@@ -0,0 +1,8 @@
Contributing
============
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

View File

@@ -0,0 +1,19 @@
```
Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
Copyright (C) 2008
Wyatt Baldwin <self@wyattbaldwin.com>
All rights reserved
Licensed under the MIT license.
http://www.opensource.org/licenses/mit-license.php
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.
```

View File

@@ -0,0 +1,18 @@
# dijkstrajs.js
dijkstrajs is a simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm.
The code was originally written by Wyatt Baldwin and turned into a node module by Thomas Cort.
## Requirements
* [nodejs](http://nodejs.org/)
## Installation
npm install dijkstrajs
## Examples
See `test/dijkstra.test.js` in the sources for some example code.

View File

@@ -0,0 +1,165 @@
'use strict';
/******************************************************************************
* Created 2008-08-19.
*
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
*
* Copyright (C) 2008
* Wyatt Baldwin <self@wyattbaldwin.com>
* All rights reserved
*
* Licensed under the MIT license.
*
* http://www.opensource.org/licenses/mit-license.php
*
* 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.
*****************************************************************************/
var dijkstra = {
single_source_shortest_paths: function(graph, s, d) {
// Predecessor map for each node that has been encountered.
// node ID => predecessor node ID
var predecessors = {};
// Costs of shortest paths from s to all nodes encountered.
// node ID => cost
var costs = {};
costs[s] = 0;
// Costs of shortest paths from s to all nodes encountered; differs from
// `costs` in that it provides easy access to the node that currently has
// the known shortest path from s.
// XXX: Do we actually need both `costs` and `open`?
var open = dijkstra.PriorityQueue.make();
open.push(s, 0);
var closest,
u, v,
cost_of_s_to_u,
adjacent_nodes,
cost_of_e,
cost_of_s_to_u_plus_cost_of_e,
cost_of_s_to_v,
first_visit;
while (!open.empty()) {
// In the nodes remaining in graph that have a known cost from s,
// find the node, u, that currently has the shortest path from s.
closest = open.pop();
u = closest.value;
cost_of_s_to_u = closest.cost;
// Get nodes adjacent to u...
adjacent_nodes = graph[u] || {};
// ...and explore the edges that connect u to those nodes, updating
// the cost of the shortest paths to any or all of those nodes as
// necessary. v is the node across the current edge from u.
for (v in adjacent_nodes) {
if (adjacent_nodes.hasOwnProperty(v)) {
// Get the cost of the edge running from u to v.
cost_of_e = adjacent_nodes[v];
// Cost of s to u plus the cost of u to v across e--this is *a*
// cost from s to v that may or may not be less than the current
// known cost to v.
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
// If we haven't visited v yet OR if the current known cost from s to
// v is greater than the new cost we just found (cost of s to u plus
// cost of u to v across e), update v's cost in the cost list and
// update v's predecessor in the predecessor list (it's now u).
cost_of_s_to_v = costs[v];
first_visit = (typeof costs[v] === 'undefined');
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
costs[v] = cost_of_s_to_u_plus_cost_of_e;
open.push(v, cost_of_s_to_u_plus_cost_of_e);
predecessors[v] = u;
}
}
}
}
if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
throw new Error(msg);
}
return predecessors;
},
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
var nodes = [];
var u = d;
var predecessor;
while (u) {
nodes.push(u);
predecessor = predecessors[u];
u = predecessors[u];
}
nodes.reverse();
return nodes;
},
find_path: function(graph, s, d) {
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
return dijkstra.extract_shortest_path_from_predecessor_list(
predecessors, d);
},
/**
* A very naive priority queue implementation.
*/
PriorityQueue: {
make: function (opts) {
var T = dijkstra.PriorityQueue,
t = {},
key;
opts = opts || {};
for (key in T) {
if (T.hasOwnProperty(key)) {
t[key] = T[key];
}
}
t.queue = [];
t.sorter = opts.sorter || T.default_sorter;
return t;
},
default_sorter: function (a, b) {
return a.cost - b.cost;
},
/**
* Add a new item to the queue and ensure the highest priority element
* is at the front of the queue.
*/
push: function (value, cost) {
var item = {value: value, cost: cost};
this.queue.push(item);
this.queue.sort(this.sorter);
},
/**
* Return the highest priority element in the queue.
*/
pop: function () {
return this.queue.shift();
},
empty: function () {
return this.queue.length === 0;
}
}
};
// node.js module exports
if (typeof module !== 'undefined') {
module.exports = dijkstra;
}

View File

@@ -0,0 +1,60 @@
{
"name": "dijkstrajs",
"version": "1.0.2",
"description": "A simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm.",
"main": "dijkstra.js",
"scripts": {
"pretest": "jshint dijkstra.js",
"test": "mocha -R spec"
},
"repository": {
"type": "git",
"url": "git://github.com/tcort/dijkstrajs"
},
"keywords": [
"dijkstra",
"shortest",
"path",
"search",
"graph"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/tcort/dijkstrajs/issues"
},
"homepage": "https://github.com/tcort/dijkstrajs",
"devDependencies": {
"expect.js": "^0.3.1",
"jshint": "^2.12.0",
"mocha": "^8.4.0"
},
"jshintConfig": {
"bitwise": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"globalstrict": true,
"immed": true,
"indent": 4,
"moz": true,
"newcap": true,
"noarg": true,
"node": true,
"noempty": true,
"nonew": true,
"trailing": true,
"undef": true,
"smarttabs": true,
"strict": true,
"validthis": true,
"globals": {
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false
}
}
}

View File

@@ -0,0 +1,96 @@
'use strict';
var expect = require('expect.js');
var dijkstra = require('../dijkstra.js');
var find_path = dijkstra.find_path;
describe('dijkstra.js', function () {
describe('.find_path()', function () {
it('should find the path between two points, all edges have weight 1', function () {
// A B C
// D E F
// G H I
var graph = {
a: {b: 10, d: 1},
b: {a: 1, c: 1, e: 1},
c: {b: 1, f: 1},
d: {a: 1, e: 1, g: 1},
e: {b: 1, d: 1, f: 1, h: 1},
f: {c: 1, e: 1, i: 1},
g: {d: 1, h: 1},
h: {e: 1, g: 1, i: 1},
i: {f: 1, h: 1}
};
var path = find_path(graph, 'a', 'i');
expect(path).to.eql(['a', 'd', 'e', 'f', 'i']);
});
it('should find the path between two points, weighted edges', function () {
var graph = {
a: {b: 10, c: 100, d: 1},
b: {c: 10},
d: {b: 1, e: 1},
e: {f: 1},
f: {c: 1},
g: {b: 1}
};
var path = find_path(graph, 'a', 'c');
expect(path).to.eql(['a', 'd', 'e', 'f', 'c']);
path = find_path(graph, 'd', 'b');
expect(path).to.eql(['d', 'b']);
});
it('should throw on unreachable destination', function () {
var graph = {
a: {b: 10, c: 100, d: 1},
b: {c: 10},
d: {b: 1, e: 1},
e: {f: 1},
f: {c: 1},
g: {b: 1}
};
expect(function () { find_path(graph, 'c', 'a'); }).to.throwException();
expect(function () { find_path(graph, 'a', 'g'); }).to.throwException();
});
it('should throw on non-existent destination', function () {
var graph = {
a: {b: 10, c: 100, d: 1},
b: {c: 10},
d: {b: 1, e: 1},
e: {f: 1},
f: {c: 1},
g: {b: 1}
};
expect(function () { find_path(graph, 'a', 'z'); }).to.throwException();
});
});
describe('.single_source_shortest_paths()', function () {
it('should find all paths from a node', function () {
var graph = {
a: {b: 10, c: 100, d: 1},
b: {c: 10},
d: {b: 1, e: 1},
e: {f: 1},
f: {c: 1},
g: {b: 1}
};
// All paths from 'a'
var paths = dijkstra.single_source_shortest_paths(graph, 'a');
expect(paths).to.eql({
d: 'a',
b: 'd',
e: 'd',
f: 'e',
c: 'f'
});
});
});
});

View File

@@ -0,0 +1,2 @@
declare function encodeUtf8 (input: string): ArrayBuffer
export = encodeUtf8

View File

@@ -0,0 +1,55 @@
'use strict'
module.exports = function encodeUtf8 (input) {
var result = []
var size = input.length
for (var index = 0; index < size; index++) {
var point = input.charCodeAt(index)
if (point >= 0xD800 && point <= 0xDBFF && size > index + 1) {
var second = input.charCodeAt(index + 1)
if (second >= 0xDC00 && second <= 0xDFFF) {
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
point = (point - 0xD800) * 0x400 + second - 0xDC00 + 0x10000
index += 1
}
}
// US-ASCII
if (point < 0x80) {
result.push(point)
continue
}
// 2-byte UTF-8
if (point < 0x800) {
result.push((point >> 6) | 192)
result.push((point & 63) | 128)
continue
}
// 3-byte UTF-8
if (point < 0xD800 || (point >= 0xE000 && point < 0x10000)) {
result.push((point >> 12) | 224)
result.push(((point >> 6) & 63) | 128)
result.push((point & 63) | 128)
continue
}
// 4-byte UTF-8
if (point >= 0x10000 && point <= 0x10FFFF) {
result.push((point >> 18) | 240)
result.push(((point >> 12) & 63) | 128)
result.push(((point >> 6) & 63) | 128)
result.push((point & 63) | 128)
continue
}
// Invalid character
result.push(0xEF, 0xBF, 0xBD)
}
return new Uint8Array(result).buffer
}

View File

@@ -0,0 +1,13 @@
{
"name": "encode-utf8",
"version": "1.0.3",
"license": "MIT",
"repository": "LinusU/encode-utf8",
"scripts": {
"test": "standard && mocha"
},
"devDependencies": {
"mocha": "^6.2.2",
"standard": "^14.3.1"
}
}

View File

@@ -0,0 +1,27 @@
# Encode UTF8
Turn a string into an ArrayBuffer by using the UTF8 encoding.
## Installation
```js
npm install --save encode-uf8
```
## Usage
```js
const encodeUtf8 = require('encode-utf8')
console.log(encodeUtf8('Hello, World!'))
//=> ArrayBuffer { byteLength: 13 }
console.log(encodeUtf8('🐵 🙈 🙉 🙊'))
//=> ArrayBuffer { byteLength: 19 }
```
## API
### `encodeUtf8(input: string): ArrayBuffer`
Returns an ArrayBuffer with the string represented as UTF8 encoded data.

View File

@@ -0,0 +1,74 @@
/* eslint-env mocha */
'use strict'
const assert = require('assert')
const encodeUtf8 = require('./')
const testCases = [
'゚・✿ヾ╲(。◕‿◕。)╱✿・゚',
'𝌆',
'🐵 🙈 🙉 🙊',
'💩',
'åß∂ƒ©˙∆˚¬…æ',
'Hello, World!',
'Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗',
'𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌',
'사회과학원 어학연구소'
]
const badStrings = [
{
input: 'abc123',
expected: [0x61, 0x62, 0x63, 0x31, 0x32, 0x33],
name: 'Sanity check'
},
{
input: '\uD800',
expected: [0xef, 0xbf, 0xbd],
name: 'Surrogate half (low)'
},
{
input: '\uDC00',
expected: [0xef, 0xbf, 0xbd],
name: 'Surrogate half (high)'
},
{
input: 'abc\uD800123',
expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33],
name: 'Surrogate half (low), in a string'
},
{
input: 'abc\uDC00123',
expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33],
name: 'Surrogate half (high), in a string'
},
{
input: '\uDC00\uD800',
expected: [0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd],
name: 'Wrong order'
}
]
describe('encode-utf8', () => {
describe('test strings', () => {
for (const input of testCases) {
it(`should encode "${input}"`, () => {
const actual = Buffer.from(encodeUtf8(input))
const expected = Buffer.from(input, 'utf8')
assert.ok(actual.equals(expected))
})
}
})
describe('web platform test', () => {
for (const testCase of badStrings) {
it(testCase.name, () => {
const actual = Array.from(new Uint8Array(encodeUtf8(testCase.input)))
assert.deepStrictEqual(actual, testCase.expected)
})
}
})
})

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.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.

View File

@@ -0,0 +1,534 @@
# otplib
> Time-based (TOTP) and HMAC-based (HOTP) One-Time Password library
[![npm][badge-npm]][project-npm]
[![Build Status][badge-circle]][project-circle]
[![Coverage Status][badge-coveralls]][project-coveralls]
[![npm downloads][badge-npm-downloads]][project-npm]
[![TypeScript Support][badge-type-ts]][project-v-api]
---
<!-- TOC depthFrom:2 -->
- [About](#about)
- [Features](#features)
- [Quick Start](#quick-start)
- [In Node.js](#in-nodejs)
- [In Browser](#in-browser)
- [References](#references)
- [API / Demo Website](#api--demo-website)
- [Versioning](#versioning)
- [Migrating from v11.x](#migrating-from-v11x)
- [Available Options](#available-options)
- [HOTP Options](#hotp-options)
- [TOTP Options](#totp-options)
- [Authenticator Options](#authenticator-options)
- [Appendix](#appendix)
- [Type Definitions](#type-definitions)
- [Async Support](#async-support)
- [Browser Compatiblity](#browser-compatiblity)
- [Length of Secrets](#length-of-secrets)
- [Google Authenticator](#google-authenticator)
- [Difference between Authenticator and TOTP](#difference-between-authenticator-and-totp)
- [RFC3548 Base32](#rfc3548-base32)
- [Displaying a QR code](#displaying-a-qr-code)
- [Getting Time Remaining / Time Used](#getting-time-remaining--time-used)
- [Using with Expo](#using-with-expo)
- [Exploring with local-repl](#exploring-with-local-repl)
- [OTP Backup Codes](#otp-backup-codes)
- [Contributors](#contributors)
- [License](#license)
<!-- /TOC -->
## About
`otplib` is a JavaScript One Time Password (OTP) library for OTP generation and verification.
It implements both [HOTP][rfc-4226-wiki] - [RFC 4226][rfc-4226]
and [TOTP][rfc-6238-wiki] - [RFC 6238][rfc-6238],
and are tested against the test vectors provided in their respective RFC specifications.
These datasets can be found in the `tests/data` folder.
- [RFC 4226 Dataset][rfc-4226-dataset]
- [RFC 6238 Dataset][rfc-6238-dataset]
This library is also compatible with [Google Authenticator](https://github.com/google/google-authenticator),
and includes additional methods to allow you to work with Google Authenticator.
## Features
- Typescript support
- [Class][link-mdn-classes] interfaces
- [Function][link-mdn-functions] interfaces
- [Async][link-mdn-async] interfaces
- Pluggable modules (crypto / base32)
- `crypto (node)`
- `crypto-js`
- `@ronomon/crypto-async`
- `thirty-two`
- `base32-encode` + `base32-decode`
- Presets provided
- `browser`
- `default (node)`
- `default-async (same as default, but with async methods)`
- `v11 (adapter for previous version)`
## Quick Start
> If you need to customise your base32 or crypto libraries,
> check out the [In-Depth Guide][docs-in-depth] and [Available Packages][docs-available-packages]
### In Node.js
```bash
npm install otplib --save
```
```js
import { authenticator } from 'otplib';
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
// Alternative:
// const secret = authenticator.generateSecret();
// Note: .generateSecret() is only available for authenticator and not totp/hotp
const token = authenticator.generate(secret);
try {
const isValid = authenticator.check(token, secret);
// or
const isValid = authenticator.verify({ token, secret });
} catch (err) {
// Possible errors
// - options validation
// - "Invalid input - it is not base32 encoded string" (if thiry-two is used)
console.error(err);
}
```
Please replace "authenticator" with "totp" or "hotp" depending on your requirements.
```js
// For TOTP
import { totp } from 'otplib';
const token = totp.generate(secret);
const isValid = totp.check(token, secret);
const isValid = totp.verify({ token, secret });
// For HOTP
import { hotp } from 'otplib';
const token = hotp.generate(secret, counter);
const isValid = hotp.check(token, secret, counter);
const isValid = hotp.verify({ token, secret, counter });
```
For all available APIs, please refer to [API Documentation][project-v-api].
### In Browser
The browser preset is a self-contained `umd` module, and it is provided in a separate bundle.
```bash
npm install @otplib/preset-browser --save
```
The following is an example, where we are using the scripts hosted by `unpkg.com`.
```html
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/buffer.js"></script>
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/index.js"></script>
<script type="text/javascript">
// window.otplib.authenticator
// window.otplib.hotp
// window.otplib.totp
</script>
```
For more details, please refer to the [@otplib/preset-browser documentation][docs-preset-browser].
## References
### API / Demo Website
| Version | Links |
| --------------- | ----------------------------------------------------------------------------------- |
| v12.x | [Website][project-v-site] / [API][project-v-api] / [Readme][project-v-readme] |
| v11.x | [API][project-v11-api] / [Readme][project-v11-readme] |
| v10.x and below | Available via git history |
### Versioning
This library follows `semver`. As such, major version bumps usually mean API changes or behavior changes.
Please check [upgrade notes](https://github.com/yeojz/otplib/wiki/upgrade-notes) for more information,
especially before making any major upgrades.
To simplify releases, all packages within this repository have their versions synced.
Therefore, if there are any releases or updates to a package, we will bump all packages.
Check out the release notes associated with each tagged versions
in the [releases](https://github.com/yeojz/otplib/releases) page.
| Release Type | Version Pattern | Command | |
| :---------------- | --------------- | ------------------------- | :------------------------------------ |
| Current / Stable | 0.0.0 | `npm install otplib` | [![npm][badge-npm]][project-npm] |
| Release Candidate | 0.0.0-0 | `npm install otplib@next` | [![npm][badge-npm-next]][project-npm] |
### Migrating from v11.x
> v12.x is a huge architectural and language rewrite. Please check out the docs if you are migrating.
> A preset adapter is available to provide methods that behave like `v11.x` of `otplib`.
```js
// Update
import { authenticator } from 'otplib'; // v11.x
// to
import { authenticator } from '@otplib/preset-v11';
// There should be no changes to your current code.
// However, deprecated or modified class methods will have console.warn.
```
### Available Options
All instantiated classes will have their options inherited from their respective options
generator. i.e. HOTP from `hotpOptions`, TOTP from `totpOptions`
and Authenticator from `authenticatorOptions`.
All OTP classes have an object setter and getter method to override these default options.
For example,
```js
import { authenticator, totp, hotp } from 'otplib';
// setting
authenticator.options = { digits: 6 };
totp.options = { digits: 6 };
hotp.options = { digits: 6 };
// getting
const opts = authenticator.options;
const opts = totp.options;
const opts = hotp.options;
// reset to default
authenticator.resetOptions();
totp.resetOptions();
hotp.resetOptions();
// getting all options, with validation
// and backfilled with library defaults
const opts = authenticator.allOptions();
const opts = totp.allOptions();
const opts = hotp.allOptions();
```
#### HOTP Options
| Option | Type | Description |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
| algorithm | string | The algorithm used for calculating the HMAC. |
| createDigest | function | Creates the digest which token is derived from. |
| createHmacKey | function | Formats the secret into a HMAC key, applying transformations (like padding) where needed. |
| digest | string | **USE WITH CAUTION**. Same digest = same token. <br />Used in cases where digest is generated externally. (eg: async use cases) |
| digits | integer | The length of the token. |
| encoding | string | The encoding that was used on the secret. |
```js
// HOTP defaults
{
algorithm: 'sha1'
createDigest: undefined, // to be provided via a @otplib/plugin-*
createHmacKey: hotpCreateHmacKey,
digits: 6,
encoding: 'ascii',
}
```
#### TOTP Options
> Note: Includes all HOTP Options
| Option | Type | Description |
| ------ | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| epoch | integer | **USE WITH CAUTION**. Same epoch = same token. <br />Starting time since the UNIX epoch (seconds). <br /> Epoch is JavaScript formatted. i.e. `Date.now()` or `UNIX time * 1000` |
| step | integer | Time step (seconds) |
| window | integer, <br /> [number, number] | Tokens in the previous and future x-windows that should be considered valid. <br /> If integer, same value will be used for both. <br /> Alternatively, define array: `[past, future]` |
```js
// TOTP defaults
{
// ...includes all HOTP defaults
createHmacKey: totpCreateHmacKey,
epoch: Date.now(),
step: 30,
window: 0,
}
```
#### Authenticator Options
> Note: Includes all HOTP + TOTP Options
| Option | Type | Description |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| createRandomBytes | function | Creates a random string containing the defined number of bytes to be used in generating a secret key. |
| keyEncoder | function | Encodes a secret key into a Base32 string before it is sent to the user (in QR Code etc). |
| keyDecoder | function | Decodes the Base32 string given by the user into a secret. |
```js
// Authenticator defaults
{
// ...includes all HOTP + TOTP defaults
encoding: 'hex',
createRandomBytes: undefined, // to be provided via a @otplib/plugin-*
keyEncoder: undefined, // to be provided via a @otplib/plugin-*
keyDecoder: undefined, // to be provided via a @otplib/plugin-*
}
```
## Appendix
### Type Definitions
`TypeScript` support was introduced in `v10.0.0`, which added type definitions over `.js` files.
As of `v12.0.0`, the library has been re-written in Typescript from the ground up.
### Async Support
`async` support was introduced in `v12.0.0` as an additional core library.
This was added as some libraries like [expo.io][link-expo-crypto] or even
the browser API ([window.Crypto.subtle][link-mdn-subtlecrypto]) started providing
only async methods.
You to find more details in the [core-async][docs-core-async] folder.
### Browser Compatiblity
`@otplib/preset-browser` is a `umd` bundle with some node modules replaced to reduce the browser size.
The approximate size for the **optimised, minified + gzipped** bundle is **9.53KB**.
Paired with the gzipped browser `buffer.js` module, it would be about `7.65KB + 9.53KB = 17.18KB`.
For more details, please refer to the [@otplib/preset-browser documentation][docs-preset-browser].
### Length of Secrets
In [RFC 6238][rfc-6238], the secret / seed length for different algorithms are predefined:
```txt
HMAC-SHA1 - 20 bytes
HMAC-SHA256 - 32 bytes
HMAC-SHA512 - 64 bytes
```
As such, the length of the secret provided (after any decoding) will be padded and sliced
according to the expected length for respective algorithms.
### Google Authenticator
#### Difference between Authenticator and TOTP
The default encoding option has been set to `hex` (Authenticator) instead of `ascii` (TOTP).
#### RFC3548 Base32
> Note: [RFC4648][rfc-4648] obseletes [RFC 3548][rfc-3548].
> Any encoders following the newer specifications will work.
Google Authenticator requires keys to be base32 encoded.
It also requires the base32 encoder to be [RFC 3548][rfc-3548] compliant.
OTP calculation will still work should you want to use
other base32 encoding methods (like Crockford's Base32)
but it will NOT be compatible with Google Authenticator.
```js
const secret = authenticator.generateSecret(); // base32 encoded hex secret key
const token = authenticator.generate(secret);
```
#### Displaying a QR code
You may want to generate and display a QR Code so that users can scan
instead of manually entering the secret. Google Authenticator and similar apps
take in a QR code that holds a URL with the protocol `otpauth://`,
which you get from `authenticator.keyuri`.
Google Authenticator will ignore the `algorithm`, `digits`, and `step` options.
See the [keyuri documentation](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)
for more information.
If you are using a different authenticator app, check the documentation
for that app to see if any options are ignored, which will result in invalid tokens.
While this library provides the "otpauth" uri, you'll need a library to
generate the QR Code image.
An example is shown below:
```js
// npm install qrcode
import qrcode from 'qrcode';
import { authenticator } from '@otplib/preset-default';
const user = 'A user name, possibly an email';
const service = 'A service name';
// v11.x and above
const otpauth = authenticator.keyuri(user, service, secret);
// v10.x and below
const otpauth = authenticator.keyuri(
encodeURIComponent(user),
encodeURIComponent(service),
secret
);
qrcode.toDataURL(otpauth, (err, imageUrl) => {
if (err) {
console.log('Error with QR');
return;
}
console.log(imageUrl);
});
```
> **Note**: For versions `v10.x` and below, `keyuri` does not URI encode
> `user` and `service`. You'll need to do so before passing in the parameteres.
### Getting Time Remaining / Time Used
Helper methods for getting the remaining time and used time within a validity period
of a `totp` or `authenticator` token were introduced in `v10.0.0`.
```js
authenticator.timeUsed(); // or totp.timeUsed();
authenticator.timeRemaining(); // or totp.timeRemaining();
// The start of a new token would be when:
// - timeUsed() === 0
// - timeRemaining() === step
```
### Using with Expo
[Expo][link-expo-io] contains modified crypto implmentations targeted at the platform.
While `otplib` does not provide an `expo` specified package, with the re-architecture
of `otplib`, you can now provide an expo native `createDigest` to the library.
Alternatively, you can make use of crypto provided by `@otplib/plugin-crypto-js` or
the bundled browser umd module `@otplib/preset-browser`.
Pull Requests are much welcomed for a native expo implementation as well.
### Exploring with local-repl
If you'll like to explore the library with `local-repl` you can do so as well.
```bash
# after cloning the repo:
npm run setup
npm run build
npx local-repl
# You should see something like:
# Node v8.9.4, local-repl 4.0.0
# otplib 10.0.0
# Context: otplib
# [otplib] >
[otplib] > secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD'
[otplib] > otplib.authenticator.generate(secret)
```
### OTP Backup Codes
It is common for services to also provide a set of backup codes to authenticate
and bypass the OTP step in the event that you are not able to access your 2FA
device or have misplaced the device.
As this process is separate from the specifications for OTP, this library does not
provide any backup code related verification logic, and thus would have to be
implemented separately.
## Contributors
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/yeojz"><img src="https://avatars2.githubusercontent.com/u/429598?v=4" width="80px;" alt="Gerald Yeo"/><br /><sub><b>Gerald Yeo</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Code">💻</a> <a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Documentation">📖</a> <a href="#maintenance-yeojz" title="Maintenance">🚧</a> <a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Tests">⚠️</a></td>
<td align="center"><a href="https://ols.io"><img src="https://avatars3.githubusercontent.com/u/6209178?v=4" width="80px;" alt="Oliver Schneider"/><br /><sub><b>Oliver Schneider</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=olsio" title="Documentation">📖</a></td>
<td align="center"><a href="https://developer.mozilla.org/profiles/madarche/"><img src="https://avatars0.githubusercontent.com/u/152407?v=4" width="80px;" alt="Marc-Aurèle DARCHE"/><br /><sub><b>Marc-Aurèle DARCHE</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=madarche" title="Documentation">📖</a></td>
<td align="center"><a href="http://shakram02.github.io/"><img src="https://avatars3.githubusercontent.com/u/10996982?v=4" width="80px;" alt="Ahmed Hamdy (@shakram02)"/><br /><sub><b>Ahmed Hamdy (@shakram02)</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=shakram02" title="Documentation">📖</a></td>
<td align="center"><a href="https://tony.brix.ninja"><img src="https://avatars3.githubusercontent.com/u/97994?v=4" width="80px;" alt="Tony Brix"/><br /><sub><b>Tony Brix</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=UziTech" title="Code">💻</a> <a href="https://github.com/yeojz/otplib/commits?author=UziTech" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/encX"><img src="https://avatars3.githubusercontent.com/u/5965883?v=4" width="80px;" alt="Plai"/><br /><sub><b>Plai</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=encX" title="Documentation">📖</a></td>
</tr>
</table>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!
## License
`otplib` is [MIT licensed][project-license]
<img width="150" src="https://otplib.yeojz.dev/otplib.png" />
<!-- Badges -->
[badge-circle]: https://img.shields.io/circleci/project/github/yeojz/otplib/master.svg?style=flat-square
[badge-coveralls]: https://img.shields.io/coveralls/yeojz/otplib/master.svg?style=flat-square
[badge-npm-downloads]: https://img.shields.io/npm/dt/otplib.svg?style=flat-square
[badge-npm-next]: https://img.shields.io/npm/v/otplib/next.svg?style=flat-square
[badge-npm]: https://img.shields.io/npm/v/otplib.svg?style=flat-square
[badge-type-ts]: https://img.shields.io/badge/typedef-.d.ts-blue.svg?style=flat-square&longCache=true
<!-- External Links -->
[link-expo-crypto]: https://docs.expo.io/versions/v33.0.0/sdk/crypto/
[link-expo-io]: https://expo.io
[link-mdn-async]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
[link-mdn-classes]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
[link-mdn-functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
[link-mdn-subtlecrypto]: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
[link-npm-buffer]: https://www.npmjs.com/package/buffer
[rfc-3548]: http://tools.ietf.org/html/rfc3548
[rfc-4226-dataset]: https://github.com/yeojz/otplib/blob/master/tests/data/rfc-4226.ts
[rfc-4226-wiki]: http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm
[rfc-4226]: http://tools.ietf.org/html/rfc4226
[rfc-4648]: https://tools.ietf.org/html/rfc4648
[rfc-6238-dataset]: https://github.com/yeojz/otplib/blob/master/tests/data/rfc-6238.ts
[rfc-6238-wiki]: http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
[rfc-6238]: http://tools.ietf.org/html/rfc6238
<!-- Project Links -->
[docs-available-packages]: https://github.com/yeojz/otplib/blob/master/packages/README.md
[docs-core-async]: https://github.com/yeojz/otplib/blob/master/packages/otplib-core-async/README.md
[docs-in-depth]: https://github.com/yeojz/otplib/blob/master/packages/otplib-core/README.md#getting-started
[docs-preset-browser-src]: https://github.com/yeojz/otplib/blob/master/packages/otplib-preset-browser/src/index.ts
[docs-preset-browser]: https://github.com/yeojz/otplib/blob/master/packages/otplib-preset-browser/README.md
[project-circle]: https://circleci.com/gh/yeojz/otplib
[project-coveralls]: https://coveralls.io/github/yeojz/otplib
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-npm]: https://www.npmjs.com/package/otplib
[project-repo]: https://github.com/yeojz/otplib
[project-v-api]: https://otplib.yeojz.dev/api
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
[project-v11-api]: https://5d4d0cc4c85e00000788a456--otplib.netlify.com/docs
[project-v11-readme]: https://github.com/yeojz/otplib/blob/d0aedccbca8ae7ec1983f40da4d7a14c9e815e9c/README.md

View File

@@ -0,0 +1 @@
export * from '@otplib/core';

View File

@@ -0,0 +1,23 @@
/**
* otplib
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@otplib/core');
Object.keys(core).forEach(function (k) {
if (k !== 'default') Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return core[k];
}
});
});

View File

@@ -0,0 +1 @@
export * from '@otplib/preset-default';

View File

@@ -0,0 +1,23 @@
/**
* otplib
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var presetDefault = require('@otplib/preset-default');
Object.keys(presetDefault).forEach(function (k) {
if (k !== 'default') Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return presetDefault[k];
}
});
});

View File

@@ -0,0 +1,34 @@
{
"name": "otplib",
"description": "HMAC-based (HOTP) and Time-based (TOTP) One-Time Password library",
"version": "12.0.1",
"main": "./index.js",
"publishConfig": {
"access": "public"
},
"scripts": {},
"dependencies": {
"@otplib/core": "^12.0.1",
"@otplib/preset-default": "^12.0.1",
"@otplib/preset-v11": "^12.0.1"
},
"otplib": {},
"keywords": [
"totp",
"hotp",
"otp",
"authenticator",
"one time password",
"google authenticator",
"authentication",
"2FA",
"2 factor",
"node",
"browser"
],
"author": "Gerald Yeo <contact@fusedthought.com>",
"license": "MIT",
"homepage": "https://yeojz.otplib.dev",
"repository": "https://github.com/yeojz/otplib",
"types": "./index.d.ts"
}

View File

@@ -0,0 +1 @@
export * from '@otplib/preset-v11';

View File

@@ -0,0 +1,23 @@
/**
* otplib
*
* @author Gerald Yeo <contact@fusedthought.com>
* @version: 12.0.1
* @license: MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var presetV11 = require('@otplib/preset-v11');
Object.keys(presetV11).forEach(function (k) {
if (k !== 'default') Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return presetV11[k];
}
});
});

View File

@@ -0,0 +1,2 @@
/browser.js
/test/imagediff.js

View File

@@ -0,0 +1,19 @@
{
"parserOptions": { "ecmaVersion": 2018 },
"extends": ["eslint:recommended", "prettier"],
"env": {
"node": true,
"es6": true
},
"rules": {
"no-var": "error"
},
"overrides": [
{
"files": ["test/*.js", "examples/*.js"],
"rules": {
"no-console": "off"
}
}
]
}

View File

@@ -0,0 +1,3 @@
/browser.js
/test/imagediff.js
.nyc_output

View File

@@ -0,0 +1,20 @@
pngjs2 original work Copyright (c) 2015 Luke Page & Original Contributors
pngjs derived work Copyright (c) 2012 Kuba Niegowski
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.

View File

@@ -0,0 +1,429 @@
[![Build Status](https://travis-ci.com/lukeapage/pngjs.svg?branch=master)](https://travis-ci.com/lukeapage/pngjs) [![Build status](https://ci.appveyor.com/api/projects/status/qo5x8ayutr028108/branch/master?svg=true)](https://ci.appveyor.com/project/lukeapage/pngjs/branch/master) [![codecov](https://codecov.io/gh/lukeapage/pngjs/branch/master/graph/badge.svg)](https://codecov.io/gh/lukeapage/pngjs) [![npm version](https://badge.fury.io/js/pngjs.svg)](http://badge.fury.io/js/pngjs)
# pngjs
Simple PNG encoder/decoder for Node.js with no dependencies.
Based on the original [pngjs](https://github.com/niegowski/node-pngjs) with the follow enhancements.
- Support for reading 1,2,4 & 16 bit files
- Support for reading interlace files
- Support for reading `tTRNS` transparent colours
- Support for writing colortype 0 (grayscale), colortype 2 (RGB), colortype 4 (grayscale alpha) and colortype 6 (RGBA)
- Sync interface as well as async
- API compatible with pngjs and node-pngjs
Known lack of support for:
- Extended PNG e.g. Animation
- Writing in colortype 3 (indexed color)
# Table of Contents
- [Requirements](#requirements)
- [Comparison Table](#comparison-table)
- [Tests](#tests)
- [Installation](#installation)
- [Browser](#browser)
- [Example](#example)
- [Async API](#async-api)
- [Sync API](#sync-api)
- [Changelog](#changelog)
# Requirements
- Node.js v4 (use older v2.3.0 for 0.10/0.12/iojs support)
# Comparison Table
| Name | Forked From | Sync | Async | 16 Bit | 1/2/4 Bit | Interlace | Gamma | Encodes | Tested |
| ------------- | ----------- | ---- | ----- | ------ | --------- | --------- | ------ | ------- | ------ |
| pngjs | | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| node-png | pngjs | No | Yes | No | No | No | Hidden | Yes | Manual |
| png-coder | pngjs | No | Yes | Yes | No | No | Hidden | Yes | Manual |
| pngparse | | No | Yes | No | Yes | No | No | No | Yes |
| pngparse-sync | pngparse | Yes | No | No | Yes | No | No | No | Yes |
| png-async | | No | Yes | No | No | No | No | Yes | Yes |
| png-js | | No | Yes | No | No | No | No | No | No |
Native C++ node decoders:
- png
- png-sync (sync version of above)
- pixel-png
- png-img
# Tests
Tested using [PNG Suite](http://www.schaik.com/pngsuite/). We read every file into pngjs, output it in standard 8bit colour, synchronously and asynchronously, then compare the original with the newly saved images.
To run the tests, fetch the repo (tests are not distributed via npm) and install with `npm i`, run `npm test`.
The only thing not converted is gamma correction - this is because multiple vendors will do gamma correction differently, so the tests will have different results on different browsers.
In addition we use a tolerance of 3 for 16 bit images in PhantomJS because PhantomJS seems to have non-compliant rules for downscaling 16 bit images.
# Installation
```
$ npm install pngjs --save
```
# Browser
The package has been build with a [Browserify](browserify.org) version (`npm run browserify`) and you can use the browser version by including in your code:
```
import { PNG } from 'pngjs/browser';
```
# Example
```js
var fs = require("fs"),
PNG = require("pngjs").PNG;
fs.createReadStream("in.png")
.pipe(
new PNG({
filterType: 4,
})
)
.on("parsed", function () {
for (var y = 0; y < this.height; y++) {
for (var x = 0; x < this.width; x++) {
var idx = (this.width * y + x) << 2;
// invert color
this.data[idx] = 255 - this.data[idx];
this.data[idx + 1] = 255 - this.data[idx + 1];
this.data[idx + 2] = 255 - this.data[idx + 2];
// and reduce opacity
this.data[idx + 3] = this.data[idx + 3] >> 1;
}
}
this.pack().pipe(fs.createWriteStream("out.png"));
});
```
For more examples see `examples` folder.
# Async API
As input any color type is accepted (grayscale, rgb, palette, grayscale with alpha, rgb with alpha) but 8 bit per sample (channel) is the only supported bit depth. Interlaced mode is not supported.
## Class: PNG
`PNG` is readable and writable `Stream`.
### Options
- `width` - use this with `height` if you want to create png from scratch
- `height` - as above
- `checkCRC` - whether parser should be strict about checksums in source stream (default: `true`)
- `deflateChunkSize` - chunk size used for deflating data chunks, this should be power of 2 and must not be less than 256 and more than 32\*1024 (default: 32 kB)
- `deflateLevel` - compression level for deflate (default: 9)
- `deflateStrategy` - compression strategy for deflate (default: 3)
- `deflateFactory` - deflate stream factory (default: `zlib.createDeflate`)
- `filterType` - png filtering method for scanlines (default: -1 => auto, accepts array of numbers 0-4)
- `colorType` - the output colorType - see constants. 0 = grayscale, no alpha, 2 = color, no alpha, 4 = grayscale & alpha, 6 = color & alpha. Default currently 6, but in the future may calculate best mode.
- `inputColorType` - the input colorType - see constants. Default is 6 (RGBA)
- `bitDepth` - the bitDepth of the output, 8 or 16 bits. Input data is expected to have this bit depth.
16 bit data is expected in the system endianness (Default: 8)
- `inputHasAlpha` - whether the input bitmap has 4 bytes per pixel (rgb and alpha) or 3 (rgb - no alpha).
- `bgColor` - an object containing red, green, and blue values between 0 and 255
that is used when packing a PNG if alpha is not to be included (default: 255,255,255)
### Event "metadata"
`function(metadata) { }`
Image's header has been parsed, metadata contains this information:
- `width` image size in pixels
- `height` image size in pixels
- `palette` image is paletted
- `color` image is not grayscale
- `alpha` image contains alpha channel
- `interlace` image is interlaced
### Event: "parsed"
`function(data) { }`
Input image has been completely parsed, `data` is complete and ready for modification.
### Event: "error"
`function(error) { }`
### png.parse(data, [callback])
Parses PNG file data. Can be `String` or `Buffer`. Alternatively you can stream data to instance of PNG.
Optional `callback` is once called on `error` or `parsed`. The callback gets
two arguments `(err, data)`.
Returns `this` for method chaining.
#### Example
```js
new PNG({ filterType: 4 }).parse(imageData, function (error, data) {
console.log(error, data);
});
```
### png.pack()
Starts converting data to PNG file Stream.
Returns `this` for method chaining.
### png.bitblt(dst, sx, sy, w, h, dx, dy)
Helper for image manipulation, copies a rectangle of pixels from current (i.e. the source) image (`sx`, `sy`, `w`, `h`) to `dst` image (at `dx`, `dy`).
Returns `this` for method chaining.
For example, the following code copies the top-left 100x50 px of `in.png` into dst and writes it to `out.png`:
```js
var dst = new PNG({ width: 100, height: 50 });
fs.createReadStream("in.png")
.pipe(new PNG())
.on("parsed", function () {
this.bitblt(dst, 0, 0, 100, 50, 0, 0);
dst.pack().pipe(fs.createWriteStream("out.png"));
});
```
### Property: adjustGamma()
Helper that takes data and adjusts it to be gamma corrected. Note that it is not 100% reliable with transparent colours because that requires knowing the background colour the bitmap is rendered on to.
In tests against PNG suite it compared 100% with chrome on all 8 bit and below images. On IE there were some differences.
The following example reads a file, adjusts the gamma (which sets the gamma to 0) and writes it out again, effectively removing any gamma correction from the image.
```js
fs.createReadStream("in.png")
.pipe(new PNG())
.on("parsed", function () {
this.adjustGamma();
this.pack().pipe(fs.createWriteStream("out.png"));
});
```
### Property: width
Width of image in pixels
### Property: height
Height of image in pixels
### Property: data
Buffer of image pixel data. Every pixel consists 4 bytes: R, G, B, A (opacity).
### Property: gamma
Gamma of image (0 if not specified)
## Packing a PNG and removing alpha (RGBA to RGB)
When removing the alpha channel from an image, there needs to be a background color to correctly
convert each pixel's transparency to the appropriate RGB value. By default, pngjs will flatten
the image against a white background. You can override this in the options:
```js
var fs = require("fs"),
PNG = require("pngjs").PNG;
fs.createReadStream("in.png")
.pipe(
new PNG({
colorType: 2,
bgColor: {
red: 0,
green: 255,
blue: 0,
},
})
)
.on("parsed", function () {
this.pack().pipe(fs.createWriteStream("out.png"));
});
```
# Sync API
## PNG.sync
### PNG.sync.read(buffer)
Take a buffer and returns a PNG image. The properties on the image include the meta data and `data` as per the async API above.
```
var data = fs.readFileSync('in.png');
var png = PNG.sync.read(data);
```
### PNG.sync.write(png)
Take a PNG image and returns a buffer. The properties on the image include the meta data and `data` as per the async API above.
```
var data = fs.readFileSync('in.png');
var png = PNG.sync.read(data);
var options = { colorType: 6 };
var buffer = PNG.sync.write(png, options);
fs.writeFileSync('out.png', buffer);
```
### PNG.adjustGamma(src)
Adjusts the gamma of a sync image. See the async adjustGamma.
```
var data = fs.readFileSync('in.png');
var png = PNG.sync.read(data);
PNG.adjustGamma(png);
```
# Changelog
### 5.0.0 - 15/04/2020
- Drop support for Node 8
- Browserified bundle may now contain ES20(15-20) code if the supported node version supports it. Please run the browserified version through babel if you need to support older browsers.
### 4.0.1 - 15/04/2020
- Fix to possible null reference in nextTick of async method
### 4.0.0 - 09/04/2020
- Fix issue in newer nodes with using Buffer
- Fix async issue with some png files
- Drop support for Node 4 & 6
### 3.4.0 - 09/03/2019
- Include whether the png has alpha in the meta data
- emit an error if the image is truncated instead of hanging
- Add a browserified version
- speed up some mapping functions
### 3.3.3 - 19/04/2018
- Real fix for node 9
### 3.3.2 - 16/02/2018
- Fix for node 9
### 3.3.1 - 15/11/2017
- Bugfixes and removal of es6
### 3.3.0
- Add writing 16 bit channels and support for grayscale input
### 3.2.0 - 30/04/2017
- Support for encoding 8-bit grayscale images
### 3.1.0 - 30/04/2017
- Support for pngs with zlib chunks that are malformed after valid data
### 3.0.1 - 16/02/2017
- Fix single pixel pngs
### 3.0.0 - 03/08/2016
- Drop support for node below v4 and iojs. Pin to 2.3.0 to use with old, unsupported or patched node versions.
### 2.3.0 - 22/04/2016
- Support for sync in node 0.10
### 2.2.0 - 04/12/2015
- Add sync write api
- Fix newfile example
- Correct comparison table
### 2.1.0 - 28/10/2015
- rename package to pngjs
- added 'bgColor' option
### 2.0.0 - 08/10/2015
- fixes to readme
- _breaking change_ - bitblt on the png prototype now doesn't take a unused, unnecessary src first argument
### 1.2.0 - 13/09/2015
- support passing colorType to write PNG's and writing bitmaps without alpha information
### 1.1.0 - 07/09/2015
- support passing a deflate factory for controlled compression
### 1.0.2 - 22/08/2015
- Expose all PNG creation info
### 1.0.1 - 21/08/2015
- Fix non square interlaced files
### 1.0.0 - 08/08/2015
- More tests
- source linted
- maintainability refactorings
- async API - exceptions in reading now emit warnings
- documentation improvement - sync api now documented, adjustGamma documented
- breaking change - gamma chunk is now written. previously a read then write would destroy gamma information, now it is persisted.
### 0.0.3 - 03/08/2015
- Error handling fixes
- ignore files for smaller npm footprint
### 0.0.2 - 02/08/2015
- Bugfixes to interlacing, support for transparent colours
### 0.0.1 - 02/08/2015
- Initial release, see pngjs for older changelog.
# License
(The MIT License)
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.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,354 @@
body,
html {
margin: 0;
padding: 0;
height: 100%;
}
body {
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 14px;
color: #333;
}
.small {
font-size: 12px;
}
*,
*:after,
*:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
h1 {
font-size: 20px;
margin: 0;
}
h2 {
font-size: 14px;
}
pre {
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
margin: 0;
padding: 0;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
a {
color: #0074d9;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.strong {
font-weight: bold;
}
.space-top1 {
padding: 10px 0 0 0;
}
.pad2y {
padding: 20px 0;
}
.pad1y {
padding: 10px 0;
}
.pad2x {
padding: 0 20px;
}
.pad2 {
padding: 20px;
}
.pad1 {
padding: 10px;
}
.space-left2 {
padding-left: 55px;
}
.space-right2 {
padding-right: 20px;
}
.center {
text-align: center;
}
.clearfix {
display: block;
}
.clearfix:after {
content: "";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.fl {
float: left;
}
@media only screen and (max-width: 640px) {
.col3 {
width: 100%;
max-width: 100%;
}
.hide-mobile {
display: none !important;
}
}
.quiet {
color: #7f7f7f;
color: rgba(0, 0, 0, 0.5);
}
.quiet a {
opacity: 0.7;
}
.fraction {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 10px;
color: #555;
background: #e8e8e8;
padding: 4px 5px;
border-radius: 3px;
vertical-align: middle;
}
div.path a:link,
div.path a:visited {
color: #333;
}
table.coverage {
border-collapse: collapse;
margin: 10px 0 0 0;
padding: 0;
}
table.coverage td {
margin: 0;
padding: 0;
vertical-align: top;
}
table.coverage td.line-count {
text-align: right;
padding: 0 5px 0 20px;
}
table.coverage td.line-coverage {
text-align: right;
padding-right: 10px;
min-width: 20px;
}
table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 100%;
}
.missing-if-branch {
display: inline-block;
margin-right: 5px;
border-radius: 3px;
position: relative;
padding: 0 4px;
background: #333;
color: yellow;
}
.skip-if-branch {
display: none;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: #ccc;
color: white;
}
.missing-if-branch .typ,
.skip-if-branch .typ {
color: inherit !important;
}
.coverage-summary {
border-collapse: collapse;
width: 100%;
}
.coverage-summary tr {
border-bottom: 1px solid #bbb;
}
.keyline-all {
border: 1px solid #ddd;
}
.coverage-summary td,
.coverage-summary th {
padding: 10px;
}
.coverage-summary tbody {
border: 1px solid #bbb;
}
.coverage-summary td {
border-right: 1px solid #bbb;
}
.coverage-summary td:last-child {
border-right: none;
}
.coverage-summary th {
text-align: left;
font-weight: normal;
white-space: nowrap;
}
.coverage-summary th.file {
border-right: none !important;
}
.coverage-summary th.pct {
}
.coverage-summary th.pic,
.coverage-summary th.abs,
.coverage-summary td.pct,
.coverage-summary td.abs {
text-align: right;
}
.coverage-summary td.file {
white-space: nowrap;
}
.coverage-summary td.pic {
min-width: 120px !important;
}
.coverage-summary tfoot td {
}
.coverage-summary .sorter {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
}
.coverage-summary .sorted .sorter {
background-position: 0 -20px;
}
.coverage-summary .sorted-desc .sorter {
background-position: 0 -10px;
}
.status-line {
height: 10px;
}
/* yellow */
.cbranch-no {
background: yellow !important;
color: #111;
}
/* dark red */
.red.solid,
.status-line.low,
.low .cover-fill {
background: #c21f39;
}
.low .chart {
border: 1px solid #c21f39;
}
.highlighted,
.highlighted .cstat-no,
.highlighted .fstat-no,
.highlighted .cbranch-no {
background: #c21f39 !important;
}
/* medium red */
.cstat-no,
.fstat-no,
.cbranch-no,
.cbranch-no {
background: #f6c6ce;
}
/* light red */
.low,
.cline-no {
background: #fce1e5;
}
/* light green */
.high,
.cline-yes {
background: rgb(230, 245, 208);
}
/* medium green */
.cstat-yes {
background: rgb(161, 215, 106);
}
/* dark green */
.status-line.high,
.high .cover-fill {
background: rgb(77, 146, 33);
}
.high .chart {
border: 1px solid rgb(77, 146, 33);
}
/* dark yellow (gold) */
.status-line.medium,
.medium .cover-fill {
background: #f9cd0b;
}
.medium .chart {
border: 1px solid #f9cd0b;
}
/* light yellow */
.medium {
background: #fff4c2;
}
.cstat-skip {
background: #ddd;
color: #111;
}
.fstat-skip {
background: #ddd;
color: #111 !important;
}
.cbranch-skip {
background: #ddd !important;
color: #111;
}
span.cline-neutral {
background: #eaeaea;
}
.coverage-summary td.empty {
opacity: 0.5;
padding-top: 4px;
padding-bottom: 4px;
line-height: 1;
color: #888;
}
.cover-fill,
.cover-empty {
display: inline-block;
height: 12px;
}
.chart {
line-height: 0;
}
.cover-empty {
background: white;
}
.cover-full {
border-right: none !important;
}
pre.prettyprint {
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.com {
color: #999 !important;
}
.ignore-none {
color: #999;
font-weight: normal;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -48px;
}
.footer,
.push {
height: 48px;
}

View File

@@ -0,0 +1,881 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for bitmapper.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> bitmapper.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">94.37% </span>
<span class="quiet">Statements</span>
<span class='fraction'>134/142</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">72.41% </span>
<span class="quiet">Branches</span>
<span class='fraction'>21/29</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">89.47% </span>
<span class="quiet">Functions</span>
<span class='fraction'>17/19</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">94.16% </span>
<span class="quiet">Lines</span>
<span class='fraction'>129/137</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a>
<a name='L42'></a><a href='#L42'>42</a>
<a name='L43'></a><a href='#L43'>43</a>
<a name='L44'></a><a href='#L44'>44</a>
<a name='L45'></a><a href='#L45'>45</a>
<a name='L46'></a><a href='#L46'>46</a>
<a name='L47'></a><a href='#L47'>47</a>
<a name='L48'></a><a href='#L48'>48</a>
<a name='L49'></a><a href='#L49'>49</a>
<a name='L50'></a><a href='#L50'>50</a>
<a name='L51'></a><a href='#L51'>51</a>
<a name='L52'></a><a href='#L52'>52</a>
<a name='L53'></a><a href='#L53'>53</a>
<a name='L54'></a><a href='#L54'>54</a>
<a name='L55'></a><a href='#L55'>55</a>
<a name='L56'></a><a href='#L56'>56</a>
<a name='L57'></a><a href='#L57'>57</a>
<a name='L58'></a><a href='#L58'>58</a>
<a name='L59'></a><a href='#L59'>59</a>
<a name='L60'></a><a href='#L60'>60</a>
<a name='L61'></a><a href='#L61'>61</a>
<a name='L62'></a><a href='#L62'>62</a>
<a name='L63'></a><a href='#L63'>63</a>
<a name='L64'></a><a href='#L64'>64</a>
<a name='L65'></a><a href='#L65'>65</a>
<a name='L66'></a><a href='#L66'>66</a>
<a name='L67'></a><a href='#L67'>67</a>
<a name='L68'></a><a href='#L68'>68</a>
<a name='L69'></a><a href='#L69'>69</a>
<a name='L70'></a><a href='#L70'>70</a>
<a name='L71'></a><a href='#L71'>71</a>
<a name='L72'></a><a href='#L72'>72</a>
<a name='L73'></a><a href='#L73'>73</a>
<a name='L74'></a><a href='#L74'>74</a>
<a name='L75'></a><a href='#L75'>75</a>
<a name='L76'></a><a href='#L76'>76</a>
<a name='L77'></a><a href='#L77'>77</a>
<a name='L78'></a><a href='#L78'>78</a>
<a name='L79'></a><a href='#L79'>79</a>
<a name='L80'></a><a href='#L80'>80</a>
<a name='L81'></a><a href='#L81'>81</a>
<a name='L82'></a><a href='#L82'>82</a>
<a name='L83'></a><a href='#L83'>83</a>
<a name='L84'></a><a href='#L84'>84</a>
<a name='L85'></a><a href='#L85'>85</a>
<a name='L86'></a><a href='#L86'>86</a>
<a name='L87'></a><a href='#L87'>87</a>
<a name='L88'></a><a href='#L88'>88</a>
<a name='L89'></a><a href='#L89'>89</a>
<a name='L90'></a><a href='#L90'>90</a>
<a name='L91'></a><a href='#L91'>91</a>
<a name='L92'></a><a href='#L92'>92</a>
<a name='L93'></a><a href='#L93'>93</a>
<a name='L94'></a><a href='#L94'>94</a>
<a name='L95'></a><a href='#L95'>95</a>
<a name='L96'></a><a href='#L96'>96</a>
<a name='L97'></a><a href='#L97'>97</a>
<a name='L98'></a><a href='#L98'>98</a>
<a name='L99'></a><a href='#L99'>99</a>
<a name='L100'></a><a href='#L100'>100</a>
<a name='L101'></a><a href='#L101'>101</a>
<a name='L102'></a><a href='#L102'>102</a>
<a name='L103'></a><a href='#L103'>103</a>
<a name='L104'></a><a href='#L104'>104</a>
<a name='L105'></a><a href='#L105'>105</a>
<a name='L106'></a><a href='#L106'>106</a>
<a name='L107'></a><a href='#L107'>107</a>
<a name='L108'></a><a href='#L108'>108</a>
<a name='L109'></a><a href='#L109'>109</a>
<a name='L110'></a><a href='#L110'>110</a>
<a name='L111'></a><a href='#L111'>111</a>
<a name='L112'></a><a href='#L112'>112</a>
<a name='L113'></a><a href='#L113'>113</a>
<a name='L114'></a><a href='#L114'>114</a>
<a name='L115'></a><a href='#L115'>115</a>
<a name='L116'></a><a href='#L116'>116</a>
<a name='L117'></a><a href='#L117'>117</a>
<a name='L118'></a><a href='#L118'>118</a>
<a name='L119'></a><a href='#L119'>119</a>
<a name='L120'></a><a href='#L120'>120</a>
<a name='L121'></a><a href='#L121'>121</a>
<a name='L122'></a><a href='#L122'>122</a>
<a name='L123'></a><a href='#L123'>123</a>
<a name='L124'></a><a href='#L124'>124</a>
<a name='L125'></a><a href='#L125'>125</a>
<a name='L126'></a><a href='#L126'>126</a>
<a name='L127'></a><a href='#L127'>127</a>
<a name='L128'></a><a href='#L128'>128</a>
<a name='L129'></a><a href='#L129'>129</a>
<a name='L130'></a><a href='#L130'>130</a>
<a name='L131'></a><a href='#L131'>131</a>
<a name='L132'></a><a href='#L132'>132</a>
<a name='L133'></a><a href='#L133'>133</a>
<a name='L134'></a><a href='#L134'>134</a>
<a name='L135'></a><a href='#L135'>135</a>
<a name='L136'></a><a href='#L136'>136</a>
<a name='L137'></a><a href='#L137'>137</a>
<a name='L138'></a><a href='#L138'>138</a>
<a name='L139'></a><a href='#L139'>139</a>
<a name='L140'></a><a href='#L140'>140</a>
<a name='L141'></a><a href='#L141'>141</a>
<a name='L142'></a><a href='#L142'>142</a>
<a name='L143'></a><a href='#L143'>143</a>
<a name='L144'></a><a href='#L144'>144</a>
<a name='L145'></a><a href='#L145'>145</a>
<a name='L146'></a><a href='#L146'>146</a>
<a name='L147'></a><a href='#L147'>147</a>
<a name='L148'></a><a href='#L148'>148</a>
<a name='L149'></a><a href='#L149'>149</a>
<a name='L150'></a><a href='#L150'>150</a>
<a name='L151'></a><a href='#L151'>151</a>
<a name='L152'></a><a href='#L152'>152</a>
<a name='L153'></a><a href='#L153'>153</a>
<a name='L154'></a><a href='#L154'>154</a>
<a name='L155'></a><a href='#L155'>155</a>
<a name='L156'></a><a href='#L156'>156</a>
<a name='L157'></a><a href='#L157'>157</a>
<a name='L158'></a><a href='#L158'>158</a>
<a name='L159'></a><a href='#L159'>159</a>
<a name='L160'></a><a href='#L160'>160</a>
<a name='L161'></a><a href='#L161'>161</a>
<a name='L162'></a><a href='#L162'>162</a>
<a name='L163'></a><a href='#L163'>163</a>
<a name='L164'></a><a href='#L164'>164</a>
<a name='L165'></a><a href='#L165'>165</a>
<a name='L166'></a><a href='#L166'>166</a>
<a name='L167'></a><a href='#L167'>167</a>
<a name='L168'></a><a href='#L168'>168</a>
<a name='L169'></a><a href='#L169'>169</a>
<a name='L170'></a><a href='#L170'>170</a>
<a name='L171'></a><a href='#L171'>171</a>
<a name='L172'></a><a href='#L172'>172</a>
<a name='L173'></a><a href='#L173'>173</a>
<a name='L174'></a><a href='#L174'>174</a>
<a name='L175'></a><a href='#L175'>175</a>
<a name='L176'></a><a href='#L176'>176</a>
<a name='L177'></a><a href='#L177'>177</a>
<a name='L178'></a><a href='#L178'>178</a>
<a name='L179'></a><a href='#L179'>179</a>
<a name='L180'></a><a href='#L180'>180</a>
<a name='L181'></a><a href='#L181'>181</a>
<a name='L182'></a><a href='#L182'>182</a>
<a name='L183'></a><a href='#L183'>183</a>
<a name='L184'></a><a href='#L184'>184</a>
<a name='L185'></a><a href='#L185'>185</a>
<a name='L186'></a><a href='#L186'>186</a>
<a name='L187'></a><a href='#L187'>187</a>
<a name='L188'></a><a href='#L188'>188</a>
<a name='L189'></a><a href='#L189'>189</a>
<a name='L190'></a><a href='#L190'>190</a>
<a name='L191'></a><a href='#L191'>191</a>
<a name='L192'></a><a href='#L192'>192</a>
<a name='L193'></a><a href='#L193'>193</a>
<a name='L194'></a><a href='#L194'>194</a>
<a name='L195'></a><a href='#L195'>195</a>
<a name='L196'></a><a href='#L196'>196</a>
<a name='L197'></a><a href='#L197'>197</a>
<a name='L198'></a><a href='#L198'>198</a>
<a name='L199'></a><a href='#L199'>199</a>
<a name='L200'></a><a href='#L200'>200</a>
<a name='L201'></a><a href='#L201'>201</a>
<a name='L202'></a><a href='#L202'>202</a>
<a name='L203'></a><a href='#L203'>203</a>
<a name='L204'></a><a href='#L204'>204</a>
<a name='L205'></a><a href='#L205'>205</a>
<a name='L206'></a><a href='#L206'>206</a>
<a name='L207'></a><a href='#L207'>207</a>
<a name='L208'></a><a href='#L208'>208</a>
<a name='L209'></a><a href='#L209'>209</a>
<a name='L210'></a><a href='#L210'>210</a>
<a name='L211'></a><a href='#L211'>211</a>
<a name='L212'></a><a href='#L212'>212</a>
<a name='L213'></a><a href='#L213'>213</a>
<a name='L214'></a><a href='#L214'>214</a>
<a name='L215'></a><a href='#L215'>215</a>
<a name='L216'></a><a href='#L216'>216</a>
<a name='L217'></a><a href='#L217'>217</a>
<a name='L218'></a><a href='#L218'>218</a>
<a name='L219'></a><a href='#L219'>219</a>
<a name='L220'></a><a href='#L220'>220</a>
<a name='L221'></a><a href='#L221'>221</a>
<a name='L222'></a><a href='#L222'>222</a>
<a name='L223'></a><a href='#L223'>223</a>
<a name='L224'></a><a href='#L224'>224</a>
<a name='L225'></a><a href='#L225'>225</a>
<a name='L226'></a><a href='#L226'>226</a>
<a name='L227'></a><a href='#L227'>227</a>
<a name='L228'></a><a href='#L228'>228</a>
<a name='L229'></a><a href='#L229'>229</a>
<a name='L230'></a><a href='#L230'>230</a>
<a name='L231'></a><a href='#L231'>231</a>
<a name='L232'></a><a href='#L232'>232</a>
<a name='L233'></a><a href='#L233'>233</a>
<a name='L234'></a><a href='#L234'>234</a>
<a name='L235'></a><a href='#L235'>235</a>
<a name='L236'></a><a href='#L236'>236</a>
<a name='L237'></a><a href='#L237'>237</a>
<a name='L238'></a><a href='#L238'>238</a>
<a name='L239'></a><a href='#L239'>239</a>
<a name='L240'></a><a href='#L240'>240</a>
<a name='L241'></a><a href='#L241'>241</a>
<a name='L242'></a><a href='#L242'>242</a>
<a name='L243'></a><a href='#L243'>243</a>
<a name='L244'></a><a href='#L244'>244</a>
<a name='L245'></a><a href='#L245'>245</a>
<a name='L246'></a><a href='#L246'>246</a>
<a name='L247'></a><a href='#L247'>247</a>
<a name='L248'></a><a href='#L248'>248</a>
<a name='L249'></a><a href='#L249'>249</a>
<a name='L250'></a><a href='#L250'>250</a>
<a name='L251'></a><a href='#L251'>251</a>
<a name='L252'></a><a href='#L252'>252</a>
<a name='L253'></a><a href='#L253'>253</a>
<a name='L254'></a><a href='#L254'>254</a>
<a name='L255'></a><a href='#L255'>255</a>
<a name='L256'></a><a href='#L256'>256</a>
<a name='L257'></a><a href='#L257'>257</a>
<a name='L258'></a><a href='#L258'>258</a>
<a name='L259'></a><a href='#L259'>259</a>
<a name='L260'></a><a href='#L260'>260</a>
<a name='L261'></a><a href='#L261'>261</a>
<a name='L262'></a><a href='#L262'>262</a>
<a name='L263'></a><a href='#L263'>263</a>
<a name='L264'></a><a href='#L264'>264</a>
<a name='L265'></a><a href='#L265'>265</a>
<a name='L266'></a><a href='#L266'>266</a>
<a name='L267'></a><a href='#L267'>267</a>
<a name='L268'></a><a href='#L268'>268</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-yes">313632x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1228160x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1228160x</span>
<span class="cline-any cline-yes">1228160x</span>
<span class="cline-any cline-yes">1228160x</span>
<span class="cline-any cline-yes">1228160x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">272640x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">272640x</span>
<span class="cline-any cline-yes">272640x</span>
<span class="cline-any cline-yes">272640x</span>
<span class="cline-any cline-yes">272640x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1193380x</span>
<span class="cline-any cline-yes">1193380x</span>
<span class="cline-any cline-yes">1193380x</span>
<span class="cline-any cline-yes">1193380x</span>
<span class="cline-any cline-yes">1193380x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">24576x</span>
<span class="cline-any cline-yes">24576x</span>
<span class="cline-any cline-yes">24576x</span>
<span class="cline-any cline-yes">24576x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-yes">8192x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">334250x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">334250x</span>
<span class="cline-any cline-yes">334250x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">334250x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">149504x</span>
<span class="cline-any cline-yes">149504x</span>
<span class="cline-any cline-yes">149504x</span>
<span class="cline-any cline-yes">149504x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">49612x</span>
<span class="cline-any cline-yes">49612x</span>
<span class="cline-any cline-yes">49612x</span>
<span class="cline-any cline-yes">49612x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-yes">2968x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-yes">132166x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-yes">334250x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8106x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-yes">7288x</span>
<span class="cline-any cline-yes">1822624x</span>
<span class="cline-any cline-yes">1822624x</span>
<span class="cline-any cline-yes">1822624x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">8106x</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-yes">1234340x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8106x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">269x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">66x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">72x</span>
<span class="cline-any cline-yes">72x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">263x</span>
<span class="cline-any cline-yes">263x</span>
<span class="cline-any cline-yes">2732114x</span>
<span class="cline-any cline-yes">2732114x</span>
<span class="cline-any cline-yes">2732114x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">263x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">739x</span>
<span class="cline-any cline-yes">210x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">209x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">335x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
let interlaceUtils = require("./interlace");
&nbsp;
let pixelBppMapper = [
// 0 - dummy entry
<span class="fstat-no" title="function not covered" > fu</span>nction () {},
&nbsp;
// 1 - L
// 0: 0, 1: 0, 2: 0, 3: 0xff
function (pxData, data, pxPos, rawPos) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (rawPos === data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("Ran out of data");</span>
}
&nbsp;
let pixel = data[rawPos];
pxData[pxPos] = pixel;
pxData[pxPos + 1] = pixel;
pxData[pxPos + 2] = pixel;
pxData[pxPos + 3] = 0xff;
},
&nbsp;
// 2 - LA
// 0: 0, 1: 0, 2: 0, 3: 1
function (pxData, data, pxPos, rawPos) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (rawPos + 1 &gt;= data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("Ran out of data");</span>
}
&nbsp;
let pixel = data[rawPos];
pxData[pxPos] = pixel;
pxData[pxPos + 1] = pixel;
pxData[pxPos + 2] = pixel;
pxData[pxPos + 3] = data[rawPos + 1];
},
&nbsp;
// 3 - RGB
// 0: 0, 1: 1, 2: 2, 3: 0xff
function (pxData, data, pxPos, rawPos) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (rawPos + 2 &gt;= data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("Ran out of data");</span>
}
&nbsp;
pxData[pxPos] = data[rawPos];
pxData[pxPos + 1] = data[rawPos + 1];
pxData[pxPos + 2] = data[rawPos + 2];
pxData[pxPos + 3] = 0xff;
},
&nbsp;
// 4 - RGBA
// 0: 0, 1: 1, 2: 2, 3: 3
function (pxData, data, pxPos, rawPos) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (rawPos + 3 &gt;= data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("Ran out of data");</span>
}
&nbsp;
pxData[pxPos] = data[rawPos];
pxData[pxPos + 1] = data[rawPos + 1];
pxData[pxPos + 2] = data[rawPos + 2];
pxData[pxPos + 3] = data[rawPos + 3];
},
];
&nbsp;
let pixelBppCustomMapper = [
// 0 - dummy entry
<span class="fstat-no" title="function not covered" > fu</span>nction () {},
&nbsp;
// 1 - L
// 0: 0, 1: 0, 2: 0, 3: 0xff
function (pxData, pixelData, pxPos, maxBit) {
let pixel = pixelData[0];
pxData[pxPos] = pixel;
pxData[pxPos + 1] = pixel;
pxData[pxPos + 2] = pixel;
pxData[pxPos + 3] = maxBit;
},
&nbsp;
// 2 - LA
// 0: 0, 1: 0, 2: 0, 3: 1
function (pxData, pixelData, pxPos) {
let pixel = pixelData[0];
pxData[pxPos] = pixel;
pxData[pxPos + 1] = pixel;
pxData[pxPos + 2] = pixel;
pxData[pxPos + 3] = pixelData[1];
},
&nbsp;
// 3 - RGB
// 0: 0, 1: 1, 2: 2, 3: 0xff
function (pxData, pixelData, pxPos, maxBit) {
pxData[pxPos] = pixelData[0];
pxData[pxPos + 1] = pixelData[1];
pxData[pxPos + 2] = pixelData[2];
pxData[pxPos + 3] = maxBit;
},
&nbsp;
// 4 - RGBA
// 0: 0, 1: 1, 2: 2, 3: 3
function (pxData, pixelData, pxPos) {
pxData[pxPos] = pixelData[0];
pxData[pxPos + 1] = pixelData[1];
pxData[pxPos + 2] = pixelData[2];
pxData[pxPos + 3] = pixelData[3];
},
];
&nbsp;
function bitRetriever(data, depth) {
let leftOver = [];
let i = 0;
&nbsp;
function split() {
<span class="missing-if-branch" title="if path not taken" >I</span>if (i === data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("Ran out of data");</span>
}
let byte = data[i];
i++;
let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;
switch (depth) {
<span class="branch-0 cbranch-no" title="branch not covered" > default:</span>
<span class="cstat-no" title="statement not covered" > throw new Error("unrecognised depth");</span>
case 16:
byte2 = data[i];
i++;
leftOver.push((byte &lt;&lt; 8) + byte2);
break;
case 4:
byte2 = byte &amp; 0x0f;
byte1 = byte &gt;&gt; 4;
leftOver.push(byte1, byte2);
break;
case 2:
byte4 = byte &amp; 3;
byte3 = (byte &gt;&gt; 2) &amp; 3;
byte2 = (byte &gt;&gt; 4) &amp; 3;
byte1 = (byte &gt;&gt; 6) &amp; 3;
leftOver.push(byte1, byte2, byte3, byte4);
break;
case 1:
byte8 = byte &amp; 1;
byte7 = (byte &gt;&gt; 1) &amp; 1;
byte6 = (byte &gt;&gt; 2) &amp; 1;
byte5 = (byte &gt;&gt; 3) &amp; 1;
byte4 = (byte &gt;&gt; 4) &amp; 1;
byte3 = (byte &gt;&gt; 5) &amp; 1;
byte2 = (byte &gt;&gt; 6) &amp; 1;
byte1 = (byte &gt;&gt; 7) &amp; 1;
leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8);
break;
}
}
&nbsp;
return {
get: function (count) {
while (leftOver.length &lt; count) {
split();
}
let returner = leftOver.slice(0, count);
leftOver = leftOver.slice(count);
return returner;
},
resetAfterLine: function () {
leftOver.length = 0;
},
end: function () {
<span class="missing-if-branch" title="if path not taken" >I</span>if (i !== data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("extra data found");</span>
}
},
};
}
&nbsp;
function mapImage8Bit(image, pxData, getPxPos, bpp, data, rawPos) {
// eslint-disable-line max-params
let imageWidth = image.width;
let imageHeight = image.height;
let imagePass = image.index;
for (let y = 0; y &lt; imageHeight; y++) {
for (let x = 0; x &lt; imageWidth; x++) {
let pxPos = getPxPos(x, y, imagePass);
pixelBppMapper[bpp](pxData, data, pxPos, rawPos);
rawPos += bpp; //eslint-disable-line no-param-reassign
}
}
return rawPos;
}
&nbsp;
function mapImageCustomBit(image, pxData, getPxPos, bpp, bits, maxBit) {
// eslint-disable-line max-params
let imageWidth = image.width;
let imageHeight = image.height;
let imagePass = image.index;
for (let y = 0; y &lt; imageHeight; y++) {
for (let x = 0; x &lt; imageWidth; x++) {
let pixelData = bits.get(bpp);
let pxPos = getPxPos(x, y, imagePass);
pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit);
}
bits.resetAfterLine();
}
}
&nbsp;
exports.dataToBitMap = function (data, bitmapInfo) {
let width = bitmapInfo.width;
let height = bitmapInfo.height;
let depth = bitmapInfo.depth;
let bpp = bitmapInfo.bpp;
let interlace = bitmapInfo.interlace;
let bits;
&nbsp;
if (depth !== 8) {
bits = bitRetriever(data, depth);
}
let pxData;
if (depth &lt;= 8) {
pxData = Buffer.alloc(width * height * 4);
} else {
pxData = new Uint16Array(width * height * 4);
}
let maxBit = Math.pow(2, depth) - 1;
let rawPos = 0;
let images;
let getPxPos;
&nbsp;
if (interlace) {
images = interlaceUtils.getImagePasses(width, height);
getPxPos = interlaceUtils.getInterlaceIterator(width, height);
} else {
let nonInterlacedPxPos = 0;
getPxPos = function () {
let returner = nonInterlacedPxPos;
nonInterlacedPxPos += 4;
return returner;
};
images = [{ width: width, height: height }];
}
&nbsp;
for (let imageIndex = 0; imageIndex &lt; images.length; imageIndex++) {
if (depth === 8) {
rawPos = mapImage8Bit(
images[imageIndex],
pxData,
getPxPos,
bpp,
data,
rawPos
);
} else {
mapImageCustomBit(
images[imageIndex],
pxData,
getPxPos,
bpp,
bits,
maxBit
);
}
}
if (depth === 8) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (rawPos !== data.length) {
<span class="cstat-no" title="statement not covered" > throw new Error("extra data found");</span>
}
} else {
bits.end();
}
&nbsp;
return pxData;
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

View File

@@ -0,0 +1,554 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for bitpacker.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> bitpacker.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">11.36% </span>
<span class="quiet">Statements</span>
<span class='fraction'>10/88</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">6.12% </span>
<span class="quiet">Branches</span>
<span class='fraction'>3/49</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">66.67% </span>
<span class="quiet">Functions</span>
<span class='fraction'>2/3</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">11.63% </span>
<span class="quiet">Lines</span>
<span class='fraction'>10/86</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a>
<a name='L42'></a><a href='#L42'>42</a>
<a name='L43'></a><a href='#L43'>43</a>
<a name='L44'></a><a href='#L44'>44</a>
<a name='L45'></a><a href='#L45'>45</a>
<a name='L46'></a><a href='#L46'>46</a>
<a name='L47'></a><a href='#L47'>47</a>
<a name='L48'></a><a href='#L48'>48</a>
<a name='L49'></a><a href='#L49'>49</a>
<a name='L50'></a><a href='#L50'>50</a>
<a name='L51'></a><a href='#L51'>51</a>
<a name='L52'></a><a href='#L52'>52</a>
<a name='L53'></a><a href='#L53'>53</a>
<a name='L54'></a><a href='#L54'>54</a>
<a name='L55'></a><a href='#L55'>55</a>
<a name='L56'></a><a href='#L56'>56</a>
<a name='L57'></a><a href='#L57'>57</a>
<a name='L58'></a><a href='#L58'>58</a>
<a name='L59'></a><a href='#L59'>59</a>
<a name='L60'></a><a href='#L60'>60</a>
<a name='L61'></a><a href='#L61'>61</a>
<a name='L62'></a><a href='#L62'>62</a>
<a name='L63'></a><a href='#L63'>63</a>
<a name='L64'></a><a href='#L64'>64</a>
<a name='L65'></a><a href='#L65'>65</a>
<a name='L66'></a><a href='#L66'>66</a>
<a name='L67'></a><a href='#L67'>67</a>
<a name='L68'></a><a href='#L68'>68</a>
<a name='L69'></a><a href='#L69'>69</a>
<a name='L70'></a><a href='#L70'>70</a>
<a name='L71'></a><a href='#L71'>71</a>
<a name='L72'></a><a href='#L72'>72</a>
<a name='L73'></a><a href='#L73'>73</a>
<a name='L74'></a><a href='#L74'>74</a>
<a name='L75'></a><a href='#L75'>75</a>
<a name='L76'></a><a href='#L76'>76</a>
<a name='L77'></a><a href='#L77'>77</a>
<a name='L78'></a><a href='#L78'>78</a>
<a name='L79'></a><a href='#L79'>79</a>
<a name='L80'></a><a href='#L80'>80</a>
<a name='L81'></a><a href='#L81'>81</a>
<a name='L82'></a><a href='#L82'>82</a>
<a name='L83'></a><a href='#L83'>83</a>
<a name='L84'></a><a href='#L84'>84</a>
<a name='L85'></a><a href='#L85'>85</a>
<a name='L86'></a><a href='#L86'>86</a>
<a name='L87'></a><a href='#L87'>87</a>
<a name='L88'></a><a href='#L88'>88</a>
<a name='L89'></a><a href='#L89'>89</a>
<a name='L90'></a><a href='#L90'>90</a>
<a name='L91'></a><a href='#L91'>91</a>
<a name='L92'></a><a href='#L92'>92</a>
<a name='L93'></a><a href='#L93'>93</a>
<a name='L94'></a><a href='#L94'>94</a>
<a name='L95'></a><a href='#L95'>95</a>
<a name='L96'></a><a href='#L96'>96</a>
<a name='L97'></a><a href='#L97'>97</a>
<a name='L98'></a><a href='#L98'>98</a>
<a name='L99'></a><a href='#L99'>99</a>
<a name='L100'></a><a href='#L100'>100</a>
<a name='L101'></a><a href='#L101'>101</a>
<a name='L102'></a><a href='#L102'>102</a>
<a name='L103'></a><a href='#L103'>103</a>
<a name='L104'></a><a href='#L104'>104</a>
<a name='L105'></a><a href='#L105'>105</a>
<a name='L106'></a><a href='#L106'>106</a>
<a name='L107'></a><a href='#L107'>107</a>
<a name='L108'></a><a href='#L108'>108</a>
<a name='L109'></a><a href='#L109'>109</a>
<a name='L110'></a><a href='#L110'>110</a>
<a name='L111'></a><a href='#L111'>111</a>
<a name='L112'></a><a href='#L112'>112</a>
<a name='L113'></a><a href='#L113'>113</a>
<a name='L114'></a><a href='#L114'>114</a>
<a name='L115'></a><a href='#L115'>115</a>
<a name='L116'></a><a href='#L116'>116</a>
<a name='L117'></a><a href='#L117'>117</a>
<a name='L118'></a><a href='#L118'>118</a>
<a name='L119'></a><a href='#L119'>119</a>
<a name='L120'></a><a href='#L120'>120</a>
<a name='L121'></a><a href='#L121'>121</a>
<a name='L122'></a><a href='#L122'>122</a>
<a name='L123'></a><a href='#L123'>123</a>
<a name='L124'></a><a href='#L124'>124</a>
<a name='L125'></a><a href='#L125'>125</a>
<a name='L126'></a><a href='#L126'>126</a>
<a name='L127'></a><a href='#L127'>127</a>
<a name='L128'></a><a href='#L128'>128</a>
<a name='L129'></a><a href='#L129'>129</a>
<a name='L130'></a><a href='#L130'>130</a>
<a name='L131'></a><a href='#L131'>131</a>
<a name='L132'></a><a href='#L132'>132</a>
<a name='L133'></a><a href='#L133'>133</a>
<a name='L134'></a><a href='#L134'>134</a>
<a name='L135'></a><a href='#L135'>135</a>
<a name='L136'></a><a href='#L136'>136</a>
<a name='L137'></a><a href='#L137'>137</a>
<a name='L138'></a><a href='#L138'>138</a>
<a name='L139'></a><a href='#L139'>139</a>
<a name='L140'></a><a href='#L140'>140</a>
<a name='L141'></a><a href='#L141'>141</a>
<a name='L142'></a><a href='#L142'>142</a>
<a name='L143'></a><a href='#L143'>143</a>
<a name='L144'></a><a href='#L144'>144</a>
<a name='L145'></a><a href='#L145'>145</a>
<a name='L146'></a><a href='#L146'>146</a>
<a name='L147'></a><a href='#L147'>147</a>
<a name='L148'></a><a href='#L148'>148</a>
<a name='L149'></a><a href='#L149'>149</a>
<a name='L150'></a><a href='#L150'>150</a>
<a name='L151'></a><a href='#L151'>151</a>
<a name='L152'></a><a href='#L152'>152</a>
<a name='L153'></a><a href='#L153'>153</a>
<a name='L154'></a><a href='#L154'>154</a>
<a name='L155'></a><a href='#L155'>155</a>
<a name='L156'></a><a href='#L156'>156</a>
<a name='L157'></a><a href='#L157'>157</a>
<a name='L158'></a><a href='#L158'>158</a>
<a name='L159'></a><a href='#L159'>159</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
let constants = require("./constants");
&nbsp;
module.exports = function (dataIn, width, height, options) {
let outHasAlpha =
[constants.COLORTYPE_COLOR_ALPHA, constants.COLORTYPE_ALPHA].indexOf(
options.colorType
) !== -1;
<span class="missing-if-branch" title="else path not taken" >E</span>if (options.colorType === options.inputColorType) {
let bigEndian = (function () {
let buffer = new ArrayBuffer(2);
new DataView(buffer).setInt16(0, 256, true /* littleEndian */);
// Int16Array uses the platform's endianness.
return new Int16Array(buffer)[0] !== 256;
})();
// If no need to convert to grayscale and alpha is present/absent in both, take a fast route
<span class="missing-if-branch" title="else path not taken" >E</span>if (options.bitDepth === 8 || (<span class="branch-1 cbranch-no" title="branch not covered" >options.bitDepth === 16 </span>&amp;&amp; <span class="branch-2 cbranch-no" title="branch not covered" >bigEndian)</span>) {
return dataIn;
}
}
&nbsp;
// map to a UInt16 array if data is 16bit, fix endianness below
let data = <span class="cstat-no" title="statement not covered" >options.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer);</span>
&nbsp;
let maxValue = <span class="cstat-no" title="statement not covered" >255;</span>
let inBpp = <span class="cstat-no" title="statement not covered" >constants.COLORTYPE_TO_BPP_MAP[options.inputColorType];</span>
<span class="cstat-no" title="statement not covered" > if (inBpp === 4 &amp;&amp; !options.inputHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > inBpp = 3;</span>
}
let outBpp = <span class="cstat-no" title="statement not covered" >constants.COLORTYPE_TO_BPP_MAP[options.colorType];</span>
<span class="cstat-no" title="statement not covered" > if (options.bitDepth === 16) {</span>
<span class="cstat-no" title="statement not covered" > maxValue = 65535;</span>
<span class="cstat-no" title="statement not covered" > outBpp *= 2;</span>
}
let outData = <span class="cstat-no" title="statement not covered" >Buffer.alloc(width * height * outBpp);</span>
&nbsp;
let inIndex = <span class="cstat-no" title="statement not covered" >0;</span>
let outIndex = <span class="cstat-no" title="statement not covered" >0;</span>
&nbsp;
let bgColor = <span class="cstat-no" title="statement not covered" >options.bgColor || {};</span>
<span class="cstat-no" title="statement not covered" > if (bgColor.red === undefined) {</span>
<span class="cstat-no" title="statement not covered" > bgColor.red = maxValue;</span>
}
<span class="cstat-no" title="statement not covered" > if (bgColor.green === undefined) {</span>
<span class="cstat-no" title="statement not covered" > bgColor.green = maxValue;</span>
}
<span class="cstat-no" title="statement not covered" > if (bgColor.blue === undefined) {</span>
<span class="cstat-no" title="statement not covered" > bgColor.blue = maxValue;</span>
}
&nbsp;
function <span class="fstat-no" title="function not covered" >getRGBA(</span>) {
let red;
let green;
let blue;
let alpha = <span class="cstat-no" title="statement not covered" >maxValue;</span>
<span class="cstat-no" title="statement not covered" > switch (options.inputColorType) {</span>
case constants.COLORTYPE_COLOR_ALPHA:
<span class="cstat-no" title="statement not covered" > alpha = data[inIndex + 3];</span>
<span class="cstat-no" title="statement not covered" > red = data[inIndex];</span>
<span class="cstat-no" title="statement not covered" > green = data[inIndex + 1];</span>
<span class="cstat-no" title="statement not covered" > blue = data[inIndex + 2];</span>
<span class="cstat-no" title="statement not covered" > break;</span>
case constants.COLORTYPE_COLOR:
<span class="cstat-no" title="statement not covered" > red = data[inIndex];</span>
<span class="cstat-no" title="statement not covered" > green = data[inIndex + 1];</span>
<span class="cstat-no" title="statement not covered" > blue = data[inIndex + 2];</span>
<span class="cstat-no" title="statement not covered" > break;</span>
case constants.COLORTYPE_ALPHA:
<span class="cstat-no" title="statement not covered" > alpha = data[inIndex + 1];</span>
<span class="cstat-no" title="statement not covered" > red = data[inIndex];</span>
<span class="cstat-no" title="statement not covered" > green = red;</span>
<span class="cstat-no" title="statement not covered" > blue = red;</span>
<span class="cstat-no" title="statement not covered" > break;</span>
case constants.COLORTYPE_GRAYSCALE:
<span class="cstat-no" title="statement not covered" > red = data[inIndex];</span>
<span class="cstat-no" title="statement not covered" > green = red;</span>
<span class="cstat-no" title="statement not covered" > blue = red;</span>
<span class="cstat-no" title="statement not covered" > break;</span>
default:
<span class="cstat-no" title="statement not covered" > throw new Error(</span>
"input color type:" +
options.inputColorType +
" is not supported at present"
);
}
&nbsp;
<span class="cstat-no" title="statement not covered" > if (options.inputHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > if (!outHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > alpha /= maxValue;</span>
<span class="cstat-no" title="statement not covered" > red = Math.min(</span>
Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0),
maxValue
);
<span class="cstat-no" title="statement not covered" > green = Math.min(</span>
Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0),
maxValue
);
<span class="cstat-no" title="statement not covered" > blue = Math.min(</span>
Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0),
maxValue
);
}
}
<span class="cstat-no" title="statement not covered" > return { red: red, green: green, blue: blue, alpha: alpha };</span>
}
&nbsp;
<span class="cstat-no" title="statement not covered" > for (let y = <span class="cstat-no" title="statement not covered" >0;</span> y &lt; height; y++) {</span>
<span class="cstat-no" title="statement not covered" > for (let x = <span class="cstat-no" title="statement not covered" >0;</span> x &lt; width; x++) {</span>
let rgba = <span class="cstat-no" title="statement not covered" >getRGBA(data, inIndex);</span>
&nbsp;
<span class="cstat-no" title="statement not covered" > switch (options.colorType) {</span>
case constants.COLORTYPE_COLOR_ALPHA:
case constants.COLORTYPE_COLOR:
<span class="cstat-no" title="statement not covered" > if (options.bitDepth === 8) {</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex] = rgba.red;</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex + 1] = rgba.green;</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex + 2] = rgba.blue;</span>
<span class="cstat-no" title="statement not covered" > if (outHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex + 3] = rgba.alpha;</span>
}
} else {
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(rgba.red, outIndex);</span>
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(rgba.green, outIndex + 2);</span>
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(rgba.blue, outIndex + 4);</span>
<span class="cstat-no" title="statement not covered" > if (outHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(rgba.alpha, outIndex + 6);</span>
}
}
<span class="cstat-no" title="statement not covered" > break;</span>
case constants.COLORTYPE_ALPHA:
case constants.COLORTYPE_GRAYSCALE: {
// Convert to grayscale and alpha
let grayscale = <span class="cstat-no" title="statement not covered" >(rgba.red + rgba.green + rgba.blue) / 3;</span>
<span class="cstat-no" title="statement not covered" > if (options.bitDepth === 8) {</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex] = grayscale;</span>
<span class="cstat-no" title="statement not covered" > if (outHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > outData[outIndex + 1] = rgba.alpha;</span>
}
} else {
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(grayscale, outIndex);</span>
<span class="cstat-no" title="statement not covered" > if (outHasAlpha) {</span>
<span class="cstat-no" title="statement not covered" > outData.writeUInt16BE(rgba.alpha, outIndex + 2);</span>
}
}
<span class="cstat-no" title="statement not covered" > break;</span>
}
default:
<span class="cstat-no" title="statement not covered" > throw new Error("unrecognised color Type " + options.colorType);</span>
}
&nbsp;
<span class="cstat-no" title="statement not covered" > inIndex += inBpp;</span>
<span class="cstat-no" title="statement not covered" > outIndex += outBpp;</span>
}
}
&nbsp;
<span class="cstat-no" title="statement not covered" > return outData;</span>
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

View File

@@ -0,0 +1,77 @@
/* eslint-disable */
var jumpToCode = (function init() {
// Classes of code we would like to highlight in the file view
var missingCoverageClasses = [".cbranch-no", ".cstat-no", ".fstat-no"];
// Elements to highlight in the file listing view
var fileListingElements = ["td.pct.low"];
// We don't want to select elements that are direct descendants of another match
var notSelector = ":not(" + missingCoverageClasses.join("):not(") + ") > "; // becomes `:not(a):not(b) > `
// Selecter that finds elements on the page to which we can jump
var selector =
fileListingElements.join(", ") +
", " +
notSelector +
missingCoverageClasses.join(", " + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
// The NodeList of matching elements
var missingCoverageElements = document.querySelectorAll(selector);
var currentIndex;
function toggleClass(index) {
missingCoverageElements.item(currentIndex).classList.remove("highlighted");
missingCoverageElements.item(index).classList.add("highlighted");
}
function makeCurrent(index) {
toggleClass(index);
currentIndex = index;
missingCoverageElements.item(index).scrollIntoView({
behavior: "smooth",
block: "center",
inline: "center",
});
}
function goToPrevious() {
var nextIndex = 0;
if (typeof currentIndex !== "number" || currentIndex === 0) {
nextIndex = missingCoverageElements.length - 1;
} else if (missingCoverageElements.length > 1) {
nextIndex = currentIndex - 1;
}
makeCurrent(nextIndex);
}
function goToNext() {
var nextIndex = 0;
if (
typeof currentIndex === "number" &&
currentIndex < missingCoverageElements.length - 1
) {
nextIndex = currentIndex + 1;
}
makeCurrent(nextIndex);
}
return function jump(event) {
switch (event.which) {
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
}
};
})();
window.addEventListener("keydown", jumpToCode);

View File

@@ -0,0 +1,647 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for chunkstream.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> chunkstream.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">90.11% </span>
<span class="quiet">Statements</span>
<span class='fraction'>82/91</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">81.4% </span>
<span class="quiet">Branches</span>
<span class='fraction'>35/43</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>10/10</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">90.11% </span>
<span class="quiet">Lines</span>
<span class='fraction'>82/91</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a>
<a name='L42'></a><a href='#L42'>42</a>
<a name='L43'></a><a href='#L43'>43</a>
<a name='L44'></a><a href='#L44'>44</a>
<a name='L45'></a><a href='#L45'>45</a>
<a name='L46'></a><a href='#L46'>46</a>
<a name='L47'></a><a href='#L47'>47</a>
<a name='L48'></a><a href='#L48'>48</a>
<a name='L49'></a><a href='#L49'>49</a>
<a name='L50'></a><a href='#L50'>50</a>
<a name='L51'></a><a href='#L51'>51</a>
<a name='L52'></a><a href='#L52'>52</a>
<a name='L53'></a><a href='#L53'>53</a>
<a name='L54'></a><a href='#L54'>54</a>
<a name='L55'></a><a href='#L55'>55</a>
<a name='L56'></a><a href='#L56'>56</a>
<a name='L57'></a><a href='#L57'>57</a>
<a name='L58'></a><a href='#L58'>58</a>
<a name='L59'></a><a href='#L59'>59</a>
<a name='L60'></a><a href='#L60'>60</a>
<a name='L61'></a><a href='#L61'>61</a>
<a name='L62'></a><a href='#L62'>62</a>
<a name='L63'></a><a href='#L63'>63</a>
<a name='L64'></a><a href='#L64'>64</a>
<a name='L65'></a><a href='#L65'>65</a>
<a name='L66'></a><a href='#L66'>66</a>
<a name='L67'></a><a href='#L67'>67</a>
<a name='L68'></a><a href='#L68'>68</a>
<a name='L69'></a><a href='#L69'>69</a>
<a name='L70'></a><a href='#L70'>70</a>
<a name='L71'></a><a href='#L71'>71</a>
<a name='L72'></a><a href='#L72'>72</a>
<a name='L73'></a><a href='#L73'>73</a>
<a name='L74'></a><a href='#L74'>74</a>
<a name='L75'></a><a href='#L75'>75</a>
<a name='L76'></a><a href='#L76'>76</a>
<a name='L77'></a><a href='#L77'>77</a>
<a name='L78'></a><a href='#L78'>78</a>
<a name='L79'></a><a href='#L79'>79</a>
<a name='L80'></a><a href='#L80'>80</a>
<a name='L81'></a><a href='#L81'>81</a>
<a name='L82'></a><a href='#L82'>82</a>
<a name='L83'></a><a href='#L83'>83</a>
<a name='L84'></a><a href='#L84'>84</a>
<a name='L85'></a><a href='#L85'>85</a>
<a name='L86'></a><a href='#L86'>86</a>
<a name='L87'></a><a href='#L87'>87</a>
<a name='L88'></a><a href='#L88'>88</a>
<a name='L89'></a><a href='#L89'>89</a>
<a name='L90'></a><a href='#L90'>90</a>
<a name='L91'></a><a href='#L91'>91</a>
<a name='L92'></a><a href='#L92'>92</a>
<a name='L93'></a><a href='#L93'>93</a>
<a name='L94'></a><a href='#L94'>94</a>
<a name='L95'></a><a href='#L95'>95</a>
<a name='L96'></a><a href='#L96'>96</a>
<a name='L97'></a><a href='#L97'>97</a>
<a name='L98'></a><a href='#L98'>98</a>
<a name='L99'></a><a href='#L99'>99</a>
<a name='L100'></a><a href='#L100'>100</a>
<a name='L101'></a><a href='#L101'>101</a>
<a name='L102'></a><a href='#L102'>102</a>
<a name='L103'></a><a href='#L103'>103</a>
<a name='L104'></a><a href='#L104'>104</a>
<a name='L105'></a><a href='#L105'>105</a>
<a name='L106'></a><a href='#L106'>106</a>
<a name='L107'></a><a href='#L107'>107</a>
<a name='L108'></a><a href='#L108'>108</a>
<a name='L109'></a><a href='#L109'>109</a>
<a name='L110'></a><a href='#L110'>110</a>
<a name='L111'></a><a href='#L111'>111</a>
<a name='L112'></a><a href='#L112'>112</a>
<a name='L113'></a><a href='#L113'>113</a>
<a name='L114'></a><a href='#L114'>114</a>
<a name='L115'></a><a href='#L115'>115</a>
<a name='L116'></a><a href='#L116'>116</a>
<a name='L117'></a><a href='#L117'>117</a>
<a name='L118'></a><a href='#L118'>118</a>
<a name='L119'></a><a href='#L119'>119</a>
<a name='L120'></a><a href='#L120'>120</a>
<a name='L121'></a><a href='#L121'>121</a>
<a name='L122'></a><a href='#L122'>122</a>
<a name='L123'></a><a href='#L123'>123</a>
<a name='L124'></a><a href='#L124'>124</a>
<a name='L125'></a><a href='#L125'>125</a>
<a name='L126'></a><a href='#L126'>126</a>
<a name='L127'></a><a href='#L127'>127</a>
<a name='L128'></a><a href='#L128'>128</a>
<a name='L129'></a><a href='#L129'>129</a>
<a name='L130'></a><a href='#L130'>130</a>
<a name='L131'></a><a href='#L131'>131</a>
<a name='L132'></a><a href='#L132'>132</a>
<a name='L133'></a><a href='#L133'>133</a>
<a name='L134'></a><a href='#L134'>134</a>
<a name='L135'></a><a href='#L135'>135</a>
<a name='L136'></a><a href='#L136'>136</a>
<a name='L137'></a><a href='#L137'>137</a>
<a name='L138'></a><a href='#L138'>138</a>
<a name='L139'></a><a href='#L139'>139</a>
<a name='L140'></a><a href='#L140'>140</a>
<a name='L141'></a><a href='#L141'>141</a>
<a name='L142'></a><a href='#L142'>142</a>
<a name='L143'></a><a href='#L143'>143</a>
<a name='L144'></a><a href='#L144'>144</a>
<a name='L145'></a><a href='#L145'>145</a>
<a name='L146'></a><a href='#L146'>146</a>
<a name='L147'></a><a href='#L147'>147</a>
<a name='L148'></a><a href='#L148'>148</a>
<a name='L149'></a><a href='#L149'>149</a>
<a name='L150'></a><a href='#L150'>150</a>
<a name='L151'></a><a href='#L151'>151</a>
<a name='L152'></a><a href='#L152'>152</a>
<a name='L153'></a><a href='#L153'>153</a>
<a name='L154'></a><a href='#L154'>154</a>
<a name='L155'></a><a href='#L155'>155</a>
<a name='L156'></a><a href='#L156'>156</a>
<a name='L157'></a><a href='#L157'>157</a>
<a name='L158'></a><a href='#L158'>158</a>
<a name='L159'></a><a href='#L159'>159</a>
<a name='L160'></a><a href='#L160'>160</a>
<a name='L161'></a><a href='#L161'>161</a>
<a name='L162'></a><a href='#L162'>162</a>
<a name='L163'></a><a href='#L163'>163</a>
<a name='L164'></a><a href='#L164'>164</a>
<a name='L165'></a><a href='#L165'>165</a>
<a name='L166'></a><a href='#L166'>166</a>
<a name='L167'></a><a href='#L167'>167</a>
<a name='L168'></a><a href='#L168'>168</a>
<a name='L169'></a><a href='#L169'>169</a>
<a name='L170'></a><a href='#L170'>170</a>
<a name='L171'></a><a href='#L171'>171</a>
<a name='L172'></a><a href='#L172'>172</a>
<a name='L173'></a><a href='#L173'>173</a>
<a name='L174'></a><a href='#L174'>174</a>
<a name='L175'></a><a href='#L175'>175</a>
<a name='L176'></a><a href='#L176'>176</a>
<a name='L177'></a><a href='#L177'>177</a>
<a name='L178'></a><a href='#L178'>178</a>
<a name='L179'></a><a href='#L179'>179</a>
<a name='L180'></a><a href='#L180'>180</a>
<a name='L181'></a><a href='#L181'>181</a>
<a name='L182'></a><a href='#L182'>182</a>
<a name='L183'></a><a href='#L183'>183</a>
<a name='L184'></a><a href='#L184'>184</a>
<a name='L185'></a><a href='#L185'>185</a>
<a name='L186'></a><a href='#L186'>186</a>
<a name='L187'></a><a href='#L187'>187</a>
<a name='L188'></a><a href='#L188'>188</a>
<a name='L189'></a><a href='#L189'>189</a>
<a name='L190'></a><a href='#L190'>190</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-yes">529x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">13318x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13318x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13318x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13318x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-yes">346x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">943x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-yes">309x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">311x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">327x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">327x</span>
<span class="cline-any cline-yes">327x</span>
<span class="cline-any cline-yes">327x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">327x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">741x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">741x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">741x</span>
<span class="cline-any cline-yes">568x</span>
<span class="cline-any cline-yes">568x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">568x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">173x</span>
<span class="cline-any cline-yes">173x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">173x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-yes">12617x</span>
<span class="cline-any cline-yes">12617x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12617x</span>
<span class="cline-any cline-yes">12617x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12617x</span>
<span class="cline-any cline-yes">11863x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-yes">532x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">14263x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">14263x</span>
<span class="cline-any cline-yes">15656x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15656x</span>
<span class="cline-any cline-yes">741x</span>
<span class="cline-any cline-yes">14915x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">12408x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2507x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">14263x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
let util = require("util");
let Stream = require("stream");
&nbsp;
let ChunkStream = (module.exports = function () {
Stream.call(this);
&nbsp;
this._buffers = [];
this._buffered = 0;
&nbsp;
this._reads = [];
this._paused = false;
&nbsp;
this._encoding = "utf8";
this.writable = true;
});
util.inherits(ChunkStream, Stream);
&nbsp;
ChunkStream.prototype.read = function (length, callback) {
this._reads.push({
length: Math.abs(length), // if length &lt; 0 then at most this length
allowLess: length &lt; 0,
func: callback,
});
&nbsp;
process.nextTick(
function () {
this._process();
&nbsp;
// its paused and there is not enought data then ask for more
<span class="missing-if-branch" title="if path not taken" >I</span>if (this._paused &amp;&amp; this._reads.length &gt; 0) {
<span class="cstat-no" title="statement not covered" > this._paused = false;</span>
&nbsp;
<span class="cstat-no" title="statement not covered" > this.emit("drain");</span>
}
}.bind(this)
);
};
&nbsp;
ChunkStream.prototype.write = function (data, encoding) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (!this.writable) {
<span class="cstat-no" title="statement not covered" > this.emit("error", new Error("Stream not writable"));</span>
<span class="cstat-no" title="statement not covered" > return false;</span>
}
&nbsp;
let dataBuffer;
<span class="missing-if-branch" title="else path not taken" >E</span>if (Buffer.isBuffer(data)) {
dataBuffer = data;
} else {
<span class="cstat-no" title="statement not covered" > dataBuffer = Buffer.from(data, encoding || this._encoding);</span>
}
&nbsp;
this._buffers.push(dataBuffer);
this._buffered += dataBuffer.length;
&nbsp;
this._process();
&nbsp;
// ok if there are no more read requests
if (this._reads &amp;&amp; this._reads.length === 0) {
this._paused = true;
}
&nbsp;
return this.writable &amp;&amp; !this._paused;
};
&nbsp;
ChunkStream.prototype.end = function (data, encoding) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (data) {
<span class="cstat-no" title="statement not covered" > this.write(data, encoding);</span>
}
&nbsp;
this.writable = false;
&nbsp;
// already destroyed
<span class="missing-if-branch" title="if path not taken" >I</span>if (!this._buffers) {
<span class="cstat-no" title="statement not covered" > return;</span>
}
&nbsp;
// enqueue or handle end
if (this._buffers.length === 0) {
this._end();
} else {
this._buffers.push(null);
this._process();
}
};
&nbsp;
ChunkStream.prototype.destroySoon = ChunkStream.prototype.end;
&nbsp;
ChunkStream.prototype._end = function () {
if (this._reads.length &gt; 0) {
this.emit("error", new Error("Unexpected end of input"));
}
&nbsp;
this.destroy();
};
&nbsp;
ChunkStream.prototype.destroy = function () {
<span class="missing-if-branch" title="if path not taken" >I</span>if (!this._buffers) {
<span class="cstat-no" title="statement not covered" > return;</span>
}
&nbsp;
this.writable = false;
this._reads = null;
this._buffers = null;
&nbsp;
this.emit("close");
};
&nbsp;
ChunkStream.prototype._processReadAllowingLess = function (read) {
// ok there is any data so that we can satisfy this request
this._reads.shift(); // == read
&nbsp;
// first we need to peek into first buffer
let smallerBuf = this._buffers[0];
&nbsp;
// ok there is more data than we need
if (smallerBuf.length &gt; read.length) {
this._buffered -= read.length;
this._buffers[0] = smallerBuf.slice(read.length);
&nbsp;
read.func.call(this, smallerBuf.slice(0, read.length));
} else {
// ok this is less than maximum length so use it all
this._buffered -= smallerBuf.length;
this._buffers.shift(); // == smallerBuf
&nbsp;
read.func.call(this, smallerBuf);
}
};
&nbsp;
ChunkStream.prototype._processRead = function (read) {
this._reads.shift(); // == read
&nbsp;
let pos = 0;
let count = 0;
let data = Buffer.alloc(read.length);
&nbsp;
// create buffer for all data
while (pos &lt; read.length) {
let buf = this._buffers[count++];
let len = Math.min(buf.length, read.length - pos);
&nbsp;
buf.copy(data, pos, 0, len);
pos += len;
&nbsp;
// last buffer wasn't used all so just slice it and leave
if (len !== buf.length) {
this._buffers[--count] = buf.slice(len);
}
}
&nbsp;
// remove all used buffers
if (count &gt; 0) {
this._buffers.splice(0, count);
}
&nbsp;
this._buffered -= read.length;
&nbsp;
read.func.call(this, data);
};
&nbsp;
ChunkStream.prototype._process = function () {
try {
// as long as there is any data and read requests
while (this._buffered &gt; 0 &amp;&amp; this._reads &amp;&amp; this._reads.length &gt; 0) {
let read = this._reads[0];
&nbsp;
// read any data (but no more than length)
if (read.allowLess) {
this._processReadAllowingLess(read);
} else if (this._buffered &gt;= read.length) {
// ok we can meet some expectations
&nbsp;
this._processRead(read);
} else {
// not enought data to satisfy first request in queue
// so we need to wait for more
break;
}
}
&nbsp;
if (this._buffers &amp;&amp; !this.writable) {
this._end();
}
} catch (ex) {
<span class="cstat-no" title="statement not covered" > this.emit("error", ex);</span>
}
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

View File

@@ -0,0 +1,176 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for constants.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> constants.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>1/1</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>1/1</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
module.exports = {
PNG_SIGNATURE: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],
&nbsp;
TYPE_IHDR: 0x49484452,
TYPE_IEND: 0x49454e44,
TYPE_IDAT: 0x49444154,
TYPE_PLTE: 0x504c5445,
TYPE_tRNS: 0x74524e53, // eslint-disable-line camelcase
TYPE_gAMA: 0x67414d41, // eslint-disable-line camelcase
&nbsp;
// color-type bits
COLORTYPE_GRAYSCALE: 0,
COLORTYPE_PALETTE: 1,
COLORTYPE_COLOR: 2,
COLORTYPE_ALPHA: 4, // e.g. grayscale and alpha
&nbsp;
// color-type combinations
COLORTYPE_PALETTE_COLOR: 3,
COLORTYPE_COLOR_ALPHA: 6,
&nbsp;
COLORTYPE_TO_BPP_MAP: {
0: 1,
2: 3,
3: 1,
4: 2,
6: 4,
},
&nbsp;
GAMMA_DIVISION: 100000,
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

View File

@@ -0,0 +1,200 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for crc.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> crc.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>26/26</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>2/2</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>5/5</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>22/22</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">256x</span>
<span class="cline-any cline-yes">256x</span>
<span class="cline-any cline-yes">2048x</span>
<span class="cline-any cline-yes">1024x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1024x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">256x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">2461x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">4839x</span>
<span class="cline-any cline-yes">823519x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4839x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">2195x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1592x</span>
<span class="cline-any cline-yes">1592x</span>
<span class="cline-any cline-yes">305287x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1592x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
let crcTable = [];
&nbsp;
(function () {
for (let i = 0; i &lt; 256; i++) {
let currentCrc = i;
for (let j = 0; j &lt; 8; j++) {
if (currentCrc &amp; 1) {
currentCrc = 0xedb88320 ^ (currentCrc &gt;&gt;&gt; 1);
} else {
currentCrc = currentCrc &gt;&gt;&gt; 1;
}
}
crcTable[i] = currentCrc;
}
})();
&nbsp;
let CrcCalculator = (module.exports = function () {
this._crc = -1;
});
&nbsp;
CrcCalculator.prototype.write = function (data) {
for (let i = 0; i &lt; data.length; i++) {
this._crc = crcTable[(this._crc ^ data[i]) &amp; 0xff] ^ (this._crc &gt;&gt;&gt; 8);
}
return true;
};
&nbsp;
CrcCalculator.prototype.crc32 = function () {
return this._crc ^ -1;
};
&nbsp;
CrcCalculator.crc32 = function (buf) {
let crc = -1;
for (let i = 0; i &lt; buf.length; i++) {
crc = crcTable[(crc ^ buf[i]) &amp; 0xff] ^ (crc &gt;&gt;&gt; 8);
}
return crc ^ -1;
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

View File

@@ -0,0 +1,593 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for filter-pack.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> filter-pack.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">95.83% </span>
<span class="quiet">Statements</span>
<span class='fraction'>92/96</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">81.82% </span>
<span class="quiet">Branches</span>
<span class='fraction'>36/44</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>11/11</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">95.24% </span>
<span class="quiet">Lines</span>
<span class='fraction'>80/84</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a>
<a name='L42'></a><a href='#L42'>42</a>
<a name='L43'></a><a href='#L43'>43</a>
<a name='L44'></a><a href='#L44'>44</a>
<a name='L45'></a><a href='#L45'>45</a>
<a name='L46'></a><a href='#L46'>46</a>
<a name='L47'></a><a href='#L47'>47</a>
<a name='L48'></a><a href='#L48'>48</a>
<a name='L49'></a><a href='#L49'>49</a>
<a name='L50'></a><a href='#L50'>50</a>
<a name='L51'></a><a href='#L51'>51</a>
<a name='L52'></a><a href='#L52'>52</a>
<a name='L53'></a><a href='#L53'>53</a>
<a name='L54'></a><a href='#L54'>54</a>
<a name='L55'></a><a href='#L55'>55</a>
<a name='L56'></a><a href='#L56'>56</a>
<a name='L57'></a><a href='#L57'>57</a>
<a name='L58'></a><a href='#L58'>58</a>
<a name='L59'></a><a href='#L59'>59</a>
<a name='L60'></a><a href='#L60'>60</a>
<a name='L61'></a><a href='#L61'>61</a>
<a name='L62'></a><a href='#L62'>62</a>
<a name='L63'></a><a href='#L63'>63</a>
<a name='L64'></a><a href='#L64'>64</a>
<a name='L65'></a><a href='#L65'>65</a>
<a name='L66'></a><a href='#L66'>66</a>
<a name='L67'></a><a href='#L67'>67</a>
<a name='L68'></a><a href='#L68'>68</a>
<a name='L69'></a><a href='#L69'>69</a>
<a name='L70'></a><a href='#L70'>70</a>
<a name='L71'></a><a href='#L71'>71</a>
<a name='L72'></a><a href='#L72'>72</a>
<a name='L73'></a><a href='#L73'>73</a>
<a name='L74'></a><a href='#L74'>74</a>
<a name='L75'></a><a href='#L75'>75</a>
<a name='L76'></a><a href='#L76'>76</a>
<a name='L77'></a><a href='#L77'>77</a>
<a name='L78'></a><a href='#L78'>78</a>
<a name='L79'></a><a href='#L79'>79</a>
<a name='L80'></a><a href='#L80'>80</a>
<a name='L81'></a><a href='#L81'>81</a>
<a name='L82'></a><a href='#L82'>82</a>
<a name='L83'></a><a href='#L83'>83</a>
<a name='L84'></a><a href='#L84'>84</a>
<a name='L85'></a><a href='#L85'>85</a>
<a name='L86'></a><a href='#L86'>86</a>
<a name='L87'></a><a href='#L87'>87</a>
<a name='L88'></a><a href='#L88'>88</a>
<a name='L89'></a><a href='#L89'>89</a>
<a name='L90'></a><a href='#L90'>90</a>
<a name='L91'></a><a href='#L91'>91</a>
<a name='L92'></a><a href='#L92'>92</a>
<a name='L93'></a><a href='#L93'>93</a>
<a name='L94'></a><a href='#L94'>94</a>
<a name='L95'></a><a href='#L95'>95</a>
<a name='L96'></a><a href='#L96'>96</a>
<a name='L97'></a><a href='#L97'>97</a>
<a name='L98'></a><a href='#L98'>98</a>
<a name='L99'></a><a href='#L99'>99</a>
<a name='L100'></a><a href='#L100'>100</a>
<a name='L101'></a><a href='#L101'>101</a>
<a name='L102'></a><a href='#L102'>102</a>
<a name='L103'></a><a href='#L103'>103</a>
<a name='L104'></a><a href='#L104'>104</a>
<a name='L105'></a><a href='#L105'>105</a>
<a name='L106'></a><a href='#L106'>106</a>
<a name='L107'></a><a href='#L107'>107</a>
<a name='L108'></a><a href='#L108'>108</a>
<a name='L109'></a><a href='#L109'>109</a>
<a name='L110'></a><a href='#L110'>110</a>
<a name='L111'></a><a href='#L111'>111</a>
<a name='L112'></a><a href='#L112'>112</a>
<a name='L113'></a><a href='#L113'>113</a>
<a name='L114'></a><a href='#L114'>114</a>
<a name='L115'></a><a href='#L115'>115</a>
<a name='L116'></a><a href='#L116'>116</a>
<a name='L117'></a><a href='#L117'>117</a>
<a name='L118'></a><a href='#L118'>118</a>
<a name='L119'></a><a href='#L119'>119</a>
<a name='L120'></a><a href='#L120'>120</a>
<a name='L121'></a><a href='#L121'>121</a>
<a name='L122'></a><a href='#L122'>122</a>
<a name='L123'></a><a href='#L123'>123</a>
<a name='L124'></a><a href='#L124'>124</a>
<a name='L125'></a><a href='#L125'>125</a>
<a name='L126'></a><a href='#L126'>126</a>
<a name='L127'></a><a href='#L127'>127</a>
<a name='L128'></a><a href='#L128'>128</a>
<a name='L129'></a><a href='#L129'>129</a>
<a name='L130'></a><a href='#L130'>130</a>
<a name='L131'></a><a href='#L131'>131</a>
<a name='L132'></a><a href='#L132'>132</a>
<a name='L133'></a><a href='#L133'>133</a>
<a name='L134'></a><a href='#L134'>134</a>
<a name='L135'></a><a href='#L135'>135</a>
<a name='L136'></a><a href='#L136'>136</a>
<a name='L137'></a><a href='#L137'>137</a>
<a name='L138'></a><a href='#L138'>138</a>
<a name='L139'></a><a href='#L139'>139</a>
<a name='L140'></a><a href='#L140'>140</a>
<a name='L141'></a><a href='#L141'>141</a>
<a name='L142'></a><a href='#L142'>142</a>
<a name='L143'></a><a href='#L143'>143</a>
<a name='L144'></a><a href='#L144'>144</a>
<a name='L145'></a><a href='#L145'>145</a>
<a name='L146'></a><a href='#L146'>146</a>
<a name='L147'></a><a href='#L147'>147</a>
<a name='L148'></a><a href='#L148'>148</a>
<a name='L149'></a><a href='#L149'>149</a>
<a name='L150'></a><a href='#L150'>150</a>
<a name='L151'></a><a href='#L151'>151</a>
<a name='L152'></a><a href='#L152'>152</a>
<a name='L153'></a><a href='#L153'>153</a>
<a name='L154'></a><a href='#L154'>154</a>
<a name='L155'></a><a href='#L155'>155</a>
<a name='L156'></a><a href='#L156'>156</a>
<a name='L157'></a><a href='#L157'>157</a>
<a name='L158'></a><a href='#L158'>158</a>
<a name='L159'></a><a href='#L159'>159</a>
<a name='L160'></a><a href='#L160'>160</a>
<a name='L161'></a><a href='#L161'>161</a>
<a name='L162'></a><a href='#L162'>162</a>
<a name='L163'></a><a href='#L163'>163</a>
<a name='L164'></a><a href='#L164'>164</a>
<a name='L165'></a><a href='#L165'>165</a>
<a name='L166'></a><a href='#L166'>166</a>
<a name='L167'></a><a href='#L167'>167</a>
<a name='L168'></a><a href='#L168'>168</a>
<a name='L169'></a><a href='#L169'>169</a>
<a name='L170'></a><a href='#L170'>170</a>
<a name='L171'></a><a href='#L171'>171</a>
<a name='L172'></a><a href='#L172'>172</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">44x</span>
<span class="cline-any cline-yes">5136x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">637x</span>
<span class="cline-any cline-yes">107032x</span>
<span class="cline-any cline-yes">107032x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">107032x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2670x</span>
<span class="cline-any cline-yes">581344x</span>
<span class="cline-any cline-yes">581344x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">581344x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">208x</span>
<span class="cline-any cline-yes">204096x</span>
<span class="cline-any cline-yes">204096x</span>
<span class="cline-any cline-yes">204096x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">204096x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">6931x</span>
<span class="cline-any cline-yes">1879128x</span>
<span class="cline-any cline-yes">1879128x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1879128x</span>
<span class="cline-any cline-yes">1879128x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1879128x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2776736x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">52450x</span>
<span class="cline-any cline-yes">52450x</span>
<span class="cline-any cline-yes">35370x</span>
<span class="cline-any cline-yes">35370x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-yes">10490x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">325x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
&nbsp;
let paethPredictor = require("./paeth-predictor");
&nbsp;
function filterNone(pxData, pxPos, byteWidth, rawData, rawPos) {
for (let x = 0; x &lt; byteWidth; x++) {
rawData[rawPos + x] = pxData[pxPos + x];
}
}
&nbsp;
function filterSumNone(pxData, pxPos, byteWidth) {
let sum = 0;
let length = pxPos + byteWidth;
&nbsp;
for (let i = pxPos; i &lt; length; i++) {
sum += Math.abs(pxData[i]);
}
return sum;
}
&nbsp;
function filterSub(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let val = pxData[pxPos + x] - left;
&nbsp;
rawData[rawPos + x] = val;
}
}
&nbsp;
function filterSumSub(pxData, pxPos, byteWidth, bpp) {
let sum = 0;
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let val = pxData[pxPos + x] - left;
&nbsp;
sum += Math.abs(val);
}
&nbsp;
return sum;
}
&nbsp;
function filterUp(pxData, pxPos, byteWidth, rawData, rawPos) {
for (let x = 0; x &lt; byteWidth; x++) {
let up = pxPos &gt; 0 ? pxData[pxPos + x - byteWidth] : <span class="branch-1 cbranch-no" title="branch not covered" >0;</span>
let val = pxData[pxPos + x] - up;
&nbsp;
rawData[rawPos + x] = val;
}
}
&nbsp;
function filterSumUp(pxData, pxPos, byteWidth) {
let sum = 0;
let length = pxPos + byteWidth;
for (let x = pxPos; x &lt; length; x++) {
let up = pxPos &gt; 0 ? pxData[x - byteWidth] : 0;
let val = pxData[x] - up;
&nbsp;
sum += Math.abs(val);
}
&nbsp;
return sum;
}
&nbsp;
function filterAvg(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let up = pxPos &gt; 0 ? pxData[pxPos + x - byteWidth] : <span class="branch-1 cbranch-no" title="branch not covered" >0;</span>
let val = pxData[pxPos + x] - ((left + up) &gt;&gt; 1);
&nbsp;
rawData[rawPos + x] = val;
}
}
&nbsp;
function filterSumAvg(pxData, pxPos, byteWidth, bpp) {
let sum = 0;
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let up = pxPos &gt; 0 ? pxData[pxPos + x - byteWidth] : 0;
let val = pxData[pxPos + x] - ((left + up) &gt;&gt; 1);
&nbsp;
sum += Math.abs(val);
}
&nbsp;
return sum;
}
&nbsp;
function filterPaeth(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let up = pxPos &gt; 0 ? pxData[pxPos + x - byteWidth] : <span class="branch-1 cbranch-no" title="branch not covered" >0;</span>
let upleft =
pxPos &gt; 0 &amp;&amp; x &gt;= bpp ? pxData[pxPos + x - (byteWidth + bpp)] : 0;
let val = pxData[pxPos + x] - paethPredictor(left, up, upleft);
&nbsp;
rawData[rawPos + x] = val;
}
}
&nbsp;
function filterSumPaeth(pxData, pxPos, byteWidth, bpp) {
let sum = 0;
for (let x = 0; x &lt; byteWidth; x++) {
let left = x &gt;= bpp ? pxData[pxPos + x - bpp] : 0;
let up = pxPos &gt; 0 ? pxData[pxPos + x - byteWidth] : 0;
let upleft =
pxPos &gt; 0 &amp;&amp; x &gt;= bpp ? pxData[pxPos + x - (byteWidth + bpp)] : 0;
let val = pxData[pxPos + x] - paethPredictor(left, up, upleft);
&nbsp;
sum += Math.abs(val);
}
&nbsp;
return sum;
}
&nbsp;
let filters = {
0: filterNone,
1: filterSub,
2: filterUp,
3: filterAvg,
4: filterPaeth,
};
&nbsp;
let filterSums = {
0: filterSumNone,
1: filterSumSub,
2: filterSumUp,
3: filterSumAvg,
4: filterSumPaeth,
};
&nbsp;
module.exports = function (pxData, width, height, options, bpp) {
let filterTypes;
<span class="missing-if-branch" title="else path not taken" >E</span>if (!("filterType" in options) || options.filterType === -1) {
filterTypes = [0, 1, 2, 3, 4];
} else <span class="cstat-no" title="statement not covered" >if (typeof options.filterType === "number") {</span>
<span class="cstat-no" title="statement not covered" > filterTypes = [options.filterType];</span>
} else {
<span class="cstat-no" title="statement not covered" > throw new Error("unrecognised filter types");</span>
}
&nbsp;
<span class="missing-if-branch" title="if path not taken" >I</span>if (options.bitDepth === 16) {
<span class="cstat-no" title="statement not covered" > bpp *= 2;</span>
}
let byteWidth = width * bpp;
let rawPos = 0;
let pxPos = 0;
let rawData = Buffer.alloc((byteWidth + 1) * height);
&nbsp;
let sel = filterTypes[0];
&nbsp;
for (let y = 0; y &lt; height; y++) {
<span class="missing-if-branch" title="else path not taken" >E</span>if (filterTypes.length &gt; 1) {
// find best filter for this line (with lowest sum of values)
let min = Infinity;
&nbsp;
for (let i = 0; i &lt; filterTypes.length; i++) {
let sum = filterSums[filterTypes[i]](pxData, pxPos, byteWidth, bpp);
if (sum &lt; min) {
sel = filterTypes[i];
min = sum;
}
}
}
&nbsp;
rawData[rawPos] = sel;
rawPos++;
filters[sel](pxData, pxPos, byteWidth, rawData, rawPos, bpp);
rawPos += byteWidth;
pxPos += byteWidth;
}
return rawData;
};
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Fri Apr 10 2020 13:53:16 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More