@artatol-acp/auth-nextjs 0.1.0 → 0.1.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 CHANGED
@@ -194,7 +194,8 @@ NEXT_PUBLIC_ACP_AUTH_URL=https://sso.artatol.com
194
194
  ### Server Functions
195
195
 
196
196
  - `initACPAuth(options)` - Initialize the auth client
197
- - `getUser()` - Get current user from access token
197
+ - `getUser()` - Get current user from access token (verifies locally without API call)
198
+ - `me()` - Get current user from API (validates token with auth service)
198
199
  - `verifyAccessToken(token)` - Verify and decode access token
199
200
  - `refreshAccessToken()` - Refresh access token using refresh token cookie
200
201
  - `login(email, password)` - Login user
@@ -10,5 +10,6 @@ export declare function refreshAccessToken(): Promise<string | null>;
10
10
  export declare function login(email: string, password: string): Promise<LoginResult>;
11
11
  export declare function logout(): Promise<void>;
12
12
  export declare function register(email: string, password: string): Promise<User>;
13
+ export declare function me(): Promise<User | null>;
13
14
  export { ACPAuthClient } from '@artatol-acp/auth-js';
14
15
  export type * from '@artatol-acp/auth-js';
@@ -103,5 +103,19 @@ export async function register(email, password) {
103
103
  const client = getClient();
104
104
  return await client.register({ email, password });
105
105
  }
106
+ export async function me() {
107
+ const cookieStore = await cookies();
108
+ const accessToken = cookieStore.get('access_token')?.value;
109
+ if (!accessToken) {
110
+ return null;
111
+ }
112
+ const client = getClient();
113
+ try {
114
+ return await client.me(accessToken);
115
+ }
116
+ catch {
117
+ return null;
118
+ }
119
+ }
106
120
  // Re-export client for direct use if needed
107
121
  export { ACPAuthClient } from '@artatol-acp/auth-js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artatol-acp/auth-nextjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Next.js SDK for Artatol Cloud Platform Authentication",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",