@sunggang/ui-lib 0.2.78 → 0.2.80

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/index.esm2.js CHANGED
@@ -58924,7 +58924,7 @@ var LiffProvider = function(param) {
58924
58924
  // 登入初始化函數
58925
58925
  var loginInit = function() {
58926
58926
  var _ref = _async_to_generator(function(token) {
58927
- var _resData_data, _resData_data1, response, resData, loginToken, err;
58927
+ var _resData_data, _resData_data1, _resData_data2, response, resData, loginToken, err;
58928
58928
  return _ts_generator(this, function(_state) {
58929
58929
  switch(_state.label){
58930
58930
  case 0:
@@ -58955,16 +58955,19 @@ var LiffProvider = function(param) {
58955
58955
  case 2:
58956
58956
  response = _state.sent();
58957
58957
  resData = response;
58958
+ console.log("login response", response);
58958
58959
  setLoginData(resData);
58959
58960
  if ((resData === null || resData === void 0 ? void 0 : (_resData_data = resData.data) === null || _resData_data === void 0 ? void 0 : _resData_data.access_token) && typeof resData.data.access_token === "string" && resData.data.access_token.trim() !== "" && !resData.data.access_token.startsWith("Bearer ")) {
58960
58961
  resData.data.access_token = "Bearer ".concat(resData.data.access_token);
58961
58962
  }
58963
+ console.log("has token", !!(resData === null || resData === void 0 ? void 0 : (_resData_data1 = resData.data) === null || _resData_data1 === void 0 ? void 0 : _resData_data1.access_token));
58962
58964
  window.localStorage.setItem(localStorageKey, JSON.stringify(resData));
58963
- loginToken = resData === null || resData === void 0 ? void 0 : (_resData_data1 = resData.data) === null || _resData_data1 === void 0 ? void 0 : _resData_data1.access_token;
58965
+ loginToken = resData === null || resData === void 0 ? void 0 : (_resData_data2 = resData.data) === null || _resData_data2 === void 0 ? void 0 : _resData_data2.access_token;
58964
58966
  if (loginToken) {
58965
58967
  setAccessToken(loginToken);
58966
58968
  if (memberInfoUrl) fetchMemberInfo(loginToken);
58967
58969
  } else {
58970
+ console.log(response);
58968
58971
  setUserInfo(response);
58969
58972
  if (handleLoginError) handleLoginError();
58970
58973
  }
@@ -58993,7 +58996,7 @@ var LiffProvider = function(param) {
58993
58996
  // 初始化 LIFF
58994
58997
  var initializeLiff = function() {
58995
58998
  var _ref = _async_to_generator(function(isValid) {
58996
- var customFetch, liff, originalFetch, lineToken, redirectUri, friendship, error, err;
58999
+ var customFetch, liff, originalFetch, friendship, error, lineToken, redirectUri, err;
58997
59000
  return _ts_generator(this, function(_state) {
58998
59001
  switch(_state.label){
58999
59002
  case 0:
@@ -59031,20 +59034,6 @@ var LiffProvider = function(param) {
59031
59034
  _state.sent();
59032
59035
  console.log("LIFF init succeeded.");
59033
59036
  setLiffObject(liff);
59034
- if (isValid) return [
59035
- 2
59036
- ];
59037
- lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
59038
- // 未登入先進行登入
59039
- if (!liff.isLoggedIn()) {
59040
- redirectUri = customerRedirectUrl || "".concat(window.location.href);
59041
- if (loginByUser || ignoreRoute) return [
59042
- 2
59043
- ];
59044
- liff.login({
59045
- redirectUri: redirectUri
59046
- });
59047
- }
59048
59037
  _state.label = 3;
59049
59038
  case 3:
59050
59039
  _state.trys.push([
@@ -59073,6 +59062,20 @@ var LiffProvider = function(param) {
59073
59062
  6
59074
59063
  ];
59075
59064
  case 6:
59065
+ if (isFriendship && isValid) return [
59066
+ 2
59067
+ ];
59068
+ lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
59069
+ // 未登入先進行登入
59070
+ if (!liff.isLoggedIn()) {
59071
+ redirectUri = customerRedirectUrl || "".concat(window.location.href);
59072
+ if (loginByUser || ignoreRoute) return [
59073
+ 2
59074
+ ];
59075
+ liff.login({
59076
+ redirectUri: redirectUri
59077
+ });
59078
+ }
59076
59079
  if (!lineToken) return [
59077
59080
  3,
59078
59081
  8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.2.78",
3
+ "version": "0.2.80",
4
4
  "dependencies": {
5
5
  "@iconify/react": "^4.1.1",
6
6
  "@material-ui/core": "^4.12.4",
@@ -6,6 +6,7 @@ type LiffContextType = {
6
6
  accessToken: string;
7
7
  liffError: string | null;
8
8
  initializeLiff: () => Promise<void>;
9
+ isFriendship: boolean | null;
9
10
  };
10
11
  export declare const LiffContext: React.Context<LiffContextType | undefined>;
11
12
  export declare const LiffProvider: ({ children, liffId, localStorageKey, checkTokenUrl, loginUrl, memberInfoUrl, openInApp, ignoreCheckAddFriend, ignoreRoute, loginByUser, customerRedirectUrl, inviteCode, handleLoginError, }: {