@opencampus/ocid-connect-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -0
- package/dist/ocid-connect-js.js +1738 -0
- package/dist/ocid-connect-js.js.map +1 -0
- package/lib/index.js +27 -0
- package/lib/react/LoginButton.js +125 -0
- package/lib/react/LoginCallBack.js +92 -0
- package/lib/react/OCConnect.js +66 -0
- package/lib/react/OCContext.js +24 -0
- package/lib/react/OCLogo.js +50 -0
- package/lib/react/index.js +44 -0
- package/lib/sdk/auth.js +225 -0
- package/lib/sdk/crypto/base64.js +46 -0
- package/lib/sdk/crypto/index.js +38 -0
- package/lib/sdk/crypto/verifyToken.js +63 -0
- package/lib/sdk/crypto/webcrypto.js +25 -0
- package/lib/sdk/endpoints/buildAuthEndpointUrl.js +32 -0
- package/lib/sdk/endpoints/index.js +16 -0
- package/lib/sdk/index.js +27 -0
- package/lib/sdk/lib/AuthInfoManager.js +55 -0
- package/lib/sdk/lib/StorageManager.js +118 -0
- package/lib/sdk/lib/TokenManager.js +164 -0
- package/lib/sdk/lib/TransactionManager.js +63 -0
- package/lib/sdk/lib/index.js +36 -0
- package/lib/sdk/lib/pkce.js +51 -0
- package/lib/sdk/utils/createPkceMeta.js +32 -0
- package/lib/sdk/utils/errors.js +55 -0
- package/lib/sdk/utils/index.js +49 -0
- package/lib/sdk/utils/jwtParser.js +24 -0
- package/lib/sdk/utils/prepareTokenParams.js +67 -0
- package/lib/sdk/utils/urlParser.js +24 -0
- package/package.json +81 -0
|
@@ -0,0 +1,1738 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("react"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["react"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["Slider"] = factory(require("react"));
|
|
8
|
+
else
|
|
9
|
+
root["Slider"] = factory(root["react"]);
|
|
10
|
+
})(window, function(__WEBPACK_EXTERNAL_MODULE__3__) {
|
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
+
/******/ // The module cache
|
|
13
|
+
/******/ var installedModules = {};
|
|
14
|
+
/******/
|
|
15
|
+
/******/ // The require function
|
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
|
17
|
+
/******/
|
|
18
|
+
/******/ // Check if module is in cache
|
|
19
|
+
/******/ if(installedModules[moduleId]) {
|
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
|
21
|
+
/******/ }
|
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
|
24
|
+
/******/ i: moduleId,
|
|
25
|
+
/******/ l: false,
|
|
26
|
+
/******/ exports: {}
|
|
27
|
+
/******/ };
|
|
28
|
+
/******/
|
|
29
|
+
/******/ // Execute the module function
|
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
+
/******/
|
|
32
|
+
/******/ // Flag the module as loaded
|
|
33
|
+
/******/ module.l = true;
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // Return the exports of the module
|
|
36
|
+
/******/ return module.exports;
|
|
37
|
+
/******/ }
|
|
38
|
+
/******/
|
|
39
|
+
/******/
|
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
+
/******/ __webpack_require__.m = modules;
|
|
42
|
+
/******/
|
|
43
|
+
/******/ // expose the module cache
|
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
|
45
|
+
/******/
|
|
46
|
+
/******/ // define getter function for harmony exports
|
|
47
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
48
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
49
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
50
|
+
/******/ }
|
|
51
|
+
/******/ };
|
|
52
|
+
/******/
|
|
53
|
+
/******/ // define __esModule on exports
|
|
54
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
55
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
56
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
57
|
+
/******/ }
|
|
58
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
59
|
+
/******/ };
|
|
60
|
+
/******/
|
|
61
|
+
/******/ // create a fake namespace object
|
|
62
|
+
/******/ // mode & 1: value is a module id, require it
|
|
63
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
64
|
+
/******/ // mode & 4: return value when already ns object
|
|
65
|
+
/******/ // mode & 8|1: behave like require
|
|
66
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
67
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
68
|
+
/******/ if(mode & 8) return value;
|
|
69
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
70
|
+
/******/ var ns = Object.create(null);
|
|
71
|
+
/******/ __webpack_require__.r(ns);
|
|
72
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
73
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
74
|
+
/******/ return ns;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
78
|
+
/******/ __webpack_require__.n = function(module) {
|
|
79
|
+
/******/ var getter = module && module.__esModule ?
|
|
80
|
+
/******/ function getDefault() { return module['default']; } :
|
|
81
|
+
/******/ function getModuleExports() { return module; };
|
|
82
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
83
|
+
/******/ return getter;
|
|
84
|
+
/******/ };
|
|
85
|
+
/******/
|
|
86
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
87
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
88
|
+
/******/
|
|
89
|
+
/******/ // __webpack_public_path__
|
|
90
|
+
/******/ __webpack_require__.p = "";
|
|
91
|
+
/******/
|
|
92
|
+
/******/
|
|
93
|
+
/******/ // Load entry module and return exports
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
|
95
|
+
/******/ })
|
|
96
|
+
/************************************************************************/
|
|
97
|
+
/******/ ([
|
|
98
|
+
/* 0 */
|
|
99
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
100
|
+
|
|
101
|
+
"use strict";
|
|
102
|
+
__webpack_require__.r(__webpack_exports__);
|
|
103
|
+
/* harmony import */ var _react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
104
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoginButton", function() { return _react__WEBPACK_IMPORTED_MODULE_0__["LoginButton"]; });
|
|
105
|
+
|
|
106
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoginCallBack", function() { return _react__WEBPACK_IMPORTED_MODULE_0__["LoginCallBack"]; });
|
|
107
|
+
|
|
108
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCConnect", function() { return _react__WEBPACK_IMPORTED_MODULE_0__["OCConnect"]; });
|
|
109
|
+
|
|
110
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCContext", function() { return _react__WEBPACK_IMPORTED_MODULE_0__["OCContext"]; });
|
|
111
|
+
|
|
112
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useOCAuth", function() { return _react__WEBPACK_IMPORTED_MODULE_0__["useOCAuth"]; });
|
|
113
|
+
|
|
114
|
+
/* harmony import */ var _sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(25);
|
|
115
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TokenManager", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["TokenManager"]; });
|
|
116
|
+
|
|
117
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["TransactionManager"]; });
|
|
118
|
+
|
|
119
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseStorageManager", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["BaseStorageManager"]; });
|
|
120
|
+
|
|
121
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LocalStorageManager", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["LocalStorageManager"]; });
|
|
122
|
+
|
|
123
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthCore", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["OCAuthCore"]; });
|
|
124
|
+
|
|
125
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthLive", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["OCAuthLive"]; });
|
|
126
|
+
|
|
127
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthSandbox", function() { return _sdk__WEBPACK_IMPORTED_MODULE_1__["OCAuthSandbox"]; });
|
|
128
|
+
|
|
129
|
+
/*!
|
|
130
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
131
|
+
*
|
|
132
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
133
|
+
*
|
|
134
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
135
|
+
*
|
|
136
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
/***/ }),
|
|
142
|
+
/* 1 */
|
|
143
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
144
|
+
|
|
145
|
+
"use strict";
|
|
146
|
+
__webpack_require__.r(__webpack_exports__);
|
|
147
|
+
/* harmony import */ var _LoginButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
|
148
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoginButton", function() { return _LoginButton__WEBPACK_IMPORTED_MODULE_0__["default"]; });
|
|
149
|
+
|
|
150
|
+
/* harmony import */ var _LoginCallBack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
|
|
151
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoginCallBack", function() { return _LoginCallBack__WEBPACK_IMPORTED_MODULE_1__["default"]; });
|
|
152
|
+
|
|
153
|
+
/* harmony import */ var _OCConnect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
154
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCConnect", function() { return _OCConnect__WEBPACK_IMPORTED_MODULE_2__["default"]; });
|
|
155
|
+
|
|
156
|
+
/* harmony import */ var _OCContext__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
157
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCContext", function() { return _OCContext__WEBPACK_IMPORTED_MODULE_3__["OCContext"]; });
|
|
158
|
+
|
|
159
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useOCAuth", function() { return _OCContext__WEBPACK_IMPORTED_MODULE_3__["useOCAuth"]; });
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
/***/ }),
|
|
167
|
+
/* 2 */
|
|
168
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
169
|
+
|
|
170
|
+
"use strict";
|
|
171
|
+
__webpack_require__.r(__webpack_exports__);
|
|
172
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return LoginButton; });
|
|
173
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
174
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
175
|
+
/* harmony import */ var _OCContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
176
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
177
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
178
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
179
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
180
|
+
/*!
|
|
181
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
182
|
+
*
|
|
183
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
184
|
+
*
|
|
185
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
186
|
+
*
|
|
187
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
188
|
+
*/
|
|
189
|
+
/* eslint-disable react/no-unknown-property */
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
var lightTheme = {
|
|
193
|
+
background: "#000",
|
|
194
|
+
color: "#fff",
|
|
195
|
+
button: {
|
|
196
|
+
background: "#FFF",
|
|
197
|
+
border: "#DDDDEB",
|
|
198
|
+
color: "#C5C5D1",
|
|
199
|
+
colorSuccess: "#8F8FB2"
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
var darkTheme = {
|
|
203
|
+
background: "#fff",
|
|
204
|
+
color: "#000",
|
|
205
|
+
button: {
|
|
206
|
+
background: "#141414",
|
|
207
|
+
border: "#DDDDEB",
|
|
208
|
+
color: "#FFFFFF",
|
|
209
|
+
colorSuccess: "#ADADB8"
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var neutralTheme = {
|
|
213
|
+
background: "#fff",
|
|
214
|
+
color: "#000",
|
|
215
|
+
button: {
|
|
216
|
+
background: "#F5F5F5",
|
|
217
|
+
border: "#DDDDEB",
|
|
218
|
+
color: "#141414",
|
|
219
|
+
colorSuccess: "#8F8FB2"
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
var ocBlueTheme = {
|
|
223
|
+
background: "#fff",
|
|
224
|
+
color: "#000",
|
|
225
|
+
button: {
|
|
226
|
+
background: "#141BEB",
|
|
227
|
+
border: "#DDDDEB",
|
|
228
|
+
color: "#FFFFFF",
|
|
229
|
+
colorSuccess: "#9699EB"
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
var themes = {
|
|
233
|
+
light: lightTheme,
|
|
234
|
+
dark: darkTheme,
|
|
235
|
+
neutral: neutralTheme,
|
|
236
|
+
ocBlue: ocBlueTheme
|
|
237
|
+
};
|
|
238
|
+
var genStyle = function genStyle(theme) {
|
|
239
|
+
var pill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
240
|
+
return {
|
|
241
|
+
display: "flex",
|
|
242
|
+
alignItems: "center",
|
|
243
|
+
height: 44,
|
|
244
|
+
width: 160,
|
|
245
|
+
padding: "10px 12px",
|
|
246
|
+
fontSize: 14,
|
|
247
|
+
border: "1px solid",
|
|
248
|
+
borderColor: theme.button.border,
|
|
249
|
+
borderRadius: pill ? 40 : 8,
|
|
250
|
+
background: theme.button.background,
|
|
251
|
+
color: theme.button.color
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
function LoginButton(_ref) {
|
|
255
|
+
var pill = _ref.pill,
|
|
256
|
+
disabled = _ref.disabled,
|
|
257
|
+
theme = _ref.theme;
|
|
258
|
+
var _useOCAuth = Object(_OCContext__WEBPACK_IMPORTED_MODULE_1__["useOCAuth"])(),
|
|
259
|
+
ocAuth = _useOCAuth.ocAuth;
|
|
260
|
+
var customTheme = themes[theme] || themes['ocBlue'];
|
|
261
|
+
var loginWithRedirect = /*#__PURE__*/function () {
|
|
262
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
263
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
264
|
+
while (1) switch (_context.prev = _context.next) {
|
|
265
|
+
case 0:
|
|
266
|
+
_context.next = 2;
|
|
267
|
+
return ocAuth.signInWithRedirect({
|
|
268
|
+
state: 'opencampus'
|
|
269
|
+
});
|
|
270
|
+
case 2:
|
|
271
|
+
case "end":
|
|
272
|
+
return _context.stop();
|
|
273
|
+
}
|
|
274
|
+
}, _callee);
|
|
275
|
+
}));
|
|
276
|
+
return function loginWithRedirect() {
|
|
277
|
+
return _ref2.apply(this, arguments);
|
|
278
|
+
};
|
|
279
|
+
}();
|
|
280
|
+
var style = genStyle(customTheme, pill);
|
|
281
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button", {
|
|
282
|
+
disabled: disabled,
|
|
283
|
+
onClick: loginWithRedirect,
|
|
284
|
+
style: style
|
|
285
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("img", {
|
|
286
|
+
alt: "logo",
|
|
287
|
+
src: "https://static.opencampus.xyz/assets/oc_logo.svg",
|
|
288
|
+
width: "26px",
|
|
289
|
+
height: "25px"
|
|
290
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", {
|
|
291
|
+
style: {
|
|
292
|
+
marginLeft: "10px"
|
|
293
|
+
}
|
|
294
|
+
}, "Connect\xA0", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("strong", null, "OCID")));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/***/ }),
|
|
298
|
+
/* 3 */
|
|
299
|
+
/***/ (function(module, exports) {
|
|
300
|
+
|
|
301
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
|
|
302
|
+
|
|
303
|
+
/***/ }),
|
|
304
|
+
/* 4 */
|
|
305
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
306
|
+
|
|
307
|
+
"use strict";
|
|
308
|
+
__webpack_require__.r(__webpack_exports__);
|
|
309
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OCContext", function() { return OCContext; });
|
|
310
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "useOCAuth", function() { return useOCAuth; });
|
|
311
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
312
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
313
|
+
/*!
|
|
314
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
315
|
+
*
|
|
316
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
317
|
+
*
|
|
318
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
319
|
+
*
|
|
320
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
var OCContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createContext"](null);
|
|
324
|
+
var useOCAuth = function useOCAuth() {
|
|
325
|
+
return react__WEBPACK_IMPORTED_MODULE_0__["useContext"](OCContext);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/***/ }),
|
|
329
|
+
/* 5 */
|
|
330
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
331
|
+
|
|
332
|
+
"use strict";
|
|
333
|
+
__webpack_require__.r(__webpack_exports__);
|
|
334
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
335
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
336
|
+
/* harmony import */ var _OCContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
337
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
338
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
339
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
340
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
341
|
+
/*!
|
|
342
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
343
|
+
*
|
|
344
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
345
|
+
*
|
|
346
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
347
|
+
*
|
|
348
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
var handledRedirect = false;
|
|
353
|
+
var LoginCallBack = function LoginCallBack(_ref) {
|
|
354
|
+
var successCallback = _ref.successCallback,
|
|
355
|
+
errorCallback = _ref.errorCallback,
|
|
356
|
+
customErrorComponent = _ref.customErrorComponent,
|
|
357
|
+
customLoadingComponent = _ref.customLoadingComponent;
|
|
358
|
+
var _useOCAuth = Object(_OCContext__WEBPACK_IMPORTED_MODULE_1__["useOCAuth"])(),
|
|
359
|
+
ocAuth = _useOCAuth.ocAuth,
|
|
360
|
+
authState = _useOCAuth.authState,
|
|
361
|
+
updateAuthState = _useOCAuth.updateAuthState;
|
|
362
|
+
Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () {
|
|
363
|
+
var handleLogin = /*#__PURE__*/function () {
|
|
364
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
365
|
+
var _authState;
|
|
366
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
367
|
+
while (1) switch (_context.prev = _context.next) {
|
|
368
|
+
case 0:
|
|
369
|
+
if (!ocAuth) {
|
|
370
|
+
_context.next = 12;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
_context.prev = 1;
|
|
374
|
+
_context.next = 4;
|
|
375
|
+
return ocAuth.handleLoginRedirect();
|
|
376
|
+
case 4:
|
|
377
|
+
_authState = _context.sent;
|
|
378
|
+
if (_authState.idToken) {
|
|
379
|
+
updateAuthState(_authState);
|
|
380
|
+
handledRedirect = true;
|
|
381
|
+
successCallback();
|
|
382
|
+
} else {
|
|
383
|
+
updateAuthState({
|
|
384
|
+
error: 'missing idToken from redirect callback'
|
|
385
|
+
});
|
|
386
|
+
if (errorCallback) {
|
|
387
|
+
errorCallback();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
_context.next = 12;
|
|
391
|
+
break;
|
|
392
|
+
case 8:
|
|
393
|
+
_context.prev = 8;
|
|
394
|
+
_context.t0 = _context["catch"](1);
|
|
395
|
+
updateAuthState({
|
|
396
|
+
error: _context.t0
|
|
397
|
+
});
|
|
398
|
+
if (errorCallback) {
|
|
399
|
+
errorCallback();
|
|
400
|
+
}
|
|
401
|
+
case 12:
|
|
402
|
+
case "end":
|
|
403
|
+
return _context.stop();
|
|
404
|
+
}
|
|
405
|
+
}, _callee, null, [[1, 8]]);
|
|
406
|
+
}));
|
|
407
|
+
return function handleLogin() {
|
|
408
|
+
return _ref2.apply(this, arguments);
|
|
409
|
+
};
|
|
410
|
+
}();
|
|
411
|
+
if (!handledRedirect) {
|
|
412
|
+
handleLogin();
|
|
413
|
+
}
|
|
414
|
+
}, [ocAuth]);
|
|
415
|
+
if (authState.error !== undefined && !errorCallback) {
|
|
416
|
+
return customErrorComponent ? customErrorComponent : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, "Error Logging in: ", authState.error.message);
|
|
417
|
+
} else {
|
|
418
|
+
return customLoadingComponent ? customLoadingComponent : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h3", null, "Loading ......"));
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
/* harmony default export */ __webpack_exports__["default"] = (LoginCallBack);
|
|
422
|
+
|
|
423
|
+
/***/ }),
|
|
424
|
+
/* 6 */
|
|
425
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
426
|
+
|
|
427
|
+
"use strict";
|
|
428
|
+
__webpack_require__.r(__webpack_exports__);
|
|
429
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
430
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
431
|
+
/* harmony import */ var _OCContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
432
|
+
/* harmony import */ var _sdk_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
|
433
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
434
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
435
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
436
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
437
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
438
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
439
|
+
/*!
|
|
440
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
441
|
+
*
|
|
442
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
443
|
+
*
|
|
444
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
445
|
+
*
|
|
446
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
447
|
+
*/
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
var OCConnect = function OCConnect(_ref) {
|
|
452
|
+
var children = _ref.children,
|
|
453
|
+
opts = _ref.opts,
|
|
454
|
+
sandboxMode = _ref.sandboxMode;
|
|
455
|
+
var _useState = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])({}),
|
|
456
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
457
|
+
ocAuth = _useState2[0],
|
|
458
|
+
setOcAuth = _useState2[1];
|
|
459
|
+
var _useState3 = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])({
|
|
460
|
+
isAuthenticated: false
|
|
461
|
+
}),
|
|
462
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
463
|
+
authState = _useState4[0],
|
|
464
|
+
setAuthState = _useState4[1];
|
|
465
|
+
Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () {
|
|
466
|
+
var authSdk = sandboxMode ? new _sdk_auth__WEBPACK_IMPORTED_MODULE_2__["OCAuthSandbox"](opts) : new _sdk_auth__WEBPACK_IMPORTED_MODULE_2__["OCAuthLive"](opts);
|
|
467
|
+
setOcAuth(authSdk);
|
|
468
|
+
updateAuthState(authSdk.getAuthState());
|
|
469
|
+
}, []);
|
|
470
|
+
var updateAuthState = function updateAuthState(authState) {
|
|
471
|
+
var accessToken = authState.accessToken,
|
|
472
|
+
idToken = authState.idToken,
|
|
473
|
+
isAuthenticated = authState.isAuthenticated,
|
|
474
|
+
error = authState.error;
|
|
475
|
+
setAuthState({
|
|
476
|
+
accessToken: accessToken,
|
|
477
|
+
idToken: idToken,
|
|
478
|
+
isAuthenticated: isAuthenticated,
|
|
479
|
+
error: error
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_OCContext__WEBPACK_IMPORTED_MODULE_1__["OCContext"].Provider, {
|
|
483
|
+
value: {
|
|
484
|
+
ocAuth: ocAuth,
|
|
485
|
+
authState: authState,
|
|
486
|
+
updateAuthState: updateAuthState
|
|
487
|
+
}
|
|
488
|
+
}, children);
|
|
489
|
+
};
|
|
490
|
+
/* harmony default export */ __webpack_exports__["default"] = (OCConnect);
|
|
491
|
+
|
|
492
|
+
/***/ }),
|
|
493
|
+
/* 7 */
|
|
494
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
495
|
+
|
|
496
|
+
"use strict";
|
|
497
|
+
__webpack_require__.r(__webpack_exports__);
|
|
498
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OCAuthCore", function() { return OCAuthCore; });
|
|
499
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OCAuthLive", function() { return OCAuthLive; });
|
|
500
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OCAuthSandbox", function() { return OCAuthSandbox; });
|
|
501
|
+
/* harmony import */ var _lib_AuthInfoManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
|
|
502
|
+
/* harmony import */ var _lib_TokenManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
503
|
+
/* harmony import */ var _lib_TransactionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
|
|
504
|
+
/* harmony import */ var _lib_StorageManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22);
|
|
505
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
|
|
506
|
+
/* harmony import */ var _endpoints__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(23);
|
|
507
|
+
/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(18);
|
|
508
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
509
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
510
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
511
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
512
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
513
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
514
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
515
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
516
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
517
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
518
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
519
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
520
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
521
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
522
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
523
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
524
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
525
|
+
/*!
|
|
526
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
527
|
+
*
|
|
528
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
529
|
+
*
|
|
530
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
531
|
+
*
|
|
532
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
var OCAuthCore = /*#__PURE__*/function () {
|
|
542
|
+
function OCAuthCore(loginEndpoint, redirectUri, transactionManager, tokenManager) {
|
|
543
|
+
_classCallCheck(this, OCAuthCore);
|
|
544
|
+
_defineProperty(this, "tokenManager", void 0);
|
|
545
|
+
_defineProperty(this, "authInfoManager", void 0);
|
|
546
|
+
_defineProperty(this, "transactionManager", void 0);
|
|
547
|
+
_defineProperty(this, "redirectUri", void 0);
|
|
548
|
+
_defineProperty(this, "loginEndPoint", void 0);
|
|
549
|
+
this.transactionManager = transactionManager;
|
|
550
|
+
this.tokenManager = tokenManager;
|
|
551
|
+
this.authInfoManager = new _lib_AuthInfoManager__WEBPACK_IMPORTED_MODULE_0__["default"]();
|
|
552
|
+
this.loginEndPoint = loginEndpoint;
|
|
553
|
+
this.redirectUri = redirectUri;
|
|
554
|
+
this.syncAuthInfo();
|
|
555
|
+
}
|
|
556
|
+
return _createClass(OCAuthCore, [{
|
|
557
|
+
key: "clearStorage",
|
|
558
|
+
value: function clearStorage() {
|
|
559
|
+
this.transactionManager.clearStorage();
|
|
560
|
+
this.tokenManager.clear();
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
key: "signInWithRedirect",
|
|
564
|
+
value: function () {
|
|
565
|
+
var _signInWithRedirect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
566
|
+
var paramsClone, signinParams, meta, requestUrl;
|
|
567
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
568
|
+
while (1) switch (_context.prev = _context.next) {
|
|
569
|
+
case 0:
|
|
570
|
+
// we use ONLY code flow with PKCE, so lacks a lot of options
|
|
571
|
+
// available in other OAuth SDKs.
|
|
572
|
+
paramsClone = Object.assign({}, params);
|
|
573
|
+
paramsClone.redirectUri = this.redirectUri;
|
|
574
|
+
_context.next = 4;
|
|
575
|
+
return Object(_utils__WEBPACK_IMPORTED_MODULE_4__["prepareTokenParams"])(paramsClone);
|
|
576
|
+
case 4:
|
|
577
|
+
signinParams = _context.sent;
|
|
578
|
+
meta = Object(_utils__WEBPACK_IMPORTED_MODULE_4__["createPkceMeta"])(signinParams);
|
|
579
|
+
this.transactionManager.save(meta);
|
|
580
|
+
requestUrl = Object(_endpoints__WEBPACK_IMPORTED_MODULE_5__["buildAuthEndpointUrl"])(signinParams, this.loginEndPoint);
|
|
581
|
+
window.location.assign(requestUrl);
|
|
582
|
+
case 9:
|
|
583
|
+
case "end":
|
|
584
|
+
return _context.stop();
|
|
585
|
+
}
|
|
586
|
+
}, _callee, this);
|
|
587
|
+
}));
|
|
588
|
+
function signInWithRedirect(_x) {
|
|
589
|
+
return _signInWithRedirect.apply(this, arguments);
|
|
590
|
+
}
|
|
591
|
+
return signInWithRedirect;
|
|
592
|
+
}()
|
|
593
|
+
}, {
|
|
594
|
+
key: "handleLoginRedirect",
|
|
595
|
+
value: function () {
|
|
596
|
+
var _handleLoginRedirect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
597
|
+
var urlParams, meta, codeVerifier;
|
|
598
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
599
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
600
|
+
case 0:
|
|
601
|
+
urlParams = Object(_utils__WEBPACK_IMPORTED_MODULE_4__["parseUrl"])(); // Again we only handle PKCE code flow
|
|
602
|
+
if (!urlParams.code) {
|
|
603
|
+
_context2.next = 13;
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
meta = this.transactionManager.getTransactionMeta();
|
|
607
|
+
codeVerifier = meta.codeVerifier;
|
|
608
|
+
if (!codeVerifier) {
|
|
609
|
+
_context2.next = 12;
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
_context2.next = 7;
|
|
613
|
+
return this.tokenManager.exchangeTokenFromCode(urlParams.code, codeVerifier);
|
|
614
|
+
case 7:
|
|
615
|
+
// clear transaction meta, coz it's completed
|
|
616
|
+
this.transactionManager.clear();
|
|
617
|
+
this.syncAuthInfo();
|
|
618
|
+
return _context2.abrupt("return", this.getAuthState());
|
|
619
|
+
case 12:
|
|
620
|
+
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_6__["AuthError"]('codeVerifier not found, cannot complete flow');
|
|
621
|
+
case 13:
|
|
622
|
+
return _context2.abrupt("return", {});
|
|
623
|
+
case 14:
|
|
624
|
+
case "end":
|
|
625
|
+
return _context2.stop();
|
|
626
|
+
}
|
|
627
|
+
}, _callee2, this);
|
|
628
|
+
}));
|
|
629
|
+
function handleLoginRedirect() {
|
|
630
|
+
return _handleLoginRedirect.apply(this, arguments);
|
|
631
|
+
}
|
|
632
|
+
return handleLoginRedirect;
|
|
633
|
+
}()
|
|
634
|
+
}, {
|
|
635
|
+
key: "isAuthenticated",
|
|
636
|
+
value: function isAuthenticated() {
|
|
637
|
+
// if both token exist and not expired
|
|
638
|
+
return !this.tokenManager.hasExpired();
|
|
639
|
+
}
|
|
640
|
+
}, {
|
|
641
|
+
key: "syncAuthInfo",
|
|
642
|
+
value: function syncAuthInfo() {
|
|
643
|
+
if (this.tokenManager.hasExpired()) {
|
|
644
|
+
this.authInfoManager.clear();
|
|
645
|
+
} else {
|
|
646
|
+
var idToken = this.tokenManager.getIdToken();
|
|
647
|
+
var _parseJwt = Object(_utils__WEBPACK_IMPORTED_MODULE_4__["parseJwt"])(idToken),
|
|
648
|
+
edu_username = _parseJwt.edu_username,
|
|
649
|
+
eth_address = _parseJwt.eth_address;
|
|
650
|
+
this.authInfoManager.setIdInfo({
|
|
651
|
+
edu_username: edu_username,
|
|
652
|
+
eth_address: eth_address
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}, {
|
|
657
|
+
key: "getAuthState",
|
|
658
|
+
value: function getAuthState() {
|
|
659
|
+
var authState = {
|
|
660
|
+
accessToken: this.getAccessToken(),
|
|
661
|
+
idToken: this.getIdToken(),
|
|
662
|
+
isAuthenticated: this.isAuthenticated()
|
|
663
|
+
};
|
|
664
|
+
return authState;
|
|
665
|
+
}
|
|
666
|
+
}, {
|
|
667
|
+
key: "getAuthInfo",
|
|
668
|
+
value: function getAuthInfo() {
|
|
669
|
+
return this.authInfoManager.getAuthInfo();
|
|
670
|
+
}
|
|
671
|
+
}, {
|
|
672
|
+
key: "getIdToken",
|
|
673
|
+
value: function getIdToken() {
|
|
674
|
+
return this.tokenManager.getIdToken();
|
|
675
|
+
}
|
|
676
|
+
}, {
|
|
677
|
+
key: "getAccessToken",
|
|
678
|
+
value: function getAccessToken() {
|
|
679
|
+
return this.tokenManager.getAccessToken();
|
|
680
|
+
}
|
|
681
|
+
}]);
|
|
682
|
+
}();
|
|
683
|
+
var OCAuthLS = /*#__PURE__*/function (_OCAuthCore2) {
|
|
684
|
+
function OCAuthLS(loginEndPoint, tokenEndpoint, redirectUri, publicKey) {
|
|
685
|
+
_classCallCheck(this, OCAuthLS);
|
|
686
|
+
var pkceTransactionManager = new _lib_TransactionManager__WEBPACK_IMPORTED_MODULE_2__["default"](_lib_StorageManager__WEBPACK_IMPORTED_MODULE_3__["LocalStorageManager"]);
|
|
687
|
+
var tokenManager = new _lib_TokenManager__WEBPACK_IMPORTED_MODULE_1__["default"](_lib_StorageManager__WEBPACK_IMPORTED_MODULE_3__["LocalStorageManager"], tokenEndpoint, publicKey);
|
|
688
|
+
return _callSuper(this, OCAuthLS, [loginEndPoint, redirectUri, pkceTransactionManager, tokenManager]);
|
|
689
|
+
}
|
|
690
|
+
_inherits(OCAuthLS, _OCAuthCore2);
|
|
691
|
+
return _createClass(OCAuthLS);
|
|
692
|
+
}(OCAuthCore);
|
|
693
|
+
var LIVE_PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBIDHtLbgVM76SXZ4iuIjuO+ERQPnVpJzagOsZdYxFG3ZJmvfdpr/Z29SLUbdZWafrOlAVlKe1Ovf/tcH671tTw==';
|
|
694
|
+
var SANDBOX_PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE/EymMLXd/MVYPK5r2xXQj91ZVvX3OQ+QagvR2N6lCvRVjnzmOtPRTf+u5g1RliWnmuxbV3gTm0/0VuV/40Salg==';
|
|
695
|
+
var OCAuthLive = /*#__PURE__*/function (_OCAuthLS) {
|
|
696
|
+
function OCAuthLive() {
|
|
697
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
698
|
+
_classCallCheck(this, OCAuthLive);
|
|
699
|
+
var overrideTokenEndpoint = opts.tokenEndPoint,
|
|
700
|
+
overrideLoginEndpoint = opts.loginEndPoint,
|
|
701
|
+
overridePublicKey = opts.publicKey,
|
|
702
|
+
redirectUri = opts.redirectUri;
|
|
703
|
+
var tokenEndpoint = overrideTokenEndpoint || 'https://api.login.opencampus.xyz/auth/token';
|
|
704
|
+
var loginEndpoint = overrideLoginEndpoint || 'https://api.login.opencampus.xyz/auth/login';
|
|
705
|
+
var publicKey = overridePublicKey || LIVE_PUBLIC_KEY;
|
|
706
|
+
return _callSuper(this, OCAuthLive, [loginEndpoint, tokenEndpoint, redirectUri, publicKey]);
|
|
707
|
+
}
|
|
708
|
+
_inherits(OCAuthLive, _OCAuthLS);
|
|
709
|
+
return _createClass(OCAuthLive);
|
|
710
|
+
}(OCAuthLS);
|
|
711
|
+
var OCAuthSandbox = /*#__PURE__*/function (_OCAuthLS2) {
|
|
712
|
+
function OCAuthSandbox() {
|
|
713
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
714
|
+
_classCallCheck(this, OCAuthSandbox);
|
|
715
|
+
var overrideTokenEndpoint = opts.tokenEndPoint,
|
|
716
|
+
overrideLoginEndpoint = opts.loginEndPoint,
|
|
717
|
+
overridePublicKey = opts.publicKey,
|
|
718
|
+
redirectUri = opts.redirectUri;
|
|
719
|
+
var tokenEndpoint = overrideTokenEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/token';
|
|
720
|
+
var loginEndpoint = overrideLoginEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/login';
|
|
721
|
+
var publicKey = overridePublicKey || SANDBOX_PUBLIC_KEY;
|
|
722
|
+
return _callSuper(this, OCAuthSandbox, [loginEndpoint, tokenEndpoint, redirectUri, publicKey]);
|
|
723
|
+
}
|
|
724
|
+
_inherits(OCAuthSandbox, _OCAuthLS2);
|
|
725
|
+
return _createClass(OCAuthSandbox);
|
|
726
|
+
}(OCAuthLS);
|
|
727
|
+
|
|
728
|
+
/***/ }),
|
|
729
|
+
/* 8 */
|
|
730
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
731
|
+
|
|
732
|
+
"use strict";
|
|
733
|
+
__webpack_require__.r(__webpack_exports__);
|
|
734
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
735
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
736
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
737
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
738
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
739
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
740
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
741
|
+
/*!
|
|
742
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
743
|
+
*
|
|
744
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
745
|
+
*
|
|
746
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
747
|
+
*
|
|
748
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
749
|
+
*/
|
|
750
|
+
var AuthInfoManager = /*#__PURE__*/function () {
|
|
751
|
+
function AuthInfoManager() {
|
|
752
|
+
_classCallCheck(this, AuthInfoManager);
|
|
753
|
+
_defineProperty(this, "_idInfo", void 0);
|
|
754
|
+
this._authState = null;
|
|
755
|
+
this._idInfo = null;
|
|
756
|
+
}
|
|
757
|
+
return _createClass(AuthInfoManager, [{
|
|
758
|
+
key: "setIdInfo",
|
|
759
|
+
value: function setIdInfo(IdInfo) {
|
|
760
|
+
this._idInfo = Object.assign({}, IdInfo);
|
|
761
|
+
}
|
|
762
|
+
}, {
|
|
763
|
+
key: "getIdInfoAttribute",
|
|
764
|
+
value: function getIdInfoAttribute(attribute) {
|
|
765
|
+
if (this._idInfo === null) {
|
|
766
|
+
return undefined;
|
|
767
|
+
}
|
|
768
|
+
return this._idInfo[attribute];
|
|
769
|
+
}
|
|
770
|
+
}, {
|
|
771
|
+
key: "getAuthInfo",
|
|
772
|
+
value: function getAuthInfo() {
|
|
773
|
+
return Object.assign({}, this._idInfo);
|
|
774
|
+
}
|
|
775
|
+
}, {
|
|
776
|
+
key: "clear",
|
|
777
|
+
value: function clear() {
|
|
778
|
+
this._idInfo = null;
|
|
779
|
+
}
|
|
780
|
+
}]);
|
|
781
|
+
}();
|
|
782
|
+
/* harmony default export */ __webpack_exports__["default"] = (AuthInfoManager);
|
|
783
|
+
|
|
784
|
+
/***/ }),
|
|
785
|
+
/* 9 */
|
|
786
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
787
|
+
|
|
788
|
+
"use strict";
|
|
789
|
+
__webpack_require__.r(__webpack_exports__);
|
|
790
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
|
|
791
|
+
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
|
|
792
|
+
/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
|
|
793
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
794
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
795
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
796
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
797
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
798
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
799
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
800
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
801
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
802
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
803
|
+
/*!
|
|
804
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
805
|
+
*
|
|
806
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
807
|
+
*
|
|
808
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
809
|
+
*
|
|
810
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
811
|
+
*/
|
|
812
|
+
// import StorageManager from './StorageManager';
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
var TOKEN_STORAGE_NAME = 'oc-token-storage';
|
|
817
|
+
var TokenManager = /*#__PURE__*/function () {
|
|
818
|
+
function TokenManager(StorageManagerClass, tokenEndPoint, publicKey) {
|
|
819
|
+
_classCallCheck(this, TokenManager);
|
|
820
|
+
_defineProperty(this, "storageManager", void 0);
|
|
821
|
+
_defineProperty(this, "tokenExpiredAt", void 0);
|
|
822
|
+
_defineProperty(this, "tokenEndPoint", void 0);
|
|
823
|
+
_defineProperty(this, "publicKey", void 0);
|
|
824
|
+
this.storageManager = new StorageManagerClass(TOKEN_STORAGE_NAME);
|
|
825
|
+
this.tokenEndPoint = tokenEndPoint;
|
|
826
|
+
this.publicKey = publicKey;
|
|
827
|
+
}
|
|
828
|
+
return _createClass(TokenManager, [{
|
|
829
|
+
key: "clear",
|
|
830
|
+
value: function clear() {
|
|
831
|
+
this.storageManager.getStorageObject().clearStorage();
|
|
832
|
+
}
|
|
833
|
+
}, {
|
|
834
|
+
key: "exchangeTokenFromCode",
|
|
835
|
+
value: function () {
|
|
836
|
+
var _exchangeTokenFromCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessCode, codeVerifier) {
|
|
837
|
+
var body, response, _yield$response$json, access_token, id_token, pubKey, tokenVerified, parsedAccessToken;
|
|
838
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
839
|
+
while (1) switch (_context.prev = _context.next) {
|
|
840
|
+
case 0:
|
|
841
|
+
body = {
|
|
842
|
+
accessCode: accessCode,
|
|
843
|
+
codeVerifier: codeVerifier
|
|
844
|
+
};
|
|
845
|
+
_context.prev = 1;
|
|
846
|
+
_context.next = 4;
|
|
847
|
+
return fetch(this.tokenEndPoint, {
|
|
848
|
+
method: 'POST',
|
|
849
|
+
headers: {
|
|
850
|
+
'Content-Type': 'application/json'
|
|
851
|
+
},
|
|
852
|
+
body: JSON.stringify(body)
|
|
853
|
+
});
|
|
854
|
+
case 4:
|
|
855
|
+
response = _context.sent;
|
|
856
|
+
_context.next = 7;
|
|
857
|
+
return response.json();
|
|
858
|
+
case 7:
|
|
859
|
+
_yield$response$json = _context.sent;
|
|
860
|
+
access_token = _yield$response$json.access_token;
|
|
861
|
+
id_token = _yield$response$json.id_token;
|
|
862
|
+
if (!(!access_token || !id_token)) {
|
|
863
|
+
_context.next = 12;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_2__["AuthError"]('Fail to exchange token');
|
|
867
|
+
case 12:
|
|
868
|
+
_context.next = 14;
|
|
869
|
+
return this.getPublicKey();
|
|
870
|
+
case 14:
|
|
871
|
+
pubKey = _context.sent;
|
|
872
|
+
_context.next = 17;
|
|
873
|
+
return Object(_crypto__WEBPACK_IMPORTED_MODULE_1__["verifyToken"])(id_token, pubKey);
|
|
874
|
+
case 17:
|
|
875
|
+
tokenVerified = _context.sent;
|
|
876
|
+
if (tokenVerified) {
|
|
877
|
+
_context.next = 20;
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_2__["AuthError"]('Unable to verify token');
|
|
881
|
+
case 20:
|
|
882
|
+
parsedAccessToken = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["parseJwt"])(access_token);
|
|
883
|
+
this.storageManager.getStorageObject().setStorage({
|
|
884
|
+
access_token: access_token,
|
|
885
|
+
id_token: id_token,
|
|
886
|
+
expired: parsedAccessToken.exp
|
|
887
|
+
});
|
|
888
|
+
_context.next = 28;
|
|
889
|
+
break;
|
|
890
|
+
case 24:
|
|
891
|
+
_context.prev = 24;
|
|
892
|
+
_context.t0 = _context["catch"](1);
|
|
893
|
+
console.log(_context.t0);
|
|
894
|
+
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_2__["AuthError"]('Token acquisition failed');
|
|
895
|
+
case 28:
|
|
896
|
+
case "end":
|
|
897
|
+
return _context.stop();
|
|
898
|
+
}
|
|
899
|
+
}, _callee, this, [[1, 24]]);
|
|
900
|
+
}));
|
|
901
|
+
function exchangeTokenFromCode(_x, _x2) {
|
|
902
|
+
return _exchangeTokenFromCode.apply(this, arguments);
|
|
903
|
+
}
|
|
904
|
+
return exchangeTokenFromCode;
|
|
905
|
+
}()
|
|
906
|
+
}, {
|
|
907
|
+
key: "getIdToken",
|
|
908
|
+
value: function getIdToken() {
|
|
909
|
+
return this.storageManager.getStorageObject().getItem('id_token');
|
|
910
|
+
}
|
|
911
|
+
}, {
|
|
912
|
+
key: "getAccessToken",
|
|
913
|
+
value: function getAccessToken() {
|
|
914
|
+
return this.storageManager.getStorageObject().getItem('access_token');
|
|
915
|
+
}
|
|
916
|
+
}, {
|
|
917
|
+
key: "getExpiredAt",
|
|
918
|
+
value: function getExpiredAt() {
|
|
919
|
+
return this.storageManager.getStorageObject().getItem('expired');
|
|
920
|
+
}
|
|
921
|
+
}, {
|
|
922
|
+
key: "getPublicKey",
|
|
923
|
+
value: function () {
|
|
924
|
+
var _getPublicKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
925
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
926
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
927
|
+
case 0:
|
|
928
|
+
return _context2.abrupt("return", this.publicKey);
|
|
929
|
+
case 1:
|
|
930
|
+
case "end":
|
|
931
|
+
return _context2.stop();
|
|
932
|
+
}
|
|
933
|
+
}, _callee2, this);
|
|
934
|
+
}));
|
|
935
|
+
function getPublicKey() {
|
|
936
|
+
return _getPublicKey.apply(this, arguments);
|
|
937
|
+
}
|
|
938
|
+
return getPublicKey;
|
|
939
|
+
}()
|
|
940
|
+
}, {
|
|
941
|
+
key: "hasExpired",
|
|
942
|
+
value: function hasExpired() {
|
|
943
|
+
var expiredAt = this.getExpiredAt();
|
|
944
|
+
if (!expiredAt) {
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
var cur = Math.round(new Date().valueOf() / 1000);
|
|
948
|
+
return cur >= expiredAt;
|
|
949
|
+
}
|
|
950
|
+
}]);
|
|
951
|
+
}();
|
|
952
|
+
/* harmony default export */ __webpack_exports__["default"] = (TokenManager);
|
|
953
|
+
|
|
954
|
+
/***/ }),
|
|
955
|
+
/* 10 */
|
|
956
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
957
|
+
|
|
958
|
+
"use strict";
|
|
959
|
+
__webpack_require__.r(__webpack_exports__);
|
|
960
|
+
/* harmony import */ var _urlParser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
|
|
961
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parseUrl", function() { return _urlParser__WEBPACK_IMPORTED_MODULE_0__["parseUrl"]; });
|
|
962
|
+
|
|
963
|
+
/* harmony import */ var _prepareTokenParams__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
|
|
964
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareTokenParams", function() { return _prepareTokenParams__WEBPACK_IMPORTED_MODULE_1__["prepareTokenParams"]; });
|
|
965
|
+
|
|
966
|
+
/* harmony import */ var _createPkceMeta__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(19);
|
|
967
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createPkceMeta", function() { return _createPkceMeta__WEBPACK_IMPORTED_MODULE_2__["createPkceMeta"]; });
|
|
968
|
+
|
|
969
|
+
/* harmony import */ var _jwtParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
|
|
970
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parseJwt", function() { return _jwtParser__WEBPACK_IMPORTED_MODULE_3__["parseJwt"]; });
|
|
971
|
+
|
|
972
|
+
/*!
|
|
973
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
974
|
+
*
|
|
975
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
976
|
+
*
|
|
977
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
978
|
+
*
|
|
979
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
980
|
+
*/
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
/***/ }),
|
|
987
|
+
/* 11 */
|
|
988
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
989
|
+
|
|
990
|
+
"use strict";
|
|
991
|
+
__webpack_require__.r(__webpack_exports__);
|
|
992
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseUrl", function() { return parseUrl; });
|
|
993
|
+
/*!
|
|
994
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
995
|
+
*
|
|
996
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
997
|
+
*
|
|
998
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
999
|
+
*
|
|
1000
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1001
|
+
*/
|
|
1002
|
+
var parseUrl = function parseUrl() {
|
|
1003
|
+
var queryString = window.location.search;
|
|
1004
|
+
var urlParams = new URLSearchParams(queryString);
|
|
1005
|
+
var validParams = {};
|
|
1006
|
+
if (urlParams.has('id_token')) validParams.id_token = urlParams.get('id_token');
|
|
1007
|
+
if (urlParams.has('code')) validParams.code = urlParams.get('code');
|
|
1008
|
+
if (urlParams.has('state')) validParams.state = urlParams.get('state');
|
|
1009
|
+
return validParams;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
/***/ }),
|
|
1013
|
+
/* 12 */
|
|
1014
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1015
|
+
|
|
1016
|
+
"use strict";
|
|
1017
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1018
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prepareTokenParams", function() { return prepareTokenParams; });
|
|
1019
|
+
/* harmony import */ var _lib_pkce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
|
|
1020
|
+
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
|
|
1021
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1022
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1023
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1024
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1025
|
+
/*!
|
|
1026
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1027
|
+
*
|
|
1028
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1029
|
+
*
|
|
1030
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1031
|
+
*
|
|
1032
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1033
|
+
*/
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
var prepareTokenParams = /*#__PURE__*/function () {
|
|
1037
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
1038
|
+
var redirectUri, state, codeVerifier, codeChallenge, tokenParams;
|
|
1039
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1040
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1041
|
+
case 0:
|
|
1042
|
+
// prepare all the params needed for building the signin flow
|
|
1043
|
+
// mandatory redirect_uri, for now, we only allow user to set redirect_uri and state
|
|
1044
|
+
// again this is not a full on OIDC/OAuth flow allowing user to set all the options
|
|
1045
|
+
// we prepare all the rest
|
|
1046
|
+
redirectUri = params.redirectUri, state = params.state;
|
|
1047
|
+
if (redirectUri) {
|
|
1048
|
+
_context.next = 3;
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
throw new _errors__WEBPACK_IMPORTED_MODULE_1__["InvalidParamsError"](' No redirect uri params!');
|
|
1052
|
+
case 3:
|
|
1053
|
+
// must be pkce
|
|
1054
|
+
codeVerifier = _lib_pkce__WEBPACK_IMPORTED_MODULE_0__["default"].generateVerifier();
|
|
1055
|
+
_context.next = 6;
|
|
1056
|
+
return _lib_pkce__WEBPACK_IMPORTED_MODULE_0__["default"].computeChallenge(codeVerifier);
|
|
1057
|
+
case 6:
|
|
1058
|
+
codeChallenge = _context.sent;
|
|
1059
|
+
// pack up the full set of token params needed
|
|
1060
|
+
tokenParams = {
|
|
1061
|
+
redirectUri: redirectUri,
|
|
1062
|
+
codeVerifier: codeVerifier,
|
|
1063
|
+
codeChallenge: codeChallenge,
|
|
1064
|
+
codeChallengeMethod: _lib_pkce__WEBPACK_IMPORTED_MODULE_0__["default"].DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1065
|
+
scope: 'openid',
|
|
1066
|
+
responseType: 'code'
|
|
1067
|
+
}; // just filter out undefined and null, honor other falsy states
|
|
1068
|
+
if (state !== undefined && state !== null) {
|
|
1069
|
+
tokenParams.state = state;
|
|
1070
|
+
}
|
|
1071
|
+
return _context.abrupt("return", tokenParams);
|
|
1072
|
+
case 10:
|
|
1073
|
+
case "end":
|
|
1074
|
+
return _context.stop();
|
|
1075
|
+
}
|
|
1076
|
+
}, _callee);
|
|
1077
|
+
}));
|
|
1078
|
+
return function prepareTokenParams(_x) {
|
|
1079
|
+
return _ref.apply(this, arguments);
|
|
1080
|
+
};
|
|
1081
|
+
}();
|
|
1082
|
+
|
|
1083
|
+
/***/ }),
|
|
1084
|
+
/* 13 */
|
|
1085
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1086
|
+
|
|
1087
|
+
"use strict";
|
|
1088
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1089
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_VERIFIER_LENGTH", function() { return MIN_VERIFIER_LENGTH; });
|
|
1090
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_VERIFIER_LENGTH", function() { return MAX_VERIFIER_LENGTH; });
|
|
1091
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_CODE_CHALLENGE_METHOD", function() { return DEFAULT_CODE_CHALLENGE_METHOD; });
|
|
1092
|
+
/* harmony import */ var _crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
|
|
1093
|
+
/*!
|
|
1094
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1095
|
+
*
|
|
1096
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1097
|
+
*
|
|
1098
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1099
|
+
*
|
|
1100
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1101
|
+
*/
|
|
1102
|
+
/* eslint-disable complexity, max-statements */
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
var MIN_VERIFIER_LENGTH = 43;
|
|
1106
|
+
var MAX_VERIFIER_LENGTH = 128;
|
|
1107
|
+
var DEFAULT_CODE_CHALLENGE_METHOD = 'S256';
|
|
1108
|
+
function dec2hex(dec) {
|
|
1109
|
+
return ('0' + dec.toString(16)).substr(-2);
|
|
1110
|
+
}
|
|
1111
|
+
function getRandomString(length) {
|
|
1112
|
+
var a = new Uint8Array(Math.ceil(length / 2));
|
|
1113
|
+
_crypto__WEBPACK_IMPORTED_MODULE_0__["webcrypto"].getRandomValues(a);
|
|
1114
|
+
var str = Array.from(a, dec2hex).join('');
|
|
1115
|
+
return str.slice(0, length);
|
|
1116
|
+
}
|
|
1117
|
+
function generateVerifier(prefix) {
|
|
1118
|
+
var verifier = prefix || '';
|
|
1119
|
+
if (verifier.length < MIN_VERIFIER_LENGTH) {
|
|
1120
|
+
verifier = verifier + getRandomString(MIN_VERIFIER_LENGTH - verifier.length);
|
|
1121
|
+
}
|
|
1122
|
+
return encodeURIComponent(verifier).slice(0, MAX_VERIFIER_LENGTH);
|
|
1123
|
+
}
|
|
1124
|
+
function computeChallenge(str) {
|
|
1125
|
+
var buffer = new TextEncoder().encode(str);
|
|
1126
|
+
return _crypto__WEBPACK_IMPORTED_MODULE_0__["webcrypto"].subtle.digest('SHA-256', buffer).then(function (arrayBuffer) {
|
|
1127
|
+
var hash = String.fromCharCode.apply(null, new Uint8Array(arrayBuffer));
|
|
1128
|
+
var b64u = Object(_crypto__WEBPACK_IMPORTED_MODULE_0__["stringToBase64Url"])(hash); // url-safe base64 variant
|
|
1129
|
+
|
|
1130
|
+
return b64u;
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
/* harmony default export */ __webpack_exports__["default"] = ({
|
|
1134
|
+
DEFAULT_CODE_CHALLENGE_METHOD: DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1135
|
+
generateVerifier: generateVerifier,
|
|
1136
|
+
computeChallenge: computeChallenge
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
/***/ }),
|
|
1140
|
+
/* 14 */
|
|
1141
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1142
|
+
|
|
1143
|
+
"use strict";
|
|
1144
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1145
|
+
/* harmony import */ var _webcrypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
|
|
1146
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "atob", function() { return _webcrypto__WEBPACK_IMPORTED_MODULE_0__["atob"]; });
|
|
1147
|
+
|
|
1148
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "btoa", function() { return _webcrypto__WEBPACK_IMPORTED_MODULE_0__["btoa"]; });
|
|
1149
|
+
|
|
1150
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "webcrypto", function() { return _webcrypto__WEBPACK_IMPORTED_MODULE_0__["webcrypto"]; });
|
|
1151
|
+
|
|
1152
|
+
/* harmony import */ var _base64__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
|
|
1153
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "base64ToBase64Url", function() { return _base64__WEBPACK_IMPORTED_MODULE_1__["base64ToBase64Url"]; });
|
|
1154
|
+
|
|
1155
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "base64UrlToBase64", function() { return _base64__WEBPACK_IMPORTED_MODULE_1__["base64UrlToBase64"]; });
|
|
1156
|
+
|
|
1157
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "stringToBase64Url", function() { return _base64__WEBPACK_IMPORTED_MODULE_1__["stringToBase64Url"]; });
|
|
1158
|
+
|
|
1159
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "stringToBuffer", function() { return _base64__WEBPACK_IMPORTED_MODULE_1__["stringToBuffer"]; });
|
|
1160
|
+
|
|
1161
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "base64UrlDecode", function() { return _base64__WEBPACK_IMPORTED_MODULE_1__["base64UrlDecode"]; });
|
|
1162
|
+
|
|
1163
|
+
/* harmony import */ var _verifyToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
|
|
1164
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "verifyToken", function() { return _verifyToken__WEBPACK_IMPORTED_MODULE_2__["verifyToken"]; });
|
|
1165
|
+
|
|
1166
|
+
/*!
|
|
1167
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1168
|
+
*
|
|
1169
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1170
|
+
*
|
|
1171
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1172
|
+
*
|
|
1173
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1174
|
+
*/
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
/***/ }),
|
|
1180
|
+
/* 15 */
|
|
1181
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1182
|
+
|
|
1183
|
+
"use strict";
|
|
1184
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1185
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "atob", function() { return a; });
|
|
1186
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "btoa", function() { return b; });
|
|
1187
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "webcrypto", function() { return c; });
|
|
1188
|
+
/*!
|
|
1189
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1190
|
+
*
|
|
1191
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1192
|
+
*
|
|
1193
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1194
|
+
*
|
|
1195
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1196
|
+
*/
|
|
1197
|
+
// eslint-disable-next-line no-redeclare
|
|
1198
|
+
var a = function a(str) {
|
|
1199
|
+
return window.atob(str);
|
|
1200
|
+
};
|
|
1201
|
+
// eslint-disable-next-line no-redeclare
|
|
1202
|
+
var b = function b(str) {
|
|
1203
|
+
return window.btoa(str);
|
|
1204
|
+
};
|
|
1205
|
+
// eslint-disable-next-line no-redeclare
|
|
1206
|
+
var c = typeof crypto === 'undefined' ? null : crypto;
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
/***/ }),
|
|
1210
|
+
/* 16 */
|
|
1211
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1212
|
+
|
|
1213
|
+
"use strict";
|
|
1214
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1215
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "base64ToBase64Url", function() { return base64ToBase64Url; });
|
|
1216
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "base64UrlToBase64", function() { return base64UrlToBase64; });
|
|
1217
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stringToBase64Url", function() { return stringToBase64Url; });
|
|
1218
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stringToBuffer", function() { return stringToBuffer; });
|
|
1219
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "base64UrlDecode", function() { return base64UrlDecode; });
|
|
1220
|
+
/* harmony import */ var _webcrypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
|
|
1221
|
+
/*!
|
|
1222
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1223
|
+
*
|
|
1224
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1225
|
+
*
|
|
1226
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1227
|
+
*
|
|
1228
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
// converts a standard base64-encoded string to a "url/filename safe" variant
|
|
1233
|
+
function base64ToBase64Url(b64) {
|
|
1234
|
+
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// converts a "url/filename safe" base64 string to a "standard" base64 string
|
|
1238
|
+
function base64UrlToBase64(b64u) {
|
|
1239
|
+
return b64u.replace(/-/g, '+').replace(/_/g, '/');
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// converts a string to base64 (url/filename safe variant)
|
|
1243
|
+
function stringToBase64Url(str) {
|
|
1244
|
+
var b64 = Object(_webcrypto__WEBPACK_IMPORTED_MODULE_0__["btoa"])(str);
|
|
1245
|
+
return base64ToBase64Url(b64);
|
|
1246
|
+
}
|
|
1247
|
+
function stringToBuffer(str) {
|
|
1248
|
+
var buffer = new Uint8Array(str.length);
|
|
1249
|
+
for (var i = 0; i < str.length; i++) {
|
|
1250
|
+
buffer[i] = str.charCodeAt(i);
|
|
1251
|
+
}
|
|
1252
|
+
return buffer;
|
|
1253
|
+
}
|
|
1254
|
+
function base64UrlDecode(str) {
|
|
1255
|
+
return Object(_webcrypto__WEBPACK_IMPORTED_MODULE_0__["atob"])(base64UrlToBase64(str));
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/***/ }),
|
|
1259
|
+
/* 17 */
|
|
1260
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1261
|
+
|
|
1262
|
+
"use strict";
|
|
1263
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1264
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "verifyToken", function() { return verifyToken; });
|
|
1265
|
+
/* harmony import */ var _base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
|
|
1266
|
+
/* harmony import */ var _webcrypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
|
|
1267
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1268
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1269
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1270
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1271
|
+
/*!
|
|
1272
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1273
|
+
*
|
|
1274
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1275
|
+
*
|
|
1276
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1277
|
+
*
|
|
1278
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1279
|
+
*/
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
var prepareKey = function prepareKey(key) {
|
|
1284
|
+
var binaryDerString = Object(_webcrypto__WEBPACK_IMPORTED_MODULE_1__["atob"])(key);
|
|
1285
|
+
return Object(_base64__WEBPACK_IMPORTED_MODULE_0__["stringToBuffer"])(binaryDerString);
|
|
1286
|
+
};
|
|
1287
|
+
var verifyToken = /*#__PURE__*/function () {
|
|
1288
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(idToken, key) {
|
|
1289
|
+
var format, algo, extractable, usages, preparedKey, cryptoKey, jwt, payload, b64Signature, signature;
|
|
1290
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1291
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1292
|
+
case 0:
|
|
1293
|
+
format = 'spki';
|
|
1294
|
+
algo = {
|
|
1295
|
+
name: 'ECDSA',
|
|
1296
|
+
namedCurve: 'P-256',
|
|
1297
|
+
hash: {
|
|
1298
|
+
name: "SHA-256"
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
extractable = true;
|
|
1302
|
+
usages = ['verify'];
|
|
1303
|
+
preparedKey = prepareKey(key);
|
|
1304
|
+
_context.next = 7;
|
|
1305
|
+
return _webcrypto__WEBPACK_IMPORTED_MODULE_1__["webcrypto"].subtle.importKey(format, preparedKey, algo, extractable, usages);
|
|
1306
|
+
case 7:
|
|
1307
|
+
cryptoKey = _context.sent;
|
|
1308
|
+
jwt = idToken.split('.');
|
|
1309
|
+
payload = Object(_base64__WEBPACK_IMPORTED_MODULE_0__["stringToBuffer"])(jwt[0] + '.' + jwt[1]);
|
|
1310
|
+
b64Signature = Object(_base64__WEBPACK_IMPORTED_MODULE_0__["base64UrlDecode"])(jwt[2]);
|
|
1311
|
+
signature = Object(_base64__WEBPACK_IMPORTED_MODULE_0__["stringToBuffer"])(b64Signature);
|
|
1312
|
+
_context.next = 14;
|
|
1313
|
+
return _webcrypto__WEBPACK_IMPORTED_MODULE_1__["webcrypto"].subtle.verify(algo, cryptoKey, signature, payload);
|
|
1314
|
+
case 14:
|
|
1315
|
+
return _context.abrupt("return", _context.sent);
|
|
1316
|
+
case 15:
|
|
1317
|
+
case "end":
|
|
1318
|
+
return _context.stop();
|
|
1319
|
+
}
|
|
1320
|
+
}, _callee);
|
|
1321
|
+
}));
|
|
1322
|
+
return function verifyToken(_x, _x2) {
|
|
1323
|
+
return _ref.apply(this, arguments);
|
|
1324
|
+
};
|
|
1325
|
+
}();
|
|
1326
|
+
|
|
1327
|
+
/***/ }),
|
|
1328
|
+
/* 18 */
|
|
1329
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1330
|
+
|
|
1331
|
+
"use strict";
|
|
1332
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1333
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalError", function() { return InternalError; });
|
|
1334
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InvalidParamsError", function() { return InvalidParamsError; });
|
|
1335
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AuthError", function() { return AuthError; });
|
|
1336
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1337
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
1338
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1339
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
1340
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1341
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1342
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
1343
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
1344
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
1345
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
1346
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
1347
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
1348
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
1349
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
1350
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
1351
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
1352
|
+
/*!
|
|
1353
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1354
|
+
*
|
|
1355
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1356
|
+
*
|
|
1357
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1358
|
+
*
|
|
1359
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1360
|
+
*/
|
|
1361
|
+
var InternalError = /*#__PURE__*/function (_Error) {
|
|
1362
|
+
function InternalError() {
|
|
1363
|
+
_classCallCheck(this, InternalError);
|
|
1364
|
+
return _callSuper(this, InternalError, arguments);
|
|
1365
|
+
}
|
|
1366
|
+
_inherits(InternalError, _Error);
|
|
1367
|
+
return _createClass(InternalError);
|
|
1368
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1369
|
+
var InvalidParamsError = /*#__PURE__*/function (_InternalError) {
|
|
1370
|
+
function InvalidParamsError() {
|
|
1371
|
+
_classCallCheck(this, InvalidParamsError);
|
|
1372
|
+
return _callSuper(this, InvalidParamsError, arguments);
|
|
1373
|
+
}
|
|
1374
|
+
_inherits(InvalidParamsError, _InternalError);
|
|
1375
|
+
return _createClass(InvalidParamsError);
|
|
1376
|
+
}(InternalError);
|
|
1377
|
+
var AuthError = /*#__PURE__*/function (_Error2) {
|
|
1378
|
+
function AuthError() {
|
|
1379
|
+
_classCallCheck(this, AuthError);
|
|
1380
|
+
return _callSuper(this, AuthError, arguments);
|
|
1381
|
+
}
|
|
1382
|
+
_inherits(AuthError, _Error2);
|
|
1383
|
+
return _createClass(AuthError);
|
|
1384
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1385
|
+
|
|
1386
|
+
/***/ }),
|
|
1387
|
+
/* 19 */
|
|
1388
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1389
|
+
|
|
1390
|
+
"use strict";
|
|
1391
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1392
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPkceMeta", function() { return createPkceMeta; });
|
|
1393
|
+
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
|
|
1394
|
+
/*!
|
|
1395
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1396
|
+
*
|
|
1397
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1398
|
+
*
|
|
1399
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1400
|
+
*
|
|
1401
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1402
|
+
*/
|
|
1403
|
+
|
|
1404
|
+
var createPkceMeta = function createPkceMeta(signinParams) {
|
|
1405
|
+
// prepare the meta that needs to be persisted in storage
|
|
1406
|
+
// extracted from the signinParams
|
|
1407
|
+
var codeChallenge = signinParams.codeChallenge,
|
|
1408
|
+
codeVerifier = signinParams.codeVerifier,
|
|
1409
|
+
codeChallengeMethod = signinParams.codeChallengeMethod;
|
|
1410
|
+
if (!codeChallenge || !codeVerifier || !codeChallengeMethod) {
|
|
1411
|
+
throw new _errors__WEBPACK_IMPORTED_MODULE_0__["InvalidParamsError"]('codeChallenge, codeVerifier & codeChallengeMethod are required');
|
|
1412
|
+
}
|
|
1413
|
+
return {
|
|
1414
|
+
codeChallenge: codeChallenge,
|
|
1415
|
+
codeVerifier: codeVerifier,
|
|
1416
|
+
codeChallengeMethod: codeChallengeMethod
|
|
1417
|
+
};
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
/***/ }),
|
|
1421
|
+
/* 20 */
|
|
1422
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1423
|
+
|
|
1424
|
+
"use strict";
|
|
1425
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1426
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseJwt", function() { return parseJwt; });
|
|
1427
|
+
/*!
|
|
1428
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1429
|
+
*
|
|
1430
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1431
|
+
*
|
|
1432
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1433
|
+
*
|
|
1434
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1435
|
+
*/
|
|
1436
|
+
|
|
1437
|
+
var parseJwt = function parseJwt(token) {
|
|
1438
|
+
var base64Url = token.split('.')[1];
|
|
1439
|
+
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
1440
|
+
var jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function (c) {
|
|
1441
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
1442
|
+
}).join(''));
|
|
1443
|
+
return JSON.parse(jsonPayload);
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
/***/ }),
|
|
1447
|
+
/* 21 */
|
|
1448
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1449
|
+
|
|
1450
|
+
"use strict";
|
|
1451
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1452
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1453
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1454
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
1455
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1456
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1457
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
1458
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1459
|
+
/*!
|
|
1460
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1461
|
+
*
|
|
1462
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1463
|
+
*
|
|
1464
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1465
|
+
*
|
|
1466
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1467
|
+
*/
|
|
1468
|
+
|
|
1469
|
+
// TransactionManager manages data that's stored over a "transaction"
|
|
1470
|
+
// of the login cycle
|
|
1471
|
+
// A transaction contains a few things that we want to carry over multiple
|
|
1472
|
+
// times interacting with the SDK
|
|
1473
|
+
// Currently just used for
|
|
1474
|
+
// codeChallenge, codeVerifier, codeChallengeMethod
|
|
1475
|
+
|
|
1476
|
+
var TRANSACTION_STORAGE_NAME = 'oc-transaction-storage';
|
|
1477
|
+
var TransactionManager = /*#__PURE__*/function () {
|
|
1478
|
+
function TransactionManager(StorageManagerClass) {
|
|
1479
|
+
_classCallCheck(this, TransactionManager);
|
|
1480
|
+
_defineProperty(this, "storageManager", void 0);
|
|
1481
|
+
this.storageManager = new StorageManagerClass(TRANSACTION_STORAGE_NAME);
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
// called when we start a new transaction
|
|
1485
|
+
return _createClass(TransactionManager, [{
|
|
1486
|
+
key: "clear",
|
|
1487
|
+
value: function clear() {
|
|
1488
|
+
this.storageManager.getStorageObject().clearStorage();
|
|
1489
|
+
}
|
|
1490
|
+
}, {
|
|
1491
|
+
key: "save",
|
|
1492
|
+
value: function save(meta) {
|
|
1493
|
+
this.storageManager.getStorageObject().setStorage(meta);
|
|
1494
|
+
}
|
|
1495
|
+
}, {
|
|
1496
|
+
key: "getTransactionMeta",
|
|
1497
|
+
value: function getTransactionMeta() {
|
|
1498
|
+
return this.storageManager.getStorageObject().getStorage();
|
|
1499
|
+
}
|
|
1500
|
+
}, {
|
|
1501
|
+
key: "hasActiveTransaction",
|
|
1502
|
+
value: function hasActiveTransaction() {
|
|
1503
|
+
var meta = this.storageManager.getStorageObject();
|
|
1504
|
+
return !!meta.codeChallenge && !!meta.codeVerifier;
|
|
1505
|
+
}
|
|
1506
|
+
}]);
|
|
1507
|
+
}();
|
|
1508
|
+
/* harmony default export */ __webpack_exports__["default"] = (TransactionManager);
|
|
1509
|
+
|
|
1510
|
+
/***/ }),
|
|
1511
|
+
/* 22 */
|
|
1512
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1513
|
+
|
|
1514
|
+
"use strict";
|
|
1515
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1516
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseStorageManager", function() { return BaseStorageManager; });
|
|
1517
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocalStorageManager", function() { return LocalStorageManager; });
|
|
1518
|
+
/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
|
|
1519
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1520
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
1521
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
1522
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
1523
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
1524
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
1525
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
1526
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
1527
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1528
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
1529
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1530
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1531
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
1532
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1533
|
+
/*!
|
|
1534
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1535
|
+
*
|
|
1536
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1537
|
+
*
|
|
1538
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1539
|
+
*
|
|
1540
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1541
|
+
*/
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
// We only support local storage for now
|
|
1546
|
+
var SavedObject = /*#__PURE__*/function () {
|
|
1547
|
+
function SavedObject(storageProvider, storageName) {
|
|
1548
|
+
_classCallCheck(this, SavedObject);
|
|
1549
|
+
_defineProperty(this, "storageProvider", void 0);
|
|
1550
|
+
_defineProperty(this, "storageName", void 0);
|
|
1551
|
+
this.storageProvider = storageProvider;
|
|
1552
|
+
this.storageName = storageName;
|
|
1553
|
+
}
|
|
1554
|
+
return _createClass(SavedObject, [{
|
|
1555
|
+
key: "getItem",
|
|
1556
|
+
value: function getItem(key) {
|
|
1557
|
+
return this.getStorage()[key];
|
|
1558
|
+
}
|
|
1559
|
+
}, {
|
|
1560
|
+
key: "setItem",
|
|
1561
|
+
value: function setItem(key, value) {
|
|
1562
|
+
return this.updateStorage(key, value);
|
|
1563
|
+
}
|
|
1564
|
+
}, {
|
|
1565
|
+
key: "removeItem",
|
|
1566
|
+
value: function removeItem(key) {
|
|
1567
|
+
return this.clearStorage(key);
|
|
1568
|
+
}
|
|
1569
|
+
}, {
|
|
1570
|
+
key: "getStorage",
|
|
1571
|
+
value: function getStorage() {
|
|
1572
|
+
var storageString = this.storageProvider.getItem(this.storageName);
|
|
1573
|
+
storageString = storageString || '{}';
|
|
1574
|
+
try {
|
|
1575
|
+
return JSON.parse(storageString);
|
|
1576
|
+
} catch (e) {
|
|
1577
|
+
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_0__["InternalError"]('Unable to parse storage string: ' + this.storageName);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}, {
|
|
1581
|
+
key: "setStorage",
|
|
1582
|
+
value: function setStorage(obj) {
|
|
1583
|
+
try {
|
|
1584
|
+
var storageString = obj ? JSON.stringify(obj) : '{}';
|
|
1585
|
+
this.storageProvider.setItem(this.storageName, storageString);
|
|
1586
|
+
} catch (e) {
|
|
1587
|
+
throw new Error('Unable to set storage: ' + this.storageName);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
}, {
|
|
1591
|
+
key: "clearStorage",
|
|
1592
|
+
value: function clearStorage(key) {
|
|
1593
|
+
if (!key) {
|
|
1594
|
+
// clear all
|
|
1595
|
+
this.storageProvider.removeItem(this.storageName);
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
var obj = this.getStorage();
|
|
1599
|
+
delete obj[key];
|
|
1600
|
+
this.setStorage(obj);
|
|
1601
|
+
}
|
|
1602
|
+
}, {
|
|
1603
|
+
key: "updateStorage",
|
|
1604
|
+
value: function updateStorage(key, value) {
|
|
1605
|
+
var obj = this.getStorage();
|
|
1606
|
+
obj[key] = value;
|
|
1607
|
+
this.setStorage(obj);
|
|
1608
|
+
}
|
|
1609
|
+
}]);
|
|
1610
|
+
}();
|
|
1611
|
+
var BaseStorageManager = /*#__PURE__*/function () {
|
|
1612
|
+
function BaseStorageManager(storageName, storageProvider) {
|
|
1613
|
+
_classCallCheck(this, BaseStorageManager);
|
|
1614
|
+
_defineProperty(this, "storageProvider", void 0);
|
|
1615
|
+
_defineProperty(this, "storageName", void 0);
|
|
1616
|
+
this.storageName = storageName;
|
|
1617
|
+
this.storageProvider = storageProvider;
|
|
1618
|
+
}
|
|
1619
|
+
return _createClass(BaseStorageManager, [{
|
|
1620
|
+
key: "getStorageObject",
|
|
1621
|
+
value: function getStorageObject() {
|
|
1622
|
+
return new SavedObject(this.storageProvider, this.storageName);
|
|
1623
|
+
}
|
|
1624
|
+
}]);
|
|
1625
|
+
}();
|
|
1626
|
+
var LocalStorageManager = /*#__PURE__*/function (_BaseStorageManager2) {
|
|
1627
|
+
function LocalStorageManager(storageName) {
|
|
1628
|
+
_classCallCheck(this, LocalStorageManager);
|
|
1629
|
+
return _callSuper(this, LocalStorageManager, [storageName, window.localStorage]);
|
|
1630
|
+
}
|
|
1631
|
+
_inherits(LocalStorageManager, _BaseStorageManager2);
|
|
1632
|
+
return _createClass(LocalStorageManager);
|
|
1633
|
+
}(BaseStorageManager);
|
|
1634
|
+
|
|
1635
|
+
/***/ }),
|
|
1636
|
+
/* 23 */
|
|
1637
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1638
|
+
|
|
1639
|
+
"use strict";
|
|
1640
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1641
|
+
/* harmony import */ var _buildAuthEndpointUrl__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
|
|
1642
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildAuthEndpointUrl", function() { return _buildAuthEndpointUrl__WEBPACK_IMPORTED_MODULE_0__["buildAuthEndpointUrl"]; });
|
|
1643
|
+
|
|
1644
|
+
/*!
|
|
1645
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1646
|
+
*
|
|
1647
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1648
|
+
*
|
|
1649
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1650
|
+
*
|
|
1651
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1652
|
+
*/
|
|
1653
|
+
|
|
1654
|
+
|
|
1655
|
+
/***/ }),
|
|
1656
|
+
/* 24 */
|
|
1657
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1658
|
+
|
|
1659
|
+
"use strict";
|
|
1660
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1661
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildAuthEndpointUrl", function() { return buildAuthEndpointUrl; });
|
|
1662
|
+
/*!
|
|
1663
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
1664
|
+
*
|
|
1665
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1666
|
+
*
|
|
1667
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1668
|
+
*
|
|
1669
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1670
|
+
*/
|
|
1671
|
+
var buildAuthEndpointUrl = function buildAuthEndpointUrl(signInParams, loginEndPoint) {
|
|
1672
|
+
var loginUrl = new URL(loginEndPoint);
|
|
1673
|
+
loginUrl.searchParams.append('origin_url', window.location.href);
|
|
1674
|
+
loginUrl.searchParams.append('redirect_uri', signInParams.redirectUri);
|
|
1675
|
+
loginUrl.searchParams.append('response_type', signInParams.responseType);
|
|
1676
|
+
loginUrl.searchParams.append('scope', signInParams.scope);
|
|
1677
|
+
|
|
1678
|
+
// pkce params
|
|
1679
|
+
loginUrl.searchParams.append('code_challenge', signInParams.codeChallenge);
|
|
1680
|
+
loginUrl.searchParams.append('code_challenge_method', signInParams.codeChallengeMethod);
|
|
1681
|
+
|
|
1682
|
+
// as long as it is defined we will use it
|
|
1683
|
+
if (signInParams.state !== undefined) {
|
|
1684
|
+
loginUrl.searchParams.append('state', signInParams.state);
|
|
1685
|
+
}
|
|
1686
|
+
return loginUrl.href;
|
|
1687
|
+
};
|
|
1688
|
+
|
|
1689
|
+
/***/ }),
|
|
1690
|
+
/* 25 */
|
|
1691
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1692
|
+
|
|
1693
|
+
"use strict";
|
|
1694
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1695
|
+
/* harmony import */ var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
|
|
1696
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TokenManager", function() { return _lib__WEBPACK_IMPORTED_MODULE_0__["TokenManager"]; });
|
|
1697
|
+
|
|
1698
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return _lib__WEBPACK_IMPORTED_MODULE_0__["TransactionManager"]; });
|
|
1699
|
+
|
|
1700
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseStorageManager", function() { return _lib__WEBPACK_IMPORTED_MODULE_0__["BaseStorageManager"]; });
|
|
1701
|
+
|
|
1702
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LocalStorageManager", function() { return _lib__WEBPACK_IMPORTED_MODULE_0__["LocalStorageManager"]; });
|
|
1703
|
+
|
|
1704
|
+
/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
1705
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthCore", function() { return _auth__WEBPACK_IMPORTED_MODULE_1__["OCAuthCore"]; });
|
|
1706
|
+
|
|
1707
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthLive", function() { return _auth__WEBPACK_IMPORTED_MODULE_1__["OCAuthLive"]; });
|
|
1708
|
+
|
|
1709
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OCAuthSandbox", function() { return _auth__WEBPACK_IMPORTED_MODULE_1__["OCAuthSandbox"]; });
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
/***/ }),
|
|
1715
|
+
/* 26 */
|
|
1716
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1717
|
+
|
|
1718
|
+
"use strict";
|
|
1719
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1720
|
+
/* harmony import */ var _TokenManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
|
|
1721
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TokenManager", function() { return _TokenManager__WEBPACK_IMPORTED_MODULE_0__["default"]; });
|
|
1722
|
+
|
|
1723
|
+
/* harmony import */ var _TransactionManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
|
|
1724
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return _TransactionManager__WEBPACK_IMPORTED_MODULE_1__["default"]; });
|
|
1725
|
+
|
|
1726
|
+
/* harmony import */ var _StorageManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(22);
|
|
1727
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseStorageManager", function() { return _StorageManager__WEBPACK_IMPORTED_MODULE_2__["BaseStorageManager"]; });
|
|
1728
|
+
|
|
1729
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LocalStorageManager", function() { return _StorageManager__WEBPACK_IMPORTED_MODULE_2__["LocalStorageManager"]; });
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
/***/ })
|
|
1736
|
+
/******/ ]);
|
|
1737
|
+
});
|
|
1738
|
+
//# sourceMappingURL=ocid-connect-js.js.map
|