import type { Contract } from 'autumndb'; import type { JellyfishSDK } from '.'; /** * @namespace JellyfishSDK.auth * @memberof JellyfishSDK */ export declare class AuthSdk { private sdk; constructor(sdk: JellyfishSDK); /** * @summary Get the currently authenticated user * @name whoami * @public * @function * @memberof JellyfishSDK.auth * * @description Gets the user card of the currently authorised user using * their auth token * * @fulfil {Object|null} - A single user card, or null if one wasn't found * @returns {Promise} * * @example * sdk.auth.whoami() * .then((user) => { * console.log(user) * }) */ whoami(): Promise; /** * @summary Create a new user account * @name signup * @public * @function * @memberof JellyfishSDK.auth * * @description Create a new user account and return the newly created user's * id * * @param {Object} user - The user object * @param {String} user.username - The username * @param {String} user.email - The users email address * @param {String} user.password - The users password * * @fulfil {Object} - The newly created user * @returns {Promise} * * @example * sdk.auth.signup({ * username: 'johndoe', * email: 'johndoe@example.com', * password: 'password123' * }) * .then((id) => { * console.log(id) * }) */ signup({ username, email, password, }: { username: string; email: string; password: string; }): Promise; /** * @summary Authenticate the SDK using a token * @name loginWithToken * @public * @function * @memberof JellyfishSDK.auth * * @description Authenticate the SDK using a token. The token is checked for * validity and then saved using `jellyFishSdk.setAuthToken` to be used for * later requests. Once logged in, there is no need to set the token again * * @returns {String} The new authentication token * * @param {String} token - Authentication token * * @example * sdk.auth.loginWithToken('8b465c9a-b4cb-44c1-9df9-632649d7c4c3') * .then(() => { * console.log('Authenticated') * }) */ loginWithToken(token: string): Promise; /** * @summary Authenticate the SDK using a username and password * @name login * @public * @function * @memberof JellyfishSDK.auth * * @description Authenticate the SDK using a username and password. If the * username and password are valid, a user session card will be returned. * The id of the user session id (which is used to authenticate requests) is * then saved using `jellyFishSdk.setAuthToken` to be used for later requests. * Once logged in, there is no need to set the token again * * @param {Object} options - login data * @param {String} options.username - Username * @param {String} options.password - Password * * @returns {Object} The generated user session * * @example * sdk.auth.login({ * username: 'johndoe', * password: 'password123' * }) * .then((session) => { * console.log('Authenticated', session) * }) */ login({ username, password, }: { username: string; password: string; }): Promise; /** * @summary Generate a new session token * @name refreshToken * @public * @function * @memberof JellyfishSDK.auth * * @description Refreshes the auth token used by the SDK * * @returns {String} The generated session token * * @example * sdk.auth.refreshToken * .then((token) => { * console.log('New token', token) * }) */ refreshToken(): Promise; /** * @summary Logout * @name logout * @public * @function * @memberof JellyfishSDK.auth * * @description Logout, removing the current authToken and closing all * streams and network requests * * @example * sdk.auth.logout() */ logout(): void; /** * @summary Request a password reset email for given username * @name requestPasswordReset * @public * @function * @memberof JellyfishSDK.auth * * @param {String} username - Username * * @returns {Promise} * * @example * sdk.auth.requestPasswordReset('johndoe') */ requestPasswordReset(username: string): Promise; /** * @summary Complete a password reset flow * @name completePasswordReset * @public * @function * @memberof JellyfishSDK.auth * * @param {String} newPassword - New password to set * @param {String} resetToken - Token used to authorise password reset * * @returns {Promise} * * @example * sdk.auth.completePasswordReset('password', 'token') */ completePasswordReset(newPassword: any, resetToken: any): Promise; /** * @summary Complete a password reset flow * @name completeFirstTimeLogin * @public * @function * @memberof JellyfishSDK.auth * * @param {String} newPassword - New password to set * @param {String} resetToken - Token used for first time login * * @returns {Promise} * * @example * sdk.auth.completePasswordReset('password', 'token') */ completeFirstTimeLogin(newPassword: any, firstTimeLoginToken: any): Promise; }