UNPKG

backendless-console-sdk

Version:

Backendless Console SDK for Node.js and browser

247 lines (239 loc) 10.7 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _urls = require("./urls"); var _baseService = _interopRequireDefault(require("./base/base-service")); function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable max-len */ var Users = /*#__PURE__*/function (_BaseService) { (0, _inherits2["default"])(Users, _BaseService); var _super = _createSuper(Users); function Users(req) { var _this; (0, _classCallCheck2["default"])(this, Users); _this = _super.call(this, req); _this.serviceName = 'users'; return _this; } /** * @aiToolName Get Users Regs * @category Users * @description Get user registration settings * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @sampleResult {"enabled":true,"emailConfirmation":true,"roles":["default"]} */ (0, _createClass2["default"])(Users, [{ key: "getUsersRegs", value: function getUsersRegs(appId) { return this.req.get("".concat((0, _urls.appConsole)(appId), "/userregistration")); } }, { key: "updateUsersRegs", value: function updateUsersRegs(appId, data) { return this.req.put("".concat((0, _urls.appConsole)(appId), "/userregistration"), data); } /** * @aiToolName Get Users Login * @category Users * @description Get user login settings * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @sampleResult {"sessionTimeout":3600,"maxFailedAttempts":5,"lockoutDuration":300} */ }, { key: "getUsersLogin", value: function getUsersLogin(appId) { return this.req.get("".concat((0, _urls.appConsole)(appId), "/userlogin")); } /** * @aiToolName Logout All Users * @category Users * @description Logout all users from the application * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @sampleResult {"loggedOut":150,"success":true} */ }, { key: "logoutAllUsers", value: function logoutAllUsers(appId) { return this.req.post("".concat((0, _urls.appConsole)(appId), "/userlogin/logout/all")); } /** * @aiToolName Get User Social Login * @category Users * @description Get social login URL for a provider * @paramDef {"type":"string","name":"provider","label":"Provider","description":"The social provider name","required":true} * @sampleResult {"url":"https://accounts.google.com/oauth/authorize?..."} */ }, { key: "getUserSocialLogin", value: function getUserSocialLogin(provider) { return this.req.get("/console/social/oauth/".concat(provider, "/request_url")); } }, { key: "updateUsersLogin", value: function updateUsersLogin(appId, data) { return this.req.post("".concat((0, _urls.appConsole)(appId), "/userlogin"), data); } }, { key: "getUsersProps", value: function getUsersProps(appId) { return this.req.get("".concat((0, _urls.appConsole)(appId), "/userproperties")); } }, { key: "updateUsersProps", value: function updateUsersProps(appId, data) { return this.req.put("".concat((0, _urls.appConsole)(appId), "/userproperties/").concat(data.name), data); } }, { key: "updateSocialParams", value: function updateSocialParams(appId, param) { return this.req.post("".concat((0, _urls.appConsole)(appId), "/socialparams"), param); } }, { key: "getOAuth1ProviderTemplates", value: function getOAuth1ProviderTemplates(appId) { return this.req.get("".concat((0, _urls.users)(appId), "/oauth1-templates")); } }, { key: "getOAuth2ProviderTemplates", value: function getOAuth2ProviderTemplates(appId) { return this.req.get("".concat((0, _urls.users)(appId), "/oauth2-templates")); } /** * @aiToolName Get OAuth1 Providers * @category Users * @description Get all OAuth1 providers * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @sampleResult [{"id":"provider1","name":"Twitter","enabled":true}] */ }, { key: "getOAuth1Providers", value: function getOAuth1Providers(appId) { return this.req.get("".concat((0, _urls.oauth1)(appId))); } /** * @aiToolName Get OAuth2 Providers * @category Users * @description Get all OAuth2 providers * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @sampleResult [{"id":"provider2","name":"Google","enabled":true}] */ }, { key: "getOAuth2Providers", value: function getOAuth2Providers(appId) { return this.req.get("".concat((0, _urls.oauth2)(appId))); } /** * @aiToolName Get OAuth1 Provider * @category Users * @description Get a specific OAuth1 provider * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @paramDef {"type":"string","name":"providerId","label":"Provider ID","description":"The identifier of the OAuth1 provider","required":true} * @sampleResult {"id":"provider1","name":"Twitter","consumerKey":"key123","enabled":true} */ }, { key: "getOAuth1Provider", value: function getOAuth1Provider(appId, providerId) { return this.req.get("".concat((0, _urls.oauth1)(appId), "/").concat(providerId)); } /** * @aiToolName Get OAuth2 Provider * @category Users * @description Get a specific OAuth2 provider * @paramDef {"type":"string","name":"appId","label":"Application ID","description":"The identifier of the application","required":true} * @paramDef {"type":"string","name":"providerId","label":"Provider ID","description":"The identifier of the OAuth2 provider","required":true} * @sampleResult {"id":"provider2","name":"Google","clientId":"client123","enabled":true} */ }, { key: "getOAuth2Provider", value: function getOAuth2Provider(appId, providerId) { return this.req.get("".concat((0, _urls.oauth2)(appId), "/").concat(providerId)); } }, { key: "createOAuth2Provider", value: function createOAuth2Provider(appId, provider) { return this.req.post("".concat((0, _urls.oauth2)(appId)), provider); } }, { key: "updateOAuth1Provider", value: function updateOAuth1Provider(appId, provider) { return this.req.put("".concat((0, _urls.oauth1)(appId), "/").concat(provider.id), provider); } }, { key: "updateOAuth2Provider", value: function updateOAuth2Provider(appId, provider) { return this.req.put("".concat((0, _urls.oauth2)(appId), "/").concat(provider.id), provider); } }, { key: "createOAuth1ProviderFromTemplate", value: function createOAuth1ProviderFromTemplate(appId, data) { return this.req.post("".concat((0, _urls.oauth1)(appId), "/create-from-template"), data); } }, { key: "createOAuth2ProviderFromTemplate", value: function createOAuth2ProviderFromTemplate(appId, data) { return this.req.post("".concat((0, _urls.oauth2)(appId), "/create-from-template"), data); } }, { key: "removeOAuth1Provider", value: function removeOAuth1Provider(appId, providerId) { return this.req["delete"]("".concat((0, _urls.oauth1)(appId), "/").concat(providerId)); } }, { key: "removeOAuth2Provider", value: function removeOAuth2Provider(appId, providerId) { return this.req["delete"]("".concat((0, _urls.oauth2)(appId), "/").concat(providerId)); } }, { key: "getOAuth1CallbackUrls", value: function getOAuth1CallbackUrls(appId, providerCode) { return this.req.get("".concat((0, _urls.oauth1)(appId), "/").concat(providerCode, "/callback-url")); } }, { key: "getOAuth2CallbackUrls", value: function getOAuth2CallbackUrls(appId, providerCode) { return this.req.get("".concat((0, _urls.oauth2)(appId), "/").concat(providerCode, "/callback-url")); } }, { key: "getAuth0Configuration", value: function getAuth0Configuration(appId) { return this.req.get("".concat((0, _urls.oauth0Config)(appId))); } }, { key: "updateAuth0Configuration", value: function updateAuth0Configuration(appId, config) { return this.req.put("".concat((0, _urls.oauth0Config)(appId)), config); } }, { key: "createAuth0ScopeBinding", value: function createAuth0ScopeBinding(appId, binding) { return this.req.post("".concat((0, _urls.oauth0Binding)(appId)), binding); } }, { key: "updateAuth0ScopeBinding", value: function updateAuth0ScopeBinding(appId, binding) { return this.req.put("".concat((0, _urls.oauth0Binding)(appId), "/").concat(binding.id), binding); } }, { key: "getAuth0ScopeBindings", value: function getAuth0ScopeBindings(appId) { return this.req.get("".concat((0, _urls.oauth0Binding)(appId))); } }, { key: "deleteAuth0ScopeBinding", value: function deleteAuth0ScopeBinding(appId, bindingId) { return this.req["delete"]("".concat((0, _urls.oauth0Binding)(appId), "/").concat(bindingId)); } }]); return Users; }(_baseService["default"]); var _default = exports["default"] = function _default(req) { return Users.create(req); };