@nu-art/user-account-backend 0.401.8 → 0.500.0

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 +32 -19
  3. package/_entity/account/ModuleBE_AccountDB.js +399 -303
  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 +9 -9
  18. package/_entity/session/ModuleBE_SessionDB.js +48 -12
  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 +13 -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,9 +1,10 @@
1
- import { DB_BaseObject, Dispatcher } from '@nu-art/ts-common';
1
+ import { Dispatcher } from '@nu-art/ts-common';
2
+ import { DB_BaseObject } from '@nu-art/db-api-shared';
2
3
  import { firestore } from 'firebase-admin';
3
- import { ModuleBE_BaseDB } from '@nu-art/thunderstorm-backend';
4
+ import { ModuleBE_BaseDB } from '@nu-art/db-api-backend';
4
5
  import { FirestoreQuery } from '@nu-art/firebase-shared';
5
- import { _SessionKey_Account, Account_ChangePassword, Account_ChangeThumbnail, Account_CreateAccount, 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';
6
+ 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';
7
+ import { BaseSessionClaims, CollectSessionData } from '../session/ModuleBE_SessionDB.js';
7
8
  import Transaction = firestore.Transaction;
8
9
  type BaseAccount = {
9
10
  email: string;
@@ -30,10 +31,21 @@ type Config = {
30
31
  passwordAssertion?: PasswordAssertionConfig;
31
32
  ignorePasswordAssertion?: boolean;
32
33
  };
33
- export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DBProto_Account, Config> implements CollectSessionData<_SessionKey_Account> {
34
+ export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DatabaseDef_Account, Config> implements CollectSessionData<_SessionKey_Account> {
34
35
  readonly Middleware: () => Promise<void>;
35
36
  constructor();
36
37
  init(): void;
38
+ refreshSession(_params: API_UserAccount['refreshSession']['Params']): Promise<API_UserAccount['refreshSession']['Response']>;
39
+ registerAccount(body: API_UserAccount['registerAccount']['Body']): Promise<API_UserAccount['registerAccount']['Response']>;
40
+ changePassword(body: API_UserAccount['changePassword']['Body']): Promise<API_UserAccount['changePassword']['Response']>;
41
+ login(body: API_UserAccount['login']['Body']): Promise<API_UserAccount['login']['Response']>;
42
+ createAccount(body: API_UserAccount['createAccount']['Body']): Promise<API_UserAccount['createAccount']['Response']>;
43
+ logout(_params: API_UserAccount['logout']['Params']): Promise<API_UserAccount['logout']['Response']>;
44
+ createToken(body: API_UserAccount['createToken']['Body']): Promise<API_UserAccount['createToken']['Response']>;
45
+ setPassword(body: API_UserAccount['setPassword']['Body']): Promise<API_UserAccount['setPassword']['Response']>;
46
+ getSessions(params: API_UserAccount['getSessions']['Params']): Promise<API_UserAccount['getSessions']['Response']>;
47
+ changeThumbnail(body: API_UserAccount['changeThumbnail']['Body']): Promise<API_UserAccount['changeThumbnail']['Response']>;
48
+ getPasswordAssertionConfig(_params: API_UserAccount['getPasswordAssertionConfig']['Params']): Promise<API_UserAccount['getPasswordAssertionConfig']['Response']>;
37
49
  manipulateQuery(query: FirestoreQuery<DB_Account>): FirestoreQuery<DB_Account>;
38
50
  canDeleteItems(dbItems: DB_Account[], transaction?: FirebaseFirestore.Transaction): Promise<void>;
39
51
  __collectSessionData(data: BaseSessionClaims): Promise<{
@@ -45,20 +57,21 @@ export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DBProto_Ac
45
57
  description?: string | undefined;
46
58
  displayName?: string | undefined;
47
59
  thumbnail?: string | undefined;
48
- _id: string;
49
- __metadata1?: any;
50
- __hardDelete?: boolean;
60
+ _id: string & {
61
+ readonly __brand: "id:user-account--accounts";
62
+ } & {
63
+ readonly __brand: `id:${string}`;
64
+ };
51
65
  __created?: number | undefined;
52
66
  __updated?: number | undefined;
53
- _v?: string;
54
- _originDocId?: import("@nu-art/ts-common").UniqueId;
55
- salt?: string | undefined;
67
+ _v?: string | undefined;
56
68
  _auditorId?: string | undefined;
57
69
  _newPasswordRequired?: boolean | undefined;
70
+ salt?: string | undefined;
58
71
  saltedPassword?: string | undefined;
59
72
  };
60
73
  }>;
61
- protected preWriteProcessing(dbInstance: UI_Account, originalDbInstance: DBProto_Account['dbType'], transaction?: Transaction): Promise<void>;
74
+ protected preWriteProcessing(dbInstance: UI_Account, originalDbInstance: DatabaseDef_Account['dbType'], transaction?: Transaction): Promise<void>;
62
75
  impl: {
63
76
  fixEmail: (objectWithEmail: {
64
77
  email: string;
@@ -73,17 +86,17 @@ export declare class ModuleBE_AccountDB_Class extends ModuleBE_BaseDB<DBProto_Ac
73
86
  querySafeAccount: (credentials: AccountEmail, transaction?: Transaction) => Promise<SafeDB_Account>;
74
87
  };
75
88
  account: {
76
- register: (accountWithPassword: Account_RegisterAccount["request"], transaction?: Transaction) => Promise<Account_RegisterAccount["response"]>;
77
- login: (credentials: Account_Login["request"]) => Promise<Account_Login["response"]>;
78
- create: (createAccountRequest: Account_CreateAccount["request"]) => Promise<Account_CreateAccount["response"]>;
89
+ register: (accountWithPassword: API_UserAccount["registerAccount"]["Body"], transaction?: Transaction) => Promise<API_UserAccount["registerAccount"]["Response"]>;
90
+ login: (credentials: API_UserAccount["login"]["Body"]) => Promise<API_UserAccount["login"]["Response"]>;
91
+ create: (createAccountRequest: API_UserAccount["createAccount"]["Body"]) => Promise<API_UserAccount["createAccount"]["Response"]>;
79
92
  saml: (oAuthAccount: AccountEmailWithDevice) => Promise<import("@nu-art/user-account-shared").DB_Session>;
80
- changePassword: (passwordToChange: Account_ChangePassword["request"]) => Promise<Account_ChangePassword["response"]>;
81
- setPassword: (passwordBody: Account_SetPassword["request"]) => Promise<Account_SetPassword["response"]>;
93
+ changePassword: (passwordToChange: API_UserAccount["changePassword"]["Body"]) => Promise<API_UserAccount["changePassword"]["Response"]>;
94
+ setPassword: (passwordBody: API_UserAccount["setPassword"]["Body"]) => Promise<API_UserAccount["setPassword"]["Response"]>;
82
95
  logout: () => Promise<void>;
83
- getSessions: (query: DB_BaseObject) => Promise<{
96
+ getSessions: (query: DB_BaseObject<DatabaseDef_Account["dbKey"]>) => Promise<{
84
97
  sessions: import("@nu-art/user-account-shared").DB_Session[];
85
98
  }>;
86
- changeThumbnail: (request: Account_ChangeThumbnail["request"]) => Promise<Account_ChangeThumbnail["response"]>;
99
+ changeThumbnail: (request: API_UserAccount["changeThumbnail"]["Body"]) => Promise<API_UserAccount["changeThumbnail"]["Response"]>;
87
100
  };
88
101
  password: {
89
102
  assertPasswordExistence: (email: string, password?: string, passwordCheck?: string) => void;