@insforge/sdk 0.0.58-dev.13 → 0.0.58-dev.14
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/LICENSE +201 -201
- package/README.md +249 -249
- package/dist/index.d.mts +48 -41
- package/dist/index.d.ts +48 -41
- package/dist/index.js +50 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +67 -67
package/README.md
CHANGED
|
@@ -1,249 +1,249 @@
|
|
|
1
|
-
# insforge-sdk-js
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@insforge/sdk)
|
|
4
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
|
-
|
|
6
|
-
Official TypeScript/JavaScript SDK for [InsForge](https://github.com/InsForge/InsForge) - A powerful, open-source Backend-as-a-Service (BaaS) platform.
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
- **Authentication** - Email/password, OAuth (Google, GitHub), session management
|
|
11
|
-
- **Database** - Full PostgreSQL database access with PostgREST
|
|
12
|
-
- **Storage** - File upload and management with S3-compatible storage
|
|
13
|
-
- **Edge Functions** - Serverless function invocation
|
|
14
|
-
- **AI Integration** - Built-in AI capabilities
|
|
15
|
-
- **TypeScript** - Full TypeScript support with type definitions
|
|
16
|
-
- **Automatic OAuth Handling** - Seamless OAuth callback detection
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @insforge/sdk
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Or with yarn:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
yarn add @insforge/sdk
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
### Initialize the Client
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
import { createClient } from '@insforge/sdk';
|
|
36
|
-
|
|
37
|
-
const insforge = createClient({
|
|
38
|
-
baseUrl: 'http://localhost:7130' // Your InsForge backend URL
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Authentication
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
// Sign up a new user
|
|
46
|
-
const { data, error } = await insforge.auth.signUp({
|
|
47
|
-
email: 'user@example.com',
|
|
48
|
-
password: 'securePassword123',
|
|
49
|
-
name: 'John Doe' // optional
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Sign in with email/password
|
|
53
|
-
const { data, error } = await insforge.auth.signInWithPassword({
|
|
54
|
-
email: 'user@example.com',
|
|
55
|
-
password: 'securePassword123'
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// OAuth authentication (Google, GitHub)
|
|
59
|
-
await insforge.auth.signInWithOAuth({
|
|
60
|
-
provider: 'google',
|
|
61
|
-
redirectTo: 'http://localhost:3000/dashboard'
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Get current user
|
|
65
|
-
const { data: user } = await insforge.auth.getCurrentUser();
|
|
66
|
-
|
|
67
|
-
// Sign out
|
|
68
|
-
await insforge.auth.signOut();
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Database Operations
|
|
72
|
-
|
|
73
|
-
```javascript
|
|
74
|
-
// Insert data
|
|
75
|
-
const { data, error } = await insforge.database
|
|
76
|
-
.from('posts')
|
|
77
|
-
.insert([
|
|
78
|
-
{ title: 'My First Post', content: 'Hello World!' }
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
// Query data
|
|
82
|
-
const { data, error } = await insforge.database
|
|
83
|
-
.from('posts')
|
|
84
|
-
.select('*')
|
|
85
|
-
.eq('author_id', userId);
|
|
86
|
-
|
|
87
|
-
// Update data
|
|
88
|
-
const { data, error } = await insforge.database
|
|
89
|
-
.from('posts')
|
|
90
|
-
.update({ title: 'Updated Title' })
|
|
91
|
-
.eq('id', postId);
|
|
92
|
-
|
|
93
|
-
// Delete data
|
|
94
|
-
const { data, error } = await insforge.database
|
|
95
|
-
.from('posts')
|
|
96
|
-
.delete()
|
|
97
|
-
.eq('id', postId);
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### File Storage
|
|
101
|
-
|
|
102
|
-
```javascript
|
|
103
|
-
// Upload a file
|
|
104
|
-
const file = document.querySelector('input[type="file"]').files[0];
|
|
105
|
-
const { data, error } = await insforge.storage
|
|
106
|
-
.from('avatars')
|
|
107
|
-
.upload(file);
|
|
108
|
-
|
|
109
|
-
// Download a file
|
|
110
|
-
const { data, error } = await insforge.storage
|
|
111
|
-
.from('avatars')
|
|
112
|
-
.download('user-avatar.png');
|
|
113
|
-
|
|
114
|
-
// Delete a file
|
|
115
|
-
const { data, error } = await insforge.storage
|
|
116
|
-
.from('avatars')
|
|
117
|
-
.remove(['user-avatar.png']);
|
|
118
|
-
|
|
119
|
-
// List files
|
|
120
|
-
const { data, error } = await insforge.storage
|
|
121
|
-
.from('avatars')
|
|
122
|
-
.list();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Edge Functions
|
|
126
|
-
|
|
127
|
-
```javascript
|
|
128
|
-
// Invoke an edge function
|
|
129
|
-
const { data, error } = await insforge.functions.invoke('my-function', {
|
|
130
|
-
body: { key: 'value' }
|
|
131
|
-
});
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### AI Integration
|
|
135
|
-
|
|
136
|
-
```javascript
|
|
137
|
-
// Generate text completion
|
|
138
|
-
const { data, error } = await insforge.ai.completion({
|
|
139
|
-
model: 'gpt-3.5-turbo',
|
|
140
|
-
prompt: 'Write a hello world program'
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// Analyze an image
|
|
144
|
-
const { data, error } = await insforge.ai.vision({
|
|
145
|
-
imageUrl: 'https://example.com/image.jpg',
|
|
146
|
-
prompt: 'Describe this image'
|
|
147
|
-
});
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Documentation
|
|
151
|
-
|
|
152
|
-
For complete API reference and advanced usage, see:
|
|
153
|
-
|
|
154
|
-
- **[SDK Reference](./SDK-REFERENCE.md)** - Complete API documentation
|
|
155
|
-
- **[InsForge Main Repository](https://github.com/InsForge/InsForge)** - Backend platform and setup guides
|
|
156
|
-
|
|
157
|
-
## Configuration
|
|
158
|
-
|
|
159
|
-
The SDK supports the following configuration options:
|
|
160
|
-
|
|
161
|
-
```javascript
|
|
162
|
-
const insforge = createClient({
|
|
163
|
-
baseUrl: 'http://localhost:7130', // Required: Your InsForge backend URL
|
|
164
|
-
storageStrategy: 'localStorage' // Optional: 'localStorage' or 'memory' (default: 'localStorage')
|
|
165
|
-
});
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## TypeScript Support
|
|
169
|
-
|
|
170
|
-
The SDK is written in TypeScript and provides full type definitions:
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
import { createClient, InsForgeClient, User, Session } from '@insforge/sdk';
|
|
174
|
-
|
|
175
|
-
const insforge: InsForgeClient = createClient({
|
|
176
|
-
baseUrl: 'http://localhost:7130'
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// Type-safe API calls
|
|
180
|
-
const response: { data: User | null; error: Error | null } =
|
|
181
|
-
await insforge.auth.getCurrentUser();
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Error Handling
|
|
185
|
-
|
|
186
|
-
All SDK methods return a consistent response format:
|
|
187
|
-
|
|
188
|
-
```javascript
|
|
189
|
-
const { data, error } = await insforge.auth.signUp({...});
|
|
190
|
-
|
|
191
|
-
if (error) {
|
|
192
|
-
console.error('Error:', error.message);
|
|
193
|
-
console.error('Status:', error.statusCode);
|
|
194
|
-
} else {
|
|
195
|
-
console.log('Success:', data);
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Browser Support
|
|
200
|
-
|
|
201
|
-
The SDK works in all modern browsers that support:
|
|
202
|
-
- ES6+ features
|
|
203
|
-
- Fetch API
|
|
204
|
-
- LocalStorage (for session management)
|
|
205
|
-
|
|
206
|
-
For Node.js environments, ensure you're using Node.js 18 or higher.
|
|
207
|
-
|
|
208
|
-
## Contributing
|
|
209
|
-
|
|
210
|
-
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
211
|
-
|
|
212
|
-
### Development Setup
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
# Clone the repository
|
|
216
|
-
git clone https://github.com/InsForge/insforge-sdk-js.git
|
|
217
|
-
cd insforge-sdk-js
|
|
218
|
-
|
|
219
|
-
# Install dependencies
|
|
220
|
-
npm install
|
|
221
|
-
|
|
222
|
-
# Build the SDK
|
|
223
|
-
npm run build
|
|
224
|
-
|
|
225
|
-
# Run tests
|
|
226
|
-
npm test
|
|
227
|
-
|
|
228
|
-
# Run integration tests
|
|
229
|
-
npm run test:integration
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## License
|
|
233
|
-
|
|
234
|
-
This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE) file for details.
|
|
235
|
-
|
|
236
|
-
## Community & Support
|
|
237
|
-
|
|
238
|
-
- **GitHub Issues**: [Report bugs or request features](https://github.com/InsForge/insforge-sdk-js/issues)
|
|
239
|
-
- **Documentation**: [https://docs.insforge.com](https://docs.insforge.com)
|
|
240
|
-
- **Main Repository**: [InsForge Backend Platform](https://github.com/InsForge/InsForge)
|
|
241
|
-
|
|
242
|
-
## Related Projects
|
|
243
|
-
|
|
244
|
-
- **[InsForge](https://github.com/InsForge/InsForge)** - The main InsForge backend platform
|
|
245
|
-
- **[InsForge MCP](https://github.com/InsForge/insforge-mcp)** - Model Context Protocol server for InsForge
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
Built with ❤️ by the InsForge team
|
|
1
|
+
# insforge-sdk-js
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@insforge/sdk)
|
|
4
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
|
+
|
|
6
|
+
Official TypeScript/JavaScript SDK for [InsForge](https://github.com/InsForge/InsForge) - A powerful, open-source Backend-as-a-Service (BaaS) platform.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Authentication** - Email/password, OAuth (Google, GitHub), session management
|
|
11
|
+
- **Database** - Full PostgreSQL database access with PostgREST
|
|
12
|
+
- **Storage** - File upload and management with S3-compatible storage
|
|
13
|
+
- **Edge Functions** - Serverless function invocation
|
|
14
|
+
- **AI Integration** - Built-in AI capabilities
|
|
15
|
+
- **TypeScript** - Full TypeScript support with type definitions
|
|
16
|
+
- **Automatic OAuth Handling** - Seamless OAuth callback detection
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @insforge/sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or with yarn:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @insforge/sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### Initialize the Client
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { createClient } from '@insforge/sdk';
|
|
36
|
+
|
|
37
|
+
const insforge = createClient({
|
|
38
|
+
baseUrl: 'http://localhost:7130' // Your InsForge backend URL
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Authentication
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// Sign up a new user
|
|
46
|
+
const { data, error } = await insforge.auth.signUp({
|
|
47
|
+
email: 'user@example.com',
|
|
48
|
+
password: 'securePassword123',
|
|
49
|
+
name: 'John Doe' // optional
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Sign in with email/password
|
|
53
|
+
const { data, error } = await insforge.auth.signInWithPassword({
|
|
54
|
+
email: 'user@example.com',
|
|
55
|
+
password: 'securePassword123'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// OAuth authentication (Google, GitHub)
|
|
59
|
+
await insforge.auth.signInWithOAuth({
|
|
60
|
+
provider: 'google',
|
|
61
|
+
redirectTo: 'http://localhost:3000/dashboard'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Get current user
|
|
65
|
+
const { data: user } = await insforge.auth.getCurrentUser();
|
|
66
|
+
|
|
67
|
+
// Sign out
|
|
68
|
+
await insforge.auth.signOut();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Database Operations
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
// Insert data
|
|
75
|
+
const { data, error } = await insforge.database
|
|
76
|
+
.from('posts')
|
|
77
|
+
.insert([
|
|
78
|
+
{ title: 'My First Post', content: 'Hello World!' }
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
// Query data
|
|
82
|
+
const { data, error } = await insforge.database
|
|
83
|
+
.from('posts')
|
|
84
|
+
.select('*')
|
|
85
|
+
.eq('author_id', userId);
|
|
86
|
+
|
|
87
|
+
// Update data
|
|
88
|
+
const { data, error } = await insforge.database
|
|
89
|
+
.from('posts')
|
|
90
|
+
.update({ title: 'Updated Title' })
|
|
91
|
+
.eq('id', postId);
|
|
92
|
+
|
|
93
|
+
// Delete data
|
|
94
|
+
const { data, error } = await insforge.database
|
|
95
|
+
.from('posts')
|
|
96
|
+
.delete()
|
|
97
|
+
.eq('id', postId);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### File Storage
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
// Upload a file
|
|
104
|
+
const file = document.querySelector('input[type="file"]').files[0];
|
|
105
|
+
const { data, error } = await insforge.storage
|
|
106
|
+
.from('avatars')
|
|
107
|
+
.upload(file);
|
|
108
|
+
|
|
109
|
+
// Download a file
|
|
110
|
+
const { data, error } = await insforge.storage
|
|
111
|
+
.from('avatars')
|
|
112
|
+
.download('user-avatar.png');
|
|
113
|
+
|
|
114
|
+
// Delete a file
|
|
115
|
+
const { data, error } = await insforge.storage
|
|
116
|
+
.from('avatars')
|
|
117
|
+
.remove(['user-avatar.png']);
|
|
118
|
+
|
|
119
|
+
// List files
|
|
120
|
+
const { data, error } = await insforge.storage
|
|
121
|
+
.from('avatars')
|
|
122
|
+
.list();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Edge Functions
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Invoke an edge function
|
|
129
|
+
const { data, error } = await insforge.functions.invoke('my-function', {
|
|
130
|
+
body: { key: 'value' }
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### AI Integration
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
// Generate text completion
|
|
138
|
+
const { data, error } = await insforge.ai.completion({
|
|
139
|
+
model: 'gpt-3.5-turbo',
|
|
140
|
+
prompt: 'Write a hello world program'
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Analyze an image
|
|
144
|
+
const { data, error } = await insforge.ai.vision({
|
|
145
|
+
imageUrl: 'https://example.com/image.jpg',
|
|
146
|
+
prompt: 'Describe this image'
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
For complete API reference and advanced usage, see:
|
|
153
|
+
|
|
154
|
+
- **[SDK Reference](./SDK-REFERENCE.md)** - Complete API documentation
|
|
155
|
+
- **[InsForge Main Repository](https://github.com/InsForge/InsForge)** - Backend platform and setup guides
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
The SDK supports the following configuration options:
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
const insforge = createClient({
|
|
163
|
+
baseUrl: 'http://localhost:7130', // Required: Your InsForge backend URL
|
|
164
|
+
storageStrategy: 'localStorage' // Optional: 'localStorage' or 'memory' (default: 'localStorage')
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## TypeScript Support
|
|
169
|
+
|
|
170
|
+
The SDK is written in TypeScript and provides full type definitions:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { createClient, InsForgeClient, User, Session } from '@insforge/sdk';
|
|
174
|
+
|
|
175
|
+
const insforge: InsForgeClient = createClient({
|
|
176
|
+
baseUrl: 'http://localhost:7130'
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Type-safe API calls
|
|
180
|
+
const response: { data: User | null; error: Error | null } =
|
|
181
|
+
await insforge.auth.getCurrentUser();
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Error Handling
|
|
185
|
+
|
|
186
|
+
All SDK methods return a consistent response format:
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
const { data, error } = await insforge.auth.signUp({...});
|
|
190
|
+
|
|
191
|
+
if (error) {
|
|
192
|
+
console.error('Error:', error.message);
|
|
193
|
+
console.error('Status:', error.statusCode);
|
|
194
|
+
} else {
|
|
195
|
+
console.log('Success:', data);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Browser Support
|
|
200
|
+
|
|
201
|
+
The SDK works in all modern browsers that support:
|
|
202
|
+
- ES6+ features
|
|
203
|
+
- Fetch API
|
|
204
|
+
- LocalStorage (for session management)
|
|
205
|
+
|
|
206
|
+
For Node.js environments, ensure you're using Node.js 18 or higher.
|
|
207
|
+
|
|
208
|
+
## Contributing
|
|
209
|
+
|
|
210
|
+
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
211
|
+
|
|
212
|
+
### Development Setup
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Clone the repository
|
|
216
|
+
git clone https://github.com/InsForge/insforge-sdk-js.git
|
|
217
|
+
cd insforge-sdk-js
|
|
218
|
+
|
|
219
|
+
# Install dependencies
|
|
220
|
+
npm install
|
|
221
|
+
|
|
222
|
+
# Build the SDK
|
|
223
|
+
npm run build
|
|
224
|
+
|
|
225
|
+
# Run tests
|
|
226
|
+
npm test
|
|
227
|
+
|
|
228
|
+
# Run integration tests
|
|
229
|
+
npm run test:integration
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE) file for details.
|
|
235
|
+
|
|
236
|
+
## Community & Support
|
|
237
|
+
|
|
238
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/InsForge/insforge-sdk-js/issues)
|
|
239
|
+
- **Documentation**: [https://docs.insforge.com](https://docs.insforge.com)
|
|
240
|
+
- **Main Repository**: [InsForge Backend Platform](https://github.com/InsForge/InsForge)
|
|
241
|
+
|
|
242
|
+
## Related Projects
|
|
243
|
+
|
|
244
|
+
- **[InsForge](https://github.com/InsForge/InsForge)** - The main InsForge backend platform
|
|
245
|
+
- **[InsForge MCP](https://github.com/InsForge/insforge-mcp)** - Model Context Protocol server for InsForge
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
Built with ❤️ by the InsForge team
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, SendVerificationEmailRequest, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, VerifyEmailRequest, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
4
4
|
|
|
@@ -131,7 +131,7 @@ declare class Auth {
|
|
|
131
131
|
* This runs on initialization to seamlessly complete the OAuth flow
|
|
132
132
|
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
133
133
|
*/
|
|
134
|
-
private
|
|
134
|
+
private detectAuthCallback;
|
|
135
135
|
/**
|
|
136
136
|
* Sign up a new user
|
|
137
137
|
*/
|
|
@@ -228,25 +228,13 @@ declare class Auth {
|
|
|
228
228
|
error: any | null;
|
|
229
229
|
}>;
|
|
230
230
|
/**
|
|
231
|
-
* Send email verification code
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}): Promise<{
|
|
237
|
-
data: {
|
|
238
|
-
success: boolean;
|
|
239
|
-
message: string;
|
|
240
|
-
} | null;
|
|
241
|
-
error: InsForgeError | null;
|
|
242
|
-
}>;
|
|
243
|
-
/**
|
|
244
|
-
* Send email verification link
|
|
245
|
-
* Creates a magic link token and sends it via email
|
|
231
|
+
* Send email verification (code or link based on config)
|
|
232
|
+
*
|
|
233
|
+
* Send email verification using the method configured in auth settings (verifyEmailMethod).
|
|
234
|
+
* When method is 'code', sends a 6-digit numeric code. When method is 'link', sends a magic link.
|
|
235
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
246
236
|
*/
|
|
247
|
-
|
|
248
|
-
email: string;
|
|
249
|
-
}): Promise<{
|
|
237
|
+
sendVerificationEmail(request: SendVerificationEmailRequest): Promise<{
|
|
250
238
|
data: {
|
|
251
239
|
success: boolean;
|
|
252
240
|
message: string;
|
|
@@ -254,12 +242,14 @@ declare class Auth {
|
|
|
254
242
|
error: InsForgeError | null;
|
|
255
243
|
}>;
|
|
256
244
|
/**
|
|
257
|
-
* Send password reset code
|
|
258
|
-
*
|
|
245
|
+
* Send password reset (code or link based on config)
|
|
246
|
+
*
|
|
247
|
+
* Send password reset email using the method configured in auth settings (resetPasswordMethod).
|
|
248
|
+
* When method is 'code', sends a 6-digit numeric code for two-step flow.
|
|
249
|
+
* When method is 'link', sends a magic link.
|
|
250
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
259
251
|
*/
|
|
260
|
-
|
|
261
|
-
email: string;
|
|
262
|
-
}): Promise<{
|
|
252
|
+
sendResetPasswordEmail(request: SendResetPasswordEmailRequest): Promise<{
|
|
263
253
|
data: {
|
|
264
254
|
success: boolean;
|
|
265
255
|
message: string;
|
|
@@ -267,22 +257,33 @@ declare class Auth {
|
|
|
267
257
|
error: InsForgeError | null;
|
|
268
258
|
}>;
|
|
269
259
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
260
|
+
* Exchange reset password code for reset token
|
|
261
|
+
*
|
|
262
|
+
* Step 1 of two-step password reset flow (only used when resetPasswordMethod is 'code'):
|
|
263
|
+
* 1. Verify the 6-digit code sent to user's email
|
|
264
|
+
* 2. Return a reset token that can be used to actually reset the password
|
|
265
|
+
*
|
|
266
|
+
* This endpoint is not used when resetPasswordMethod is 'link' (magic link flow is direct).
|
|
272
267
|
*/
|
|
273
|
-
|
|
274
|
-
email: string;
|
|
275
|
-
code: string;
|
|
276
|
-
}): Promise<{
|
|
268
|
+
exchangeResetPasswordToken(request: ExchangeResetPasswordTokenRequest): Promise<{
|
|
277
269
|
data: {
|
|
278
|
-
|
|
270
|
+
token: string;
|
|
279
271
|
expiresAt: string;
|
|
280
272
|
} | null;
|
|
281
273
|
error: InsForgeError | null;
|
|
282
274
|
}>;
|
|
283
275
|
/**
|
|
284
|
-
* Reset password with
|
|
285
|
-
*
|
|
276
|
+
* Reset password with token
|
|
277
|
+
*
|
|
278
|
+
* Reset user password with a token. The token can be:
|
|
279
|
+
* - Magic link token (64-character hex token from send-reset-password when method is 'link')
|
|
280
|
+
* - Reset token (from exchange-reset-password-token after code verification when method is 'code')
|
|
281
|
+
*
|
|
282
|
+
* Both token types use RESET_PASSWORD purpose and are verified the same way.
|
|
283
|
+
*
|
|
284
|
+
* Flow summary:
|
|
285
|
+
* - Code method: send-reset-password → exchange-reset-password-token → reset-password (with resetToken)
|
|
286
|
+
* - Link method: send-reset-password → reset-password (with link token directly)
|
|
286
287
|
*/
|
|
287
288
|
resetPassword(request: {
|
|
288
289
|
newPassword: string;
|
|
@@ -295,17 +296,23 @@ declare class Auth {
|
|
|
295
296
|
error: InsForgeError | null;
|
|
296
297
|
}>;
|
|
297
298
|
/**
|
|
298
|
-
* Verify email with
|
|
299
|
-
*
|
|
300
|
-
*
|
|
299
|
+
* Verify email with code or link
|
|
300
|
+
*
|
|
301
|
+
* Verify email address using the method configured in auth settings (verifyEmailMethod):
|
|
302
|
+
* - Code verification: Provide both `email` and `otp` (6-digit numeric code)
|
|
303
|
+
* - Link verification: Provide only `otp` (64-character hex token from magic link)
|
|
304
|
+
*
|
|
305
|
+
* Successfully verified users will receive a session token.
|
|
306
|
+
*
|
|
307
|
+
* The email verification link sent to users always points to the backend API endpoint.
|
|
308
|
+
* If `verifyEmailRedirectTo` is configured, the backend will redirect to that URL after successful verification.
|
|
309
|
+
* Otherwise, a default success page is displayed.
|
|
301
310
|
*/
|
|
302
|
-
verifyEmail(request: {
|
|
303
|
-
email?: string;
|
|
304
|
-
otp: string;
|
|
305
|
-
}): Promise<{
|
|
311
|
+
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
306
312
|
data: {
|
|
307
313
|
accessToken: string;
|
|
308
314
|
user?: any;
|
|
315
|
+
redirectTo?: string;
|
|
309
316
|
} | null;
|
|
310
317
|
error: InsForgeError | null;
|
|
311
318
|
}>;
|