@moreillon/vue-oidc 0.0.6 → 0.0.7
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.
|
@@ -1,4 +1,78 @@
|
|
|
1
|
+
import type OidcClient from "@moreillon/oidc-auth";
|
|
1
2
|
export default function (): {
|
|
3
|
+
client: import("vue").Ref<{
|
|
4
|
+
cookieName: string;
|
|
5
|
+
options: {
|
|
6
|
+
redirect_uri: string;
|
|
7
|
+
authority: string;
|
|
8
|
+
client_id: string;
|
|
9
|
+
extraQueryParams?: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
};
|
|
13
|
+
openidConfig?: {
|
|
14
|
+
authorization_endpoint: string;
|
|
15
|
+
token_endpoint: string;
|
|
16
|
+
userinfo_endpoint: string;
|
|
17
|
+
end_session_endpoint: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
refreshEventHandlers: Function[];
|
|
20
|
+
init: (enforce?: boolean) => Promise<import("@moreillon/oidc-auth").InitOutput | undefined>;
|
|
21
|
+
sendUserToAuthUrl: (saveHref: Boolean) => Promise<void>;
|
|
22
|
+
fetchOidcConfig: () => Promise<any>;
|
|
23
|
+
generateAuthUrl: () => Promise<string>;
|
|
24
|
+
createTimeoutForTokenExpiry: (oidConfig: import("@moreillon/oidc-auth").OidcConfig) => void;
|
|
25
|
+
makeCookieOptions: () => string;
|
|
26
|
+
makeExpiryDate: (expires_in: number) => Date;
|
|
27
|
+
isExpired: (expires_at: string) => boolean;
|
|
28
|
+
saveAuthDataInCookies: (data: {
|
|
29
|
+
expires_in: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
exchangeCodeForToken: (code: string) => Promise<void>;
|
|
32
|
+
getUser: () => Promise<any>;
|
|
33
|
+
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<void>;
|
|
34
|
+
onTokenRefreshed: (handler: (oidcData: import("@moreillon/oidc-auth").Tokens) => void) => void;
|
|
35
|
+
runRefreshEventHandlers: (newTokens: import("@moreillon/oidc-auth").Tokens) => void;
|
|
36
|
+
login: () => void;
|
|
37
|
+
logout: () => void;
|
|
38
|
+
} | null, OidcClient | {
|
|
39
|
+
cookieName: string;
|
|
40
|
+
options: {
|
|
41
|
+
redirect_uri: string;
|
|
42
|
+
authority: string;
|
|
43
|
+
client_id: string;
|
|
44
|
+
extraQueryParams?: {
|
|
45
|
+
[key: string]: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
openidConfig?: {
|
|
49
|
+
authorization_endpoint: string;
|
|
50
|
+
token_endpoint: string;
|
|
51
|
+
userinfo_endpoint: string;
|
|
52
|
+
end_session_endpoint: string;
|
|
53
|
+
} | undefined;
|
|
54
|
+
refreshEventHandlers: Function[];
|
|
55
|
+
init: (enforce?: boolean) => Promise<import("@moreillon/oidc-auth").InitOutput | undefined>;
|
|
56
|
+
sendUserToAuthUrl: (saveHref: Boolean) => Promise<void>;
|
|
57
|
+
fetchOidcConfig: () => Promise<any>;
|
|
58
|
+
generateAuthUrl: () => Promise<string>;
|
|
59
|
+
createTimeoutForTokenExpiry: (oidConfig: import("@moreillon/oidc-auth").OidcConfig) => void;
|
|
60
|
+
makeCookieOptions: () => string;
|
|
61
|
+
makeExpiryDate: (expires_in: number) => Date;
|
|
62
|
+
isExpired: (expires_at: string) => boolean;
|
|
63
|
+
saveAuthDataInCookies: (data: {
|
|
64
|
+
expires_in: number;
|
|
65
|
+
}) => void;
|
|
66
|
+
exchangeCodeForToken: (code: string) => Promise<void>;
|
|
67
|
+
getUser: () => Promise<any>;
|
|
68
|
+
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<void>;
|
|
69
|
+
onTokenRefreshed: (handler: (oidcData: import("@moreillon/oidc-auth").Tokens) => void) => void;
|
|
70
|
+
runRefreshEventHandlers: (newTokens: import("@moreillon/oidc-auth").Tokens) => void;
|
|
71
|
+
login: () => void;
|
|
72
|
+
logout: () => void;
|
|
73
|
+
} | null>;
|
|
2
74
|
user: import("vue").Ref<any, any>;
|
|
3
75
|
access_token: import("vue").Ref<string | null, string | null>;
|
|
76
|
+
login: (() => void) | undefined;
|
|
77
|
+
logout: (() => void) | undefined;
|
|
4
78
|
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
+
const client = ref(null);
|
|
2
3
|
const user = ref(null);
|
|
3
4
|
const access_token = ref(null);
|
|
4
5
|
export default function () {
|
|
5
6
|
return {
|
|
7
|
+
client,
|
|
6
8
|
user,
|
|
7
9
|
access_token,
|
|
10
|
+
login: client.value?.login,
|
|
11
|
+
logout: client.value?.logout,
|
|
8
12
|
};
|
|
9
13
|
}
|
package/dist/plugins/auth.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import useAuth from "../composables/useAuth";
|
|
2
2
|
import OidcClient from "@moreillon/oidc-auth";
|
|
3
|
-
let oidcClient;
|
|
4
3
|
export default {
|
|
5
4
|
async install(app, options) {
|
|
6
5
|
const { enforce, ...oidcOptions } = options;
|
|
7
6
|
const auth = useAuth();
|
|
8
|
-
|
|
9
|
-
const oidcData = await
|
|
7
|
+
auth.client.value = new OidcClient(oidcOptions);
|
|
8
|
+
const oidcData = await auth.client.value.init(enforce);
|
|
10
9
|
if (!oidcData)
|
|
11
10
|
return;
|
|
12
11
|
const { user, tokens: { access_token }, } = oidcData;
|
|
13
12
|
auth.user.value = user;
|
|
14
13
|
auth.access_token.value = access_token;
|
|
15
|
-
|
|
14
|
+
auth.client.value.onTokenRefreshed(({ access_token }) => {
|
|
16
15
|
auth.access_token.value = access_token;
|
|
17
16
|
});
|
|
18
17
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moreillon/vue-oidc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@moreillon/oidc-auth": "^3.0.
|
|
14
|
+
"@moreillon/oidc-auth": "^3.0.3",
|
|
15
15
|
"vue": "^3.5.17"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|