@alwatr/crypto 1.1.1 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.1.3 (2023-09-19)
7
+
8
+ **Note:** Version bump only for package @alwatr/crypto
9
+
10
+ ## [1.1.2](https://github.com/AliMD/alwatr/compare/@alwatr/crypto@1.1.1...@alwatr/crypto@1.1.2) (2023-09-12)
11
+
12
+ **Note:** Version bump only for package @alwatr/crypto
13
+
6
14
  ## [1.1.1](https://github.com/AliMD/alwatr/compare/@alwatr/crypto@1.1.0...@alwatr/crypto@1.1.1) (2023-09-12)
7
15
 
8
16
  **Note:** Version bump only for package @alwatr/crypto
@@ -15,21 +23,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
15
23
 
16
24
  ### Features
17
25
 
18
- * **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650))
26
+ - **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650))
19
27
 
20
28
  ### Performance Improvements
21
29
 
22
- * **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd))
30
+ - **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd))
23
31
 
24
32
  # 0.31.0 (2023-05-08)
25
33
 
26
34
  ### Bug Fixes
27
35
 
28
- * **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2))
36
+ - **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2))
29
37
 
30
38
  ### Features
31
39
 
32
- * **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad))
40
+ - **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad))
33
41
 
34
42
  # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14)
35
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/crypto",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Secure authentication HOTP token generator (the HMAC-based One-Time Password algorithm) and crypto utils written in tiny TypeScript module.",
5
5
  "keywords": [
6
6
  "crypto",
@@ -40,9 +40,9 @@
40
40
  "url": "https://github.com/AliMD/alwatr/issues"
41
41
  },
42
42
  "dependencies": {
43
- "@alwatr/logger": "^1.1.1",
44
- "@alwatr/math": "^1.1.1",
43
+ "@alwatr/logger": "^1.1.3",
44
+ "@alwatr/math": "^1.1.3",
45
45
  "tslib": "^2.6.2"
46
46
  },
47
- "gitHead": "ebc98f75330ab77c7a5bfeebe0fd1f4748bf3821"
47
+ "gitHead": "e48c6b60a1836901902e523ab1f07019e3cddb76"
48
48
  }
