UNPKG

sendit-sdk

Version:

Sendit sdk for integrating to sendit system

45 lines (33 loc) 2.06 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SenditOauth2Client = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _config = require('./config'); var _type = require('./type'); var _url = require('url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var SenditOauth2Client = exports.SenditOauth2Client = function () { function SenditOauth2Client(clientId, redirectUri) { _classCallCheck(this, SenditOauth2Client); this.clientId = clientId; this.redirectUri = redirectUri; } _createClass(SenditOauth2Client, [{ key: 'generateLoginUrl', value: function generateLoginUrl(type, scopeArray) { var scopes = typeof scopeArray === 'string' ? scopeArray : scopeArray.join(','); if (type !== _type.responseType.IMPLICIT && type !== _type.responseType.CODE) { throw new Error('Could not use this function with provided grant type'); } return _url2.default.resolve(_config.config.authorizeUri, 'oauth/authorize') + ('?response_type=' + type + '&client_id=' + this.clientId + '&redirect_uri=' + this.redirectUri + '&scope=' + scopes); } }, { key: 'generateLoginButton', value: function generateLoginButton(type, scopeArray) {} }]); return SenditOauth2Client; }();