@thunderid/nuxt 0.2.0 → 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 (43) 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/components/auth/SignUp.js +1 -4
  6. package/dist/runtime/composables/useThunderID.js +1 -12
  7. package/dist/runtime/errors/error-codes.d.ts +0 -2
  8. package/dist/runtime/errors/error-codes.js +0 -2
  9. package/dist/runtime/plugins/thunderid.d.ts +2 -3
  10. package/dist/runtime/plugins/thunderid.js +1 -13
  11. package/dist/runtime/server/ThunderIDNuxtClient.d.ts +2 -10
  12. package/dist/runtime/server/ThunderIDNuxtClient.js +3 -116
  13. package/dist/runtime/server/plugins/thunderid-ssr.d.ts +1 -3
  14. package/dist/runtime/server/plugins/thunderid-ssr.js +2 -22
  15. package/dist/runtime/server/routes/auth/session/signin.post.d.ts +1 -1
  16. package/dist/runtime/server/routes/auth/session/signin.post.js +1 -1
  17. package/dist/runtime/server/routes/auth/session/signup.post.js +2 -2
  18. package/dist/runtime/types.d.ts +1 -20
  19. package/package.json +9 -9
  20. package/dist/runtime/components/organization/CreateOrganization.d.ts +0 -32
  21. package/dist/runtime/components/organization/CreateOrganization.js +0 -29
  22. package/dist/runtime/components/organization/Organization.d.ts +0 -39
  23. package/dist/runtime/components/organization/Organization.js +0 -17
  24. package/dist/runtime/components/organization/OrganizationList.d.ts +0 -34
  25. package/dist/runtime/components/organization/OrganizationList.js +0 -30
  26. package/dist/runtime/components/organization/OrganizationProfile.d.ts +0 -32
  27. package/dist/runtime/components/organization/OrganizationProfile.js +0 -32
  28. package/dist/runtime/components/organization/OrganizationSwitcher.d.ts +0 -36
  29. package/dist/runtime/components/organization/OrganizationSwitcher.js +0 -26
  30. package/dist/runtime/server/routes/auth/branding/branding.get.d.ts +0 -31
  31. package/dist/runtime/server/routes/auth/branding/branding.get.js +0 -40
  32. package/dist/runtime/server/routes/auth/organizations/current.get.d.ts +0 -29
  33. package/dist/runtime/server/routes/auth/organizations/current.get.js +0 -24
  34. package/dist/runtime/server/routes/auth/organizations/id.get.d.ts +0 -28
  35. package/dist/runtime/server/routes/auth/organizations/id.get.js +0 -28
  36. package/dist/runtime/server/routes/auth/organizations/index.get.d.ts +0 -28
  37. package/dist/runtime/server/routes/auth/organizations/index.get.js +0 -24
  38. package/dist/runtime/server/routes/auth/organizations/index.post.d.ts +0 -30
  39. package/dist/runtime/server/routes/auth/organizations/index.post.js +0 -30
  40. package/dist/runtime/server/routes/auth/organizations/me.get.d.ts +0 -28
  41. package/dist/runtime/server/routes/auth/organizations/me.get.js +0 -24
  42. package/dist/runtime/server/routes/auth/organizations/switch.post.d.ts +0 -32
  43. package/dist/runtime/server/routes/auth/organizations/switch.post.js +0 -49
@@ -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;
@@ -1,49 +0,0 @@
1
- import { defineEventHandler, readBody, createError } from "h3";
2
- import ThunderIDNuxtClient from "../../../ThunderIDNuxtClient.js";
3
- import { verifyAndRehydrateSession } from "../../../utils/serverSession.js";
4
- import { issueSessionCookie } from "../../../utils/session.js";
5
- import { useRuntimeConfig } from "#imports";
6
- export default defineEventHandler(async (event) => {
7
- const config = useRuntimeConfig();
8
- const sessionSecret = config.thunderid?.sessionSecret;
9
- const session = await verifyAndRehydrateSession(
10
- event,
11
- sessionSecret
12
- );
13
- if (!session) {
14
- throw createError({ statusCode: 401, statusMessage: "Unauthorized: Invalid or expired session." });
15
- }
16
- const { sessionId } = session;
17
- let organization;
18
- try {
19
- const body = await readBody(event);
20
- organization = body.organization;
21
- } catch {
22
- throw createError({ statusCode: 400, statusMessage: "Invalid request body." });
23
- }
24
- if (!organization?.id) {
25
- throw createError({ statusCode: 400, statusMessage: "organization.id is required." });
26
- }
27
- let tokenResponse;
28
- try {
29
- const client = ThunderIDNuxtClient.getInstance();
30
- const response = await client.switchOrganization(organization, sessionId);
31
- tokenResponse = response;
32
- } catch (err) {
33
- throw createError({
34
- statusCode: 500,
35
- statusMessage: `Organisation switch failed: ${err instanceof Error ? err.message : String(err)}`
36
- });
37
- }
38
- try {
39
- const runtimeConfig = useRuntimeConfig();
40
- const runtimeSessionSecret = runtimeConfig.thunderid?.sessionSecret;
41
- await issueSessionCookie(event, sessionId, tokenResponse, runtimeSessionSecret);
42
- } catch (err) {
43
- throw createError({
44
- statusCode: 500,
45
- statusMessage: `Failed to establish new session after organisation switch: ${err instanceof Error ? err.message : String(err)}`
46
- });
47
- }
48
- return { success: true };
49
- });