@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,17 @@
|
|
|
1
|
+
import { Fragment, defineComponent, h } from "vue";
|
|
2
|
+
import { useOrganization } from "#imports";
|
|
3
|
+
const Organization = defineComponent({
|
|
4
|
+
name: "Organization",
|
|
5
|
+
setup(_props, { slots }) {
|
|
6
|
+
const { currentOrganization } = useOrganization();
|
|
7
|
+
return () => {
|
|
8
|
+
if (!currentOrganization?.value) {
|
|
9
|
+
const fallback = slots["fallback"]?.();
|
|
10
|
+
return fallback ? h(Fragment, {}, fallback) : null;
|
|
11
|
+
}
|
|
12
|
+
const content = slots["default"]?.({ organization: currentOrganization.value });
|
|
13
|
+
return content ? h(Fragment, {}, content) : null;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export default Organization;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 OrganizationList container.
|
|
21
|
+
*
|
|
22
|
+
* Reads organization list context from `useOrganization()` (Nuxt auto-import)
|
|
23
|
+
* and delegates rendering to {@link BaseOrganizationList} from `@asgardeo/vue`.
|
|
24
|
+
*
|
|
25
|
+
* Emits a `select` event with the chosen {@link IOrganization} before calling
|
|
26
|
+
* `switchOrganization` so consumers can handle custom post-switch logic.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```vue
|
|
30
|
+
* <AsgardeoOrganizationList @select="handleOrgSelect" />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare const OrganizationList: Component;
|
|
34
|
+
export default OrganizationList;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseOrganizationList } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { useOrganization } from "#imports";
|
|
5
|
+
const OrganizationList = defineComponent({
|
|
6
|
+
emits: ["select"],
|
|
7
|
+
name: "OrganizationList",
|
|
8
|
+
props: {
|
|
9
|
+
className: { default: "", type: String }
|
|
10
|
+
},
|
|
11
|
+
setup(props, { slots, emit }) {
|
|
12
|
+
const { myOrganizations, isLoading, switchOrganization } = useOrganization();
|
|
13
|
+
const handleSelect = async (org) => {
|
|
14
|
+
emit("select", org);
|
|
15
|
+
await switchOrganization(org);
|
|
16
|
+
};
|
|
17
|
+
return () => h(
|
|
18
|
+
BaseOrganizationList,
|
|
19
|
+
{
|
|
20
|
+
class: withVendorCSSClassPrefix("organization-list--styled"),
|
|
21
|
+
className: props.className,
|
|
22
|
+
isLoading: isLoading?.value ?? false,
|
|
23
|
+
onSelect: handleSelect,
|
|
24
|
+
organizations: myOrganizations?.value ?? []
|
|
25
|
+
},
|
|
26
|
+
slots
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export default OrganizationList;
|
|
@@ -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 OrganizationProfile container.
|
|
21
|
+
*
|
|
22
|
+
* Reads the current organization from `useOrganization()` (Nuxt auto-import,
|
|
23
|
+
* re-exported from `@asgardeo/vue`) and delegates rendering to
|
|
24
|
+
* {@link BaseOrganizationProfile} from `@asgardeo/vue`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```vue
|
|
28
|
+
* <AsgardeoOrganizationProfile :editable="true" />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const OrganizationProfile: Component;
|
|
32
|
+
export default OrganizationProfile;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseOrganizationProfile } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { useOrganization } from "#imports";
|
|
5
|
+
const OrganizationProfile = defineComponent({
|
|
6
|
+
name: "OrganizationProfile",
|
|
7
|
+
props: {
|
|
8
|
+
className: { default: "", type: String },
|
|
9
|
+
editable: { default: false, type: Boolean },
|
|
10
|
+
onUpdate: {
|
|
11
|
+
default: void 0,
|
|
12
|
+
type: Function
|
|
13
|
+
},
|
|
14
|
+
title: { default: "Organization Profile", type: String }
|
|
15
|
+
},
|
|
16
|
+
setup(props, { slots }) {
|
|
17
|
+
const { currentOrganization } = useOrganization();
|
|
18
|
+
return () => h(
|
|
19
|
+
BaseOrganizationProfile,
|
|
20
|
+
{
|
|
21
|
+
class: withVendorCSSClassPrefix("organization-profile--styled"),
|
|
22
|
+
className: props.className,
|
|
23
|
+
editable: props.editable,
|
|
24
|
+
onUpdate: props.onUpdate,
|
|
25
|
+
organization: currentOrganization?.value ?? null,
|
|
26
|
+
title: props.title
|
|
27
|
+
},
|
|
28
|
+
slots
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export default OrganizationProfile;
|
|
@@ -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 OrganizationSwitcher container.
|
|
21
|
+
*
|
|
22
|
+
* Reads organization context from `useOrganization()` (Nuxt auto-import,
|
|
23
|
+
* re-exported from `@asgardeo/vue`) and delegates rendering to
|
|
24
|
+
* {@link BaseOrganizationSwitcher} from `@asgardeo/vue`.
|
|
25
|
+
*
|
|
26
|
+
* The `switchOrganization` action is provided by the OrganizationProvider
|
|
27
|
+
* context set up by {@link AsgardeoRoot}, which ultimately calls the Nitro
|
|
28
|
+
* `/api/auth/switch-org` route — no direct `window.location` usage.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```vue
|
|
32
|
+
* <AsgardeoOrganizationSwitcher />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const OrganizationSwitcher: Component;
|
|
36
|
+
export default OrganizationSwitcher;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseOrganizationSwitcher } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { useOrganization } from "#imports";
|
|
5
|
+
const OrganizationSwitcher = defineComponent({
|
|
6
|
+
name: "OrganizationSwitcher",
|
|
7
|
+
props: {
|
|
8
|
+
className: { default: "", type: String }
|
|
9
|
+
},
|
|
10
|
+
setup(props, { slots }) {
|
|
11
|
+
const { currentOrganization, myOrganizations, isLoading, switchOrganization } = useOrganization();
|
|
12
|
+
return () => h(
|
|
13
|
+
BaseOrganizationSwitcher,
|
|
14
|
+
{
|
|
15
|
+
class: withVendorCSSClassPrefix("organization-switcher--styled"),
|
|
16
|
+
className: props.className,
|
|
17
|
+
currentOrganization: currentOrganization?.value ?? null,
|
|
18
|
+
isLoading: isLoading?.value ?? false,
|
|
19
|
+
onSwitch: switchOrganization,
|
|
20
|
+
organizations: myOrganizations?.value ?? []
|
|
21
|
+
},
|
|
22
|
+
slots
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export default OrganizationSwitcher;
|
|
@@ -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 User control component.
|
|
21
|
+
*
|
|
22
|
+
* Exposes the current authenticated user via a scoped slot. Renders the
|
|
23
|
+
* `fallback` slot when no user is signed in.
|
|
24
|
+
*
|
|
25
|
+
* Uses `useAsgardeo()` from the Nuxt auto-import layer.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```vue
|
|
29
|
+
* <AsgardeoUser>
|
|
30
|
+
* <template #default="{ user }">
|
|
31
|
+
* <p>Welcome, {{ user.givenName }}!</p>
|
|
32
|
+
* </template>
|
|
33
|
+
* <template #fallback><p>Not signed in.</p></template>
|
|
34
|
+
* </AsgardeoUser>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const User: Component;
|
|
38
|
+
export default User;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment, defineComponent, h } from "vue";
|
|
2
|
+
import { useAsgardeo } from "#imports";
|
|
3
|
+
const User = defineComponent({
|
|
4
|
+
name: "User",
|
|
5
|
+
setup(_props, { slots }) {
|
|
6
|
+
const { user } = useAsgardeo();
|
|
7
|
+
return () => {
|
|
8
|
+
if (!user.value) {
|
|
9
|
+
const fallback = slots["fallback"]?.();
|
|
10
|
+
return fallback ? h(Fragment, {}, fallback) : null;
|
|
11
|
+
}
|
|
12
|
+
const content = slots["default"]?.({ user: user.value });
|
|
13
|
+
return content ? h(Fragment, {}, content) : null;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export default User;
|
|
@@ -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 UserDropdown container.
|
|
21
|
+
*
|
|
22
|
+
* Reads `user` and `signOut` from `useAsgardeo()` (Nuxt auto-import) and
|
|
23
|
+
* profile data from `useUser()`, then delegates rendering to
|
|
24
|
+
* {@link BaseUserDropdown} from `@asgardeo/vue`.
|
|
25
|
+
*
|
|
26
|
+
* The `signOut` action comes from the Nuxt plugin's ASGARDEO_KEY so it uses
|
|
27
|
+
* `navigateTo` for the redirect instead of `window.location`.
|
|
28
|
+
*
|
|
29
|
+
* The embedded profile modal renders the Nuxt-specific `UserProfile` so that
|
|
30
|
+
* profile update handlers are also wired through the Nuxt auto-import layer.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```vue
|
|
34
|
+
* <AsgardeoUserDropdown />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const UserDropdown: Component;
|
|
38
|
+
export default UserDropdown;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseUserDropdown, UserProfile as UserProfileComponent } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h, ref } from "vue";
|
|
4
|
+
import { useAsgardeo, useUser } from "#imports";
|
|
5
|
+
const UserDropdown = defineComponent({
|
|
6
|
+
emits: ["profileClick"],
|
|
7
|
+
name: "UserDropdown",
|
|
8
|
+
props: {
|
|
9
|
+
className: { default: "", type: String }
|
|
10
|
+
},
|
|
11
|
+
setup(props, { slots, emit }) {
|
|
12
|
+
const { user, signOut } = useAsgardeo();
|
|
13
|
+
useUser();
|
|
14
|
+
const isProfileModalOpen = ref(false);
|
|
15
|
+
return () => h(
|
|
16
|
+
BaseUserDropdown,
|
|
17
|
+
{
|
|
18
|
+
class: withVendorCSSClassPrefix("user-dropdown--styled"),
|
|
19
|
+
className: props.className,
|
|
20
|
+
isProfileModalOpen: isProfileModalOpen.value,
|
|
21
|
+
onProfileClick: () => {
|
|
22
|
+
isProfileModalOpen.value = true;
|
|
23
|
+
emit("profileClick");
|
|
24
|
+
},
|
|
25
|
+
onProfileModalClose: () => {
|
|
26
|
+
isProfileModalOpen.value = false;
|
|
27
|
+
},
|
|
28
|
+
onSignOut: () => {
|
|
29
|
+
signOut();
|
|
30
|
+
},
|
|
31
|
+
// Inline profile content avoids creating a circular dependency on the
|
|
32
|
+
// Nuxt UserProfile container; UserProfileComponent from @asgardeo/vue
|
|
33
|
+
// reads its data from the OrganizationProvider / UserProvider context
|
|
34
|
+
// wired up by AsgardeoRoot, so it works identically.
|
|
35
|
+
profileContent: isProfileModalOpen.value ? h(UserProfileComponent, {
|
|
36
|
+
cardLayout: false,
|
|
37
|
+
editable: true
|
|
38
|
+
}) : null,
|
|
39
|
+
user: user.value
|
|
40
|
+
},
|
|
41
|
+
slots
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export default UserDropdown;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 UserProfile container.
|
|
21
|
+
*
|
|
22
|
+
* Reads user profile data from `useUser()` (Nuxt auto-import, re-exported
|
|
23
|
+
* from `@asgardeo/vue`) and delegates rendering to {@link BaseUserProfile}
|
|
24
|
+
* from `@asgardeo/vue`.
|
|
25
|
+
*
|
|
26
|
+
* Preserves the same prop/slot API as the Vue SDK's `UserProfile` component
|
|
27
|
+
* so consumers don't need to change their templates.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```vue
|
|
31
|
+
* <AsgardeoUserProfile :editable="true" title="My Profile" />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare const UserProfile: Component;
|
|
35
|
+
export default UserProfile;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { withVendorCSSClassPrefix } from "@asgardeo/browser";
|
|
2
|
+
import { BaseUserProfile } from "@asgardeo/vue";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { useUser } from "#imports";
|
|
5
|
+
const UserProfile = defineComponent({
|
|
6
|
+
name: "UserProfile",
|
|
7
|
+
props: {
|
|
8
|
+
cardLayout: { default: true, type: Boolean },
|
|
9
|
+
className: { default: "", type: String },
|
|
10
|
+
editable: { default: true, type: Boolean },
|
|
11
|
+
hideFields: { default: () => [], type: Array },
|
|
12
|
+
showFields: { default: () => [], type: Array },
|
|
13
|
+
title: { default: "Profile", type: String }
|
|
14
|
+
},
|
|
15
|
+
setup(props, { slots }) {
|
|
16
|
+
const { flattenedProfile, schemas, updateProfile } = useUser();
|
|
17
|
+
return () => h(
|
|
18
|
+
BaseUserProfile,
|
|
19
|
+
{
|
|
20
|
+
cardLayout: props.cardLayout,
|
|
21
|
+
class: withVendorCSSClassPrefix("user-profile--styled"),
|
|
22
|
+
className: props.className,
|
|
23
|
+
editable: props.editable,
|
|
24
|
+
flattenedProfile: flattenedProfile?.value,
|
|
25
|
+
hideFields: props.hideFields,
|
|
26
|
+
onUpdate: updateProfile,
|
|
27
|
+
schemas: schemas?.value,
|
|
28
|
+
showFields: props.showFields,
|
|
29
|
+
title: props.title
|
|
30
|
+
},
|
|
31
|
+
slots
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export default UserProfile;
|
|
@@ -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 AsgardeoContext } from '@asgardeo/vue';
|
|
19
|
+
/**
|
|
20
|
+
* Nuxt-aware primary composable for Asgardeo authentication.
|
|
21
|
+
*
|
|
22
|
+
* Mirrors the Next.js `useAsgardeo` hook: a thin wrapper over the base SDK's
|
|
23
|
+
* `useAsgardeo` that re-binds the redirect-based actions (`signIn`, `signOut`,
|
|
24
|
+
* `signUp`) to Nuxt's {@link navigateTo} so SSR redirects use the correct
|
|
25
|
+
* response mechanism instead of `window.location`.
|
|
26
|
+
*
|
|
27
|
+
* The surrounding context is guaranteed to be present by the Nuxt plugin
|
|
28
|
+
* (`ASGARDEO_KEY`) and {@link AsgardeoRoot} (the auxiliary provider tree),
|
|
29
|
+
* so this composable does not carry a fallback branch.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```vue
|
|
33
|
+
* <script setup>
|
|
34
|
+
* const { isSignedIn, user, signIn, signOut } = useAsgardeo();
|
|
35
|
+
* </script>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function useAsgardeo(): AsgardeoContext;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EmbeddedSignInFlowStatus, getRedirectBasedSignUpUrl } from "@asgardeo/browser";
|
|
2
|
+
import { useAsgardeo as useAsgardeoVue } from "@asgardeo/vue";
|
|
3
|
+
import { navigateTo, useState, useRuntimeConfig } from "#app";
|
|
4
|
+
export function useAsgardeo() {
|
|
5
|
+
const context = useAsgardeoVue();
|
|
6
|
+
const signIn = async (...args) => {
|
|
7
|
+
const arg0 = args[0];
|
|
8
|
+
const isEmbedded = typeof arg0 === "object" && arg0 !== null && "flowId" in arg0;
|
|
9
|
+
if (isEmbedded) {
|
|
10
|
+
const payload = arg0;
|
|
11
|
+
const request = args[1] ?? {};
|
|
12
|
+
const res = await $fetch("/api/auth/signin", {
|
|
13
|
+
body: { payload, request },
|
|
14
|
+
method: "POST"
|
|
15
|
+
});
|
|
16
|
+
if (res.data?.afterSignInUrl) {
|
|
17
|
+
if (import.meta.client) {
|
|
18
|
+
try {
|
|
19
|
+
const session = await $fetch("/api/auth/session");
|
|
20
|
+
const authState = useState("asgardeo:auth");
|
|
21
|
+
authState.value = session;
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
authData: {},
|
|
27
|
+
flowStatus: EmbeddedSignInFlowStatus.SuccessCompleted
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return res.data;
|
|
31
|
+
}
|
|
32
|
+
const options = arg0;
|
|
33
|
+
const returnTo = typeof options?.["returnTo"] === "string" ? options["returnTo"] : void 0;
|
|
34
|
+
const url = returnTo ? `/api/auth/signin?returnTo=${encodeURIComponent(returnTo)}` : "/api/auth/signin";
|
|
35
|
+
await navigateTo(url, { external: true });
|
|
36
|
+
return void 0;
|
|
37
|
+
};
|
|
38
|
+
const signOut = async () => {
|
|
39
|
+
const res = await $fetch("/api/auth/signout", { method: "POST" });
|
|
40
|
+
await navigateTo(res.redirectUrl || "/", { external: true });
|
|
41
|
+
};
|
|
42
|
+
const signUp = async (...args) => {
|
|
43
|
+
const payload = args[0];
|
|
44
|
+
if (payload && typeof payload === "object" && "flowType" in payload) {
|
|
45
|
+
const res = await $fetch("/api/auth/signup", {
|
|
46
|
+
body: { payload },
|
|
47
|
+
method: "POST"
|
|
48
|
+
});
|
|
49
|
+
if (res.data?.afterSignUpUrl) {
|
|
50
|
+
await navigateTo(res.data.afterSignUpUrl, { external: false });
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return res.data;
|
|
54
|
+
}
|
|
55
|
+
const cfg = useRuntimeConfig().public.asgardeo ?? {};
|
|
56
|
+
if (cfg.signUpUrl) {
|
|
57
|
+
await navigateTo(cfg.signUpUrl, { external: true });
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
const redirectUrl = getRedirectBasedSignUpUrl({
|
|
61
|
+
applicationId: cfg.applicationId,
|
|
62
|
+
baseUrl: cfg.baseUrl,
|
|
63
|
+
clientId: cfg.clientId
|
|
64
|
+
});
|
|
65
|
+
if (redirectUrl) {
|
|
66
|
+
await navigateTo(redirectUrl, { external: true });
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
await navigateTo("/sign-up", { external: false });
|
|
70
|
+
return void 0;
|
|
71
|
+
};
|
|
72
|
+
return { ...context, signIn, signOut, signUp };
|
|
73
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { ErrorCode } from './error-codes.js';
|
|
19
|
+
/**
|
|
20
|
+
* Structured error type for the Asgardeo Nuxt SDK.
|
|
21
|
+
*
|
|
22
|
+
* Every error thrown by SDK internals should be an `AsgardeoError` so
|
|
23
|
+
* that callers can branch on `err.code` instead of matching strings.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* try {
|
|
28
|
+
* const session = await requireServerSession(event);
|
|
29
|
+
* } catch (err) {
|
|
30
|
+
* if (err instanceof AsgardeoError && err.code === ErrorCode.SessionMissing) {
|
|
31
|
+
* throw createError({ statusCode: 401 });
|
|
32
|
+
* }
|
|
33
|
+
* throw err;
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class AsgardeoError extends Error {
|
|
38
|
+
readonly code: ErrorCode;
|
|
39
|
+
readonly statusCode?: number;
|
|
40
|
+
readonly cause?: unknown;
|
|
41
|
+
readonly context?: Record<string, unknown>;
|
|
42
|
+
constructor(message: string, code: ErrorCode, opts?: {
|
|
43
|
+
cause?: unknown;
|
|
44
|
+
context?: Record<string, unknown>;
|
|
45
|
+
statusCode?: number;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AsgardeoError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
statusCode;
|
|
4
|
+
cause;
|
|
5
|
+
context;
|
|
6
|
+
constructor(message, code, opts) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "AsgardeoError";
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.statusCode = opts?.statusCode;
|
|
11
|
+
this.cause = opts?.cause;
|
|
12
|
+
this.context = opts?.context;
|
|
13
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -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
|
+
/**
|
|
19
|
+
* Typed error codes for the Asgardeo Nuxt SDK.
|
|
20
|
+
* Every structured error thrown by the SDK carries one of these codes
|
|
21
|
+
* so callers can react to specific failure modes without string matching.
|
|
22
|
+
*/
|
|
23
|
+
export declare enum ErrorCode {
|
|
24
|
+
ConfigMissingBaseUrl = "config/missing-base-url",
|
|
25
|
+
ConfigMissingClientId = "config/missing-client-id",
|
|
26
|
+
ConfigMissingSecret = "config/missing-session-secret",
|
|
27
|
+
OAuthCallbackError = "oauth/callback-error",
|
|
28
|
+
OAuthStateInvalid = "oauth/state-invalid",
|
|
29
|
+
OpenRedirectBlocked = "security/open-redirect-blocked",
|
|
30
|
+
OrganizationCreateFailed = "organization/create-failed",
|
|
31
|
+
OrganizationSwitchFailed = "organization/switch-failed",
|
|
32
|
+
SessionExpired = "session/expired",
|
|
33
|
+
SessionInvalid = "session/invalid",
|
|
34
|
+
SessionMissing = "session/missing",
|
|
35
|
+
TempSessionInvalid = "session/temp-invalid",
|
|
36
|
+
TokenExchangeFailed = "oauth/token-exchange-failed",
|
|
37
|
+
TokenRefreshFailed = "oauth/token-refresh-failed",
|
|
38
|
+
UserProfileFetchFailed = "scim2/user-profile-fetch-failed",
|
|
39
|
+
UserProfileUpdateFailed = "scim2/user-profile-update-failed"
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
2
|
+
ErrorCode2["ConfigMissingBaseUrl"] = "config/missing-base-url";
|
|
3
|
+
ErrorCode2["ConfigMissingClientId"] = "config/missing-client-id";
|
|
4
|
+
ErrorCode2["ConfigMissingSecret"] = "config/missing-session-secret";
|
|
5
|
+
ErrorCode2["OAuthCallbackError"] = "oauth/callback-error";
|
|
6
|
+
ErrorCode2["OAuthStateInvalid"] = "oauth/state-invalid";
|
|
7
|
+
ErrorCode2["OpenRedirectBlocked"] = "security/open-redirect-blocked";
|
|
8
|
+
ErrorCode2["OrganizationCreateFailed"] = "organization/create-failed";
|
|
9
|
+
ErrorCode2["OrganizationSwitchFailed"] = "organization/switch-failed";
|
|
10
|
+
ErrorCode2["SessionExpired"] = "session/expired";
|
|
11
|
+
ErrorCode2["SessionInvalid"] = "session/invalid";
|
|
12
|
+
ErrorCode2["SessionMissing"] = "session/missing";
|
|
13
|
+
ErrorCode2["TempSessionInvalid"] = "session/temp-invalid";
|
|
14
|
+
ErrorCode2["TokenExchangeFailed"] = "oauth/token-exchange-failed";
|
|
15
|
+
ErrorCode2["TokenRefreshFailed"] = "oauth/token-refresh-failed";
|
|
16
|
+
ErrorCode2["UserProfileFetchFailed"] = "scim2/user-profile-fetch-failed";
|
|
17
|
+
ErrorCode2["UserProfileUpdateFailed"] = "scim2/user-profile-update-failed";
|
|
18
|
+
return ErrorCode2;
|
|
19
|
+
})(ErrorCode || {});
|