Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onelogin/sdk

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onelogin/sdk - npm Package Compare versions

Comparing version 2.0.13 to 3.0.0-alpha.1

.babelrc

83

package.json
{
"name": "@onelogin/sdk",
"version": "2.0.13",
"description": "JavaScript SDK for OneLogin APIs",
"homepage": "http://onelogin.com/",
"contributors": [
"Bob Dickinson <bob.dickinson@onelogin.com>",
"Dominick Caponi <dominick.caponi@onelogin.com>"
],
"repository": {
"type": "git",
"url": "git://github.com/onelogin/onelogin-node-sdk.git"
},
"bugs": {
"url": "https://github.com/onelogin/onelogin-node-sdk/issues"
},
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"base64-js": "^1.5.1",
"btoa": "^1.2.1",
"qs": "^6.9.6"
},
"scripts": {
"build": "tsc -p tsconfig.json",
"test": "mocha -r mock-local-storage -r ts-node/register tests/**/*.test.ts",
"coverage": "nyc -r text -e .ts -x \"tests/**/*.test.ts\" npm run test",
"docs": "jsdoc lib"
},
"engines": {
"node": ">= 0.12"
},
"main": "dist/main.js",
"typings": "dist/main.d.ts",
"devDependencies": {
"@types/chai": "^4.2.14",
"@types/chai-as-promised": "^7.1.3",
"@types/express": "^4.17.8",
"@types/mocha": "^8.0.3",
"@types/nock": "^11.1.0",
"@types/node": "^14.11.2",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"dotenv": "^8.2.0",
"jsdoc": "^3.6.7",
"mocha": "^8.2.1",
"mock-local-storage": "^1.1.17",
"nock": "^13.0.4",
"nyc": "^15.1.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
},
"directories": {
"lib": "lib",
"test": "test"
},
"author": "Dominick Caponi <dominick.caponi@onelogin.com>"
"name": "@onelogin/sdk",
"version": "3.0.0-alpha.1",
"description": "NodeJS client for @onelogin/sdk",
"repository": {
"type": "git",
"url": "https://github.com/onelogin/onelogin-node-sdk.git"
},
"main": "dist/api.js",
"types": "dist/api.d.ts",
"scripts": {
"clean": "rm -Rf node_modules/ *.js",
"build": "tsc",
"test": "echo 'There are currently no tests'"
},
"author": "OpenAPI-Generator Contributors",
"license": "MIT",
"dependencies": {
"bluebird": "^3.5.0",
"request": "^2.81.0",
"rewire": "^3.0.2"
},
"devDependencies": {
"@types/bluebird": "^3.5.33",
"@types/node": "^12",
"@types/request": "^2.48.8",
"typescript": "^4.0"
}
}

@@ -1,200 +0,324 @@

