@meistrari/auth-nuxt 1.0.0-beta.1 → 1.0.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/README.md +69 -71
- package/dist/module.json +1 -1
- package/dist/runtime/composables/api-key.d.ts +35 -8
- package/dist/runtime/composables/organization.d.ts +108 -21
- package/dist/runtime/composables/session.d.ts +58 -13
- package/dist/runtime/composables/session.js +1 -1
- package/dist/runtime/server/types/h3.d.ts +11 -11
- package/dist/runtime/shared.js +1 -1
- package/package.json +49 -49
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ Add the module to your `nuxt.config.ts`:
|
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
export default defineNuxtConfig({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
modules: ['@meistrari/auth-nuxt'],
|
|
18
|
+
telaAuth: {
|
|
19
|
+
apiUrl: 'https://your-auth-api.com',
|
|
20
|
+
jwtCookieName: 'tela-jwt', // Optional: custom JWT cookie name
|
|
21
|
+
skipServerMiddleware: false, // Optional: skip automatic server middleware
|
|
22
|
+
}
|
|
23
23
|
})
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -90,28 +90,26 @@ await signOut(() => {
|
|
|
90
90
|
**Email and Password:**
|
|
91
91
|
```typescript
|
|
92
92
|
await signInWithEmailAndPassword({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
callbackURL: '/dashboard',
|
|
96
|
-
errorCallbackURL: '/login?error=true'
|
|
93
|
+
email: 'user@example.com',
|
|
94
|
+
password: 'secure-password',
|
|
97
95
|
})
|
|
98
96
|
```
|
|
99
97
|
|
|
100
98
|
**Social Authentication:**
|
|
101
99
|
```typescript
|
|
102
100
|
await signInWithSocialProvider({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
provider: 'google', // or 'microsoft'
|
|
102
|
+
callbackURL: '/dashboard',
|
|
103
|
+
errorCallbackURL: '/login?error=true'
|
|
106
104
|
})
|
|
107
105
|
```
|
|
108
106
|
|
|
109
107
|
**SAML SSO:**
|
|
110
108
|
```typescript
|
|
111
109
|
await signInWithSaml({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
email: 'user@example.com',
|
|
111
|
+
callbackURL: '/dashboard',
|
|
112
|
+
errorCallbackURL: '/login?error=true'
|
|
115
113
|
})
|
|
116
114
|
```
|
|
117
115
|
|
|
@@ -181,19 +179,19 @@ await inviteUserToOrganization({
|
|
|
181
179
|
**Update Organization:**
|
|
182
180
|
```typescript
|
|
183
181
|
await updateOrganization({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
name: 'New Organization Name',
|
|
183
|
+
logo: 'https://example.com/logo.png',
|
|
184
|
+
settings: { /* custom settings */ }
|
|
187
185
|
})
|
|
188
186
|
```
|
|
189
187
|
|
|
190
188
|
**Invite Member:**
|
|
191
189
|
```typescript
|
|
192
190
|
await inviteUserToOrganization({
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
userEmail: 'user@example.com',
|
|
192
|
+
role: 'admin', // or 'member', 'reviewer'
|
|
193
|
+
teamId: 'team-id', // optional
|
|
194
|
+
resend: false // optional: resend if invitation exists
|
|
197
195
|
})
|
|
198
196
|
```
|
|
199
197
|
|
|
@@ -201,7 +199,7 @@ await inviteUserToOrganization({
|
|
|
201
199
|
```typescript
|
|
202
200
|
// Create team
|
|
203
201
|
const team = await createTeam({
|
|
204
|
-
|
|
202
|
+
name: 'Development Team'
|
|
205
203
|
})
|
|
206
204
|
|
|
207
205
|
// Add member to team
|
|
@@ -263,20 +261,20 @@ The SDK automatically sets up server-side authentication context for API routes.
|
|
|
263
261
|
```typescript
|
|
264
262
|
// server/api/protected.ts
|
|
265
263
|
export default defineEventHandler(async (event) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
264
|
+
// Authentication context is automatically available
|
|
265
|
+
const { user, workspace } = event.context.auth
|
|
266
|
+
|
|
267
|
+
if (!user) {
|
|
268
|
+
throw createError({
|
|
269
|
+
statusCode: 401,
|
|
270
|
+
statusMessage: 'Unauthorized'
|
|
271
|
+
})
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
message: `Hello, ${user.email}!`,
|
|
276
|
+
userId: user.id
|
|
277
|
+
}
|
|
280
278
|
})
|
|
281
279
|
```
|
|
282
280
|
|
|
@@ -289,13 +287,13 @@ Create custom server middleware using the provided helper:
|
|
|
289
287
|
import { meistrariAuthMiddleware } from '@meistrari/auth-nuxt/server/middleware/auth'
|
|
290
288
|
|
|
291
289
|
export default meistrariAuthMiddleware(async (event) => {
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
// event.context.auth contains user and workspace
|
|
291
|
+
const { user, workspace } = event.context.auth
|
|
294
292
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
// Your custom logic here
|
|
294
|
+
if (user) {
|
|
295
|
+
console.log(`Authenticated user: ${user.email}`)
|
|
296
|
+
}
|
|
299
297
|
})
|
|
300
298
|
```
|
|
301
299
|
|
|
@@ -305,23 +303,23 @@ The SDK exports comprehensive TypeScript types from the core package:
|
|
|
305
303
|
|
|
306
304
|
```typescript
|
|
307
305
|
import type {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
306
|
+
User,
|
|
307
|
+
Session,
|
|
308
|
+
Organization,
|
|
309
|
+
FullOrganization,
|
|
310
|
+
Member,
|
|
311
|
+
Invitation,
|
|
312
|
+
Team,
|
|
313
|
+
TeamMember,
|
|
314
|
+
ApiKey,
|
|
315
|
+
CreateApiKeyPayload,
|
|
316
|
+
UpdateApiKeyPayload,
|
|
317
|
+
CreateTeamPayload,
|
|
318
|
+
UpdateTeamPayload,
|
|
319
|
+
InviteUserToOrganizationOptions,
|
|
320
|
+
RemoveUserFromOrganizationOptions,
|
|
321
|
+
UpdateMemberRoleOptions,
|
|
322
|
+
UpdateOrganizationPayload
|
|
325
323
|
} from '@meistrari/auth-nuxt/core'
|
|
326
324
|
```
|
|
327
325
|
|
|
@@ -361,7 +359,7 @@ import { isTokenExpired, validateToken, extractTokenPayload } from '@meistrari/a
|
|
|
361
359
|
|
|
362
360
|
// Check if token is expired
|
|
363
361
|
if (isTokenExpired(jwtToken)) {
|
|
364
|
-
|
|
362
|
+
// Token needs refresh
|
|
365
363
|
}
|
|
366
364
|
|
|
367
365
|
// Validate token against JWKS endpoint
|
|
@@ -393,15 +391,15 @@ The SDK handles common authentication errors automatically:
|
|
|
393
391
|
import { APIError } from '@meistrari/auth-nuxt/core'
|
|
394
392
|
|
|
395
393
|
try {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
394
|
+
await signInWithEmailAndPassword({
|
|
395
|
+
email: 'user@example.com',
|
|
396
|
+
password: 'wrong-password',
|
|
397
|
+
})
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
if (error instanceof APIError) {
|
|
401
|
+
console.error('Authentication failed:', error.message, error.status)
|
|
402
|
+
}
|
|
405
403
|
}
|
|
406
404
|
```
|
|
407
405
|
|
package/dist/module.json
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createNuxtAuthClient } from '../shared.js';
|
|
2
|
+
type AuthClient = ReturnType<typeof createNuxtAuthClient>;
|
|
3
|
+
type ApiKeyClient = AuthClient['apiKey'];
|
|
4
|
+
export interface UseTelaApiKey {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new API key.
|
|
7
|
+
* @param payload - API key configuration
|
|
8
|
+
* @returns The created API key with the secret (only shown once)
|
|
9
|
+
*/
|
|
10
|
+
createApiKey: ApiKeyClient['createApiKey'];
|
|
11
|
+
/**
|
|
12
|
+
* Updates an existing API key.
|
|
13
|
+
* @param payload - Fields to update
|
|
14
|
+
* @returns The updated API key
|
|
15
|
+
*/
|
|
16
|
+
updateApiKey: ApiKeyClient['updateApiKey'];
|
|
17
|
+
/**
|
|
18
|
+
* Deletes an existing API key.
|
|
19
|
+
* @param id - The ID of the API key to delete
|
|
20
|
+
*/
|
|
21
|
+
deleteApiKey: ApiKeyClient['deleteApiKey'];
|
|
22
|
+
/**
|
|
23
|
+
* Lists all API keys of the current user.
|
|
24
|
+
* @returns A list of API keys
|
|
25
|
+
*/
|
|
26
|
+
listApiKeys: ApiKeyClient['listApiKeys'];
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves an existing API key.
|
|
29
|
+
* @param id - The ID of the API key to retrieve
|
|
30
|
+
* @returns The API key
|
|
31
|
+
*/
|
|
32
|
+
getApiKey: ApiKeyClient['getApiKey'];
|
|
33
|
+
}
|
|
2
34
|
/**
|
|
3
35
|
* Composable for managing API keys.
|
|
4
36
|
*
|
|
5
37
|
* @returns An object containing API key management functions.
|
|
6
38
|
*/
|
|
7
|
-
export declare function useTelaApiKey():
|
|
8
|
-
|
|
9
|
-
updateApiKey: (payload: UpdateApiKeyPayload) => Promise<any>;
|
|
10
|
-
deleteApiKey: (id: string) => Promise<any>;
|
|
11
|
-
listApiKeys: () => Promise<any>;
|
|
12
|
-
getApiKey: (id: string) => Promise<any>;
|
|
13
|
-
};
|
|
39
|
+
export declare function useTelaApiKey(): UseTelaApiKey;
|
|
40
|
+
export {};
|
|
@@ -1,28 +1,115 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, ListMembersOptions, Member, RemoveUserFromOrganizationOptions, Team, TeamMember, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload } from '@meistrari/auth-core';
|
|
3
|
+
import { type FullOrganizationWithRelations } from './state.js';
|
|
4
|
+
export interface UseTelaOrganizationReturn {
|
|
5
|
+
/** Reactive reference to the active organization with members, invitations, and teams. */
|
|
6
|
+
activeOrganization: Ref<FullOrganizationWithRelations | null>;
|
|
7
|
+
/** Reactive reference to the current user's membership in the active organization. */
|
|
8
|
+
activeMember: Ref<Member | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the active organization for the current user session and updates the active organization state.
|
|
11
|
+
* @returns The active organization with members, invitations, and teams
|
|
12
|
+
*/
|
|
13
|
+
getActiveOrganization: () => Promise<FullOrganizationWithRelations | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Lists all organizations for the current user session.
|
|
16
|
+
* @returns A list of organizations
|
|
17
|
+
*/
|
|
18
|
+
listOrganizations: () => Promise<FullOrganization[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the active organization for the current user session and updates the active organization state.
|
|
21
|
+
* @param id - The ID of the organization to set as active
|
|
22
|
+
*/
|
|
12
23
|
setActiveOrganization: (id: string) => Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Updates the active organization for the current user session and updates the active organization state.
|
|
26
|
+
* @param payload - The organization fields to update
|
|
27
|
+
* @returns The updated organization
|
|
28
|
+
*/
|
|
29
|
+
updateOrganization: (payload: UpdateOrganizationPayload) => Promise<FullOrganization>;
|
|
30
|
+
/**
|
|
31
|
+
* Lists the members of the active organization.
|
|
32
|
+
* @param options - Pagination options
|
|
33
|
+
* @returns A list of members
|
|
34
|
+
*/
|
|
35
|
+
listMembers: (options?: ListMembersOptions) => Promise<Member[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the active member of the current user session.
|
|
38
|
+
* @returns The active member
|
|
39
|
+
*/
|
|
40
|
+
getActiveMember: () => Promise<Member>;
|
|
41
|
+
/**
|
|
42
|
+
* Invites a user to the active organization.
|
|
43
|
+
* @param options - Invitation configuration
|
|
44
|
+
* @returns The invitation
|
|
45
|
+
*/
|
|
46
|
+
inviteUserToOrganization: (options: InviteUserToOrganizationOptions) => Promise<Invitation>;
|
|
47
|
+
/**
|
|
48
|
+
* Accepts an organization invitation and updates the active organization state.
|
|
49
|
+
* @param id - The invitation ID to accept
|
|
50
|
+
*/
|
|
17
51
|
acceptInvitation: (id: string) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Cancels a pending organization invitation and updates the active organization state.
|
|
54
|
+
* @param id - The invitation ID to cancel
|
|
55
|
+
*/
|
|
18
56
|
cancelInvitation: (id: string) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Removes a user from the active organization.
|
|
59
|
+
* @param options - User identifier (either memberId or userEmail must be provided)
|
|
60
|
+
*/
|
|
19
61
|
removeUserFromOrganization: (options: RemoveUserFromOrganizationOptions) => Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Updates the role of an organization member.
|
|
64
|
+
* @param options - Role update configuration
|
|
65
|
+
*/
|
|
20
66
|
updateMemberRole: (options: UpdateMemberRoleOptions) => Promise<void>;
|
|
21
|
-
|
|
22
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new team within the active organization.
|
|
69
|
+
* @param payload - Team configuration
|
|
70
|
+
* @returns The created team
|
|
71
|
+
*/
|
|
72
|
+
createTeam: (payload: CreateTeamPayload) => Promise<Team>;
|
|
73
|
+
/**
|
|
74
|
+
* Updates an existing team's details.
|
|
75
|
+
* @param id - The team ID to update
|
|
76
|
+
* @param payload - Team fields to update
|
|
77
|
+
* @returns The updated team
|
|
78
|
+
*/
|
|
79
|
+
updateTeam: (id: string, payload: UpdateTeamPayload) => Promise<Team>;
|
|
80
|
+
/**
|
|
81
|
+
* Deletes a team from the active organization.
|
|
82
|
+
* @param id - The team ID to delete
|
|
83
|
+
*/
|
|
23
84
|
deleteTeam: (id: string) => Promise<void>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Lists all teams in the active organization.
|
|
87
|
+
* @returns An array of teams
|
|
88
|
+
*/
|
|
89
|
+
listTeams: () => Promise<Team[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Lists all members of a specific team.
|
|
92
|
+
* @param id - The team ID
|
|
93
|
+
* @returns An array of team members
|
|
94
|
+
*/
|
|
95
|
+
listTeamMembers: (id: string) => Promise<TeamMember[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Adds a user to a team.
|
|
98
|
+
* @param teamId - The team ID
|
|
99
|
+
* @param userId - The user ID to add
|
|
100
|
+
* @returns The added team member
|
|
101
|
+
*/
|
|
102
|
+
addTeamMember: (teamId: string, userId: string) => Promise<TeamMember>;
|
|
103
|
+
/**
|
|
104
|
+
* Removes a user from a team.
|
|
105
|
+
* @param teamId - The team ID
|
|
106
|
+
* @param userId - The user ID to remove
|
|
107
|
+
*/
|
|
27
108
|
removeTeamMember: (teamId: string, userId: string) => Promise<void>;
|
|
28
|
-
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Composable for managing organizations and their members, invitations, and teams.
|
|
112
|
+
*
|
|
113
|
+
* @returns An object containing organization management functions and the active organization and member states.
|
|
114
|
+
*/
|
|
115
|
+
export declare function useTelaOrganization(): UseTelaOrganizationReturn;
|
|
@@ -1,18 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, User } from '@meistrari/auth-core';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
export interface UseTelaSessionReturn {
|
|
4
|
+
/** Reactive reference to the current user. Null if not authenticated. */
|
|
5
|
+
user: Ref<User | null>;
|
|
6
|
+
/** Reactive reference to the current session. Null if not authenticated. */
|
|
7
|
+
session: Ref<Session | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the current user session.
|
|
10
|
+
* @returns The current user session
|
|
11
|
+
*/
|
|
12
|
+
getSession: () => Promise<{
|
|
13
|
+
user: User;
|
|
14
|
+
session: Session;
|
|
15
|
+
} | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a valid JWT token.
|
|
18
|
+
* @returns The JWT token, or null if not authenticated
|
|
19
|
+
*/
|
|
20
|
+
getToken: () => Promise<string | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Authenticates a user with email and password credentials.
|
|
23
|
+
* @param options - Email/password sign-in configuration
|
|
24
|
+
*/
|
|
25
|
+
signInWithEmailAndPassword: (options: SignInWithEmailAndPasswordOptions) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Initiates social authentication flow with Google or Microsoft.
|
|
28
|
+
* @param options - Social sign-in configuration
|
|
29
|
+
* @throws {InvalidSocialProvider} When the provider is not 'google' or 'microsoft'
|
|
30
|
+
* @throws {InvalidCallbackURL} When callback URLs are malformed
|
|
31
|
+
*/
|
|
32
|
+
signInWithSocialProvider: (options: SocialSignInOptions) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Initiates SAML-based Single Sign-On authentication flow.
|
|
35
|
+
* @param options - SAML sign-in configuration
|
|
36
|
+
* @throws {EmailRequired} When email is not provided
|
|
37
|
+
* @throws {InvalidCallbackURL} When callback URLs are malformed
|
|
38
|
+
*/
|
|
39
|
+
signInWithSaml: (options: SignInWithSamlOptions) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Signs out the currently authenticated user.
|
|
42
|
+
* @param callback - Optional callback function to execute after signing out
|
|
43
|
+
*/
|
|
44
|
+
signOut: (callback?: (() => void) | (() => Promise<void>)) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Initiates a password reset request by sending a reset email.
|
|
47
|
+
* @param email - Email address of the user requesting password reset
|
|
48
|
+
* @param callbackURL - URL where the user will be redirected to complete the reset
|
|
49
|
+
*/
|
|
50
|
+
requestPasswordReset: (email: string, callbackURL: string) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Completes the password reset process with a reset token and new password.
|
|
53
|
+
* @param token - The password reset token from the email
|
|
54
|
+
* @param password - The new password to set
|
|
55
|
+
*/
|
|
56
|
+
resetPassword: (token: string, password: string) => Promise<void>;
|
|
57
|
+
}
|
|
2
58
|
/**
|
|
3
59
|
* Composable for managing user sessions and authentication.
|
|
4
60
|
*
|
|
5
61
|
* @returns An object containing session management functions and the user and session states.
|
|
6
62
|
*/
|
|
7
|
-
export declare function useTelaSession():
|
|
8
|
-
user: import("vue").Ref<any, any>;
|
|
9
|
-
session: import("vue").Ref<any, any>;
|
|
10
|
-
getSession: () => Promise<any>;
|
|
11
|
-
getToken: () => Promise<any>;
|
|
12
|
-
signInWithEmailAndPassword: ({ email, password, callbackURL, errorCallbackURL, }: SignInWithEmailAndPasswordOptions) => Promise<void>;
|
|
13
|
-
signInWithSocialProvider: ({ provider, callbackURL, errorCallbackURL, }: SocialSignInOptions) => Promise<void>;
|
|
14
|
-
signInWithSaml: ({ email, callbackURL, errorCallbackURL, }: SignInWithSamlOptions) => Promise<void>;
|
|
15
|
-
signOut: (callback?: (() => void) | (() => Promise<void>)) => Promise<void>;
|
|
16
|
-
requestPasswordReset: (email: string, callbackURL: string) => Promise<void>;
|
|
17
|
-
resetPassword: (token: string, password: string) => Promise<void>;
|
|
18
|
-
};
|
|
63
|
+
export declare function useTelaSession(): UseTelaSessionReturn;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCookie, useRuntimeConfig } from "#app";
|
|
2
2
|
import { APIError } from "@meistrari/auth-core";
|
|
3
3
|
import { createNuxtAuthClient } from "../shared.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useOrganizationState, useSessionState } from "./state.js";
|
|
5
5
|
export function useTelaSession() {
|
|
6
6
|
const { user, session } = useSessionState();
|
|
7
7
|
const { jwtCookieName, apiUrl } = useRuntimeConfig().public.telaAuth;
|
|
@@ -2,21 +2,21 @@ import type { JWTTokenPayload } from '@meistrari/auth-core'
|
|
|
2
2
|
import type { H3Event, H3EventContext } from 'h3'
|
|
3
3
|
|
|
4
4
|
declare module 'h3' {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface H3EventContext {
|
|
6
|
+
auth?: {
|
|
7
|
+
user: { email: string } & JWTTokenPayload['user'] | null
|
|
8
|
+
workspace: JWTTokenPayload['workspace'] | null
|
|
9
|
+
}
|
|
9
10
|
}
|
|
10
|
-
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface AuthenticatedH3EventContext extends H3EventContext {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
auth: {
|
|
15
|
+
user: { email: string } & JWTTokenPayload['user'] | null
|
|
16
|
+
workspace: JWTTokenPayload['workspace'] | null
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface AuthenticatedH3Event extends H3Event {
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
context: AuthenticatedH3EventContext
|
|
22
|
+
}
|
package/dist/runtime/shared.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthClient } from "@meistrari/auth-core";
|
|
2
|
-
|
|
2
|
+
const version = "__PACKAGE_VERSION__";
|
|
3
3
|
export function createNuxtAuthClient(apiUrl, getAuthToken) {
|
|
4
4
|
const serviceName = typeof process !== "undefined" ? process.env.SERVICE_NAME : "";
|
|
5
5
|
const userAgent = `auth-sdk:nuxt:${version}${serviceName ? `@${serviceName}` : ""}`;
|
package/package.json
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
"./server/middleware/auth": {
|
|
11
|
-
"types": "./dist/runtime/server/middleware/auth.d.ts",
|
|
12
|
-
"import": "./dist/runtime/server/middleware/auth.js"
|
|
13
|
-
},
|
|
14
|
-
"./core": {
|
|
15
|
-
"types": "./dist/core.d.mts",
|
|
16
|
-
"import": "./dist/core.mjs"
|
|
17
|
-
}
|
|
2
|
+
"name": "@meistrari/auth-nuxt",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/types.d.mts",
|
|
8
|
+
"import": "./dist/module.mjs"
|
|
18
9
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
".": [
|
|
23
|
-
"./dist/types.d.mts"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
10
|
+
"./server/middleware/auth": {
|
|
11
|
+
"types": "./dist/runtime/server/middleware/auth.d.ts",
|
|
12
|
+
"import": "./dist/runtime/server/middleware/auth.js"
|
|
26
13
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@nuxt/devtools": "2.6.3",
|
|
41
|
-
"@nuxt/eslint-config": "1.9.0",
|
|
42
|
-
"@nuxt/kit": "4.0.3",
|
|
43
|
-
"@nuxt/module-builder": "1.0.2",
|
|
44
|
-
"@nuxt/schema": "4.0.3",
|
|
45
|
-
"@nuxt/test-utils": "3.19.2",
|
|
46
|
-
"@types/node": "latest",
|
|
47
|
-
"changelogen": "0.6.2",
|
|
48
|
-
"nuxt": "4.0.3",
|
|
49
|
-
"typescript": "5.9.2",
|
|
50
|
-
"unbuild": "3.6.1",
|
|
51
|
-
"vitest": "3.2.4",
|
|
52
|
-
"vue-tsc": "3.0.6"
|
|
14
|
+
"./core": {
|
|
15
|
+
"types": "./dist/core.d.mts",
|
|
16
|
+
"import": "./dist/core.mjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/module.mjs",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
".": [
|
|
23
|
+
"./dist/types.d.mts"
|
|
24
|
+
]
|
|
53
25
|
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@meistrari/auth-core": "1.4.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"nuxt": "^3.0.0 || ^4.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@nuxt/devtools": "2.6.3",
|
|
41
|
+
"@nuxt/eslint-config": "1.9.0",
|
|
42
|
+
"@nuxt/kit": "4.0.3",
|
|
43
|
+
"@nuxt/module-builder": "1.0.2",
|
|
44
|
+
"@nuxt/schema": "4.0.3",
|
|
45
|
+
"@nuxt/test-utils": "3.19.2",
|
|
46
|
+
"@types/node": "latest",
|
|
47
|
+
"changelogen": "0.6.2",
|
|
48
|
+
"nuxt": "4.0.3",
|
|
49
|
+
"typescript": "5.9.2",
|
|
50
|
+
"unbuild": "3.6.1",
|
|
51
|
+
"vitest": "3.2.4",
|
|
52
|
+
"vue-tsc": "3.0.6"
|
|
53
|
+
}
|
|
54
54
|
}
|