@nu-art/user-account-backend 0.401.9 → 0.500.6

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 (35) hide show
  1. package/SlackReporter.js +3 -3
  2. package/_entity/account/ModuleBE_AccountDB.d.ts +43 -31
  3. package/_entity/account/ModuleBE_AccountDB.js +410 -321
  4. package/_entity/account/ModuleBE_SAML.d.ts +3 -3
  5. package/_entity/account/ModuleBE_SAML.js +107 -62
  6. package/_entity/account/module-pack.d.ts +1 -1
  7. package/_entity/account/module-pack.js +2 -2
  8. package/_entity/failed-login-attempt/ModuleBE_FailedLoginAttemptDB.d.ts +8 -13
  9. package/_entity/failed-login-attempt/ModuleBE_FailedLoginAttemptDB.js +2 -4
  10. package/_entity/failed-login-attempt/module-pack.d.ts +1 -1
  11. package/_entity/failed-login-attempt/module-pack.js +2 -2
  12. package/_entity/login-attempts/ModuleBE_LoginAttemptDB.d.ts +5 -8
  13. package/_entity/login-attempts/ModuleBE_LoginAttemptDB.js +2 -2
  14. package/_entity/login-attempts/dispatchers.d.ts +4 -3
  15. package/_entity/login-attempts/module-pack.d.ts +1 -1
  16. package/_entity/login-attempts/module-pack.js +2 -2
  17. package/_entity/session/ModuleBE_SessionDB.d.ts +23 -25
  18. package/_entity/session/ModuleBE_SessionDB.js +46 -44
  19. package/_entity/session/consts.d.ts +8 -5
  20. package/_entity/session/consts.js +3 -2
  21. package/index.d.ts +12 -1
  22. package/index.js +12 -1
  23. package/module-pack.d.ts +2 -2
  24. package/module-pack.js +9 -5
  25. package/package.json +14 -11
  26. package/_entity/account/index.d.ts +0 -3
  27. package/_entity/account/index.js +0 -3
  28. package/_entity/failed-login-attempt/index.d.ts +0 -2
  29. package/_entity/failed-login-attempt/index.js +0 -2
  30. package/_entity/login-attempts/index.d.ts +0 -2
  31. package/_entity/login-attempts/index.js +0 -2
  32. package/_entity/session/index.d.ts +0 -3
  33. package/_entity/session/index.js +0 -3
  34. package/_entity.d.ts +0 -8
  35. package/_entity.js +0 -8
package/SlackReporter.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
2
  import { ModuleBE_Slack } from '@nu-art/slack-backend';
3
- import { MemKey_AccountEmail } from './_entity/session/index.js';
3
+ import { MemKey_AccountEmail } from './_entity/session/consts.js';
4
4
  export class SlackReporter extends Logger {
5
5
  fallbackChannel = ModuleBE_Slack.getDefaultChannel();
6
6
  report;
@@ -14,7 +14,7 @@ export class SlackReporter extends Logger {
14
14
  if (!userId)
15
15
  return this.sendReportToChannel(channel);
16
16
  const dmId = await ModuleBE_Slack.openDM([userId]);
17
- await ModuleBE_Slack.postMessage(this.report, dmId);
17
+ await ModuleBE_Slack.sendText(this.report, dmId);
18
18
  }
19
19
  catch (err) {
20
20
  this.logError('Failed to send report to user.\nSending to channel instead.\n', err);
@@ -22,6 +22,6 @@ export class SlackReporter extends Logger {
22
22
  }
23
23
  };
24
24
  sendReportToChannel = async (channel) => {
25
- await ModuleBE_Slack.postMessage(this.report, channel ?? this.fallbackChannel);
25
+ await ModuleBE_Slack.sendText(this.report, channel ?? this.fallbackChannel);
26
26
  };
27
27
  }
@@ -1,10 +1,9 @@
1
- import { DB_BaseObject, Dispatcher } from '@nu-art/ts-common';
2
- import { firestore } from 'firebase-admin';
3
- import { ModuleBE_BaseDB } from '@nu-art/thunderstorm-backend';
1
+ import { Dispatcher } from '@nu-art/ts-common';
2
+ import { DB_BaseObject } from '@nu-art/db-api-shared';
3
+ import { ModuleBE_BaseDB } from '@nu-art/db-api-backend';
4
4
  import { FirestoreQuery } from '@nu-art/firebase-shared';
