@opencampus/ocid-connect-js 2.0.0 → 2.0.2

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 CHANGED
@@ -301,17 +301,17 @@ import LoginButton from '../components/LoginButton';
301
301
  import { useOCAuth } from '@opencampus/ocid-connect-js';
302
302
 
303
303
  export default function Home() {
304
- const { authState, ocAuth } = useOCAuth();
305
-
306
- if (authState.error) {
307
- return <div>Error: {authState.error.message}</div>;
308
- }
304
+ const { isInitialized, authState, ocAuth } = useOCAuth();
309
305
 
310
306
  // Add a loading state
311
- if (authState.isLoading) {
307
+ if (!isInitialized) {
312
308
  return <div>Loading...</div>;
313
309
  }
314
310
 
311
+ if (authState.error) {
312
+ return <div>Error: {authState.error.message}</div>;
313
+ }
314
+
315
315
  return (
316
316
  <div>
317
317
  <h1>Welcome to My App</h1>
@@ -2415,13 +2415,13 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
2415
2415
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2416
2416
  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); }
2417
2417
  /*!
2418
- * Copyright 2024-Present Animoca Brands Corporation Ltd.
2419
- *
2420
- * 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:
2421
- *
2422
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2423
- *
2424
- * 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.
2418
+ * Copyright 2024-Present Animoca Brands Corporation Ltd.
2419
+ *
2420
+ * 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:
2421
+ *
2422
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2423
+ *
2424
+ * 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.
2425
2425
  */
2426
2426
 
2427
2427
  var CookieStorageProvider = /*#__PURE__*/function () {
@@ -2430,13 +2430,20 @@ var CookieStorageProvider = /*#__PURE__*/function () {
2430
2430
  _classCallCheck(this, CookieStorageProvider);
2431
2431
  _defineProperty(this, "domain", void 0);
2432
2432
  _defineProperty(this, "sameSite", void 0);
2433
+ _defineProperty(this, "keyPrefix", void 0);
2433
2434
  this.domain = options.domain;
2434
2435
  this.sameSite = options.sameSite;
2436
+ this.keyPrefix = options.cookieKeyPrefix;
2435
2437
  }
2436
2438
  return _createClass(CookieStorageProvider, [{
2439
+ key: "getKey",
2440
+ value: function getKey(key) {
2441
+ return this.keyPrefix ? "".concat(this.keyPrefix, "-").concat(key) : key;
2442
+ }
2443
+ }, {
2437
2444
  key: "getItem",
2438
2445
  value: function getItem(key) {
2439
- return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.get(key);
2446
+ return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.get(this.getKey(key));
2440
2447
  }
2441
2448
  }, {
2442
2449
  key: "setItem",
@@ -2454,12 +2461,12 @@ var CookieStorageProvider = /*#__PURE__*/function () {
2454
2461
  }
2455
2462
 
2456
2463
  // if sameSite is undefined or null, leave default browser behavior
2457
- return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.set(key, value, cookieOptions);
2464
+ return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.set(this.getKey(key), value, cookieOptions);
2458
2465
  }
2459
2466
  }, {
2460
2467
  key: "removeItem",
2461
2468
  value: function removeItem(key) {
2462
- return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.remove(key, {
2469
+ return js_cookie__WEBPACK_IMPORTED_MODULE_0___default.a.remove(this.getKey(key), {
2463
2470
  path: '/',
2464
2471
  domain: this.domain
2465
2472
  });