package/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAA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,mBAAmB;IAClC;;OAEG;IACH,SAAS,EAAE,eAAe,CAAC;IAE3B;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,oBAAoB,CAAC;IAClC,UAAU,EAAE,mBAAmB,CAAC;CACjC"}
package/type.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["import type {DurationString} from '@alwatr/math';\n\nexport type CryptoAlgorithm = 'md5' | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512';\nexport type CryptoEncoding = 'base64' | 'base64url' | 'hex' | 'binary';\n\nexport type TokenStatus = 'valid' | 'invalid' | 'expired';\nexport type HashStatus = 'valid' | 'invalid';\n\n\nexport interface TokenGeneratorConfig {\n /**\n * Secret string data to generate token.\n */\n secret: string;\n\n /**\n * Token expiration time.\n *\n * `null` mean without expiration time\n */\n duration: DurationString | null;\n\n /**\n * OpenSSl digest algorithm.\n */\n algorithm: CryptoAlgorithm;\n\n /**\n * Encoding of token.\n */\n encoding: CryptoEncoding;\n}\n\nexport interface HashGeneratorConfig {\n /**\n * OpenSSl digest algorithm.\n */\n algorithm: CryptoAlgorithm;\n\n /**\n * Encoding of hash.\n */\n encoding: CryptoEncoding;\n\n /**\n * CRC hash max length.\n */\n crcLength?: number;\n}\n\nexport interface UserFactoryConfig {\n tokenConfig: TokenGeneratorConfig;\n hashConfig: HashGeneratorConfig;\n}\n"]}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["import type {DurationString} from '@alwatr/math';\n\nexport type CryptoAlgorithm = 'md5' | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512';\nexport type CryptoEncoding = 'base64' | 'base64url' | 'hex' | 'binary';\n\nexport type TokenStatus = 'valid' | 'invalid' | 'expired';\nexport type HashStatus = 'valid' | 'invalid';\n\nexport interface TokenGeneratorConfig {\n /**\n * Secret string data to generate token.\n */\n secret: string;\n\n /**\n * Token expiration time.\n *\n * `null` mean without expiration time\n */\n duration: DurationString | null;\n\n /**\n * OpenSSl digest algorithm.\n */\n algorithm: CryptoAlgorithm;\n\n /**\n * Encoding of token.\n */\n encoding: CryptoEncoding;\n}\n\nexport interface HashGeneratorConfig {\n /**\n * OpenSSl digest algorithm.\n */\n algorithm: CryptoAlgorithm;\n\n /**\n * Encoding of hash.\n */\n encoding: CryptoEncoding;\n\n /**\n * CRC hash max length.\n */\n crcLength?: number;\n}\n\nexport interface UserFactoryConfig {\n tokenConfig: TokenGeneratorConfig;\n hashConfig: HashGeneratorConfig;\n}\n"]}
package/user.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAC,mBAAmB,EAAE,oBAAoB,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAEtF;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,SAAS,CAAC,eAAe,uBAAC;IAC1B,SAAS,CAAC,cAAc,sBAAC;gBAGrB,UAAU,EAAE,mBAAmB,EAC/B,WAAW,EAAE,oBAAoB;IAMrC;;;;;;;;;;;OAWG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI7B;;;;;;;;OAQG;IACH,aAAa,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,MAAM;IAIlE;;;;;;;;;;OAUG;IACH,WAAW,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW;CAGrF"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAC,mBAAmB,EAAE,oBAAoB,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAEtF;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,SAAS,CAAC,eAAe,uBAAC;IAC1B,SAAS,CAAC,cAAc,sBAAC;gBAEb,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,oBAAoB;IAK9E;;;;;;;;;;;OAWG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI7B;;;;;;;;OAQG;IACH,aAAa,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,MAAM;IAIlE;;;;;;;;;;OAUG;IACH,WAAW,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW;CAGrF"}
package/user.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAIhD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAI5B,YACI,UAA+B,EAC/B,WAAiC;QAEnC,IAAI,CAAC,cAAc,GAAG,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU;QACR,OAAO,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC;IACxD,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,aAAa,CAAC,YAA2C;QACvD,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;;OAUG;IACH,WAAW,CAAC,YAA2C,EAAE,KAAa;QACpE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["import {AlwatrHashGenerator} from './hash.js';\nimport {AlwatrTokenGenerator} from './token.js';\n\nimport type {HashGeneratorConfig, TokenGeneratorConfig, TokenStatus} from './type.js';\n\n/**\n * User factory for generating self-validate user-id and user-token.\n */\nexport class AlwatrUserFactory {\n protected _tokenGenerator;\n protected _hashGenerator;\n\n constructor(\n hashConfig: HashGeneratorConfig,\n tokenConfig: TokenGeneratorConfig,\n ) {\n this._hashGenerator = new AlwatrHashGenerator(hashConfig);\n this._tokenGenerator = new AlwatrTokenGenerator(tokenConfig);\n }\n\n /**\n * Generate new self-verifiable user-id.\n *\n * Example:\n *\n * ```ts\n * const newUser = {\n * id: userFactory.generateId(),\n * ...\n * }\n * ```\n */\n generateId(): string {\n return 'U' + this._hashGenerator.randomSelfValidate();\n }\n\n /**\n * Validate user-id without token.\n *\n * Example:\n *\n * ```ts\n * if (!userFactory.verifyId(user.id)) {\n * new Error('invalid_user');\n * }\n * ```\n */\n verifyId(id: string): boolean {\n return this._hashGenerator.verifySelfValidate(id.substring(1));\n }\n\n /**\n * Generate user auth token.\n *\n * Example:\n *\n * ```ts\n * const userToken = userFactory.generateToken([user.id, user.lpe]);\n * ```\n */\n generateToken(uniquelyList: (string | number | boolean)[]): string {\n return this._tokenGenerator.generate(uniquelyList.join());\n }\n\n /**\n * Verify user auth token.\n *\n * Example:\n *\n * ```ts\n * if (!userFactory.verifyToken([user.id, user.lpe], userToken)) {\n * new error('invalid_token');\n * }\n * ```\n */\n verifyToken(uniquelyList: (string | number | boolean)[], token: string): TokenStatus {\n return this._tokenGenerator.verify(uniquelyList.join(), token);\n }\n}\n"]}
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAIhD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAI5B,YAAY,UAA+B,EAAE,WAAiC;QAC5E,IAAI,CAAC,cAAc,GAAG,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU;QACR,OAAO,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC;IACxD,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,aAAa,CAAC,YAA2C;QACvD,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;;OAUG;IACH,WAAW,CAAC,YAA2C,EAAE,KAAa;QACpE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["import {AlwatrHashGenerator} from './hash.js';\nimport {AlwatrTokenGenerator} from './token.js';\n\nimport type {HashGeneratorConfig, TokenGeneratorConfig, TokenStatus} from './type.js';\n\n/**\n * User factory for generating self-validate user-id and user-token.\n */\nexport class AlwatrUserFactory {\n protected _tokenGenerator;\n protected _hashGenerator;\n\n constructor(hashConfig: HashGeneratorConfig, tokenConfig: TokenGeneratorConfig) {\n this._hashGenerator = new AlwatrHashGenerator(hashConfig);\n this._tokenGenerator = new AlwatrTokenGenerator(tokenConfig);\n }\n\n /**\n * Generate new self-verifiable user-id.\n *\n * Example:\n *\n * ```ts\n * const newUser = {\n * id: userFactory.generateId(),\n * ...\n * }\n * ```\n */\n generateId(): string {\n return 'U' + this._hashGenerator.randomSelfValidate();\n }\n\n /**\n * Validate user-id without token.\n *\n * Example:\n *\n * ```ts\n * if (!userFactory.verifyId(user.id)) {\n * new Error('invalid_user');\n * }\n * ```\n */\n verifyId(id: string): boolean {\n return this._hashGenerator.verifySelfValidate(id.substring(1));\n }\n\n /**\n * Generate user auth token.\n *\n * Example:\n *\n * ```ts\n * const userToken = userFactory.generateToken([user.id, user.lpe]);\n * ```\n */\n generateToken(uniquelyList: (string | number | boolean)[]): string {\n return this._tokenGenerator.generate(uniquelyList.join());\n }\n\n /**\n * Verify user auth token.\n *\n * Example:\n *\n * ```ts\n * if (!userFactory.verifyToken([user.id, user.lpe], userToken)) {\n * new error('invalid_token');\n * }\n * ```\n */\n verifyToken(uniquelyList: (string | number | boolean)[], token: string): TokenStatus {\n return this._tokenGenerator.verify(uniquelyList.join(), token);\n }\n}\n"]}