# OneLogin Node.js SDK
# one_login_api
This SDK will let you execute all the API methods, version/2, described at https://developers.onelogin.com/api-docs/2/getting-started/dev-overview.
OneLoginApi - JavaScript client for one_login_api
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
The SDK also covers common use cases with OneLogin including PKCE and Smart MFA integration with React, Angular and Vue.
- API version: 3.0.0-alpha.1
- Package version: 3.0.0-alpha.1
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
## Development Status
## Installation
This module is under development and accepting PRs from the community.
### For [Node.js](https://nodejs.org/)
## Getting started
#### npm
You'll need a OneLogin account and a set of API credentials before you get started.
To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).
If you don't have an account you can [sign up for a free developer account here](https://www.onelogin.com/developer-signup).
Then install it via:
From the admin panel of your OneLogin account, select Developers > API Credentials and click New Credential to create an API credential.
```shell
npm install one_login_api --save
```
| Value | Description |
| ------------- | ----------- |
| client_id | Required unless using for frontend (see PKCE): A valid OneLogin API client_id |
| client_secret | Required unless using for frontend (see PKCE): A valid OneLogin API client_secret |
| region | Optional if not using baseURL: 'us' or 'eu'. |
| baseURL | Optional if not using a region: Should look like `https://api.<region>.onelogin.com` |
Finally, you need to build the module:
## CRUD Resources
```shell
npm run build
```
Currently this SDK supports the following resources:
##### Local development
| Resource | Description | Docs |
| -------- | ----------- | ---- |
| Apps | The OneLogin App Resource (e.g. an OIDC or SAML application) | https://developers.onelogin.com/api-docs/2/apps/overview |
| Users | Representation of a User in OneLogin | https://developers.onelogin.com/api-docs/2/users/overview |
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
```shell
npm install
```
import Client from "@onelogin/sdk";
const onelogin = new Client({
clientID: abc-123-def-456,
clientSecret: 654-fed-321-cba,
region: "us"
});
Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
let newApp = onelogin.apps.Create({
name: "new app",
connector_id: 123
}) // creates a new SAML app
```shell
npm link
```
newApp.name= "updated app"
onelogin.apps.Update(newApp) // updates the app in OneLogin
To use the link you just defined in your project, switch to the directory you want to use your one_login_api from, and run:
let apps = onelogin.apps.Query() // list all apps
let samlApps = onelogin.apps.Query({connector_id: 123}) // list SAML apps (connector_id = 123)
let awsApp = onelogin.apps.FindByID(newApp.ID) // aws app with id = 123
onelogin.apps.Destroy(newApp.ID) // destroys the app in OneLogin
```shell
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
```
## Use Cases
Finally, you need to build the module:
### PKCE (OAuth Login) For SPA (React, Vue, Angular) and Mobile Apps
```shell
npm run build
```
This SDK supports integrating OneLogin as the IdP for PKCE https://developers.onelogin.com/blog/pkce-dust-react-app
#### git
PKCE is a useful auth flow for apps that don't have a secure means for storing client secret and prevents auth_code intercept attacks https://tools.ietf.org/html/rfc7636
If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:
For this flow, you'll need to create a OIDC App in OneLogin and configure it to use PKCE in the SSO setting by setting the Token Endpoint value to None (PKCE)
Then, note down the Client ID for the app (different from the OneLogin API credential Client ID)
Finally under Configuration, specify one or more redirect urls to be allowed. http://localhost:3000 is also allowed for local development.
```shell
npm install GIT_USER_ID/GIT_REPO_ID --save
```
import Client from "@onelogin/sdk";
const onelogin = new Client({region: "us"}); // client id and secret are not required here
### For browser
let pkceClient = onelogin.pkce.Configure({
redirectURL: "http://localhost:3000",
clientID: oidc-123-client-3456
});
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file):
let loginLink = document.getElementById("loginLink") // some <a> tag
pkceClient.CreateAuthURL().then(url => loginLink.href = url) // establish link for user to click to go to login page
let accessToken = ""
let urlParams = new URLSearchParams(location.search);
let code = urlParams['code']; // code returned after successful login
pkceClient.GetAccessTokenAsync(code).then(token => accessToken = token)
let me = null
pkceClient.GetUserInfoAsync(accessToken).then(user => me = user)
```shell
browserify main.js > bundle.js
```
### Smart MFA for Deno / NodeJS Backend
Then include *bundle.js* in the HTML pages.
This SDK comes with the methods required to support the Smart MFA scenario. This scenario checks a User's behavior analytics with Vigilance A.I. to determine if an additional factor such as Email or SMS is required.
### Webpack Configuration
Generally one of 2 things should happen:
Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:
1. User is checked against Vigilance and no action required
2. User is checked but requires additional factor. In this case you'll get a MFA token in the response of the `CheckMFARequired` function to validate later.
* Finally as shown in `/otp` we combine the MFA token with the supplied OTP collected from the client and use that to determine if a user has rightful access
```javascript
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
```
const onelogin = new Client({
clientID: abc-123-def-456,
clientSecret: 654-fed-321-cba,
region: "us"
});
// implement these routes
router.post('/signup', signupRoute)
router.post('/login', loginRoute)
router.post('/otp', otpRoute)
## Getting Started
signupRoute = async (req: Request, res: Response) => {
try {
let existingUser = this.userDB.Read(req.body.email)
if( existingUser ) {
return res.status(400).json({
error: `User with id ${req.body.email} exists!`
})
}
Please follow the [installation](#installation) instruction and execute the following JS code:
let { email: user_identifier, phone, password } = req.body
let context = {
user_agent: req.headers["user-agent"],
ip: req.connection.remoteAddress
}
```javascript
var OneLoginApi = require('one_login_api');
let { data, error } = await onelogin.smartMFA.CheckMFARequired({
user_identifier, phone, context
})
if( error ) return res.status(error.httpStatusCode).json(error.data)
var api = new OneLoginApi.DefaultApi()
var authorization = "authorization_example"; // {String}
var userId = 56; // {Number} Set to the id of the user.
var activateFactorRequest = new OneLoginApi.ActivateFactorRequest(); // {ActivateFactorRequest}
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
}
};
api.activateFactor(authorization, userId, activateFactorRequest, callback);
this.userDB.Upsert({
phone,
password,
id: user_identifier,
email: user_identifier
})
```
console.log(`Completed Risk Assessment for ${user_identifier}`)
return res.status(200).json(data.mfa)
## Documentation for API Endpoints
} catch( err ) {
console.log("An unknown error occurred", err)
return res.status(500).send(err.message)
}
}
All URIs are relative to *https://onelogininc.onelogin.com*
loginRoute = async (req: Request, res: Response) => {
try {
let user = this.userDB.Read(req.body.email)
if( !user ) {
return res.status(400).json({
error: `User with id ${req.body.email} not found!`
})
}
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*OneLoginApi.DefaultApi* | [**activateFactor**](docs/DefaultApi.md#activateFactor) | **POST** /api/2/mfa/users/{user_id}/verifications |
*OneLoginApi.DefaultApi* | [**addAccessTokenClaim**](docs/DefaultApi.md#addAccessTokenClaim) | **POST** /api/2/api_authorizations/{id}/claims |
*OneLoginApi.DefaultApi* | [**addClientApp**](docs/DefaultApi.md#addClientApp) | **POST** /api/2/api_authorizations/{id}/clients |
*OneLoginApi.DefaultApi* | [**addRoleAdmins**](docs/DefaultApi.md#addRoleAdmins) | **POST** /api/2/roles/{role_id}/admins |
*OneLoginApi.DefaultApi* | [**addRoleUsers**](docs/DefaultApi.md#addRoleUsers) | **POST** /api/2/roles/{role_id}/users |
*OneLoginApi.DefaultApi* | [**addScope**](docs/DefaultApi.md#addScope) | **POST** /api/2/api_authorizations/{id}/scopes |
*OneLoginApi.DefaultApi* | [**bulkMappingSort**](docs/DefaultApi.md#bulkMappingSort) | **PUT** /api/2/apps/mappings/sort |
*OneLoginApi.DefaultApi* | [**bulkSort**](docs/DefaultApi.md#bulkSort) | **PUT** /api/2/apps/{app_id}/rules/sort |
*OneLoginApi.DefaultApi* | [**createApp**](docs/DefaultApi.md#createApp) | **POST** /api/2/apps |
*OneLoginApi.DefaultApi* | [**createAuthorizationServer**](docs/DefaultApi.md#createAuthorizationServer) | **POST** /api/2/api_authorizations |
*OneLoginApi.DefaultApi* | [**createEnvironmentVariable**](docs/DefaultApi.md#createEnvironmentVariable) | **POST** /api/2/hooks/envs |
*OneLoginApi.DefaultApi* | [**createHook**](docs/DefaultApi.md#createHook) | **POST** /api/2/hooks |
*OneLoginApi.DefaultApi* | [**createMapping**](docs/DefaultApi.md#createMapping) | **POST** /api/2/mappings |
*OneLoginApi.DefaultApi* | [**createRiskRule**](docs/DefaultApi.md#createRiskRule) | **POST** /api/2/risk/rules |
*OneLoginApi.DefaultApi* | [**createRoles**](docs/DefaultApi.md#createRoles) | **POST** /api/2/roles |
*OneLoginApi.DefaultApi* | [**createRule**](docs/DefaultApi.md#createRule) | **POST** /api/2/apps/{app_id}/rules |
*OneLoginApi.DefaultApi* | [**createUser**](docs/DefaultApi.md#createUser) | **POST** /api/2/users |
*OneLoginApi.DefaultApi* | [**deleteAccessTokenClaim**](docs/DefaultApi.md#deleteAccessTokenClaim) | **DELETE** /api/2/api_authorizations/{id}/claims/{claim_id} |
*OneLoginApi.DefaultApi* | [**deleteApp**](docs/DefaultApi.md#deleteApp) | **DELETE** /api/2/apps/{app_id} |
*OneLoginApi.DefaultApi* | [**deleteAppParameter**](docs/DefaultApi.md#deleteAppParameter) | **DELETE** /api/2/apps/{app_id}/parameters/{parameter_id} |
*OneLoginApi.DefaultApi* | [**deleteAuthorizationServer**](docs/DefaultApi.md#deleteAuthorizationServer) | **DELETE** /api/2/api_authorizations/{id} |
*OneLoginApi.DefaultApi* | [**deleteEnvironmentVariable**](docs/DefaultApi.md#deleteEnvironmentVariable) | **DELETE** /api/2/hooks/envs/{envvar_id} |
*OneLoginApi.DefaultApi* | [**deleteFactor**](docs/DefaultApi.md#deleteFactor) | **DELETE** /api/2/mfa/users/{user_id}/devices/{device_id} |
*OneLoginApi.DefaultApi* | [**deleteHook**](docs/DefaultApi.md#deleteHook) | **DELETE** /api/2/hooks/{hook_id} |
*OneLoginApi.DefaultApi* | [**deleteMapping**](docs/DefaultApi.md#deleteMapping) | **DELETE** /api/2/mappings/{mapping_id} |
*OneLoginApi.DefaultApi* | [**deleteRiskRule**](docs/DefaultApi.md#deleteRiskRule) | **DELETE** /api/2/risk/rules/{risk_rule_id} |
*OneLoginApi.DefaultApi* | [**deleteRole**](docs/DefaultApi.md#deleteRole) | **DELETE** /api/2/roles/{role_id} |
*OneLoginApi.DefaultApi* | [**deleteRule**](docs/DefaultApi.md#deleteRule) | **DELETE** /api/2/apps/{app_id}/rules/{rule_id} |
*OneLoginApi.DefaultApi* | [**deleteScope**](docs/DefaultApi.md#deleteScope) | **DELETE** /api/2/api_authorizations/{id}/scopes/{scope_id} |
*OneLoginApi.DefaultApi* | [**deleteUser**](docs/DefaultApi.md#deleteUser) | **DELETE** /api/2/users/{user_id} |
*OneLoginApi.DefaultApi* | [**dryRunMapping**](docs/DefaultApi.md#dryRunMapping) | **POST** /api/2/mappings/{mapping_id}/dryrun |
*OneLoginApi.DefaultApi* | [**enrollFactor**](docs/DefaultApi.md#enrollFactor) | **POST** /api/2/mfa/users/{user_id}/registrations |
*OneLoginApi.DefaultApi* | [**generateMfaToken**](docs/DefaultApi.md#generateMfaToken) | **POST** /api/2/mfs/users/{user_id}/mfa_token |
*OneLoginApi.DefaultApi* | [**generateSamlAssertion**](docs/DefaultApi.md#generateSamlAssertion) | **POST** /api/2/saml_assertion |
*OneLoginApi.DefaultApi* | [**generateToken**](docs/DefaultApi.md#generateToken) | **POST** /auth/oauth2/v2/token |
*OneLoginApi.DefaultApi* | [**getApp**](docs/DefaultApi.md#getApp) | **GET** /api/2/apps/{app_id} |
*OneLoginApi.DefaultApi* | [**getAuthorizationServer**](docs/DefaultApi.md#getAuthorizationServer) | **GET** /api/2/api_authorizations/{id} |
*OneLoginApi.DefaultApi* | [**getAvailableFactors**](docs/DefaultApi.md#getAvailableFactors) | **GET** /api/2/mfa/users/{user_id}/factors |
*OneLoginApi.DefaultApi* | [**getClientApps**](docs/DefaultApi.md#getClientApps) | **GET** /api/2/api_authorizations/{id}/clients |
*OneLoginApi.DefaultApi* | [**getEnrolledFactors**](docs/DefaultApi.md#getEnrolledFactors) | **GET** /api/2/mfa/users/{user_id}/devices |
*OneLoginApi.DefaultApi* | [**getEnvironmentVariable**](docs/DefaultApi.md#getEnvironmentVariable) | **GET** /api/2/hooks/envs/{envvar_id} |
*OneLoginApi.DefaultApi* | [**getHook**](docs/DefaultApi.md#getHook) | **GET** /api/2/hooks/{hook_id} |
*OneLoginApi.DefaultApi* | [**getLogs**](docs/DefaultApi.md#getLogs) | **GET** /api/2/hooks/{hook_id}/logs |
*OneLoginApi.DefaultApi* | [**getMapping**](docs/DefaultApi.md#getMapping) | **GET** /api/2/mappings/{mapping_id} |
*OneLoginApi.DefaultApi* | [**getRateLimit**](docs/DefaultApi.md#getRateLimit) | **GET** /auth/rate_limit |
*OneLoginApi.DefaultApi* | [**getRiskRule**](docs/DefaultApi.md#getRiskRule) | **GET** /api/2/risk/rules/{risk_rule_id} |
*OneLoginApi.DefaultApi* | [**getRiskScore**](docs/DefaultApi.md#getRiskScore) | **POST** /api/2/risk/verify |
*OneLoginApi.DefaultApi* | [**getRole**](docs/DefaultApi.md#getRole) | **GET** /api/2/roles/{role_id} |
*OneLoginApi.DefaultApi* | [**getRoleAdmins**](docs/DefaultApi.md#getRoleAdmins) | **GET** /api/2/roles/{role_id}/admins |
*OneLoginApi.DefaultApi* | [**getRoleApps**](docs/DefaultApi.md#getRoleApps) | **GET** /api/2/roles/{role_id}/apps |
*OneLoginApi.DefaultApi* | [**getRoleUsers**](docs/DefaultApi.md#getRoleUsers) | **GET** /api/2/roles/{role_id}/users |
*OneLoginApi.DefaultApi* | [**getRule**](docs/DefaultApi.md#getRule) | **GET** /api/2/apps/{app_id}/rules/{rule_id} |
*OneLoginApi.DefaultApi* | [**getScoreInsights**](docs/DefaultApi.md#getScoreInsights) | **GET** /api/2/risk/scores |
*OneLoginApi.DefaultApi* | [**getUser**](docs/DefaultApi.md#getUser) | **GET** /api/2/users/{user_id} |
*OneLoginApi.DefaultApi* | [**getUserApps**](docs/DefaultApi.md#getUserApps) | **GET** /api/2/users/{user_id}/apps |
*OneLoginApi.DefaultApi* | [**listAccessTokenClaims**](docs/DefaultApi.md#listAccessTokenClaims) | **GET** /api/2/api_authorizations/{id}/claims |
*OneLoginApi.DefaultApi* | [**listActionValues**](docs/DefaultApi.md#listActionValues) | **GET** /api/2/apps/{app_id}/rules/actions/{actuion_value}/values |
*OneLoginApi.DefaultApi* | [**listActions**](docs/DefaultApi.md#listActions) | **GET** /api/2/apps/{app_id}/rules/actions |
*OneLoginApi.DefaultApi* | [**listAppUsers**](docs/DefaultApi.md#listAppUsers) | **GET** /api/2/apps/{app_id}/users |
*OneLoginApi.DefaultApi* | [**listApps**](docs/DefaultApi.md#listApps) | **GET** /api/2/apps |
*OneLoginApi.DefaultApi* | [**listAuthorizationServers**](docs/DefaultApi.md#listAuthorizationServers) | **GET** /api/2/api_authorizations |
*OneLoginApi.DefaultApi* | [**listConditionOperators**](docs/DefaultApi.md#listConditionOperators) | **GET** /api/2/apps/{app_id}/rules/conditions/{condition_value}/operators |
*OneLoginApi.DefaultApi* | [**listConditionValues**](docs/DefaultApi.md#listConditionValues) | **GET** /api/2/apps/{app_id}/rules/conditions/{condition_value}/values |
*OneLoginApi.DefaultApi* | [**listConditions**](docs/DefaultApi.md#listConditions) | **GET** /api/2/apps/{app_id}/rules/conditions |
*OneLoginApi.DefaultApi* | [**listConnectors**](docs/DefaultApi.md#listConnectors) | **GET** /api/2/connectors |
*OneLoginApi.DefaultApi* | [**listEnvironmentVariables**](docs/DefaultApi.md#listEnvironmentVariables) | **GET** /api/2/hooks/envs |
*OneLoginApi.DefaultApi* | [**listHooks**](docs/DefaultApi.md#listHooks) | **GET** /api/2/hooks |
*OneLoginApi.DefaultApi* | [**listMappingActionValues**](docs/DefaultApi.md#listMappingActionValues) | **GET** /api/2/apps/mappings/actions/{actuion_value}/values |
*OneLoginApi.DefaultApi* | [**listMappingActions**](docs/DefaultApi.md#listMappingActions) | **GET** /api/2/apps/mappings/actions |
*OneLoginApi.DefaultApi* | [**listMappingConditionOperators**](docs/DefaultApi.md#listMappingConditionOperators) | **GET** /api/2/apps/mappings/conditions/{condition_value}/operators |
*OneLoginApi.DefaultApi* | [**listMappingConditionValues**](docs/DefaultApi.md#listMappingConditionValues) | **GET** /api/2/apps/mappings/conditions/{condition_value}/values |
*OneLoginApi.DefaultApi* | [**listMappingConditions**](docs/DefaultApi.md#listMappingConditions) | **GET** /api/2/apps/mappings/conditions |
*OneLoginApi.DefaultApi* | [**listMappings**](docs/DefaultApi.md#listMappings) | **GET** /api/2/mappings |
*OneLoginApi.DefaultApi* | [**listRiskRules**](docs/DefaultApi.md#listRiskRules) | **GET** /api/2/risk/rules |
*OneLoginApi.DefaultApi* | [**listRoles**](docs/DefaultApi.md#listRoles) | **GET** /api/2/roles |
*OneLoginApi.DefaultApi* | [**listRules**](docs/DefaultApi.md#listRules) | **GET** /api/2/apps/{app_id}/rules |
*OneLoginApi.DefaultApi* | [**listScopes**](docs/DefaultApi.md#listScopes) | **GET** /api/2/api_authorizations/{id}/scopes |
*OneLoginApi.DefaultApi* | [**listUsers**](docs/DefaultApi.md#listUsers) | **GET** /api/2/users |
*OneLoginApi.DefaultApi* | [**removeClientApp**](docs/DefaultApi.md#removeClientApp) | **DELETE** /api/2/api_authorizations/{id}/clients/{client_app_id} |
*OneLoginApi.DefaultApi* | [**removeRoleAdmins**](docs/DefaultApi.md#removeRoleAdmins) | **DELETE** /api/2/roles/{role_id}/admins |
*OneLoginApi.DefaultApi* | [**removeRoleUsers**](docs/DefaultApi.md#removeRoleUsers) | **DELETE** /api/2/roles/{role_id}/users |
*OneLoginApi.DefaultApi* | [**revokeToken**](docs/DefaultApi.md#revokeToken) | **POST** /auth/oauth2/revoke |
*OneLoginApi.DefaultApi* | [**setRoleApps**](docs/DefaultApi.md#setRoleApps) | **PUT** /api/2/roles/{role_id}/apps |
*OneLoginApi.DefaultApi* | [**trackEvent**](docs/DefaultApi.md#trackEvent) | **POST** /api/2/risk/events |
*OneLoginApi.DefaultApi* | [**updateAccessTokenClaim**](docs/DefaultApi.md#updateAccessTokenClaim) | **PUT** /api/2/api_authorizations/{id}/claims/{claim_id} |
*OneLoginApi.DefaultApi* | [**updateApp**](docs/DefaultApi.md#updateApp) | **PUT** /api/2/apps/{app_id} |
*OneLoginApi.DefaultApi* | [**updateAuthorizationServer**](docs/DefaultApi.md#updateAuthorizationServer) | **PUT** /api/2/api_authorizations/{id} |
*OneLoginApi.DefaultApi* | [**updateClientApp**](docs/DefaultApi.md#updateClientApp) | **PUT** /api/2/api_authorizations/{id}/clients/{client_app_id} |
*OneLoginApi.DefaultApi* | [**updateEnvironmentVariable**](docs/DefaultApi.md#updateEnvironmentVariable) | **PUT** /api/2/hooks/envs/{envvar_id} |
*OneLoginApi.DefaultApi* | [**updateHook**](docs/DefaultApi.md#updateHook) | **PUT** /api/2/hooks/{hook_id} |
*OneLoginApi.DefaultApi* | [**updateMapping**](docs/DefaultApi.md#updateMapping) | **PUT** /api/2/mappings/{mapping_id} |
*OneLoginApi.DefaultApi* | [**updateRiskRule**](docs/DefaultApi.md#updateRiskRule) | **PUT** /api/2/risk/rules/{risk_rule_id} |
*OneLoginApi.DefaultApi* | [**updateRole**](docs/DefaultApi.md#updateRole) | **PUT** /api/2/roles/{role_id} |
*OneLoginApi.DefaultApi* | [**updateRule**](docs/DefaultApi.md#updateRule) | **PUT** /api/2/apps/{app_id}/rules/{rule_id} |
*OneLoginApi.DefaultApi* | [**updateScope**](docs/DefaultApi.md#updateScope) | **PUT** /api/2/api_authorizations/{id}/scopes/{scope_id} |
*OneLoginApi.DefaultApi* | [**updateUser**](docs/DefaultApi.md#updateUser) | **PUT** /api/2/users/{user_id} |
*OneLoginApi.DefaultApi* | [**verifyEnrollment**](docs/DefaultApi.md#verifyEnrollment) | **PUT** /api/2/mfa/users/{user_id}/registrations/{registration_id} |
*OneLoginApi.DefaultApi* | [**verifyEnrollmentVoiceProtect**](docs/DefaultApi.md#verifyEnrollmentVoiceProtect) | **GET** /api/2/mfa/users/{user_id}/registrations/{registration_id} |
*OneLoginApi.DefaultApi* | [**verifyFactor**](docs/DefaultApi.md#verifyFactor) | **PUT** /api/2/mfa/users/{user_id}/verifications/{verification_id} |
*OneLoginApi.DefaultApi* | [**verifyFactorSaml**](docs/DefaultApi.md#verifyFactorSaml) | **POST** /api/2/saml_assertion/verify_factor |
*OneLoginApi.DefaultApi* | [**verifyFactorVoice**](docs/DefaultApi.md#verifyFactorVoice) | **GET** /api/2/mfa/users/{user_id}/verifications/{verification_id} |
if( !user.validated(req.body.password) ) {
return res.status(400).json({ error: `Wrong password` })
}
let { email: user_identifier, phone } = user
let context = {
user_agent: req.headers["user-agent"],
ip: req.connection.remoteAddress
}
## Documentation for Models
let { data, error } = await onelogin.smartMFA.CheckMFARequired({
user_identifier, phone, context
})
- [OneLoginApi.Action](docs/Action.md)
- [OneLoginApi.ActivateFactorRequest](docs/ActivateFactorRequest.md)
- [OneLoginApi.AddAccessTokenClaimRequest](docs/AddAccessTokenClaimRequest.md)
- [OneLoginApi.AddClientAppRequest](docs/AddClientAppRequest.md)
- [OneLoginApi.AddRoleUsers200ResponseInner](docs/AddRoleUsers200ResponseInner.md)
- [OneLoginApi.AddScopeRequest](docs/AddScopeRequest.md)
- [OneLoginApi.AuthMethod](docs/AuthMethod.md)
- [OneLoginApi.AuthServerConfiguration](docs/AuthServerConfiguration.md)
- [OneLoginApi.ClientApp](docs/ClientApp.md)
- [OneLoginApi.Condition](docs/Condition.md)
- [OneLoginApi.Connector](docs/Connector.md)
- [OneLoginApi.CreateAuthorizationServerRequest](docs/CreateAuthorizationServerRequest.md)
- [OneLoginApi.CreateEnvironmentVariableRequest](docs/CreateEnvironmentVariableRequest.md)
- [OneLoginApi.CreateRoles201ResponseInner](docs/CreateRoles201ResponseInner.md)
- [OneLoginApi.Device](docs/Device.md)
- [OneLoginApi.EnrollFactorRequest](docs/EnrollFactorRequest.md)
- [OneLoginApi.Envvar](docs/Envvar.md)
- [OneLoginApi.ErrorStatus](docs/ErrorStatus.md)
- [OneLoginApi.ErrorStatusErrorsInner](docs/ErrorStatusErrorsInner.md)
- [OneLoginApi.FactorInner](docs/FactorInner.md)
- [OneLoginApi.FactorInnerFactorData](docs/FactorInnerFactorData.md)
- [OneLoginApi.GenerateMfaToken200Response](docs/GenerateMfaToken200Response.md)
- [OneLoginApi.GenerateMfaToken422Response](docs/GenerateMfaToken422Response.md)
- [OneLoginApi.GenerateMfaToken422ResponseDetails](docs/GenerateMfaToken422ResponseDetails.md)
- [OneLoginApi.GenerateMfaTokenRequest](docs/GenerateMfaTokenRequest.md)
- [OneLoginApi.GenerateSamlAssertionRequest](docs/GenerateSamlAssertionRequest.md)
- [OneLoginApi.GenerateToken200Response](docs/GenerateToken200Response.md)
- [OneLoginApi.GenerateToken400Response](docs/GenerateToken400Response.md)
- [OneLoginApi.GenerateTokenRequest](docs/GenerateTokenRequest.md)
- [OneLoginApi.GetAuthorizationServer200Response](docs/GetAuthorizationServer200Response.md)
- [OneLoginApi.GetAvailableFactors200ResponseInner](docs/GetAvailableFactors200ResponseInner.md)
- [OneLoginApi.GetClientApps200ResponseInner](docs/GetClientApps200ResponseInner.md)
- [OneLoginApi.GetClientApps200ResponseInnerScopesInner](docs/GetClientApps200ResponseInnerScopesInner.md)
- [OneLoginApi.GetRateLimit200Response](docs/GetRateLimit200Response.md)
- [OneLoginApi.GetRateLimit200ResponseData](docs/GetRateLimit200ResponseData.md)
- [OneLoginApi.GetRiskScore200Response](docs/GetRiskScore200Response.md)
- [OneLoginApi.GetRiskScore400Response](docs/GetRiskScore400Response.md)
- [OneLoginApi.GetRiskScoreRequest](docs/GetRiskScoreRequest.md)
- [OneLoginApi.GetScoreInsights200Response](docs/GetScoreInsights200Response.md)
- [OneLoginApi.GetScoreInsights200ResponseScores](docs/GetScoreInsights200ResponseScores.md)
- [OneLoginApi.GetUserApps200ResponseInner](docs/GetUserApps200ResponseInner.md)
- [OneLoginApi.Hook](docs/Hook.md)
- [OneLoginApi.HookConditionsInner](docs/HookConditionsInner.md)
- [OneLoginApi.HookOptions](docs/HookOptions.md)
- [OneLoginApi.HookStatus](docs/HookStatus.md)
- [OneLoginApi.Id](docs/Id.md)
- [OneLoginApi.ListAccessTokenClaims200ResponseInner](docs/ListAccessTokenClaims200ResponseInner.md)
- [OneLoginApi.ListActions200ResponseInner](docs/ListActions200ResponseInner.md)
- [OneLoginApi.ListAppUsers200ResponseInner](docs/ListAppUsers200ResponseInner.md)
- [OneLoginApi.ListAuthorizationServers200ResponseInner](docs/ListAuthorizationServers200ResponseInner.md)
- [OneLoginApi.ListAuthorizationServers200ResponseInnerConfiguration](docs/ListAuthorizationServers200ResponseInnerConfiguration.md)
- [OneLoginApi.ListConditionOperators200ResponseInner](docs/ListConditionOperators200ResponseInner.md)
- [OneLoginApi.ListConditionValues200ResponseInner](docs/ListConditionValues200ResponseInner.md)
- [OneLoginApi.ListConditions200ResponseInner](docs/ListConditions200ResponseInner.md)
- [OneLoginApi.ListMappingConditionOperators200ResponseInner](docs/ListMappingConditionOperators200ResponseInner.md)
- [OneLoginApi.ListMappingConditions200ResponseInner](docs/ListMappingConditions200ResponseInner.md)
- [OneLoginApi.ListScopes200ResponseInner](docs/ListScopes200ResponseInner.md)
- [OneLoginApi.Log](docs/Log.md)
- [OneLoginApi.Mapping](docs/Mapping.md)
- [OneLoginApi.Registration](docs/Registration.md)
- [OneLoginApi.RemoveRoleUsersRequest](docs/RemoveRoleUsersRequest.md)
- [OneLoginApi.RevokeTokenRequest](docs/RevokeTokenRequest.md)
- [OneLoginApi.RiskDevice](docs/RiskDevice.md)
- [OneLoginApi.RiskRule](docs/RiskRule.md)
- [OneLoginApi.RiskUser](docs/RiskUser.md)
- [OneLoginApi.Role](docs/Role.md)
- [OneLoginApi.Rule](docs/Rule.md)
- [OneLoginApi.RuleId](docs/RuleId.md)
- [OneLoginApi.Schema](docs/Schema.md)
- [OneLoginApi.Schema1](docs/Schema1.md)
- [OneLoginApi.Schema1AddedBy](docs/Schema1AddedBy.md)
- [OneLoginApi.SchemaProvisioning](docs/SchemaProvisioning.md)
- [OneLoginApi.Session](docs/Session.md)
- [OneLoginApi.SetRoleApps200ResponseInner](docs/SetRoleApps200ResponseInner.md)
- [OneLoginApi.Source](docs/Source.md)
- [OneLoginApi.Status](docs/Status.md)
- [OneLoginApi.Status1](docs/Status1.md)
- [OneLoginApi.Status2](docs/Status2.md)
- [OneLoginApi.Status2Status](docs/Status2Status.md)
- [OneLoginApi.TrackEventRequest](docs/TrackEventRequest.md)
- [OneLoginApi.UpdateAuthorizationServer400Response](docs/UpdateAuthorizationServer400Response.md)
- [OneLoginApi.UpdateClientAppRequest](docs/UpdateClientAppRequest.md)
- [OneLoginApi.UpdateEnvironmentVariableRequest](docs/UpdateEnvironmentVariableRequest.md)
- [OneLoginApi.UpdateRole200Response](docs/UpdateRole200Response.md)
- [OneLoginApi.User](docs/User.md)
- [OneLoginApi.VerifyEnrollmentRequest](docs/VerifyEnrollmentRequest.md)
- [OneLoginApi.VerifyFactorRequest](docs/VerifyFactorRequest.md)
- [OneLoginApi.VerifyFactorSaml200Response](docs/VerifyFactorSaml200Response.md)
- [OneLoginApi.VerifyFactorSamlRequest](docs/VerifyFactorSamlRequest.md)
- [OneLoginApi.VerifyFactorVoice200ResponseInner](docs/VerifyFactorVoice200ResponseInner.md)
if( error ) return res.status(error.httpStatusCode).json(error.data)
console.log(`Completed Risk Assessment for ${user_identifier}`)
return res.status(200).json(data.mfa)
} catch( err ) {
console.log("An unknown error occurred", err)
return res.status(500).send(err.message)
}
}
## Documentation for Authorization
otpRoute = async (req: Request, res: Response) => {
try {
let data = await onelogin.smartMFA.ValidateOTP( { ...req.body } )
console.log("OTP Validation Done!")
return res.status(200).json(data)
} catch( err ) {
console.log("An unknown error occurred", err)
return res.status(500).send(err.message)
}
}
```
All endpoints do not require authorization.
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"declaration": true,
"noImplicitAny": true,
"esModuleInterop": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"]
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "ES5",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"noLib": false,
"declaration": true,
"lib": ["dom", "es6", "es5", "dom.iterable", "scripthost"],
"outDir": "dist",
"typeRoots": [
"node_modules/@types"
]
},
"typeRoots": [
"./@types",
"./node_modules/@types",
"exclude": [
"dist",
"node_modules"
]
},
"include": ["lib/**/*"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc