Auths
Auths ⇐ APIClient
Use Fonoster Auth, a capability of Fonoster, to validate and create short life tokens.
Kind: global class
Extends: APIClient
See: module:core:APIClient
- Auths ⇐
APIClient
- new Auths(options)
- .createToken(request) ⇒
Promise.<CreateTokenResponse>
- .createNoAccessToken(request) ⇒
Promise.<CreateTokenResponse>
- .validateToken(request) ⇒
Promise.<boolean>
new Auths(options)
Constructs a new Auth object.
Param | Type | Description |
---|---|---|
options | ClientOptions | Options to indicate the objects endpoint |
Example
const request = {
accessKeyId: "US618572e3ec11d10600000001",
roleName: "USER"
};
auth.createToken(request)
.then(console.log) // returns an object with the token
.catch(console.error); // an error occurred
auths.createToken(request) ⇒ Promise.<CreateTokenResponse>
Creates a short-life token. The client must have role allowed to create tokens.
Kind: instance method of Auths
Param | Type | Description |
---|---|---|
request | CreateTokenRequest | Request to create a new token |
request.accessKeyId | string | Path to the function |
request.expiration | string | Longevity of the token |
request.roleName | string | Role assigned to the token |
Example
const Fonoster = require("@fonoster/sdk");
const auth = new Fonoster.Auth();
const request = {
accessKeyId: "PJ618572e3ec11d10600000001",
roleName: "SERVICE",
expiration: "10m"
};
auth.createToken(request)
.then(console.log) // returns an object with the token
.catch(console.error); // an error occurred
auths.createNoAccessToken(request) ⇒ Promise.<CreateTokenResponse>
Creates a short-life token meant only to serve as a signature. This token will only be useful to sign a request.
Kind: instance method of Auths
Param | Type | Description |
---|---|---|
request | CreateTokenRequest | Request to create a new signature token |
request.accessKeyId | string | Path to the function |
Example
const Fonoster = require("@fonoster/sdk");
const auth = new Fonoster.Auth();
const request = {
accessKeyId: "PJ619154d081467a0700000001",
};
auth.createNoAccessToken(request)
.then(console.log) // returns an object with the token
.catch(console.error); // an error occurred
auths.validateToken(request) ⇒ Promise.<boolean>
Checks if a give token was issue by the system.
Kind: instance method of Auths
Param | Type | Description |
---|---|---|
request | CreateTokValidateTokenRequestenRequest | Request to verify the validity of a token |
request.token | string | Path to the function. |
Example
const Fonoster = require("@fonoster/sdk");
const auth = new Fonoster.Auth();
const request = {
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
};
auth.validateToken(request)
.then(console.log) // returns `true` or `false`
.catch(console.error); // an error occurred