From b4afee46835e211e44193a0c9363b811d14526dc Mon Sep 17 00:00:00 2001 From: SuzuyaBish Date: Tue, 2 Apr 2024 13:36:55 +0200 Subject: [PATCH] chore: Bump expo constants version to latest Expo constants bumped to latest to upgrade expo config version due to eas android build failure --- dist/ApiClient.js | 2 +- dist/SDK/Enums/TokenType.enum.js | 2 +- dist/SDK/KindeSDK.js | 2 +- dist/SDK/OAuth/AuthorizationCode.js | 2 +- dist/SDK/Storage/Base.js | 2 +- dist/SDK/Storage/ExpoStorage.js | 2 +- dist/SDK/Storage/RNStorage.js | 2 +- dist/SDK/Storage/index.js | 2 +- dist/SDK/Utils.js | 2 +- dist/SDK/constants/index.js | 2 +- dist/common/exceptions/invalid-type.exception.js | 2 +- .../exceptions/property-required.exception.js | 2 +- .../exceptions/unauthenticated.exception.js | 2 +- dist/common/exceptions/unexpected.exception.js | 2 +- dist/index.js | 2 +- package.json | 15 ++++++++------- 16 files changed, 23 insertions(+), 22 deletions(-) diff --git a/dist/ApiClient.js b/dist/ApiClient.js index b37dff3..76547b4 100644 --- a/dist/ApiClient.js +++ b/dist/ApiClient.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ResponseError=exports.RequiredError=exports.JSONApiResponse=exports.FetchError=exports.DefaultConfig=exports.Configuration=exports.COLLECTION_FORMATS=exports.BaseAPI=exports.BASE_PATH=void 0;exports.canConsumeForm=canConsumeForm;exports.exists=exists;exports.querystring=querystring;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _Storage=_interopRequireDefault(require("./SDK/Storage"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0&&arguments[0]!==undefined?arguments[0]:{};(0,_classCallCheck2["default"])(this,Configuration);this.configuration=configuration;}(0,_createClass2["default"])(Configuration,[{key:"config",set:function set(configuration){this.configuration=configuration;}},{key:"basePath",get:function get(){return this.configuration.basePath!=null?this.configuration.basePath:BASE_PATH;}},{key:"fetchApi",get:function get(){return this.configuration.fetchApi;}},{key:"middleware",get:function get(){return this.configuration.middleware||[];}},{key:"queryParamsStringify",get:function get(){return this.configuration.queryParamsStringify||querystring;}},{key:"username",get:function get(){return this.configuration.username;}},{key:"password",get:function get(){return this.configuration.password;}},{key:"apiKey",get:function get(){var apiKey=this.configuration.apiKey;if(apiKey){return typeof apiKey==='function'?apiKey:function(){return apiKey;};}return undefined;}},{key:"accessToken",get:function get(){var accessToken=this.configuration.accessToken;if(accessToken){return typeof accessToken==='function'?accessToken:(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",accessToken);case 1:case"end":return _context.stop();}},_callee);}));}return undefined;}},{key:"headers",get:function get(){return this.configuration.headers;}},{key:"credentials",get:function get(){return this.configuration.credentials;}}]);return Configuration;}();exports.Configuration=Configuration;var DefaultConfig=new Configuration();exports.DefaultConfig=DefaultConfig;var BaseAPI=function(_request,_createFetchParams){function BaseAPI(){var _this=this,_ref2,_configuration$middle;var configuration=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DefaultConfig;(0,_classCallCheck2["default"])(this,BaseAPI);this.configuration=configuration;(0,_defineProperty2["default"])(this,"middleware",void 0);(0,_defineProperty2["default"])(this,"fetchApi",function(_x,_x2){return(_ref2=_ref2||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(url,init){var fetchParams,_iterator,_step,_middleware2,response,_iterator2,_step2,middleware,_iterator3,_step3,_middleware;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:fetchParams={url:url,init:init};_iterator=_createForOfIteratorHelper(_this.middleware);_context2.prev=2;_iterator.s();case 4:if((_step=_iterator.n()).done){_context2.next=15;break;}_middleware2=_step.value;if(!_middleware2.pre){_context2.next=13;break;}_context2.next=9;return _middleware2.pre(Object.assign({fetch:_this.fetchApi},fetchParams));case 9:_context2.t0=_context2.sent;if(_context2.t0){_context2.next=12;break;}_context2.t0=fetchParams;case 12:fetchParams=_context2.t0;case 13:_context2.next=4;break;case 15:_context2.next=20;break;case 17:_context2.prev=17;_context2.t1=_context2["catch"](2);_iterator.e(_context2.t1);case 20:_context2.prev=20;_iterator.f();return _context2.finish(20);case 23:response=undefined;_context2.prev=24;_context2.next=27;return(_this.configuration.fetchApi||fetch)(fetchParams.url,fetchParams.init);case 27:response=_context2.sent;_context2.next=56;break;case 30:_context2.prev=30;_context2.t2=_context2["catch"](24);_iterator2=_createForOfIteratorHelper(_this.middleware);_context2.prev=33;_iterator2.s();case 35:if((_step2=_iterator2.n()).done){_context2.next=46;break;}middleware=_step2.value;if(!middleware.onError){_context2.next=44;break;}_context2.next=40;return middleware.onError({fetch:_this.fetchApi,url:fetchParams.url,init:fetchParams.init,error:_context2.t2,response:response?response.clone():undefined});case 40:_context2.t3=_context2.sent;if(_context2.t3){_context2.next=43;break;}_context2.t3=response;case 43:response=_context2.t3;case 44:_context2.next=35;break;case 46:_context2.next=51;break;case 48:_context2.prev=48;_context2.t4=_context2["catch"](33);_iterator2.e(_context2.t4);case 51:_context2.prev=51;_iterator2.f();return _context2.finish(51);case 54:if(!(response===undefined)){_context2.next=56;break;}throw new FetchError(_context2.t2,'The request failed and the interceptors did not return an alternative response');case 56:_iterator3=_createForOfIteratorHelper(_this.middleware);_context2.prev=57;_iterator3.s();case 59:if((_step3=_iterator3.n()).done){_context2.next=70;break;}_middleware=_step3.value;if(!_middleware.post){_context2.next=68;break;}_context2.next=64;return _middleware.post({fetch:_this.fetchApi,url:fetchParams.url,init:fetchParams.init,response:response.clone()});case 64:_context2.t5=_context2.sent;if(_context2.t5){_context2.next=67;break;}_context2.t5=response;case 67:response=_context2.t5;case 68:_context2.next=59;break;case 70:_context2.next=75;break;case 72:_context2.prev=72;_context2.t6=_context2["catch"](57);_iterator3.e(_context2.t6);case 75:_context2.prev=75;_iterator3.f();return _context2.finish(75);case 78:return _context2.abrupt("return",response);case 79:case"end":return _context2.stop();}},_callee2,null,[[2,17,20,23],[24,30],[33,48,51,54],[57,72,75,78]]);}))).apply(this,arguments);});this.middleware=(_configuration$middle=configuration.middleware)!==null&&_configuration$middle!==void 0?_configuration$middle:[];}(0,_createClass2["default"])(BaseAPI,[{key:"withMiddleware",value:function withMiddleware(){var _next$middleware;var next=this.clone();next.middleware=(_next$middleware=next.middleware).concat.apply(_next$middleware,arguments);return next;}},{key:"withPreMiddleware",value:function withPreMiddleware(){for(var _len=arguments.length,preMiddlewares=new Array(_len),_key=0;_key<_len;_key++){preMiddlewares[_key]=arguments[_key];}var middlewares=preMiddlewares.map(function(pre){return{pre:pre};});return this.withMiddleware.apply(this,(0,_toConsumableArray2["default"])(middlewares));}},{key:"withPostMiddleware",value:function withPostMiddleware(){for(var _len2=arguments.length,postMiddlewares=new Array(_len2),_key2=0;_key2<_len2;_key2++){postMiddlewares[_key2]=arguments[_key2];}var middlewares=postMiddlewares.map(function(post){return{post:post};});return this.withMiddleware.apply(this,(0,_toConsumableArray2["default"])(middlewares));}},{key:"request",value:function request(_x3,_x4){return(_request=_request||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(context,initOverrides){var _yield$this$createFet,url,init,accessToken,response;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this.createFetchParams(context,initOverrides);case 2:_yield$this$createFet=_context3.sent;url=_yield$this$createFet.url;init=_yield$this$createFet.init;_context3.next=7;return _Storage["default"].getAccessToken();case 7:accessToken=_context3.sent;_context3.next=10;return this.fetchApi(url,Object.assign({},init,{headers:{Authorization:accessToken?"Bearer "+accessToken:''}}));case 10:response=_context3.sent;if(!(response.status>=200&&response.status<300)){_context3.next=13;break;}return _context3.abrupt("return",response);case 13:throw new ResponseError(response,'Response returned an error code');case 14:case"end":return _context3.stop();}},_callee3,this);}))).apply(this,arguments);}},{key:"createFetchParams",value:function createFetchParams(_x5,_x6){return(_createFetchParams=_createFetchParams||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(context,initOverrides){var url,headers,initOverrideFn,initParams,overridedInit,init;return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:url=this.configuration.basePath+context.path;if(context.query!==undefined&&Object.keys(context.query).length!==0){url+='?'+this.configuration.queryParamsStringify(context.query);}headers=Object.assign({},this.configuration.headers,context.headers);Object.keys(headers).forEach(function(key){return headers[key]===undefined?delete headers[key]:{};});initOverrideFn=typeof initOverrides==='function'?initOverrides:(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:return _context4.abrupt("return",initOverrides);case 1:case"end":return _context4.stop();}},_callee4);}));initParams={method:context.method,headers:headers,body:context.body,credentials:this.configuration.credentials};_context5.t0=Object;_context5.t1={};_context5.t2=initParams;_context5.next=11;return initOverrideFn({init:initParams,context:context});case 11:_context5.t3=_context5.sent;overridedInit=_context5.t0.assign.call(_context5.t0,_context5.t1,_context5.t2,_context5.t3);init=Object.assign({},overridedInit,{body:isFormData(overridedInit.body)||overridedInit.body instanceof URLSearchParams||isBlob(overridedInit.body)?overridedInit.body:JSON.stringify(overridedInit.body)});return _context5.abrupt("return",{url:url,init:init});case 15:case"end":return _context5.stop();}},_callee5,this);}))).apply(this,arguments);}},{key:"clone",value:function clone(){var constructor=this.constructor;var next=new constructor(this.configuration);next.middleware=Array.isArray(this.middleware)?this.middleware.slice():[];return next;}}]);return BaseAPI;}();exports.BaseAPI=BaseAPI;function isBlob(value){return typeof Blob!=='undefined'&&value instanceof Blob;}function isFormData(value){return typeof FormData!=='undefined'&&value instanceof FormData;}var ResponseError=function(_Error){(0,_inherits2["default"])(ResponseError,_Error);var _super=_createSuper(ResponseError);function ResponseError(response,msg){var _this2;(0,_classCallCheck2["default"])(this,ResponseError);_this2=_super.call(this,msg);_this2.response=response;(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this2),"name",'ResponseError');return _this2;}return(0,_createClass2["default"])(ResponseError);}((0,_wrapNativeSuper2["default"])(Error));exports.ResponseError=ResponseError;var FetchError=function(_Error2){(0,_inherits2["default"])(FetchError,_Error2);var _super2=_createSuper(FetchError);function FetchError(cause,msg){var _this3;(0,_classCallCheck2["default"])(this,FetchError);_this3=_super2.call(this,msg);_this3.cause=cause;(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this3),"name",'FetchError');return _this3;}return(0,_createClass2["default"])(FetchError);}((0,_wrapNativeSuper2["default"])(Error));exports.FetchError=FetchError;var RequiredError=function(_Error3){(0,_inherits2["default"])(RequiredError,_Error3);var _super3=_createSuper(RequiredError);function RequiredError(field,msg){var _this4;(0,_classCallCheck2["default"])(this,RequiredError);_this4=_super3.call(this,msg);_this4.field=field;(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this4),"name",'RequiredError');return _this4;}return(0,_createClass2["default"])(RequiredError);}((0,_wrapNativeSuper2["default"])(Error));exports.RequiredError=RequiredError;var COLLECTION_FORMATS={csv:',',ssv:' ',tsv:'\t',pipes:'|'};exports.COLLECTION_FORMATS=COLLECTION_FORMATS;function exists(json,key){var value=json[key];return value!==null&&value!==undefined;}function querystring(params){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';return Object.keys(params).map(function(key){return querystringSingleKey(key,params[key],prefix);}).filter(function(part){return part.length>0;}).join('&');}function querystringSingleKey(key,value){var keyPrefix=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';var fullKey=keyPrefix+(keyPrefix.length?"["+key+"]":key);if(value instanceof Array){var multiValue=value.map(function(singleValue){return encodeURIComponent(String(singleValue));}).join("&"+encodeURIComponent(fullKey)+"=");return encodeURIComponent(fullKey)+"="+multiValue;}if(value instanceof Set){var valueAsArray=Array.from(value);return querystringSingleKey(key,valueAsArray,keyPrefix);}if(value instanceof Date){return encodeURIComponent(fullKey)+"="+encodeURIComponent(value.toISOString());}if(value instanceof Object){return querystring(value,fullKey);}return encodeURIComponent(fullKey)+"="+encodeURIComponent(String(value));}function canConsumeForm(consumes){var _iterator4=_createForOfIteratorHelper(consumes),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var consume=_step4.value;if('multipart/form-data'===consume.contentType){return true;}}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}return false;}var JSONApiResponse=function(_value){function JSONApiResponse(raw){var transformer=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(jsonValue){return jsonValue;};(0,_classCallCheck2["default"])(this,JSONApiResponse);this.raw=raw;this.transformer=transformer;}(0,_createClass2["default"])(JSONApiResponse,[{key:"value",value:function value(){return(_value=_value||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.t0=this;_context6.next=3;return this.raw.json();case 3:_context6.t1=_context6.sent;return _context6.abrupt("return",_context6.t0.transformer.call(_context6.t0,_context6.t1));case 5:case"end":return _context6.stop();}},_callee6,this);}))).apply(this,arguments);}}]);return JSONApiResponse;}();exports.JSONApiResponse=JSONApiResponse; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ResponseError=exports.RequiredError=exports.JSONApiResponse=exports.FetchError=exports.DefaultConfig=exports.Configuration=exports.COLLECTION_FORMATS=exports.BaseAPI=exports.BASE_PATH=void 0;exports.canConsumeForm=canConsumeForm;exports.exists=exists;exports.querystring=querystring;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _Storage=_interopRequireDefault(require("./SDK/Storage"));function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0&&arguments[0]!==undefined?arguments[0]:{};(0,_classCallCheck2["default"])(this,Configuration);this.configuration=configuration;}return(0,_createClass2["default"])(Configuration,[{key:"config",set:function set(configuration){this.configuration=configuration;}},{key:"basePath",get:function get(){return this.configuration.basePath!=null?this.configuration.basePath:BASE_PATH;}},{key:"fetchApi",get:function get(){return this.configuration.fetchApi;}},{key:"middleware",get:function get(){return this.configuration.middleware||[];}},{key:"queryParamsStringify",get:function get(){return this.configuration.queryParamsStringify||querystring;}},{key:"username",get:function get(){return this.configuration.username;}},{key:"password",get:function get(){return this.configuration.password;}},{key:"apiKey",get:function get(){var apiKey=this.configuration.apiKey;if(apiKey){return typeof apiKey==='function'?apiKey:function(){return apiKey;};}return undefined;}},{key:"accessToken",get:function get(){var accessToken=this.configuration.accessToken;if(accessToken){return typeof accessToken==='function'?accessToken:(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",accessToken);case 1:case"end":return _context.stop();}},_callee);}));}return undefined;}},{key:"headers",get:function get(){return this.configuration.headers;}},{key:"credentials",get:function get(){return this.configuration.credentials;}}]);}();var DefaultConfig=exports.DefaultConfig=new Configuration();var BaseAPI=exports.BaseAPI=function(){function BaseAPI(){var _this=this,_configuration$middle;var configuration=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DefaultConfig;(0,_classCallCheck2["default"])(this,BaseAPI);this.configuration=configuration;(0,_defineProperty2["default"])(this,"middleware",void 0);(0,_defineProperty2["default"])(this,"fetchApi",function(){var _ref2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(url,init){var fetchParams,_iterator,_step,_middleware2,response,_iterator2,_step2,middleware,_iterator3,_step3,_middleware;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:fetchParams={url:url,init:init};_iterator=_createForOfIteratorHelper(_this.middleware);_context2.prev=2;_iterator.s();case 4:if((_step=_iterator.n()).done){_context2.next=15;break;}_middleware2=_step.value;if(!_middleware2.pre){_context2.next=13;break;}_context2.next=9;return _middleware2.pre(Object.assign({fetch:_this.fetchApi},fetchParams));case 9:_context2.t0=_context2.sent;if(_context2.t0){_context2.next=12;break;}_context2.t0=fetchParams;case 12:fetchParams=_context2.t0;case 13:_context2.next=4;break;case 15:_context2.next=20;break;case 17:_context2.prev=17;_context2.t1=_context2["catch"](2);_iterator.e(_context2.t1);case 20:_context2.prev=20;_iterator.f();return _context2.finish(20);case 23:response=undefined;_context2.prev=24;_context2.next=27;return(_this.configuration.fetchApi||fetch)(fetchParams.url,fetchParams.init);case 27:response=_context2.sent;_context2.next=56;break;case 30:_context2.prev=30;_context2.t2=_context2["catch"](24);_iterator2=_createForOfIteratorHelper(_this.middleware);_context2.prev=33;_iterator2.s();case 35:if((_step2=_iterator2.n()).done){_context2.next=46;break;}middleware=_step2.value;if(!middleware.onError){_context2.next=44;break;}_context2.next=40;return middleware.onError({fetch:_this.fetchApi,url:fetchParams.url,init:fetchParams.init,error:_context2.t2,response:response?response.clone():undefined});case 40:_context2.t3=_context2.sent;if(_context2.t3){_context2.next=43;break;}_context2.t3=response;case 43:response=_context2.t3;case 44:_context2.next=35;break;case 46:_context2.next=51;break;case 48:_context2.prev=48;_context2.t4=_context2["catch"](33);_iterator2.e(_context2.t4);case 51:_context2.prev=51;_iterator2.f();return _context2.finish(51);case 54:if(!(response===undefined)){_context2.next=56;break;}throw new FetchError(_context2.t2,'The request failed and the interceptors did not return an alternative response');case 56:_iterator3=_createForOfIteratorHelper(_this.middleware);_context2.prev=57;_iterator3.s();case 59:if((_step3=_iterator3.n()).done){_context2.next=70;break;}_middleware=_step3.value;if(!_middleware.post){_context2.next=68;break;}_context2.next=64;return _middleware.post({fetch:_this.fetchApi,url:fetchParams.url,init:fetchParams.init,response:response.clone()});case 64:_context2.t5=_context2.sent;if(_context2.t5){_context2.next=67;break;}_context2.t5=response;case 67:response=_context2.t5;case 68:_context2.next=59;break;case 70:_context2.next=75;break;case 72:_context2.prev=72;_context2.t6=_context2["catch"](57);_iterator3.e(_context2.t6);case 75:_context2.prev=75;_iterator3.f();return _context2.finish(75);case 78:return _context2.abrupt("return",response);case 79:case"end":return _context2.stop();}},_callee2,null,[[2,17,20,23],[24,30],[33,48,51,54],[57,72,75,78]]);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());this.middleware=(_configuration$middle=configuration.middleware)!==null&&_configuration$middle!==void 0?_configuration$middle:[];}return(0,_createClass2["default"])(BaseAPI,[{key:"withMiddleware",value:function withMiddleware(){var _next$middleware;var next=this.clone();next.middleware=(_next$middleware=next.middleware).concat.apply(_next$middleware,arguments);return next;}},{key:"withPreMiddleware",value:function withPreMiddleware(){for(var _len=arguments.length,preMiddlewares=new Array(_len),_key=0;_key<_len;_key++){preMiddlewares[_key]=arguments[_key];}var middlewares=preMiddlewares.map(function(pre){return{pre:pre};});return this.withMiddleware.apply(this,(0,_toConsumableArray2["default"])(middlewares));}},{key:"withPostMiddleware",value:function withPostMiddleware(){for(var _len2=arguments.length,postMiddlewares=new Array(_len2),_key2=0;_key2<_len2;_key2++){postMiddlewares[_key2]=arguments[_key2];}var middlewares=postMiddlewares.map(function(post){return{post:post};});return this.withMiddleware.apply(this,(0,_toConsumableArray2["default"])(middlewares));}},{key:"request",value:function(){var _request=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(context,initOverrides){var _yield$this$createFet,url,init,accessToken,response;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this.createFetchParams(context,initOverrides);case 2:_yield$this$createFet=_context3.sent;url=_yield$this$createFet.url;init=_yield$this$createFet.init;_context3.next=7;return _Storage["default"].getAccessToken();case 7:accessToken=_context3.sent;_context3.next=10;return this.fetchApi(url,Object.assign({},init,{headers:{Authorization:accessToken?"Bearer "+accessToken:''}}));case 10:response=_context3.sent;if(!(response.status>=200&&response.status<300)){_context3.next=13;break;}return _context3.abrupt("return",response);case 13:throw new ResponseError(response,'Response returned an error code');case 14:case"end":return _context3.stop();}},_callee3,this);}));function request(_x3,_x4){return _request.apply(this,arguments);}return request;}()},{key:"createFetchParams",value:function(){var _createFetchParams=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(context,initOverrides){var url,headers,initOverrideFn,initParams,overridedInit,init;return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:url=this.configuration.basePath+context.path;if(context.query!==undefined&&Object.keys(context.query).length!==0){url+='?'+this.configuration.queryParamsStringify(context.query);}headers=Object.assign({},this.configuration.headers,context.headers);Object.keys(headers).forEach(function(key){return headers[key]===undefined?delete headers[key]:{};});initOverrideFn=typeof initOverrides==='function'?initOverrides:(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:return _context4.abrupt("return",initOverrides);case 1:case"end":return _context4.stop();}},_callee4);}));initParams={method:context.method,headers:headers,body:context.body,credentials:this.configuration.credentials};_context5.t0=Object;_context5.t1={};_context5.t2=initParams;_context5.next=11;return initOverrideFn({init:initParams,context:context});case 11:_context5.t3=_context5.sent;overridedInit=_context5.t0.assign.call(_context5.t0,_context5.t1,_context5.t2,_context5.t3);init=Object.assign({},overridedInit,{body:isFormData(overridedInit.body)||overridedInit.body instanceof URLSearchParams||isBlob(overridedInit.body)?overridedInit.body:JSON.stringify(overridedInit.body)});return _context5.abrupt("return",{url:url,init:init});case 15:case"end":return _context5.stop();}},_callee5,this);}));function createFetchParams(_x5,_x6){return _createFetchParams.apply(this,arguments);}return createFetchParams;}()},{key:"clone",value:function clone(){var constructor=this.constructor;var next=new constructor(this.configuration);next.middleware=Array.isArray(this.middleware)?this.middleware.slice():[];return next;}}]);}();function isBlob(value){return typeof Blob!=='undefined'&&value instanceof Blob;}function isFormData(value){return typeof FormData!=='undefined'&&value instanceof FormData;}var ResponseError=exports.ResponseError=function(_Error){function ResponseError(response,msg){var _this2;(0,_classCallCheck2["default"])(this,ResponseError);_this2=_callSuper(this,ResponseError,[msg]);_this2.response=response;(0,_defineProperty2["default"])(_this2,"name",'ResponseError');return _this2;}(0,_inherits2["default"])(ResponseError,_Error);return(0,_createClass2["default"])(ResponseError);}((0,_wrapNativeSuper2["default"])(Error));var FetchError=exports.FetchError=function(_Error2){function FetchError(cause,msg){var _this3;(0,_classCallCheck2["default"])(this,FetchError);_this3=_callSuper(this,FetchError,[msg]);_this3.cause=cause;(0,_defineProperty2["default"])(_this3,"name",'FetchError');return _this3;}(0,_inherits2["default"])(FetchError,_Error2);return(0,_createClass2["default"])(FetchError);}((0,_wrapNativeSuper2["default"])(Error));var RequiredError=exports.RequiredError=function(_Error3){function RequiredError(field,msg){var _this4;(0,_classCallCheck2["default"])(this,RequiredError);_this4=_callSuper(this,RequiredError,[msg]);_this4.field=field;(0,_defineProperty2["default"])(_this4,"name",'RequiredError');return _this4;}(0,_inherits2["default"])(RequiredError,_Error3);return(0,_createClass2["default"])(RequiredError);}((0,_wrapNativeSuper2["default"])(Error));var COLLECTION_FORMATS=exports.COLLECTION_FORMATS={csv:',',ssv:' ',tsv:'\t',pipes:'|'};function exists(json,key){var value=json[key];return value!==null&&value!==undefined;}function querystring(params){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';return Object.keys(params).map(function(key){return querystringSingleKey(key,params[key],prefix);}).filter(function(part){return part.length>0;}).join('&');}function querystringSingleKey(key,value){var keyPrefix=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';var fullKey=keyPrefix+(keyPrefix.length?"["+key+"]":key);if(value instanceof Array){var multiValue=value.map(function(singleValue){return encodeURIComponent(String(singleValue));}).join("&"+encodeURIComponent(fullKey)+"=");return encodeURIComponent(fullKey)+"="+multiValue;}if(value instanceof Set){var valueAsArray=Array.from(value);return querystringSingleKey(key,valueAsArray,keyPrefix);}if(value instanceof Date){return encodeURIComponent(fullKey)+"="+encodeURIComponent(value.toISOString());}if(value instanceof Object){return querystring(value,fullKey);}return encodeURIComponent(fullKey)+"="+encodeURIComponent(String(value));}function canConsumeForm(consumes){var _iterator4=_createForOfIteratorHelper(consumes),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var consume=_step4.value;if('multipart/form-data'===consume.contentType){return true;}}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}return false;}var JSONApiResponse=exports.JSONApiResponse=function(){function JSONApiResponse(raw){var transformer=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(jsonValue){return jsonValue;};(0,_classCallCheck2["default"])(this,JSONApiResponse);this.raw=raw;this.transformer=transformer;}return(0,_createClass2["default"])(JSONApiResponse,[{key:"value",value:function(){var _value=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.t0=this;_context6.next=3;return this.raw.json();case 3:_context6.t1=_context6.sent;return _context6.abrupt("return",_context6.t0.transformer.call(_context6.t0,_context6.t1));case 5:case"end":return _context6.stop();}},_callee6,this);}));function value(){return _value.apply(this,arguments);}return value;}()}]);}(); \ No newline at end of file diff --git a/dist/SDK/Enums/TokenType.enum.js b/dist/SDK/Enums/TokenType.enum.js index c62b70d..473dc9a 100644 --- a/dist/SDK/Enums/TokenType.enum.js +++ b/dist/SDK/Enums/TokenType.enum.js @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:true});exports.TokenType=void 0;var TokenType=function(TokenType){TokenType["ACCESS_TOKEN"]="access_token";TokenType["ID_TOKEN"]="id_token";return TokenType;}({});exports.TokenType=TokenType; \ No newline at end of file +Object.defineProperty(exports,"__esModule",{value:true});exports.TokenType=void 0;var TokenType=exports.TokenType=function(TokenType){TokenType["ACCESS_TOKEN"]="access_token";TokenType["ID_TOKEN"]="id_token";return TokenType;}({}); \ No newline at end of file diff --git a/dist/SDK/KindeSDK.js b/dist/SDK/KindeSDK.js index 90d42df..079ea2c 100644 --- a/dist/SDK/KindeSDK.js +++ b/dist/SDK/KindeSDK.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _jwtDecode=_interopRequireDefault(require("jwt-decode"));var _urlParse=_interopRequireDefault(require("url-parse"));var _unauthenticated=require("../common/exceptions/unauthenticated.exception");var _unexpected=require("../common/exceptions/unexpected.exception");var _Enums=require("./Enums");var _AuthorizationCode=_interopRequireDefault(require("./OAuth/AuthorizationCode"));var _Storage=_interopRequireDefault(require("./Storage"));var _Utils=require("./Utils");var runtime=_interopRequireWildcard(require("../ApiClient"));var _constants=require("./constants");function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var KindeSDK=function(_runtime$BaseAPI,_login,_register,_logout,_getToken,_useRefreshToken,_forceTokenRefresh,_cleanUp,_getUserDetails,_getClaims,_getClaim,_getPermissions,_getPermission,_getOrganization,_getUserOrganizations,_getIntegerFlag,_getBooleanFlag,_getStringFlag,_getFlag,_getFeatureFlags){(0,_inherits2["default"])(KindeSDK,_runtime$BaseAPI);var _super=_createSuper(KindeSDK);function KindeSDK(issuer,redirectUri,clientId,logoutRedirectUri){var _this;var scope=arguments.length>4&&arguments[4]!==undefined?arguments[4]:'openid profile email offline';var additionalParameters=arguments.length>5&&arguments[5]!==undefined?arguments[5]:{};var authBrowserOptions=arguments.length>6?arguments[6]:undefined;(0,_classCallCheck2["default"])(this,KindeSDK);var configuration=new runtime.Configuration({basePath:issuer});_this=_super.call(this,configuration);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"issuer",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"redirectUri",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"clientId",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"logoutRedirectUri",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"scope",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"clientSecret",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"additionalParameters",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"authBrowserOptions",void 0);_this.issuer=issuer;(0,_Utils.checkNotNull)(_this.issuer,'Issuer');_this.redirectUri=redirectUri;(0,_Utils.checkNotNull)(_this.redirectUri,'Redirect URI');_this.clientId=clientId;(0,_Utils.checkNotNull)(_this.clientId,'Client Id');_this.logoutRedirectUri=logoutRedirectUri;(0,_Utils.checkNotNull)(_this.logoutRedirectUri,'Logout Redirect URI');_this.additionalParameters=(0,_Utils.checkAdditionalParameters)(additionalParameters);_this.scope=scope;_this.authBrowserOptions=authBrowserOptions;return _this;}(0,_createClass2["default"])(KindeSDK,[{key:"login",value:function login(){return(_login=_login||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var additionalParameters,authBrowserOptions,auth,additionalParametersMerged,_args=arguments;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:additionalParameters=_args.length>0&&_args[0]!==undefined?_args[0]:{};authBrowserOptions=_args.length>1?_args[1]:undefined;(0,_Utils.checkAdditionalParameters)(additionalParameters);_context.next=5;return this.cleanUp();case 5:auth=new _AuthorizationCode["default"]();additionalParametersMerged=Object.assign({},this.additionalParameters,additionalParameters);return _context.abrupt("return",auth.authenticate(this,true,'login',additionalParametersMerged,authBrowserOptions));case 8:case"end":return _context.stop();}},_callee,this);}))).apply(this,arguments);}},{key:"register",value:function register(){return(_register=_register||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var additionalParameters,authBrowserOptions,auth,additionalParametersMerged,_args2=arguments;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:additionalParameters=_args2.length>0&&_args2[0]!==undefined?_args2[0]:{};authBrowserOptions=_args2.length>1?_args2[1]:undefined;(0,_Utils.checkAdditionalParameters)(additionalParameters);_context2.next=5;return this.cleanUp();case 5:auth=new _AuthorizationCode["default"]();additionalParametersMerged=Object.assign({},this.additionalParameters,additionalParameters);return _context2.abrupt("return",auth.authenticate(this,true,'registration',additionalParametersMerged,authBrowserOptions));case 8:case"end":return _context2.stop();}},_callee2,this);}))).apply(this,arguments);}},{key:"createOrg",value:function createOrg(){var additionalParameters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var authBrowserOptions=arguments.length>1?arguments[1]:undefined;return this.register(Object.assign({is_create_org:true},additionalParameters),authBrowserOptions);}},{key:"logout",value:function logout(){return(_logout=_logout||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){var isRevoke,authBrowserOptions,payload,URLParsed,response,_args3=arguments;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:isRevoke=_args3.length>0&&_args3[0]!==undefined?_args3[0]:false;authBrowserOptions=_args3.length>1?_args3[1]:undefined;_context3.next=4;return this.cleanUp();case 4:if(!isRevoke){_context3.next=16;break;}payload=new _AuthorizationCode["default"]().buildBaseAuthenticateURL(this);_context3.prev=6;_context3.next=9;return this.request({path:"/oauth2/revoke",method:'POST',headers:{},body:(0,_Utils.convertObject2FormData)(payload)});case 9:return _context3.abrupt("return",true);case 12:_context3.prev=12;_context3.t0=_context3["catch"](6);console.error(_context3.t0.message);return _context3.abrupt("return",false);case 16:URLParsed=(0,_urlParse["default"])(this.logoutEndpoint,true);URLParsed.query['redirect']=this.logoutRedirectUri;_context3.next=20;return(0,_Utils.openWebBrowser)(URLParsed.toString(),this.redirectUri,authBrowserOptions||this.authBrowserOptions);case 20:response=_context3.sent;return _context3.abrupt("return",response.type==='success');case 22:case"end":return _context3.stop();}},_callee3,this,[[6,12]]);}))).apply(this,arguments);}},{key:"getToken",value:function getToken(_x){return(_getToken=_getToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(url){var token,URLParsed,_URLParsed$query,code,error,error_description,msg,formData,state,codeVerifier;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.prev=0;_context4.next=3;return this.isAuthenticated;case 3:if(!_context4.sent){_context4.next=8;break;}_context4.next=6;return _Storage["default"].getToken();case 6:token=_context4.sent;return _context4.abrupt("return",token);case 8:_context4.next=12;break;case 10:_context4.prev=10;_context4.t0=_context4["catch"](0);case 12:(0,_Utils.checkNotNull)(url,'URL');URLParsed=(0,_urlParse["default"])(String(url),true);_URLParsed$query=URLParsed.query,code=_URLParsed$query.code,error=_URLParsed$query.error,error_description=_URLParsed$query.error_description;if(!error){_context4.next=18;break;}msg=error_description!==null&&error_description!==void 0?error_description:error;throw new _unauthenticated.UnAuthenticatedException(msg);case 18:(0,_Utils.checkNotNull)(code,'code');formData=new FormData();formData.append('code',code);formData.append('client_id',this.clientId);formData.append('grant_type','authorization_code');formData.append('redirect_uri',this.redirectUri);state=_Storage["default"].getState();if(state){formData.append('state',state);}codeVerifier=_Storage["default"].getCodeVerifier();if(codeVerifier){formData.append('code_verifier',codeVerifier);}return _context4.abrupt("return",this.fetchToken(formData));case 29:case"end":return _context4.stop();}},_callee4,this,[[0,10]]);}))).apply(this,arguments);}},{key:"useRefreshToken",value:function useRefreshToken(_x2){return(_useRefreshToken=_useRefreshToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(refreshToken){var formData;return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:formData=new FormData();formData.append('client_id',this.clientId);formData.append('grant_type','refresh_token');formData.append('refresh_token',refreshToken);return _context5.abrupt("return",this.fetchToken(formData));case 5:case"end":return _context5.stop();}},_callee5,this);}))).apply(this,arguments);}},{key:"forceTokenRefresh",value:function forceTokenRefresh(){return(_forceTokenRefresh=_forceTokenRefresh||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){var currentToken,response;return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.next=2;return _Storage["default"].getToken();case 2:currentToken=_context6.sent;if(!(!currentToken||!currentToken.refresh_token)){_context6.next=5;break;}throw new Error('No refresh token available to perform token refresh.');case 5:_context6.prev=5;_context6.next=8;return this.useRefreshToken(currentToken.refresh_token);case 8:response=_context6.sent;_context6.next=11;return _Storage["default"].setToken(response);case 11:return _context6.abrupt("return",response);case 14:_context6.prev=14;_context6.t0=_context6["catch"](5);console.error('Failed to refresh token:',_context6.t0);return _context6.abrupt("return",null);case 18:case"end":return _context6.stop();}},_callee6,this,[[5,14]]);}))).apply(this,arguments);}},{key:"fetchToken",value:function fetchToken(formData){var _this2=this,_ref;return new Promise(function(_x3,_x4){return(_ref=_ref||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(resolve,reject){var response,dataResponse;return _regenerator["default"].wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return fetch(_this2.tokenEndpoint,{method:'POST',headers:{'Content-Type':'multipart/form-data','Kinde-SDK':'ReactNative/1.2.2'},body:formData});case 2:response=_context7.sent;_context7.next=5;return response.json();case 5:dataResponse=_context7.sent;if(!dataResponse.error){_context7.next=9;break;}reject(dataResponse);return _context7.abrupt("return");case 9:_context7.next=11;return _Storage["default"].setToken(dataResponse);case 11:resolve(dataResponse);case 12:case"end":return _context7.stop();}},_callee7);}))).apply(this,arguments);});}},{key:"cleanUp",value:function cleanUp(){return(_cleanUp=_cleanUp||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){return _regenerator["default"].wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:return _context8.abrupt("return",_Storage["default"].clearAll());case 1:case"end":return _context8.stop();}},_callee8);}))).apply(this,arguments);}},{key:"getUserDetails",value:function getUserDetails(){return(_getUserDetails=_getUserDetails||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){return _regenerator["default"].wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:return _context9.abrupt("return",_Storage["default"].getUserProfile());case 1:case"end":return _context9.stop();}},_callee9);}))).apply(this,arguments);}},{key:"getClaims",value:function getClaims(){return(_getClaims=_getClaims||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10(){var tokenType,token,_args10=arguments;return _regenerator["default"].wrap(function _callee10$(_context10){while(1)switch(_context10.prev=_context10.next){case 0:tokenType=_args10.length>0&&_args10[0]!==undefined?_args10[0]:_Enums.TokenType.ACCESS_TOKEN;if([_Enums.TokenType.ACCESS_TOKEN,_Enums.TokenType.ID_TOKEN].includes(tokenType)){_context10.next=3;break;}throw new _unexpected.UnexpectedException('tokenType');case 3:_context10.next=5;return _Storage["default"].getTokenType(tokenType);case 5:token=_context10.sent;if(token){_context10.next=8;break;}throw new _unauthenticated.UnAuthenticatedException();case 8:return _context10.abrupt("return",(0,_jwtDecode["default"])(token));case 9:case"end":return _context10.stop();}},_callee10);}))).apply(this,arguments);}},{key:"getClaim",value:function getClaim(_x5){return(_getClaim=_getClaim||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11(keyName){var _claims$keyName;var tokenType,claims,_args11=arguments;return _regenerator["default"].wrap(function _callee11$(_context11){while(1)switch(_context11.prev=_context11.next){case 0:tokenType=_args11.length>1&&_args11[1]!==undefined?_args11[1]:_Enums.TokenType.ACCESS_TOKEN;_context11.next=3;return this.getClaims(tokenType);case 3:claims=_context11.sent;if(!claims.hasOwnProperty(keyName)){console.warn("The claimed value of \""+keyName+"\" does not exist in your token");}return _context11.abrupt("return",{name:keyName,value:(_claims$keyName=claims[keyName])!==null&&_claims$keyName!==void 0?_claims$keyName:null});case 6:case"end":return _context11.stop();}},_callee11,this);}))).apply(this,arguments);}},{key:"getPermissions",value:function getPermissions(){return(_getPermissions=_getPermissions||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee12(){var claims;return _regenerator["default"].wrap(function _callee12$(_context12){while(1)switch(_context12.prev=_context12.next){case 0:_context12.next=2;return this.getClaims();case 2:claims=_context12.sent;return _context12.abrupt("return",{orgCode:claims['org_code'],permissions:claims['permissions']});case 4:case"end":return _context12.stop();}},_callee12,this);}))).apply(this,arguments);}},{key:"getPermission",value:function getPermission(_x6){return(_getPermission=_getPermission||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee13(permission){var allClaims,permissions;return _regenerator["default"].wrap(function _callee13$(_context13){while(1)switch(_context13.prev=_context13.next){case 0:_context13.next=2;return this.getClaims();case 2:allClaims=_context13.sent;permissions=allClaims['permissions'];return _context13.abrupt("return",{orgCode:allClaims['org_code'],isGranted:permissions===null||permissions===void 0?void 0:permissions.includes(permission)});case 5:case"end":return _context13.stop();}},_callee13,this);}))).apply(this,arguments);}},{key:"getOrganization",value:function getOrganization(){return(_getOrganization=_getOrganization||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee14(){var orgCode;return _regenerator["default"].wrap(function _callee14$(_context14){while(1)switch(_context14.prev=_context14.next){case 0:_context14.next=2;return this.getClaim('org_code');case 2:orgCode=_context14.sent.value;return _context14.abrupt("return",{orgCode:orgCode});case 4:case"end":return _context14.stop();}},_callee14,this);}))).apply(this,arguments);}},{key:"getUserOrganizations",value:function getUserOrganizations(){return(_getUserOrganizations=_getUserOrganizations||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee15(){var orgCodes;return _regenerator["default"].wrap(function _callee15$(_context15){while(1)switch(_context15.prev=_context15.next){case 0:_context15.next=2;return this.getClaim('org_codes',_Enums.TokenType.ID_TOKEN);case 2:orgCodes=_context15.sent.value;return _context15.abrupt("return",{orgCodes:orgCodes});case 4:case"end":return _context15.stop();}},_callee15,this);}))).apply(this,arguments);}},{key:"getIntegerFlag",value:function getIntegerFlag(_x7,_x8){return(_getIntegerFlag=_getIntegerFlag||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee16(flagName,defaultValue){return _regenerator["default"].wrap(function _callee16$(_context16){while(1)switch(_context16.prev=_context16.next){case 0:_context16.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'i');case 2:return _context16.abrupt("return",_context16.sent.value);case 3:case"end":return _context16.stop();}},_callee16,this);}))).apply(this,arguments);}},{key:"getBooleanFlag",value:function getBooleanFlag(_x9,_x10){return(_getBooleanFlag=_getBooleanFlag||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee17(flagName,defaultValue){return _regenerator["default"].wrap(function _callee17$(_context17){while(1)switch(_context17.prev=_context17.next){case 0:_context17.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'b');case 2:return _context17.abrupt("return",_context17.sent.value);case 3:case"end":return _context17.stop();}},_callee17,this);}))).apply(this,arguments);}},{key:"getStringFlag",value:function getStringFlag(_x11,_x12){return(_getStringFlag=_getStringFlag||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee18(flagName,defaultValue){return _regenerator["default"].wrap(function _callee18$(_context18){while(1)switch(_context18.prev=_context18.next){case 0:_context18.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'s');case 2:return _context18.abrupt("return",_context18.sent.value);case 3:case"end":return _context18.stop();}},_callee18,this);}))).apply(this,arguments);}},{key:"getFlag",value:function getFlag(_x13){return(_getFlag=_getFlag||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee19(flagName){var options,flagType,isUsedDefault,flag,flagTypeParsed,requestType,_args19=arguments;return _regenerator["default"].wrap(function _callee19$(_context19){while(1)switch(_context19.prev=_context19.next){case 0:options=_args19.length>1&&_args19[1]!==undefined?_args19[1]:{};flagType=_args19.length>2?_args19[2]:undefined;isUsedDefault=false;_context19.next=5;return this.getFeatureFlags(flagName);case 5:flag=_context19.sent;if(!flag){isUsedDefault=true;flag={v:options['defaultValue'],t:flagType};}if(flag['v']){_context19.next=9;break;}throw new Error("This flag '"+flagName+"' was not found, and no default value has been provided");case 9:flagTypeParsed=_constants.FLAG_TYPE[flag['t']];requestType=_constants.FLAG_TYPE[flagType];if(!(requestType!==undefined&&flagTypeParsed!==requestType)){_context19.next=13;break;}throw new Error("Flag '"+flagName+"' is type "+flagTypeParsed+" - requested type "+requestType);case 13:return _context19.abrupt("return",{code:flagName,type:flagTypeParsed,value:flag['v'],is_default:isUsedDefault});case 14:case"end":return _context19.stop();}},_callee19,this);}))).apply(this,arguments);}},{key:"getFeatureFlags",value:function getFeatureFlags(_x14){return(_getFeatureFlags=_getFeatureFlags||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee20(name){var flags;return _regenerator["default"].wrap(function _callee20$(_context20){while(1)switch(_context20.prev=_context20.next){case 0:_context20.next=2;return this.getClaim('feature_flags');case 2:flags=_context20.sent.value;if(!(name&&flags)){_context20.next=5;break;}return _context20.abrupt("return",flags[name]);case 5:return _context20.abrupt("return",flags);case 6:case"end":return _context20.stop();}},_callee20,this);}))).apply(this,arguments);}},{key:"isAuthenticated",get:function get(){var _this3=this;return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee21(){var timeExpired,now,isAuthenticated,token,refreshToken,_token;return _regenerator["default"].wrap(function _callee21$(_context21){while(1)switch(_context21.prev=_context21.next){case 0:_context21.next=2;return _Storage["default"].getExpiredAt();case 2:timeExpired=_context21.sent;now=new Date().getTime();isAuthenticated=timeExpired*1000>now;if(!isAuthenticated){_context21.next=7;break;}return _context21.abrupt("return",true);case 7:_context21.next=9;return _Storage["default"].getToken();case 9:token=_context21.sent;refreshToken=token===null||token===void 0?void 0:token.refresh_token;if(refreshToken){_context21.next=13;break;}return _context21.abrupt("return",false);case 13:_context21.prev=13;_context21.next=16;return _this3.useRefreshToken(refreshToken);case 16:_token=_context21.sent;return _context21.abrupt("return",((_token===null||_token===void 0?void 0:_token.expires_in)||0)>0);case 20:_context21.prev=20;_context21.t0=_context21["catch"](13);return _context21.abrupt("return",false);case 23:case"end":return _context21.stop();}},_callee21,null,[[13,20]]);}))();}},{key:"authorizationEndpoint",get:function get(){return this.issuer+"/oauth2/auth";}},{key:"tokenEndpoint",get:function get(){return this.issuer+"/oauth2/token";}},{key:"logoutEndpoint",get:function get(){return this.issuer+"/logout";}}]);return KindeSDK;}(runtime.BaseAPI);var _default=KindeSDK;exports["default"]=_default; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _jwtDecode=_interopRequireDefault(require("jwt-decode"));var _urlParse=_interopRequireDefault(require("url-parse"));var _unauthenticated=require("../common/exceptions/unauthenticated.exception");var _unexpected=require("../common/exceptions/unexpected.exception");var _Enums=require("./Enums");var _AuthorizationCode=_interopRequireDefault(require("./OAuth/AuthorizationCode"));var _Storage=_interopRequireDefault(require("./Storage"));var _Utils=require("./Utils");var runtime=_interopRequireWildcard(require("../ApiClient"));var _constants=require("./constants");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var KindeSDK=function(_runtime$BaseAPI){function KindeSDK(issuer,redirectUri,clientId,logoutRedirectUri){var _this;var scope=arguments.length>4&&arguments[4]!==undefined?arguments[4]:'openid profile email offline';var additionalParameters=arguments.length>5&&arguments[5]!==undefined?arguments[5]:{};var authBrowserOptions=arguments.length>6?arguments[6]:undefined;(0,_classCallCheck2["default"])(this,KindeSDK);var configuration=new runtime.Configuration({basePath:issuer});_this=_callSuper(this,KindeSDK,[configuration]);(0,_defineProperty2["default"])(_this,"issuer",void 0);(0,_defineProperty2["default"])(_this,"redirectUri",void 0);(0,_defineProperty2["default"])(_this,"clientId",void 0);(0,_defineProperty2["default"])(_this,"logoutRedirectUri",void 0);(0,_defineProperty2["default"])(_this,"scope",void 0);(0,_defineProperty2["default"])(_this,"clientSecret",void 0);(0,_defineProperty2["default"])(_this,"additionalParameters",void 0);(0,_defineProperty2["default"])(_this,"authBrowserOptions",void 0);_this.issuer=issuer;(0,_Utils.checkNotNull)(_this.issuer,'Issuer');_this.redirectUri=redirectUri;(0,_Utils.checkNotNull)(_this.redirectUri,'Redirect URI');_this.clientId=clientId;(0,_Utils.checkNotNull)(_this.clientId,'Client Id');_this.logoutRedirectUri=logoutRedirectUri;(0,_Utils.checkNotNull)(_this.logoutRedirectUri,'Logout Redirect URI');_this.additionalParameters=(0,_Utils.checkAdditionalParameters)(additionalParameters);_this.scope=scope;_this.authBrowserOptions=authBrowserOptions;return _this;}(0,_inherits2["default"])(KindeSDK,_runtime$BaseAPI);return(0,_createClass2["default"])(KindeSDK,[{key:"login",value:(function(){var _login=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var additionalParameters,authBrowserOptions,auth,additionalParametersMerged,_args=arguments;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:additionalParameters=_args.length>0&&_args[0]!==undefined?_args[0]:{};authBrowserOptions=_args.length>1?_args[1]:undefined;(0,_Utils.checkAdditionalParameters)(additionalParameters);_context.next=5;return this.cleanUp();case 5:auth=new _AuthorizationCode["default"]();additionalParametersMerged=Object.assign({},this.additionalParameters,additionalParameters);return _context.abrupt("return",auth.authenticate(this,true,'login',additionalParametersMerged,authBrowserOptions));case 8:case"end":return _context.stop();}},_callee,this);}));function login(){return _login.apply(this,arguments);}return login;}())},{key:"register",value:(function(){var _register=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var additionalParameters,authBrowserOptions,auth,additionalParametersMerged,_args2=arguments;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:additionalParameters=_args2.length>0&&_args2[0]!==undefined?_args2[0]:{};authBrowserOptions=_args2.length>1?_args2[1]:undefined;(0,_Utils.checkAdditionalParameters)(additionalParameters);_context2.next=5;return this.cleanUp();case 5:auth=new _AuthorizationCode["default"]();additionalParametersMerged=Object.assign({},this.additionalParameters,additionalParameters);return _context2.abrupt("return",auth.authenticate(this,true,'registration',additionalParametersMerged,authBrowserOptions));case 8:case"end":return _context2.stop();}},_callee2,this);}));function register(){return _register.apply(this,arguments);}return register;}())},{key:"createOrg",value:function createOrg(){var additionalParameters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var authBrowserOptions=arguments.length>1?arguments[1]:undefined;return this.register(Object.assign({is_create_org:true},additionalParameters),authBrowserOptions);}},{key:"logout",value:(function(){var _logout=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){var isRevoke,authBrowserOptions,payload,URLParsed,response,_args3=arguments;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:isRevoke=_args3.length>0&&_args3[0]!==undefined?_args3[0]:false;authBrowserOptions=_args3.length>1?_args3[1]:undefined;_context3.next=4;return this.cleanUp();case 4:if(!isRevoke){_context3.next=16;break;}payload=new _AuthorizationCode["default"]().buildBaseAuthenticateURL(this);_context3.prev=6;_context3.next=9;return this.request({path:"/oauth2/revoke",method:'POST',headers:{},body:(0,_Utils.convertObject2FormData)(payload)});case 9:return _context3.abrupt("return",true);case 12:_context3.prev=12;_context3.t0=_context3["catch"](6);console.error(_context3.t0.message);return _context3.abrupt("return",false);case 16:URLParsed=(0,_urlParse["default"])(this.logoutEndpoint,true);URLParsed.query['redirect']=this.logoutRedirectUri;_context3.next=20;return(0,_Utils.openWebBrowser)(URLParsed.toString(),this.redirectUri,authBrowserOptions||this.authBrowserOptions);case 20:response=_context3.sent;return _context3.abrupt("return",response.type==='success');case 22:case"end":return _context3.stop();}},_callee3,this,[[6,12]]);}));function logout(){return _logout.apply(this,arguments);}return logout;}())},{key:"getToken",value:(function(){var _getToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(url){var token,URLParsed,_URLParsed$query,code,error,error_description,msg,formData,state,codeVerifier;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.prev=0;_context4.next=3;return this.isAuthenticated;case 3:if(!_context4.sent){_context4.next=8;break;}_context4.next=6;return _Storage["default"].getToken();case 6:token=_context4.sent;return _context4.abrupt("return",token);case 8:_context4.next=12;break;case 10:_context4.prev=10;_context4.t0=_context4["catch"](0);case 12:(0,_Utils.checkNotNull)(url,'URL');URLParsed=(0,_urlParse["default"])(String(url),true);_URLParsed$query=URLParsed.query,code=_URLParsed$query.code,error=_URLParsed$query.error,error_description=_URLParsed$query.error_description;if(!error){_context4.next=18;break;}msg=error_description!==null&&error_description!==void 0?error_description:error;throw new _unauthenticated.UnAuthenticatedException(msg);case 18:(0,_Utils.checkNotNull)(code,'code');formData=new FormData();formData.append('code',code);formData.append('client_id',this.clientId);formData.append('grant_type','authorization_code');formData.append('redirect_uri',this.redirectUri);state=_Storage["default"].getState();if(state){formData.append('state',state);}codeVerifier=_Storage["default"].getCodeVerifier();if(codeVerifier){formData.append('code_verifier',codeVerifier);}return _context4.abrupt("return",this.fetchToken(formData));case 29:case"end":return _context4.stop();}},_callee4,this,[[0,10]]);}));function getToken(_x){return _getToken.apply(this,arguments);}return getToken;}())},{key:"useRefreshToken",value:(function(){var _useRefreshToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(refreshToken){var formData;return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:formData=new FormData();formData.append('client_id',this.clientId);formData.append('grant_type','refresh_token');formData.append('refresh_token',refreshToken);return _context5.abrupt("return",this.fetchToken(formData));case 5:case"end":return _context5.stop();}},_callee5,this);}));function useRefreshToken(_x2){return _useRefreshToken.apply(this,arguments);}return useRefreshToken;}())},{key:"forceTokenRefresh",value:(function(){var _forceTokenRefresh=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){var currentToken,response;return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.next=2;return _Storage["default"].getToken();case 2:currentToken=_context6.sent;if(!(!currentToken||!currentToken.refresh_token)){_context6.next=5;break;}throw new Error('No refresh token available to perform token refresh.');case 5:_context6.prev=5;_context6.next=8;return this.useRefreshToken(currentToken.refresh_token);case 8:response=_context6.sent;_context6.next=11;return _Storage["default"].setToken(response);case 11:return _context6.abrupt("return",response);case 14:_context6.prev=14;_context6.t0=_context6["catch"](5);console.error('Failed to refresh token:',_context6.t0);return _context6.abrupt("return",null);case 18:case"end":return _context6.stop();}},_callee6,this,[[5,14]]);}));function forceTokenRefresh(){return _forceTokenRefresh.apply(this,arguments);}return forceTokenRefresh;}())},{key:"fetchToken",value:function fetchToken(formData){var _this2=this;return new Promise(function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(resolve,reject){var response,dataResponse;return _regenerator["default"].wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return fetch(_this2.tokenEndpoint,{method:'POST',headers:{'Content-Type':'multipart/form-data','Kinde-SDK':'ReactNative/1.2.2'},body:formData});case 2:response=_context7.sent;_context7.next=5;return response.json();case 5:dataResponse=_context7.sent;if(!dataResponse.error){_context7.next=9;break;}reject(dataResponse);return _context7.abrupt("return");case 9:_context7.next=11;return _Storage["default"].setToken(dataResponse);case 11:resolve(dataResponse);case 12:case"end":return _context7.stop();}},_callee7);}));return function(_x3,_x4){return _ref.apply(this,arguments);};}());}},{key:"cleanUp",value:(function(){var _cleanUp=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){return _regenerator["default"].wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:return _context8.abrupt("return",_Storage["default"].clearAll());case 1:case"end":return _context8.stop();}},_callee8);}));function cleanUp(){return _cleanUp.apply(this,arguments);}return cleanUp;}())},{key:"getUserDetails",value:(function(){var _getUserDetails=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){return _regenerator["default"].wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:return _context9.abrupt("return",_Storage["default"].getUserProfile());case 1:case"end":return _context9.stop();}},_callee9);}));function getUserDetails(){return _getUserDetails.apply(this,arguments);}return getUserDetails;}())},{key:"getClaims",value:(function(){var _getClaims=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10(){var tokenType,token,_args10=arguments;return _regenerator["default"].wrap(function _callee10$(_context10){while(1)switch(_context10.prev=_context10.next){case 0:tokenType=_args10.length>0&&_args10[0]!==undefined?_args10[0]:_Enums.TokenType.ACCESS_TOKEN;if([_Enums.TokenType.ACCESS_TOKEN,_Enums.TokenType.ID_TOKEN].includes(tokenType)){_context10.next=3;break;}throw new _unexpected.UnexpectedException('tokenType');case 3:_context10.next=5;return _Storage["default"].getTokenType(tokenType);case 5:token=_context10.sent;if(token){_context10.next=8;break;}throw new _unauthenticated.UnAuthenticatedException();case 8:return _context10.abrupt("return",(0,_jwtDecode["default"])(token));case 9:case"end":return _context10.stop();}},_callee10);}));function getClaims(){return _getClaims.apply(this,arguments);}return getClaims;}())},{key:"getClaim",value:(function(){var _getClaim=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11(keyName){var _claims$keyName;var tokenType,claims,_args11=arguments;return _regenerator["default"].wrap(function _callee11$(_context11){while(1)switch(_context11.prev=_context11.next){case 0:tokenType=_args11.length>1&&_args11[1]!==undefined?_args11[1]:_Enums.TokenType.ACCESS_TOKEN;_context11.next=3;return this.getClaims(tokenType);case 3:claims=_context11.sent;if(!claims.hasOwnProperty(keyName)){console.warn("The claimed value of \""+keyName+"\" does not exist in your token");}return _context11.abrupt("return",{name:keyName,value:(_claims$keyName=claims[keyName])!==null&&_claims$keyName!==void 0?_claims$keyName:null});case 6:case"end":return _context11.stop();}},_callee11,this);}));function getClaim(_x5){return _getClaim.apply(this,arguments);}return getClaim;}())},{key:"getPermissions",value:(function(){var _getPermissions=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee12(){var claims;return _regenerator["default"].wrap(function _callee12$(_context12){while(1)switch(_context12.prev=_context12.next){case 0:_context12.next=2;return this.getClaims();case 2:claims=_context12.sent;return _context12.abrupt("return",{orgCode:claims['org_code'],permissions:claims['permissions']});case 4:case"end":return _context12.stop();}},_callee12,this);}));function getPermissions(){return _getPermissions.apply(this,arguments);}return getPermissions;}())},{key:"getPermission",value:(function(){var _getPermission=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee13(permission){var allClaims,permissions;return _regenerator["default"].wrap(function _callee13$(_context13){while(1)switch(_context13.prev=_context13.next){case 0:_context13.next=2;return this.getClaims();case 2:allClaims=_context13.sent;permissions=allClaims['permissions'];return _context13.abrupt("return",{orgCode:allClaims['org_code'],isGranted:permissions===null||permissions===void 0?void 0:permissions.includes(permission)});case 5:case"end":return _context13.stop();}},_callee13,this);}));function getPermission(_x6){return _getPermission.apply(this,arguments);}return getPermission;}())},{key:"getOrganization",value:(function(){var _getOrganization=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee14(){var orgCode;return _regenerator["default"].wrap(function _callee14$(_context14){while(1)switch(_context14.prev=_context14.next){case 0:_context14.next=2;return this.getClaim('org_code');case 2:orgCode=_context14.sent.value;return _context14.abrupt("return",{orgCode:orgCode});case 4:case"end":return _context14.stop();}},_callee14,this);}));function getOrganization(){return _getOrganization.apply(this,arguments);}return getOrganization;}())},{key:"getUserOrganizations",value:(function(){var _getUserOrganizations=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee15(){var orgCodes;return _regenerator["default"].wrap(function _callee15$(_context15){while(1)switch(_context15.prev=_context15.next){case 0:_context15.next=2;return this.getClaim('org_codes',_Enums.TokenType.ID_TOKEN);case 2:orgCodes=_context15.sent.value;return _context15.abrupt("return",{orgCodes:orgCodes});case 4:case"end":return _context15.stop();}},_callee15,this);}));function getUserOrganizations(){return _getUserOrganizations.apply(this,arguments);}return getUserOrganizations;}())},{key:"getIntegerFlag",value:(function(){var _getIntegerFlag=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee16(flagName,defaultValue){return _regenerator["default"].wrap(function _callee16$(_context16){while(1)switch(_context16.prev=_context16.next){case 0:_context16.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'i');case 2:return _context16.abrupt("return",_context16.sent.value);case 3:case"end":return _context16.stop();}},_callee16,this);}));function getIntegerFlag(_x7,_x8){return _getIntegerFlag.apply(this,arguments);}return getIntegerFlag;}())},{key:"getBooleanFlag",value:(function(){var _getBooleanFlag=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee17(flagName,defaultValue){return _regenerator["default"].wrap(function _callee17$(_context17){while(1)switch(_context17.prev=_context17.next){case 0:_context17.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'b');case 2:return _context17.abrupt("return",_context17.sent.value);case 3:case"end":return _context17.stop();}},_callee17,this);}));function getBooleanFlag(_x9,_x10){return _getBooleanFlag.apply(this,arguments);}return getBooleanFlag;}())},{key:"getStringFlag",value:(function(){var _getStringFlag=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee18(flagName,defaultValue){return _regenerator["default"].wrap(function _callee18$(_context18){while(1)switch(_context18.prev=_context18.next){case 0:_context18.next=2;return this.getFlag(flagName,{defaultValue:defaultValue},'s');case 2:return _context18.abrupt("return",_context18.sent.value);case 3:case"end":return _context18.stop();}},_callee18,this);}));function getStringFlag(_x11,_x12){return _getStringFlag.apply(this,arguments);}return getStringFlag;}())},{key:"getFlag",value:(function(){var _getFlag=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee19(flagName){var options,flagType,isUsedDefault,flag,flagTypeParsed,requestType,_args19=arguments;return _regenerator["default"].wrap(function _callee19$(_context19){while(1)switch(_context19.prev=_context19.next){case 0:options=_args19.length>1&&_args19[1]!==undefined?_args19[1]:{};flagType=_args19.length>2?_args19[2]:undefined;isUsedDefault=false;_context19.next=5;return this.getFeatureFlags(flagName);case 5:flag=_context19.sent;if(!flag){isUsedDefault=true;flag={v:options['defaultValue'],t:flagType};}if(flag['v']){_context19.next=9;break;}throw new Error("This flag '"+flagName+"' was not found, and no default value has been provided");case 9:flagTypeParsed=_constants.FLAG_TYPE[flag['t']];requestType=_constants.FLAG_TYPE[flagType];if(!(requestType!==undefined&&flagTypeParsed!==requestType)){_context19.next=13;break;}throw new Error("Flag '"+flagName+"' is type "+flagTypeParsed+" - requested type "+requestType);case 13:return _context19.abrupt("return",{code:flagName,type:flagTypeParsed,value:flag['v'],is_default:isUsedDefault});case 14:case"end":return _context19.stop();}},_callee19,this);}));function getFlag(_x13){return _getFlag.apply(this,arguments);}return getFlag;}())},{key:"getFeatureFlags",value:(function(){var _getFeatureFlags=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee20(name){var flags;return _regenerator["default"].wrap(function _callee20$(_context20){while(1)switch(_context20.prev=_context20.next){case 0:_context20.next=2;return this.getClaim('feature_flags');case 2:flags=_context20.sent.value;if(!(name&&flags)){_context20.next=5;break;}return _context20.abrupt("return",flags[name]);case 5:return _context20.abrupt("return",flags);case 6:case"end":return _context20.stop();}},_callee20,this);}));function getFeatureFlags(_x14){return _getFeatureFlags.apply(this,arguments);}return getFeatureFlags;}())},{key:"isAuthenticated",get:function get(){var _this3=this;return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee21(){var timeExpired,now,isAuthenticated,token,refreshToken,_token;return _regenerator["default"].wrap(function _callee21$(_context21){while(1)switch(_context21.prev=_context21.next){case 0:_context21.next=2;return _Storage["default"].getExpiredAt();case 2:timeExpired=_context21.sent;now=new Date().getTime();isAuthenticated=timeExpired*1000>now;if(!isAuthenticated){_context21.next=7;break;}return _context21.abrupt("return",true);case 7:_context21.next=9;return _Storage["default"].getToken();case 9:token=_context21.sent;refreshToken=token===null||token===void 0?void 0:token.refresh_token;if(refreshToken){_context21.next=13;break;}return _context21.abrupt("return",false);case 13:_context21.prev=13;_context21.next=16;return _this3.useRefreshToken(refreshToken);case 16:_token=_context21.sent;return _context21.abrupt("return",((_token===null||_token===void 0?void 0:_token.expires_in)||0)>0);case 20:_context21.prev=20;_context21.t0=_context21["catch"](13);return _context21.abrupt("return",false);case 23:case"end":return _context21.stop();}},_callee21,null,[[13,20]]);}))();}},{key:"authorizationEndpoint",get:function get(){return this.issuer+"/oauth2/auth";}},{key:"tokenEndpoint",get:function get(){return this.issuer+"/oauth2/token";}},{key:"logoutEndpoint",get:function get(){return this.issuer+"/logout";}}]);}(runtime.BaseAPI);var _default=exports["default"]=KindeSDK; \ No newline at end of file diff --git a/dist/SDK/OAuth/AuthorizationCode.js b/dist/SDK/OAuth/AuthorizationCode.js index a795e76..6d1cc9f 100644 --- a/dist/SDK/OAuth/AuthorizationCode.js +++ b/dist/SDK/OAuth/AuthorizationCode.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _urlParse=_interopRequireDefault(require("url-parse"));var _Storage=_interopRequireDefault(require("../Storage"));var _Utils=require("../Utils");var AuthorizationCode=function(_authenticate){function AuthorizationCode(){(0,_classCallCheck2["default"])(this,AuthorizationCode);}(0,_createClass2["default"])(AuthorizationCode,[{key:"authenticate",value:function authenticate(_x){return(_authenticate=_authenticate||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(kindeSDK){var usePKCE,startPage,additionalParameters,options,URLParsed,baseInfo,stateGenerated,challenge,_args=arguments;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:usePKCE=_args.length>1&&_args[1]!==undefined?_args[1]:false;startPage=_args.length>2&&_args[2]!==undefined?_args[2]:'login';additionalParameters=_args.length>3&&_args[3]!==undefined?_args[3]:{};options=_args.length>4?_args[4]:undefined;URLParsed=(0,_urlParse["default"])(kindeSDK.authorizationEndpoint,true);baseInfo=this.buildBaseAuthenticateURL(kindeSDK);Object.keys(baseInfo).forEach(function(k){URLParsed.query[k]=baseInfo[k];});URLParsed.query['start_page']=startPage;stateGenerated=(0,_Utils.generateRandomString)();URLParsed.query['state']=stateGenerated;(0,_Utils.addAdditionalParameters)(URLParsed.query,additionalParameters);_Storage["default"].setState(stateGenerated);if(usePKCE){challenge=(0,_Utils.generateChallenge)();URLParsed.query['code_challenge']=challenge.codeChallenge;URLParsed.query['code_challenge_method']='S256';_Storage["default"].setCodeVerifier(challenge.codeVerifier);}return _context.abrupt("return",(0,_Utils.OpenWebInApp)(URLParsed.toString(),kindeSDK,options));case 14:case"end":return _context.stop();}},_callee,this);}))).apply(this,arguments);}},{key:"buildBaseAuthenticateURL",value:function buildBaseAuthenticateURL(kindeSDK){return{client_id:kindeSDK.clientId,redirect_uri:kindeSDK.redirectUri,client_secret:kindeSDK.clientSecret,scope:kindeSDK.scope,grant_type:'authorization_code',response_type:'code'};}}]);return AuthorizationCode;}();var _default=AuthorizationCode;exports["default"]=_default; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _urlParse=_interopRequireDefault(require("url-parse"));var _Storage=_interopRequireDefault(require("../Storage"));var _Utils=require("../Utils");var AuthorizationCode=function(){function AuthorizationCode(){(0,_classCallCheck2["default"])(this,AuthorizationCode);}return(0,_createClass2["default"])(AuthorizationCode,[{key:"authenticate",value:(function(){var _authenticate=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(kindeSDK){var usePKCE,startPage,additionalParameters,options,URLParsed,baseInfo,stateGenerated,challenge,_args=arguments;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:usePKCE=_args.length>1&&_args[1]!==undefined?_args[1]:false;startPage=_args.length>2&&_args[2]!==undefined?_args[2]:'login';additionalParameters=_args.length>3&&_args[3]!==undefined?_args[3]:{};options=_args.length>4?_args[4]:undefined;URLParsed=(0,_urlParse["default"])(kindeSDK.authorizationEndpoint,true);baseInfo=this.buildBaseAuthenticateURL(kindeSDK);Object.keys(baseInfo).forEach(function(k){URLParsed.query[k]=baseInfo[k];});URLParsed.query['start_page']=startPage;stateGenerated=(0,_Utils.generateRandomString)();URLParsed.query['state']=stateGenerated;(0,_Utils.addAdditionalParameters)(URLParsed.query,additionalParameters);_Storage["default"].setState(stateGenerated);if(usePKCE){challenge=(0,_Utils.generateChallenge)();URLParsed.query['code_challenge']=challenge.codeChallenge;URLParsed.query['code_challenge_method']='S256';_Storage["default"].setCodeVerifier(challenge.codeVerifier);}return _context.abrupt("return",(0,_Utils.OpenWebInApp)(URLParsed.toString(),kindeSDK,options));case 14:case"end":return _context.stop();}},_callee,this);}));function authenticate(_x){return _authenticate.apply(this,arguments);}return authenticate;}())},{key:"buildBaseAuthenticateURL",value:function buildBaseAuthenticateURL(kindeSDK){return{client_id:kindeSDK.clientId,redirect_uri:kindeSDK.redirectUri,client_secret:kindeSDK.clientSecret,scope:kindeSDK.scope,grant_type:'authorization_code',response_type:'code'};}}]);}();var _default=exports["default"]=AuthorizationCode; \ No newline at end of file diff --git a/dist/SDK/Storage/Base.js b/dist/SDK/Storage/Base.js index 642f085..a99a2d1 100644 --- a/dist/SDK/Storage/Base.js +++ b/dist/SDK/Storage/Base.js @@ -1 +1 @@ -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 _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var BaseStore=function(){function BaseStore(){(0,_classCallCheck2["default"])(this,BaseStore);(0,_defineProperty2["default"])(this,"data",void 0);this.data=new Map();}(0,_createClass2["default"])(BaseStore,[{key:"getItem",value:function getItem(key){return this.data.get(key);}},{key:"length",get:function get(){return this.data.size;}},{key:"setItem",value:function setItem(key,value){this.data.set(key,value);}},{key:"removeItem",value:function removeItem(key){this.data["delete"](key);}},{key:"clear",value:function clear(){this.data=new Map();}}]);return BaseStore;}();var _default=BaseStore;exports["default"]=_default; \ No newline at end of file +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 _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var BaseStore=function(){function BaseStore(){(0,_classCallCheck2["default"])(this,BaseStore);(0,_defineProperty2["default"])(this,"data",void 0);this.data=new Map();}return(0,_createClass2["default"])(BaseStore,[{key:"getItem",value:function getItem(key){return this.data.get(key);}},{key:"length",get:function get(){return this.data.size;}},{key:"setItem",value:function setItem(key,value){this.data.set(key,value);}},{key:"removeItem",value:function removeItem(key){this.data["delete"](key);}},{key:"clear",value:function clear(){this.data=new Map();}}]);}();var _default=exports["default"]=BaseStore; \ No newline at end of file diff --git a/dist/SDK/Storage/ExpoStorage.js b/dist/SDK/Storage/ExpoStorage.js index a3677f5..4968b79 100644 --- a/dist/SDK/Storage/ExpoStorage.js +++ b/dist/SDK/Storage/ExpoStorage.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var SecureStore=_interopRequireWildcard(require("expo-secure-store"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ExpoStorage=function(_getItem,_setItem,_clear){function ExpoStorage(){(0,_classCallCheck2["default"])(this,ExpoStorage);}(0,_createClass2["default"])(ExpoStorage,[{key:"getItem",value:function getItem(){return(_getItem=_getItem||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var access_token,expires_in,id_token,refresh_token;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return SecureStore.getItemAsync('kinde_access_token');case 2:access_token=_context.sent;_context.next=5;return SecureStore.getItemAsync('kinde_expires_in');case 5:expires_in=_context.sent;_context.next=8;return SecureStore.getItemAsync('kinde_id_token');case 8:id_token=_context.sent;_context.next=11;return SecureStore.getItemAsync('kinde_refresh_token');case 11:refresh_token=_context.sent;return _context.abrupt("return",JSON.stringify({access_token:access_token,expires_in:expires_in,id_token:id_token,refresh_token:refresh_token}));case 13:case"end":return _context.stop();}},_callee);}))).apply(this,arguments);}},{key:"setItem",value:function setItem(_x){return(_setItem=_setItem||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(value){var _ref,access_token,expires_in,id_token,refresh_token;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_ref=typeof value==='string'?JSON.parse(value):value,access_token=_ref.access_token,expires_in=_ref.expires_in,id_token=_ref.id_token,refresh_token=_ref.refresh_token;_context2.next=3;return SecureStore.setItemAsync('kinde_access_token',String(access_token));case 3:_context2.next=5;return SecureStore.setItemAsync('kinde_expires_in',String(expires_in));case 5:_context2.next=7;return SecureStore.setItemAsync('kinde_id_token',String(id_token));case 7:_context2.next=9;return SecureStore.setItemAsync('kinde_refresh_token',String(refresh_token));case 9:return _context2.abrupt("return",true);case 10:case"end":return _context2.stop();}},_callee2);}))).apply(this,arguments);}},{key:"clear",value:function clear(){return(_clear=_clear||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return SecureStore.deleteItemAsync('kinde_access_token');case 2:_context3.next=4;return SecureStore.deleteItemAsync('kinde_expires_in');case 4:_context3.next=6;return SecureStore.deleteItemAsync('kinde_id_token');case 6:_context3.next=8;return SecureStore.deleteItemAsync('kinde_refresh_token');case 8:return _context3.abrupt("return",true);case 9:case"end":return _context3.stop();}},_callee3);}))).apply(this,arguments);}}]);return ExpoStorage;}();exports["default"]=ExpoStorage; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var SecureStore=_interopRequireWildcard(require("expo-secure-store"));function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;}var ExpoStorage=exports["default"]=function(){function ExpoStorage(){(0,_classCallCheck2["default"])(this,ExpoStorage);}return(0,_createClass2["default"])(ExpoStorage,[{key:"getItem",value:function(){var _getItem=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var access_token,expires_in,id_token,refresh_token;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return SecureStore.getItemAsync('kinde_access_token');case 2:access_token=_context.sent;_context.next=5;return SecureStore.getItemAsync('kinde_expires_in');case 5:expires_in=_context.sent;_context.next=8;return SecureStore.getItemAsync('kinde_id_token');case 8:id_token=_context.sent;_context.next=11;return SecureStore.getItemAsync('kinde_refresh_token');case 11:refresh_token=_context.sent;return _context.abrupt("return",JSON.stringify({access_token:access_token,expires_in:expires_in,id_token:id_token,refresh_token:refresh_token}));case 13:case"end":return _context.stop();}},_callee);}));function getItem(){return _getItem.apply(this,arguments);}return getItem;}()},{key:"setItem",value:function(){var _setItem=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(value){var _ref,access_token,expires_in,id_token,refresh_token;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_ref=typeof value==='string'?JSON.parse(value):value,access_token=_ref.access_token,expires_in=_ref.expires_in,id_token=_ref.id_token,refresh_token=_ref.refresh_token;_context2.next=3;return SecureStore.setItemAsync('kinde_access_token',String(access_token));case 3:_context2.next=5;return SecureStore.setItemAsync('kinde_expires_in',String(expires_in));case 5:_context2.next=7;return SecureStore.setItemAsync('kinde_id_token',String(id_token));case 7:_context2.next=9;return SecureStore.setItemAsync('kinde_refresh_token',String(refresh_token));case 9:return _context2.abrupt("return",true);case 10:case"end":return _context2.stop();}},_callee2);}));function setItem(_x){return _setItem.apply(this,arguments);}return setItem;}()},{key:"clear",value:function(){var _clear=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return SecureStore.deleteItemAsync('kinde_access_token');case 2:_context3.next=4;return SecureStore.deleteItemAsync('kinde_expires_in');case 4:_context3.next=6;return SecureStore.deleteItemAsync('kinde_id_token');case 6:_context3.next=8;return SecureStore.deleteItemAsync('kinde_refresh_token');case 8:return _context3.abrupt("return",true);case 9:case"end":return _context3.stop();}},_callee3);}));function clear(){return _clear.apply(this,arguments);}return clear;}()}]);}(); \ No newline at end of file diff --git a/dist/SDK/Storage/RNStorage.js b/dist/SDK/Storage/RNStorage.js index 573f89b..15e9549 100644 --- a/dist/SDK/Storage/RNStorage.js +++ b/dist/SDK/Storage/RNStorage.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var KeyChain=_interopRequireWildcard(require("react-native-keychain"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;}var RNStorage=function(_getItem,_setItem){function RNStorage(){(0,_classCallCheck2["default"])(this,RNStorage);}(0,_createClass2["default"])(RNStorage,[{key:"getItem",value:function getItem(){return(_getItem=_getItem||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",KeyChain.getGenericPassword());case 1:case"end":return _context.stop();}},_callee);}))).apply(this,arguments);}},{key:"setItem",value:function setItem(_x){return(_setItem=_setItem||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(value){var rs;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return KeyChain.setGenericPassword('kinde',typeof value==='string'?value:JSON.stringify(value));case 2:rs=_context2.sent;return _context2.abrupt("return",Boolean(rs));case 4:case"end":return _context2.stop();}},_callee2);}))).apply(this,arguments);}},{key:"clear",value:function clear(){return KeyChain.resetGenericPassword();}}]);return RNStorage;}();exports["default"]=RNStorage; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var KeyChain=_interopRequireWildcard(require("react-native-keychain"));function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;}var RNStorage=exports["default"]=function(){function RNStorage(){(0,_classCallCheck2["default"])(this,RNStorage);}return(0,_createClass2["default"])(RNStorage,[{key:"getItem",value:function(){var _getItem=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",KeyChain.getGenericPassword());case 1:case"end":return _context.stop();}},_callee);}));function getItem(){return _getItem.apply(this,arguments);}return getItem;}()},{key:"setItem",value:function(){var _setItem=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(value){var rs;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return KeyChain.setGenericPassword('kinde',typeof value==='string'?value:JSON.stringify(value));case 2:rs=_context2.sent;return _context2.abrupt("return",Boolean(rs));case 4:case"end":return _context2.stop();}},_callee2);}));function setItem(_x){return _setItem.apply(this,arguments);}return setItem;}()},{key:"clear",value:function clear(){return KeyChain.resetGenericPassword();}}]);}(); \ No newline at end of file diff --git a/dist/SDK/Storage/index.js b/dist/SDK/Storage/index.js index 0be3896..f82633a 100644 --- a/dist/SDK/Storage/index.js +++ b/dist/SDK/Storage/index.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));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 _jwtDecode2=_interopRequireDefault(require("jwt-decode"));var _TokenType=require("../Enums/TokenType.enum");var _Base=_interopRequireDefault(require("./Base"));var _Utils=require("../Utils");var _globalThis$sessionSt;function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof3(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var Storage=function(_BaseStore,_getStorage,_getToken,_setToken,_getTokenType,_getAccessToken,_getIdToken,_getExpiredAt,_clearAll,_getUserProfile){(0,_inherits2["default"])(Storage,_BaseStore);var _super=_createSuper(Storage);function Storage(){(0,_classCallCheck2["default"])(this,Storage);return _super.call(this);}(0,_createClass2["default"])(Storage,[{key:"getStorage",value:function getStorage(){return(_getStorage=_getStorage||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var _builder,builder;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!_Utils.isExpo){_context.next=5;break;}_context.next=3;return Promise.resolve().then(function(){return _interopRequireWildcard(require('./ExpoStorage'));});case 3:_builder=_context.sent;return _context.abrupt("return",new _builder["default"]());case 5:_context.next=7;return Promise.resolve().then(function(){return _interopRequireWildcard(require('./RNStorage'));});case 7:builder=_context.sent;return _context.abrupt("return",new builder["default"]());case 9:case"end":return _context.stop();}},_callee);}))).apply(this,arguments);}},{key:"getToken",value:function getToken(){return(_getToken=_getToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var storage,cred;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return this.getStorage();case 2:storage=_context2.sent;_context2.next=5;return storage.getItem();case 5:cred=_context2.sent;_context2.prev=6;if(!((0,_typeof2["default"])(cred)==='object')){_context2.next=9;break;}return _context2.abrupt("return",cred?JSON.parse(cred.password):null);case 9:return _context2.abrupt("return",cred?JSON.parse(cred):null);case 12:_context2.prev=12;_context2.t0=_context2["catch"](6);return _context2.abrupt("return",null);case 15:case"end":return _context2.stop();}},_callee2,this,[[6,12]]);}))).apply(this,arguments);}},{key:"setToken",value:function setToken(_x){return(_setToken=_setToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(token){var storage;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this.getStorage();case 2:storage=_context3.sent;return _context3.abrupt("return",storage.setItem(token));case 4:case"end":return _context3.stop();}},_callee3,this);}))).apply(this,arguments);}},{key:"getTokenType",value:function getTokenType(_x2){return(_getTokenType=_getTokenType||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(type){var _token$newType;var token,newType;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return this.getToken();case 2:token=_context4.sent;newType=type===_TokenType.TokenType.ID_TOKEN?type:_TokenType.TokenType.ACCESS_TOKEN;return _context4.abrupt("return",(_token$newType=token===null||token===void 0?void 0:token[newType])!==null&&_token$newType!==void 0?_token$newType:null);case 5:case"end":return _context4.stop();}},_callee4,this);}))).apply(this,arguments);}},{key:"getAccessToken",value:function getAccessToken(){return(_getAccessToken=_getAccessToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(){return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:return _context5.abrupt("return",this.getTokenType(_TokenType.TokenType.ACCESS_TOKEN));case 1:case"end":return _context5.stop();}},_callee5,this);}))).apply(this,arguments);}},{key:"getIdToken",value:function getIdToken(){return(_getIdToken=_getIdToken||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:return _context6.abrupt("return",this.getTokenType(_TokenType.TokenType.ID_TOKEN));case 1:case"end":return _context6.stop();}},_callee6,this);}))).apply(this,arguments);}},{key:"getExpiredAt",value:function getExpiredAt(){return(_getExpiredAt=_getExpiredAt||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(){var _jwtDecode;var token;return _regenerator["default"].wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return this.getAccessToken();case 2:token=_context7.sent;return _context7.abrupt("return",token?(_jwtDecode=(0,_jwtDecode2["default"])(token))===null||_jwtDecode===void 0?void 0:_jwtDecode['exp']:0);case 4:case"end":return _context7.stop();}},_callee7,this);}))).apply(this,arguments);}},{key:"getState",value:function getState(){return this.getItem('state');}},{key:"setState",value:function setState(newState){return this.setItem('state',this.convertString(newState));}},{key:"getCodeVerifier",value:function getCodeVerifier(){return this.getItem('codeVerifier');}},{key:"setCodeVerifier",value:function setCodeVerifier(newCodeVerifier){return this.setItem('codeVerifier',this.convertString(newCodeVerifier));}},{key:"clearAll",value:function clearAll(){return(_clearAll=_clearAll||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){var storage;return _regenerator["default"].wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:this.clear();_context8.next=3;return this.getStorage();case 3:storage=_context8.sent;return _context8.abrupt("return",storage.clear());case 5:case"end":return _context8.stop();}},_callee8,this);}))).apply(this,arguments);}},{key:"getUserProfile",value:function getUserProfile(){return(_getUserProfile=_getUserProfile||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){var _payload$sub,_payload$given_name,_payload$family_name,_payload$email,_payload$picture;var token,payload;return _regenerator["default"].wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:_context9.next=2;return this.getIdToken();case 2:token=_context9.sent;payload=token?(0,_jwtDecode2["default"])(token):{};return _context9.abrupt("return",{id:(_payload$sub=payload['sub'])!==null&&_payload$sub!==void 0?_payload$sub:'',given_name:(_payload$given_name=payload['given_name'])!==null&&_payload$given_name!==void 0?_payload$given_name:'',family_name:(_payload$family_name=payload['family_name'])!==null&&_payload$family_name!==void 0?_payload$family_name:'',email:(_payload$email=payload['email'])!==null&&_payload$email!==void 0?_payload$email:'',picture:(_payload$picture=payload['picture'])!==null&&_payload$picture!==void 0?_payload$picture:''});case 5:case"end":return _context9.stop();}},_callee9,this);}))).apply(this,arguments);}},{key:"convertString",value:function convertString(str){return typeof str==='string'?str:JSON.stringify(str);}}]);return Storage;}(_Base["default"]);var sessionStorage=globalThis.sessionStorage=(_globalThis$sessionSt=globalThis.sessionStorage)!==null&&_globalThis$sessionSt!==void 0?_globalThis$sessionSt:new Storage();var _default=sessionStorage;exports["default"]=_default; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _jwtDecode2=_interopRequireDefault(require("jwt-decode"));var _TokenType=require("../Enums/TokenType.enum");var _Base=_interopRequireDefault(require("./Base"));var _Utils=require("../Utils");var _globalThis$sessionSt;function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof3(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var Storage=function(_BaseStore){function Storage(){(0,_classCallCheck2["default"])(this,Storage);return _callSuper(this,Storage);}(0,_inherits2["default"])(Storage,_BaseStore);return(0,_createClass2["default"])(Storage,[{key:"getStorage",value:function(){var _getStorage=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var _builder,builder;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!_Utils.isExpo){_context.next=5;break;}_context.next=3;return Promise.resolve().then(function(){return _interopRequireWildcard(require('./ExpoStorage'));});case 3:_builder=_context.sent;return _context.abrupt("return",new _builder["default"]());case 5:_context.next=7;return Promise.resolve().then(function(){return _interopRequireWildcard(require('./RNStorage'));});case 7:builder=_context.sent;return _context.abrupt("return",new builder["default"]());case 9:case"end":return _context.stop();}},_callee);}));function getStorage(){return _getStorage.apply(this,arguments);}return getStorage;}()},{key:"getToken",value:function(){var _getToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var storage,cred;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return this.getStorage();case 2:storage=_context2.sent;_context2.next=5;return storage.getItem();case 5:cred=_context2.sent;_context2.prev=6;if(!((0,_typeof2["default"])(cred)==='object')){_context2.next=9;break;}return _context2.abrupt("return",cred?JSON.parse(cred.password):null);case 9:return _context2.abrupt("return",cred?JSON.parse(cred):null);case 12:_context2.prev=12;_context2.t0=_context2["catch"](6);return _context2.abrupt("return",null);case 15:case"end":return _context2.stop();}},_callee2,this,[[6,12]]);}));function getToken(){return _getToken.apply(this,arguments);}return getToken;}()},{key:"setToken",value:function(){var _setToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(token){var storage;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this.getStorage();case 2:storage=_context3.sent;return _context3.abrupt("return",storage.setItem(token));case 4:case"end":return _context3.stop();}},_callee3,this);}));function setToken(_x){return _setToken.apply(this,arguments);}return setToken;}()},{key:"getTokenType",value:function(){var _getTokenType=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(type){var _token$newType;var token,newType;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return this.getToken();case 2:token=_context4.sent;newType=type===_TokenType.TokenType.ID_TOKEN?type:_TokenType.TokenType.ACCESS_TOKEN;return _context4.abrupt("return",(_token$newType=token===null||token===void 0?void 0:token[newType])!==null&&_token$newType!==void 0?_token$newType:null);case 5:case"end":return _context4.stop();}},_callee4,this);}));function getTokenType(_x2){return _getTokenType.apply(this,arguments);}return getTokenType;}()},{key:"getAccessToken",value:function(){var _getAccessToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(){return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:return _context5.abrupt("return",this.getTokenType(_TokenType.TokenType.ACCESS_TOKEN));case 1:case"end":return _context5.stop();}},_callee5,this);}));function getAccessToken(){return _getAccessToken.apply(this,arguments);}return getAccessToken;}()},{key:"getIdToken",value:function(){var _getIdToken=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:return _context6.abrupt("return",this.getTokenType(_TokenType.TokenType.ID_TOKEN));case 1:case"end":return _context6.stop();}},_callee6,this);}));function getIdToken(){return _getIdToken.apply(this,arguments);}return getIdToken;}()},{key:"getExpiredAt",value:function(){var _getExpiredAt=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(){var _jwtDecode;var token;return _regenerator["default"].wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:_context7.next=2;return this.getAccessToken();case 2:token=_context7.sent;return _context7.abrupt("return",token?(_jwtDecode=(0,_jwtDecode2["default"])(token))===null||_jwtDecode===void 0?void 0:_jwtDecode['exp']:0);case 4:case"end":return _context7.stop();}},_callee7,this);}));function getExpiredAt(){return _getExpiredAt.apply(this,arguments);}return getExpiredAt;}()},{key:"getState",value:function getState(){return this.getItem('state');}},{key:"setState",value:function setState(newState){return this.setItem('state',this.convertString(newState));}},{key:"getCodeVerifier",value:function getCodeVerifier(){return this.getItem('codeVerifier');}},{key:"setCodeVerifier",value:function setCodeVerifier(newCodeVerifier){return this.setItem('codeVerifier',this.convertString(newCodeVerifier));}},{key:"clearAll",value:function(){var _clearAll=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){var storage;return _regenerator["default"].wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:this.clear();_context8.next=3;return this.getStorage();case 3:storage=_context8.sent;return _context8.abrupt("return",storage.clear());case 5:case"end":return _context8.stop();}},_callee8,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"getUserProfile",value:function(){var _getUserProfile=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){var _payload$sub,_payload$given_name,_payload$family_name,_payload$email,_payload$picture;var token,payload;return _regenerator["default"].wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:_context9.next=2;return this.getIdToken();case 2:token=_context9.sent;payload=token?(0,_jwtDecode2["default"])(token):{};return _context9.abrupt("return",{id:(_payload$sub=payload['sub'])!==null&&_payload$sub!==void 0?_payload$sub:'',given_name:(_payload$given_name=payload['given_name'])!==null&&_payload$given_name!==void 0?_payload$given_name:'',family_name:(_payload$family_name=payload['family_name'])!==null&&_payload$family_name!==void 0?_payload$family_name:'',email:(_payload$email=payload['email'])!==null&&_payload$email!==void 0?_payload$email:'',picture:(_payload$picture=payload['picture'])!==null&&_payload$picture!==void 0?_payload$picture:''});case 5:case"end":return _context9.stop();}},_callee9,this);}));function getUserProfile(){return _getUserProfile.apply(this,arguments);}return getUserProfile;}()},{key:"convertString",value:function convertString(str){return typeof str==='string'?str:JSON.stringify(str);}}]);}(_Base["default"]);var sessionStorage=globalThis.sessionStorage=(_globalThis$sessionSt=globalThis.sessionStorage)!==null&&_globalThis$sessionSt!==void 0?_globalThis$sessionSt:new Storage();var _default=exports["default"]=sessionStorage; \ No newline at end of file diff --git a/dist/SDK/Utils.js b/dist/SDK/Utils.js index 900985a..bad5915 100644 --- a/dist/SDK/Utils.js +++ b/dist/SDK/Utils.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.checkAdditionalParameters=exports.addAdditionalParameters=exports.OpenWebInApp=void 0;exports.checkNotNull=checkNotNull;exports.convertObject2FormData=void 0;exports.generateChallenge=generateChallenge;exports.generateRandomString=generateRandomString;exports.openWebBrowser=exports.isExpo=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _cryptoJs=_interopRequireDefault(require("crypto-js"));var _expoConstants=_interopRequireDefault(require("expo-constants"));var WebBrowser=_interopRequireWildcard(require("expo-web-browser"));var _reactNativeInappbrowserReborn=_interopRequireDefault(require("react-native-inappbrowser-reborn"));var _invalidType=require("../common/exceptions/invalid-type.exception");var _propertyRequired=require("../common/exceptions/property-required.exception");var _unexpected=require("../common/exceptions/unexpected.exception");var _constants=require("./constants");var _ref,_ref2;function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof3(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0&&arguments[0]!==undefined?arguments[0]:32;return base64URLEncode(_cryptoJs["default"].lib.WordArray.random(byteLength));}function generateChallenge(){var state=generateRandomString();var codeVerifier=generateRandomString();var codeChallenge=base64URLEncode(sha256(codeVerifier));return{state:state,codeVerifier:codeVerifier,codeChallenge:codeChallenge};}function checkNotNull(reference,name){if(reference===null||reference===undefined){throw new _propertyRequired.PropertyRequiredException(name);}return reference;}var getValueByKey=function getValueByKey(obj,key){return obj[key];};var checkAdditionalParameters=function checkAdditionalParameters(){var additionalParameters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if((0,_typeof2["default"])(additionalParameters)!=='object'){throw new _unexpected.UnexpectedException('additionalParameters');}var keyExists=Object.keys(additionalParameters);if(keyExists.length){var keysAllow=Object.keys(_constants.AdditionalParametersAllow);var _iterator=_createForOfIteratorHelper(keyExists),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var key=_step.value;if(!keysAllow.includes(key)){throw new _unexpected.UnexpectedException(key);}if((0,_typeof2["default"])(additionalParameters[key])!==_constants.AdditionalParametersAllow[key]){throw new _invalidType.InvalidTypeException(key,getValueByKey(_constants.AdditionalParametersAllow,key));}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return additionalParameters;}return{};};exports.checkAdditionalParameters=checkAdditionalParameters;var addAdditionalParameters=function addAdditionalParameters(target){var additionalParameters=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var keyExists=Object.keys(additionalParameters);if(keyExists.length){keyExists.forEach(function(key){target[key]=getValueByKey(additionalParameters,key);});}return target;};exports.addAdditionalParameters=addAdditionalParameters;var isExpo=_expoConstants["default"].executionEnvironment!==undefined;exports.isExpo=isExpo;var OpenWebInApp=function OpenWebInApp(_x,_x2,_x3){return(_ref=_ref||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(url,kindeSDK,options){var response;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return openWebBrowser(url,kindeSDK.redirectUri,options||kindeSDK.authBrowserOptions);case 3:response=_context.sent;if(!(response.type==='success'&&response.url)){_context.next=6;break;}return _context.abrupt("return",kindeSDK.getToken(response.url));case 6:console.error('Something wrong when trying to authenticating. Reason: ',response.type);return _context.abrupt("return",null);case 10:_context.prev=10;_context.t0=_context["catch"](0);console.error('Something wrong when trying to authenticating. Reason: ',_context.t0.message);return _context.abrupt("return",null);case 14:case"end":return _context.stop();}},_callee,null,[[0,10]]);}))).apply(this,arguments);};exports.OpenWebInApp=OpenWebInApp;var openWebBrowser=function openWebBrowser(_x4,_x5,_x6){return(_ref2=_ref2||(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(url,redirectUri,options){return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!isExpo){_context2.next=2;break;}return _context2.abrupt("return",WebBrowser.openAuthSessionAsync(url,redirectUri,options));case 2:if(!_reactNativeInappbrowserReborn["default"]){_context2.next=7;break;}_context2.next=5;return _reactNativeInappbrowserReborn["default"].isAvailable();case 5:if(!_context2.sent){_context2.next=7;break;}return _context2.abrupt("return",_reactNativeInappbrowserReborn["default"].openAuth(url,redirectUri,Object.assign({ephemeralWebSession:false,showTitle:false,enableUrlBarHiding:true,enableDefaultShare:false,forceCloseOnRedirection:false,showInRecents:true},options)));case 7:throw new Error('Not found web browser');case 8:case"end":return _context2.stop();}},_callee2);}))).apply(this,arguments);};exports.openWebBrowser=openWebBrowser;var convertObject2FormData=function convertObject2FormData(obj){var formData=new FormData();Object.keys(obj).forEach(function(k){formData.append(k,obj[k]);});return formData;};exports.convertObject2FormData=convertObject2FormData; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.checkAdditionalParameters=exports.addAdditionalParameters=exports.OpenWebInApp=void 0;exports.checkNotNull=checkNotNull;exports.convertObject2FormData=void 0;exports.generateChallenge=generateChallenge;exports.generateRandomString=generateRandomString;exports.openWebBrowser=exports.isExpo=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _cryptoJs=_interopRequireDefault(require("crypto-js"));var _expoConstants=_interopRequireDefault(require("expo-constants"));var WebBrowser=_interopRequireWildcard(require("expo-web-browser"));var _reactNativeInappbrowserReborn=_interopRequireDefault(require("react-native-inappbrowser-reborn"));var _invalidType=require("../common/exceptions/invalid-type.exception");var _propertyRequired=require("../common/exceptions/property-required.exception");var _unexpected=require("../common/exceptions/unexpected.exception");var _constants=require("./constants");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof3(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0&&arguments[0]!==undefined?arguments[0]:32;return base64URLEncode(_cryptoJs["default"].lib.WordArray.random(byteLength));}function generateChallenge(){var state=generateRandomString();var codeVerifier=generateRandomString();var codeChallenge=base64URLEncode(sha256(codeVerifier));return{state:state,codeVerifier:codeVerifier,codeChallenge:codeChallenge};}function checkNotNull(reference,name){if(reference===null||reference===undefined){throw new _propertyRequired.PropertyRequiredException(name);}return reference;}var getValueByKey=function getValueByKey(obj,key){return obj[key];};var checkAdditionalParameters=exports.checkAdditionalParameters=function checkAdditionalParameters(){var additionalParameters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if((0,_typeof2["default"])(additionalParameters)!=='object'){throw new _unexpected.UnexpectedException('additionalParameters');}var keyExists=Object.keys(additionalParameters);if(keyExists.length){var keysAllow=Object.keys(_constants.AdditionalParametersAllow);var _iterator=_createForOfIteratorHelper(keyExists),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var key=_step.value;if(!keysAllow.includes(key)){throw new _unexpected.UnexpectedException(key);}if((0,_typeof2["default"])(additionalParameters[key])!==_constants.AdditionalParametersAllow[key]){throw new _invalidType.InvalidTypeException(key,getValueByKey(_constants.AdditionalParametersAllow,key));}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return additionalParameters;}return{};};var addAdditionalParameters=exports.addAdditionalParameters=function addAdditionalParameters(target){var additionalParameters=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var keyExists=Object.keys(additionalParameters);if(keyExists.length){keyExists.forEach(function(key){target[key]=getValueByKey(additionalParameters,key);});}return target;};var isExpo=exports.isExpo=_expoConstants["default"].executionEnvironment!==undefined;var OpenWebInApp=exports.OpenWebInApp=function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(url,kindeSDK,options){var response;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return openWebBrowser(url,kindeSDK.redirectUri,options||kindeSDK.authBrowserOptions);case 3:response=_context.sent;if(!(response.type==='success'&&response.url)){_context.next=6;break;}return _context.abrupt("return",kindeSDK.getToken(response.url));case 6:console.error('Something wrong when trying to authenticating. Reason: ',response.type);return _context.abrupt("return",null);case 10:_context.prev=10;_context.t0=_context["catch"](0);console.error('Something wrong when trying to authenticating. Reason: ',_context.t0.message);return _context.abrupt("return",null);case 14:case"end":return _context.stop();}},_callee,null,[[0,10]]);}));return function OpenWebInApp(_x,_x2,_x3){return _ref.apply(this,arguments);};}();var openWebBrowser=exports.openWebBrowser=function(){var _ref2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(url,redirectUri,options){return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!isExpo){_context2.next=2;break;}return _context2.abrupt("return",WebBrowser.openAuthSessionAsync(url,redirectUri,options));case 2:if(!_reactNativeInappbrowserReborn["default"]){_context2.next=7;break;}_context2.next=5;return _reactNativeInappbrowserReborn["default"].isAvailable();case 5:if(!_context2.sent){_context2.next=7;break;}return _context2.abrupt("return",_reactNativeInappbrowserReborn["default"].openAuth(url,redirectUri,Object.assign({ephemeralWebSession:false,showTitle:false,enableUrlBarHiding:true,enableDefaultShare:false,forceCloseOnRedirection:false,showInRecents:true},options)));case 7:throw new Error('Not found web browser');case 8:case"end":return _context2.stop();}},_callee2);}));return function openWebBrowser(_x4,_x5,_x6){return _ref2.apply(this,arguments);};}();var convertObject2FormData=exports.convertObject2FormData=function convertObject2FormData(obj){var formData=new FormData();Object.keys(obj).forEach(function(k){formData.append(k,obj[k]);});return formData;}; \ No newline at end of file diff --git a/dist/SDK/constants/index.js b/dist/SDK/constants/index.js index 0e8b86f..e25756c 100644 --- a/dist/SDK/constants/index.js +++ b/dist/SDK/constants/index.js @@ -1 +1 @@ -Object.defineProperty(exports,"__esModule",{value:true});exports.FLAG_TYPE=exports.AdditionalParametersAllow=void 0;var AdditionalParametersAllow={audience:'string',is_create_org:'boolean',org_code:'string',org_name:'string'};exports.AdditionalParametersAllow=AdditionalParametersAllow;var FLAG_TYPE={s:'string',i:'number',b:'boolean'};exports.FLAG_TYPE=FLAG_TYPE; \ No newline at end of file +Object.defineProperty(exports,"__esModule",{value:true});exports.FLAG_TYPE=exports.AdditionalParametersAllow=void 0;var AdditionalParametersAllow=exports.AdditionalParametersAllow={audience:'string',is_create_org:'boolean',org_code:'string',org_name:'string'};var FLAG_TYPE=exports.FLAG_TYPE={s:'string',i:'number',b:'boolean'}; \ No newline at end of file diff --git a/dist/common/exceptions/invalid-type.exception.js b/dist/common/exceptions/invalid-type.exception.js index e582e43..426bee4 100644 --- a/dist/common/exceptions/invalid-type.exception.js +++ b/dist/common/exceptions/invalid-type.exception.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.InvalidTypeException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var InvalidTypeException=function(_Error){(0,_inherits2["default"])(InvalidTypeException,_Error);var _super=_createSuper(InvalidTypeException);function InvalidTypeException(result,expected){var _this;(0,_classCallCheck2["default"])(this,InvalidTypeException);_this=_super.call(this,"InvalidType "+result+". Expected: "+expected);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"name",void 0);_this.name='InvalidTypeException';return _this;}return(0,_createClass2["default"])(InvalidTypeException);}((0,_wrapNativeSuper2["default"])(Error));exports.InvalidTypeException=InvalidTypeException; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.InvalidTypeException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var InvalidTypeException=exports.InvalidTypeException=function(_Error){function InvalidTypeException(result,expected){var _this;(0,_classCallCheck2["default"])(this,InvalidTypeException);_this=_callSuper(this,InvalidTypeException,["InvalidType "+result+". Expected: "+expected]);(0,_defineProperty2["default"])(_this,"name",void 0);_this.name='InvalidTypeException';return _this;}(0,_inherits2["default"])(InvalidTypeException,_Error);return(0,_createClass2["default"])(InvalidTypeException);}((0,_wrapNativeSuper2["default"])(Error)); \ No newline at end of file diff --git a/dist/common/exceptions/property-required.exception.js b/dist/common/exceptions/property-required.exception.js index 3becb4a..4b4166c 100644 --- a/dist/common/exceptions/property-required.exception.js +++ b/dist/common/exceptions/property-required.exception.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PropertyRequiredException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var PropertyRequiredException=function(_Error){(0,_inherits2["default"])(PropertyRequiredException,_Error);var _super=_createSuper(PropertyRequiredException);function PropertyRequiredException(msg){var _this;(0,_classCallCheck2["default"])(this,PropertyRequiredException);_this=_super.call(this,msg+" cannot be empty");(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"name",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"property",void 0);_this.name='PropertyRequiredException';_this.property=msg;return _this;}return(0,_createClass2["default"])(PropertyRequiredException);}((0,_wrapNativeSuper2["default"])(Error));exports.PropertyRequiredException=PropertyRequiredException; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PropertyRequiredException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var PropertyRequiredException=exports.PropertyRequiredException=function(_Error){function PropertyRequiredException(msg){var _this;(0,_classCallCheck2["default"])(this,PropertyRequiredException);_this=_callSuper(this,PropertyRequiredException,[msg+" cannot be empty"]);(0,_defineProperty2["default"])(_this,"name",void 0);(0,_defineProperty2["default"])(_this,"property",void 0);_this.name='PropertyRequiredException';_this.property=msg;return _this;}(0,_inherits2["default"])(PropertyRequiredException,_Error);return(0,_createClass2["default"])(PropertyRequiredException);}((0,_wrapNativeSuper2["default"])(Error)); \ No newline at end of file diff --git a/dist/common/exceptions/unauthenticated.exception.js b/dist/common/exceptions/unauthenticated.exception.js index 54db6b6..6ad59e2 100644 --- a/dist/common/exceptions/unauthenticated.exception.js +++ b/dist/common/exceptions/unauthenticated.exception.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.UnAuthenticatedException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var UnAuthenticatedException=function(_Error){(0,_inherits2["default"])(UnAuthenticatedException,_Error);var _super=_createSuper(UnAuthenticatedException);function UnAuthenticatedException(msg){var _this;(0,_classCallCheck2["default"])(this,UnAuthenticatedException);_this=_super.call(this,msg!==null&&msg!==void 0?msg:'Request is missing required authentication credential');(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"name",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"property",void 0);_this.name='UnAuthenticatedException';_this.property=msg!==null&&msg!==void 0?msg:'Request is missing required authentication credential';return _this;}return(0,_createClass2["default"])(UnAuthenticatedException);}((0,_wrapNativeSuper2["default"])(Error));exports.UnAuthenticatedException=UnAuthenticatedException; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.UnAuthenticatedException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var UnAuthenticatedException=exports.UnAuthenticatedException=function(_Error){function UnAuthenticatedException(msg){var _this;(0,_classCallCheck2["default"])(this,UnAuthenticatedException);_this=_callSuper(this,UnAuthenticatedException,[msg!==null&&msg!==void 0?msg:'Request is missing required authentication credential']);(0,_defineProperty2["default"])(_this,"name",void 0);(0,_defineProperty2["default"])(_this,"property",void 0);_this.name='UnAuthenticatedException';_this.property=msg!==null&&msg!==void 0?msg:'Request is missing required authentication credential';return _this;}(0,_inherits2["default"])(UnAuthenticatedException,_Error);return(0,_createClass2["default"])(UnAuthenticatedException);}((0,_wrapNativeSuper2["default"])(Error)); \ No newline at end of file diff --git a/dist/common/exceptions/unexpected.exception.js b/dist/common/exceptions/unexpected.exception.js index ed93d47..cdbf19a 100644 --- a/dist/common/exceptions/unexpected.exception.js +++ b/dist/common/exceptions/unexpected.exception.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.UnexpectedException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));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 _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2["default"])(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var UnexpectedException=function(_Error){(0,_inherits2["default"])(UnexpectedException,_Error);var _super=_createSuper(UnexpectedException);function UnexpectedException(msg){var _this;(0,_classCallCheck2["default"])(this,UnexpectedException);_this=_super.call(this,"Unexpected "+msg);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"name",void 0);(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"property",void 0);_this.name='UnexpectedException';_this.property=msg;return _this;}return(0,_createClass2["default"])(UnexpectedException);}((0,_wrapNativeSuper2["default"])(Error));exports.UnexpectedException=UnexpectedException; \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.UnexpectedException=void 0;var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _wrapNativeSuper2=_interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var UnexpectedException=exports.UnexpectedException=function(_Error){function UnexpectedException(msg){var _this;(0,_classCallCheck2["default"])(this,UnexpectedException);_this=_callSuper(this,UnexpectedException,["Unexpected "+msg]);(0,_defineProperty2["default"])(_this,"name",void 0);(0,_defineProperty2["default"])(_this,"property",void 0);_this.name='UnexpectedException';_this.property=msg;return _this;}(0,_inherits2["default"])(UnexpectedException,_Error);return(0,_createClass2["default"])(UnexpectedException);}((0,_wrapNativeSuper2["default"])(Error)); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index c010ce9..4fe37ef 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={KindeSDK:true,Storage:true,ApiClient:true};exports.ApiClient=void 0;Object.defineProperty(exports,"KindeSDK",{enumerable:true,get:function get(){return _KindeSDK["default"];}});Object.defineProperty(exports,"Storage",{enumerable:true,get:function get(){return _Storage["default"];}});var _KindeSDK=_interopRequireDefault(require("./SDK/KindeSDK"));var _Storage=_interopRequireDefault(require("./SDK/Storage"));var ApiClient=_interopRequireWildcard(require("./ApiClient"));exports.ApiClient=ApiClient;var _Enums=require("./SDK/Enums");Object.keys(_Enums).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_Enums[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _Enums[key];}});});var _Utils=require("./SDK/Utils");Object.keys(_Utils).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_Utils[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _Utils[key];}});});var _KindeSDK2=require("./types/KindeSDK");Object.keys(_KindeSDK2).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_KindeSDK2[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _KindeSDK2[key];}});});function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj);}return newObj;} \ No newline at end of file +var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={KindeSDK:true,Storage:true,ApiClient:true};exports.ApiClient=void 0;Object.defineProperty(exports,"KindeSDK",{enumerable:true,get:function get(){return _KindeSDK["default"];}});Object.defineProperty(exports,"Storage",{enumerable:true,get:function get(){return _Storage["default"];}});var _KindeSDK=_interopRequireDefault(require("./SDK/KindeSDK"));var _Storage=_interopRequireDefault(require("./SDK/Storage"));var ApiClient=_interopRequireWildcard(require("./ApiClient"));exports.ApiClient=ApiClient;var _Enums=require("./SDK/Enums");Object.keys(_Enums).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_Enums[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _Enums[key];}});});var _Utils=require("./SDK/Utils");Object.keys(_Utils).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_Utils[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _Utils[key];}});});var _KindeSDK2=require("./types/KindeSDK");Object.keys(_KindeSDK2).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_KindeSDK2[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _KindeSDK2[key];}});});function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return{"default":e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n["default"]=e,t&&t.set(e,n),n;} \ No newline at end of file diff --git a/package.json b/package.json index 357de0e..71821cb 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,14 @@ "dependencies": { "@babel/runtime": "^7.19.4", "crypto-js": "3.3.0", - "expo-constants": "^14.2.1", + "expo-constants": "^15.4.5", + "expo-manifests": "^0.13.2", "expo-modules-core": "^1.2.6", - "expo-web-browser": "12.1.1", - "expo-secure-store": "^12.1.1", + "expo-secure-store": "*", + "expo-web-browser": "*", "jwt-decode": "^3.1.2", "qs": "^6.11.0", - "react-native-inappbrowser-reborn": "^3.7.0", + "react-native-inappbrowser-reborn": ">= 3.7", "react-native-keychain": ">= 8.0", "superagent": "^7.0.2", "url-parse": "^1.5.10" @@ -92,10 +93,10 @@ }, "peerDependencies": { "expo-secure-store": "*", - "react-native": ">= 0.70", - "react-native-keychain": ">= 8.0", "expo-web-browser": "*", - "react-native-inappbrowser-reborn": ">= 3.7" + "react-native": ">= 0.70", + "react-native-inappbrowser-reborn": ">= 3.7", + "react-native-keychain": ">= 8.0" }, "files": [ "dist"