autentikigo v0.0.7
Autentikigo
An authentication package.
Instalation
To install the autentikigo, use one of the following command:
- npm:
npm install autentikigo
Use
var autentikigo = require('autentikigo')Register method
var register = await autentikigo.register(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
uniqueId(string)birthday(date)email(string)password(string)cpfApiEndpoint(string)cnpjApiEndpoint(string)
uniqueId
CPF/CNPJ of the user that will be registered.
birthday
User birthday.
email
User e-mail.
password
User password.
cpfApiEndpoint
Endpoint of CPF API (https://www.cpfcnpj.com.br/).
Exemplo
https://api.cpfcnpj.com.br/5ae973d7a997af13f0aaf2bf60e65803/2/cnpjApiEndpoint
Endpoint of CNPJ API (https://www.cpfcnpj.com.br/).
Exemplo
https://api.cpfcnpj.com.br/5ae973d7a997af13f0aaf2bf60e65803/6/connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoLogin method
var login = await autentikigo.login(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
user(string)password(string)projectId(string)jwtSecret(string)jwtRefreshSecret(string)
user
CPF, CNPJ, usernama or email of the user that will be authenticated.
password
User password.
projectId
Id of the application/project that wants to authenticate user.
jwtSecret
Secret to create the authentication token (JWT).
jwtRefreshSecret
Secret to create the authentication refresh token (JWT).
connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoAuthorize method
var authorize = await autentikigo.authorizeProject(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
userId(string)acl(string)verified(boolean)projectId(string)
userId
Id of user that will be authorize application/project to use his data.
acl
User acl in the specifique application/project.
verified
Parameter that defines if user was verified.
projectId
Id of the application/project that wants to authenticate user.
connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoGenerate recovery password token method
var generateRecoveryPasswordToken = await autentikigo.generateRecoveryPasswordToken(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
email(string)jwtSecret(string)
email
Email of the user who will recover the password.
jwtSecret
Secret to create the authentication token (JWT).
connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoChange password method
var changePassword = await autentikigo.changePassword(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
password(string)recoveryPasswordToken(string)jwtSecret(string)
password
New password.
recoveryPasswordToken
Token to recovery password.
jwtSecret
Secret to create the authentication token (JWT).
connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoMiddleware method
var middleware = await autentikigo.middleware(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
token(string)jwtSecret(string)userId(string)projectId(string)roles(array)endpoint(string)method(string)
token
Authentication token (JWT) obtained in the login method.
jwtSecret
Secret to verify the authentication token (JWT).
userId
Id of user that will be authorize application/project to use his data.
projectId
Id of the application/project that wants to authenticate user.
roles
Array of roles (ACL).
Exemplo
[
{
"group": "user",
"permissions": [
{
"resource": "users/*",
"methods": [
"POST",
"GET",
"PUT"
]
}
]
},
]endpoint
Endpoint that user want to access.
method
Method to use in endpoint.
Exemplo
'POST'connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigoGet user info method
var userInfo = await autentikigo.getUserInfo(queryParams, connectionParams);queryParams
Required parameters.
Tipo: object
token(string)jwtSecret(string)projectId(string)
token
Authentication token (JWT) obtained in the login method.
jwtSecret
Secret to verify the authentication token (JWT).
projectId
Id of the application/project that wants to authenticate user.
connectionParams
Connection parameters (Required).
Tipo: object
connectionString(string)
connectionString
MongoDB connection string.
Exemplo
mongodb://127.0.0.1:27017/autentikigo