Merge remote-tracking branch 'origin' into identity-based-pricing

This commit is contained in:
Tuan Dang
2024-06-19 14:18:13 -07:00
60 changed files with 2376 additions and 693 deletions
+1
View File
@@ -10,6 +10,7 @@ export type TServerConfig = {
export type TCreateAdminUserDTO = {
email: string;
password: string;
firstName: string;
lastName?: string;
protectedKey: string;
+3 -1
View File
@@ -1,5 +1,6 @@
export {
useGetAuthToken,
useOauthTokenExchange,
useResetPassword,
useSelectOrganization,
useSendMfaToken,
@@ -7,4 +8,5 @@ export {
useSendVerificationEmail,
useVerifyMfaToken,
useVerifyPasswordResetCode,
useVerifySignupEmailVerificationCode} from "./queries";
useVerifySignupEmailVerificationCode
} from "./queries";
+16
View File
@@ -23,6 +23,7 @@ import {
SendMfaTokenDTO,
SRP1DTO,
SRPR1Res,
TOauthTokenExchangeDTO,
VerifyMfaTokenDTO,
VerifyMfaTokenRes,
VerifySignupInviteDTO
@@ -92,6 +93,7 @@ export const useLogin2 = () => {
mutationFn: async (details: {
email: string;
clientProof: string;
password: string;
providerAuthToken?: string;
}) => {
return login2(details);
@@ -99,6 +101,20 @@ export const useLogin2 = () => {
});
};
export const oauthTokenExchange = async (details: TOauthTokenExchangeDTO) => {
const { data } = await apiRequest.post<Login2Res>("/api/v1/sso/token-exchange", details);
return data;
};
export const useOauthTokenExchange = () => {
// note: use after srp1
return useMutation({
mutationFn: async (details: TOauthTokenExchangeDTO) => {
return oauthTokenExchange(details);
}
});
};
export const srp1 = async (details: SRP1DTO) => {
const { data } = await apiRequest.post<SRPR1Res>("/api/v1/password/srp1", details);
return data;
+8
View File
@@ -23,6 +23,11 @@ export type VerifyMfaTokenRes = {
tag: string;
};
export type TOauthTokenExchangeDTO = {
providerAuthToken: string;
email: string;
};
export type Login1DTO = {
email: string;
clientPublicKey: string;
@@ -34,6 +39,7 @@ export type Login2DTO = {
email: string;
clientProof: string;
providerAuthToken?: string;
password: string;
};
export type Login1Res = {
@@ -86,6 +92,7 @@ export type CompleteAccountDTO = {
encryptedPrivateKeyTag: string;
salt: string;
verifier: string;
password: string;
};
export type CompleteAccountSignupDTO = CompleteAccountDTO & {
@@ -101,6 +108,7 @@ export type VerifySignupInviteDTO = {
};
export type ChangePasswordDTO = {
password: string;
clientProof: string;
protectedKey: string;
protectedKeyIV: string;
+9
View File
@@ -20,6 +20,7 @@ import {
export const userKeys = {
getUser: ["user"] as const,
getPrivateKey: ["user"] as const,
userAction: ["user-action"] as const,
getOrgUsers: (orgId: string) => [{ orgId }, "user"],
myIp: ["ip"] as const,
@@ -351,3 +352,11 @@ export const useGetMyOrganizationProjects = (orgId: string) => {
enabled: true
});
};
export const fetchMyPrivateKey = async () => {
const {
data: { privateKey }
} = await apiRequest.get<{ privateKey: string }>("/api/v1/user/private-key");
return privateKey;
};