5
- import { _SessionKey_Account, Account_ChangePassword, Account_ChangeThumbnail, Account_CreateAccount, Account_Delete, Account_Login, Account_RegisterAccount, Account_SetPassword, AccountEmail, AccountEmailWithDevice, AccountToAssertPassword, AccountToSpice, AccountType, DB_Account, DBProto_Account, PasswordAssertionConfig, SafeDB_Account, UI_Account } from '@nu-art/user-account-shared';
6
- import { BaseSessionClaims, CollectSessionData } from '../session/index.js';
7
- import Transaction = firestore.Transaction;
5
+ import { _SessionKey_Account, AccountEmail, AccountEmailWithDevice, AccountToAssertPassword, AccountToSpice, AccountType, API_UserAccount, DatabaseDef_Account, DB_Account, PasswordAssertionConfig, SafeDB_Account, UI_Account } from '@nu-art/user-account-shared';
6
+ import { BaseSessionClaims, CollectSessionData } from '../session/ModuleBE_SessionDB.js';
8
7
  type BaseAccount = {
9
8
  email: string;
10
9
  type: AccountType;
@@ -15,28 +14,40 @@ type SpicedAccount = BaseAccount & {
15
14
  };
16
15
  type AccountToCreate = SpicedAccount | BaseAccount;
17
16
  export interface OnNewUserRegistered {
18
- __onNewUserRegistered(account: SafeDB_Account, transaction: Transaction): void;
17
+ __onNewUserRegistered(account: SafeDB_Account): void;
19
18
  }
20
19
  export interface OnUserLogin {
21
- __onUserLogin(account: SafeDB_Account, transaction: Transaction): void;
20
+ __onUserLogin(account: SafeDB_Account): void;
22
21
  }
23
22
  export interface OnPreLogout {
24
23
  __onPreLogout: () => Promise<void>;
25
24
  }
26
- export declare const dispatch_onAccountLogin: Dispatcher<OnUserLogin, "__onUserLogin", [account: SafeDB_Account, transaction: firestore.Transaction], void>;
25
+ export declare const dispatch_onAccountLogin: Dispatcher<OnUserLogin, "__onUserLogin", [account: SafeDB_Account], void>;
27
26
  export declare const dispatch_onPreLogout: Dispatcher<OnPreLogout, "__onPreLogout", [], void>;
28
27
  export interface OnAccountDeleted {
29
- __onAccountDeleted: (account: SafeDB_Account, transaction: Transaction) => Promise<void>;
28
+ __onAccountDeleted: (account: SafeDB_Account) => Promise<void>;
30
29
  }
31
30
  type Config = {
32
31
  canRegister: boolean;
33
32
  passwordAssertion?: PasswordAssertionConfig;
34
33
  ignorePasswordAssertion?: boolean;
35
34
  };
36
- export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DBProto_Account, Config> implements CollectSessionData<_SessionKey_Account> {
35
+ export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DatabaseDef_Account, Config> implements CollectSessionData<_SessionKey_Account> {
37
36
  readonly Middleware: () => Promise<void>;
38
37
  constructor();
39
38
  init(): void;
39
+ refreshSession(_params: API_UserAccount['refreshSession']['Params']): Promise<API_UserAccount['refreshSession']['Response']>;
40
+ registerAccount(body: API_UserAccount['registerAccount']['Body']): Promise<API_UserAccount['registerAccount']['Response']>;
41
+ changePassword(body: API_UserAccount['changePassword']['Body']): Promise<API_UserAccount['changePassword']['Response']>;
42
+ login(body: API_UserAccount['login']['Body']): Promise<API_UserAccount['login']['Response']>;
43
+ createAccount(body: API_UserAccount['createAccount']['Body']): Promise<API_UserAccount['createAccount']['Response']>;
44
+ logout(_params: API_UserAccount['logout']['Params']): Promise<API_UserAccount['logout']['Response']>;
45
+ createToken(body: API_UserAccount['createToken']['Body']): Promise<API_UserAccount['createToken']['Response']>;
46
+ setPassword(body: API_UserAccount['setPassword']['Body']): Promise<API_UserAccount['setPassword']['Response']>;
47
+ getSessions(params: API_UserAccount['getSessions']['Params']): Promise<API_UserAccount['getSessions']['Response']>;
48
+ changeThumbnail(body: API_UserAccount['changeThumbnail']['Body']): Promise<API_UserAccount['changeThumbnail']['Response']>;
49
+ getPasswordAssertionConfig(_params: API_UserAccount['getPasswordAssertionConfig']['Params']): Promise<API_UserAccount['getPasswordAssertionConfig']['Response']>;
50
+ deleteAccount(params: API_UserAccount['deleteAccount']['Params']): Promise<API_UserAccount['deleteAccount']['Response']>;
40
51
  manipulateQuery(query: FirestoreQuery<DB_Account>): FirestoreQuery<DB_Account>;
41
52
  __collectSessionData(data: BaseSessionClaims): Promise<{
42
53
  key: "account";
@@ -47,46 +58,47 @@ export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DBProto_Ac
47
58
  description?: string | undefined;
48
59
  displayName?: string | undefined;
49
60
  thumbnail?: string | undefined;
50
- _id: string;
51
- __metadata1?: any;
52
- __hardDelete?: boolean;
61
+ _id: string & {
62
+ readonly __brand: "id:user-account--accounts";
63
+ } & {
64
+ readonly __brand: `id:${string}`;
65
+ };
53
66
  __created?: number | undefined;
54
67
  __updated?: number | undefined;
55
- _v?: string;
56
- _originDocId?: import("@nu-art/ts-common").UniqueId;
57
- salt?: string | undefined;
68
+ _v?: string | undefined;
58
69
  _auditorId?: string | undefined;
59
70
  _newPasswordRequired?: boolean | undefined;
71
+ salt?: string | undefined;
60
72
  saltedPassword?: string | undefined;
61
73
  };
62
74
  }>;
63
- protected preWriteProcessing(dbInstance: UI_Account, originalDbInstance: DBProto_Account['dbType'], transaction?: Transaction): Promise<void>;
75
+ protected preWriteProcessing(dbInstance: UI_Account, originalDbInstance: DatabaseDef_Account['dbType']): Promise<void>;
64
76
  impl: {
65
77
  fixEmail: (objectWithEmail: {
66
78
  email: string;
67
79
  }) => void;
68
80
  assertPasswordCheck: (accountToAssert: AccountToAssertPassword) => void;
69
81
  spiceAccount: (accountToSpice: AccountToSpice) => SpicedAccount;
70
- create: (accountToCreate: AccountToCreate, transaction: Transaction) => Promise<SafeDB_Account>;
82
+ create: (accountToCreate: AccountToCreate) => Promise<SafeDB_Account>;
71
83
  setAccountMemKeys: (account: SafeDB_Account) => Promise<void>;
72
- onAccountCreated: (account: SafeDB_Account, transaction: Transaction) => Promise<void>;
73
- onAccountLogin: (account: SafeDB_Account, transaction: Transaction) => Promise<void>;
74
- queryUnsafeAccount: (credentials: AccountEmail, transaction?: Transaction) => Promise<DB_Account>;
75
- querySafeAccount: (credentials: AccountEmail, transaction?: Transaction) => Promise<SafeDB_Account>;
84
+ onAccountCreated: (account: SafeDB_Account) => Promise<void>;
85
+ onAccountLogin: (account: SafeDB_Account) => Promise<void>;
86
+ queryUnsafeAccount: (credentials: AccountEmail) => Promise<DB_Account>;
87
+ querySafeAccount: (credentials: AccountEmail) => Promise<SafeDB_Account>;
76
88
  };
77
89
  account: {
78
- register: (accountWithPassword: Account_RegisterAccount["request"], transaction?: Transaction) => Promise<Account_RegisterAccount["response"]>;
79
- login: (credentials: Account_Login["request"]) => Promise<Account_Login["response"]>;
80
- create: (createAccountRequest: Account_CreateAccount["request"]) => Promise<Account_CreateAccount["response"]>;
90
+ register: (accountWithPassword: API_UserAccount["registerAccount"]["Body"]) => Promise<API_UserAccount["registerAccount"]["Response"]>;
91
+ login: (credentials: API_UserAccount["login"]["Body"]) => Promise<API_UserAccount["login"]["Response"]>;
92
+ create: (createAccountRequest: API_UserAccount["createAccount"]["Body"]) => Promise<API_UserAccount["createAccount"]["Response"]>;
81
93
  saml: (oAuthAccount: AccountEmailWithDevice) => Promise<import("@nu-art/user-account-shared").DB_Session>;
82
- changePassword: (passwordToChange: Account_ChangePassword["request"]) => Promise<Account_ChangePassword["response"]>;
83
- setPassword: (passwordBody: Account_SetPassword["request"]) => Promise<Account_SetPassword["response"]>;
94
+ changePassword: (passwordToChange: API_UserAccount["changePassword"]["Body"]) => Promise<API_UserAccount["changePassword"]["Response"]>;
95
+ setPassword: (passwordBody: API_UserAccount["setPassword"]["Body"]) => Promise<API_UserAccount["setPassword"]["Response"]>;
84
96
  logout: () => Promise<void>;
85
- getSessions: (query: DB_BaseObject) => Promise<{
97
+ getSessions: (query: DB_BaseObject<DatabaseDef_Account["dbKey"]>) => Promise<{
86
98
  sessions: import("@nu-art/user-account-shared").DB_Session[];
87
99
  }>;
88
- changeThumbnail: (request: Account_ChangeThumbnail["request"]) => Promise<Account_ChangeThumbnail["response"]>;
89
- delete: (request: Account_Delete["request"]) => Promise<Account_Delete["response"]>;
100
+ changeThumbnail: (request: API_UserAccount["changeThumbnail"]["Body"]) => Promise<API_UserAccount["changeThumbnail"]["Response"]>;
101
+ delete: (request: API_UserAccount["deleteAccount"]["Params"]) => Promise<API_UserAccount["deleteAccount"]["Response"]>;
90
102
  };
91
103
  password: {
92
104
  assertPasswordExistence: (email: string, password?: string, passwordCheck?: string) => void;