api2key-base-sdk 0.1.4 → 0.1.5
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 +21 -0
- package/dist/auth/client.d.ts +12 -2
- package/dist/auth/client.js +37 -0
- package/dist/core/types.d.ts +32 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
|
|
47
47
|
1. `login(input)`
|
|
48
48
|
2. `register(input)`
|
|
49
|
+
3. `verifyEmail(input)`
|
|
50
|
+
4. `resendVerification(input)`
|
|
51
|
+
5. `forgotPassword(input)`
|
|
52
|
+
6. `resetPassword(input)`
|
|
53
|
+
7. `sendChangePasswordCode(accessToken?)`
|
|
54
|
+
8. `changePassword(input, accessToken?)`
|
|
49
55
|
3. `me(accessToken?)`
|
|
50
56
|
4. `logout(accessToken?)`
|
|
51
57
|
|
|
@@ -108,6 +114,21 @@ const baseClient = createBasePlatformClient({
|
|
|
108
114
|
const me = await baseClient.auth.me();
|
|
109
115
|
const credits = await baseClient.credits.getBalance();
|
|
110
116
|
|
|
117
|
+
await baseClient.auth.verifyEmail({
|
|
118
|
+
email: 'user@example.com',
|
|
119
|
+
code: '123456',
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await baseClient.auth.forgotPassword({
|
|
123
|
+
email: 'user@example.com',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
await baseClient.auth.resetPassword({
|
|
127
|
+
email: 'user@example.com',
|
|
128
|
+
code: '123456',
|
|
129
|
+
newPassword: 'NewPassword123!',
|
|
130
|
+
});
|
|
131
|
+
|
|
111
132
|
const projectClient = createProjectPlatformClient({
|
|
112
133
|
baseUrl: process.env.API2KEY_BASE_URL!,
|
|
113
134
|
getAccessToken: () => process.env.ACCESS_TOKEN,
|
package/dist/auth/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatformHttpClient } from '../core/client';
|
|
2
|
-
import type { AuthSession, AuthUser } from '../core/types';
|
|
2
|
+
import type { AuthChangePasswordInput, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthSession, AuthUser, AuthVerifyEmailInput, AuthResetPasswordInput } from '../core/types';
|
|
3
3
|
export declare class AuthClient {
|
|
4
4
|
private readonly http;
|
|
5
5
|
constructor(http: PlatformHttpClient);
|
|
@@ -13,10 +13,20 @@ export declare class AuthClient {
|
|
|
13
13
|
password: string;
|
|
14
14
|
name?: string;
|
|
15
15
|
projectId?: string;
|
|
16
|
-
}): Promise<
|
|
16
|
+
}): Promise<AuthRegisterResult>;
|
|
17
|
+
verifyEmail(input: AuthVerifyEmailInput): Promise<AuthSession>;
|
|
18
|
+
resendVerification(input: {
|
|
19
|
+
email: string;
|
|
20
|
+
}): Promise<null>;
|
|
21
|
+
forgotPassword(input: {
|
|
22
|
+
email: string;
|
|
23
|
+
}): Promise<AuthPasswordResetDispatchResult | null>;
|
|
24
|
+
resetPassword(input: AuthResetPasswordInput): Promise<null>;
|
|
17
25
|
me(accessToken?: string): Promise<{
|
|
18
26
|
user: AuthUser;
|
|
19
27
|
membership?: unknown;
|
|
20
28
|
}>;
|
|
21
29
|
logout(accessToken?: string): Promise<null>;
|
|
30
|
+
sendChangePasswordCode(accessToken?: string): Promise<AuthPasswordResetDispatchResult>;
|
|
31
|
+
changePassword(input: AuthChangePasswordInput, accessToken?: string): Promise<null>;
|
|
22
32
|
}
|
package/dist/auth/client.js
CHANGED
|
@@ -14,6 +14,30 @@ export class AuthClient {
|
|
|
14
14
|
body: input,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
verifyEmail(input) {
|
|
18
|
+
return this.http.request('/api/v1/auth/verify-email', {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body: input,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
resendVerification(input) {
|
|
24
|
+
return this.http.request('/api/v1/auth/resend-verification', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: input,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
forgotPassword(input) {
|
|
30
|
+
return this.http.request('/api/v1/auth/forgot-password', {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: input,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
resetPassword(input) {
|
|
36
|
+
return this.http.request('/api/v1/auth/reset-password', {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
body: input,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
17
41
|
me(accessToken) {
|
|
18
42
|
return this.http.request('/api/v1/auth/me', {
|
|
19
43
|
accessToken,
|
|
@@ -25,4 +49,17 @@ export class AuthClient {
|
|
|
25
49
|
accessToken,
|
|
26
50
|
});
|
|
27
51
|
}
|
|
52
|
+
sendChangePasswordCode(accessToken) {
|
|
53
|
+
return this.http.request('/api/v1/auth/change-password/send-code', {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
accessToken,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
changePassword(input, accessToken) {
|
|
59
|
+
return this.http.request('/api/v1/auth/change-password', {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
body: input,
|
|
62
|
+
accessToken,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
28
65
|
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface AuthUser {
|
|
|
27
27
|
name?: string;
|
|
28
28
|
avatar?: string | null;
|
|
29
29
|
role: 'user' | 'admin' | 'super_admin';
|
|
30
|
+
emailVerified?: boolean;
|
|
31
|
+
emailVerifiedAt?: number | null;
|
|
30
32
|
creditsBalance?: number;
|
|
31
33
|
projectId?: string | null;
|
|
32
34
|
projectName?: string | null;
|
|
@@ -56,6 +58,36 @@ export interface AuthSession {
|
|
|
56
58
|
refreshToken?: string;
|
|
57
59
|
expiresIn?: number;
|
|
58
60
|
}
|
|
61
|
+
export interface AuthRegistrationPending {
|
|
62
|
+
requiresEmailVerification: true;
|
|
63
|
+
email: string;
|
|
64
|
+
verificationExpiresIn: number;
|
|
65
|
+
}
|
|
66
|
+
export type AuthRegisterResult = AuthSession | AuthRegistrationPending;
|
|
67
|
+
export type AuthVerifyEmailInput = {
|
|
68
|
+
token: string;
|
|
69
|
+
} | {
|
|
70
|
+
email: string;
|
|
71
|
+
code: string;
|
|
72
|
+
};
|
|
73
|
+
export interface AuthVerificationDispatchResult {
|
|
74
|
+
email: string;
|
|
75
|
+
verificationExpiresIn: number;
|
|
76
|
+
}
|
|
77
|
+
export interface AuthPasswordResetDispatchResult {
|
|
78
|
+
email: string;
|
|
79
|
+
resetExpiresIn: number;
|
|
80
|
+
}
|
|
81
|
+
export interface AuthResetPasswordInput {
|
|
82
|
+
email: string;
|
|
83
|
+
code: string;
|
|
84
|
+
newPassword: string;
|
|
85
|
+
}
|
|
86
|
+
export interface AuthChangePasswordInput {
|
|
87
|
+
currentPassword: string;
|
|
88
|
+
newPassword: string;
|
|
89
|
+
code: string;
|
|
90
|
+
}
|
|
59
91
|
export interface ProjectSummary {
|
|
60
92
|
id: string;
|
|
61
93
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { ProjectsClient } from './projects/client';
|
|
|
10
10
|
import { UserApiKeysClient } from './user/api-keys-client';
|
|
11
11
|
import { UserSettingsClient } from './user/settings-client';
|
|
12
12
|
export * from './core/errors';
|
|
13
|
-
export type { AdminConfigItem, AdminMembershipFilters, AdminMembershipRecord, AdminModelInput, AdminModelRecord, AdminOrderFilters, AdminOrderRecord, AdminProduct, AdminProductBackfillResult, AdminProductListResult, AdminProject, AdminProjectExportFormat, AdminUserCreditsSummary, AdminUserRecord, AiModelSummary, AuthSession, AuthUser, CreditsBalance, CreditsLedgerItem, MembershipView, OrderDetail, OrderSummary, PaymentCreateResponse, PaymentQueryResponse, PlatformClientOptions, PlatformEnvelope, PlatformRequestOptions, ProductSummary, ProjectSummary, UpdateAdminUserInput, UserApiKeyRecord, UserApiKeySecret, UserSettingDefinition, UserSettingsPayload, } from './core/types';
|
|
13
|
+
export type { AdminConfigItem, AdminMembershipFilters, AdminMembershipRecord, AdminModelInput, AdminModelRecord, AdminOrderFilters, AdminOrderRecord, AdminProduct, AdminProductBackfillResult, AdminProductListResult, AdminProject, AdminProjectExportFormat, AdminUserCreditsSummary, AdminUserRecord, AiModelSummary, AuthChangePasswordInput, AuthPasswordResetDispatchResult, AuthRegisterResult, AuthRegistrationPending, AuthSession, AuthUser, AuthVerificationDispatchResult, AuthVerifyEmailInput, AuthResetPasswordInput, CreditsBalance, CreditsLedgerItem, MembershipView, OrderDetail, OrderSummary, PaymentCreateResponse, PaymentQueryResponse, PlatformClientOptions, PlatformEnvelope, PlatformRequestOptions, ProductSummary, ProjectSummary, UpdateAdminUserInput, UserApiKeyRecord, UserApiKeySecret, UserSettingDefinition, UserSettingsPayload, } from './core/types';
|
|
14
14
|
export declare class BasePlatformClient {
|
|
15
15
|
readonly http: PlatformHttpClient;
|
|
16
16
|
readonly auth: AuthClient;
|