@insforge/sdk 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/dist/index.d.mts +230 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +417 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +385 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var InsForgeError = class _InsForgeError extends Error {
|
|
3
|
+
constructor(message, statusCode, error, nextActions) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "InsForgeError";
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.error = error;
|
|
8
|
+
this.nextActions = nextActions;
|
|
9
|
+
}
|
|
10
|
+
static fromApiError(apiError) {
|
|
11
|
+
return new _InsForgeError(
|
|
12
|
+
apiError.message,
|
|
13
|
+
apiError.statusCode,
|
|
14
|
+
apiError.error,
|
|
15
|
+
apiError.nextActions
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/lib/http-client.ts
|
|
21
|
+
var HttpClient = class {
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.baseUrl = config.url || "http://localhost:7130";
|
|
24
|
+
this.fetch = config.fetch || globalThis.fetch;
|
|
25
|
+
this.defaultHeaders = {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
...config.headers
|
|
28
|
+
};
|
|
29
|
+
if (config.apiKey) {
|
|
30
|
+
this.defaultHeaders["Authorization"] = `Bearer ${config.apiKey}`;
|
|
31
|
+
}
|
|
32
|
+
if (!this.fetch) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Fetch is not available. Please provide a fetch implementation in the config."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
buildUrl(path, params) {
|
|
39
|
+
const url = new URL(path, this.baseUrl);
|
|
40
|
+
if (params) {
|
|
41
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
42
|
+
url.searchParams.append(key, value);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return url.toString();
|
|
46
|
+
}
|
|
47
|
+
async request(method, path, options = {}) {
|
|
48
|
+
const { params, headers = {}, body, ...fetchOptions } = options;
|
|
49
|
+
const url = this.buildUrl(path, params);
|
|
50
|
+
const response = await this.fetch(url, {
|
|
51
|
+
method,
|
|
52
|
+
headers: {
|
|
53
|
+
...this.defaultHeaders,
|
|
54
|
+
...headers
|
|
55
|
+
},
|
|
56
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
57
|
+
...fetchOptions
|
|
58
|
+
});
|
|
59
|
+
if (response.status === 204) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
let data;
|
|
63
|
+
const contentType = response.headers.get("content-type");
|
|
64
|
+
if (contentType?.includes("application/json")) {
|
|
65
|
+
data = await response.json();
|
|
66
|
+
} else {
|
|
67
|
+
data = await response.text();
|
|
68
|
+
}
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
if (data && typeof data === "object" && "error" in data) {
|
|
71
|
+
throw InsForgeError.fromApiError(data);
|
|
72
|
+
}
|
|
73
|
+
throw new InsForgeError(
|
|
74
|
+
`Request failed: ${response.statusText}`,
|
|
75
|
+
response.status,
|
|
76
|
+
"REQUEST_FAILED"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return data;
|
|
80
|
+
}
|
|
81
|
+
get(path, options) {
|
|
82
|
+
return this.request("GET", path, options);
|
|
83
|
+
}
|
|
84
|
+
post(path, body, options) {
|
|
85
|
+
return this.request("POST", path, { ...options, body });
|
|
86
|
+
}
|
|
87
|
+
put(path, body, options) {
|
|
88
|
+
return this.request("PUT", path, { ...options, body });
|
|
89
|
+
}
|
|
90
|
+
patch(path, body, options) {
|
|
91
|
+
return this.request("PATCH", path, { ...options, body });
|
|
92
|
+
}
|
|
93
|
+
delete(path, options) {
|
|
94
|
+
return this.request("DELETE", path, options);
|
|
95
|
+
}
|
|
96
|
+
setAuthToken(token) {
|
|
97
|
+
if (token) {
|
|
98
|
+
this.defaultHeaders["Authorization"] = `Bearer ${token}`;
|
|
99
|
+
} else {
|
|
100
|
+
delete this.defaultHeaders["Authorization"];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/lib/token-manager.ts
|
|
106
|
+
var TOKEN_KEY = "insforge-auth-token";
|
|
107
|
+
var USER_KEY = "insforge-auth-user";
|
|
108
|
+
var TokenManager = class {
|
|
109
|
+
constructor(storage) {
|
|
110
|
+
if (storage) {
|
|
111
|
+
this.storage = storage;
|
|
112
|
+
} else if (typeof window !== "undefined" && window.localStorage) {
|
|
113
|
+
this.storage = window.localStorage;
|
|
114
|
+
} else {
|
|
115
|
+
const store = /* @__PURE__ */ new Map();
|
|
116
|
+
this.storage = {
|
|
117
|
+
getItem: (key) => store.get(key) || null,
|
|
118
|
+
setItem: (key, value) => {
|
|
119
|
+
store.set(key, value);
|
|
120
|
+
},
|
|
121
|
+
removeItem: (key) => {
|
|
122
|
+
store.delete(key);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
saveSession(session) {
|
|
128
|
+
this.storage.setItem(TOKEN_KEY, session.accessToken);
|
|
129
|
+
this.storage.setItem(USER_KEY, JSON.stringify(session.user));
|
|
130
|
+
}
|
|
131
|
+
getSession() {
|
|
132
|
+
const token = this.storage.getItem(TOKEN_KEY);
|
|
133
|
+
const userStr = this.storage.getItem(USER_KEY);
|
|
134
|
+
if (!token || !userStr) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const user = JSON.parse(userStr);
|
|
139
|
+
return { accessToken: token, user };
|
|
140
|
+
} catch {
|
|
141
|
+
this.clearSession();
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
getAccessToken() {
|
|
146
|
+
const token = this.storage.getItem(TOKEN_KEY);
|
|
147
|
+
return typeof token === "string" ? token : null;
|
|
148
|
+
}
|
|
149
|
+
clearSession() {
|
|
150
|
+
this.storage.removeItem(TOKEN_KEY);
|
|
151
|
+
this.storage.removeItem(USER_KEY);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/modules/auth.ts
|
|
156
|
+
var Auth = class {
|
|
157
|
+
constructor(http, tokenManager) {
|
|
158
|
+
this.http = http;
|
|
159
|
+
this.tokenManager = tokenManager;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sign up a new user
|
|
163
|
+
*/
|
|
164
|
+
async signUp(request) {
|
|
165
|
+
try {
|
|
166
|
+
const response = await this.http.post("/api/auth/users", request);
|
|
167
|
+
const session = {
|
|
168
|
+
accessToken: response.accessToken,
|
|
169
|
+
user: response.user
|
|
170
|
+
};
|
|
171
|
+
this.tokenManager.saveSession(session);
|
|
172
|
+
this.http.setAuthToken(response.accessToken);
|
|
173
|
+
return {
|
|
174
|
+
data: {
|
|
175
|
+
user: response.user,
|
|
176
|
+
session
|
|
177
|
+
},
|
|
178
|
+
error: null
|
|
179
|
+
};
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return {
|
|
182
|
+
data: { user: null, session: null },
|
|
183
|
+
error: error instanceof InsForgeError ? error : new InsForgeError(
|
|
184
|
+
"Failed to sign up",
|
|
185
|
+
500,
|
|
186
|
+
"SIGNUP_ERROR"
|
|
187
|
+
)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Sign in with email and password
|
|
193
|
+
*/
|
|
194
|
+
async signInWithPassword(request) {
|
|
195
|
+
try {
|
|
196
|
+
const response = await this.http.post("/api/auth/sessions", request);
|
|
197
|
+
const session = {
|
|
198
|
+
accessToken: response.accessToken,
|
|
199
|
+
user: response.user
|
|
200
|
+
};
|
|
201
|
+
this.tokenManager.saveSession(session);
|
|
202
|
+
this.http.setAuthToken(response.accessToken);
|
|
203
|
+
return {
|
|
204
|
+
data: {
|
|
205
|
+
user: response.user,
|
|
206
|
+
session
|
|
207
|
+
},
|
|
208
|
+
error: null
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
return {
|
|
212
|
+
data: { user: null, session: null },
|
|
213
|
+
error: error instanceof InsForgeError ? error : new InsForgeError(
|
|
214
|
+
"Invalid login credentials",
|
|
215
|
+
401,
|
|
216
|
+
"INVALID_CREDENTIALS"
|
|
217
|
+
)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sign in with OAuth provider
|
|
223
|
+
*/
|
|
224
|
+
async signInWithOAuth(options) {
|
|
225
|
+
try {
|
|
226
|
+
const { provider, redirectTo, skipBrowserRedirect } = options;
|
|
227
|
+
const params = redirectTo ? { redirect_uri: redirectTo } : void 0;
|
|
228
|
+
const endpoint = `/api/auth/oauth/${provider}`;
|
|
229
|
+
const response = await this.http.get(endpoint, { params });
|
|
230
|
+
if (typeof window !== "undefined" && !skipBrowserRedirect) {
|
|
231
|
+
window.location.href = response.authUrl;
|
|
232
|
+
return { data: {}, error: null };
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
data: {
|
|
236
|
+
url: response.authUrl,
|
|
237
|
+
provider
|
|
238
|
+
},
|
|
239
|
+
error: null
|
|
240
|
+
};
|
|
241
|
+
} catch (error) {
|
|
242
|
+
return {
|
|
243
|
+
data: {},
|
|
244
|
+
error: error instanceof InsForgeError ? error : new InsForgeError(
|
|
245
|
+
`Failed to initialize OAuth`,
|
|
246
|
+
500,
|
|
247
|
+
"OAUTH_ERROR"
|
|
248
|
+
)
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Sign out the current user
|
|
254
|
+
*/
|
|
255
|
+
async signOut() {
|
|
256
|
+
try {
|
|
257
|
+
this.tokenManager.clearSession();
|
|
258
|
+
this.http.setAuthToken(null);
|
|
259
|
+
return { error: null };
|
|
260
|
+
} catch (error) {
|
|
261
|
+
return {
|
|
262
|
+
error: new InsForgeError(
|
|
263
|
+
"Failed to sign out",
|
|
264
|
+
500,
|
|
265
|
+
"SIGNOUT_ERROR"
|
|
266
|
+
)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get the current user from the API
|
|
272
|
+
* Returns exactly what the backend returns: {id, email, role}
|
|
273
|
+
*/
|
|
274
|
+
async getCurrentUser() {
|
|
275
|
+
try {
|
|
276
|
+
const session = this.tokenManager.getSession();
|
|
277
|
+
if (!session?.accessToken) {
|
|
278
|
+
return { data: null, error: null };
|
|
279
|
+
}
|
|
280
|
+
this.http.setAuthToken(session.accessToken);
|
|
281
|
+
const response = await this.http.get("/api/auth/sessions/current");
|
|
282
|
+
return {
|
|
283
|
+
data: response,
|
|
284
|
+
error: null
|
|
285
|
+
};
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (error instanceof InsForgeError && error.statusCode === 401) {
|
|
288
|
+
await this.signOut();
|
|
289
|
+
return { data: null, error: null };
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
data: null,
|
|
293
|
+
error: error instanceof InsForgeError ? error : new InsForgeError(
|
|
294
|
+
"Failed to get current user",
|
|
295
|
+
500,
|
|
296
|
+
"GET_USER_ERROR"
|
|
297
|
+
)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get the stored session (no API call)
|
|
303
|
+
*/
|
|
304
|
+
async getSession() {
|
|
305
|
+
try {
|
|
306
|
+
const session = this.tokenManager.getSession();
|
|
307
|
+
if (session?.accessToken) {
|
|
308
|
+
this.http.setAuthToken(session.accessToken);
|
|
309
|
+
return { data: { session }, error: null };
|
|
310
|
+
}
|
|
311
|
+
return { data: { session: null }, error: null };
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return {
|
|
314
|
+
data: { session: null },
|
|
315
|
+
error: error instanceof InsForgeError ? error : new InsForgeError(
|
|
316
|
+
"Failed to get session",
|
|
317
|
+
500,
|
|
318
|
+
"GET_SESSION_ERROR"
|
|
319
|
+
)
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/client.ts
|
|
326
|
+
var InsForgeClient = class {
|
|
327
|
+
constructor(config = {}) {
|
|
328
|
+
this.http = new HttpClient(config);
|
|
329
|
+
this.tokenManager = new TokenManager(config.storage);
|
|
330
|
+
this.auth = new Auth(
|
|
331
|
+
this.http,
|
|
332
|
+
this.tokenManager
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Set a custom API key for authentication
|
|
337
|
+
* This is useful for server-to-server communication
|
|
338
|
+
*
|
|
339
|
+
* @param apiKey - The API key (should start with 'ik_')
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* client.setApiKey('ik_your_api_key_here');
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
setApiKey(apiKey) {
|
|
347
|
+
this.http.setAuthToken(apiKey);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Get the underlying HTTP client for custom requests
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const httpClient = client.getHttpClient();
|
|
355
|
+
* const customData = await httpClient.get('/api/custom-endpoint');
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
getHttpClient() {
|
|
359
|
+
return this.http;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Future modules will be added here:
|
|
363
|
+
* - database: Database operations
|
|
364
|
+
* - storage: File storage operations
|
|
365
|
+
* - functions: Serverless functions
|
|
366
|
+
* - tables: Table management
|
|
367
|
+
* - metadata: Backend metadata
|
|
368
|
+
*/
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/index.ts
|
|
372
|
+
function createClient(config) {
|
|
373
|
+
return new InsForgeClient(config);
|
|
374
|
+
}
|
|
375
|
+
var index_default = InsForgeClient;
|
|
376
|
+
export {
|
|
377
|
+
Auth,
|
|
378
|
+
HttpClient,
|
|
379
|
+
InsForgeClient,
|
|
380
|
+
InsForgeError,
|
|
381
|
+
TokenManager,
|
|
382
|
+
createClient,
|
|
383
|
+
index_default as default
|
|
384
|
+
};
|
|
385
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/lib/http-client.ts","../src/lib/token-manager.ts","../src/modules/auth.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * InsForge SDK Types - only SDK-specific types here\n * Use @insforge/shared-schemas directly for API types\n */\n\nimport type { UserSchema } from '@insforge/shared-schemas';\n\nexport interface InsForgeConfig {\n /**\n * The URL of the InsForge backend API\n * @default \"http://localhost:7130\"\n */\n url?: string;\n\n /**\n * API key (optional)\n * Can be used for server-side operations or specific use cases\n */\n apiKey?: string;\n\n /**\n * Custom fetch implementation (useful for Node.js environments)\n */\n fetch?: typeof fetch;\n\n /**\n * Storage adapter for persisting tokens\n */\n storage?: TokenStorage;\n\n /**\n * Whether to automatically refresh tokens before they expire\n * @default true\n */\n autoRefreshToken?: boolean;\n\n /**\n * Whether to persist session in storage\n * @default true\n */\n persistSession?: boolean;\n\n /**\n * Custom headers to include with every request\n */\n headers?: Record<string, string>;\n}\n\nexport interface TokenStorage {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n}\n\nexport interface AuthSession {\n user: UserSchema;\n accessToken: string;\n expiresAt?: Date;\n}\n\nexport interface ApiError {\n error: string;\n message: string;\n statusCode: number;\n nextActions?: string;\n}\n\nexport class InsForgeError extends Error {\n public statusCode: number;\n public error: string;\n public nextActions?: string;\n\n constructor(message: string, statusCode: number, error: string, nextActions?: string) {\n super(message);\n this.name = 'InsForgeError';\n this.statusCode = statusCode;\n this.error = error;\n this.nextActions = nextActions;\n }\n\n static fromApiError(apiError: ApiError): InsForgeError {\n return new InsForgeError(\n apiError.message,\n apiError.statusCode,\n apiError.error,\n apiError.nextActions\n );\n }\n}","import { InsForgeConfig, ApiError, InsForgeError } from '../types';\n\nexport interface RequestOptions extends RequestInit {\n params?: Record<string, string>;\n}\n\nexport class HttpClient {\n private baseUrl: string;\n private fetch: typeof fetch;\n private defaultHeaders: Record<string, string>;\n\n constructor(config: InsForgeConfig) {\n this.baseUrl = config.url || 'http://localhost:7130';\n this.fetch = config.fetch || globalThis.fetch;\n this.defaultHeaders = {\n 'Content-Type': 'application/json',\n ...config.headers,\n };\n \n // Add API key if provided\n if (config.apiKey) {\n this.defaultHeaders['Authorization'] = `Bearer ${config.apiKey}`;\n }\n\n if (!this.fetch) {\n throw new Error(\n 'Fetch is not available. Please provide a fetch implementation in the config.'\n );\n }\n }\n\n private buildUrl(path: string, params?: Record<string, string>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n return url.toString();\n }\n\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const { params, headers = {}, body, ...fetchOptions } = options;\n \n const url = this.buildUrl(path, params);\n \n const response = await this.fetch(url, {\n method,\n headers: {\n ...this.defaultHeaders,\n ...headers,\n },\n body: body ? JSON.stringify(body) : undefined,\n ...fetchOptions,\n });\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n // Try to parse JSON response\n let data: any;\n const contentType = response.headers.get('content-type');\n if (contentType?.includes('application/json')) {\n data = await response.json();\n } else {\n // For non-JSON responses, return text\n data = await response.text();\n }\n\n // Handle errors\n if (!response.ok) {\n if (data && typeof data === 'object' && 'error' in data) {\n throw InsForgeError.fromApiError(data as ApiError);\n }\n throw new InsForgeError(\n `Request failed: ${response.statusText}`,\n response.status,\n 'REQUEST_FAILED'\n );\n }\n\n return data as T;\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n post<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, { ...options, body });\n }\n\n put<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, { ...options, body });\n }\n\n patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n setAuthToken(token: string | null) {\n if (token) {\n this.defaultHeaders['Authorization'] = `Bearer ${token}`;\n } else {\n delete this.defaultHeaders['Authorization'];\n }\n }\n}","import { TokenStorage, AuthSession } from '../types';\n\nconst TOKEN_KEY = 'insforge-auth-token';\nconst USER_KEY = 'insforge-auth-user';\n\nexport class TokenManager {\n private storage: TokenStorage;\n\n constructor(storage?: TokenStorage) {\n if (storage) {\n // Use provided storage\n this.storage = storage;\n } else if (typeof window !== 'undefined' && window.localStorage) {\n // Browser: use localStorage\n this.storage = window.localStorage;\n } else {\n // Node.js: use in-memory storage\n const store = new Map<string, string>();\n this.storage = {\n getItem: (key: string) => store.get(key) || null,\n setItem: (key: string, value: string) => { store.set(key, value); },\n removeItem: (key: string) => { store.delete(key); }\n };\n }\n }\n\n saveSession(session: AuthSession): void {\n this.storage.setItem(TOKEN_KEY, session.accessToken);\n this.storage.setItem(USER_KEY, JSON.stringify(session.user));\n }\n\n getSession(): AuthSession | null {\n const token = this.storage.getItem(TOKEN_KEY);\n const userStr = this.storage.getItem(USER_KEY);\n\n if (!token || !userStr) {\n return null;\n }\n\n try {\n const user = JSON.parse(userStr as string);\n return { accessToken: token as string, user };\n } catch {\n this.clearSession();\n return null;\n }\n }\n\n getAccessToken(): string | null {\n const token = this.storage.getItem(TOKEN_KEY);\n return typeof token === 'string' ? token : null;\n }\n\n clearSession(): void {\n this.storage.removeItem(TOKEN_KEY);\n this.storage.removeItem(USER_KEY);\n }\n}","/**\n * Auth module for InsForge SDK\n * Uses shared schemas for type safety\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { TokenManager } from '../lib/token-manager';\nimport { AuthSession, InsForgeError } from '../types';\n\nimport type {\n UserSchema,\n CreateUserRequest,\n CreateUserResponse,\n CreateSessionRequest,\n CreateSessionResponse,\n GetCurrentSessionResponse,\n GetOauthUrlResponse,\n} from '@insforge/shared-schemas';\n\nexport class Auth {\n constructor(\n private http: HttpClient,\n private tokenManager: TokenManager\n ) {}\n\n /**\n * Sign up a new user\n */\n async signUp(request: CreateUserRequest): Promise<{\n data: { user: UserSchema | null; session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateUserResponse>('/api/auth/users', request);\n \n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: { \n user: response.user, \n session \n }, \n error: null \n };\n } catch (error) {\n return { \n data: { user: null, session: null }, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Failed to sign up',\n 500,\n 'SIGNUP_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with email and password\n */\n async signInWithPassword(request: CreateSessionRequest): Promise<{\n data: { user: UserSchema | null; session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateSessionResponse>('/api/auth/sessions', request);\n \n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: { \n user: response.user, \n session \n }, \n error: null \n };\n } catch (error) {\n return { \n data: { user: null, session: null }, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Invalid login credentials',\n 401,\n 'INVALID_CREDENTIALS'\n )\n };\n }\n }\n\n /**\n * Sign in with OAuth provider\n */\n async signInWithOAuth(options: {\n provider: 'google' | 'github';\n redirectTo?: string;\n skipBrowserRedirect?: boolean;\n }): Promise<{\n data: { url?: string; provider?: string };\n error: InsForgeError | null;\n }> {\n try {\n const { provider, redirectTo, skipBrowserRedirect } = options;\n \n const params = redirectTo \n ? { redirect_uri: redirectTo } \n : undefined;\n \n const endpoint = `/api/auth/oauth/${provider}`;\n const response = await this.http.get<GetOauthUrlResponse>(endpoint, { params });\n \n // Automatically redirect in browser unless told not to\n if (typeof window !== 'undefined' && !skipBrowserRedirect) {\n window.location.href = response.authUrl;\n return { data: {}, error: null };\n }\n\n return { \n data: { \n url: response.authUrl,\n provider \n }, \n error: null \n };\n } catch (error) {\n return { \n data: {}, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n `Failed to initialize OAuth`,\n 500,\n 'OAUTH_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign out the current user\n */\n async signOut(): Promise<{ error: InsForgeError | null }> {\n try {\n this.tokenManager.clearSession();\n this.http.setAuthToken(null);\n return { error: null };\n } catch (error) {\n return { \n error: new InsForgeError(\n 'Failed to sign out',\n 500,\n 'SIGNOUT_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the current user from the API\n * Returns exactly what the backend returns: {id, email, role}\n */\n async getCurrentUser(): Promise<{\n data: GetCurrentSessionResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n // Check if we have a token\n const session = this.tokenManager.getSession();\n if (!session?.accessToken) {\n return { data: null, error: null };\n }\n\n // Call the API\n this.http.setAuthToken(session.accessToken);\n const response = await this.http.get<GetCurrentSessionResponse>('/api/auth/sessions/current');\n \n return {\n data: response,\n error: null\n };\n } catch (error) {\n // If unauthorized, clear session\n if (error instanceof InsForgeError && error.statusCode === 401) {\n await this.signOut();\n return { data: null, error: null };\n }\n \n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Failed to get current user',\n 500,\n 'GET_USER_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the stored session (no API call)\n */\n async getSession(): Promise<{\n data: { session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const session = this.tokenManager.getSession();\n \n if (session?.accessToken) {\n this.http.setAuthToken(session.accessToken);\n return { data: { session }, error: null };\n }\n\n return { data: { session: null }, error: null };\n } catch (error) {\n return { \n data: { session: null }, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Failed to get session',\n 500,\n 'GET_SESSION_ERROR'\n )\n };\n }\n }\n\n}","import { InsForgeConfig } from './types';\nimport { HttpClient } from './lib/http-client';\nimport { TokenManager } from './lib/token-manager';\nimport { Auth } from './modules/auth';\n\n/**\n * Main InsForge SDK Client\n * \n * @example\n * ```typescript\n * import { InsForgeClient } from '@insforge/sdk';\n * \n * const client = new InsForgeClient({\n * baseUrl: 'http://localhost:7130'\n * });\n * \n * // Register a new user\n * const session = await client.auth.register({\n * email: 'user@example.com',\n * password: 'password123',\n * name: 'John Doe'\n * });\n * \n * // Or login\n * const session = await client.auth.login({\n * email: 'user@example.com',\n * password: 'password123'\n * });\n * \n * // Get current user\n * const user = await client.auth.getCurrentUser();\n * ```\n */\nexport class InsForgeClient {\n private http: HttpClient;\n private tokenManager: TokenManager;\n \n /**\n * Authentication module\n */\n public readonly auth: Auth;\n\n constructor(config: InsForgeConfig = {}) {\n // Initialize HTTP client\n this.http = new HttpClient(config);\n \n // Initialize token manager with storage\n this.tokenManager = new TokenManager(config.storage);\n \n // Initialize auth module\n this.auth = new Auth(\n this.http,\n this.tokenManager\n );\n }\n\n\n /**\n * Set a custom API key for authentication\n * This is useful for server-to-server communication\n * \n * @param apiKey - The API key (should start with 'ik_')\n * \n * @example\n * ```typescript\n * client.setApiKey('ik_your_api_key_here');\n * ```\n */\n setApiKey(apiKey: string): void {\n // API keys can be used as Bearer tokens\n this.http.setAuthToken(apiKey);\n }\n\n /**\n * Get the underlying HTTP client for custom requests\n * \n * @example\n * ```typescript\n * const httpClient = client.getHttpClient();\n * const customData = await httpClient.get('/api/custom-endpoint');\n * ```\n */\n getHttpClient(): HttpClient {\n return this.http;\n }\n\n /**\n * Future modules will be added here:\n * - database: Database operations\n * - storage: File storage operations\n * - functions: Serverless functions\n * - tables: Table management\n * - metadata: Backend metadata\n */\n}","/**\n * @insforge/sdk - TypeScript SDK for InsForge Backend-as-a-Service\n * \n * @packageDocumentation\n */\n\n// Main client\nexport { InsForgeClient } from './client';\n\n// Types\nexport type {\n InsForgeConfig,\n InsForgeConfig as ClientOptions, // Alias for compatibility\n TokenStorage,\n AuthSession,\n ApiError,\n} from './types';\n\nexport { InsForgeError } from './types';\n\n// Re-export shared schemas that SDK users will need\nexport type {\n UserSchema,\n CreateUserRequest,\n CreateSessionRequest,\n AuthErrorResponse,\n} from '@insforge/shared-schemas';\n\n// Re-export auth module for advanced usage\nexport { Auth } from './modules/auth';\n\n// Re-export utilities for advanced usage\nexport { HttpClient } from './lib/http-client';\nexport { TokenManager } from './lib/token-manager';\n\n// Factory function for creating clients (Supabase-style)\nimport { InsForgeClient } from './client';\nimport { InsForgeConfig } from './types';\n\nexport function createClient(config: InsForgeConfig): InsForgeClient {\n return new InsForgeClient(config);\n}\n\n// Default export for convenience\nexport default InsForgeClient;"],"mappings":";AAmEO,IAAM,gBAAN,MAAM,uBAAsB,MAAM;AAAA,EAKvC,YAAY,SAAiB,YAAoB,OAAe,aAAsB;AACpF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,aAAa,UAAmC;AACrD,WAAO,IAAI;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;AClFO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAY,QAAwB;AAClC,SAAK,UAAU,OAAO,OAAO;AAC7B,SAAK,QAAQ,OAAO,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K,aAAa,WAAW;AAE7C,UAAI,SAAS,aAAa;AACxB,aAAK,KAAK,aAAa,QAAQ,WAAW;AAC1C,eAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,KAAK;AAAA,MAC1C;AAEA,aAAO,EAAE,MAAM,EAAE,SAAS,KAAK,GAAG,OAAO,KAAK;AAAA,IAChD,SAAS,OAAO;AACd,aAAO;AAAA,QACL,MAAM,EAAE,SAAS,KAAK;AAAA,QACtB,OAAO,iBAAiB,gBAAgB,QAAQ,IAAI;AAAA,UAClD;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEF;;;ACxMO,IAAM,iBAAN,MAAqB;AAAA,EAS1B,YAAY,SAAyB,CAAC,GAAG;AAEvC,SAAK,OAAO,IAAI,WAAW,MAAM;AAGjC,SAAK,eAAe,IAAI,aAAa,OAAO,OAAO;AAGnD,SAAK,OAAO,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,UAAU,QAAsB;AAE9B,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,gBAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUF;;;ACvDO,SAAS,aAAa,QAAwC;AACnE,SAAO,IAAI,eAAe,MAAM;AAClC;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@insforge/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TypeScript SDK for InsForge Backend-as-a-Service platform",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"test:run": "vitest run",
|
|
23
|
+
"lint": "eslint src --ext .ts",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"insforge",
|
|
28
|
+
"baas",
|
|
29
|
+
"backend",
|
|
30
|
+
"sdk",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"author": "InsForge",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"dependencies": {},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.11.24",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
39
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
40
|
+
"eslint": "^8.57.0",
|
|
41
|
+
"tsup": "^8.0.2",
|
|
42
|
+
"typescript": "^5.3.3",
|
|
43
|
+
"vitest": "^1.3.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@insforge/shared-schemas": "workspace:*"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
50
|
+
}
|
|
51
|
+
}
|