@foru-ms/sdk 1.2.1 → 1.2.3
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 +113 -79
- package/dist/resources/Auth.d.ts +9 -0
- package/dist/resources/Auth.js +13 -0
- package/dist/types.d.ts +10 -0
- package/examples/authentication.ts +14 -2
- package/package.json +1 -1
- package/src/resources/Auth.ts +14 -0
- package/src/types.ts +11 -0
package/README.md
CHANGED
|
@@ -183,55 +183,70 @@ Check the `/examples` directory for detailed examples:
|
|
|
183
183
|
* `me()`: Get specific details of the currently authenticated user.
|
|
184
184
|
* `forgotPassword(email: string)`: Initiate password reset flow.
|
|
185
185
|
* `resetPassword(payload: { password: string; oldPassword?: string; email?: string; token?: string })`: Reset password using token or old password.
|
|
186
|
+
* `getSecurity()`: Get account security information for the authenticated user. Returns IP addresses, registration date, last seen timestamp, and verification status. **Requires authentication token.**
|
|
186
187
|
|
|
187
188
|
### Threads (`client.threads`)
|
|
188
189
|
|
|
189
|
-
|
|
190
|
+
**Thread Management**
|
|
191
|
+
* `list(params: { query?: string; tagId?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted' | 'subscribed'; cursor?: string; userId?: string })`: List threads with filtering options.
|
|
190
192
|
* `create(payload: CreateThreadPayload)`: Create a new thread.
|
|
191
193
|
* `retrieve(id: string)`: Get a thread by ID.
|
|
192
194
|
* `update(id: string, payload: UpdateThreadPayload)`: Update a thread.
|
|
193
195
|
* `delete(id: string)`: Delete a thread.
|
|
194
|
-
* `getPosts(id: string, params: { cursor?: string; filter?: 'newest' | 'oldest' })`: Get posts in a thread.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* `
|
|
198
|
-
* `
|
|
199
|
-
* `
|
|
200
|
-
* `
|
|
201
|
-
* `
|
|
202
|
-
* `
|
|
203
|
-
* `
|
|
204
|
-
* `
|
|
205
|
-
* `
|
|
206
|
-
* `
|
|
207
|
-
* `
|
|
208
|
-
* `
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
* `
|
|
212
|
-
* `
|
|
213
|
-
* `
|
|
196
|
+
* `getPosts(id: string, params: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get posts in a thread.
|
|
197
|
+
|
|
198
|
+
**Thread Interactions**
|
|
199
|
+
* `like(id: string, userId?: string, extendedData?: any)`: Like a thread.
|
|
200
|
+
* `unlike(id: string, userId?: string)`: Unlike a thread.
|
|
201
|
+
* `getLikes(id: string, params?: { cursor?: string })`: Get users who liked a thread with pagination.
|
|
202
|
+
* `dislike(id: string, userId?: string, extendedData?: any)`: Dislike a thread.
|
|
203
|
+
* `undislike(id: string, userId?: string)`: Remove dislike from a thread.
|
|
204
|
+
* `getDislikes(id: string, params?: { cursor?: string })`: Get users who disliked a thread with pagination.
|
|
205
|
+
* `upvote(id: string, userId?: string, extendedData?: any)`: Upvote a thread.
|
|
206
|
+
* `unupvote(id: string, userId?: string)`: Remove upvote from a thread.
|
|
207
|
+
* `getUpvotes(id: string, params?: { cursor?: string })`: Get users who upvoted a thread with pagination.
|
|
208
|
+
* `downvote(id: string, userId?: string, extendedData?: any)`: Downvote a thread.
|
|
209
|
+
* `undownvote(id: string, userId?: string)`: Remove downvote from a thread.
|
|
210
|
+
* `getDownvotes(id: string, params?: { cursor?: string })`: Get users who downvoted a thread with pagination.
|
|
211
|
+
|
|
212
|
+
**Thread Subscriptions**
|
|
213
|
+
* `subscribe(id: string, userId?: string, extendedData?: any)`: Subscribe to a thread.
|
|
214
|
+
* `unsubscribe(id: string, userId?: string)`: Unsubscribe from a thread.
|
|
215
|
+
* `getSubscribers(id: string, params?: { cursor?: string })`: Get users subscribed to a thread with pagination.
|
|
216
|
+
|
|
217
|
+
**Thread Polls**
|
|
218
|
+
* `createPoll(id: string, payload: { title?: string; expiresAt?: string; options: Array<{ title: string; color?: string; extendedData?: any }>, extendedData?: any })`: Create a poll for a thread.
|
|
219
|
+
* `getPoll(id: string)`: Get poll details and configuration.
|
|
220
|
+
* `updatePoll(id: string, payload: { title?: string; expiresAt?: string; closed?: boolean; options?: Array<{ id?: string; title?: string; color?: string; extendedData?: any }>; extendedData?: any })`: Update poll configuration.
|
|
221
|
+
* `deletePoll(id: string)`: Delete a poll from a thread.
|
|
222
|
+
* `getPollResults(id: string, userId?: string)`: Get poll results with vote counts.
|
|
223
|
+
* `vote(id: string, userId?: string, optionId: string)`: Cast a vote in a thread poll.
|
|
224
|
+
* `voteUpdate(id: string, userId?: string, optionId: string)`: Change an existing vote.
|
|
225
|
+
* `unvote(id: string, userId?: string)`: Remove your vote from a poll.
|
|
214
226
|
|
|
215
227
|
### Posts (`client.posts`)
|
|
216
228
|
|
|
217
|
-
|
|
218
|
-
* `
|
|
229
|
+
**Post Management**
|
|
230
|
+
* `list(params: { query?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted'; cursor?: string; userId?: string })`: List posts with filtering options.
|
|
231
|
+
* `create(payload: CreatePostPayload)`: Create a new post/reply.
|
|
219
232
|
* `retrieve(id: string)`: Get a post by ID.
|
|
220
233
|
* `update(id: string, payload: UpdatePostPayload)`: Update a post.
|
|
221
|
-
* `delete(id: string)`: Delete a post.
|
|
222
|
-
* `getChildren(id: string, params
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
* `
|
|
226
|
-
* `
|
|
227
|
-
* `
|
|
228
|
-
* `
|
|
229
|
-
* `
|
|
230
|
-
* `
|
|
231
|
-
* `
|
|
232
|
-
* `
|
|
233
|
-
* `
|
|
234
|
-
* `
|
|
234
|
+
* `delete(id: string, payload?: { userId?: string })`: Delete a post.
|
|
235
|
+
* `getChildren(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get child posts (nested replies).
|
|
236
|
+
|
|
237
|
+
**Post Interactions**
|
|
238
|
+
* `like(id: string, userId?: string, extendedData?: any)`: Like a post.
|
|
239
|
+
* `unlike(id: string, userId?: string)`: Unlike a post.
|
|
240
|
+
* `getLikes(id: string, params?: { cursor?: string })`: Get users who liked a post with pagination.
|
|
241
|
+
* `dislike(id: string, userId?: string, extendedData?: any)`: Dislike a post.
|
|
242
|
+
* `undislike(id: string, userId?: string)`: Remove dislike from a post.
|
|
243
|
+
* `getDislikes(id: string, params?: { cursor?: string })`: Get users who disliked a post with pagination.
|
|
244
|
+
* `upvote(id: string, userId?: string, extendedData?: any)`: Upvote a post.
|
|
245
|
+
* `unupvote(id: string, userId?: string)`: Remove upvote from a post.
|
|
246
|
+
* `getUpvotes(id: string, params?: { cursor?: string })`: Get users who upvoted a post with pagination.
|
|
247
|
+
* `downvote(id: string, userId?: string, extendedData?: any)`: Downvote a post.
|
|
248
|
+
* `undownvote(id: string, userId?: string)`: Remove downvote from a post.
|
|
249
|
+
* `getDownvotes(id: string, params?: { cursor?: string })`: Get users who downvoted a post with pagination.
|
|
235
250
|
|
|
236
251
|
### Users (`client.users`)
|
|
237
252
|
|
|
@@ -244,32 +259,32 @@ Check the `/examples` directory for detailed examples:
|
|
|
244
259
|
* `getPosts(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get all posts created by a user.
|
|
245
260
|
* `getFollowers(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get user's followers.
|
|
246
261
|
* `getFollowing(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get who a user follows.
|
|
247
|
-
* `follow(id: string, followerId
|
|
248
|
-
* `unfollow(id: string, followerId
|
|
262
|
+
* `follow(id: string, followerId?: string, extendedData?: any)`: Follow a user.
|
|
263
|
+
* `unfollow(id: string, followerId?: string)`: Unfollow a user.
|
|
249
264
|
|
|
250
265
|
|
|
251
266
|
### Tags (`client.tags`)
|
|
252
267
|
|
|
253
|
-
* `list(params?: { query?: string; cursor?: string })`: List tags.
|
|
268
|
+
* `list(params?: { query?: string; cursor?: string })`: List all tags.
|
|
269
|
+
* `listSubscribed(params: { userId?: string; query?: string; cursor?: string })`: List tags a user is subscribed to.
|
|
254
270
|
* `create(payload: { name: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Create a tag.
|
|
255
|
-
* `retrieve(id: string, params?: { userId?: string })`: Get a tag.
|
|
271
|
+
* `retrieve(id: string, params?: { userId?: string })`: Get a tag with optional user context.
|
|
256
272
|
* `update(id: string, payload: { name?: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Update a tag.
|
|
257
273
|
* `delete(id: string)`: Delete a tag.
|
|
258
274
|
* `getThreads(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get all threads with a specific tag.
|
|
259
|
-
* `subscribe(id: string, userId
|
|
260
|
-
* `unsubscribe(id: string, userId
|
|
261
|
-
* `getSubscribers(id: string, params?: { cursor?: string })`: Get users subscribed to a tag.
|
|
262
|
-
* `listSubscribed(params: { userId: string; query?: string; cursor?: string })`: List tags a user is subscribed to.
|
|
275
|
+
* `subscribe(id: string, userId?: string)`: Subscribe to a tag.
|
|
276
|
+
* `unsubscribe(id: string, userId?: string)`: Unsubscribe from a tag.
|
|
277
|
+
* `getSubscribers(id: string, params?: { cursor?: string })`: Get users subscribed to a tag with pagination.
|
|
263
278
|
|
|
264
279
|
|
|
265
280
|
### Notifications (`client.notifications`)
|
|
266
281
|
|
|
267
|
-
* `list(params: { userId
|
|
268
|
-
* `
|
|
269
|
-
* `
|
|
270
|
-
* `
|
|
271
|
-
* `
|
|
272
|
-
* `
|
|
282
|
+
* `list(params: { userId?: string; read?: boolean; filter?: 'newest' | 'oldest'; cursor?: string })`: List notifications for a user.
|
|
283
|
+
* `create(payload: { threadId?: string; postId?: string; privateMessageId?: string; notifierId?: string; notifiedId: string; type: string; description?: string; extendedData?: Record<string, any> })`: Create a notification manually.
|
|
284
|
+
* `retrieve(id: string, userId?: string)`: Get a notification by ID.
|
|
285
|
+
* `update(id: string, payload: { userId?: string; read: boolean })`: Update a notification's read status.
|
|
286
|
+
* `delete(id: string, userId?: string)`: Delete a notification.
|
|
287
|
+
* `markAllAsRead(userId?: string, read?: boolean)`: Bulk update read status for all of a user's notifications. Default read status is `true`.
|
|
273
288
|
|
|
274
289
|
### Search (`client.search`)
|
|
275
290
|
|
|
@@ -277,12 +292,13 @@ Check the `/examples` directory for detailed examples:
|
|
|
277
292
|
|
|
278
293
|
### Webhooks (`client.webhooks`)
|
|
279
294
|
|
|
280
|
-
* `list()`: List webhooks.
|
|
281
|
-
* `create(payload: { name: string; url: string; events: string[] })`: Create a webhook.
|
|
282
|
-
* `retrieve(id: string)`: Get a webhook.
|
|
283
|
-
* `update(id: string, payload:
|
|
295
|
+
* `list()`: List all webhooks for your instance.
|
|
296
|
+
* `create(payload: { name: string; url: string; events: string[] })`: Create a new webhook subscription.
|
|
297
|
+
* `retrieve(id: string)`: Get a webhook by ID.
|
|
298
|
+
* `update(id: string, payload: { name?: string; url?: string; events?: string[]; active?: boolean })`: Update a webhook configuration.
|
|
284
299
|
* `delete(id: string)`: Delete a webhook.
|
|
285
|
-
* `getDeliveries(id: string, params
|
|
300
|
+
* `getDeliveries(id: string, params?: { cursor?: string })`: Get webhook delivery history with pagination. Track successful and failed deliveries.
|
|
301
|
+
* `verifySignature(payload: any, signature: string, timestamp: string, secret: string, maxAge?: number)`: Verify webhook signature for security. Uses HMAC-SHA256. Default maxAge is 5 minutes to prevent replay attacks.
|
|
286
302
|
|
|
287
303
|
### Stats (`client.stats`)
|
|
288
304
|
|
|
@@ -290,46 +306,49 @@ Check the `/examples` directory for detailed examples:
|
|
|
290
306
|
|
|
291
307
|
### Integrations (`client.integrations`)
|
|
292
308
|
|
|
293
|
-
* `list()`: Get all configured integrations.
|
|
294
|
-
* `create(payload: { type: 'SLACK' | 'DISCORD' | 'SALESFORCE' | 'HUBSPOT' | 'OKTA' | 'AUTH0'; name: string; config: any })`: Configure
|
|
295
|
-
* `retrieve(id: string)`: Get integration details.
|
|
296
|
-
* `update(id: string, payload: { name?: string;
|
|
309
|
+
* `list()`: Get all configured integrations for your instance.
|
|
310
|
+
* `create(payload: { type: 'SLACK' | 'DISCORD' | 'SALESFORCE' | 'HUBSPOT' | 'OKTA' | 'AUTH0'; name: string; config: any })`: Configure a new integration (Slack, Discord, CRM, or SSO).
|
|
311
|
+
* `retrieve(id: string)`: Get integration details by ID.
|
|
312
|
+
* `update(id: string, payload: { name?: string; type?: string; enabled?: boolean; config?: any })`: Update an integration configuration.
|
|
297
313
|
* `delete(id: string)`: Remove an integration.
|
|
314
|
+
* `test(integrationId: string)`: Send a test message to verify integration is working correctly.
|
|
315
|
+
* `oauthAuthorize(provider: 'hubspot' | 'salesforce')`: Initiate OAuth flow for a provider (redirects to provider).
|
|
316
|
+
* `oauthCallback(provider: string, code: string, state: string)`: Handle OAuth callback from provider.
|
|
298
317
|
|
|
299
318
|
### Private Messages (`client.privateMessages`)
|
|
300
319
|
|
|
301
320
|
* `list(params?: { query?: string; userId?: string; filter?: 'newest' | 'oldest'; cursor?: string })`: List private messages.
|
|
302
|
-
* `create(payload: { title?: string; body: string; recipientId: string; senderId?: string; extendedData?: Record<string, any> })`: Send a
|
|
303
|
-
* `retrieve(id: string)`: Get a message
|
|
304
|
-
* `reply(id: string, payload: { body: string; senderId
|
|
305
|
-
* `update(id: string, payload: {
|
|
306
|
-
* `delete(id: string)`: Delete a message.
|
|
321
|
+
* `create(payload: { title?: string; body: string; recipientId: string; senderId?: string; extendedData?: Record<string, any> })`: Send a new private message.
|
|
322
|
+
* `retrieve(id: string, userId?: string)`: Get a message by ID.
|
|
323
|
+
* `reply(id: string, payload: { body: string; senderId?: string; title?: string; extendedData?: Record<string, any> })`: Reply to a message thread.
|
|
324
|
+
* `update(id: string, payload: { body?: string; extendedData?: Record<string, any> })`: Update a message (only sender can update).
|
|
325
|
+
* `delete(id: string)`: Delete a message (participants can delete).
|
|
307
326
|
|
|
308
327
|
### Reports (`client.reports`)
|
|
309
328
|
|
|
310
|
-
* `list(params?: { reporterId?: string; reportedId?: string; read?: boolean; cursor?: string; filter?: 'newest' | 'oldest' })`: List reports.
|
|
311
|
-
* `create(payload: { reporterId
|
|
312
|
-
* `
|
|
313
|
-
* `
|
|
314
|
-
* `
|
|
329
|
+
* `list(params?: { reporterId?: string; reportedId?: string; read?: boolean; cursor?: string; filter?: 'newest' | 'oldest' })`: List reports with filtering options.
|
|
330
|
+
* `create(payload: { reporterId?: string; reportedId?: string; threadId?: string; postId?: string; privateMessageId?: string; type?: string; description?: string; extendedData?: Record<string, any> })`: Submit a new report.
|
|
331
|
+
* `retrieve(id: string)`: Get a report by ID.
|
|
332
|
+
* `update(id: string, payload: { threadId?: string; postId?: string; privateMessageId?: string; reportedId?: string; reporterId?: string; type?: string; description?: string; read?: boolean; extendedData?: Record<string, any> })`: Update report details (full update).
|
|
333
|
+
* `updateStatus(id: string, read: boolean)`: Update read status of a report (partial update).
|
|
334
|
+
* `batchUpdate(payload: { reportIds: string[]; read: boolean })`: Bulk update read status for multiple reports.
|
|
315
335
|
* `delete(id: string)`: Delete a report.
|
|
316
|
-
* `updateStatus(id: string, read: boolean)`: Update read status of a report.
|
|
317
336
|
|
|
318
337
|
### Roles (`client.roles`)
|
|
319
338
|
|
|
320
339
|
* `list(params?: { filter?: 'newest' | 'oldest'; cursor?: string })`: List user roles.
|
|
321
340
|
* `create(payload: { name: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Create a new role.
|
|
322
|
-
* `retrieve(id: string)`: Get a role.
|
|
341
|
+
* `retrieve(id: string)`: Get a role by ID.
|
|
323
342
|
* `update(id: string, payload: { name?: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Update a role.
|
|
324
343
|
* `delete(id: string)`: Delete a role.
|
|
325
344
|
|
|
326
345
|
### SSO (`client.sso`)
|
|
327
346
|
|
|
328
|
-
* `list()`: List SSO providers.
|
|
329
|
-
* `create(payload: { provider: 'OKTA' | 'AUTH0' | 'SAML'; domain: string; config: any })`: Configure SSO.
|
|
330
|
-
* `retrieve(id: string)`: Get SSO provider details.
|
|
331
|
-
* `update(id: string, payload: {
|
|
332
|
-
* `delete(id: string)`: Remove SSO provider.
|
|
347
|
+
* `list()`: List all SSO providers configured for your instance.
|
|
348
|
+
* `create(payload: { provider: 'OKTA' | 'AUTH0' | 'SAML'; domain: string; config: any })`: Configure a new SSO provider.
|
|
349
|
+
* `retrieve(id: string)`: Get SSO provider details by ID.
|
|
350
|
+
* `update(id: string, payload: { name?: string; type?: 'SAML' | 'OIDC' | 'OAUTH2'; enabled?: boolean; config?: any })`: Update SSO configuration.
|
|
351
|
+
* `delete(id: string)`: Remove an SSO provider.
|
|
333
352
|
|
|
334
353
|
## Types
|
|
335
354
|
|
|
@@ -341,6 +360,7 @@ import {
|
|
|
341
360
|
RegisterPayload,
|
|
342
361
|
User,
|
|
343
362
|
LoginResponse,
|
|
363
|
+
SecurityInfo,
|
|
344
364
|
|
|
345
365
|
// Thread Types
|
|
346
366
|
Thread,
|
|
@@ -510,6 +530,20 @@ We welcome contributions! Please see our contributing guidelines for more inform
|
|
|
510
530
|
|
|
511
531
|
## Changelog
|
|
512
532
|
|
|
533
|
+
### v1.2.3
|
|
534
|
+
- README documentation update
|
|
535
|
+
- Enhanced all API reference sections with:
|
|
536
|
+
- Better organization with categorized subsections (Management, Interactions, Subscriptions, Polls)
|
|
537
|
+
- Corrected optional vs required parameters throughout
|
|
538
|
+
- Added missing methods documentation (poll CRUD, webhook deliveries, integration OAuth, etc.)
|
|
539
|
+
- Improved clarity and consistency across all resource sections
|
|
540
|
+
- Added detailed descriptions for complex operations
|
|
541
|
+
|
|
542
|
+
### v1.2.2
|
|
543
|
+
- Added Auth resource with authentication methods
|
|
544
|
+
- Introduced comprehensive SDK type definitions
|
|
545
|
+
- Updated documentation
|
|
546
|
+
|
|
513
547
|
### v1.2.1
|
|
514
548
|
- README.md formatting and updates
|
|
515
549
|
|
|
@@ -518,11 +552,11 @@ We welcome contributions! Please see our contributing guidelines for more inform
|
|
|
518
552
|
- Added automatic retry logic with exponential backoff
|
|
519
553
|
- Added pagination helpers for easy iteration
|
|
520
554
|
- Added webhook signature verification
|
|
521
|
-
- Added
|
|
555
|
+
- Added new endpoints
|
|
522
556
|
- Enhanced documentation and examples
|
|
523
557
|
|
|
524
558
|
### v1.1.0
|
|
525
|
-
- Added
|
|
559
|
+
- Added new endpoints
|
|
526
560
|
- Enhanced documentation and examples
|
|
527
561
|
|
|
528
562
|
### v1.0.0
|
package/dist/resources/Auth.d.ts
CHANGED
|
@@ -21,4 +21,13 @@ export declare class AuthResource {
|
|
|
21
21
|
}): Promise<{
|
|
22
22
|
message: string;
|
|
23
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Get account security information for the authenticated user.
|
|
26
|
+
* This includes IP addresses, registration date, last seen timestamp, and verification status.
|
|
27
|
+
* Requires authentication token.
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise<SecurityInfo> Security information including IPs and account activity
|
|
30
|
+
* @throws {ApiError} If not authenticated or user not found
|
|
31
|
+
*/
|
|
32
|
+
getSecurity(): Promise<import('../types').SecurityInfo>;
|
|
24
33
|
}
|
package/dist/resources/Auth.js
CHANGED
|
@@ -45,5 +45,18 @@ class AuthResource {
|
|
|
45
45
|
body: JSON.stringify(body),
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Get account security information for the authenticated user.
|
|
50
|
+
* This includes IP addresses, registration date, last seen timestamp, and verification status.
|
|
51
|
+
* Requires authentication token.
|
|
52
|
+
*
|
|
53
|
+
* @returns Promise<SecurityInfo> Security information including IPs and account activity
|
|
54
|
+
* @throws {ApiError} If not authenticated or user not found
|
|
55
|
+
*/
|
|
56
|
+
async getSecurity() {
|
|
57
|
+
return this.client.request('/auth/security', {
|
|
58
|
+
method: 'GET',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
48
61
|
}
|
|
49
62
|
exports.AuthResource = AuthResource;
|
package/dist/types.d.ts
CHANGED
|
@@ -113,6 +113,16 @@ export interface PostListResponse {
|
|
|
113
113
|
export interface LoginResponse {
|
|
114
114
|
token: string;
|
|
115
115
|
}
|
|
116
|
+
export interface SecurityInfo {
|
|
117
|
+
userId: string;
|
|
118
|
+
username: string;
|
|
119
|
+
registrationIp: string;
|
|
120
|
+
registrationDate: string;
|
|
121
|
+
lastIp: string;
|
|
122
|
+
lastSeenAt: string;
|
|
123
|
+
isOnline: boolean;
|
|
124
|
+
emailVerified: boolean;
|
|
125
|
+
}
|
|
116
126
|
export type ThreadFilter = 'newest' | 'oldest';
|
|
117
127
|
export type InteractionType = 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted' | 'subscribed';
|
|
118
128
|
export interface Tag {
|
|
@@ -54,12 +54,24 @@ async function main() {
|
|
|
54
54
|
});
|
|
55
55
|
console.log('Password reset successful');
|
|
56
56
|
|
|
57
|
-
// Example 5:
|
|
57
|
+
// Example 5: Get Account Security Information
|
|
58
|
+
console.log('\n=== Account Security Info ===');
|
|
59
|
+
const securityInfo = await client.auth.getSecurity();
|
|
60
|
+
console.log('User ID:', securityInfo.userId);
|
|
61
|
+
console.log('Username:', securityInfo.username);
|
|
62
|
+
console.log('Registration IP:', securityInfo.registrationIp);
|
|
63
|
+
console.log('Registration Date:', new Date(securityInfo.registrationDate).toLocaleDateString());
|
|
64
|
+
console.log('Last IP:', securityInfo.lastIp);
|
|
65
|
+
console.log('Last Seen:', new Date(securityInfo.lastSeenAt).toLocaleString());
|
|
66
|
+
console.log('Is Online:', securityInfo.isOnline);
|
|
67
|
+
console.log('Email Verified:', securityInfo.emailVerified);
|
|
68
|
+
|
|
69
|
+
// Example 6: Check Authentication Status
|
|
58
70
|
console.log('\n=== Authentication Status ===');
|
|
59
71
|
console.log('Is authenticated:', client.isAuthenticated());
|
|
60
72
|
console.log('Current token:', client.token);
|
|
61
73
|
|
|
62
|
-
// Example
|
|
74
|
+
// Example 7: Logout (clear token)
|
|
63
75
|
console.log('\n=== Logout ===');
|
|
64
76
|
client.clearToken();
|
|
65
77
|
console.log('Token cleared');
|
package/package.json
CHANGED
package/src/resources/Auth.ts
CHANGED
|
@@ -61,4 +61,18 @@ export class AuthResource {
|
|
|
61
61
|
body: JSON.stringify(body),
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get account security information for the authenticated user.
|
|
67
|
+
* This includes IP addresses, registration date, last seen timestamp, and verification status.
|
|
68
|
+
* Requires authentication token.
|
|
69
|
+
*
|
|
70
|
+
* @returns Promise<SecurityInfo> Security information including IPs and account activity
|
|
71
|
+
* @throws {ApiError} If not authenticated or user not found
|
|
72
|
+
*/
|
|
73
|
+
async getSecurity(): Promise<import('../types').SecurityInfo> {
|
|
74
|
+
return this.client.request<import('../types').SecurityInfo>('/auth/security', {
|
|
75
|
+
method: 'GET',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
64
78
|
}
|
package/src/types.ts
CHANGED
|
@@ -128,6 +128,17 @@ export interface LoginResponse {
|
|
|
128
128
|
token: string;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
export interface SecurityInfo {
|
|
132
|
+
userId: string;
|
|
133
|
+
username: string;
|
|
134
|
+
registrationIp: string;
|
|
135
|
+
registrationDate: string;
|
|
136
|
+
lastIp: string;
|
|
137
|
+
lastSeenAt: string;
|
|
138
|
+
isOnline: boolean;
|
|
139
|
+
emailVerified: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
131
142
|
export type ThreadFilter = 'newest' | 'oldest';
|
|
132
143
|
export type InteractionType = 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted' | 'subscribed';
|
|
133
144
|
|