@asgardeo/nuxt 0.0.0
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/LICENSE +201 -0
- package/README.md +26 -0
- package/dist/module.d.mts +36 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +68 -0
- package/dist/runtime/composables/asgardeo/useAuth.d.ts +19 -0
- package/dist/runtime/composables/asgardeo/useAuth.js +129 -0
- package/dist/runtime/server/handler.d.ts +31 -0
- package/dist/runtime/server/handler.js +231 -0
- package/dist/runtime/server/services/asgardeo/index.d.ts +23 -0
- package/dist/runtime/server/services/asgardeo/index.js +18 -0
- package/dist/runtime/types.d.ts +67 -0
- package/dist/runtime/types.js +0 -0
- package/dist/types.d.mts +9 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2005
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<p align="center" style="color: #343a40">
|
|
2
|
+
<h1 align="center">@asgardeo/nuxt</h1>
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center" style="font-size: 1.2rem;">Nuxt.js SDK for Asgardeo</p>
|
|
5
|
+
<div align="center">
|
|
6
|
+
<img alt="npm (scoped)" src="https://img.shields.io/npm/v/@asgardeo/nuxt">
|
|
7
|
+
<img alt="npm" src="https://img.shields.io/npm/dw/@asgardeo/nuxt">
|
|
8
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Using npm
|
|
15
|
+
npm install @asgardeo/nuxt
|
|
16
|
+
|
|
17
|
+
# or using pnpm
|
|
18
|
+
pnpm add @asgardeo/nuxt
|
|
19
|
+
|
|
20
|
+
# or using yarn
|
|
21
|
+
yarn add @asgardeo/nuxt
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
Apache-2.0
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NuxtModule } from 'nuxt/schema';
|
|
2
|
+
import { ModuleOptions } from '../dist/runtime/types.js';
|
|
3
|
+
export { BasicUserInfo } from '../dist/runtime/types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
7
|
+
*
|
|
8
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
9
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
10
|
+
* in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing,
|
|
16
|
+
* software distributed under the License is distributed on an
|
|
17
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
18
|
+
* KIND, either express or implied. See the License for the
|
|
19
|
+
* specific language governing permissions and limitations
|
|
20
|
+
* under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare const _default: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
24
|
+
|
|
25
|
+
declare module '@nuxt/schema' {
|
|
26
|
+
interface PublicRuntimeConfig {
|
|
27
|
+
asgardeoAuth: Pick<ModuleOptions, 'clientID' | 'baseUrl' | 'signInRedirectURL' | 'signOutRedirectURL' | 'scope'>;
|
|
28
|
+
}
|
|
29
|
+
interface RuntimeConfig {
|
|
30
|
+
asgardeoAuth: {
|
|
31
|
+
clientSecret: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addImports, addServerImports } from '@nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
|
|
4
|
+
const PACKAGE_NAME = "@asgardeo/nuxt";
|
|
5
|
+
const module = defineNuxtModule({
|
|
6
|
+
defaults: {
|
|
7
|
+
baseUrl: process.env.ASGARDEO_BASE_URL || "",
|
|
8
|
+
clientID: process.env.ASGARDEO_CLIENT_ID || "",
|
|
9
|
+
clientSecret: process.env.ASGARDEO_CLIENT_SECRET || "",
|
|
10
|
+
scope: ["openid", "profile"],
|
|
11
|
+
signInRedirectURL: process.env.ASGARDEO_SIGN_IN_REDIRECT_URL || "",
|
|
12
|
+
signOutRedirectURL: process.env.ASGARDEO_SIGN_OUT_REDIRECT_URL || ""
|
|
13
|
+
},
|
|
14
|
+
meta: {
|
|
15
|
+
configKey: "asgardeoAuth",
|
|
16
|
+
name: PACKAGE_NAME
|
|
17
|
+
},
|
|
18
|
+
setup(userOptions, nuxt) {
|
|
19
|
+
const options = defu(
|
|
20
|
+
userOptions,
|
|
21
|
+
nuxt.options.runtimeConfig.asgardeoAuth,
|
|
22
|
+
nuxt.options.runtimeConfig.public.asgardeoAuth,
|
|
23
|
+
{
|
|
24
|
+
clientID: process.env.ASGARDEO_CLIENT_ID,
|
|
25
|
+
clientSecret: process.env.ASGARDEO_CLIENT_SECRET,
|
|
26
|
+
enablePKCE: true,
|
|
27
|
+
scope: ["openid", "profile"],
|
|
28
|
+
serverOrigin: process.env.ASGARDEO_BASE_URL,
|
|
29
|
+
signInRedirectURL: process.env.ASGARDEO_SIGN_IN_REDIRECT_URL || "",
|
|
30
|
+
signOutRedirectURL: process.env.ASGARDEO_SIGN_OUT_REDIRECT_URL || ""
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
nuxt.options.runtimeConfig.public.asgardeoAuth = defu(nuxt.options.runtimeConfig.public.asgardeoAuth, {
|
|
34
|
+
clientID: options.clientID
|
|
35
|
+
});
|
|
36
|
+
nuxt.options.runtimeConfig.asgardeoAuth = defu(nuxt.options.runtimeConfig.asgardeoAuth, {
|
|
37
|
+
clientID: options.clientID,
|
|
38
|
+
clientSecret: options.clientSecret,
|
|
39
|
+
scope: options.scope,
|
|
40
|
+
serverOrigin: options.baseUrl,
|
|
41
|
+
signInRedirectURL: options.signInRedirectURL,
|
|
42
|
+
signOutRedirectURL: options.signOutRedirectURL
|
|
43
|
+
});
|
|
44
|
+
const { resolve } = createResolver(import.meta.url);
|
|
45
|
+
const runtimeDir = resolve("./runtime");
|
|
46
|
+
const runtimeServerDir = resolve("./runtime/server");
|
|
47
|
+
addImports({
|
|
48
|
+
from: resolve(runtimeDir, "composables/asgardeo/useAuth"),
|
|
49
|
+
name: "useAuth"
|
|
50
|
+
});
|
|
51
|
+
addServerImports([
|
|
52
|
+
{
|
|
53
|
+
as: "AsgardeoAuthHandler",
|
|
54
|
+
from: resolve(runtimeServerDir, "handler"),
|
|
55
|
+
name: "AsgardeoAuthHandler"
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
59
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
60
|
+
nitroConfig.alias["#auth/server"] = resolve(runtimeDir, "server/services/asgardeo");
|
|
61
|
+
nitroConfig.externals = defu(typeof nitroConfig.externals === "object" ? nitroConfig.externals : {}, {
|
|
62
|
+
inline: [resolve(runtimeDir)]
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export { module as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { AuthInterface } from '../../types.js';
|
|
19
|
+
export declare const useAuth: () => AuthInterface;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { navigateTo } from "#imports";
|
|
2
|
+
export const useAuth = () => {
|
|
3
|
+
const signIn = async (callbackUrl) => {
|
|
4
|
+
const options = {
|
|
5
|
+
external: true,
|
|
6
|
+
query: {}
|
|
7
|
+
};
|
|
8
|
+
const redirectParam = callbackUrl || (typeof window !== "undefined" ? window.location.pathname : "/");
|
|
9
|
+
options.query = { callbackUrl: redirectParam };
|
|
10
|
+
options.external = true;
|
|
11
|
+
await navigateTo("/api/auth/signin", options);
|
|
12
|
+
};
|
|
13
|
+
const getIdToken = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch("/api/auth/get-id-token", {
|
|
16
|
+
credentials: "include",
|
|
17
|
+
method: "GET"
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const data = await response.json();
|
|
23
|
+
return data.idToken;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getAccessToken = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch("/api/auth/get-access-token", {
|
|
31
|
+
credentials: "include",
|
|
32
|
+
method: "GET"
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
return data.accessToken;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const getDecodedIDToken = async () => {
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(`/api/auth/get-decoded-id-token`, {
|
|
46
|
+
credentials: "include",
|
|
47
|
+
method: "GET"
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const data = await response.json();
|
|
53
|
+
return data.decodedIDToken;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const revokeAccessToken = async () => {
|
|
59
|
+
await fetch("/api/auth/revoke-token", {
|
|
60
|
+
method: "POST"
|
|
61
|
+
}).catch((error) => error.data);
|
|
62
|
+
};
|
|
63
|
+
const isAuthenticated = async () => {
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch("/api/auth/isAuthenticated", {
|
|
66
|
+
credentials: "include",
|
|
67
|
+
method: "GET"
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return await response.json();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const signOut = async () => {
|
|
78
|
+
const options = { external: true };
|
|
79
|
+
await navigateTo("/api/auth/signout", options);
|
|
80
|
+
};
|
|
81
|
+
const getBasicUserInfo = async () => {
|
|
82
|
+
try {
|
|
83
|
+
const userInfo = await $fetch("/api/auth/user", {
|
|
84
|
+
method: "GET"
|
|
85
|
+
});
|
|
86
|
+
return userInfo;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const getOIDCServiceEndpoints = async () => {
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch("/api/auth/get-oidc-endpoints", {
|
|
94
|
+
method: "GET"
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return await response.json();
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const getDataLayer = async () => {
|
|
105
|
+
try {
|
|
106
|
+
const response = await fetch("/api/auth/get-data-layer", {
|
|
107
|
+
method: "GET"
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return await response.json();
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
getAccessToken,
|
|
119
|
+
getBasicUserInfo,
|
|
120
|
+
getDataLayer,
|
|
121
|
+
getDecodedIDToken,
|
|
122
|
+
getIdToken,
|
|
123
|
+
getOIDCServiceEndpoints,
|
|
124
|
+
isAuthenticated,
|
|
125
|
+
revokeAccessToken,
|
|
126
|
+
signIn,
|
|
127
|
+
signOut
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { type AuthClientConfig } from '@asgardeo/auth-node';
|
|
19
|
+
import type { CookieSerializeOptions } from 'cookie-es';
|
|
20
|
+
export interface AsgardeoAuthHandlerOptions {
|
|
21
|
+
basePath?: string;
|
|
22
|
+
cookies?: {
|
|
23
|
+
defaultOptions?: CookieSerializeOptions;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
sessionIdOptions?: CookieSerializeOptions;
|
|
26
|
+
state?: string;
|
|
27
|
+
stateOptions?: CookieSerializeOptions;
|
|
28
|
+
};
|
|
29
|
+
defaultCallbackUrl?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const AsgardeoAuthHandler: (config: AuthClientConfig, options?: AsgardeoAuthHandlerOptions) => any;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { defineEventHandler, sendRedirect, setCookie, deleteCookie, getQuery, getCookie, createError } from "h3";
|
|
3
|
+
import { getAsgardeoSdkInstance } from "./services/asgardeo/index.js";
|
|
4
|
+
function mergeCookieOptions(base, specific) {
|
|
5
|
+
const defaultBase = {
|
|
6
|
+
httpOnly: true,
|
|
7
|
+
path: "/",
|
|
8
|
+
sameSite: "lax",
|
|
9
|
+
secure: process.env.NODE_ENV === "production"
|
|
10
|
+
};
|
|
11
|
+
return { ...defaultBase, ...base, ...specific };
|
|
12
|
+
}
|
|
13
|
+
export const AsgardeoAuthHandler = (config, options) => {
|
|
14
|
+
const defaultCookieOptsFromUser = options?.cookies?.defaultOptions ?? {};
|
|
15
|
+
const sessionIdCookieName = options?.cookies?.sessionId ?? "ASGARDEO_SESSION_ID";
|
|
16
|
+
const sessionIdCookieOptions = mergeCookieOptions(
|
|
17
|
+
{
|
|
18
|
+
// Base defaults (already includes secure, httpOnly, path, sameSite)
|
|
19
|
+
maxAge: 9e5 / 1e3
|
|
20
|
+
// Default session length (15 minutes)
|
|
21
|
+
},
|
|
22
|
+
{ ...defaultCookieOptsFromUser, ...options?.cookies?.sessionIdOptions }
|
|
23
|
+
);
|
|
24
|
+
return defineEventHandler(async (event) => {
|
|
25
|
+
const action = event.context.params?._;
|
|
26
|
+
const { method } = event.node.req;
|
|
27
|
+
const authClient = getAsgardeoSdkInstance(config);
|
|
28
|
+
if (action === "signin" && method === "GET") {
|
|
29
|
+
try {
|
|
30
|
+
const sessionId = randomUUID();
|
|
31
|
+
setCookie(event, sessionIdCookieName, sessionId, sessionIdCookieOptions);
|
|
32
|
+
await authClient.signIn(
|
|
33
|
+
(authorizationUrl) => {
|
|
34
|
+
sendRedirect(event, authorizationUrl, 302);
|
|
35
|
+
},
|
|
36
|
+
sessionId,
|
|
37
|
+
getQuery(event).code?.toString(),
|
|
38
|
+
getQuery(event).session_state?.toString(),
|
|
39
|
+
getQuery(event).state?.toString(),
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
42
|
+
return null;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw createError({
|
|
45
|
+
data: error.message,
|
|
46
|
+
statusCode: 500,
|
|
47
|
+
statusMessage: "Failed to initiate sign in"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
} else if (action === "callback" && method === "GET") {
|
|
51
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
52
|
+
if (!sessionId) {
|
|
53
|
+
throw createError({
|
|
54
|
+
statusCode: 400,
|
|
55
|
+
statusMessage: "Authentication callback error: Session ID missing."
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const { code, session_state, state, error, error_description } = getQuery(event);
|
|
59
|
+
if (!code) {
|
|
60
|
+
if (error) {
|
|
61
|
+
throw createError({
|
|
62
|
+
statusCode: 400,
|
|
63
|
+
statusMessage: `Authentication failed: ${error_description ?? error}`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw createError({
|
|
67
|
+
statusCode: 400,
|
|
68
|
+
statusMessage: "Authorization code missing in callback."
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const tokenResponse = await authClient.signIn(
|
|
73
|
+
() => {
|
|
74
|
+
},
|
|
75
|
+
// no-op redirect callback
|
|
76
|
+
sessionId,
|
|
77
|
+
code.toString(),
|
|
78
|
+
session_state?.toString() ?? "",
|
|
79
|
+
state?.toString() ?? ""
|
|
80
|
+
);
|
|
81
|
+
if (!tokenResponse?.accessToken && !tokenResponse?.idToken) {
|
|
82
|
+
throw createError({
|
|
83
|
+
statusCode: 500,
|
|
84
|
+
statusMessage: "Token exchange failed: Invalid response from Identity Provider."
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return await sendRedirect(event, options?.defaultCallbackUrl ?? "/", 302);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
throw createError({
|
|
90
|
+
data: err.message ?? "An unexpected error occurred during token exchange",
|
|
91
|
+
statusCode: 500,
|
|
92
|
+
statusMessage: "Token exchange failed."
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
} else if (action === "user" && method === "GET") {
|
|
96
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
97
|
+
if (!sessionId) {
|
|
98
|
+
throw createError({
|
|
99
|
+
statusCode: 401,
|
|
100
|
+
statusMessage: "Unauthorized: No active session found."
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return await authClient.getBasicUserInfo(sessionId);
|
|
105
|
+
} catch {
|
|
106
|
+
throw createError({
|
|
107
|
+
statusCode: 500,
|
|
108
|
+
statusMessage: "Failed to retrieve user information."
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
} else if (action === "isAuthenticated" && method === "GET") {
|
|
112
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
113
|
+
if (!sessionId) return false;
|
|
114
|
+
try {
|
|
115
|
+
return await authClient.isAuthenticated(sessionId);
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
} else if (action === "get-id-token" && method === "GET") {
|
|
120
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
121
|
+
if (!sessionId) {
|
|
122
|
+
throw createError({
|
|
123
|
+
statusCode: 401,
|
|
124
|
+
statusMessage: "Unauthorized: No active session found."
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const idToken = await authClient.getIDToken(sessionId);
|
|
129
|
+
return { idToken };
|
|
130
|
+
} catch {
|
|
131
|
+
throw createError({
|
|
132
|
+
statusCode: 500,
|
|
133
|
+
statusMessage: "Failed to retrieve ID token."
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
} else if (action === "get-access-token" && method === "GET") {
|
|
137
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
138
|
+
if (!sessionId) {
|
|
139
|
+
throw createError({
|
|
140
|
+
statusCode: 401,
|
|
141
|
+
statusMessage: "Unauthorized: No active session found."
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const accessToken = await authClient.getAccessToken(sessionId);
|
|
146
|
+
return { accessToken };
|
|
147
|
+
} catch {
|
|
148
|
+
throw createError({
|
|
149
|
+
statusCode: 500,
|
|
150
|
+
statusMessage: "Failed to retrieve access token."
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
} else if (action === "get-decoded-id-token" && method === "GET") {
|
|
154
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
155
|
+
if (!sessionId) {
|
|
156
|
+
throw createError({
|
|
157
|
+
statusCode: 401,
|
|
158
|
+
statusMessage: "Unauthorized: No active session found."
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
return await authClient.getDecodedIDToken(sessionId);
|
|
163
|
+
} catch {
|
|
164
|
+
throw createError({
|
|
165
|
+
statusCode: 500,
|
|
166
|
+
statusMessage: "Failed to retrieve decoded ID token."
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
} else if (action === "revoke-token" && method === "POST") {
|
|
170
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
171
|
+
if (!sessionId) {
|
|
172
|
+
throw createError({
|
|
173
|
+
statusCode: 401,
|
|
174
|
+
statusMessage: "Unauthorized: No active session found."
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
return await authClient.revokeAccessToken(sessionId);
|
|
179
|
+
} catch {
|
|
180
|
+
throw createError({
|
|
181
|
+
statusCode: 500,
|
|
182
|
+
statusMessage: "Failed to revoke tokens."
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} else if (action === "get-oidc-endpoints" && method === "GET") {
|
|
186
|
+
try {
|
|
187
|
+
return await authClient.getOIDCServiceEndpoints();
|
|
188
|
+
} catch {
|
|
189
|
+
throw createError({
|
|
190
|
+
statusCode: 500,
|
|
191
|
+
statusMessage: "Failed to retrieve OIDC service endpoints."
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
} else if (action === "signout" && method === "GET") {
|
|
195
|
+
const sessionId = getCookie(event, sessionIdCookieName);
|
|
196
|
+
if (!sessionId) {
|
|
197
|
+
return sendRedirect(event, options?.defaultCallbackUrl ?? "/", 302);
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const signOutURL = await authClient.signOut(sessionId);
|
|
201
|
+
deleteCookie(event, sessionIdCookieName, sessionIdCookieOptions);
|
|
202
|
+
if (!signOutURL) {
|
|
203
|
+
return await sendRedirect(event, "/?error=signout_url_missing", 302);
|
|
204
|
+
}
|
|
205
|
+
return await sendRedirect(event, signOutURL, 302);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
deleteCookie(event, sessionIdCookieName, sessionIdCookieOptions);
|
|
208
|
+
throw createError({
|
|
209
|
+
data: error.message || "An unexpected error occurred during sign out",
|
|
210
|
+
statusCode: 500,
|
|
211
|
+
statusMessage: "Sign out failed."
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
} else if (action === "get-data-layer" && method === "GET") {
|
|
215
|
+
try {
|
|
216
|
+
const dataLayer = await authClient.getDataLayer();
|
|
217
|
+
return dataLayer;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
throw createError({
|
|
220
|
+
statusCode: 500,
|
|
221
|
+
statusMessage: "Failed to retrieve Data Layer."
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
throw createError({
|
|
226
|
+
statusCode: 404,
|
|
227
|
+
statusMessage: `Authentication endpoint not found or method not allowed for action: ${action}`
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { AsgardeoNodeClient, type AuthClientConfig } from '@asgardeo/auth-node';
|
|
19
|
+
/**
|
|
20
|
+
* Returns a singleton AsgardeoNodeClient instance.
|
|
21
|
+
* Must be called with configuration on first call.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAsgardeoSdkInstance(config: AuthClientConfig): AsgardeoNodeClient<any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AsgardeoNodeClient } from "@asgardeo/auth-node";
|
|
2
|
+
let authClientInstance = null;
|
|
3
|
+
export function getAsgardeoSdkInstance(config) {
|
|
4
|
+
if (authClientInstance) {
|
|
5
|
+
return authClientInstance;
|
|
6
|
+
}
|
|
7
|
+
if (!config) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"[Asgardeo] No configuration provided. You must call getAsgardeoSdkInstance(config) with a valid AuthClientConfig on the first use."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
authClientInstance = new AsgardeoNodeClient(config);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new Error("[Asgardeo] SDK initialization failed. Check provided configuration and SDK compatibility.");
|
|
16
|
+
}
|
|
17
|
+
return authClientInstance;
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { BasicUserInfo, DataLayer, IdTokenPayload, OIDCEndpoints } from '@asgardeo/auth-node';
|
|
19
|
+
export interface ModuleOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The base URL of your Asgardeo organization tenant.
|
|
22
|
+
* e.g., https://api.asgardeo.io/t/your_org_name
|
|
23
|
+
* @default process.env.ASGARDEO_BASE_URL
|
|
24
|
+
*/
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
/**
|
|
27
|
+
* Asgardeo Application Client ID.
|
|
28
|
+
* @default process.env.ASGARDEO_CLIENT_ID
|
|
29
|
+
*/
|
|
30
|
+
clientID: string;
|
|
31
|
+
/**
|
|
32
|
+
* Asgardeo Application Client Secret. (Server-side only)
|
|
33
|
+
* @default process.env.ASGARDEO_CLIENT_SECRET
|
|
34
|
+
*/
|
|
35
|
+
clientSecret?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Authentication scopes to request from Asgardeo.
|
|
38
|
+
* @default ['openid', 'profile']
|
|
39
|
+
*/
|
|
40
|
+
scope?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* The absolute redirect URI where Asgardeo should redirect after sign-in.
|
|
43
|
+
* Must match the URI configured in your Asgardeo app.
|
|
44
|
+
* @default process.env.ASGARDEO_SIGN_IN_REDIRECT_URL
|
|
45
|
+
*/
|
|
46
|
+
signInRedirectURL: string;
|
|
47
|
+
/**
|
|
48
|
+
* The absolute URI to redirect to after sign-out completes.
|
|
49
|
+
* @default process.env.ASGARDEO_SIGN_OUT_REDIRECT_URL
|
|
50
|
+
*/
|
|
51
|
+
signOutRedirectURL: string;
|
|
52
|
+
}
|
|
53
|
+
export interface AuthInterface {
|
|
54
|
+
getAccessToken: () => Promise<string | null>;
|
|
55
|
+
getBasicUserInfo: () => Promise<BasicUserInfo | null>;
|
|
56
|
+
getDataLayer: () => Promise<DataLayer<any> | null>;
|
|
57
|
+
getDecodedIDToken: () => Promise<IdTokenPayload | null>;
|
|
58
|
+
getIdToken: () => Promise<string | null>;
|
|
59
|
+
getOIDCServiceEndpoints: () => Promise<OIDCEndpoints | null>;
|
|
60
|
+
isAuthenticated: () => Promise<boolean>;
|
|
61
|
+
revokeAccessToken: () => Promise<void>;
|
|
62
|
+
signIn: (callbackUrl?: string) => Promise<void>;
|
|
63
|
+
signOut: () => Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
export type SessionLastRefreshedAt = Date | undefined;
|
|
66
|
+
export type SessionStatus = 'authenticated' | 'unauthenticated' | 'loading';
|
|
67
|
+
export type { BasicUserInfo };
|
|
File without changes
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { type BasicUserInfo } from '../dist/runtime/types.js'
|
|
8
|
+
|
|
9
|
+
export { default } from './module.mjs'
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asgardeo/nuxt",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Nuxt module for Asgardeo - Authentication and Identity Management",
|
|
5
|
+
"author": "WSO2",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://github.com/asgardeo/web-ui-sdks/tree/main/packages/nuxt#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/asgardeo/web-ui-sdks/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/asgardeo/web-ui-sdks",
|
|
14
|
+
"directory": "packages/nuxt"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"asgardeo",
|
|
18
|
+
"authentication",
|
|
19
|
+
"identity",
|
|
20
|
+
"oauth",
|
|
21
|
+
"oidc",
|
|
22
|
+
"nuxt",
|
|
23
|
+
"nuxt3",
|
|
24
|
+
"login",
|
|
25
|
+
"sso",
|
|
26
|
+
"identity-management"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/types.d.mts",
|
|
32
|
+
"import": "./dist/module.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/module.mjs",
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
".": [
|
|
39
|
+
"./dist/types.d.mts"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@asgardeo/auth-node": "^0.1.3",
|
|
50
|
+
"@nuxt/kit": "^3.16.2",
|
|
51
|
+
"defu": "^6.1.4"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@nuxt/devtools": "^2.4.0",
|
|
55
|
+
"@nuxt/eslint-config": "^1.3.0",
|
|
56
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
57
|
+
"@nuxt/schema": "^3.16.2",
|
|
58
|
+
"@nuxt/test-utils": "^3.17.2",
|
|
59
|
+
"@types/node": "latest",
|
|
60
|
+
"changelogen": "^0.6.1",
|
|
61
|
+
"cookie-es": "^2.0.0",
|
|
62
|
+
"eslint": "8.57.0",
|
|
63
|
+
"nuxt": "^3.16.2",
|
|
64
|
+
"typescript": "~5.8.3",
|
|
65
|
+
"vitest": "^3.1.1",
|
|
66
|
+
"vue-tsc": "^2.2.8"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "nuxt module-build prepare && nuxt module-build build",
|
|
73
|
+
"dev": "nuxi dev playground",
|
|
74
|
+
"dev:build": "nuxi build playground",
|
|
75
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
76
|
+
"lint": "nuxt prepare && eslint .",
|
|
77
|
+
"test": "vitest run --passWithNoTests",
|
|
78
|
+
"typecheck": "nuxt prepare && vue-tsc --noEmit"
|
|
79
|
+
}
|
|
80
|
+
}
|