@levellink/core
Advanced tools
Comparing version 2.0.16 to 2.0.17
# @levellink/core | ||
## 2.0.17 | ||
### Patch Changes | ||
- 适配login | ||
## 2.0.16 | ||
@@ -4,0 +10,0 @@ |
@@ -21,2 +21,4 @@ import type { FC } from 'react'; | ||
export interface ContextProps { | ||
beforeLogin?: () => void; | ||
afterLogin?: () => void; | ||
customToast: any; | ||
@@ -23,0 +25,0 @@ getWallet: () => Promise<WalletInfo>; |
@@ -45,3 +45,5 @@ 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); } | ||
customToast = _ref.customToast, | ||
walletURL = _ref.walletURL; | ||
walletURL = _ref.walletURL, | ||
beforeLogin = _ref.beforeLogin, | ||
afterLogin = _ref.afterLogin; | ||
var _useState = useState(null), | ||
@@ -86,3 +88,3 @@ _useState2 = _slicedToArray(_useState, 2), | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var urlParams, token, nodeId, publicKey, chainId, decodedToken, decodedNodeId, newUrl, newQueryString, cleanURL, tokenInStorage; | ||
var isXallerWallet, urlParams, token, nodeId, publicKey, chainId, decodedToken, decodedNodeId, newUrl, newQueryString, cleanURL, tokenInStorage; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
@@ -92,9 +94,14 @@ while (1) switch (_context2.prev = _context2.next) { | ||
_context2.prev = 0; | ||
if (!(Cookies.get('MAGAPE_TYPE') === '3' && Cookies.get('MAGAPE_TOKEN') && Cookies.get('MAGAPE_AUTHORIZATION'))) { | ||
_context2.next = 4; | ||
isXallerWallet = Cookies.get('MAGAPE_TYPE') === '3' && Cookies.get('MAGAPE_TOKEN') && Cookies.get('MAGAPE_AUTHORIZATION'); | ||
if (!isXallerWallet) { | ||
_context2.next = 8; | ||
break; | ||
} | ||
updateWalletInfo(); | ||
beforeLogin === null || beforeLogin === void 0 || beforeLogin(); | ||
_context2.next = 6; | ||
return updateWalletInfo(); | ||
case 6: | ||
afterLogin === null || afterLogin === void 0 || afterLogin(); | ||
return _context2.abrupt("return"); | ||
case 4: | ||
case 8: | ||
urlParams = new URLSearchParams(window.location.search); | ||
@@ -106,12 +113,12 @@ token = urlParams.get(TOKEN_NAME) && decodeURIComponent(urlParams.get(TOKEN_NAME)); | ||
if (!(token && nodeId)) { | ||
_context2.next = 30; | ||
_context2.next = 34; | ||
break; | ||
} | ||
_context2.next = 12; | ||
_context2.next = 16; | ||
return deCrypto(token, DECRYPTOKEY); | ||
case 12: | ||
case 16: | ||
decodedToken = _context2.sent; | ||
_context2.next = 15; | ||
_context2.next = 19; | ||
return deCrypto(nodeId, DECRYPTOKEY); | ||
case 15: | ||
case 19: | ||
decodedNodeId = _context2.sent; | ||
@@ -136,3 +143,3 @@ localStorage.setItem(TOKEN_NAME, decodedToken); | ||
window.history.replaceState({}, document.title, cleanURL); | ||
case 30: | ||
case 34: | ||
tokenInStorage = localStorage.getItem(TOKEN_NAME); | ||
@@ -142,14 +149,14 @@ if (localStorage.getItem(TOKEN_NAME) && (tokenInStorage === null || tokenInStorage === void 0 ? void 0 : tokenInStorage.split('.')[0]) !== 'free') { | ||
} | ||
_context2.next = 37; | ||
_context2.next = 41; | ||
break; | ||
case 34: | ||
_context2.prev = 34; | ||
case 38: | ||
_context2.prev = 38; | ||
_context2.t0 = _context2["catch"](0); | ||
console.error('Error during initialization:', _context2.t0); | ||
// 处理错误 | ||
case 37: | ||
case 41: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, null, [[0, 34]]); | ||
}, _callee2, null, [[0, 38]]); | ||
})); | ||
@@ -156,0 +163,0 @@ return function initialize() { |
@@ -112,3 +112,3 @@ 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); } | ||
type: type, | ||
networkId: localStorage.getItem('nodeId'), | ||
networkId: localStorage.getItem('nodeId') || Cookies.get('nodeId'), | ||
requestId: getNaMs().toString() | ||
@@ -115,0 +115,0 @@ }), |
@@ -21,2 +21,4 @@ import type { FC } from 'react'; | ||
export interface ContextProps { | ||
beforeLogin?: () => void; | ||
afterLogin?: () => void; | ||
customToast: any; | ||
@@ -23,0 +25,0 @@ getWallet: () => Promise<WalletInfo>; |
@@ -43,3 +43,5 @@ "use strict"; | ||
customToast, | ||
walletURL | ||
walletURL, | ||
beforeLogin, | ||
afterLogin | ||
}) => { | ||
@@ -60,4 +62,7 @@ const [wallet, setWallet] = (0, _react.useState)(null); | ||
try { | ||
if (_jsCookie.default.get('MAGAPE_TYPE') === '3' && _jsCookie.default.get('MAGAPE_TOKEN') && _jsCookie.default.get('MAGAPE_AUTHORIZATION')) { | ||
updateWalletInfo(); | ||
const isXallerWallet = _jsCookie.default.get('MAGAPE_TYPE') === '3' && _jsCookie.default.get('MAGAPE_TOKEN') && _jsCookie.default.get('MAGAPE_AUTHORIZATION'); | ||
if (isXallerWallet) { | ||
beforeLogin?.(); | ||
await updateWalletInfo(); | ||
afterLogin?.(); | ||
return; | ||
@@ -64,0 +69,0 @@ } |
@@ -73,3 +73,3 @@ "use strict"; | ||
type, | ||
networkId: localStorage.getItem('nodeId'), | ||
networkId: localStorage.getItem('nodeId') || _jsCookie.default.get('nodeId'), | ||
requestId: (0, _time.getNaMs)().toString() | ||
@@ -76,0 +76,0 @@ }, |
{ | ||
"name": "@levellink/core", | ||
"description": "the ui for levellink apps", | ||
"version": "2.0.16", | ||
"version": "2.0.17", | ||
"main": "dist/lib/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/esm/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
354585
8368