@asgardeo/nuxt 0.0.0 → 0.1.0-alpha.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/README.md +482 -6
- package/dist/module.d.mts +17 -24
- package/dist/module.json +2 -2
- package/dist/module.mjs +174 -48
- package/dist/runtime/components/AsgardeoRoot.d.ts +52 -0
- package/dist/runtime/components/AsgardeoRoot.js +160 -0
- package/dist/runtime/components/actions/SignInButton.d.ts +37 -0
- package/dist/runtime/components/actions/SignInButton.js +51 -0
- package/dist/runtime/components/actions/SignOutButton.d.ts +34 -0
- package/dist/runtime/components/actions/SignOutButton.js +43 -0
- package/dist/runtime/components/actions/SignUpButton.d.ts +33 -0
- package/dist/runtime/components/actions/SignUpButton.js +48 -0
- package/dist/runtime/components/auth/Callback.d.ts +43 -0
- package/dist/runtime/components/auth/Callback.js +93 -0
- package/dist/runtime/components/auth/SignIn.d.ts +38 -0
- package/dist/runtime/components/auth/SignIn.js +60 -0
- package/dist/runtime/components/auth/SignUp.d.ts +40 -0
- package/dist/runtime/components/auth/SignUp.js +79 -0
- package/dist/runtime/components/control/Loading.d.ts +36 -0
- package/dist/runtime/components/control/Loading.js +17 -0
- package/dist/runtime/components/control/SignedIn.d.ts +38 -0
- package/dist/runtime/components/control/SignedIn.js +17 -0
- package/dist/runtime/components/control/SignedOut.d.ts +37 -0
- package/dist/runtime/components/control/SignedOut.js +17 -0
- package/dist/runtime/components/organization/CreateOrganization.d.ts +32 -0
- package/dist/runtime/components/organization/CreateOrganization.js +29 -0
- package/dist/runtime/components/organization/Organization.d.ts +39 -0
- package/dist/runtime/components/organization/Organization.js +17 -0
- package/dist/runtime/components/organization/OrganizationList.d.ts +34 -0
- package/dist/runtime/components/organization/OrganizationList.js +30 -0
- package/dist/runtime/components/organization/OrganizationProfile.d.ts +32 -0
- package/dist/runtime/components/organization/OrganizationProfile.js +32 -0
- package/dist/runtime/components/organization/OrganizationSwitcher.d.ts +36 -0
- package/dist/runtime/components/organization/OrganizationSwitcher.js +26 -0
- package/dist/runtime/components/user/User.d.ts +38 -0
- package/dist/runtime/components/user/User.js +17 -0
- package/dist/runtime/components/user/UserDropdown.d.ts +38 -0
- package/dist/runtime/components/user/UserDropdown.js +45 -0
- package/dist/runtime/components/user/UserProfile.d.ts +35 -0
- package/dist/runtime/components/user/UserProfile.js +35 -0
- package/dist/runtime/composables/useAsgardeo.d.ts +38 -0
- package/dist/runtime/composables/useAsgardeo.js +73 -0
- package/dist/runtime/errors/asgardeo-error.d.ts +47 -0
- package/dist/runtime/errors/asgardeo-error.js +15 -0
- package/dist/runtime/errors/error-codes.d.ts +40 -0
- package/dist/runtime/errors/error-codes.js +19 -0
- package/dist/runtime/{composables/asgardeo/useAuth.d.ts → errors/index.d.ts} +2 -2
- package/dist/runtime/errors/index.js +2 -0
- package/dist/runtime/middleware/auth.d.ts +35 -0
- package/dist/runtime/middleware/auth.js +2 -0
- package/dist/runtime/middleware/defineAsgardeoMiddleware.d.ts +53 -0
- package/dist/runtime/middleware/defineAsgardeoMiddleware.js +24 -0
- package/dist/runtime/plugins/asgardeo.d.ts +40 -0
- package/dist/runtime/plugins/asgardeo.js +129 -0
- package/dist/runtime/server/AsgardeoNuxtClient.d.ts +182 -0
- package/dist/runtime/server/AsgardeoNuxtClient.js +366 -0
- package/dist/runtime/server/index.d.ts +33 -0
- package/dist/runtime/server/index.js +3 -0
- package/dist/runtime/server/plugins/asgardeo-ssr.d.ts +41 -0
- package/dist/runtime/server/plugins/asgardeo-ssr.js +134 -0
- package/dist/runtime/server/routes/auth/branding/branding.get.d.ts +31 -0
- package/dist/runtime/server/routes/auth/branding/branding.get.js +40 -0
- package/dist/runtime/server/routes/auth/organizations/current.get.d.ts +29 -0
- package/dist/runtime/server/routes/auth/organizations/current.get.js +24 -0
- package/dist/runtime/server/routes/auth/organizations/id.get.d.ts +28 -0
- package/dist/runtime/server/routes/auth/organizations/id.get.js +28 -0
- package/dist/runtime/server/routes/auth/organizations/index.get.d.ts +28 -0
- package/dist/runtime/server/routes/auth/organizations/index.get.js +24 -0
- package/dist/runtime/server/routes/auth/organizations/index.post.d.ts +30 -0
- package/dist/runtime/server/routes/auth/organizations/index.post.js +30 -0
- package/dist/runtime/server/routes/auth/organizations/me.get.d.ts +28 -0
- package/dist/runtime/server/routes/auth/organizations/me.get.js +24 -0
- package/dist/runtime/server/routes/auth/organizations/switch.post.d.ts +32 -0
- package/dist/runtime/server/routes/auth/organizations/switch.post.js +49 -0
- package/dist/runtime/server/routes/auth/session/callback.get.d.ts +27 -0
- package/dist/runtime/server/routes/auth/session/callback.get.js +91 -0
- package/dist/runtime/server/routes/auth/session/callback.post.d.ts +48 -0
- package/dist/runtime/server/routes/auth/session/callback.post.js +53 -0
- package/dist/runtime/server/routes/auth/session/session.get.d.ts +26 -0
- package/dist/runtime/server/routes/auth/session/session.get.js +22 -0
- package/dist/runtime/server/routes/auth/session/signin.get.d.ts +29 -0
- package/dist/runtime/server/routes/auth/session/signin.get.js +37 -0
- package/dist/runtime/server/routes/auth/session/signin.post.d.ts +37 -0
- package/dist/runtime/server/routes/auth/session/signin.post.js +102 -0
- package/dist/runtime/server/routes/auth/session/signout.post.d.ts +31 -0
- package/dist/runtime/server/routes/auth/session/signout.post.js +38 -0
- package/dist/runtime/server/routes/auth/session/signup.post.d.ts +36 -0
- package/dist/runtime/server/routes/auth/session/signup.post.js +30 -0
- package/dist/runtime/server/routes/auth/session/token.get.d.ts +29 -0
- package/dist/runtime/server/routes/auth/session/token.get.js +6 -0
- package/dist/runtime/server/routes/auth/user/profile.get.d.ts +29 -0
- package/dist/runtime/server/routes/auth/user/profile.get.js +24 -0
- package/dist/runtime/server/{handler.d.ts → routes/auth/user/profile.patch.d.ts} +17 -13
- package/dist/runtime/server/routes/auth/user/profile.patch.js +33 -0
- package/dist/runtime/server/{services/asgardeo/index.d.ts → routes/auth/user/user.get.d.ts} +6 -4
- package/dist/runtime/server/routes/auth/user/user.get.js +21 -0
- package/dist/runtime/server/utils/event-context.d.ts +49 -0
- package/dist/runtime/server/utils/event-context.js +3 -0
- package/dist/runtime/server/utils/serverSession.d.ts +65 -0
- package/dist/runtime/server/utils/serverSession.js +44 -0
- package/dist/runtime/server/utils/session.d.ts +85 -0
- package/dist/runtime/server/utils/session.js +106 -0
- package/dist/runtime/server/utils/token-refresh.d.ts +42 -0
- package/dist/runtime/server/utils/token-refresh.js +65 -0
- package/dist/runtime/types/augments.d.ts +61 -0
- package/dist/runtime/types.d.ts +115 -38
- package/dist/runtime/utils/createRouteMatcher.d.ts +40 -0
- package/dist/runtime/utils/createRouteMatcher.js +7 -0
- package/dist/runtime/utils/index.d.ts +30 -0
- package/dist/runtime/utils/index.js +1 -0
- package/dist/runtime/utils/log.d.ts +44 -0
- package/dist/runtime/utils/log.js +25 -0
- package/dist/runtime/utils/url-validation.d.ts +49 -0
- package/dist/runtime/utils/url-validation.js +38 -0
- package/dist/types.d.mts +0 -2
- package/package.json +48 -23
- package/dist/runtime/composables/asgardeo/useAuth.js +0 -129
- package/dist/runtime/server/handler.js +0 -231
- package/dist/runtime/server/services/asgardeo/index.js +0 -18
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AsgardeoRuntimeError } from "@asgardeo/browser";
|
|
2
|
+
import { BaseSignUpButton } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h, ref } from "vue";
|
|
4
|
+
import { navigateTo } from "#app";
|
|
5
|
+
import { useAsgardeo } from "#imports";
|
|
6
|
+
const SignUpButton = defineComponent({
|
|
7
|
+
emits: ["click", "error"],
|
|
8
|
+
name: "SignUpButton",
|
|
9
|
+
setup(_, { slots, emit, attrs }) {
|
|
10
|
+
const { signUp, signUpUrl } = useAsgardeo();
|
|
11
|
+
const isLoading = ref(false);
|
|
12
|
+
const handleSignUp = async (e) => {
|
|
13
|
+
try {
|
|
14
|
+
isLoading.value = true;
|
|
15
|
+
if (signUpUrl) {
|
|
16
|
+
await navigateTo(signUpUrl, { external: true });
|
|
17
|
+
} else {
|
|
18
|
+
await signUp();
|
|
19
|
+
}
|
|
20
|
+
if (e) emit("click", e);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
emit("error", error);
|
|
23
|
+
throw new AsgardeoRuntimeError(
|
|
24
|
+
`Sign up failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
25
|
+
"SignUpButton-handleSignUp-RuntimeError-001",
|
|
26
|
+
"nuxt",
|
|
27
|
+
"Something went wrong while trying to sign up. Please try again later."
|
|
28
|
+
);
|
|
29
|
+
} finally {
|
|
30
|
+
isLoading.value = false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return () => {
|
|
34
|
+
const slotContent = slots["default"] ? () => slots["default"]({ isLoading: isLoading.value }) : void 0;
|
|
35
|
+
return h(
|
|
36
|
+
BaseSignUpButton,
|
|
37
|
+
{
|
|
38
|
+
class: attrs["class"],
|
|
39
|
+
isLoading: isLoading.value,
|
|
40
|
+
onClick: handleSignUp,
|
|
41
|
+
style: attrs["style"]
|
|
42
|
+
},
|
|
43
|
+
slotContent
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export default SignUpButton;
|
|
@@ -0,0 +1,43 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific Callback component.
|
|
21
|
+
*
|
|
22
|
+
* Handles OAuth callback parameter forwarding — extracts `code`, `state`, and
|
|
23
|
+
* `error` from the URL, validates the state stored in `sessionStorage`, and
|
|
24
|
+
* forwards the OAuth parameters to the originating route.
|
|
25
|
+
*
|
|
26
|
+
* **SSR-safe**: all `window` / `sessionStorage` access is gated inside
|
|
27
|
+
* `onMounted`, which only runs on the client. Navigation uses Nuxt's
|
|
28
|
+
* `navigateTo` instead of `window.location` so the redirect is handled
|
|
29
|
+
* correctly in both SSR and CSR contexts.
|
|
30
|
+
*
|
|
31
|
+
* Pass `onNavigate` to override the navigation handler (e.g. for testing or
|
|
32
|
+
* custom routing logic).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```vue
|
|
36
|
+
* <!-- pages/callback.vue -->
|
|
37
|
+
* <template>
|
|
38
|
+
* <AsgardeoCallback :on-error="handleError" />
|
|
39
|
+
* </template>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare const Callback: Component;
|
|
43
|
+
export default Callback;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineComponent, onMounted } from "vue";
|
|
2
|
+
import { navigateTo } from "#app";
|
|
3
|
+
const error = (msg, ...args) => {
|
|
4
|
+
console.error(`[@asgardeo/nuxt] Callback: ${msg}`, ...args);
|
|
5
|
+
};
|
|
6
|
+
const Callback = defineComponent({
|
|
7
|
+
name: "Callback",
|
|
8
|
+
props: {
|
|
9
|
+
onError: { default: void 0, type: Function },
|
|
10
|
+
onNavigate: { default: void 0, type: Function }
|
|
11
|
+
},
|
|
12
|
+
setup(props) {
|
|
13
|
+
const navigate = (path) => {
|
|
14
|
+
if (props.onNavigate) {
|
|
15
|
+
props.onNavigate(path);
|
|
16
|
+
} else {
|
|
17
|
+
navigateTo(path);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
let returnPath = "/";
|
|
22
|
+
try {
|
|
23
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
24
|
+
const code = urlParams.get("code");
|
|
25
|
+
const state = urlParams.get("state");
|
|
26
|
+
const nonce = urlParams.get("nonce");
|
|
27
|
+
const oauthError = urlParams.get("error");
|
|
28
|
+
const errorDescription = urlParams.get("error_description");
|
|
29
|
+
if (!code && !state && !oauthError) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!state) {
|
|
33
|
+
throw new Error("Missing OAuth state parameter - possible security issue");
|
|
34
|
+
}
|
|
35
|
+
const storedData = sessionStorage.getItem(`asgardeo_oauth_${state}`);
|
|
36
|
+
if (!storedData) {
|
|
37
|
+
if (oauthError) {
|
|
38
|
+
const errorMsg = errorDescription || oauthError || "OAuth authentication failed";
|
|
39
|
+
const err = new Error(errorMsg);
|
|
40
|
+
props.onError?.(err);
|
|
41
|
+
const params2 = new URLSearchParams();
|
|
42
|
+
params2.set("error", oauthError);
|
|
43
|
+
if (errorDescription) {
|
|
44
|
+
params2.set("error_description", errorDescription);
|
|
45
|
+
}
|
|
46
|
+
navigate(`/?${params2.toString()}`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
throw new Error("Invalid OAuth state - possible CSRF attack");
|
|
50
|
+
}
|
|
51
|
+
const { path, timestamp } = JSON.parse(storedData);
|
|
52
|
+
returnPath = path || "/";
|
|
53
|
+
const MAX_STATE_AGE = 3e5;
|
|
54
|
+
if (Date.now() - timestamp > MAX_STATE_AGE) {
|
|
55
|
+
sessionStorage.removeItem(`asgardeo_oauth_${state}`);
|
|
56
|
+
throw new Error("OAuth state expired - please try again");
|
|
57
|
+
}
|
|
58
|
+
sessionStorage.removeItem(`asgardeo_oauth_${state}`);
|
|
59
|
+
if (oauthError) {
|
|
60
|
+
const errorMsg = errorDescription || oauthError || "OAuth authentication failed";
|
|
61
|
+
const err = new Error(errorMsg);
|
|
62
|
+
props.onError?.(err);
|
|
63
|
+
const params2 = new URLSearchParams();
|
|
64
|
+
params2.set("error", oauthError);
|
|
65
|
+
if (errorDescription) {
|
|
66
|
+
params2.set("error_description", errorDescription);
|
|
67
|
+
}
|
|
68
|
+
navigate(`${returnPath}?${params2.toString()}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!code) {
|
|
72
|
+
throw new Error("Missing OAuth authorization code");
|
|
73
|
+
}
|
|
74
|
+
const params = new URLSearchParams();
|
|
75
|
+
params.set("code", code);
|
|
76
|
+
if (nonce) {
|
|
77
|
+
params.set("nonce", nonce);
|
|
78
|
+
}
|
|
79
|
+
navigate(`${returnPath}?${params.toString()}`);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
const errorMessage = err instanceof Error ? err.message : "OAuth callback processing failed";
|
|
82
|
+
error("OAuth callback error:", err);
|
|
83
|
+
props.onError?.(err instanceof Error ? err : new Error(errorMessage));
|
|
84
|
+
const params = new URLSearchParams();
|
|
85
|
+
params.set("error", "callback_error");
|
|
86
|
+
params.set("error_description", errorMessage);
|
|
87
|
+
navigate(`${returnPath}?${params.toString()}`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return () => null;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
export default Callback;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific SignIn container for the embedded (app-native) sign-in flow.
|
|
21
|
+
*
|
|
22
|
+
* Mirrors the Vue SDK's `SignIn` container but replaces all `window.location`
|
|
23
|
+
* navigation with Nuxt's `navigateTo` so redirects after a successful embedded
|
|
24
|
+
* sign-in are SSR-safe.
|
|
25
|
+
*
|
|
26
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer — the Nuxt-specific
|
|
27
|
+
* wrapper that provides Nitro-route-aware `signIn`, `signOut`, `signUp`.
|
|
28
|
+
*
|
|
29
|
+
* Delegates all UI rendering to {@link BaseSignIn} from `@asgardeo/vue`, which
|
|
30
|
+
* itself is platform-aware (routes to V1 authenticator or V2 component flow).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```vue
|
|
34
|
+
* <AsgardeoSignIn @success="onSignIn" @error="onError" />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const SignIn: Component;
|
|
38
|
+
export default SignIn;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BaseSignIn } from "@asgardeo/vue";
|
|
2
|
+
import { defineComponent, h } from "vue";
|
|
3
|
+
import { navigateTo } from "#app";
|
|
4
|
+
import { useAsgardeo } from "#imports";
|
|
5
|
+
const SignIn = defineComponent({
|
|
6
|
+
emits: ["error", "success"],
|
|
7
|
+
name: "SignIn",
|
|
8
|
+
props: {
|
|
9
|
+
className: { default: "", type: String },
|
|
10
|
+
size: {
|
|
11
|
+
default: "medium",
|
|
12
|
+
type: String
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
default: "outlined",
|
|
16
|
+
type: String
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
setup(props, { emit, attrs }) {
|
|
20
|
+
const { signIn, afterSignInUrl, isInitialized, isLoading } = useAsgardeo();
|
|
21
|
+
const handleInitialize = async () => (
|
|
22
|
+
// Pass flowId='' to trigger the embedded-flow initiation path in useAsgardeo.
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
await signIn({ flowId: "" }, {})
|
|
25
|
+
);
|
|
26
|
+
const handleOnSubmit = async (payload, request) => await signIn(payload, request);
|
|
27
|
+
const handleSuccess = async (authData) => {
|
|
28
|
+
emit("success", authData);
|
|
29
|
+
if (authData && afterSignInUrl) {
|
|
30
|
+
if (import.meta.client) {
|
|
31
|
+
const url = new URL(afterSignInUrl, window.location.origin);
|
|
32
|
+
Object.entries(authData).forEach(([key, value]) => {
|
|
33
|
+
if (value !== void 0 && value !== null) {
|
|
34
|
+
url.searchParams.append(key, String(value));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
await navigateTo(url.pathname + url.search + url.hash);
|
|
38
|
+
} else {
|
|
39
|
+
await navigateTo(afterSignInUrl);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return () => h(BaseSignIn, {
|
|
44
|
+
...attrs,
|
|
45
|
+
afterSignInUrl,
|
|
46
|
+
class: props.className,
|
|
47
|
+
isLoading: (isLoading?.value ?? false) || !(isInitialized?.value ?? true),
|
|
48
|
+
onError: (err) => emit("error", err),
|
|
49
|
+
onInitialize: handleInitialize,
|
|
50
|
+
onSubmit: handleOnSubmit,
|
|
51
|
+
onSuccess: handleSuccess,
|
|
52
|
+
showLogo: true,
|
|
53
|
+
showSubtitle: true,
|
|
54
|
+
showTitle: true,
|
|
55
|
+
size: props.size,
|
|
56
|
+
variant: props.variant
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export default SignIn;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { BaseSignUpRenderProps } from '@asgardeo/vue';
|
|
19
|
+
import { type Component } from 'vue';
|
|
20
|
+
export type SignUpRenderProps = BaseSignUpRenderProps;
|
|
21
|
+
/**
|
|
22
|
+
* Nuxt-specific SignUp container for the embedded registration flow.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors the Vue SDK's `SignUp` container but replaces all `window.location`
|
|
25
|
+
* redirects with Nuxt's `navigateTo` for SSR-safe navigation after a
|
|
26
|
+
* successful sign-up.
|
|
27
|
+
*
|
|
28
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer and delegates all UI
|
|
29
|
+
* rendering to {@link BaseSignUp} from `@asgardeo/vue`.
|
|
30
|
+
*
|
|
31
|
+
* Additionally, `window.location.href` for OAuth redirect URLs is replaced
|
|
32
|
+
* with `navigateTo` so the redirect works in both SSR and CSR contexts.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```vue
|
|
36
|
+
* <AsgardeoSignUp @complete="onComplete" @error="onError" />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const SignUp: Component;
|
|
40
|
+
export default SignUp;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EmbeddedFlowResponseType,
|
|
3
|
+
EmbeddedFlowType
|
|
4
|
+
} from "@asgardeo/browser";
|
|
5
|
+
import { BaseSignUp } from "@asgardeo/vue";
|
|
6
|
+
import { defineComponent, h } from "vue";
|
|
7
|
+
import { navigateTo } from "#app";
|
|
8
|
+
import { useAsgardeo } from "#imports";
|
|
9
|
+
const SignUp = defineComponent({
|
|
10
|
+
name: "SignUp",
|
|
11
|
+
props: {
|
|
12
|
+
afterSignUpUrl: { default: void 0, type: String },
|
|
13
|
+
buttonClassName: { default: "", type: String },
|
|
14
|
+
className: { default: "", type: String },
|
|
15
|
+
errorClassName: { default: "", type: String },
|
|
16
|
+
inputClassName: { default: "", type: String },
|
|
17
|
+
messageClassName: { default: "", type: String },
|
|
18
|
+
onComplete: { default: void 0, type: Function },
|
|
19
|
+
onError: { default: void 0, type: Function },
|
|
20
|
+
shouldRedirectAfterSignUp: { default: true, type: Boolean },
|
|
21
|
+
showSubtitle: { default: true, type: Boolean },
|
|
22
|
+
showTitle: { default: true, type: Boolean },
|
|
23
|
+
size: { default: "medium", type: String },
|
|
24
|
+
variant: { default: "outlined", type: String }
|
|
25
|
+
},
|
|
26
|
+
setup(props, { slots }) {
|
|
27
|
+
const { signUp, isInitialized, applicationId } = useAsgardeo();
|
|
28
|
+
const handleInitialize = async (payload) => {
|
|
29
|
+
let applicationIdFromUrl = null;
|
|
30
|
+
if (import.meta.client) {
|
|
31
|
+
const urlParams = new URL(window.location.href).searchParams;
|
|
32
|
+
applicationIdFromUrl = urlParams.get("applicationId");
|
|
33
|
+
}
|
|
34
|
+
const effectiveApplicationId = applicationId || applicationIdFromUrl || void 0;
|
|
35
|
+
const initialPayload = payload || {
|
|
36
|
+
flowType: EmbeddedFlowType.Registration,
|
|
37
|
+
...effectiveApplicationId && { applicationId: effectiveApplicationId }
|
|
38
|
+
};
|
|
39
|
+
return await signUp(initialPayload);
|
|
40
|
+
};
|
|
41
|
+
const handleOnSubmit = async (payload) => await signUp(payload);
|
|
42
|
+
const handleComplete = async (response) => {
|
|
43
|
+
props.onComplete?.(response);
|
|
44
|
+
const oauthRedirectUrl = response?.redirectUrl;
|
|
45
|
+
if (props.shouldRedirectAfterSignUp && oauthRedirectUrl) {
|
|
46
|
+
await navigateTo(oauthRedirectUrl, { external: true });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (props.shouldRedirectAfterSignUp && response?.type !== EmbeddedFlowResponseType.Redirection && props.afterSignUpUrl) {
|
|
50
|
+
await navigateTo(props.afterSignUpUrl, { external: true });
|
|
51
|
+
}
|
|
52
|
+
if (props.shouldRedirectAfterSignUp && response?.type === EmbeddedFlowResponseType.Redirection && response?.data?.redirectURL && !response.data.redirectURL.includes("oauth") && !response.data.redirectURL.includes("auth")) {
|
|
53
|
+
await navigateTo(response.data.redirectURL, { external: true });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return () => h(
|
|
57
|
+
BaseSignUp,
|
|
58
|
+
{
|
|
59
|
+
afterSignUpUrl: props.afterSignUpUrl,
|
|
60
|
+
buttonClassName: props.buttonClassName,
|
|
61
|
+
className: props.className,
|
|
62
|
+
errorClassName: props.errorClassName,
|
|
63
|
+
inputClassName: props.inputClassName,
|
|
64
|
+
isInitialized: isInitialized?.value ?? false,
|
|
65
|
+
messageClassName: props.messageClassName,
|
|
66
|
+
onComplete: handleComplete,
|
|
67
|
+
onError: props.onError,
|
|
68
|
+
onInitialize: handleInitialize,
|
|
69
|
+
onSubmit: handleOnSubmit,
|
|
70
|
+
showSubtitle: props.showSubtitle,
|
|
71
|
+
showTitle: props.showTitle,
|
|
72
|
+
size: props.size,
|
|
73
|
+
variant: props.variant
|
|
74
|
+
},
|
|
75
|
+
slots["default"] ? { default: (renderProps) => slots["default"](renderProps) } : void 0
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
export default SignUp;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific Loading control component.
|
|
21
|
+
*
|
|
22
|
+
* Renders its default slot while Asgardeo is initialising. Renders the
|
|
23
|
+
* `fallback` slot (if provided) once loading is complete.
|
|
24
|
+
*
|
|
25
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```vue
|
|
29
|
+
* <AsgardeoLoading>
|
|
30
|
+
* <Spinner />
|
|
31
|
+
* <template #fallback><NuxtPage /></template>
|
|
32
|
+
* </AsgardeoLoading>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const Loading: Component;
|
|
36
|
+
export default Loading;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment, defineComponent, h } from "vue";
|
|
2
|
+
import { useAsgardeo } from "#imports";
|
|
3
|
+
const Loading = defineComponent({
|
|
4
|
+
name: "Loading",
|
|
5
|
+
setup(_props, { slots }) {
|
|
6
|
+
const { isLoading } = useAsgardeo();
|
|
7
|
+
return () => {
|
|
8
|
+
if (!isLoading.value) {
|
|
9
|
+
const fallback = slots["fallback"]?.();
|
|
10
|
+
return fallback ? h(Fragment, {}, fallback) : null;
|
|
11
|
+
}
|
|
12
|
+
const content = slots["default"]?.();
|
|
13
|
+
return content ? h(Fragment, {}, content) : null;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export default Loading;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific SignedIn control component.
|
|
21
|
+
*
|
|
22
|
+
* Renders its default slot only when the user is authenticated. Renders the
|
|
23
|
+
* `fallback` slot (if provided) when the user is not signed in.
|
|
24
|
+
*
|
|
25
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer so it reads from the
|
|
26
|
+
* ASGARDEO_KEY context wired up by the Nuxt plugin — not directly from
|
|
27
|
+
* `@asgardeo/vue`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```vue
|
|
31
|
+
* <AsgardeoSignedIn>
|
|
32
|
+
* <p>Welcome!</p>
|
|
33
|
+
* <template #fallback><p>Please sign in.</p></template>
|
|
34
|
+
* </AsgardeoSignedIn>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const SignedIn: Component;
|
|
38
|
+
export default SignedIn;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment, defineComponent, h } from "vue";
|
|
2
|
+
import { useAsgardeo } from "#imports";
|
|
3
|
+
const SignedIn = defineComponent({
|
|
4
|
+
name: "SignedIn",
|
|
5
|
+
setup(_props, { slots }) {
|
|
6
|
+
const { isSignedIn } = useAsgardeo();
|
|
7
|
+
return () => {
|
|
8
|
+
if (!isSignedIn.value) {
|
|
9
|
+
const fallback = slots["fallback"]?.();
|
|
10
|
+
return fallback ? h(Fragment, {}, fallback) : null;
|
|
11
|
+
}
|
|
12
|
+
const content = slots["default"]?.();
|
|
13
|
+
return content ? h(Fragment, {}, content) : null;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export default SignedIn;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific SignedOut control component.
|
|
21
|
+
*
|
|
22
|
+
* Renders its default slot only when the user is NOT authenticated. Renders
|
|
23
|
+
* the `fallback` slot (if provided) when the user is already signed in.
|
|
24
|
+
*
|
|
25
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer so it reads from the
|
|
26
|
+
* ASGARDEO_KEY context wired up by the Nuxt plugin.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```vue
|
|
30
|
+
* <AsgardeoSignedOut>
|
|
31
|
+
* <p>Please sign in.</p>
|
|
32
|
+
* <template #fallback><p>You are signed in.</p></template>
|
|
33
|
+
* </AsgardeoSignedOut>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const SignedOut: Component;
|
|
37
|
+
export default SignedOut;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment, defineComponent, h } from "vue";
|
|
2
|
+
import { useAsgardeo } from "#imports";
|
|
3
|
+
const SignedOut = defineComponent({
|
|
4
|
+
name: "SignedOut",
|
|
5
|
+
setup(_props, { slots }) {
|
|
6
|
+
const { isSignedIn } = useAsgardeo();
|
|
7
|
+
return () => {
|
|
8
|
+
if (isSignedIn.value) {
|
|
9
|
+
const fallback = slots["fallback"]?.();
|
|
10
|
+
return fallback ? h(Fragment, {}, fallback) : null;
|
|
11
|
+
}
|
|
12
|
+
const content = slots["default"]?.();
|
|
13
|
+
return content ? h(Fragment, {}, content) : null;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export default SignedOut;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific CreateOrganization container.
|
|
21
|
+
*
|
|
22
|
+
* Reads `createOrganization` from `useOrganization()` (Nuxt auto-import,
|
|
23
|
+
* re-exported from `@asgardeo/vue`) and delegates rendering to
|
|
24
|
+
* {@link BaseCreateOrganization} from `@asgardeo/vue`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```vue
|
|
28
|
+
* <AsgardeoCreateOrganization title="New Team" />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const CreateOrganization: Component;
|
|
32
|
+
export default CreateOrganization;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseCreateOrganization } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { useOrganization } from "#imports";
|
|
5
|
+
const CreateOrganization = defineComponent({
|
|
6
|
+
name: "CreateOrganization",
|
|
7
|
+
props: {
|
|
8
|
+
className: { default: "", type: String },
|
|
9
|
+
description: { default: "Create a new sub-organization.", type: String },
|
|
10
|
+
title: { default: "Create Organization", type: String }
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
const { createOrganization } = useOrganization();
|
|
14
|
+
return () => h(
|
|
15
|
+
BaseCreateOrganization,
|
|
16
|
+
{
|
|
17
|
+
class: withVendorCSSClassPrefix("create-organization--styled"),
|
|
18
|
+
className: props.className,
|
|
19
|
+
description: props.description,
|
|
20
|
+
onCreate: createOrganization ? async (name) => {
|
|
21
|
+
await createOrganization({ description: "", name, parentId: "", type: "TENANT" }, "");
|
|
22
|
+
} : void 0,
|
|
23
|
+
title: props.title
|
|
24
|
+
},
|
|
25
|
+
slots
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export default CreateOrganization;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 Component } from 'vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-specific Organization control component.
|
|
21
|
+
*
|
|
22
|
+
* Exposes the current organization via a scoped slot. Renders the `fallback`
|
|
23
|
+
* slot when no organization is selected.
|
|
24
|
+
*
|
|
25
|
+
* Uses `useOrganization()` from the Nuxt auto-import layer (re-exported from
|
|
26
|
+
* `@asgardeo/vue`) so it reads from the OrganizationProvider context.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```vue
|
|
30
|
+
* <AsgardeoOrganization>
|
|
31
|
+
* <template #default="{ organization }">
|
|
32
|
+
* <p>Current org: {{ organization.name }}</p>
|
|
33
|
+
* </template>
|
|
34
|
+
* <template #fallback><p>No organization selected.</p></template>
|
|
35
|
+
* </AsgardeoOrganization>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const Organization: Component;
|
|
39
|
+
export default Organization;
|