"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/defineProperty"),a=require("@babel/runtime/regenerator"),u=require("@badgateway/oauth2-client"),i=require("../jsonApi/index.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(e),c=o(t),l=o(r),d=o(n),f=o(a),p=new(c.default((function e(){var t,r=this;l.default(this,e),d.default(this,"configure",(function(e){r.options=e,r.handler=new u.OAuth2Client(r.options)})),d.default(this,"authorize",(t=s.default(f.default.mark((function e(t){var n,a;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.options.redirectUri,a=r.options.scope||t,e.next=4,r.handler.authorizationCode.getAuthorizeUri({redirectUri:n,scope:a});case 4:document.location=e.sent;case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})),d.default(this,"authenticate",s.default(f.default.mark((function e(){var t,r,n,a;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URL(document.location).searchParams,r=t.get("code"),e.next=4,i.postUserAuthTokenExchange("oauth2",r);case 4:return n=e.sent,a=n.token,e.abrupt("return",a.access_token);case 7:case"end":return e.stop()}}),e)}))))})));exports.provider=p;
