@1auth/account-username 0.0.0-beta.1 → 0.0.0-beta.2

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.
Files changed (3) hide show
  1. package/README.md +44 -0
  2. package/index.js +5 -5
  3. package/package.json +15 -11
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ <div align="center">
2
+ <h1>@1auth/account-username</h1>
3
+ <!--<img alt="1auth logo" src="https://raw.githubusercontent.com/willfarrell/1auth/main/docs/img/logo.svg"/>-->
4
+ <p><strong>Username validation and management for account authentication</strong></p>
5
+ <p>
6
+ <a href="https://github.com/willfarrell/1auth/actions/workflows/test-unit.yml"><img src="https://github.com/willfarrell/1auth/actions/workflows/test-unit.yml/badge.svg" alt="GitHub Actions unit test status"></a>
7
+ <a href="https://github.com/willfarrell/1auth/actions/workflows/test-dast.yml"><img src="https://github.com/willfarrell/1auth/actions/workflows/test-dast.yml/badge.svg" alt="GitHub Actions dast test status"></a>
8
+ <a href="https://github.com/willfarrell/1auth/actions/workflows/test-perf.yml"><img src="https://github.com/willfarrell/1auth/actions/workflows/test-perf.yml/badge.svg" alt="GitHub Actions perf test status"></a>
9
+ <a href="https://github.com/willfarrell/1auth/actions/workflows/test-sast.yml"><img src="https://github.com/willfarrell/1auth/actions/workflows/test-sast.yml/badge.svg" alt="GitHub Actions SAST test status"></a>
10
+ <a href="https://github.com/willfarrell/1auth/actions/workflows/test-lint.yml"><img src="https://github.com/willfarrell/1auth/actions/workflows/test-lint.yml/badge.svg" alt="GitHub Actions lint test status"></a>
11
+ <br/>
12
+ <a href="https://www.npmjs.com/package/@1auth/account-username"><img alt="npm version" src="https://img.shields.io/npm/v/@1auth/account-username.svg"></a>
13
+ <a href="https://packagephobia.com/result?p=@1auth/account-username"><img src="https://packagephobia.com/badge?p=@1auth/account-username" alt="npm install size"></a>
14
+ <a href="https://www.npmjs.com/package/@1auth/account-username">
15
+ <img alt="npm weekly downloads" src="https://img.shields.io/npm/dw/@1auth/account-username.svg"></a>
16
+ <a href="https://www.npmjs.com/package/@1auth/account-username#provenance">
17
+ <img alt="npm provenance" src="https://img.shields.io/badge/provenance-Yes-brightgreen"></a>
18
+ <br/>
19
+ <a href="https://scorecard.dev/viewer/?uri=github.com/willfarrell/1auth"><img src="https://api.scorecard.dev/projects/github.com/willfarrell/1auth/badge" alt="Open Source Security Foundation (OpenSSF) Scorecard"></a>
20
+ <a href="https://slsa.dev"><img src="https://slsa.dev/images/gh-badge-level3.svg" alt="SLSA 3"></a>
21
+ <a href="https://github.com/willfarrell/1auth/blob/main/docs/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a>
22
+ <a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
23
+ <a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
24
+ </p>
25
+ <p>You can read the documentation at: <a href="https://1auth.js.org">https://1auth.js.org</a></p>
26
+ </div>
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ npm install @1auth/account-username
32
+ ```
33
+
34
+ ## Documentation and examples
35
+
36
+ For documentation and examples, refer to the main [1auth monorepo on GitHub](https://github.com/willfarrell/1auth) or the [1auth website](https://1auth.js.org).
37
+
38
+ ## Contributing
39
+
40
+ Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/willfarrell/1auth/issues) or to [submit Pull Requests](https://github.com/willfarrell/1auth/pulls).
41
+
42
+ ## License
43
+
44
+ Licensed under [MIT License](LICENSE). Copyright (c) 2020-2026 [will Farrell](https://github.com/willfarrell) and [contributors](https://github.com/willfarrell/1auth/graphs/contributors).
package/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import { createSeasonedDigest, symmetricDecryptFields } from "@1auth/crypto";
10
10
 
11
11
  // Only allow characters that are safe to encode
12
- // not allowed because it can be used to declare and extension
12
+ // not allowed because it can be used to declare an extension
13
13
  let usernameBlacklistRegExp;
14
14
  const options = {
15
15
  id: "username",
@@ -18,8 +18,8 @@ const options = {
18
18
  minLength: 1,
19
19
  maxLength: 32,
20
20
  };
21
- export default (params) => {
22
- Object.assign(options, accountOptions(), params);
21
+ export default (opt = {}) => {
22
+ Object.assign(options, accountOptions(), opt);
23
23
  if (options.usernameBlacklist.length) {
24
24
  usernameBlacklistRegExp = new RegExp(
25
25
  `(${options.usernameBlacklist.map((value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`,
@@ -30,7 +30,7 @@ export default (params) => {
30
30
  export const exists = async (username) => {
31
31
  const usernameSanitized = sanitize(username);
32
32
  const usernameDigest = createSeasonedDigest(usernameSanitized);
33
- return options.store.exists(options.table, {
33
+ return await options.store.exists(options.table, {
34
34
  digest: usernameDigest,
35
35
  });
36
36
  };
@@ -115,7 +115,7 @@ export const validateLength = (value) => {
115
115
  };
116
116
 
117
117
  export const validateAllowedChar = (value) => {
118
- // TODO URL encode compare
118
+ // allowedCharRegExp only permits URL-safe chars, no encoding needed
119
119
  if (!options.allowedCharRegExp.test(value)) {
120
120
  return "400 Bad Request";
121
121
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@1auth/account-username",
3
- "version": "0.0.0-beta.1",
4
- "description": "",
3
+ "version": "0.0.0-beta.2",
4
+ "description": "Username validation and management for account authentication",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=24"
@@ -12,18 +12,14 @@
12
12
  },
13
13
  "main": "./index.js",
14
14
  "module": "./index.js",
15
+ "sideEffects": false,
15
16
  "exports": {
16
17
  ".": {
17
- "import": {
18
- "types": "./index.d.ts",
19
- "default": "./index.js"
20
- }
18
+ "import": "./index.js"
21
19
  }
22
20
  },
23
- "types": "index.d.ts",
24
21
  "files": [
25
- "index.js",
26
- "index.d.ts"
22
+ "index.js"
27
23
  ],
28
24
  "scripts": {
29
25
  "test": "npm run test:unit",
@@ -34,7 +30,14 @@
34
30
  "type": "github",
35
31
  "url": "https://github.com/sponsors/willfarrell"
36
32
  },
37
- "keywords": [],
33
+ "keywords": [
34
+ "1auth",
35
+ "OWASP",
36
+ "ASVS",
37
+ "account",
38
+ "username",
39
+ "identity"
40
+ ],
38
41
  "author": {
39
42
  "name": "1auth contributors",
40
43
  "url": "https://github.com/willfarrell/1auth/graphs/contributors"
@@ -50,6 +53,7 @@
50
53
  "homepage": "https://github.com/willfarrell/1auth",
51
54
  "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
52
55
  "dependencies": {
53
- "@1auth/account": "0.0.0-beta.1"
56
+ "@1auth/account": "0.0.0-beta.2",
57
+ "@1auth/crypto": "0.0.0-beta.2"
54
58
  }
55
59
  }