@logto/vue 2.0.1 → 2.0.3

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
@@ -5,8 +5,6 @@
5
5
 
6
6
  The Logto Vue SDK written in TypeScript. Check out our [integration guide](https://docs.logto.io/docs/recipes/integrate-logto/vue) or [docs](https://docs.logto.io/sdk/JavaScript/vue/) for more information.
7
7
 
8
- We also provide [集成指南](https://docs.logto.io/zh-cn/docs/recipes/integrate-logto/vue/) and [文档](https://docs.logto.io/zh-cn/sdk/JavaScript/vue/) in Simplified Chinese.
9
-
10
8
  ## Installation
11
9
 
12
10
  ### Using npm
package/lib/index.cjs CHANGED
@@ -95,9 +95,14 @@ const useHandleSignInCallback = (callback) => {
95
95
  }
96
96
  const { isAuthenticated, isLoading, logtoClient, error } = context$1;
97
97
  const { handleSignInCallback } = plugin.createPluginMethods(context$1);
98
- vue.watchEffect(() => {
98
+ vue.watchEffect(async () => {
99
+ if (!logtoClient.value) {
100
+ return;
101
+ }
99
102
  const currentPageUrl = window.location.href;
100
- if (!isAuthenticated.value && logtoClient.value?.isSignInRedirected(currentPageUrl)) {
103
+ const isAuthenticated = await logtoClient.value.isAuthenticated();
104
+ const isRedirected = await logtoClient.value.isSignInRedirected(currentPageUrl);
105
+ if (!isAuthenticated && isRedirected) {
101
106
  void handleSignInCallback(currentPageUrl, callback);
102
107
  }
103
108
  });
@@ -116,6 +121,10 @@ Object.defineProperty(exports, 'LogtoError', {
116
121
  enumerable: true,
117
122
  get: function () { return LogtoClient.LogtoError; }
118
123
  });
124
+ Object.defineProperty(exports, 'LogtoRequestError', {
125
+ enumerable: true,
126
+ get: function () { return LogtoClient.LogtoRequestError; }
127
+ });
119
128
  Object.defineProperty(exports, 'OidcError', {
120
129
  enumerable: true,
121
130
  get: function () { return LogtoClient.OidcError; }
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { IdTokenClaims, LogtoConfig, UserInfoResponse } from '@logto/browser';
2
2
  import type { App, Ref } from 'vue';
3
3
  export type { LogtoConfig, IdTokenClaims, UserInfoResponse, LogtoErrorCode, LogtoClientErrorCode, InteractionMode, } from '@logto/browser';
4
- export { LogtoError, LogtoClientError, OidcError, Prompt, ReservedScope, UserScope, } from '@logto/browser';
4
+ export { LogtoError, LogtoClientError, LogtoRequestError, OidcError, Prompt, ReservedScope, UserScope, } from '@logto/browser';
5
5
  type LogtoVuePlugin = {
6
6
  install: (app: App, config: LogtoConfig) => void;
7
7
  };
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import LogtoClient from '@logto/browser';
2
- export { LogtoClientError, LogtoError, OidcError, Prompt, ReservedScope, UserScope } from '@logto/browser';
2
+ export { LogtoClientError, LogtoError, LogtoRequestError, OidcError, Prompt, ReservedScope, UserScope } from '@logto/browser';
3
3
  import { readonly, inject, watchEffect } from 'vue';
4
4
  import { contextInjectionKey, logtoInjectionKey } from './consts.js';
5
5
  import { createContext, throwContextError } from './context.js';
@@ -90,9 +90,14 @@ const useHandleSignInCallback = (callback) => {
90
90
  }
91
91
  const { isAuthenticated, isLoading, logtoClient, error } = context;
92
92
  const { handleSignInCallback } = createPluginMethods(context);
93
- watchEffect(() => {
93
+ watchEffect(async () => {
94
+ if (!logtoClient.value) {
95
+ return;
96
+ }
94
97
  const currentPageUrl = window.location.href;
95
- if (!isAuthenticated.value && logtoClient.value?.isSignInRedirected(currentPageUrl)) {
98
+ const isAuthenticated = await logtoClient.value.isAuthenticated();
99
+ const isRedirected = await logtoClient.value.isSignInRedirected(currentPageUrl);
100
+ if (!isAuthenticated && isRedirected) {
96
101
  void handleSignInCallback(currentPageUrl, callback);
97
102
  }
98
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/vue",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",
@@ -21,19 +21,19 @@
21
21
  "directory": "packages/vue"
22
22
  },
23
23
  "dependencies": {
24
- "@logto/browser": "^2.0.0"
24
+ "@logto/browser": "^2.1.2"
25
25
  },
26
26
  "devDependencies": {
27
- "@silverhand/eslint-config": "^3.0.1",
28
- "@silverhand/ts-config": "^3.0.0",
27
+ "@silverhand/eslint-config": "^4.0.1",
28
+ "@silverhand/ts-config": "^4.0.0",
29
29
  "@swc/core": "^1.3.50",
30
30
  "@swc/jest": "^0.2.24",
31
31
  "@types/jest": "^29.5.0",
32
- "eslint": "^8.38.0",
32
+ "eslint": "^8.44.0",
33
33
  "jest": "^29.5.0",
34
- "lint-staged": "^13.0.0",
34
+ "lint-staged": "^14.0.0",
35
35
  "postcss": "^8.4.6",
36
- "prettier": "^2.8.7",
36
+ "prettier": "^3.0.0",
37
37
  "stylelint": "^15.0.0",
38
38
  "typescript": "^5.0.0",
39
39
  "vue": "^3.2.35"