import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/createClass";import t from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/regenerator";import{OAuth2Client as a}from"@badgateway/oauth2-client";import{postUserAuthTokenExchange as i}from"../jsonApi/index.js";var s=new(r((function r(){var s,c=this;t(this,r),n(this,"configure",(function(e){c.options=e,c.handler=new a(c.options)})),n(this,"authorize",(s=e(o.mark((function e(r){var t,n;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.options.redirectUri,n=c.options.scope||r,e.next=4,c.handler.authorizationCode.getAuthorizeUri({redirectUri:t,scope:n});case 4:document.location=e.sent;case 5:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})),n(this,"authenticate",e(o.mark((function e(){var r,t,n,a;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL(document.location).searchParams,t=r.get("code"),e.next=4,i("oauth2",t);case 4:return n=e.sent,a=n.token,e.abrupt("return",a.access_token);case 7:case"end":return e.stop()}}),e)}))))})));export{s as provider};
//# sourceMappingURL=oauth2.js.map
