@openape/nuxt-auth-sp 0.3.0 → 0.4.1

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/dist/module.d.mts CHANGED
@@ -1,5 +1,49 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
+ interface ManifestConfig {
4
+ service?: {
5
+ name?: string;
6
+ description?: string;
7
+ url?: string;
8
+ icon?: string;
9
+ privacy_policy?: string;
10
+ terms?: string;
11
+ contact?: string;
12
+ };
13
+ auth?: {
14
+ ddisa_domain?: string;
15
+ oidc_client_id?: string;
16
+ supported_methods?: ('ddisa' | 'oidc')[];
17
+ login_url?: string;
18
+ };
19
+ scopes?: Record<string, {
20
+ name: string;
21
+ description: string;
22
+ risk: 'low' | 'medium' | 'high' | 'critical';
23
+ category?: string;
24
+ parameters?: Record<string, {
25
+ type: string;
26
+ description: string;
27
+ }>;
28
+ }>;
29
+ categories?: Record<string, {
30
+ name: string;
31
+ icon?: string;
32
+ }>;
33
+ policies?: {
34
+ agent_access?: string;
35
+ delegation?: 'allowed' | 'denied';
36
+ max_delegation_duration?: string | null;
37
+ require_grant_for_risk?: Record<string, string | null>;
38
+ require_mfa_for_risk?: Record<string, boolean>;
39
+ };
40
+ rate_limits?: Record<string, Record<string, number>>;
41
+ endpoints?: {
42
+ api_base?: string;
43
+ openapi?: string;
44
+ grant_verify?: string;
45
+ };
46
+ }
3
47
  interface ModuleOptions {
4
48
  spId: string;
5
49
  spName: string;
@@ -7,8 +51,9 @@ interface ModuleOptions {
7
51
  openapeUrl: string;
8
52
  fallbackIdpUrl: string;
9
53
  routes: boolean;
54
+ manifest?: ManifestConfig;
10
55
  }
11
56
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
57
 
13
58
  export { _default as default };
14
- export type { ModuleOptions };
59
+ export type { ManifestConfig, ModuleOptions };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@openape/nuxt-auth-sp",
3
3
  "configKey": "openapeSp",
4
- "version": "0.3.0",
4
+ "version": "0.4.1",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.4",
6
+ "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { useLogger, defineNuxtModule, createResolver, addServerImportsDir, addIm
3
3
  import { defu } from 'defu';
4
4
 
5
5
  const logger = useLogger("@openape/nuxt-auth-sp");
6
- const module = defineNuxtModule({
6
+ const module$1 = defineNuxtModule({
7
7
  meta: {
8
8
  name: "@openape/nuxt-auth-sp",
9
9
  configKey: "openapeSp"
@@ -54,8 +54,9 @@ const module = defineNuxtModule({
54
54
  addServerHandler({ route: "/api/me", handler: resolve("./runtime/server/api/me.get") });
55
55
  addServerHandler({ route: "/.well-known/sp-manifest.json", handler: resolve("./runtime/server/routes/well-known/sp-manifest.json.get") });
56
56
  addServerHandler({ route: "/.well-known/auth.md", handler: resolve("./runtime/server/routes/well-known/auth.md.get") });
57
+ addServerHandler({ route: "/.well-known/openape.json", handler: resolve("./runtime/server/routes/well-known/openape.json.get") });
57
58
  }
58
59
  }
59
60
  });
60
61
 
61
- export { module as default };
62
+ export { module$1 as default };
@@ -0,0 +1,38 @@
1
+ type __VLS_Props = {
2
+ title?: string;
3
+ subtitle?: string;
4
+ buttonText?: string;
5
+ placeholder?: string;
6
+ };
7
+ declare var __VLS_1: {}, __VLS_3: {
8
+ error: any;
9
+ }, __VLS_5: {
10
+ submitting: any;
11
+ }, __VLS_7: {};
12
+ type __VLS_Slots = {} & {
13
+ header?: (props: typeof __VLS_1) => any;
14
+ } & {
15
+ error?: (props: typeof __VLS_3) => any;
16
+ } & {
17
+ button?: (props: typeof __VLS_5) => any;
18
+ } & {
19
+ footer?: (props: typeof __VLS_7) => any;
20
+ };
21
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ error: (error: Error) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ onError?: ((error: Error) => any) | undefined;
25
+ }>, {
26
+ title: string;
27
+ subtitle: string;
28
+ buttonText: string;
29
+ placeholder: string;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -1,52 +1,39 @@
1
- <script setup lang="ts">
2
- withDefaults(defineProps<{
3
- title?: string
4
- subtitle?: string
5
- buttonText?: string
6
- placeholder?: string
7
- }>(), {
8
- title: 'Sign in',
9
- subtitle: 'Enter your email to continue',
10
- buttonText: 'Continue',
11
- placeholder: 'you@example.com',
12
- })
13
-
14
- const emit = defineEmits<{
15
- error: [error: Error]
16
- }>()
17
-
18
- const { user, loading, fetchUser, login } = useOpenApeAuth()
19
- const email = ref('')
20
- const error = ref('')
21
- const submitting = ref(false)
22
-
23
- const route = useRoute()
24
-
1
+ <script setup>
2
+ defineProps({
3
+ title: { type: String, required: false, default: "Sign in" },
4
+ subtitle: { type: String, required: false, default: "Enter your email to continue" },
5
+ buttonText: { type: String, required: false, default: "Continue" },
6
+ placeholder: { type: String, required: false, default: "you@example.com" }
7
+ });
8
+ const emit = defineEmits(["error"]);
9
+ const { user, loading, fetchUser, login } = useOpenApeAuth();
10
+ const email = ref("");
11
+ const error = ref("");
12
+ const submitting = ref(false);
13
+ const route = useRoute();
25
14
  onMounted(async () => {
26
- await fetchUser()
15
+ await fetchUser();
27
16
  if (user.value) {
28
- navigateTo('/dashboard')
17
+ navigateTo("/dashboard");
29
18
  }
30
19
  if (route.query.error) {
31
- error.value = String(route.query.error)
20
+ error.value = String(route.query.error);
32
21
  }
33
- })
34
-
22
+ });
35
23
  async function handleSubmit() {
36
- error.value = ''
37
- if (!email.value || !email.value.includes('@')) {
38
- error.value = 'Please enter a valid email address'
39
- return
24
+ error.value = "";
25
+ if (!email.value || !email.value.includes("@")) {
26
+ error.value = "Please enter a valid email address";
27
+ return;
40
28
  }
41
- submitting.value = true
29
+ submitting.value = true;
42
30
  try {
43
- await login(email.value)
44
- }
45
- catch (e: unknown) {
46
- const err = e instanceof Error ? e : new Error('Login failed')
47
- error.value = (e as any)?.data?.message || err.message
48
- emit('error', err)
49
- submitting.value = false
31
+ await login(email.value);
32
+ } catch (e) {
33
+ const err = e instanceof Error ? e : new Error("Login failed");
34
+ error.value = e?.data?.message || err.message;
35
+ emit("error", err);
36
+ submitting.value = false;
50
37
  }
51
38
  }
52
39
  </script>
@@ -0,0 +1,38 @@
1
+ type __VLS_Props = {
2
+ title?: string;
3
+ subtitle?: string;
4
+ buttonText?: string;
5
+ placeholder?: string;
6
+ };
7
+ declare var __VLS_1: {}, __VLS_3: {
8
+ error: any;
9
+ }, __VLS_5: {
10
+ submitting: any;
11
+ }, __VLS_7: {};
12
+ type __VLS_Slots = {} & {
13
+ header?: (props: typeof __VLS_1) => any;
14
+ } & {
15
+ error?: (props: typeof __VLS_3) => any;
16
+ } & {
17
+ button?: (props: typeof __VLS_5) => any;
18
+ } & {
19
+ footer?: (props: typeof __VLS_7) => any;
20
+ };
21
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ error: (error: Error) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ onError?: ((error: Error) => any) | undefined;
25
+ }>, {
26
+ title: string;
27
+ subtitle: string;
28
+ buttonText: string;
29
+ placeholder: string;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -1,2 +1,2 @@
1
- declare const _default: import("nuxt/app").RouteMiddleware;
1
+ declare const _default: import("#app").RouteMiddleware;
2
2
  export default _default;
@@ -30,7 +30,8 @@ export default defineEventHandler(async (event) => {
30
30
  clearFlowState(event);
31
31
  const session = await getSpSession(event);
32
32
  await session.update({
33
- claims: result.claims
33
+ claims: result.claims,
34
+ authorizationDetails: result.authorizationDetails
34
35
  });
35
36
  return sendRedirect(event, "/dashboard");
36
37
  } catch (err) {
@@ -0,0 +1,17 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, {
2
+ endpoints?: {} | undefined;
3
+ rate_limits?: {} | undefined;
4
+ policies?: {} | undefined;
5
+ categories?: {} | undefined;
6
+ scopes?: {} | undefined;
7
+ version: string;
8
+ service: {
9
+ name: any;
10
+ url: string;
11
+ };
12
+ auth: {
13
+ ddisa_domain: any;
14
+ supported_methods: string[];
15
+ };
16
+ }>;
17
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { defineEventHandler, getRequestURL, setResponseHeader } from "h3";
2
+ import { useRuntimeConfig } from "nitropack/runtime";
3
+ import { getSpConfig } from "../../utils/sp-config.js";
4
+ export default defineEventHandler((event) => {
5
+ const config = useRuntimeConfig();
6
+ const { spId, spName } = getSpConfig();
7
+ const origin = getRequestURL(event).origin;
8
+ const manifest = config.openapeSp.manifest;
9
+ setResponseHeader(event, "Access-Control-Allow-Origin", "*");
10
+ setResponseHeader(event, "Cache-Control", "public, max-age=3600");
11
+ return {
12
+ version: "1.0",
13
+ service: {
14
+ name: spName,
15
+ url: origin,
16
+ ...manifest?.service || {}
17
+ },
18
+ auth: {
19
+ ddisa_domain: spId,
20
+ supported_methods: ["ddisa"],
21
+ ...manifest?.auth || {}
22
+ },
23
+ ...manifest?.scopes ? { scopes: manifest.scopes } : {},
24
+ ...manifest?.categories ? { categories: manifest.categories } : {},
25
+ ...manifest?.policies ? { policies: manifest.policies } : {},
26
+ ...manifest?.rate_limits ? { rate_limits: manifest.rate_limits } : {},
27
+ ...manifest?.endpoints ? { endpoints: manifest.endpoints } : {}
28
+ };
29
+ });
@@ -0,0 +1,30 @@
1
+ import type { OpenApeAuthorizationDetail } from '@openape/core';
2
+ import type { H3Event } from 'h3';
3
+ /**
4
+ * Check if the current session has a grant for the given action.
5
+ */
6
+ export declare function hasGrant(event: H3Event, action: string): Promise<boolean>;
7
+ /**
8
+ * Find a specific grant by action from the session's authorization_details.
9
+ */
10
+ export declare function findGrant(event: H3Event, action: string): Promise<OpenApeAuthorizationDetail | null>;
11
+ /**
12
+ * Consume a 'once' grant by calling the IdP verify endpoint.
13
+ * Returns the verification result or throws on failure.
14
+ */
15
+ export declare function consumeGrant(event: H3Event, grantId: string): Promise<{
16
+ valid: boolean;
17
+ }>;
18
+ /**
19
+ * Check if the current session is a delegated session (has act claim as object).
20
+ */
21
+ export declare function isDelegated(event: H3Event): Promise<boolean>;
22
+ /**
23
+ * Get the actual actor (delegate) from a delegated session.
24
+ * Returns the delegate's identifier (e.g. agent email) or null if not delegated.
25
+ */
26
+ export declare function getActor(event: H3Event): Promise<string | null>;
27
+ /**
28
+ * Get the subject (delegator — person being acted on behalf of) from the session.
29
+ */
30
+ export declare function getSubject(event: H3Event): Promise<string | null>;
@@ -0,0 +1,55 @@
1
+ import { getSpSession } from "./sp-session.js";
2
+ import { getSpConfig } from "./sp-config.js";
3
+ export async function hasGrant(event, action) {
4
+ const session = await getSpSession(event);
5
+ const details = session.data.authorizationDetails;
6
+ if (!details) return false;
7
+ return details.some((d) => d.action === action);
8
+ }
9
+ export async function findGrant(event, action) {
10
+ const session = await getSpSession(event);
11
+ const details = session.data.authorizationDetails;
12
+ if (!details) return null;
13
+ return details.find((d) => d.action === action) ?? null;
14
+ }
15
+ export async function consumeGrant(event, grantId) {
16
+ const session = await getSpSession(event);
17
+ const details = session.data.authorizationDetails;
18
+ const detail = details?.find((d) => d.grant_id === grantId);
19
+ if (!detail) {
20
+ throw new Error(`Grant ${grantId} not found in session`);
21
+ }
22
+ const claims = session.data.claims;
23
+ const idpUrl = claims?.iss || getSpConfig().fallbackIdpUrl;
24
+ const response = await fetch(`${idpUrl}/api/grants/verify`, {
25
+ method: "POST",
26
+ headers: { "Content-Type": "application/json" },
27
+ body: JSON.stringify({ grant_id: grantId })
28
+ });
29
+ if (!response.ok) {
30
+ throw new Error(`Grant verification failed: ${response.status}`);
31
+ }
32
+ return response.json();
33
+ }
34
+ export async function isDelegated(event) {
35
+ const session = await getSpSession(event);
36
+ const claims = session.data.claims;
37
+ if (!claims) return false;
38
+ return typeof claims.act === "object" && claims.act !== null && "sub" in claims.act;
39
+ }
40
+ export async function getActor(event) {
41
+ const session = await getSpSession(event);
42
+ const claims = session.data.claims;
43
+ if (!claims) return null;
44
+ const act = claims.act;
45
+ if (typeof act === "object" && act !== null && "sub" in act) {
46
+ return act.sub;
47
+ }
48
+ return null;
49
+ }
50
+ export async function getSubject(event) {
51
+ const session = await getSpSession(event);
52
+ const claims = session.data.claims;
53
+ if (!claims) return null;
54
+ return claims.sub ?? null;
55
+ }
package/dist/types.d.mts CHANGED
@@ -1,7 +1,3 @@
1
- import type { NuxtModule } from '@nuxt/schema'
1
+ export { default } from './module.mjs'
2
2
 
3
- import type { default as Module } from './module.js'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module.js'
3
+ export { type ManifestConfig, type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openape/nuxt-auth-sp",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.1",
5
5
  "description": "OpenAPE Service Provider Nuxt module — adds OIDC login via DNS-based IdP discovery",
6
6
  "author": "Delta Mind GmbH",
7
7
  "license": "AGPL-3.0-or-later",
@@ -33,9 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@nuxt/kit": "^3.21.1",
36
- "@openape/auth": "^0.1.3",
37
- "@openape/core": "^0.1.2",
38
- "@openape/nuxt-auth-sp": "0.3.0",
36
+ "@openape/auth": "^0.2.0",
37
+ "@openape/core": "^0.2.0",
39
38
  "defu": "^6.1.4"
40
39
  },
41
40
  "peerDependencies": {
@@ -44,12 +43,15 @@
44
43
  "devDependencies": {
45
44
  "@antfu/eslint-config": "^7.6.1",
46
45
  "@changesets/cli": "^2.30.0",
47
- "@nuxt/module-builder": "^0.8.4",
46
+ "@nuxt/module-builder": "^1.0.2",
47
+ "@nuxt/ui": "^4.5.1",
48
48
  "@types/node": "^22.19.13",
49
49
  "eslint": "^9.39.3",
50
50
  "nuxt": "^4.3.1",
51
+ "tailwindcss": "^4.2.1",
51
52
  "typescript": "^5.9.3",
52
53
  "vitest": "^3.2.4",
54
+ "vue": "^3.5.30",
53
55
  "vue-tsc": "^3.2.5"
54
56
  },
55
57
  "engines": {
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- spId: string;
5
- spName: string;
6
- sessionSecret: string;
7
- openapeUrl: string;
8
- fallbackIdpUrl: string;
9
- routes: boolean;
10
- }
11
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
-
13
- export { _default as default };
14
- export type { ModuleOptions };
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module'