@foru-ms/sdk 1.2.1 → 1.2.2
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 +5 -2
- 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,9 +183,11 @@ 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
|
|
|
190
|
+
|
|
189
191
|
* `list(params: { limit?: number; filter?: 'newest' | 'oldest'; tagId?: string; cursor?: string })`: List threads.
|
|
190
192
|
* `create(payload: CreateThreadPayload)`: Create a new thread.
|
|
191
193
|
* `retrieve(id: string)`: Get a thread by ID.
|
|
@@ -341,6 +343,7 @@ import {
|
|
|
341
343
|
RegisterPayload,
|
|
342
344
|
User,
|
|
343
345
|
LoginResponse,
|
|
346
|
+
SecurityInfo,
|
|
344
347
|
|
|
345
348
|
// Thread Types
|
|
346
349
|
Thread,
|
|
@@ -518,11 +521,11 @@ We welcome contributions! Please see our contributing guidelines for more inform
|
|
|
518
521
|
- Added automatic retry logic with exponential backoff
|
|
519
522
|
- Added pagination helpers for easy iteration
|
|
520
523
|
- Added webhook signature verification
|
|
521
|
-
- Added
|
|
524
|
+
- Added new endpoints
|
|
522
525
|
- Enhanced documentation and examples
|
|
523
526
|
|
|
524
527
|
### v1.1.0
|
|
525
|
-
- Added
|
|
528
|
+
- Added new endpoints
|
|
526
529
|
- Enhanced documentation and examples
|
|
527
530
|
|
|
528
531
|
### 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
|
|