|
1 | 1 | import type { AuthenticationCreds, SignalDataSet, SignalDataTypeMap } from 'baileys' |
2 | 2 |
|
3 | | -/** Discriminator union for every Baileys signal category. */ |
4 | 3 | export type AuthStoreKey = keyof SignalDataTypeMap |
5 | 4 |
|
6 | | -/** Resolved value type for a given signal category. */ |
7 | 5 | export type AuthStoreValue<K extends AuthStoreKey> = SignalDataTypeMap[K] |
8 | 6 |
|
9 | | -/** |
10 | | - * Pluggable signal-key store mirroring Baileys' `SignalKeyStore` shape. |
11 | | - * After {@link AuthStore.close} resolves every other method MUST throw |
12 | | - * `ZaileysStoreError` with code `STORE_CLOSED`. |
13 | | - */ |
14 | 7 | export interface AuthStore { |
15 | | - /** |
16 | | - * Look up signal values by id within a single category. |
17 | | - * @param type Signal category to read. |
18 | | - * @param ids Identifiers to fetch. |
19 | | - * @returns Map keyed by id; missing ids resolve to `undefined`. |
20 | | - */ |
21 | 8 | read<K extends AuthStoreKey>( |
22 | 9 | type: K, |
23 | 10 | ids: readonly string[], |
24 | 11 | ): Promise<{ [id: string]: AuthStoreValue<K> | undefined }> |
25 | | - /** |
26 | | - * Persist a partial signal map. `null` values delete the matching id. |
27 | | - * @param data Baileys `SignalDataSet` payload (full or partial). |
28 | | - */ |
29 | 12 | write(data: SignalDataSet): Promise<void> |
30 | | - /** |
31 | | - * Remove ids from a category. |
32 | | - * @param type Signal category. |
33 | | - * @param ids Identifiers to drop. |
34 | | - */ |
35 | 13 | delete<K extends AuthStoreKey>(type: K, ids: readonly string[]): Promise<void> |
36 | | - /** Wipe every signal category (used on 401/410 auto-cleanup). */ |
37 | 14 | clear(): Promise<void> |
38 | | - /** Release backing resources; idempotent. */ |
39 | 15 | close(): Promise<void> |
40 | 16 | } |
41 | 17 |
|
42 | | -/** |
43 | | - * Credential persistence for the long-lived `AuthenticationCreds` blob. |
44 | | - * After {@link AuthCredsStore} sibling close every method MUST throw |
45 | | - * `ZaileysStoreError` with code `STORE_CLOSED`. |
46 | | - */ |
47 | 18 | export interface AuthCredsStore { |
48 | | - /** Load persisted creds; resolves `undefined` when none exist. */ |
49 | 19 | readCreds(): Promise<AuthenticationCreds | undefined> |
50 | | - /** Persist creds atomically. */ |
51 | 20 | writeCreds(creds: AuthenticationCreds): Promise<void> |
52 | | - /** Remove persisted creds. */ |
53 | 21 | deleteCreds(): Promise<void> |
54 | 22 | } |
55 | 23 |
|
56 | | -/** Composite bundle handed to the Client to satisfy Baileys auth wiring. */ |
57 | 24 | export interface AuthStoreBundle { |
58 | 25 | readonly creds: AuthCredsStore |
59 | 26 | readonly signal: AuthStore |
|
0 commit comments