kuzzle-sdk
Advanced tools
Comparing version 7.7.5 to 7.7.6
@@ -1,1 +0,1 @@ | ||
/*! Kuzzle Javascript SDK version 7.7.5 */ | ||
/*! Kuzzle Javascript SDK version 7.7.6 */ |
{ | ||
"name": "kuzzle-sdk", | ||
"version": "7.7.5", | ||
"version": "7.7.6", | ||
"description": "Official Javascript SDK for Kuzzle", | ||
@@ -34,11 +34,3 @@ "author": "The Kuzzle Team <support@kuzzle.io>", | ||
"dev": "node -r ts-node/register ", | ||
"doc": "docker-compose -f doc/docker-compose.yml up", | ||
"doc-testing": "bash .ci/test-docs.sh", | ||
"doc-prepare": "kuzdoc framework:install", | ||
"doc-dev": "kuzdoc repo:dev -d /sdk/js/7/ -v 7", | ||
"doc-build": "kuzdoc repo:build -d /sdk/js/7/ -v 7", | ||
"doc-upload": "kuzdoc repo:deploy -d /sdk/js/7/ -v 7", | ||
"doc-cloudfront": "kuzdoc repo:cloudfront -d /sdk/js/7/*", | ||
"doc-deploy": "npm run doc-upload && npm run doc-cloudfront", | ||
"doc-netlify": "npm run doc-prepare && kuzdoc repo:build -d / -v 7" | ||
"doc-testing": "bash .ci/test-docs.sh" | ||
}, | ||
@@ -50,35 +42,34 @@ "browser": "dist/kuzzle.js", | ||
"min-req-promise": "^1.0.1", | ||
"ws": "^7.4.6" | ||
"ws": "^8.2.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.14.3", | ||
"@babel/preset-env": "^7.14.4", | ||
"@types/node": "^15.6.1", | ||
"@typescript-eslint/eslint-plugin": "^4.25.0", | ||
"@typescript-eslint/parser": "^4.25.0", | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@types/node": "^16.9.4", | ||
"@typescript-eslint/eslint-plugin": "^4.31.2", | ||
"@typescript-eslint/parser": "^4.31.2", | ||
"babel-loader": "^8.2.2", | ||
"buffer": "^6.0.3", | ||
"codecov": "^3.8.2", | ||
"codecov": "^3.8.3", | ||
"cucumber": "^6.0.5", | ||
"eslint": "^7.27.0", | ||
"eslint": "^7.32.0", | ||
"eslint-friendly-formatter": "^4.0.1", | ||
"eslint-loader": "^4.0.2", | ||
"https-browserify": "^1.0.0", | ||
"kuzdoc": "^1.4.5", | ||
"lolex": "^6.0.0", | ||
"mocha": "8.4.0", | ||
"mocha": "9.1.1", | ||
"mock-require": "^3.0.3", | ||
"nyc": "^15.1.0", | ||
"proxyquire": "^2.1.3", | ||
"retry": "^0.12.0", | ||
"retry": "^0.13.1", | ||
"rewire": "^5.0.0", | ||
"should": "13.2.3", | ||
"should-sinon": "0.0.6", | ||
"sinon": "^11.1.1", | ||
"sinon": "^11.1.2", | ||
"stream-http": "^3.2.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.2", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.4.3", | ||
"url": "^0.11.0", | ||
"webpack": "^5.38.1", | ||
"webpack-cli": "^4.7.0" | ||
"webpack": "^5.53.0", | ||
"webpack-cli": "^4.8.0" | ||
}, | ||
@@ -85,0 +76,0 @@ "engines": { |
@@ -1,541 +0,460 @@ | ||
const { BaseController } = require('./Base'); | ||
const { Role } = require('../core/security/Role'); | ||
const { RoleSearchResult } = require('../core/searchResult/Role'); | ||
const { Profile } = require('../core/security/Profile'); | ||
const { ProfileSearchResult } = require('../core/searchResult/Profile'); | ||
const { User } = require('../core/security/User'); | ||
const { UserSearchResult } = require('../core/searchResult/User'); | ||
class SecurityController extends BaseController { | ||
/** | ||
* @param {Kuzzle} kuzzle | ||
*/ | ||
constructor (kuzzle) { | ||
super(kuzzle, 'security'); | ||
} | ||
/** | ||
* Creates a new API key for a user. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {String} description - API key description | ||
* @param {Object} [options] - { _id, expiresIn, refresh } | ||
* | ||
* @returns {Promise.<Object>} ApiKey { _id, _source } | ||
*/ | ||
createApiKey(userId, description, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'createApiKey', | ||
_id: options._id, | ||
expiresIn: options.expiresIn, | ||
refresh: options.refresh, | ||
body: { | ||
description | ||
} | ||
}; | ||
return this.query(request) | ||
.then(response => response.result); | ||
} | ||
/** | ||
* Checks if an API action can be executed by a user | ||
* | ||
* @param {String} kuid - User kuid | ||
* @param {Object} requestPayload - Request to check | ||
*/ | ||
checkRights (kuid, requestPayload) { | ||
const request = { | ||
userId: kuid, | ||
body: requestPayload, | ||
action: 'checkRights' | ||
}; | ||
return this.query(request) | ||
.then(response => response.result.allowed); | ||
} | ||
/** | ||
* Deletes an user API key. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {String} id - API key ID | ||
* @param {Object} [options] - { refresh } | ||
* | ||
* @returns {Promise} | ||
*/ | ||
deleteApiKey(userId, id, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'deleteApiKey', | ||
_id: id, | ||
refresh: options.refresh | ||
}; | ||
return this.query(request) | ||
.then(() => {}); | ||
} | ||
/** | ||
* Searches for a user API key. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {Object} [query] - Search query | ||
* @param {Object} [options] - { from, size } | ||
* | ||
* @returns {Promise.<object[]>} - { hits, total } | ||
*/ | ||
searchApiKeys(userId, query = {}, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'searchApiKeys', | ||
from: options.from, | ||
size: options.size, | ||
lang: options.lang, | ||
body: query | ||
}; | ||
return this.query(request) | ||
.then(response => response.result); | ||
} | ||
createCredentials (strategy, _id, body, options = {}) { | ||
return this.query({ | ||
_id, | ||
strategy, | ||
body, | ||
action: 'createCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
createFirstAdmin (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createFirstAdmin', | ||
reset: options.reset | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createOrReplaceProfile (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createOrReplaceProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile( | ||
this.kuzzle, | ||
response.result._id, | ||
response.result._source)); | ||
} | ||
createOrReplaceRole (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createOrReplaceRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
createProfile (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile( | ||
this.kuzzle, | ||
response.result._id, | ||
response.result._source)); | ||
} | ||
createRestrictedUser (body, _id = null, options = {}) { | ||
if (!body.content) { | ||
body.content = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SecurityController = void 0; | ||
const Base_1 = require("./Base"); | ||
const Role_1 = require("../core/security/Role"); | ||
const Role_2 = require("../core/searchResult/Role"); | ||
const Profile_1 = require("../core/security/Profile"); | ||
const Profile_2 = require("../core/searchResult/Profile"); | ||
const User_1 = require("../core/security/User"); | ||
const User_2 = require("../core/searchResult/User"); | ||
class SecurityController extends Base_1.BaseController { | ||
/** | ||
* @param {Kuzzle} kuzzle | ||
*/ | ||
constructor(kuzzle) { | ||
super(kuzzle, 'security'); | ||
} | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createRestrictedUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createRole (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
createUser (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
deleteCredentials (strategy, _id, options = {}) { | ||
const request = { | ||
strategy, | ||
_id, | ||
action: 'deleteCredentials' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteProfile (_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteRole (_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteRole' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteUser (_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
getAllCredentialFields (options = {}) { | ||
return this.query({ | ||
action: 'getAllCredentialFields' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentialFields (strategy, options = {}) { | ||
return this.query({ | ||
strategy, | ||
action: 'getCredentialFields' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentials (strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'getCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentialsById (strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'getCredentialsById' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getProfile (_id, options = {}) { | ||
return this.query({_id, action: 'getProfile'}, options) | ||
.then(response => new Profile( | ||
this.kuzzle, | ||
response.result._id, | ||
response.result._source)); | ||
} | ||
getProfileMapping (options = {}) { | ||
return this.query({ | ||
action: 'getProfileMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getProfileRights (_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getProfileRights' | ||
}, options) | ||
.then(response => response.result.hits); | ||
} | ||
getRole (_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getRole' | ||
}, options) | ||
.then(response => new Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
getRoleMapping (options = {}) { | ||
return this.query({ | ||
action: 'getRoleMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getUser (_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUser' | ||
}, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
getUserMapping (options = {}) { | ||
return this.query({ | ||
action: 'getUserMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getUserRights (_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUserRights' | ||
}, options) | ||
.then(response => response.result.hits); | ||
} | ||
getUserStrategies (_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUserStrategies' | ||
}, options) | ||
.then(response => response.result.strategies); | ||
} | ||
hasCredentials (strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'hasCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteProfiles (ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteProfiles', | ||
body: {ids} | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteRoles (ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteRoles', | ||
body: {ids} | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteUsers (ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteUsers', | ||
body: {ids} | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mGetProfiles (ids, options = {}) { | ||
return this.query({action: 'mGetProfiles', body: {ids}}, options) | ||
.then(response => response.result.hits.map( | ||
hit => new Profile(this.kuzzle, hit._id, hit._source))); | ||
} | ||
mGetUsers (ids, options = {}) { | ||
const request = { | ||
action: 'mGetUsers', | ||
body: {ids} | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result.hits.map(hit => new User(this.kuzzle, hit._id, hit._source))); | ||
} | ||
mGetRoles (ids, options = {}) { | ||
return this.query({ | ||
action: 'mGetRoles', | ||
body: {ids} | ||
}, options) | ||
.then(response => response.result.hits.map(hit => new Role(this.kuzzle, hit._id, hit._source.controllers))); | ||
} | ||
refresh(collection) { | ||
return this.query({ | ||
collection, | ||
action: 'refresh' | ||
}); | ||
} | ||
replaceUser (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'replaceUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
searchProfiles (body, options= {}) { | ||
const request = { | ||
body, | ||
action: 'searchProfiles' | ||
}; | ||
for (const opt of ['from', 'size', 'scroll']) { | ||
request[opt] = options[opt]; | ||
/** | ||
* Creates a new API key for a user. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {String} description - API key description | ||
* @param {Object} [options] - { _id, expiresIn, refresh } | ||
* | ||
* @returns {Promise.<Object>} ApiKey { _id, _source } | ||
*/ | ||
createApiKey(userId, description, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'createApiKey', | ||
_id: options._id, | ||
expiresIn: options.expiresIn, | ||
refresh: options.refresh, | ||
body: { | ||
description | ||
} | ||
}; | ||
return this.query(request) | ||
.then(response => response.result); | ||
} | ||
return this.query(request, options) | ||
.then(response => new ProfileSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
searchRoles (body, options = {}) { | ||
const request = { | ||
body, | ||
action: 'searchRoles' | ||
}; | ||
for (const opt of ['from', 'size']) { | ||
request[opt] = options[opt]; | ||
/** | ||
* Checks if an API action can be executed by a user | ||
* | ||
* @param {String} kuid - User kuid | ||
* @param {Object} requestPayload - Request to check | ||
*/ | ||
checkRights(kuid, requestPayload) { | ||
const request = { | ||
userId: kuid, | ||
body: requestPayload, | ||
action: 'checkRights' | ||
}; | ||
return this.query(request) | ||
.then(response => response.result.allowed); | ||
} | ||
return this.query(request, options) | ||
.then(response => new RoleSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
searchUsers (body, options = {}) { | ||
const request = { | ||
body, | ||
action: 'searchUsers' | ||
}; | ||
for (const opt of ['from', 'size', 'scroll', 'lang']) { | ||
request[opt] = options[opt]; | ||
/** | ||
* Deletes an user API key. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {String} id - API key ID | ||
* @param {Object} [options] - { refresh } | ||
* | ||
* @returns {Promise} | ||
*/ | ||
deleteApiKey(userId, id, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'deleteApiKey', | ||
_id: id, | ||
refresh: options.refresh | ||
}; | ||
return this.query(request); | ||
} | ||
return this.query(request, options) | ||
.then(response => new UserSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
updateCredentials (strategy, _id, body, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
body, | ||
action: 'updateCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateProfile (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile( | ||
this.kuzzle, | ||
response.result._id, | ||
response.result._source)); | ||
} | ||
updateProfileMapping (body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateProfileMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateRole (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
updateRoleMapping (body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateRoleMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateUser (_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
updateUserMapping (body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateUserMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
validateCredentials (strategy, _id, body, options = {}) { | ||
return this.query({ | ||
_id, | ||
strategy, | ||
body, | ||
action: 'validateCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
/** | ||
* Searches for a user API key. | ||
* | ||
* @param {String} userId - User kuid | ||
* @param {Object} [query] - Search query | ||
* @param {Object} [options] - { from, size } | ||
* | ||
* @returns {Promise.<object[]>} - { hits, total } | ||
*/ | ||
searchApiKeys(userId, query = {}, options = {}) { | ||
const request = { | ||
userId, | ||
action: 'searchApiKeys', | ||
from: options.from, | ||
size: options.size, | ||
lang: options.lang, | ||
body: query | ||
}; | ||
return this.query(request) | ||
.then(response => response.result); | ||
} | ||
createCredentials(strategy, _id, body, options = {}) { | ||
return this.query({ | ||
_id, | ||
strategy, | ||
body, | ||
action: 'createCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
createFirstAdmin(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createFirstAdmin', | ||
reset: options.reset | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createOrReplaceProfile(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createOrReplaceProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile_1.Profile(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createOrReplaceRole(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createOrReplaceRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role_1.Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
createProfile(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile_1.Profile(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createRestrictedUser(body, _id = null, options = {}) { | ||
if (!body.content) { | ||
body.content = {}; | ||
} | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createRestrictedUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
createRole(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role_1.Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
createUser(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'createUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
deleteCredentials(strategy, _id, options = {}) { | ||
const request = { | ||
strategy, | ||
_id, | ||
action: 'deleteCredentials' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteProfile(_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteRole(_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteRole' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
deleteUser(_id, options = {}) { | ||
const request = { | ||
_id, | ||
action: 'deleteUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
getAllCredentialFields(options = {}) { | ||
return this.query({ | ||
action: 'getAllCredentialFields' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentialFields(strategy, options = {}) { | ||
return this.query({ | ||
strategy, | ||
action: 'getCredentialFields' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentials(strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'getCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getCredentialsById(strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'getCredentialsById' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getProfile(_id, options = {}) { | ||
return this.query({ _id, action: 'getProfile' }, options) | ||
.then(response => new Profile_1.Profile(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
getProfileMapping(options = {}) { | ||
return this.query({ | ||
action: 'getProfileMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getProfileRights(_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getProfileRights' | ||
}, options) | ||
.then(response => response.result.hits); | ||
} | ||
getRole(_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getRole' | ||
}, options) | ||
.then(response => new Role_1.Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
getRoleMapping(options = {}) { | ||
return this.query({ | ||
action: 'getRoleMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getUser(_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUser' | ||
}, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
getUserMapping(options = {}) { | ||
return this.query({ | ||
action: 'getUserMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
getUserRights(_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUserRights' | ||
}, options) | ||
.then(response => response.result.hits); | ||
} | ||
getUserStrategies(_id, options = {}) { | ||
return this.query({ | ||
_id, | ||
action: 'getUserStrategies' | ||
}, options) | ||
.then(response => response.result.strategies); | ||
} | ||
hasCredentials(strategy, _id, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
action: 'hasCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteProfiles(ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteProfiles', | ||
body: { ids } | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteRoles(ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteRoles', | ||
body: { ids } | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mDeleteUsers(ids, options = {}) { | ||
const request = { | ||
action: 'mDeleteUsers', | ||
body: { ids } | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result); | ||
} | ||
mGetProfiles(ids, options = {}) { | ||
return this.query({ action: 'mGetProfiles', body: { ids } }, options) | ||
.then(response => response.result.hits.map(hit => new Profile_1.Profile(this.kuzzle, hit._id, hit._source))); | ||
} | ||
mGetUsers(ids, options = {}) { | ||
const request = { | ||
action: 'mGetUsers', | ||
body: { ids } | ||
}; | ||
return this.query(request, options) | ||
.then(response => response.result.hits.map(hit => new User_1.User(this.kuzzle, hit._id, hit._source))); | ||
} | ||
mGetRoles(ids, options = {}) { | ||
return this.query({ | ||
action: 'mGetRoles', | ||
body: { ids } | ||
}, options) | ||
.then(response => response.result.hits.map(hit => new Role_1.Role(this.kuzzle, hit._id, hit._source.controllers))); | ||
} | ||
refresh(collection) { | ||
return this.query({ | ||
collection, | ||
action: 'refresh' | ||
}); | ||
} | ||
replaceUser(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'replaceUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
searchProfiles(body, options = {}) { | ||
const request = { | ||
body, | ||
action: 'searchProfiles' | ||
}; | ||
for (const opt of ['from', 'size', 'scroll']) { | ||
request[opt] = options[opt]; | ||
} | ||
return this.query(request, options) | ||
.then(response => new Profile_2.ProfileSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
searchRoles(body, options = {}) { | ||
const request = { | ||
body, | ||
action: 'searchRoles' | ||
}; | ||
for (const opt of ['from', 'size']) { | ||
request[opt] = options[opt]; | ||
} | ||
return this.query(request, options) | ||
.then(response => new Role_2.RoleSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
searchUsers(body, options = {}) { | ||
const request = { | ||
body, | ||
action: 'searchUsers' | ||
}; | ||
for (const opt of ['from', 'size', 'scroll', 'lang']) { | ||
request[opt] = options[opt]; | ||
} | ||
return this.query(request, options) | ||
.then(response => new User_2.UserSearchResult(this.kuzzle, request, options, response.result)); | ||
} | ||
updateCredentials(strategy, _id, body, options = {}) { | ||
return this.query({ | ||
strategy, | ||
_id, | ||
body, | ||
action: 'updateCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateProfile(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateProfile' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Profile_1.Profile(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
updateProfileMapping(body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateProfileMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateRole(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateRole', | ||
force: options.force ? true : null | ||
}; | ||
return this.query(request, options) | ||
.then(response => new Role_1.Role(this.kuzzle, response.result._id, response.result._source.controllers)); | ||
} | ||
updateRoleMapping(body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateRoleMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
updateUser(_id, body, options = {}) { | ||
const request = { | ||
_id, | ||
body, | ||
action: 'updateUser' | ||
}; | ||
return this.query(request, options) | ||
.then(response => new User_1.User(this.kuzzle, response.result._id, response.result._source)); | ||
} | ||
updateUserMapping(body, options = {}) { | ||
return this.query({ | ||
body, | ||
action: 'updateUserMapping' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
validateCredentials(strategy, _id, body, options = {}) { | ||
return this.query({ | ||
_id, | ||
strategy, | ||
body, | ||
action: 'validateCredentials' | ||
}, options) | ||
.then(response => response.result); | ||
} | ||
} | ||
module.exports = { SecurityController }; | ||
exports.SecurityController = SecurityController; | ||
//# sourceMappingURL=Security.js.map |
@@ -8,2 +8,3 @@ import { KuzzleEventEmitter } from './core/KuzzleEventEmitter'; | ||
import { RealtimeController } from './controllers/Realtime'; | ||
import { SecurityController } from './controllers/Security'; | ||
import { Deprecation } from './utils/Deprecation'; | ||
@@ -55,3 +56,3 @@ import { JSONObject } from './types'; | ||
realtime: RealtimeController; | ||
security: any; | ||
security: SecurityController; | ||
server: any; | ||
@@ -58,0 +59,0 @@ private _protectedEvents; |
@@ -197,3 +197,3 @@ "use strict"; | ||
}); | ||
return proxify_1.proxify(this, { | ||
return (0, proxify_1.proxify)(this, { | ||
seal: true, | ||
@@ -406,2 +406,5 @@ name: 'kuzzle', | ||
if (!this.authenticator) { | ||
this.emit('reconnectionError', { | ||
error: new Error('Could not re-authenticate: "authenticator" property is not set.') | ||
}); | ||
return false; | ||
@@ -492,3 +495,3 @@ } | ||
if (!request.requestId) { | ||
request.requestId = uuidv4_1.uuidv4(); | ||
request.requestId = (0, uuidv4_1.uuidv4)(); | ||
} | ||
@@ -495,0 +498,0 @@ if (request.refresh === undefined && options.refresh !== undefined) { |
@@ -31,3 +31,3 @@ 'use strict'; | ||
} | ||
this.id = uuidv4_1.uuidv4(); | ||
this.id = (0, uuidv4_1.uuidv4)(); | ||
this.state = 'offline'; | ||
@@ -34,0 +34,0 @@ this._cookieSupport = false; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
452186
29
97
10612