@thunderid/nuxt 0.2.1 → 0.2.2

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.
Files changed (38) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +0 -46
  3. package/dist/runtime/components/ThunderIDRoot.d.ts +3 -7
  4. package/dist/runtime/components/ThunderIDRoot.js +22 -92
  5. package/dist/runtime/errors/error-codes.d.ts +0 -2
  6. package/dist/runtime/errors/error-codes.js +0 -2
  7. package/dist/runtime/plugins/thunderid.d.ts +2 -3
  8. package/dist/runtime/plugins/thunderid.js +1 -13
  9. package/dist/runtime/server/ThunderIDNuxtClient.d.ts +1 -8
  10. package/dist/runtime/server/ThunderIDNuxtClient.js +1 -83
  11. package/dist/runtime/server/plugins/thunderid-ssr.d.ts +1 -3
  12. package/dist/runtime/server/plugins/thunderid-ssr.js +2 -22
  13. package/dist/runtime/types.d.ts +1 -14
  14. package/package.json +4 -4
  15. package/dist/runtime/components/organization/CreateOrganization.d.ts +0 -32
  16. package/dist/runtime/components/organization/CreateOrganization.js +0 -29
  17. package/dist/runtime/components/organization/Organization.d.ts +0 -39
  18. package/dist/runtime/components/organization/Organization.js +0 -17
  19. package/dist/runtime/components/organization/OrganizationList.d.ts +0 -34
  20. package/dist/runtime/components/organization/OrganizationList.js +0 -30
  21. package/dist/runtime/components/organization/OrganizationProfile.d.ts +0 -32
  22. package/dist/runtime/components/organization/OrganizationProfile.js +0 -32
  23. package/dist/runtime/components/organization/OrganizationSwitcher.d.ts +0 -36
  24. package/dist/runtime/components/organization/OrganizationSwitcher.js +0 -26
  25. package/dist/runtime/server/routes/auth/branding/branding.get.d.ts +0 -31
  26. package/dist/runtime/server/routes/auth/branding/branding.get.js +0 -40
  27. package/dist/runtime/server/routes/auth/organizations/current.get.d.ts +0 -29
  28. package/dist/runtime/server/routes/auth/organizations/current.get.js +0 -24
  29. package/dist/runtime/server/routes/auth/organizations/id.get.d.ts +0 -28
  30. package/dist/runtime/server/routes/auth/organizations/id.get.js +0 -28
  31. package/dist/runtime/server/routes/auth/organizations/index.get.d.ts +0 -28
  32. package/dist/runtime/server/routes/auth/organizations/index.get.js +0 -24
  33. package/dist/runtime/server/routes/auth/organizations/index.post.d.ts +0 -30
  34. package/dist/runtime/server/routes/auth/organizations/index.post.js +0 -30
  35. package/dist/runtime/server/routes/auth/organizations/me.get.d.ts +0 -28
  36. package/dist/runtime/server/routes/auth/organizations/me.get.js +0 -24
  37. package/dist/runtime/server/routes/auth/organizations/switch.post.d.ts +0 -32
  38. package/dist/runtime/server/routes/auth/organizations/switch.post.js +0 -49
