2.2.0 • Published 4 years ago

@iotechpis/ioaccount v2.2.0

Weekly downloads
23
License
ISC
Repository
github
Last release
4 years ago

npm-iotechpis_ioaccount

Install

npm i @iotechpis/ioaccount -s

How to use

Init

//Mongo connection for ioTokens DB
const mongodb_connection = "mongodb://username:password@0.0.0.0:27017/db";
//URL for ioaccount API
const ioaccount_api = "https://ioaccountapi.com";

const current_app_id = 78345673457;
const token_expiration_time = 15000; //in sec

require("@iotechpis/ioaccount").init(mongodb_connection, ioaccount_api, current_app_id, token_expiration_time, callback);

auth

.login(email, password, callback)

let email = "m@domain.com";
let password = "12345";

require("@iotechpis/ioaccount").auth.login(email, password, (error, data) => {
//data = {headers, body};
});

.logout(token, callback)

let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";

require("@iotechpis/ioaccount").auth.logout(token, () => {

});

.info(token, callback)

let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";

require("@iotechpis/ioaccount").auth.info(token, (error, data) => {
//data = {headers, body};
});

.recoverPasswordRequest(email, callback)

let email = "email@domain.com";

require("@iotechpis/ioaccount").auth.recoverPasswordRequest(email, (error, data) => {
//data = {headers, body};
});

tokens

.create(payload, callback)

let payload = {
	user_id: "1", //only this field is obligatory, the others can be whatever you want
};

require("@iotechpis/ioaccount").tokens.create(payload, (token) => {
});

.delete(token, callback)

let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";

require("@iotechpis/ioaccount").tokens.delete(token, () => {
});

.validate(token, callback)

let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";

require("@iotechpis/ioaccount").tokens.validate(token, (error, token, payload) => {
});

user

.register(email, password, confirm_password, callback)

let email = "name@domain.com";

require("@iotechpis/ioaccount").user.register(email, (error, data) => {
//data = {headers, body};
});

.registerMany(users, callback)

let users = [
    {
        "email": "johnsm@email.com"
    }, ...
];
  
require("@iotechpis/ioaccount").user.registerMany(users, (error, data) => {
//data = {headers, body};
});

.getByIds(users, callback)

let ids = [
    "rgjregjenrg",
    "rwjegnregn"
];
  
require("@iotechpis/ioaccount").user.getByIds(ids, (error, data) => {
//data = {headers, body};
});
2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago