@sharadox/account-web-library 0.1.0-development.24 → 0.1.0-development.27
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/README.md +95 -20
- package/distribution/account-activity/index.d.ts +16 -0
- package/distribution/account-activity/index.d.ts.map +1 -0
- package/distribution/account-activity/index.js +18 -0
- package/distribution/account-activity/index.js.map +1 -0
- package/distribution/account-activity/type.d.ts +15 -0
- package/distribution/account-activity/type.d.ts.map +1 -0
- package/distribution/account-activity/type.js.map +1 -0
- package/distribution/account-database/type.d.ts +57 -4
- package/distribution/account-database/type.d.ts.map +1 -1
- package/distribution/account-deletion/index.d.ts +18 -0
- package/distribution/account-deletion/index.d.ts.map +1 -0
- package/distribution/account-deletion/index.js +28 -0
- package/distribution/account-deletion/index.js.map +1 -0
- package/distribution/account-export/index.d.ts +17 -0
- package/distribution/account-export/index.d.ts.map +1 -0
- package/distribution/account-export/index.js +87 -0
- package/distribution/account-export/index.js.map +1 -0
- package/distribution/account-export/type.d.ts +40 -0
- package/distribution/account-export/type.d.ts.map +1 -0
- package/distribution/{username-change → account-export}/type.js.map +1 -1
- package/distribution/account-migration/index.d.ts.map +1 -1
- package/distribution/account-migration/index.js +110 -0
- package/distribution/account-migration/index.js.map +1 -1
- package/distribution/account-name/index.d.ts +13 -0
- package/distribution/account-name/index.d.ts.map +1 -0
- package/distribution/account-name/index.js +22 -0
- package/distribution/account-name/index.js.map +1 -0
- package/distribution/account-name/type.d.ts +9 -0
- package/distribution/account-name/type.d.ts.map +1 -0
- package/distribution/account-name/type.js +2 -0
- package/distribution/account-name/type.js.map +1 -0
- package/distribution/account-name-change/index.d.ts +15 -0
- package/distribution/account-name-change/index.d.ts.map +1 -0
- package/distribution/account-name-change/index.js +26 -0
- package/distribution/account-name-change/index.js.map +1 -0
- package/distribution/account-name-change/type.d.ts +7 -0
- package/distribution/account-name-change/type.d.ts.map +1 -0
- package/distribution/account-name-change/type.js +2 -0
- package/distribution/account-name-change/type.js.map +1 -0
- package/distribution/account-picture-change/index.d.ts +30 -0
- package/distribution/account-picture-change/index.d.ts.map +1 -0
- package/distribution/account-picture-change/index.js +70 -0
- package/distribution/account-picture-change/index.js.map +1 -0
- package/distribution/account-picture-change/type.d.ts +11 -0
- package/distribution/account-picture-change/type.d.ts.map +1 -0
- package/distribution/account-picture-change/type.js +2 -0
- package/distribution/account-picture-change/type.js.map +1 -0
- package/distribution/account-server/index.d.ts +11 -1
- package/distribution/account-server/index.d.ts.map +1 -1
- package/distribution/account-server/index.js +12 -1
- package/distribution/account-server/index.js.map +1 -1
- package/distribution/account-server/type.d.ts +2 -0
- package/distribution/account-server/type.d.ts.map +1 -1
- package/distribution/account-session-end/index.d.ts +15 -0
- package/distribution/account-session-end/index.d.ts.map +1 -0
- package/distribution/account-session-end/index.js +21 -0
- package/distribution/account-session-end/index.js.map +1 -0
- package/distribution/account-session-list/index.d.ts +16 -0
- package/distribution/account-session-list/index.d.ts.map +1 -0
- package/distribution/account-session-list/index.js +33 -0
- package/distribution/account-session-list/index.js.map +1 -0
- package/distribution/account-session-list/type.d.ts +13 -0
- package/distribution/account-session-list/type.d.ts.map +1 -0
- package/distribution/account-session-list/type.js +2 -0
- package/distribution/account-session-list/type.js.map +1 -0
- package/distribution/account-sign-in/index.d.ts +1 -1
- package/distribution/account-sign-in/index.d.ts.map +1 -1
- package/distribution/account-sign-in/index.js +4 -2
- package/distribution/account-sign-in/index.js.map +1 -1
- package/distribution/account-sign-in/type.d.ts +2 -0
- package/distribution/account-sign-in/type.d.ts.map +1 -1
- package/distribution/audit-event/index.d.ts.map +1 -1
- package/distribution/audit-event/index.js +12 -1
- package/distribution/audit-event/index.js.map +1 -1
- package/distribution/audit-event/type.d.ts +1 -0
- package/distribution/audit-event/type.d.ts.map +1 -1
- package/distribution/browser-session-read/index.d.ts.map +1 -1
- package/distribution/browser-session-read/index.js +5 -1
- package/distribution/browser-session-read/index.js.map +1 -1
- package/distribution/browser-session-read/type.d.ts +5 -1
- package/distribution/browser-session-read/type.d.ts.map +1 -1
- package/distribution/code-request/index.js +1 -1
- package/distribution/code-request/type.d.ts +1 -1
- package/distribution/code-sending/index.d.ts +14 -0
- package/distribution/code-sending/index.d.ts.map +1 -0
- package/distribution/code-sending/index.js +65 -0
- package/distribution/code-sending/index.js.map +1 -0
- package/distribution/code-sending/type.d.ts +31 -0
- package/distribution/code-sending/type.d.ts.map +1 -0
- package/distribution/code-sending/type.js +2 -0
- package/distribution/code-sending/type.js.map +1 -0
- package/distribution/contact-addition-flow/index.d.ts +31 -0
- package/distribution/contact-addition-flow/index.d.ts.map +1 -0
- package/distribution/contact-addition-flow/index.js +85 -0
- package/distribution/contact-addition-flow/index.js.map +1 -0
- package/distribution/contact-addition-flow/type.d.ts +22 -0
- package/distribution/contact-addition-flow/type.d.ts.map +1 -0
- package/distribution/contact-addition-flow/type.js +2 -0
- package/distribution/contact-addition-flow/type.js.map +1 -0
- package/distribution/database-error/index.d.ts +1 -1
- package/distribution/database-error/index.js +1 -1
- package/distribution/email-channel/index.js +1 -1
- package/distribution/identifier/index.d.ts +23 -0
- package/distribution/identifier/index.d.ts.map +1 -0
- package/distribution/identifier/index.js +32 -0
- package/distribution/identifier/index.js.map +1 -0
- package/distribution/identifier/type.d.ts +10 -0
- package/distribution/identifier/type.d.ts.map +1 -0
- package/distribution/identifier/type.js +2 -0
- package/distribution/identifier/type.js.map +1 -0
- package/distribution/identifier-availability/index.d.ts +11 -0
- package/distribution/identifier-availability/index.d.ts.map +1 -0
- package/distribution/identifier-availability/index.js +21 -0
- package/distribution/identifier-availability/index.js.map +1 -0
- package/distribution/identifier-change/index.d.ts +15 -0
- package/distribution/identifier-change/index.d.ts.map +1 -0
- package/distribution/identifier-change/index.js +43 -0
- package/distribution/identifier-change/index.js.map +1 -0
- package/distribution/identifier-change/type.d.ts +7 -0
- package/distribution/identifier-change/type.d.ts.map +1 -0
- package/distribution/identifier-change/type.js +2 -0
- package/distribution/identifier-change/type.js.map +1 -0
- package/distribution/memory-picture-storage/index.d.ts +15 -0
- package/distribution/memory-picture-storage/index.d.ts.map +1 -0
- package/distribution/memory-picture-storage/index.js +16 -0
- package/distribution/memory-picture-storage/index.js.map +1 -0
- package/distribution/one-time-code/index.d.ts +2 -2
- package/distribution/one-time-code/index.js +3 -3
- package/distribution/person-account/index.d.ts +7 -3
- package/distribution/person-account/index.d.ts.map +1 -1
- package/distribution/person-account/index.js +21 -9
- package/distribution/person-account/index.js.map +1 -1
- package/distribution/person-account/type.d.ts +5 -2
- package/distribution/person-account/type.d.ts.map +1 -1
- package/distribution/picture-key/index.d.ts +8 -0
- package/distribution/picture-key/index.d.ts.map +1 -0
- package/distribution/picture-key/index.js +10 -0
- package/distribution/picture-key/index.js.map +1 -0
- package/distribution/picture-preparation/index.d.ts +18 -0
- package/distribution/picture-preparation/index.d.ts.map +1 -0
- package/distribution/picture-preparation/index.js +86 -0
- package/distribution/picture-preparation/index.js.map +1 -0
- package/distribution/picture-preparation/type.d.ts +18 -0
- package/distribution/picture-preparation/type.d.ts.map +1 -0
- package/distribution/picture-preparation/type.js +2 -0
- package/distribution/picture-preparation/type.js.map +1 -0
- package/distribution/picture-storage/type.d.ts +11 -0
- package/distribution/picture-storage/type.d.ts.map +1 -0
- package/distribution/picture-storage/type.js +2 -0
- package/distribution/picture-storage/type.js.map +1 -0
- package/distribution/recovery-code-regeneration/index.d.ts +19 -0
- package/distribution/recovery-code-regeneration/index.d.ts.map +1 -0
- package/distribution/recovery-code-regeneration/index.js +34 -0
- package/distribution/recovery-code-regeneration/index.js.map +1 -0
- package/distribution/recovery-code-store/index.d.ts +25 -0
- package/distribution/recovery-code-store/index.d.ts.map +1 -0
- package/distribution/recovery-code-store/index.js +34 -0
- package/distribution/recovery-code-store/index.js.map +1 -0
- package/distribution/second-factor-finish/index.d.ts +12 -0
- package/distribution/second-factor-finish/index.d.ts.map +1 -0
- package/distribution/second-factor-finish/index.js +78 -0
- package/distribution/second-factor-finish/index.js.map +1 -0
- package/distribution/second-factor-finish/type.d.ts +27 -0
- package/distribution/second-factor-finish/type.d.ts.map +1 -0
- package/distribution/second-factor-finish/type.js +2 -0
- package/distribution/second-factor-finish/type.js.map +1 -0
- package/distribution/secret-encryption/index.d.ts +17 -0
- package/distribution/secret-encryption/index.d.ts.map +1 -0
- package/distribution/secret-encryption/index.js +37 -0
- package/distribution/secret-encryption/index.js.map +1 -0
- package/distribution/sign-in-finish/index.d.ts +3 -3
- package/distribution/sign-in-finish/index.d.ts.map +1 -1
- package/distribution/sign-in-finish/index.js +22 -5
- package/distribution/sign-in-finish/index.js.map +1 -1
- package/distribution/sign-in-finish/type.d.ts +8 -1
- package/distribution/sign-in-finish/type.d.ts.map +1 -1
- package/distribution/sign-in-start/index.d.ts +4 -6
- package/distribution/sign-in-start/index.d.ts.map +1 -1
- package/distribution/sign-in-start/index.js +14 -62
- package/distribution/sign-in-start/index.js.map +1 -1
- package/distribution/sign-in-start/type.d.ts +7 -0
- package/distribution/sign-in-start/type.d.ts.map +1 -1
- package/distribution/sign-up-finish/index.d.ts +4 -4
- package/distribution/sign-up-finish/index.d.ts.map +1 -1
- package/distribution/sign-up-finish/index.js +11 -6
- package/distribution/sign-up-finish/index.js.map +1 -1
- package/distribution/sign-up-finish/type.d.ts +6 -1
- package/distribution/sign-up-finish/type.d.ts.map +1 -1
- package/distribution/signed-ticket/index.d.ts +1 -1
- package/distribution/signed-ticket/index.js +1 -1
- package/distribution/step-up/index.d.ts +48 -0
- package/distribution/step-up/index.d.ts.map +1 -0
- package/distribution/step-up/index.js +83 -0
- package/distribution/step-up/index.js.map +1 -0
- package/distribution/step-up/type.d.ts +15 -0
- package/distribution/step-up/type.d.ts.map +1 -0
- package/distribution/step-up/type.js +2 -0
- package/distribution/{username → step-up}/type.js.map +1 -1
- package/distribution/test-person/index.d.ts +14 -0
- package/distribution/test-person/index.d.ts.map +1 -0
- package/distribution/test-person/index.js +20 -0
- package/distribution/test-person/index.js.map +1 -0
- package/distribution/totp/type.d.ts +1 -1
- package/distribution/totp/type.d.ts.map +1 -1
- package/distribution/totp-setup/index.d.ts +50 -0
- package/distribution/totp-setup/index.d.ts.map +1 -0
- package/distribution/totp-setup/index.js +136 -0
- package/distribution/totp-setup/index.js.map +1 -0
- package/distribution/totp-setup/type.d.ts +24 -0
- package/distribution/totp-setup/type.d.ts.map +1 -0
- package/distribution/totp-setup/type.js +2 -0
- package/distribution/totp-setup/type.js.map +1 -0
- package/package.json +4 -3
- package/distribution/username/index.d.ts +0 -23
- package/distribution/username/index.d.ts.map +0 -1
- package/distribution/username/index.js +0 -32
- package/distribution/username/index.js.map +0 -1
- package/distribution/username/type.d.ts +0 -10
- package/distribution/username/type.d.ts.map +0 -1
- package/distribution/username-availability/index.d.ts +0 -11
- package/distribution/username-availability/index.d.ts.map +0 -1
- package/distribution/username-availability/index.js +0 -21
- package/distribution/username-availability/index.js.map +0 -1
- package/distribution/username-change/index.d.ts +0 -15
- package/distribution/username-change/index.d.ts.map +0 -1
- package/distribution/username-change/index.js +0 -39
- package/distribution/username-change/index.js.map +0 -1
- package/distribution/username-change/type.d.ts +0 -7
- package/distribution/username-change/type.d.ts.map +0 -1
- /package/distribution/{username-change → account-activity}/type.js +0 -0
- /package/distribution/{username → account-export}/type.js +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { UsernameCheck } from "@sharadox/account-web-library/username/type";
|
|
2
|
-
/** The longest username. */
|
|
3
|
-
export declare const USERNAME_MAXIMUM_LENGTH = 50;
|
|
4
|
-
/**
|
|
5
|
-
* Checks a username against the rules:
|
|
6
|
-
* - 1 to 50 characters;
|
|
7
|
-
* - only A–Z, a–z and 0–9, with `-`, `_` or `.` allowed only between letters or digits, never two in a row;
|
|
8
|
-
* - shown as written, unique without regard to case (see `usernameKey`).
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* checkUsername("Luis-Pires"); // { valid: true, username: "Luis-Pires", key: "luis-pires" }
|
|
12
|
-
* checkUsername("a--b"); // { valid: false, reason: "characters" }
|
|
13
|
-
*/
|
|
14
|
-
export declare function checkUsername(username: string): UsernameCheck;
|
|
15
|
-
/**
|
|
16
|
-
* The form a username is unique in: lowercase, so `abc` and `aBc` are the same username (the database's unique index
|
|
17
|
-
* is on this key).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* usernameKey("aBc"); // "abc"
|
|
21
|
-
*/
|
|
22
|
-
export declare function usernameKey(username: string): string;
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/username/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAKjF,4BAA4B;AAC5B,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAI7D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** Letters and digits, with single `-`, `_` or `.` only between them. */
|
|
2
|
-
const PATTERN = /^[A-Za-z0-9]+(?:[-_.][A-Za-z0-9]+)*$/;
|
|
3
|
-
/** The longest username. */
|
|
4
|
-
export const USERNAME_MAXIMUM_LENGTH = 50;
|
|
5
|
-
/**
|
|
6
|
-
* Checks a username against the rules:
|
|
7
|
-
* - 1 to 50 characters;
|
|
8
|
-
* - only A–Z, a–z and 0–9, with `-`, `_` or `.` allowed only between letters or digits, never two in a row;
|
|
9
|
-
* - shown as written, unique without regard to case (see `usernameKey`).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* checkUsername("Luis-Pires"); // { valid: true, username: "Luis-Pires", key: "luis-pires" }
|
|
13
|
-
* checkUsername("a--b"); // { valid: false, reason: "characters" }
|
|
14
|
-
*/
|
|
15
|
-
export function checkUsername(username) {
|
|
16
|
-
if (username.length < 1 || username.length > USERNAME_MAXIMUM_LENGTH)
|
|
17
|
-
return { valid: false, reason: "length" };
|
|
18
|
-
if (!PATTERN.test(username))
|
|
19
|
-
return { valid: false, reason: "characters" };
|
|
20
|
-
return { valid: true, username, key: usernameKey(username) };
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The form a username is unique in: lowercase, so `abc` and `aBc` are the same username (the database's unique index
|
|
24
|
-
* is on this key).
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* usernameKey("aBc"); // "abc"
|
|
28
|
-
*/
|
|
29
|
-
export function usernameKey(username) {
|
|
30
|
-
return username.toLowerCase();
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/username/index.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,OAAO,GAAG,sCAAsC,CAAC;AAEvD,4BAA4B;AAC5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,uBAAuB;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAChH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAC3E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** A username that follows the rules (with its `key` for uniqueness), or why not. */
|
|
2
|
-
export type UsernameCheck = {
|
|
3
|
-
valid: true;
|
|
4
|
-
username: string;
|
|
5
|
-
key: string;
|
|
6
|
-
} | {
|
|
7
|
-
valid: false;
|
|
8
|
-
reason: "length" | "characters";
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/username/type.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,MAAM,aAAa,GACvB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Kysely } from "kysely";
|
|
2
|
-
import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
|
|
3
|
-
/**
|
|
4
|
-
* Whether a username can be taken: `available`, `taken` (in any case: `aBc` is taken when `abc` exists) or `invalid`
|
|
5
|
-
* (outside the rules). Rate limit callers: it tells whether an account exists.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* await usernameAvailability(database, "Luis-Pires"); // "available"
|
|
9
|
-
*/
|
|
10
|
-
export declare function usernameAvailability(database: Kysely<AccountDatabase>, username: string): Promise<"available" | "taken" | "invalid">;
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/username-availability/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAG3F;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC,CAS5C"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { sql } from "kysely";
|
|
2
|
-
import { checkUsername } from "@sharadox/account-web-library/username";
|
|
3
|
-
/**
|
|
4
|
-
* Whether a username can be taken: `available`, `taken` (in any case: `aBc` is taken when `abc` exists) or `invalid`
|
|
5
|
-
* (outside the rules). Rate limit callers: it tells whether an account exists.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* await usernameAvailability(database, "Luis-Pires"); // "available"
|
|
9
|
-
*/
|
|
10
|
-
export async function usernameAvailability(database, username) {
|
|
11
|
-
const check = checkUsername(username);
|
|
12
|
-
if (!check.valid)
|
|
13
|
-
return "invalid";
|
|
14
|
-
const found = await database
|
|
15
|
-
.selectFrom("account")
|
|
16
|
-
.select("id")
|
|
17
|
-
.where(sql `lower(username)`, "=", check.key)
|
|
18
|
-
.executeTakeFirst();
|
|
19
|
-
return found ? "taken" : "available";
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/username-availability/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAiC,EACjC,QAAgB;IAEhB,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,QAAQ;SACzB,UAAU,CAAC,SAAS,CAAC;SACrB,MAAM,CAAC,IAAI,CAAC;SACZ,KAAK,CAAC,GAAG,CAAQ,iBAAiB,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;SACnD,gBAAgB,EAAE,CAAC;IACtB,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AACvC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Kysely } from "kysely";
|
|
2
|
-
import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
|
|
3
|
-
import type { UsernameChangeResult } from "@sharadox/account-web-library/username-change/type";
|
|
4
|
-
/**
|
|
5
|
-
* Changes an account's username whenever its owner wants; the old one is free for anyone at once. Accounts are
|
|
6
|
-
* referenced by id, so nothing breaks; the audit log keeps the history. Changing only the case is allowed.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* await changeUsername(database, { accountId, username: "Luis-Pires" }); // { changed: true }
|
|
10
|
-
*/
|
|
11
|
-
export declare function changeUsername(database: Kysely<AccountDatabase>, { accountId, username }: {
|
|
12
|
-
accountId: string;
|
|
13
|
-
username: string;
|
|
14
|
-
}): Promise<UsernameChangeResult>;
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/username-change/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAI3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE/F;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC/D,OAAO,CAAC,oBAAoB,CAAC,CAwB/B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
|
|
2
|
-
import { databaseError } from "@sharadox/account-web-library/database-error";
|
|
3
|
-
import { checkUsername } from "@sharadox/account-web-library/username";
|
|
4
|
-
/**
|
|
5
|
-
* Changes an account's username whenever its owner wants; the old one is free for anyone at once. Accounts are
|
|
6
|
-
* referenced by id, so nothing breaks; the audit log keeps the history. Changing only the case is allowed.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* await changeUsername(database, { accountId, username: "Luis-Pires" }); // { changed: true }
|
|
10
|
-
*/
|
|
11
|
-
export async function changeUsername(database, { accountId, username }) {
|
|
12
|
-
if (!checkUsername(username).valid)
|
|
13
|
-
return { changed: false, reason: "username-invalid" };
|
|
14
|
-
try {
|
|
15
|
-
return await database.transaction().execute(async (transaction) => {
|
|
16
|
-
const current = await transaction
|
|
17
|
-
.selectFrom("account")
|
|
18
|
-
.select("username")
|
|
19
|
-
.where("id", "=", accountId)
|
|
20
|
-
.forUpdate()
|
|
21
|
-
.executeTakeFirst();
|
|
22
|
-
if (!current)
|
|
23
|
-
return { changed: false, reason: "no-account" };
|
|
24
|
-
await transaction.updateTable("account").set({ username }).where("id", "=", accountId).execute();
|
|
25
|
-
await recordAuditEvent(transaction, {
|
|
26
|
-
accountId,
|
|
27
|
-
action: "account.username-changed",
|
|
28
|
-
detail: { from: current.username, to: username },
|
|
29
|
-
});
|
|
30
|
-
return { changed: true };
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (databaseError(error)?.constraint === "account_username_key")
|
|
35
|
-
return { changed: false, reason: "username-taken" };
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/username-change/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAiC,EACjC,EAAE,SAAS,EAAE,QAAQ,EAA2C;IAEhE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC1F,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAiC,EAAE;YAC/F,MAAM,OAAO,GAAG,MAAM,WAAW;iBAC9B,UAAU,CAAC,SAAS,CAAC;iBACrB,MAAM,CAAC,UAAU,CAAC;iBAClB,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC;iBAC3B,SAAS,EAAE;iBACX,gBAAgB,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO;gBAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;YAC9D,MAAM,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;YACjG,MAAM,gBAAgB,CAAC,WAAW,EAAE;gBAClC,SAAS;gBACT,MAAM,EAAE,0BAA0B;gBAClC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;aACjD,CAAC,CAAC;YACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,UAAU,KAAK,sBAAsB;YAC7D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;QACtD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/username-change/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAC9B;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,YAAY,CAAA;CAAE,CAAC"}
|
|
File without changes
|
|
File without changes
|