@base44-preview/sdk 0.7.3-pr.30.2bc2a1c → 0.7.4-dev.34c1532
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/client.d.ts +44 -0
- package/dist/modules/auth.d.ts +22 -0
- package/dist/modules/auth.js +36 -0
- package/dist/utils/axios-client.js +41 -1
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.js +2 -0
- package/package.json +3 -2
package/dist/client.d.ts
CHANGED
|
@@ -72,6 +72,28 @@ export declare function createClient(config: {
|
|
|
72
72
|
user: any;
|
|
73
73
|
}>;
|
|
74
74
|
isAuthenticated(): Promise<boolean>;
|
|
75
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
+
register(payload: {
|
|
77
|
+
email: string;
|
|
78
|
+
password: string;
|
|
79
|
+
turnstile_token?: string | null;
|
|
80
|
+
referral_code?: string | null;
|
|
81
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
82
|
+
verifyOtp({ email, otpCode }: {
|
|
83
|
+
email: string;
|
|
84
|
+
otpCode: string;
|
|
85
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
86
|
+
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
87
|
+
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
88
|
+
resetPassword({ resetToken, newPassword, }: {
|
|
89
|
+
resetToken: string;
|
|
90
|
+
newPassword: string;
|
|
91
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
92
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
93
|
+
userId: string;
|
|
94
|
+
currentPassword: string;
|
|
95
|
+
newPassword: string;
|
|
96
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
75
97
|
};
|
|
76
98
|
functions: {
|
|
77
99
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -139,6 +161,28 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
139
161
|
user: any;
|
|
140
162
|
}>;
|
|
141
163
|
isAuthenticated(): Promise<boolean>;
|
|
164
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
165
|
+
register(payload: {
|
|
166
|
+
email: string;
|
|
167
|
+
password: string;
|
|
168
|
+
turnstile_token?: string | null;
|
|
169
|
+
referral_code?: string | null;
|
|
170
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
171
|
+
verifyOtp({ email, otpCode }: {
|
|
172
|
+
email: string;
|
|
173
|
+
otpCode: string;
|
|
174
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
175
|
+
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
176
|
+
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
177
|
+
resetPassword({ resetToken, newPassword, }: {
|
|
178
|
+
resetToken: string;
|
|
179
|
+
newPassword: string;
|
|
180
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
181
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
182
|
+
userId: string;
|
|
183
|
+
currentPassword: string;
|
|
184
|
+
newPassword: string;
|
|
185
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
142
186
|
};
|
|
143
187
|
functions: {
|
|
144
188
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -56,4 +56,26 @@ export declare function createAuthModule(axios: AxiosInstance, functionsAxiosCli
|
|
|
56
56
|
* @returns {Promise<boolean>} True if token is valid
|
|
57
57
|
*/
|
|
58
58
|
isAuthenticated(): Promise<boolean>;
|
|
59
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
60
|
+
register(payload: {
|
|
61
|
+
email: string;
|
|
62
|
+
password: string;
|
|
63
|
+
turnstile_token?: string | null;
|
|
64
|
+
referral_code?: string | null;
|
|
65
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
66
|
+
verifyOtp({ email, otpCode }: {
|
|
67
|
+
email: string;
|
|
68
|
+
otpCode: string;
|
|
69
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
70
|
+
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
71
|
+
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
72
|
+
resetPassword({ resetToken, newPassword, }: {
|
|
73
|
+
resetToken: string;
|
|
74
|
+
newPassword: string;
|
|
75
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
77
|
+
userId: string;
|
|
78
|
+
currentPassword: string;
|
|
79
|
+
newPassword: string;
|
|
80
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
59
81
|
};
|
package/dist/modules/auth.js
CHANGED
|
@@ -141,5 +141,41 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
141
141
|
return false;
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
|
+
inviteUser(userEmail, role) {
|
|
145
|
+
return axios.post(`/apps/${appId}/users/invite-user`, {
|
|
146
|
+
user_email: userEmail,
|
|
147
|
+
role,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
register(payload) {
|
|
151
|
+
return axios.post(`/apps/${appId}/auth/register`, payload);
|
|
152
|
+
},
|
|
153
|
+
verifyOtp({ email, otpCode }) {
|
|
154
|
+
return axios.post(`/apps/${appId}/auth/verify-otp`, {
|
|
155
|
+
email,
|
|
156
|
+
otp_code: otpCode,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
resendOtp(email) {
|
|
160
|
+
return axios.post(`/apps/${appId}/auth/resend-otp`, { email });
|
|
161
|
+
},
|
|
162
|
+
resetPasswordRequest(email) {
|
|
163
|
+
return axios.post(`/apps/${appId}/auth/reset-password-request`, {
|
|
164
|
+
email,
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
resetPassword({ resetToken, newPassword, }) {
|
|
168
|
+
return axios.post(`/apps/${appId}/auth/reset-password`, {
|
|
169
|
+
reset_token: resetToken,
|
|
170
|
+
new_password: newPassword,
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
changePassword({ userId, currentPassword, newPassword, }) {
|
|
174
|
+
return axios.post(`/apps/${appId}/auth/change-password`, {
|
|
175
|
+
user_id: userId,
|
|
176
|
+
current_password: currentPassword,
|
|
177
|
+
new_password: newPassword,
|
|
178
|
+
});
|
|
179
|
+
},
|
|
144
180
|
};
|
|
145
181
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { isInIFrame } from "./common";
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
4
|
export class Base44Error extends Error {
|
|
3
5
|
constructor(message, status, code, data, originalError) {
|
|
4
6
|
super(message);
|
|
@@ -82,11 +84,49 @@ export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth =
|
|
|
82
84
|
if (typeof window !== "undefined") {
|
|
83
85
|
config.headers.set("X-Origin-URL", window.location.href);
|
|
84
86
|
}
|
|
87
|
+
if (isInIFrame) {
|
|
88
|
+
const requestId = uuidv4();
|
|
89
|
+
try {
|
|
90
|
+
window.parent.postMessage({
|
|
91
|
+
type: "api-request-start",
|
|
92
|
+
requestId,
|
|
93
|
+
data: {
|
|
94
|
+
url: baseURL + config.url,
|
|
95
|
+
method: config.method,
|
|
96
|
+
body: config.data instanceof FormData
|
|
97
|
+
? "[FormData object]"
|
|
98
|
+
: config.data,
|
|
99
|
+
},
|
|
100
|
+
}, "*");
|
|
101
|
+
}
|
|
102
|
+
catch (_a) {
|
|
103
|
+
/* skip the logging */
|
|
104
|
+
}
|
|
105
|
+
}
|
|
85
106
|
return config;
|
|
86
107
|
});
|
|
87
108
|
// Handle responses
|
|
88
109
|
if (interceptResponses) {
|
|
89
|
-
client.interceptors.response.use((response) =>
|
|
110
|
+
client.interceptors.response.use((response) => {
|
|
111
|
+
var _a;
|
|
112
|
+
const requestId = (_a = response.config) === null || _a === void 0 ? void 0 : _a.requestId;
|
|
113
|
+
try {
|
|
114
|
+
if (isInIFrame && requestId) {
|
|
115
|
+
window.parent.postMessage({
|
|
116
|
+
type: "api-request-end",
|
|
117
|
+
requestId,
|
|
118
|
+
data: {
|
|
119
|
+
statusCode: response.status,
|
|
120
|
+
response: response.data,
|
|
121
|
+
},
|
|
122
|
+
}, "*");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (_b) {
|
|
126
|
+
/* do nothing */
|
|
127
|
+
}
|
|
128
|
+
return response.data;
|
|
129
|
+
}, (error) => {
|
|
90
130
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
91
131
|
const message = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
92
132
|
((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.detail) ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4-dev.34c1532",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"axios": "^1.6.2",
|
|
23
|
-
"socket.io-client": "^4.7.5"
|
|
23
|
+
"socket.io-client": "^4.7.5",
|
|
24
|
+
"uuid": "^13.0.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@vitest/coverage-istanbul": "^1.0.0",
|