@sethub/sdk
Version:
<div align="center"> <h1> SetHub SDK </h1>
45 lines (44 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Authentication = void 0;
class Authentication {
constructor(httpClient) {
this.httpClient = httpClient;
}
async signInWithEmailAndPassword(input, options) {
const { email, password } = input;
const response = await this.httpClient.post('/v1/auth/login', {
email,
password
}, options);
if (!response.ok) {
return {
data: null,
error: response.body
};
}
const apiResponseBody = response.body;
const parsedResponsBody = {
accessToken: apiResponseBody.access_token,
refreshToken: apiResponseBody.refresh_token
};
return {
data: parsedResponsBody,
error: null
};
}
async signUp(input, options) {
const response = await this.httpClient.post('/v1/auth/sign-up', input, options);
if (!response.ok) {
return {
data: null,
error: response.body
};
}
return {
data: response.body,
error: null
};
}
}
exports.Authentication = Authentication;