@meistrari/auth-nuxt 1.0.0-beta.1 → 1.0.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 +72 -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,28 @@ await signOut(() => {
|
|
|
90
90
|
**Email and Password:**
|
|
91
91
|
```typescript
|
|
92
92
|
await signInWithEmailAndPassword({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
email: 'user@example.com',
|
|
94
|
+
password: 'secure-password',
|
|
95
|
+
callbackURL: '/dashboard',
|
|
96
|
+
errorCallbackURL: '/login?error=true'
|
|
97
97
|
})
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
**Social Authentication:**
|
|
101
101
|
```typescript
|
|
102
102
|
await signInWithSocialProvider({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
provider: 'google', // or 'microsoft'
|
|
104
|
+
callbackURL: '/dashboard',
|
|
105
|
+
errorCallbackURL: '/login?error=true'
|
|
106
106
|
})
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
**SAML SSO:**
|
|
110
110
|
```typescript
|
|
111
111
|
await signInWithSaml({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
email: 'user@example.com',
|
|
113
|
+
callbackURL: '/dashboard',
|
|
114
|
+
errorCallbackURL: '/login?error=true'
|
|
115
115
|
})
|
|
116
116
|
```
|
|
117
117
|
|
|
@@ -181,19 +181,19 @@ await inviteUserToOrganization({
|
|
|
181
181
|
**Update Organization:**
|
|
182
182
|
```typescript
|
|
183
183
|
await updateOrganization({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
name: 'New Organization Name',
|
|
185
|
+
logo: 'https://example.com/logo.png',
|
|
186
|
+
settings: { /* custom settings */ }
|
|
187
187
|
})
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
**Invite Member:**
|
|
191
191
|
```typescript
|
|
192
192
|
await inviteUserToOrganization({
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
userEmail: 'user@example.com',
|
|
194
|
+
role: 'admin', // or 'member', 'reviewer'
|
|
195
|
+
teamId: 'team-id', // optional
|
|
196
|
+
resend: false // optional: resend if invitation exists
|
|
197
197
|
})
|
|
198
198
|
```
|
|
199
199
|
|
|
@@ -201,7 +201,7 @@ await inviteUserToOrganization({
|
|
|
201
201
|
```typescript
|
|
202
202
|
// Create team
|
|
203
203
|
const team = await createTeam({
|
|
204
|
-
|
|
204
|
+
name: 'Development Team'
|
|
205
205
|
})
|
|
206
206
|
|
|
207
207
|
// Add member to team
|
|
@@ -263,20 +263,20 @@ The SDK automatically sets up server-side authentication context for API routes.
|
|
|
263
263
|
```typescript
|
|
264
264
|
// server/api/protected.ts
|
|
265
265
|
export default defineEventHandler(async (event) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
266
|
+
// Authentication context is automatically available
|
|
267
|
+
const { user, workspace } = event.context.auth
|
|
268
|
+
|
|
269
|
+
if (!user) {
|
|
270
|
+
throw createError({
|
|
271
|
+
statusCode: 401,
|
|
272
|
+
statusMessage: 'Unauthorized'
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
message: `Hello, ${user.email}!`,
|
|
278
|
+
userId: user.id
|
|
279
|
+
}
|
|
280
280
|
})
|
|
281
281
|
```
|
|
282
282
|
|
|
@@ -289,13 +289,13 @@ Create custom server middleware using the provided helper:
|
|
|
289
289
|
import { meistrariAuthMiddleware } from '@meistrari/auth-nuxt/server/middleware/auth'
|
|
290
290
|
|
|
291
291
|
export default meistrariAuthMiddleware(async (event) => {
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
// event.context.auth contains user and workspace
|
|
293
|
+
const { user, workspace } = event.context.auth
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
// Your custom logic here
|
|
296
|
+
if (user) {
|
|
297
|
+
console.log(`Authenticated user: ${user.email}`)
|
|
298
|
+
}
|
|
299
299
|
})
|
|
300
300
|
```
|
|
301
301
|
|
|
@@ -305,23 +305,23 @@ The SDK exports comprehensive TypeScript types from the core package:
|
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
307
|
import type {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
308
|
+
User,
|
|
309
|
+
Session,
|
|
310
|
+
Organization,
|
|
311
|
+
FullOrganization,
|
|
312
|
+
Member,
|
|
313
|
+
Invitation,
|
|
314
|
+
Team,
|
|
315
|
+
TeamMember,
|
|
316
|
+
ApiKey,
|
|
317
|
+
CreateApiKeyPayload,
|
|
318
|
+
UpdateApiKeyPayload,
|
|
319
|
+
CreateTeamPayload,
|
|
320
|
+
UpdateTeamPayload,
|
|
321
|
+
InviteUserToOrganizationOptions,
|
|
322
|
+
RemoveUserFromOrganizationOptions,
|
|
323
|
+
UpdateMemberRoleOptions,
|
|
324
|
+
UpdateOrganizationPayload
|
|
325
325
|
} from '@meistrari/auth-nuxt/core'
|
|
326
326
|
```
|
|
327
327
|
|
|
@@ -361,7 +361,7 @@ import { isTokenExpired, validateToken, extractTokenPayload } from '@meistrari/a
|
|
|
361
361
|
|
|
362
362
|
// Check if token is expired
|
|
363
363
|
if (isTokenExpired(jwtToken)) {
|
|
364
|
-
|
|
364
|
+
// Token needs refresh
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// Validate token against JWKS endpoint
|
|
@@ -393,15 +393,16 @@ The SDK handles common authentication errors automatically:
|
|
|
393
393
|
import { APIError } from '@meistrari/auth-nuxt/core'
|
|
394
394
|
|
|
395
395
|
try {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
396
|
+
await signInWithEmailAndPassword({
|
|
397
|
+
email: 'user@example.com',
|
|
398
|
+
password: 'wrong-password',
|
|
399
|
+
callbackURL: '/dashboard'
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
if (error instanceof APIError) {
|
|
404
|
+
console.error('Authentication failed:', error.message, error.status)
|
|
405
|
+
}
|
|
405
406
|
}
|
|
406
407
|
```
|
|
407
408
|
|
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.0",
|
|
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
|
}
|