@nokori/js-sdk
Advanced tools
Comparing version 1.3.12 to 1.3.13
@@ -0,1 +1,3 @@ | ||
import MailScenarios from '@/enums/MailScenarios'; | ||
declare class BrowserStorage { | ||
@@ -300,2 +302,18 @@ private store; | ||
interface IUser { | ||
userId?: string; | ||
accountId?: string; | ||
firstName?: string; | ||
lastName?: string; | ||
email: string; | ||
hasPassword?: boolean; | ||
verified?: boolean; | ||
createdAt?: string; | ||
updatedAt?: string; | ||
lastLoggedInAt?: string; | ||
} | ||
interface IUserDTO extends IUser { | ||
autoVerify?: boolean; | ||
} | ||
interface nkAPIResponse { | ||
@@ -313,15 +331,22 @@ data: any | null; | ||
refreshServiceToken(token: string): Promise<boolean | null>; | ||
signup(args: any): Promise<nkAPIResponse>; | ||
signup(args: IUserDTO): Promise<nkAPIResponse>; | ||
verifyUser(args: { | ||
verifyToken: string; | ||
}): Promise<nkAPIResponse>; | ||
resendVerificationEmail(args: any): Promise<nkAPIResponse>; | ||
login(args: any): Promise<nkAPIResponse>; | ||
logout(token: string): Promise<nkAPIResponse>; | ||
requestPasswordReset(args: any): Promise<nkAPIResponse>; | ||
resetPassword(args: { | ||
changePassword(args: { | ||
password: string; | ||
userId: string; | ||
token: string; | ||
}): Promise<nkAPIResponse>; | ||
setPassword(args: { | ||
password: string; | ||
userId: string; | ||
}): Promise<nkAPIResponse>; | ||
getUser(userId: string): Promise<nkAPIResponse>; | ||
getUsers(): Promise<nkAPIResponse>; | ||
getSession(args: { | ||
sessionKey: string; | ||
}): Promise<nkAPIResponse>; | ||
refreshSession(token: string): Promise<nkAPIResponse>; | ||
@@ -387,5 +412,6 @@ } | ||
email: string; | ||
password: string; | ||
password?: string; | ||
firstName?: string; | ||
lastName?: string; | ||
autoVerify?: boolean; | ||
}): Promise<{ | ||
@@ -407,9 +433,2 @@ data: null; | ||
}>; | ||
resendVerificationEmail(args: any): Promise<{ | ||
data: null; | ||
error: Error | null; | ||
} | { | ||
data: any; | ||
error: null; | ||
}>; | ||
login(args: any): Promise<{ | ||
@@ -438,3 +457,7 @@ error: Error | null; | ||
}>; | ||
requestPasswordReset(args: any): Promise<{ | ||
changePassword(args: { | ||
password: string; | ||
userId: string; | ||
token: string; | ||
}): Promise<{ | ||
data: null; | ||
@@ -446,3 +469,6 @@ error: Error | null; | ||
}>; | ||
resetPassword(args: any): Promise<{ | ||
setPassword(args: { | ||
password: string; | ||
userId: string; | ||
}): Promise<{ | ||
data: null; | ||
@@ -465,2 +491,9 @@ error: Error | null; | ||
}>; | ||
getUsers(): Promise<{ | ||
data: any; | ||
error: null; | ||
} | { | ||
data: null; | ||
error: unknown; | ||
}>; | ||
isAuthenticated(): Promise<{ | ||
@@ -591,2 +624,3 @@ data: null; | ||
interface SendMailRequestDTO { | ||
scenario?: MailScenarios | ||
templateId: string | ||
@@ -593,0 +627,0 @@ settings: { |
@@ -730,5 +730,5 @@ var __defProp = Object.defineProperty; | ||
} | ||
async resendVerificationEmail(args) { | ||
async login(args) { | ||
try { | ||
const result = await this.httpService.put(`${this.resource}/verify/resend/${args.verifyRequestToken}`); | ||
const result = await this.httpService.post(`${this.resource}/login`, args); | ||
if (result.status === "error") | ||
@@ -752,5 +752,5 @@ return { | ||
} | ||
async login(args) { | ||
async logout(token) { | ||
try { | ||
const result = await this.httpService.post(`${this.resource}/login`, args); | ||
const result = await this.httpService.get(`${this.resource}/logout?token=${token}`); | ||
if (result.status === "error") | ||
@@ -774,5 +774,8 @@ return { | ||
} | ||
async logout(token) { | ||
async changePassword(args) { | ||
try { | ||
const result = await this.httpService.get(`${this.resource}/logout?token=${token}`); | ||
const { password, userId, token } = args; | ||
const result = await this.httpService.put(`${this.resource}/users/${userId}/password?token=${token}`, { | ||
password | ||
}); | ||
if (result.status === "error") | ||
@@ -796,5 +799,8 @@ return { | ||
} | ||
async requestPasswordReset(args) { | ||
async setPassword(args) { | ||
try { | ||
const result = await this.httpService.post(`${this.resource}/password-reset-request`, args); | ||
const { password, userId } = args; | ||
const result = await this.httpService.post(`${this.resource}/users/${userId}/password`, { | ||
password | ||
}); | ||
if (result.status === "error") | ||
@@ -818,8 +824,5 @@ return { | ||
} | ||
async resetPassword(args) { | ||
async getUser(userId) { | ||
try { | ||
const { token, password } = args; | ||
const result = await this.httpService.post(`${this.resource}/password-reset?token=${token}`, { | ||
password | ||
}); | ||
const result = await this.httpService.get(`${this.resource}/users/${userId}`); | ||
if (result.status === "error") | ||
@@ -843,5 +846,5 @@ return { | ||
} | ||
async getUser(userId) { | ||
async getUsers() { | ||
try { | ||
const result = await this.httpService.get(`${this.resource}/users/${userId}`); | ||
const result = await this.httpService.get(`${this.resource}/users`); | ||
if (result.status === "error") | ||
@@ -865,2 +868,23 @@ return { | ||
} | ||
async getSession(args) { | ||
try { | ||
const result = await this.httpService.get(`${this.resource}/sessions/${args.sessionKey}`); | ||
if (result.status === "error") | ||
return { | ||
data: null, | ||
error: result, | ||
statusCode: result.statusCode | ||
}; | ||
return { | ||
data: result.data, | ||
error: null, | ||
statusCode: result.statusCode | ||
}; | ||
} catch (error) { | ||
return { | ||
data: null, | ||
error | ||
}; | ||
} | ||
} | ||
async refreshSession(token) { | ||
@@ -978,14 +1002,2 @@ try { | ||
} | ||
async resendVerificationEmail(args) { | ||
const { data, error } = await this.api.resendVerificationEmail(args); | ||
if (!data) | ||
return { | ||
data: null, | ||
error | ||
}; | ||
return { | ||
data, | ||
error: null | ||
}; | ||
} | ||
async login(args) { | ||
@@ -1039,4 +1051,4 @@ this._removeSession(); | ||
} | ||
async requestPasswordReset(args) { | ||
const { data, error } = await this.api.requestPasswordReset(args); | ||
async changePassword(args) { | ||
const { data, error } = await this.api.changePassword(args); | ||
if (!data) | ||
@@ -1052,4 +1064,4 @@ return { | ||
} | ||
async resetPassword(args) { | ||
const { data, error } = await this.api.resetPassword(args); | ||
async setPassword(args) { | ||
const { data, error } = await this.api.setPassword(args); | ||
if (!data) | ||
@@ -1109,2 +1121,21 @@ return { | ||
} | ||
async getUsers() { | ||
try { | ||
const { data, error } = await this.api.getUsers(); | ||
if (!data) | ||
return { | ||
data: null, | ||
error | ||
}; | ||
return { | ||
data, | ||
error: null | ||
}; | ||
} catch (error1) { | ||
return { | ||
data: null, | ||
error: error1 | ||
}; | ||
} | ||
} | ||
async isAuthenticated() { | ||
@@ -1111,0 +1142,0 @@ const data = this.storage.getSync(storage_enum_default.STORAGE_KEY); |
{ | ||
"name": "@nokori/js-sdk", | ||
"version": "1.3.12", | ||
"version": "1.3.13", | ||
"description": "nokori Node.JS js/ts sdk", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
559176
17873