@opencampus/ocid-connect-js 1.2.6 → 2.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.
@@ -89,7 +89,7 @@ function LoginButton(_ref) {
89
89
  ocAuth = _useOCAuth.ocAuth;
90
90
  var customTheme = themes[theme] || themes['ocBlue'];
91
91
  var loginWithRedirect = /*#__PURE__*/function () {
92
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
92
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
93
93
  return _regeneratorRuntime().wrap(function _callee$(_context) {
94
94
  while (1) switch (_context.prev = _context.next) {
95
95
  case 0:
@@ -6,19 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _OCSpinner = _interopRequireDefault(require("./OCSpinner"));
9
10
  var _OCContext = require("./OCContext");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
12
14
  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; }
13
15
  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); }
14
16
  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); }); }; } /*!
15
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
16
- *
17
- * 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:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
- *
21
- * 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.
17
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
18
+ *
19
+ * 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:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22
+ *
23
+ * 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.
22
24
  */
23
25
  var handledRedirect = false;
24
26
  var LoginCallBack = function LoginCallBack(_ref) {
@@ -33,7 +35,7 @@ var LoginCallBack = function LoginCallBack(_ref) {
33
35
  setAuthError = _useOCAuth.setAuthError;
34
36
  (0, _react.useEffect)(function () {
35
37
  var handleLogin = /*#__PURE__*/function () {
36
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
37
39
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
40
  while (1) switch (_context.prev = _context.next) {
39
41
  case 0:
@@ -72,7 +74,18 @@ var LoginCallBack = function LoginCallBack(_ref) {
72
74
  if (isInitialized && authState.error !== undefined && !errorCallback) {
73
75
  return customErrorComponent ? customErrorComponent : /*#__PURE__*/_react["default"].createElement("div", null, "Error Logging in: ", authState.error.message);
74
76
  } else {
75
- return customLoadingComponent ? customLoadingComponent : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("h3", null, "Loading ......"));
77
+ return customLoadingComponent ? customLoadingComponent : /*#__PURE__*/_react["default"].createElement("div", {
78
+ style: {
79
+ height: '100vh',
80
+ width: '100%',
81
+ display: 'flex',
82
+ justifyContent: 'center',
83
+ alignItems: 'center'
84
+ }
85
+ }, /*#__PURE__*/_react["default"].createElement(_OCSpinner["default"], {
86
+ height: 100,
87
+ width: 100
88
+ }));
76
89
  }
77
90
  };
78
91
  var _default = exports["default"] = LoginCallBack;
@@ -16,13 +16,13 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
16
16
  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; }
17
17
  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; } }
18
18
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /*!
19
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
20
- *
21
- * 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:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
24
- *
25
- * 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.
19
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
20
+ *
21
+ * 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:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
24
+ *
25
+ * 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.
26
26
  */
27
27
  var OCConnect = function OCConnect(_ref) {
28
28
  var children = _ref.children,
@@ -0,0 +1,25 @@
1
+ .oc-spinner-container {
2
+ position: relative;
3
+
4
+ .oc-logo-img {
5
+ position: absolute;
6
+ top: 15%;
7
+ left: 15%;
8
+ }
9
+
10
+ .oc-spinner {
11
+ width: 100%;
12
+ height: 100%;
13
+ border-radius: 50%;
14
+ background: radial-gradient(farthest-side,#141BEB 94%,#0000) top/9px 9px no-repeat,
15
+ conic-gradient(#00EDBE 30%,#141BEB);
16
+ -webkit-mask: radial-gradient(farthest-side,#0000 calc(100% - 9px),#000 0);
17
+ animation: spinner-oc-animation 1s infinite linear;
18
+ }
19
+ }
20
+
21
+ @keyframes spinner-oc-animation {
22
+ 100% {
23
+ transform: rotate(1turn);
24
+ }
25
+ }
@@ -0,0 +1,6 @@
1
+ export default OCSpinner;
2
+ declare function OCSpinner({ width, height }: {
3
+ width: any;
4
+ height: any;
5
+ }): React.JSX.Element;
6
+ import React from 'react';
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ require("./OCSpinner.css");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ /*!
11
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
12
+ *
13
+ * 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:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16
+ *
17
+ * 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.
18
+ */
19
+
20
+ var OCSpinner = function OCSpinner(_ref) {
21
+ var width = _ref.width,
22
+ height = _ref.height;
23
+ return /*#__PURE__*/_react["default"].createElement("div", {
24
+ className: "oc-spinner-container",
25
+ style: {
26
+ width: width || 80,
27
+ height: height || 80
28
+ }
29
+ }, /*#__PURE__*/_react["default"].createElement("div", {
30
+ className: "oc-spinner"
31
+ }), /*#__PURE__*/_react["default"].createElement("img", {
32
+ className: "oc-logo-img",
33
+ alt: "logo",
34
+ src: "https://static.opencampus.xyz/assets/oc_logo.svg",
35
+ width: "70%",
36
+ height: "70%"
37
+ }));
38
+ };
39
+ var _default = exports["default"] = OCSpinner;
package/lib/sdk/auth.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export class OCAuthCore {
2
- constructor(loginEndpoint: any, redirectUri: any, transactionManager: any, tokenManager: any, referralCode: any, logoutEndPoint: any);
2
+ constructor(clientId: any, loginEndpoint: any, redirectUri: any, transactionManager: any, tokenManager: any, referralCode: any, logoutEndPoint: any);
3
+ clientId: any;
3
4
  tokenManager: any;
4
5
  authInfoManager: AuthInfoManager;
5
6
  transactionManager: any;
package/lib/sdk/auth.js CHANGED
@@ -29,17 +29,18 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
29
29
  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; }
30
30
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
31
31
  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); } /*!
32
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
33
- *
34
- * 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:
35
- *
36
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37
- *
38
- * 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.
32
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
33
+ *
34
+ * 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:
35
+ *
36
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37
+ *
38
+ * 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.
39
39
  */
40
40
  var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
41
- function OCAuthCore(loginEndpoint, redirectUri, transactionManager, tokenManager, referralCode, logoutEndPoint) {
41
+ function OCAuthCore(clientId, loginEndpoint, redirectUri, transactionManager, tokenManager, referralCode, logoutEndPoint) {
42
42
  _classCallCheck(this, OCAuthCore);
43
+ _defineProperty(this, "clientId", void 0);
43
44
  _defineProperty(this, "tokenManager", void 0);
44
45
  _defineProperty(this, "authInfoManager", void 0);
45
46
  _defineProperty(this, "transactionManager", void 0);
@@ -47,6 +48,9 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
47
48
  _defineProperty(this, "loginEndPoint", void 0);
48
49
  _defineProperty(this, "logoutEndPoint", void 0);
49
50
  _defineProperty(this, "referralCode", void 0);
51
+ if (!clientId) {
52
+ throw new _errors.InvalidParamsError('clientId is not defined');
53
+ }
50
54
  this.transactionManager = transactionManager;
51
55
  this.tokenManager = tokenManager;
52
56
  this.authInfoManager = new _AuthInfoManager["default"]();
@@ -54,6 +58,7 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
54
58
  this.logoutEndPoint = logoutEndPoint;
55
59
  this.redirectUri = redirectUri;
56
60
  this.referralCode = referralCode;
61
+ this.clientId = clientId;
57
62
  this.syncAuthInfo();
58
63
  }
59
64
  return _createClass(OCAuthCore, [{
@@ -65,7 +70,7 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
65
70
  }, {
66
71
  key: "logout",
67
72
  value: function () {
68
- var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(logoutReturnTo) {
73
+ var _logout = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(logoutReturnTo) {
69
74
  var url;
70
75
  return _regeneratorRuntime().wrap(function _callee$(_context) {
71
76
  while (1) switch (_context.prev = _context.next) {
@@ -90,7 +95,7 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
90
95
  }, {
91
96
  key: "signInWithRedirect",
92
97
  value: function () {
93
- var _signInWithRedirect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
98
+ var _signInWithRedirect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
94
99
  var paramsClone, signinParams, meta, requestUrl;
95
100
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
96
101
  while (1) switch (_context2.prev = _context2.next) {
@@ -99,16 +104,17 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
99
104
  // available in other OAuth SDKs.
100
105
  paramsClone = Object.assign({}, params);
101
106
  paramsClone.redirectUri = this.redirectUri;
102
- _context2.next = 4;
107
+ paramsClone.clientId = this.clientId;
108
+ _context2.next = 5;
103
109
  return (0, _utils.prepareTokenParams)(paramsClone);
104
- case 4:
110
+ case 5:
105
111
  signinParams = _context2.sent;
106
112
  meta = (0, _utils.createPkceMeta)(signinParams);
107
113
  this.transactionManager.save(meta);
108
114
  signinParams.referralCode = this.referralCode;
109
115
  requestUrl = (0, _endpoints.buildAuthEndpointUrl)(signinParams, this.loginEndPoint);
110
116
  window.location.assign(requestUrl);
111
- case 10:
117
+ case 11:
112
118
  case "end":
113
119
  return _context2.stop();
114
120
  }
@@ -122,7 +128,7 @@ var OCAuthCore = exports.OCAuthCore = /*#__PURE__*/function () {
122
128
  }, {
123
129
  key: "handleLoginRedirect",
124
130
  value: function () {
125
- var _handleLoginRedirect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
131
+ var _handleLoginRedirect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
126
132
  var urlParams, meta, codeVerifier;
127
133
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
128
134
  while (1) switch (_context3.prev = _context3.next) {
@@ -245,7 +251,8 @@ var OCAuthLive = exports.OCAuthLive = /*#__PURE__*/function (_OCAuthCore2) {
245
251
  overrideLogoutEndpoint = opts.logoutEndPoint,
246
252
  overridePublicKey = opts.publicKey,
247
253
  redirectUri = opts.redirectUri,
248
- referralCode = opts.referralCode;
254
+ referralCode = opts.referralCode,
255
+ clientId = opts.clientId;
249
256
  var tokenEndpoint = overrideTokenEndpoint || 'https://api.login.opencampus.xyz/auth/token';
250
257
  var loginEndpoint = overrideLoginEndpoint || 'https://api.login.opencampus.xyz/auth/login';
251
258
  var logoutEndpoint = overrideLogoutEndpoint || 'https://api.login.opencampus.xyz/auth/logout';
@@ -253,7 +260,7 @@ var OCAuthLive = exports.OCAuthLive = /*#__PURE__*/function (_OCAuthCore2) {
253
260
  var storageClass = (0, _StorageManager.getStorageClass)(opts);
254
261
  var pkceTransactionManager = new _TransactionManager["default"](storageClass);
255
262
  var tokenManager = new _TokenManager["default"](storageClass, tokenEndpoint, publicKey);
256
- return _callSuper(this, OCAuthLive, [loginEndpoint, redirectUri, pkceTransactionManager, tokenManager, referralCode, logoutEndpoint, false]);
263
+ return _callSuper(this, OCAuthLive, [clientId, loginEndpoint, redirectUri, pkceTransactionManager, tokenManager, referralCode, logoutEndpoint]);
257
264
  }
258
265
  _inherits(OCAuthLive, _OCAuthCore2);
259
266
  return _createClass(OCAuthLive);
@@ -268,6 +275,7 @@ var OCAuthSandbox = exports.OCAuthSandbox = /*#__PURE__*/function (_OCAuthCore3)
268
275
  overridePublicKey = opts.publicKey,
269
276
  redirectUri = opts.redirectUri,
270
277
  referralCode = opts.referralCode;
278
+ var clientId = opts.clientId || 'sandbox';
271
279
  var tokenEndpoint = overrideTokenEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/token';
272
280
  var loginEndpoint = overrideLoginEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/login';
273
281
  var logoutEndpoint = overrideLogoutEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/logout';
@@ -275,7 +283,7 @@ var OCAuthSandbox = exports.OCAuthSandbox = /*#__PURE__*/function (_OCAuthCore3)
275
283
  var storageClass = (0, _StorageManager.getStorageClass)(opts);
276
284
  var pkceTransactionManager = new _TransactionManager["default"](storageClass);
277
285
  var tokenManager = new _TokenManager["default"](storageClass, tokenEndpoint, publicKey);
278
- return _callSuper(this, OCAuthSandbox, [loginEndpoint, redirectUri, pkceTransactionManager, tokenManager, referralCode, logoutEndpoint, true]);
286
+ return _callSuper(this, OCAuthSandbox, [clientId, loginEndpoint, redirectUri, pkceTransactionManager, tokenManager, referralCode, logoutEndpoint]);
279
287
  }
280
288
  _inherits(OCAuthSandbox, _OCAuthCore3);
281
289
  return _createClass(OCAuthSandbox);
@@ -23,7 +23,7 @@ var prepareKey = function prepareKey(key) {
23
23
  return (0, _base.stringToBuffer)(binaryDerString);
24
24
  };
25
25
  var verifyToken = exports.verifyToken = /*#__PURE__*/function () {
26
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(idToken, key) {
26
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(idToken, key) {
27
27
  var format, algo, extractable, usages, preparedKey, cryptoKey, jwt, payload, b64Signature, signature;
28
28
  return _regeneratorRuntime().wrap(function _callee$(_context) {
29
29
  while (1) switch (_context.prev = _context.next) {
@@ -5,16 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildAuthEndpointUrl = void 0;
7
7
  /*!
8
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
9
- *
10
- * 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:
11
- *
12
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
- *
14
- * 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.
8
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
9
+ *
10
+ * 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:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
+ *
14
+ * 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.
15
15
  */
16
16
  var buildAuthEndpointUrl = exports.buildAuthEndpointUrl = function buildAuthEndpointUrl(signInParams, loginEndPoint) {
17
17
  var loginUrl = new URL(loginEndPoint);
18
+ loginUrl.searchParams.append('client_id', signInParams.clientId);
18
19
  loginUrl.searchParams.append('origin_url', window.location.href);
19
20
  loginUrl.searchParams.append('redirect_uri', signInParams.redirectUri);
20
21
  loginUrl.searchParams.append('response_type', signInParams.responseType);
@@ -45,7 +45,7 @@ var TokenManager = /*#__PURE__*/function () {
45
45
  }, {
46
46
  key: "exchangeTokenFromCode",
47
47
  value: function () {
48
- var _exchangeTokenFromCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessCode, codeVerifier) {
48
+ var _exchangeTokenFromCode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessCode, codeVerifier) {
49
49
  var state,
50
50
  body,
51
51
  response,
@@ -152,7 +152,7 @@ var TokenManager = /*#__PURE__*/function () {
152
152
  }, {
153
153
  key: "getPublicKey",
154
154
  value: function () {
155
- var _getPublicKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
155
+ var _getPublicKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
156
156
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
157
157
  while (1) switch (_context2.prev = _context2.next) {
158
158
  case 0:
@@ -36,7 +36,7 @@ var InternalError = exports.InternalError = /*#__PURE__*/function (_Error) {
36
36
  }
37
37
  _inherits(InternalError, _Error);
38
38
  return _createClass(InternalError);
39
- }( /*#__PURE__*/_wrapNativeSuper(Error));
39
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
40
40
  var InvalidParamsError = exports.InvalidParamsError = /*#__PURE__*/function (_InternalError) {
41
41
  function InvalidParamsError() {
42
42
  _classCallCheck(this, InvalidParamsError);
@@ -52,4 +52,4 @@ var AuthError = exports.AuthError = /*#__PURE__*/function (_Error2) {
52
52
  }
53
53
  _inherits(AuthError, _Error2);
54
54
  return _createClass(AuthError);
55
- }( /*#__PURE__*/_wrapNativeSuper(Error));
55
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
@@ -1,4 +1,5 @@
1
1
  export function prepareTokenParams(params: any): Promise<{
2
+ clientId: any;
2
3
  redirectUri: any;
3
4
  codeVerifier: string;
4
5
  codeChallenge: any;
@@ -11,17 +11,17 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
11
11
  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; }
12
12
  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); }
13
13
  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); }); }; } /*!
14
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
15
- *
16
- * 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:
17
- *
18
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19
- *
20
- * 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.
14
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
15
+ *
16
+ * 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:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19
+ *
20
+ * 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.
21
21
  */
22
22
  var prepareTokenParams = exports.prepareTokenParams = /*#__PURE__*/function () {
23
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
24
- var redirectUri, state, codeVerifier, codeChallenge, tokenParams;
23
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
24
+ var clientId, redirectUri, state, codeVerifier, codeChallenge, tokenParams;
25
25
  return _regeneratorRuntime().wrap(function _callee$(_context) {
26
26
  while (1) switch (_context.prev = _context.next) {
27
27
  case 0:
@@ -29,7 +29,7 @@ var prepareTokenParams = exports.prepareTokenParams = /*#__PURE__*/function () {
29
29
  // mandatory redirect_uri, for now, we only allow user to set redirect_uri and state
30
30
  // again this is not a full on OIDC/OAuth flow allowing user to set all the options
31
31
  // we prepare all the rest
32
- redirectUri = params.redirectUri, state = params.state;
32
+ clientId = params.clientId, redirectUri = params.redirectUri, state = params.state;
33
33
  if (redirectUri) {
34
34
  _context.next = 3;
35
35
  break;
@@ -44,6 +44,7 @@ var prepareTokenParams = exports.prepareTokenParams = /*#__PURE__*/function () {
44
44
  codeChallenge = _context.sent;
45
45
  // pack up the full set of token params needed
46
46
  tokenParams = {
47
+ clientId: clientId,
47
48
  redirectUri: redirectUri,
48
49
  codeVerifier: codeVerifier,
49
50
  codeChallenge: codeChallenge,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencampus/ocid-connect-js",
3
- "version": "1.2.6",
3
+ "version": "2.0.0",
4
4
  "author": "Animoca Brands",
5
5
  "license": "MIT",
6
6
  "description": "OCID Connector Library",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "build-dev": "gulp clean && gulp copy && webpack",
14
14
  "generate-types": "tsc --declaration --allowJs --emitDeclarationOnly",
15
- "lib": "babel ./src --out-dir ./lib && yarn generate-types",
15
+ "lib": "babel ./src --out-dir ./lib && cp ./src/react/*.css lib/react/ && yarn generate-types",
16
16
  "build": "NODE_OPTIONS=--openssl-legacy-provider npm run lib && NODE_OPTIONS=--openssl-legacy-provider gulp dist",
17
17
  "prepublishOnly": "npm run build",
18
18
  "lint": "eslint src",