@okta/okta-sdk-nodejs
Advanced tools
Comparing version 0.1.0 to 0.3.0
{ | ||
"name": "@okta/okta-sdk-nodejs", | ||
"version": "0.1.0", | ||
"version": "0.3.0", | ||
"description": "Okta API wrapper for Node.js", | ||
@@ -20,5 +20,2 @@ "engines": { | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"keywords": [], | ||
@@ -35,3 +32,3 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@okta/openapi": "^0.2.0", | ||
"@okta/openapi": "^0.5.0", | ||
"chai": "^3.5.0", | ||
@@ -45,4 +42,9 @@ "eslint": "^3.19.0", | ||
"mocha": "^3.4.1", | ||
"nyc": "^10.3.2" | ||
"nyc": "^10.3.2", | ||
"speakeasy": "^2.0.0" | ||
}, | ||
"okta": { | ||
"commitSha": "d315ae2394d1043e21e829b67e9af8b6a12f3466", | ||
"fullVersion": "0.3.0-20171016205517-d315ae2" | ||
} | ||
} |
@@ -9,5 +9,5 @@ # okta-sdk-nodejs | ||
This library is under development and is currently a 0.x version series. Breaking changes will be introduced as minor version bumps in the 0.x range. Some of the API is not yet expressed in this library, please use your IDE hints or view [src/api-client.js](src/api-client.js) to browse available methods. We will eventually publish the JsDoc documentation on https://developer.okta.com. | ||
This library is under development and is currently a 0.x version series. Breaking changes will be introduced as minor version bumps in the 0.x range. Some of the API is not yet expressed in this library, please refer to the JsDoc: [Okta NodeJS Management SDK Documentation](https://developer.okta.com/okta-sdk-nodejs/jsdocs/). | ||
Need help? Contact [developers@okta.com](mailto:developers@okta.com) or use the [Okta Developer Forum]. | ||
Need help? Contact [developers@okta.com](mailto:developers@okta.com) or use the [Okta Developer Forum]. | ||
@@ -14,0 +14,0 @@ ## Installation |
@@ -27,6 +27,6 @@ /*! | ||
*/ | ||
constructor(client, uri, Ctor) { | ||
constructor(client, uri, factory) { | ||
this.nextUri = uri; | ||
this.client = client; | ||
this.Ctor = Ctor; | ||
this.factory = factory; | ||
this.currentItems = []; | ||
@@ -42,3 +42,3 @@ } | ||
const result = { | ||
value: new self.Ctor(item, self.client), | ||
value: self.factory.createInstance(item, self.client), | ||
done: !self.currentItems.length && !self.nextUri | ||
@@ -45,0 +45,0 @@ }; |
@@ -23,2 +23,4 @@ /*! | ||
const models = require('./models'); | ||
const factories = require('./factories'); | ||
const ModelFactory = require('./model-factory'); | ||
@@ -50,3 +52,3 @@ /** | ||
return new Collection(this, url, models.Group); | ||
return new Collection(this, url, new ModelFactory(models.Group)); | ||
} | ||
@@ -83,3 +85,3 @@ | ||
return new Collection(this, url, models.GroupRule); | ||
return new Collection(this, url, new ModelFactory(models.GroupRule)); | ||
} | ||
@@ -108,3 +110,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/groups/rules/{ruleId} | ||
* Removes a specific group rule by id from your organization | ||
*/ | ||
@@ -125,3 +127,3 @@ deleteRule(ruleId, queryParameters) { | ||
* @description | ||
* Convenience method for /api/v1/groups/rules/{ruleId} | ||
* Fetches a specific group rule by id from your organization | ||
*/ | ||
@@ -155,3 +157,3 @@ getRule(ruleId) { | ||
* @description | ||
* Convenience method for /api/v1/groups/rules/{ruleId}/lifecycle/activate | ||
* Activates a specific group rule by id from your organization | ||
*/ | ||
@@ -169,3 +171,3 @@ activateRule(ruleId) { | ||
* @description | ||
* Convenience method for /api/v1/groups/rules/{ruleId}/lifecycle/deactivate | ||
* Deactivates a specific group rule by id from your organization | ||
*/ | ||
@@ -183,3 +185,3 @@ deactivateRule(ruleId) { | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId} | ||
* Removes a group with `OKTA_GROUP` type from your organization. | ||
*/ | ||
@@ -199,3 +201,3 @@ deleteGroup(groupId) { | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId} | ||
* Lists all group rules for your organization. | ||
*/ | ||
@@ -217,3 +219,3 @@ getGroup(groupId, queryParameters) { | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId} | ||
* Updates the profile for a group with `OKTA_GROUP` type from your organization. | ||
*/ | ||
@@ -232,15 +234,2 @@ updateGroup(groupId, group) { | ||
* @param groupId {String} | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId}/stats | ||
*/ | ||
getGroupStats(groupId) { | ||
let url = `${this.baseUrl}/api/v1/groups/${groupId}/stats`; | ||
const request = this.http.getJson(url); | ||
return request.then(jsonRes => new models.GroupStats(jsonRes, this)); | ||
} | ||
/** | ||
* | ||
* @param groupId {String} | ||
* @param {Object} queryParams Map of query parameters to add to this request | ||
@@ -250,3 +239,3 @@ * @param {String} [queryParams.after] | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId}/users | ||
* Enumerates all [users](/docs/api/resources/users.html#user-model) that are a member of a group. | ||
*/ | ||
@@ -259,3 +248,3 @@ listGroupUsers(groupId, queryParameters) { | ||
return new Collection(this, url, models.User); | ||
return new Collection(this, url, new ModelFactory(models.User)); | ||
} | ||
@@ -268,3 +257,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId}/users/{userId} | ||
* Removes a [user](users.html#user-model) from a group with `OKTA_GROUP` type. | ||
*/ | ||
@@ -283,3 +272,3 @@ removeGroupUser(groupId, userId) { | ||
* @description | ||
* Convenience method for /api/v1/groups/{groupId}/users/{userId} | ||
* Adds a [user](users.html#user-model) to a group with `OKTA_GROUP` type. | ||
*/ | ||
@@ -312,3 +301,3 @@ addUserToGroup(groupId, userId) { | ||
return new Collection(this, url, models.User); | ||
return new Collection(this, url, new ModelFactory(models.User)); | ||
} | ||
@@ -341,3 +330,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/users/{userId} | ||
* Deletes a user permanently. This operation can only be performed on users that have a `DEPROVISIONED` status. **This action cannot be recovered!** | ||
*/ | ||
@@ -355,3 +344,3 @@ deactivateOrDeleteUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId} | ||
* Fetches a user from your Okta organization. | ||
*/ | ||
@@ -370,3 +359,3 @@ getUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId} | ||
* Update a user's profile and/or credentials using strict-update semantics. | ||
*/ | ||
@@ -388,3 +377,3 @@ updateUser(userId, user) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/appLinks | ||
* Fetches appLinks for all direct or indirect (via group membership) assigned applications. | ||
*/ | ||
@@ -397,3 +386,3 @@ listAppLinks(userId, queryParameters) { | ||
return new Collection(this, url, models.AppLink); | ||
return new Collection(this, url, new ModelFactory(models.AppLink)); | ||
} | ||
@@ -406,3 +395,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/credentials/change_password | ||
* Changes a user's password by validating the user's current password. This operation can only be performed on users in `STAGED`, `ACTIVE`, `PASSWORD_EXPIRED`, or `RECOVERY` status that have a valid [password credential](#password-object) | ||
*/ | ||
@@ -423,3 +412,3 @@ changePassword(userId, changePasswordRequest) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/credentials/change_recovery_question | ||
* Changes a user's recovery question & answer credential by validating the user's current password. This operation can only be performed on users in **STAGED**, **ACTIVE** or **RECOVERY** `status` that have a valid [password credential](#password-object) | ||
*/ | ||
@@ -442,3 +431,3 @@ changeRecoveryQuestion(userId, userCredentials) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/credentials/forgot_password | ||
* Generates a one-time token (OTT) that can be used to reset a user's password. The user will be required to validate their security question's answer when visiting the reset link. This operation can only be performed on users with a valid [recovery question credential](#recovery-question-object) and have an `ACTIVE` status. | ||
*/ | ||
@@ -460,7 +449,132 @@ forgotPassword(userId, userCredentials, queryParameters) { | ||
* @param userId {String} | ||
* @description | ||
* Enumerates all the enrolled factors for the specified user | ||
*/ | ||
listFactors(userId) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors`; | ||
return new Collection(this, url, new factories.Factor()); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param {Factor} factor | ||
* @param {Object} queryParams Map of query parameters to add to this request | ||
* @param {String} [queryParams.updatePhone] | ||
* @param {String} [queryParams.templateId] | ||
* @description | ||
* Enrolls a user with a supported [factor](#list-factors-to-enroll) | ||
*/ | ||
addFactor(userId, factor, queryParameters) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors`; | ||
const queryString = qs.stringify(queryParameters || {}); | ||
url += queryString ? ('?' + queryString) : ''; | ||
const request = this.http.postJson(url, { | ||
body: factor | ||
}); | ||
return request.then(jsonRes => new factories.Factor().createInstance(jsonRes, this)); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @description | ||
* Enumerates all the [supported factors](#supported-factors-for-providers) that can be enrolled for the specified user | ||
*/ | ||
listSupportedFactors(userId) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/catalog`; | ||
return new Collection(this, url, new factories.Factor()); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @description | ||
* Enumerates all available security questions for a user's `question` factor | ||
*/ | ||
listSupportedSecurityQuestions(userId) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/questions`; | ||
return new Collection(this, url, new ModelFactory(models.SecurityQuestion)); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param factorId {String} | ||
* @description | ||
* Unenrolls an existing factor for the specified user, allowing the user to enroll a new factor. | ||
*/ | ||
deleteFactor(userId, factorId) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/${factorId}`; | ||
const request = this.http.delete(url); | ||
return request; | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param factorId {String} | ||
* @description | ||
* Fetches a factor for the specified user | ||
*/ | ||
getFactor(userId, factorId) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/${factorId}`; | ||
const request = this.http.getJson(url); | ||
return request.then(jsonRes => new factories.Factor().createInstance(jsonRes, this)); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param factorId {String} | ||
* @param {VerifyFactorRequest} verifyFactorRequest | ||
* @description | ||
* The `sms` and `token:software:totp` [factor types](#factor-type) require activation to complete the enrollment process. | ||
*/ | ||
activateFactor(userId, factorId, verifyFactorRequest) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/${factorId}/lifecycle/activate`; | ||
const request = this.http.postJson(url, { | ||
body: verifyFactorRequest | ||
}); | ||
return request.then(jsonRes => new factories.Factor().createInstance(jsonRes, this)); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param factorId {String} | ||
* @param {VerifyFactorRequest} verifyFactorRequest | ||
* @param {Object} queryParams Map of query parameters to add to this request | ||
* @param {String} [queryParams.templateId] | ||
* @description | ||
* Verifies an OTP for a `token` or `token:hardware` factor | ||
*/ | ||
verifyFactor(userId, factorId, verifyFactorRequest, queryParameters) { | ||
let url = `${this.baseUrl}/api/v1/users/${userId}/factors/${factorId}/verify`; | ||
const queryString = qs.stringify(queryParameters || {}); | ||
url += queryString ? ('?' + queryString) : ''; | ||
const request = this.http.postJson(url, { | ||
body: verifyFactorRequest | ||
}); | ||
return request.then(jsonRes => new models.VerifyFactorResponse(jsonRes, this)); | ||
} | ||
/** | ||
* | ||
* @param userId {String} | ||
* @param {Object} queryParams Map of query parameters to add to this request | ||
* @param {String} [queryParams.after] | ||
* @param {String} [queryParams.limit] | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/groups | ||
* Fetches the groups of which the user is a member. | ||
*/ | ||
@@ -473,3 +587,3 @@ listUserGroups(userId, queryParameters) { | ||
return new Collection(this, url, models.Group); | ||
return new Collection(this, url, new ModelFactory(models.Group)); | ||
} | ||
@@ -483,3 +597,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/activate | ||
* Activates a user. This operation can only be performed on users with a `STAGED` status. Activation of a user is an asynchronous operation. The user will have the `transitioningToStatus` property with a value of `ACTIVE` during activation to indicate that the user hasn't completed the asynchronous operation. The user will have a status of `ACTIVE` when the activation process is complete. | ||
*/ | ||
@@ -500,3 +614,3 @@ activateUser(userId, queryParameters) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/deactivate | ||
* Deactivates a user. This operation can only be performed on users that do not have a `DEPROVISIONED` status. Deactivation of a user is an asynchronous operation. The user will have the `transitioningToStatus` property with a value of `DEPROVISIONED` during deactivation to indicate that the user hasn't completed the asynchronous operation. The user will have a status of `DEPROVISIONED` when the deactivation process is complete. | ||
*/ | ||
@@ -516,3 +630,3 @@ deactivateUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/expire_password | ||
* This operation transitions the user to the status of `PASSWORD_EXPIRED` so that the user is required to change their password at their next login. | ||
*/ | ||
@@ -533,3 +647,3 @@ expirePassword(userId, queryParameters) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/reset_factors | ||
* This operation resets all factors for the specified user. All MFA factor enrollments returned to the unenrolled state. The user's status remains ACTIVE. This link is present only if the user is currently enrolled in one or more MFA factors. | ||
*/ | ||
@@ -550,3 +664,3 @@ resetAllFactors(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/reset_password | ||
* Generates a one-time token (OTT) that can be used to reset a user's password. The OTT link can be automatically emailed to the user or returned to the API caller and distributed using a custom flow. | ||
*/ | ||
@@ -567,3 +681,3 @@ resetPassword(userId, queryParameters) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/suspend | ||
* Suspends a user. This operation can only be performed on users with an `ACTIVE` status. The user will have a status of `SUSPENDED` when the process is complete. | ||
*/ | ||
@@ -581,3 +695,3 @@ suspendUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/unlock | ||
* Unlocks a user with a `LOCKED_OUT` status and returns them to `ACTIVE` status. Users will be able to login with their current password. | ||
*/ | ||
@@ -595,3 +709,3 @@ unlockUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/lifecycle/unsuspend | ||
* Unsuspends a user and returns them to the `ACTIVE` state. This operation can only be performed on users that have a `SUSPENDED` status. | ||
*/ | ||
@@ -611,3 +725,3 @@ unsuspendUser(userId) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/roles | ||
* Lists all roles assigned to a user. | ||
*/ | ||
@@ -620,3 +734,3 @@ listAssignedRoles(userId, queryParameters) { | ||
return new Collection(this, url, models.Role); | ||
return new Collection(this, url, new ModelFactory(models.Role)); | ||
} | ||
@@ -629,3 +743,3 @@ | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/roles | ||
* Assigns a role to a user. | ||
*/ | ||
@@ -646,3 +760,3 @@ addRoleToUser(userId, role) { | ||
* @description | ||
* Convenience method for /api/v1/users/{userId}/roles/{roleId} | ||
* Unassigns a role from a user. | ||
*/ | ||
@@ -672,3 +786,3 @@ removeRoleFromUser(userId, roleId) { | ||
return new Collection(this, url, models.Group); | ||
return new Collection(this, url, new ModelFactory(models.Group)); | ||
} | ||
@@ -675,0 +789,0 @@ |
@@ -36,5 +36,2 @@ /*! | ||
} | ||
getStats() { | ||
return this.client.getGroupStats(this.id); | ||
} | ||
removeUser(userId) { | ||
@@ -41,0 +38,0 @@ return this.client.removeGroupUser(this.id, userId); |
@@ -21,3 +21,12 @@ /*! | ||
exports.AuthenticationProviderType = require('./AuthenticationProviderType'); | ||
exports.CallFactor = require('./CallFactor'); | ||
exports.CallFactorProfile = require('./CallFactorProfile'); | ||
exports.ChangePasswordRequest = require('./ChangePasswordRequest'); | ||
exports.EmailFactor = require('./EmailFactor'); | ||
exports.EmailFactorProfile = require('./EmailFactorProfile'); | ||
exports.Factor = require('./Factor'); | ||
exports.FactorProfile = require('./FactorProfile'); | ||
exports.FactorResultType = require('./FactorResultType'); | ||
exports.FactorStatus = require('./FactorStatus'); | ||
exports.FactorType = require('./FactorType'); | ||
exports.ForgotPasswordResponse = require('./ForgotPasswordResponse'); | ||
@@ -35,4 +44,7 @@ exports.Group = require('./Group'); | ||
exports.GroupRuleUserCondition = require('./GroupRuleUserCondition'); | ||
exports.GroupStats = require('./GroupStats'); | ||
exports.HardwareFactor = require('./HardwareFactor'); | ||
exports.HardwareFactorProfile = require('./HardwareFactorProfile'); | ||
exports.PasswordCredential = require('./PasswordCredential'); | ||
exports.PushFactor = require('./PushFactor'); | ||
exports.PushFactorProfile = require('./PushFactorProfile'); | ||
exports.RecoveryQuestionCredential = require('./RecoveryQuestionCredential'); | ||
@@ -42,3 +54,12 @@ exports.ResetPasswordToken = require('./ResetPasswordToken'); | ||
exports.RoleStatus = require('./RoleStatus'); | ||
exports.SecurityQuestion = require('./SecurityQuestion'); | ||
exports.SecurityQuestionFactor = require('./SecurityQuestionFactor'); | ||
exports.SecurityQuestionFactorProfile = require('./SecurityQuestionFactorProfile'); | ||
exports.SmsFactor = require('./SmsFactor'); | ||
exports.SmsFactorProfile = require('./SmsFactorProfile'); | ||
exports.TempPassword = require('./TempPassword'); | ||
exports.TokenFactor = require('./TokenFactor'); | ||
exports.TokenFactorProfile = require('./TokenFactorProfile'); | ||
exports.TotpFactor = require('./TotpFactor'); | ||
exports.TotpFactorProfile = require('./TotpFactorProfile'); | ||
exports.User = require('./User'); | ||
@@ -49,1 +70,5 @@ exports.UserActivationToken = require('./UserActivationToken'); | ||
exports.UserStatus = require('./UserStatus'); | ||
exports.VerifyFactorRequest = require('./VerifyFactorRequest'); | ||
exports.VerifyFactorResponse = require('./VerifyFactorResponse'); | ||
exports.WebFactor = require('./WebFactor'); | ||
exports.WebFactorProfile = require('./WebFactorProfile'); |
@@ -96,4 +96,19 @@ /*! | ||
} | ||
addFactor(factor, queryParameters) { | ||
return this.client.addFactor(this.id, factor, queryParameters); | ||
} | ||
listSupportedFactors() { | ||
return this.client.listSupportedFactors(this.id); | ||
} | ||
listFactors() { | ||
return this.client.listFactors(this.id); | ||
} | ||
listSupportedSecurityQuestions() { | ||
return this.client.listSupportedSecurityQuestions(this.id); | ||
} | ||
getFactor(factorId) { | ||
return this.client.getFactor(this.id, factorId); | ||
} | ||
} | ||
module.exports = User; |
126461
73
2775
11