@blackbyte/sugar 1.0.0-beta.38 → 1.0.0-beta.39

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.
@@ -1,8 +1,9 @@
1
1
  import aes from './aes/aes.js';
2
2
  import base64 from './base64/base64.js';
3
+ import bcrypt from './bcrypt/bcrypt.js';
3
4
  import md5 from './md5/md5.js';
4
5
  import object from './object/object.js';
5
6
  import sha256 from './sha256/sha256.js';
6
7
  import sha512 from './sha512/sha512.js';
7
8
  import stega from './stega/stega.js';
8
- export { aes as __aes, base64 as __base64, md5 as __md5, object as __object, sha256 as __sha256, sha512 as __sha512, stega as __stega, aes, base64, md5, object, sha256, sha512, stega, };
9
+ export { aes as __aes, base64 as __base64, bcrypt as __bcrypt, md5 as __md5, object as __object, sha256 as __sha256, sha512 as __sha512, stega as __stega, aes, base64, bcrypt, md5, object, sha256, sha512, stega, };
@@ -1,9 +1,10 @@
1
1
  import aes from './aes/aes.js';
2
2
  import base64 from './base64/base64.js';
3
+ import bcrypt from './bcrypt/bcrypt.js';
3
4
  import md5 from './md5/md5.js';
4
5
  import object from './object/object.js';
5
6
  import sha256 from './sha256/sha256.js';
6
7
  import sha512 from './sha512/sha512.js';
7
8
  import stega from './stega/stega.js';
8
- export { aes as __aes, base64 as __base64, md5 as __md5, object as __object, sha256 as __sha256, sha512 as __sha512, stega as __stega, aes, base64, md5, object, sha256, sha512, stega, };
9
+ export { aes as __aes, base64 as __base64, bcrypt as __bcrypt, md5 as __md5, object as __object, sha256 as __sha256, sha512 as __sha512, stega as __stega, aes, base64, bcrypt, md5, object, sha256, sha512, stega, };
9
10
  //# sourceMappingURL=_exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/shared/crypto/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AAErC,OAAO,EACL,GAAG,IAAI,KAAK,EACZ,MAAM,IAAI,QAAQ,EAClB,GAAG,IAAI,KAAK,EACZ,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,KAAK,IAAI,OAAO,EAChB,GAAG,EACH,MAAM,EACN,GAAG,EACH,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,GACN,CAAC"}
