@blocklet/server-js 1.16.49-beta-20250821-102221-1b7283d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +60 -0
- package/dist/base.js +88 -0
- package/dist/base.js.map +1 -0
- package/dist/browser.d.ts +5507 -0
- package/dist/browser.js +15 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.js +1 -0
- package/dist/module.js +14 -0
- package/dist/module.js.map +1 -0
- package/dist/report.html +39 -0
- package/dist/schema/graphql.json +39382 -0
- package/dist/signer/index.js +9 -0
- package/dist/signer/index.js.map +1 -0
- package/dist/signer/sha256.js +27 -0
- package/dist/signer/sha256.js.map +1 -0
- package/dist/signer/totp.js +62 -0
- package/dist/signer/totp.js.map +1 -0
- package/dist/types.js +11633 -0
- package/dist/types.js.map +1 -0
- package/docs/QUERIES.md +47092 -0
- package/lib/base.js +88 -0
- package/lib/base.js.map +1 -0
- package/lib/module.js +14 -0
- package/lib/module.js.map +1 -0
- package/lib/node.d.ts +5507 -0
- package/lib/node.js +93 -0
- package/lib/node.js.map +1 -0
- package/lib/schema/graphql.json +39382 -0
- package/lib/signer/index.js +9 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/signer/sha256.js +27 -0
- package/lib/signer/sha256.js.map +1 -0
- package/lib/signer/totp.js +62 -0
- package/lib/signer/totp.js.map +1 -0
- package/lib/types.js +11633 -0
- package/lib/types.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["totp","require","sha256","module","exports"],"sources":["../../src/signer/index.js"],"sourcesContent":["const totp = require('./totp');\nconst sha256 = require('./sha256');\n\nmodule.exports = {\n totp,\n sha256,\n};\n"],"mappings":";;AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAC9B,MAAMC,MAAM,GAAGD,OAAO,CAAC,UAAU,CAAC;AAElCE,MAAM,CAACC,OAAO,GAAG;EACfJ,IAAI;EACJE;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
+
const {
|
|
5
|
+
createHash
|
|
6
|
+
} = require('crypto');
|
|
7
|
+
const sign = (key, counter) => {
|
|
8
|
+
// eslint-disable-next-line no-param-reassign
|
|
9
|
+
counter = counter || Math.floor(Date.now() / 1000 / 30);
|
|
10
|
+
const hash = createHash('sha256');
|
|
11
|
+
const token = hash.update("".concat(key).concat(counter)).digest('base64');
|
|
12
|
+
return token;
|
|
13
|
+
};
|
|
14
|
+
const verify = (key, sig, counter) => {
|
|
15
|
+
// eslint-disable-next-line no-param-reassign
|
|
16
|
+
counter = counter || Math.floor(Date.now() / 1000 / 30);
|
|
17
|
+
for (const i of [counter, counter - 1, counter + 1]) {
|
|
18
|
+
const token = sign(key, i);
|
|
19
|
+
if (token === sig) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
exports.sign = sign;
|
|
26
|
+
exports.verify = verify;
|
|
27
|
+
//# sourceMappingURL=sha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.js","names":["createHash","require","sign","key","counter","Math","floor","Date","now","hash","token","update","concat","digest","verify","sig","i","exports"],"sources":["../../src/signer/sha256.js"],"sourcesContent":["const { createHash } = require('crypto');\n\nconst sign = (key, counter) => {\n // eslint-disable-next-line no-param-reassign\n counter = counter || Math.floor(Date.now() / 1000 / 30);\n\n const hash = createHash('sha256');\n const token = hash.update(`${key}${counter}`).digest('base64');\n return token;\n};\n\nconst verify = (key, sig, counter) => {\n // eslint-disable-next-line no-param-reassign\n counter = counter || Math.floor(Date.now() / 1000 / 30);\n\n for (const i of [counter, counter - 1, counter + 1]) {\n const token = sign(key, i);\n if (token === sig) {\n return true;\n }\n }\n\n return false;\n};\n\nexports.sign = sign;\nexports.verify = verify;\n"],"mappings":";;;AAAA,MAAM;EAAEA;AAAW,CAAC,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAExC,MAAMC,IAAI,GAAGA,CAACC,GAAG,EAAEC,OAAO,KAAK;EAC7B;EACAA,OAAO,GAAGA,OAAO,IAAIC,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;EAEvD,MAAMC,IAAI,GAAGT,UAAU,CAAC,QAAQ,CAAC;EACjC,MAAMU,KAAK,GAAGD,IAAI,CAACE,MAAM,IAAAC,MAAA,CAAIT,GAAG,EAAAS,MAAA,CAAGR,OAAO,CAAE,CAAC,CAACS,MAAM,CAAC,QAAQ,CAAC;EAC9D,OAAOH,KAAK;AACd,CAAC;AAED,MAAMI,MAAM,GAAGA,CAACX,GAAG,EAAEY,GAAG,EAAEX,OAAO,KAAK;EACpC;EACAA,OAAO,GAAGA,OAAO,IAAIC,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;EAEvD,KAAK,MAAMQ,CAAC,IAAI,CAACZ,OAAO,EAAEA,OAAO,GAAG,CAAC,EAAEA,OAAO,GAAG,CAAC,CAAC,EAAE;IACnD,MAAMM,KAAK,GAAGR,IAAI,CAACC,GAAG,EAAEa,CAAC,CAAC;IAC1B,IAAIN,KAAK,KAAKK,GAAG,EAAE;MACjB,OAAO,IAAI;IACb;EACF;EAEA,OAAO,KAAK;AACd,CAAC;AAEDE,OAAO,CAACf,IAAI,GAAGA,IAAI;AACnBe,OAAO,CAACH,MAAM,GAAGA,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.parse-int.js");
|
|
4
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
|
+
/**
|
|
6
|
+
* https://github.com/simontabor/2fa
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* eslint-disable no-bitwise */
|
|
10
|
+
const crypto = require('crypto');
|
|
11
|
+
const sign = (key, counter) => {
|
|
12
|
+
const length = 6;
|
|
13
|
+
// eslint-disable-next-line no-param-reassign
|
|
14
|
+
counter = counter || Math.floor(Date.now() / 1000 / 30);
|
|
15
|
+
const hmac = crypto.createHmac('sha1', key);
|
|
16
|
+
|
|
17
|
+
// get the counter as bytes
|
|
18
|
+
const counterBytes = new Array(8);
|
|
19
|
+
for (let i = counterBytes.length - 1; i >= 0; i--) {
|
|
20
|
+
counterBytes[i] = counter & 0xff;
|
|
21
|
+
// eslint-disable-next-line no-param-reassign
|
|
22
|
+
counter >>= 8;
|
|
23
|
+
}
|
|
24
|
+
const token = hmac.update(Buffer.from(counterBytes)).digest('hex');
|
|
25
|
+
|
|
26
|
+
// get the token as bytes
|
|
27
|
+
const tokenBytes = [];
|
|
28
|
+
for (let i = 0; i < token.length; i += 2) {
|
|
29
|
+
tokenBytes.push(parseInt(token.substr(i, 2), 16));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// truncate to 4 bytes
|
|
33
|
+
// eslint-disable-next-line no-bitwise
|
|
34
|
+
let offset = tokenBytes[19] & 0xf;
|
|
35
|
+
let ourCode = (tokenBytes[offset++] & 0x7f) << 24 | (tokenBytes[offset++] & 0xff) << 16 | (tokenBytes[offset++] & 0xff) << 8 | tokenBytes[offset++] & 0xff;
|
|
36
|
+
|
|
37
|
+
// we want strings!
|
|
38
|
+
ourCode += '';
|
|
39
|
+
|
|
40
|
+
// truncate to correct length
|
|
41
|
+
ourCode = ourCode.substr(ourCode.length - length);
|
|
42
|
+
|
|
43
|
+
// 0 pad
|
|
44
|
+
while (ourCode.length < length) ourCode = "0".concat(ourCode);
|
|
45
|
+
return ourCode;
|
|
46
|
+
};
|
|
47
|
+
const verifyHOTP = (key, code, counter) => {
|
|
48
|
+
for (const i of [counter, counter - 1, counter + 1]) {
|
|
49
|
+
if (sign(key, i) === code) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
const verify = (key, code, counter) => {
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
counter = counter || Math.floor(Date.now() / 1000 / 30);
|
|
58
|
+
return verifyHOTP(key, code, counter);
|
|
59
|
+
};
|
|
60
|
+
exports.sign = sign;
|
|
61
|
+
exports.verify = verify;
|
|
62
|
+
//# sourceMappingURL=totp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.js","names":["crypto","require","sign","key","counter","length","Math","floor","Date","now","hmac","createHmac","counterBytes","Array","i","token","update","Buffer","from","digest","tokenBytes","push","parseInt","substr","offset","ourCode","concat","verifyHOTP","code","verify","exports"],"sources":["../../src/signer/totp.js"],"sourcesContent":["/**\n * https://github.com/simontabor/2fa\n */\n\n/* eslint-disable no-bitwise */\nconst crypto = require('crypto');\n\nconst sign = (key, counter) => {\n const length = 6;\n // eslint-disable-next-line no-param-reassign\n counter = counter || Math.floor(Date.now() / 1000 / 30);\n\n const hmac = crypto.createHmac('sha1', key);\n\n // get the counter as bytes\n const counterBytes = new Array(8);\n for (let i = counterBytes.length - 1; i >= 0; i--) {\n counterBytes[i] = counter & 0xff;\n // eslint-disable-next-line no-param-reassign\n counter >>= 8;\n }\n\n const token = hmac.update(Buffer.from(counterBytes)).digest('hex');\n\n // get the token as bytes\n const tokenBytes = [];\n for (let i = 0; i < token.length; i += 2) {\n tokenBytes.push(parseInt(token.substr(i, 2), 16));\n }\n\n // truncate to 4 bytes\n // eslint-disable-next-line no-bitwise\n let offset = tokenBytes[19] & 0xf;\n let ourCode =\n ((tokenBytes[offset++] & 0x7f) << 24) |\n ((tokenBytes[offset++] & 0xff) << 16) |\n ((tokenBytes[offset++] & 0xff) << 8) |\n (tokenBytes[offset++] & 0xff);\n\n // we want strings!\n ourCode += '';\n\n // truncate to correct length\n ourCode = ourCode.substr(ourCode.length - length);\n\n // 0 pad\n while (ourCode.length < length) ourCode = `0${ourCode}`;\n\n return ourCode;\n};\n\nconst verifyHOTP = (key, code, counter) => {\n for (const i of [counter, counter - 1, counter + 1]) {\n if (sign(key, i) === code) {\n return true;\n }\n }\n\n return false;\n};\n\nconst verify = (key, code, counter) => {\n // eslint-disable-next-line no-param-reassign\n counter = counter || Math.floor(Date.now() / 1000 / 30);\n\n return verifyHOTP(key, code, counter);\n};\n\nexports.sign = sign;\nexports.verify = verify;\n"],"mappings":";;;;AAAA;AACA;AACA;;AAEA;AACA,MAAMA,MAAM,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAEhC,MAAMC,IAAI,GAAGA,CAACC,GAAG,EAAEC,OAAO,KAAK;EAC7B,MAAMC,MAAM,GAAG,CAAC;EAChB;EACAD,OAAO,GAAGA,OAAO,IAAIE,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;EAEvD,MAAMC,IAAI,GAAGV,MAAM,CAACW,UAAU,CAAC,MAAM,EAAER,GAAG,CAAC;;EAE3C;EACA,MAAMS,YAAY,GAAG,IAAIC,KAAK,CAAC,CAAC,CAAC;EACjC,KAAK,IAAIC,CAAC,GAAGF,YAAY,CAACP,MAAM,GAAG,CAAC,EAAES,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACjDF,YAAY,CAACE,CAAC,CAAC,GAAGV,OAAO,GAAG,IAAI;IAChC;IACAA,OAAO,KAAK,CAAC;EACf;EAEA,MAAMW,KAAK,GAAGL,IAAI,CAACM,MAAM,CAACC,MAAM,CAACC,IAAI,CAACN,YAAY,CAAC,CAAC,CAACO,MAAM,CAAC,KAAK,CAAC;;EAElE;EACA,MAAMC,UAAU,GAAG,EAAE;EACrB,KAAK,IAAIN,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGC,KAAK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