@alien_org/auth-client 0.0.7-beta

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 ADDED
@@ -0,0 +1,51 @@
1
+ # @alien_org/auth-client
2
+
3
+ Core authentication utilities for the Alien Miniapp SDK. This package provides tools for verifying JWT tokens issued by the Alien SSO.
4
+
5
+ Use it in your miniapp backend to verify tokens sent by miniapp.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ bun add @alien_org/auth-client
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Verifying Tokens
16
+
17
+ Use `createAuthClient` to verify JWT access tokens from Alien SSO.
18
+
19
+ ```typescript
20
+ import { createAuthClient } from '@alien_org/auth-client';
21
+
22
+
23
+ const client = createAuthClient();
24
+
25
+ try {
26
+ const tokenInfo = await client.verifyToken(accessToken);
27
+ console.log('Session address:', tokenInfo.sub);
28
+ } catch (error) {
29
+ console.error('Invalid token:', error);
30
+ }
31
+ ```
32
+
33
+ ### Custom JWKS URL
34
+
35
+ `createAuthClient` accepts an optional jwksUrl parameter to use custom JWKS endpoint for JWT verification.
36
+
37
+ ```typescript
38
+ import { createAuthClient } from '@alien_org/core';
39
+
40
+
41
+ const client = createAuthClient({
42
+ jwksUrl: "https://sso.alien-api.com/.well-known/jwks.json"
43
+ });
44
+
45
+ try {
46
+ const tokenInfo = await client.verifyToken(accessToken);
47
+ console.log('Session address:', tokenInfo.sub);
48
+ } catch (error) {
49
+ console.error('Invalid token:', error);
50
+ }
51
+ ```