1
+ {"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/shared/crypto/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AAErC,OAAO,EACL,GAAG,IAAI,KAAK,EACZ,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,GAAG,IAAI,KAAK,EACZ,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,KAAK,IAAI,OAAO,EAChB,GAAG,EACH,MAAM,EACN,MAAM,EACN,GAAG,EACH,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,GACN,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @name bcrypt
3
+ * @namespace shared.crypto
4
+ * @type Object
5
+ * @platform js
6
+ * @platform node
7
+ * @status stable
8
+ *
9
+ * Expose two function named "encrypt" that you can use to process your content using the bcrypt algorithm
10
+ *
11
+ * @snippet bcrypt.encrypt($1)
12
+ *
13
+ * @example js
14
+ * import { bcrypt } from '@blackbyte/sugar/crypto';
15
+ * bcrypt.encrypt('hello world');
16
+ *
17
+ * @see https://www.npmjs.com/package/bcryptjs?activeTab=readme
18
+ * @since 1.0.0
19
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
20
+ */
21
+ declare const _default: {
22
+ /**
23
+ * @name encrypt
24
+ * @type Function
25
+ *
26
+ * Encrypt
27
+ *
28
+ * @param {String} message The message to encrypt
29
+ * @return {String} The encrypted string
30
+ *
31
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
32
+ */
33
+ encrypt: (message: any, saltRounds?: number) => string;
34
+ /**
35
+ * @name compareSync
36
+ * @type Function
37
+ *
38
+ * Compare synchronously
39
+ *
40
+ * @param {String} message The message to compare
41
+ * @param {String} hash The hash to compare against
42
+ * @return {Boolean} True if the message matches the hash, false otherwise
43
+ *
44
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
45
+ */
46
+ compareSync: (message: any, hash: string) => boolean;
47
+ /**
48
+ * @name compare
49
+ * @type Function
50
+ *
51
+ * Compare asynchronously
52
+ *
53
+ * @param {String} message The message to compare
54
+ * @param {String} hash The hash to compare against
55
+ * @return {Promise<Boolean>} A promise that resolves to true if the message matches the hash, false otherwise
56
+ *
57
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
58
+ */
59
+ compare: (message: any, hash: string) => Promise<boolean>;
60
+ };
61
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import bcryptjs from 'bcryptjs';
2
+ /**
3
+ * @name bcrypt
4
+ * @namespace shared.crypto
5
+ * @type Object
6
+ * @platform js
7
+ * @platform node
8
+ * @status stable
9
+ *
10
+ * Expose two function named "encrypt" that you can use to process your content using the bcrypt algorithm
11
+ *
12
+ * @snippet bcrypt.encrypt($1)
13
+ *
14
+ * @example js
15
+ * import { bcrypt } from '@blackbyte/sugar/crypto';
16
+ * bcrypt.encrypt('hello world');
17
+ *
18
+ * @see https://www.npmjs.com/package/bcryptjs?activeTab=readme
19
+ * @since 1.0.0
20
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
21
+ */
22
+ export default {
23
+ /**
24
+ * @name encrypt
25
+ * @type Function
26
+ *
27
+ * Encrypt
28
+ *
29
+ * @param {String} message The message to encrypt
30
+ * @return {String} The encrypted string
31
+ *
32
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
33
+ */
34
+ encrypt: function (message, saltRounds = 10) {
35
+ if (typeof message !== 'string')
36
+ message = String(message);
37
+ const salt = bcryptjs.genSaltSync(saltRounds);
38
+ return bcryptjs.hashSync(message, salt);
39
+ },
40
+ /**
41
+ * @name compareSync
42
+ * @type Function
43
+ *
44
+ * Compare synchronously
45
+ *
46
+ * @param {String} message The message to compare
47
+ * @param {String} hash The hash to compare against
48
+ * @return {Boolean} True if the message matches the hash, false otherwise
49
+ *
50
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
51
+ */
52
+ compareSync: function (message, hash) {
53
+ if (typeof message !== 'string')
54
+ message = String(message);
55
+ return bcryptjs.compareSync(message, hash);
56
+ },
57
+ /**
58
+ * @name compare
59
+ * @type Function
60
+ *
61
+ * Compare asynchronously
62
+ *
63
+ * @param {String} message The message to compare
64
+ * @param {String} hash The hash to compare against
65
+ * @return {Promise<Boolean>} A promise that resolves to true if the message matches the hash, false otherwise
66
+ *
67
+ * @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
68
+ */
69
+ compare: function (message, hash) {
70
+ if (typeof message !== 'string')
71
+ message = String(message);
72
+ return bcryptjs.compare(message, hash);
73
+ },
74
+ };
75
+ //# sourceMappingURL=bcrypt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bcrypt.js","sourceRoot":"","sources":["../../../../src/shared/crypto/bcrypt/bcrypt.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAe;IACb;;;;;;;;;;OAUG;IACH,OAAO,EAAE,UAAU,OAAY,EAAE,aAAqB,EAAE;QACtD,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC9C,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,EAAE,UAAU,OAAY,EAAE,IAAY;QAC/C,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,UAAU,OAAY,EAAE,IAAY;QAC3C,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackbyte/sugar",
3
3
  "description": "The toolkit that you missed... like a sugar in your coffee!",
4
- "version": "1.0.0-beta.38",
4
+ "version": "1.0.0-beta.39",
5
5
  "keywords": [
6
6
  "javascript",
7
7
  "typescript",
@@ -219,6 +219,7 @@
219
219
  "@faker-js/faker": "^8.4.1",
220
220
  "@vercel/stega": "^1.0.0",
221
221
  "aggregation": "^1.2.7",
222
+ "bcryptjs": "^3.0.3",
222
223
  "chalk": "^5.3.0",
223
224
  "change-case": "^5.4.3",
224
225
  "clipboardy": "^4.0.0",