@squadbase/server 0.0.1-beta.4 → 0.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 ADDED
@@ -0,0 +1,89 @@
1
+ # @squadbase/server
2
+
3
+ Server Side JavaScript SDK for Squadbase - A package for handling server-side operations in Squadbase applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @squadbase/server
9
+ # or
10
+ yarn add @squadbase/server
11
+ # or
12
+ pnpm add @squadbase/server
13
+ ```
14
+
15
+ ## Features
16
+
17
+ ### User Session
18
+
19
+ ```typescript
20
+ import { createServerClient } from "@squadbase/server";
21
+
22
+ const client = createServerClient({
23
+ projectId: "your-project-id",
24
+ cookieOptions: {
25
+ getCookie: () => {
26
+ // Implement your cookie retrieval logic here
27
+ // This should return the session cookie string
28
+ },
29
+ },
30
+ });
31
+
32
+ // Get the current authenticated user
33
+ const user = await client.getUser();
34
+ console.log(user);
35
+ // {
36
+ // username: string,
37
+ // email: string,
38
+ // firstName: string,
39
+ // lastName: string,
40
+ // iconUrl: string | null,
41
+ // roles: string[]
42
+ // }
43
+ ```
44
+
45
+ ### Local Development
46
+
47
+ For local development, you can provide a mock user:
48
+
49
+ ```typescript
50
+ const client = createServerClient({
51
+ projectId: "your-project-id",
52
+ cookieOptions: {
53
+ getCookie: () => undefined,
54
+ },
55
+ mockUser: {
56
+ username: "test-user",
57
+ email: "test@example.com",
58
+ firstName: "Test",
59
+ lastName: "User",
60
+ iconUrl: null,
61
+ roles: ["user"],
62
+ },
63
+ });
64
+ ```
65
+
66
+ ## API Reference
67
+
68
+ ### `createServerClient(options: ServerClientOptions)`
69
+
70
+ Creates a new server client instance.
71
+
72
+ #### Options
73
+
74
+ - `projectId` (string): Your Squadbase project ID
75
+ - `cookieOptions` (object):
76
+ - `getCookie`: Function that returns the session cookie string
77
+ - `mockUser` (optional): Mock user object for local development
78
+
79
+ ### `ServerClient`
80
+
81
+ #### Methods
82
+
83
+ - `getUser()`: Returns the current authenticated user
84
+ - Returns: Promise<User>
85
+ - Throws: Error if authentication fails
86
+
87
+ ## License
88
+
89
+ MIT
package/dist/index.cjs CHANGED
@@ -4122,7 +4122,10 @@ var ServerClient = class {
4122
4122
  const request = new Request(
4123
4123
  `https://${this.options.projectId}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4124
4124
  {
4125
- method: "POST"
4125
+ method: "POST",
4126
+ headers: {
4127
+ Authorization: `Bearer ${sessionToken}`
4128
+ }
4126
4129
  }
4127
4130
  );
4128
4131
  const response = await fetch(request);
package/dist/index.js CHANGED
@@ -4096,7 +4096,10 @@ var ServerClient = class {
4096
4096
  const request = new Request(
4097
4097
  `https://${this.options.projectId}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4098
4098
  {
4099
- method: "POST"
4099
+ method: "POST",
4100
+ headers: {
4101
+ Authorization: `Bearer ${sessionToken}`
4102
+ }
4100
4103
  }
4101
4104
  );
4102
4105
  const response = await fetch(request);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squadbase/server",
3
- "version": "0.0.1-beta.4",
4
- "description": "Server SDK for Squadbase",
3
+ "version": "0.0.1",
4
+ "description": "Server-side SDK for Squadbase",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "access": "public"
25
25
  },
26
26
  "keywords": [],
27
- "author": "Atsuki Hasegawa",
28
- "license": "ISC",
27
+ "author": "Squadbase",
28
+ "license": "MIT",
29
29
  "dependencies": {
30
30
  "cookie": "^1.0.2"
31
31
  },