mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 20:49:14 +00:00
feat: RemoteAuth Strategy (#1450)
* index.js * [authReady] - new BaseAuthStrategy function * [RemoteAuth] - new Class RemoteAuth added * Eslint Fixes * Eslint Fixes * Added types for RemoteAuth (mostly assumed types from PR message and src/authStrategies/RemoteAuth.js) * [dependency updates] - added unzipper & archiver * [Types] - Fixing typescript declarations * Renaming Base Class Hook * auth hook rename on client * [Error Handling] - Delegate responsability to end users * [Refactor] - deletemetadata code refactor * [Refactor] - backupSyncIntervalMs renamed * [Refactor] - Minor improvement on deleteMetadata * [Refactor] - backupSyncIntervalMs rename on index.d.ts * [Update] - Fix for Ubuntu crahsing on extractSession * [Update] - Delegate responsability to stores of making sure the previous session is deleted strictly only after the new one is saved * [Update] - Improve file paths handling & naming (reduce assumptions between RemoteAuth and stores) * [Update] - Adding new event <REMOTE_SESSION_SAVED> on Constants.js * [Update] - Adding new authHooks <destroy> & <disconnect> * [Update] - Adding <destroy> & <disconnect> hooks on Client.js * [Update] - Adding new features to index.d.ts * [RemoteAuth] - New Features added to RemoteAuth Class * [dependency updates] - added fs-extra * [Cross Platform] - Windows is now compatible with RemoteAuth * [optionalDependencies] - moved archiver, fs-extra & unzipper to optional dependencies on package.json * [optionalDependencies] - adding validation for when optional dependencies are missing * [Update] - Node Deprecation warining for rmdir changed for rm instead Co-authored-by: h110m <nichtwitzig228@gmail.com>
This commit is contained in:
31
index.d.ts
vendored
31
index.d.ts
vendored
@@ -265,6 +265,9 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Emitted when the client has initialized and is ready to receive messages */
|
||||
on(event: 'ready', listener: () => void): this
|
||||
|
||||
/** Emitted when the RemoteAuth session is saved successfully on the external Database */
|
||||
on(event: 'remote_session_saved', listener: () => void): this
|
||||
}
|
||||
|
||||
/** Current connection information */
|
||||
@@ -354,6 +357,9 @@ declare namespace WAWebJS {
|
||||
failureEventPayload?: any
|
||||
}>;
|
||||
getAuthEventPayload: () => Promise<any>;
|
||||
afterAuthReady: () => Promise<void>;
|
||||
disconnect: () => Promise<void>;
|
||||
destroy: () => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -374,6 +380,30 @@ declare namespace WAWebJS {
|
||||
dataPath?: string
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote-based authentication
|
||||
*/
|
||||
export class RemoteAuth extends AuthStrategy {
|
||||
public clientId?: string;
|
||||
public dataPath?: string;
|
||||
constructor(options?: {
|
||||
store: Store,
|
||||
clientId?: string,
|
||||
dataPath?: string,
|
||||
backupSyncIntervalMs: number
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote store interface
|
||||
*/
|
||||
export interface Store {
|
||||
sessionExists: ({session: string}) => Promise<boolean> | boolean,
|
||||
delete: ({session: string}) => Promise<any> | any,
|
||||
save: ({session: string}) => Promise<any> | any,
|
||||
extract: ({session: string, path: string}) => Promise<any> | any,
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy session auth strategy
|
||||
@@ -476,6 +506,7 @@ declare namespace WAWebJS {
|
||||
DISCONNECTED = 'disconnected',
|
||||
STATE_CHANGED = 'change_state',
|
||||
BATTERY_CHANGED = 'change_battery',
|
||||
REMOTE_SESSION_SAVED = 'remote_session_saved'
|
||||
}
|
||||
|
||||
/** Group notification types */
|
||||
|
||||
Reference in New Issue
Block a user