@logto/vue 1.0.0-beta.13 → 1.0.0-beta.15
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/lib/module.d.mts +82 -0
- package/package.json +4 -4
package/lib/module.d.mts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { IdTokenClaims, LogtoConfig, UserInfoResponse } from "@logto/browser";
|
|
2
|
+
import { App, Ref } from "vue";
|
|
3
|
+
export type { LogtoConfig, IdTokenClaims, UserInfoResponse, LogtoErrorCode, LogtoClientErrorCode, } from '@logto/browser';
|
|
4
|
+
export { LogtoError, LogtoClientError, OidcError, Prompt, ReservedScope, UserScope, } from '@logto/browser';
|
|
5
|
+
type LogtoVuePlugin = {
|
|
6
|
+
install: (app: App, config: LogtoConfig) => void;
|
|
7
|
+
};
|
|
8
|
+
type Logto = {
|
|
9
|
+
isAuthenticated: Readonly<Ref<boolean>>;
|
|
10
|
+
isLoading: Readonly<Ref<boolean>>;
|
|
11
|
+
error: Readonly<Ref<Error | undefined>>;
|
|
12
|
+
fetchUserInfo: () => Promise<UserInfoResponse | undefined>;
|
|
13
|
+
getAccessToken: (resource?: string) => Promise<string | undefined>;
|
|
14
|
+
getIdTokenClaims: () => Promise<IdTokenClaims | undefined>;
|
|
15
|
+
signIn: (redirectUri: string) => Promise<void>;
|
|
16
|
+
signOut: (postLogoutRedirectUri?: string) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Creates the Logto Vue plugin
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createApp } from 'vue';
|
|
23
|
+
* import { createLogto } from '@logto/vue';
|
|
24
|
+
*
|
|
25
|
+
* const app = createApp(App);
|
|
26
|
+
* const app.use(createLogto, {
|
|
27
|
+
* appId: '<your-app-id>',
|
|
28
|
+
* endpoint: '<your-oidc-endpoint-domain>',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* app.mount('#app');
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Use this in your Vue root component to register the plugin
|
|
35
|
+
*/
|
|
36
|
+
export const createLogto: LogtoVuePlugin;
|
|
37
|
+
/**
|
|
38
|
+
* A Vue composable method that provides the Logto reactive refs and auth methods.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { useLogto } from '@logto/vue';
|
|
42
|
+
*
|
|
43
|
+
* export default {
|
|
44
|
+
* setup() {
|
|
45
|
+
* const { isAuthenticated, signIn } = useLogto();
|
|
46
|
+
*
|
|
47
|
+
* return {
|
|
48
|
+
* isAuthenticated,
|
|
49
|
+
* onClickSignIn: () => {
|
|
50
|
+
* signIn('<your-redirect-uri>');
|
|
51
|
+
* },
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Use this composable in the setup script of your Vue component to make sure the injection works
|
|
58
|
+
*/
|
|
59
|
+
export const useLogto: () => Logto;
|
|
60
|
+
/**
|
|
61
|
+
* A Vue composable method that watches browser navigation and automatically handles the sign-in callback
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { useLogto } from '@logto/vue';
|
|
65
|
+
* import { useHandleSignInCallback } from '@logto/vue';
|
|
66
|
+
*
|
|
67
|
+
* export default {
|
|
68
|
+
* setup() {
|
|
69
|
+
* useHandleSignInCallback();
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Use this in the setup script of your Callback page to make sure the injection works
|
|
75
|
+
*/
|
|
76
|
+
export const useHandleSignInCallback: (callback?: () => void) => {
|
|
77
|
+
isLoading: Readonly<Ref<boolean>>;
|
|
78
|
+
isAuthenticated: Readonly<Ref<boolean>>;
|
|
79
|
+
error: Readonly<Ref<Error | undefined>>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/vue",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
4
4
|
"source": "./src/index.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"dev:tsc": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
|
|
23
23
|
"precommit": "lint-staged",
|
|
24
24
|
"check": "tsc --noEmit",
|
|
25
|
-
"build": "rm -rf lib/ && pnpm check && parcel build",
|
|
25
|
+
"build": "rm -rf lib/ && pnpm check && parcel build && cp lib/index.d.ts lib/module.d.mts",
|
|
26
26
|
"lint": "eslint --ext .ts src",
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"test:coverage": "jest --silent --coverage",
|
|
29
29
|
"prepack": "pnpm test"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@logto/browser": "^1.0.0-beta.
|
|
32
|
+
"@logto/browser": "^1.0.0-beta.15"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jest/types": "^27.5.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "4dcfacd4a1b5d5fa5c7c83edb34c591fab2a8f44"
|
|
74
74
|
}
|