1.9.0 • Published 2 years ago
@bettr/authenticator v1.9.0
Bettr Authenticator
Google Cloud Function to authenticate users through the Public API.
Build
yarn install # will run the build postinstallEnvironment config
Dummy values:
API_BASE_URL="https://api.bettr.live"
API_KEY="YOUR API KEY"
API_SECRET="YOUR API SECRET"API
Entry point
bettrAuthenticatorPOST
Usage
import { bindHandler } from "@bettr/authenticator";
/* To bind the `bettrAuthenticatorPOST` http handler
* to `@google-cloud/functions-framework`, call the
* binder method: */
bindHandler();OR bind manually:
import { handler } from "@bettr/authenticator";
import * as functions from "@google-cloud/functions-framework";
functions.http("bettrAuthenticatorPOST", (req, res) => handler(req, res));Request body schema
interface IRequestBodySchema {
user: IRequestBodyUser;
/* Correlation Id of the request, used for request
* tracking (UUIDv4), optional
*/
correlationId?: string;
}
interface IRequestBodyUser {
firstName: string;
lastName: string;
email: string;
acceptTerms: boolean; // required, for compliance reasons
password?: string; // optional, not checked for match
profile?: object; // optional
needsPasswordChange?: boolean; // optional
}Response schema
Success response
interface IResponseBodySchema {
status: ApplicationResponseStatus.Ok;
data: IResponseBodyData;
correlationId: string;
}
interface IResponseBodyData {
status: ApplicationResponseStatus.Ok;
// User Id in Bettr (UUIDv4)
userId: string;
/*
* Bettr Access token, to be forwarded to
* auth callback
*/
accessToken: string;
/*
* can be used to authenticate the user:
* "{redirectUrl}?accessToken={accessToken}"
*/
redirectUrl?: string;
/*
* Correlation Id of the response/overriden
* with the request's one if passed (UUIDv4)
*/
correlationId: string;
}Error response
interface IErrorReponseBodySchema {
status: ApplicationResponseStatus.Error;
message: string;
correlationId: string;
}Author
Arpad Kiss [arpad@greeneyes.ai](mailto:arpad@greeneyes.ai?Subject=Bettr+Authenticator)
License
GNU Lesser General Public License v3.0
The code is built upon @greeneyesai/api-utils package:
https://www.npmjs.com/package/@greeneyesai/api-utils.
© Bettr.App