@@ -1,39 +0,0 @@
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
- * `@thunderid/vue`) so it reads from the OrganizationProvider context.
27
- *
28
- * @example
29
- * ```vue
30
- * <ThunderIDOrganization>
31
- * <template #default="{ organization }">
32
- * <p>Current org: {{ organization.name }}</p>
33
- * </template>
34
- * <template #fallback><p>No organization selected.</p></template>
35
- * </ThunderIDOrganization>
36
- * ```
37
- */
38
- declare const Organization: Component;
39
- export default Organization;
@@ -1,17 +0,0 @@
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;
@@ -1,34 +0,0 @@
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 `@thunderid/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
- * <ThunderIDOrganizationList @select="handleOrgSelect" />
31
- * ```
32
- */
33
- declare const OrganizationList: Component;
34
- export default OrganizationList;
@@ -1,30 +0,0 @@
1
- import { withVendorCSSClassPrefix } from "@thunderid/browser";
2
- import { BaseOrganizationList } from "@thunderid/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;
@@ -1,32 +0,0 @@
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 `@thunderid/vue`) and delegates rendering to
24
- * {@link BaseOrganizationProfile} from `@thunderid/vue`.
25
- *
26
- * @example
27
- * ```vue
28
- * <ThunderIDOrganizationProfile :editable="true" />
29
- * ```
30
- */
31
- declare const OrganizationProfile: Component;
32
- export default OrganizationProfile;
@@ -1,32 +0,0 @@
1
- import { withVendorCSSClassPrefix } from "@thunderid/browser";
2
- import { BaseOrganizationProfile } from "@thunderid/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;
@@ -1,36 +0,0 @@
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 `@thunderid/vue`) and delegates rendering to
24
- * {@link BaseOrganizationSwitcher} from `@thunderid/vue`.
25
- *
26
- * The `switchOrganization` action is provided by the OrganizationProvider
27
- * context set up by {@link ThunderIDRoot}, which ultimately calls the Nitro
28
- * `/api/auth/switch-org` route — no direct `window.location` usage.
29
- *
30
- * @example
31
- * ```vue
32
- * <ThunderIDOrganizationSwitcher />
33
- * ```
34
- */
35
- declare const OrganizationSwitcher: Component;
36
- export default OrganizationSwitcher;
@@ -1,26 +0,0 @@
1
- import { withVendorCSSClassPrefix } from "@thunderid/browser";
2
- import { BaseOrganizationSwitcher } from "@thunderid/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;
@@ -1,31 +0,0 @@
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 { BrandingPreference } from '@thunderid/node';
19
- /**
20
- * GET /api/auth/branding
21
- *
22
- * Returns the branding preference for the current tenant / organisation context.
23
- * Resolves the correct `baseUrl` (org-scoped if the session is inside an org).
24
- * Does not require an authenticated session — unauthenticated callers receive
25
- * the root-tenant branding.
26
- *
27
- * Used by `ThunderIDRoot.revalidateBranding` to refresh client-side branding
28
- * state without a full page reload.
29
- */
30
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<BrandingPreference | null>>;
31
- export default _default;
@@ -1,40 +0,0 @@
1
- import { defineEventHandler, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig(event);
7
- const publicConfig = config.public.thunderid;
8
- const sessionSecret = config.thunderid?.sessionSecret;
9
- const baseUrl = publicConfig?.baseUrl ?? "";
10
- let resolvedBaseUrl = baseUrl;
11
- try {
12
- const session = await verifyAndRehydrateSession(
13
- event,
14
- sessionSecret
15
- );
16
- if (session) {
17
- if (session.organizationId) {
18
- resolvedBaseUrl = `${baseUrl}/o`;
19
- } else {
20
- const client = ThunderIDNuxtClient.getInstance();
21
- const idToken = await client.getDecodedIdToken(
22
- session.sessionId
23
- );
24
- if (idToken?.user_org) {
25
- resolvedBaseUrl = `${baseUrl}/o`;
26
- }
27
- }
28
- }
29
- } catch {
30
- }
31
- try {
32
- const client = ThunderIDNuxtClient.getInstance();
33
- return await client.getBrandingPreference({ baseUrl: resolvedBaseUrl });
34
- } catch (err) {
35
- throw createError({
36
- statusCode: 500,
37
- statusMessage: `Failed to retrieve branding preference: ${err instanceof Error ? err.message : String(err)}`
38
- });
39
- }
40
- });
@@ -1,29 +0,0 @@
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 { Organization } from '@thunderid/node';
19
- /**
20
- * GET /api/auth/organizations/current
21
- *
22
- * Returns the organisation the authenticated user is currently acting within,
23
- * derived from the session's ID token (`org_id` / `org_name` claims).
24
- * Returns `null` when the user is not inside an organisation context.
25
- *
26
- * Used by `ThunderIDRoot.revalidateCurrentOrganization` callback.
27
- */
28
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Organization | null>>;
29
- export default _default;
@@ -1,24 +0,0 @@
1
- import { defineEventHandler, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig();
7
- const sessionSecret = config.thunderid?.sessionSecret;
8
- const session = await verifyAndRehydrateSession(
9
- event,
10
- sessionSecret
11
- );
12
- if (!session) {
13
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
14
- }
15
- try {
16
- const client = ThunderIDNuxtClient.getInstance();
17
- return await client.getCurrentOrganization(session.sessionId);
18
- } catch (err) {
19
- throw createError({
20
- statusCode: 500,
21
- statusMessage: `Failed to retrieve current organisation: ${err instanceof Error ? err.message : String(err)}`
22
- });
23
- }
24
- });
@@ -1,28 +0,0 @@
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 { OrganizationDetails } from '@thunderid/node';
19
- /**
20
- * GET /api/auth/organizations/:id
21
- *
22
- * Returns the details of a single organisation by its ID.
23
- * Requires an active session.
24
- *
25
- * Mirrors `getOrganizationAction` in the Next.js SDK.
26
- */
27
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<OrganizationDetails>>;
28
- export default _default;
@@ -1,28 +0,0 @@
1
- import { defineEventHandler, getRouterParam, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig();
7
- const sessionSecret = config.thunderid?.sessionSecret;
8
- const session = await verifyAndRehydrateSession(
9
- event,
10
- sessionSecret
11
- );
12
- if (!session) {
13
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
14
- }
15
- const organizationId = getRouterParam(event, "id");
16
- if (!organizationId) {
17
- throw createError({ statusCode: 400, statusMessage: "Organization ID is required." });
18
- }
19
- try {
20
- const client = ThunderIDNuxtClient.getInstance();
21
- return await client.getOrganization(organizationId, session.sessionId);
22
- } catch (err) {
23
- throw createError({
24
- statusCode: 500,
25
- statusMessage: `Failed to retrieve organisation: ${err instanceof Error ? err.message : String(err)}`
26
- });
27
- }
28
- });
@@ -1,28 +0,0 @@
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 { AllOrganizationsApiResponse } from '@thunderid/node';
19
- /**
20
- * GET /api/auth/organizations
21
- *
22
- * Returns all organisations accessible to the authenticated user (paginated).
23
- * Used by `ThunderIDRoot.getAllOrganizations` callback.
24
- *
25
- * Mirrors `getAllOrganizations` server action in the Next.js SDK.
26
- */
27
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<AllOrganizationsApiResponse>>;
28
- export default _default;
@@ -1,24 +0,0 @@
1
- import { defineEventHandler, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig();
7
- const sessionSecret = config.thunderid?.sessionSecret;
8
- const session = await verifyAndRehydrateSession(
9
- event,
10
- sessionSecret
11
- );
12
- if (!session) {
13
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
14
- }
15
- try {
16
- const client = ThunderIDNuxtClient.getInstance();
17
- return await client.getAllOrganizations(void 0, session.sessionId);
18
- } catch (err) {
19
- throw createError({
20
- statusCode: 500,
21
- statusMessage: `Failed to retrieve all organisations: ${err instanceof Error ? err.message : String(err)}`
22
- });
23
- }
24
- });
@@ -1,30 +0,0 @@
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 { Organization } from '@thunderid/node';
19
- /**
20
- * POST /api/auth/organizations
21
- *
22
- * Creates a new sub-organisation under the authenticated user's root organisation.
23
- *
24
- * Request body: {@link CreateOrganizationPayload}
25
- * Response: {@link Organization}
26
- *
27
- * Mirrors `createOrganization` server action in the Next.js SDK.
28
- */
29
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Organization>>;
30
- export default _default;
@@ -1,30 +0,0 @@
1
- import { defineEventHandler, readBody, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig();
7
- const sessionSecret = config.thunderid?.sessionSecret;
8
- const session = await verifyAndRehydrateSession(
9
- event,
10
- sessionSecret
11
- );
12
- if (!session) {
13
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
14
- }
15
- let payload;
16
- try {
17
- payload = await readBody(event);
18
- } catch {
19
- throw createError({ statusCode: 400, statusMessage: "Invalid request body." });
20
- }
21
- try {
22
- const client = ThunderIDNuxtClient.getInstance();
23
- return await client.createOrganization(payload, session.sessionId);
24
- } catch (err) {
25
- throw createError({
26
- statusCode: 500,
27
- statusMessage: `Failed to create organisation: ${err instanceof Error ? err.message : String(err)}`
28
- });
29
- }
30
- });
@@ -1,28 +0,0 @@
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 { Organization } from '@thunderid/node';
19
- /**
20
- * GET /api/auth/organizations/me
21
- *
22
- * Returns the list of organisations the authenticated user is a member of.
23
- * Used by `ThunderIDRoot.revalidateMyOrganizations` to refresh client-side state.
24
- *
25
- * Mirrors `getMyOrganizations` server action in the Next.js SDK.
26
- */
27
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Organization[]>>;
28
- export default _default;
@@ -1,24 +0,0 @@
1
- import { defineEventHandler, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { useRuntimeConfig } from "#imports";
5
- export default defineEventHandler(async (event) => {
6
- const config = useRuntimeConfig();
7
- const sessionSecret = config.thunderid?.sessionSecret;
8
- const session = await verifyAndRehydrateSession(
9
- event,
10
- sessionSecret
11
- );
12
- if (!session) {
13
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
14
- }
15
- try {
16
- const client = ThunderIDNuxtClient.getInstance();
17
- return await client.getMyOrganizations(session.sessionId);
18
- } catch (err) {
19
- throw createError({
20
- statusCode: 500,
21
- statusMessage: `Failed to retrieve organisations: ${err instanceof Error ? err.message : String(err)}`
22
- });
23
- }
24
- });
@@ -1,32 +0,0 @@
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
- * POST /api/auth/organizations/switch
20
- *
21
- * Performs an `organization_switch` token exchange for the given organisation,
22
- * then re-issues the JWT session cookie so subsequent requests carry the new
23
- * organisation context.
24
- *
25
- * Request body: `{ organization: Organization }`
26
- *
27
- * Mirrors `switchOrganization` server action in the Next.js SDK.
28
- */
29
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
30
- success: boolean;
31
- }>>;
32
- export default _default;