Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | 83x 83x 83x 83x 83x 83x 83x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x | import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb"; import { BoolValue, StringValue, } from "google-protobuf/google/protobuf/wrappers_pb"; import { ChangeEmailV2Req, ChangeLanguagePreferenceReq, ChangePasswordV2Req, ChangePhoneReq, CreateInviteCodeReq, DeleteAccountReq, DisableInviteCodeReq, FillContributorFormReq, ListActiveSessionsReq, LogOutOtherSessionsReq, LogOutSessionReq, ProfilePublicVisibility, SetProfilePublicVisibilityReq, UpdateMyVolunteerInfoReq, VerifyPhoneReq, } from "proto/account_pb"; import { CompletePasswordResetV2Req, ConfirmChangeEmailV2Req, ContributorForm as ContributorFormPb, ResetPasswordReq, } from "proto/auth_pb"; import { contributorFormFromObject } from "./auth"; import client from "./client"; export async function getAccountInfo() { const res = await client.account.getAccountInfo(new Empty()); return res.toObject(); } export function resetPassword(userId: string) { const req = new ResetPasswordReq(); req.setUser(userId); return client.auth.resetPassword(req); } export function CompletePasswordResetV2( resetToken: string, newPassword: string, ) { const req = new CompletePasswordResetV2Req(); req.setPasswordResetToken(resetToken); req.setNewPassword(newPassword); return client.auth.completePasswordResetV2(req); } export function changePassword(oldPassword: string, newPassword: string) { const req = new ChangePasswordV2Req(); req.setOldPassword(oldPassword); req.setNewPassword(newPassword); return client.account.changePasswordV2(req); } export function changeEmail(newEmail: string, currentPassword: string) { const req = new ChangeEmailV2Req(); req.setNewEmail(newEmail); req.setPassword(currentPassword); return client.account.changeEmailV2(req); } export function changeLanguage(newLanguage: string) { // make a ChangeLanguage request const req = new ChangeLanguagePreferenceReq(); // set the new request language to newLanguage req.setUiLanguagePreference(newLanguage); // return the response return client.account.changeLanguagePreference(req); } export async function confirmChangeEmail(resetToken: string) { const req = new ConfirmChangeEmailV2Req(); req.setChangeEmailToken(resetToken); return client.auth.confirmChangeEmailV2(req); } export async function getContributorFormInfo() { const res = await client.account.getContributorFormInfo(new Empty()); return res.toObject(); } export async function fillContributorForm(form: ContributorFormPb.AsObject) { const res = await client.account.fillContributorForm( new FillContributorFormReq().setContributorForm( contributorFormFromObject(form), ), ); return res.toObject(); } export function deleteAccount(confirm: boolean, reason?: string) { const req = new DeleteAccountReq(); req.setConfirm(confirm); Iif (reason) { req.setReason(reason); } return client.account.deleteAccount(req); } export function changePhone(phone: string) { const req = new ChangePhoneReq(); req.setPhone(phone); return client.account.changePhone(req); } export function removePhone() { const req = new ChangePhoneReq(); req.setPhone(""); return client.account.changePhone(req); } export function verifyPhone(code: string) { const req = new VerifyPhoneReq(); req.setToken(code); return client.account.verifyPhone(req); } export async function listActiveSessions(pageToken?: string) { const req = new ListActiveSessionsReq(); Iif (pageToken) { req.setPageToken(pageToken); } const response = await client.account.listActiveSessions(req); return response.toObject(); } export async function logOutOtherSessions(confirm: boolean) { const req = new LogOutOtherSessionsReq(); req.setConfirm(confirm); const response = await client.account.logOutOtherSessions(req); return response.toObject(); } export async function logOutSession(created: Timestamp.AsObject) { const req = new LogOutSessionReq(); const ts = new Timestamp(); ts.setSeconds(created.seconds); ts.setNanos(created.nanos); req.setCreated(ts); const response = await client.account.logOutSession(req); return response.toObject(); } export async function initiateStrongVerification() { const res = await client.account.initiateStrongVerification(new Empty()); return res.toObject(); } export async function deleteStrongVerificationData() { await client.account.deleteStrongVerificationData(new Empty()); } export function setProfilePublicVisibility(setting: ProfilePublicVisibility) { const req = new SetProfilePublicVisibilityReq(); req.setProfilePublicVisibility(setting); return client.account.setProfilePublicVisibility(req); } export type UpdateVolunteerInfoParams = { [k in keyof UpdateMyVolunteerInfoReq.AsObject]: Required<UpdateMyVolunteerInfoReq.AsObject>[k]["value"]; }; export function updateVolunteerInfo(info: UpdateVolunteerInfoParams) { const req = new UpdateMyVolunteerInfoReq(); Iif (info.showOnTeamPage !== undefined) { req.setShowOnTeamPage(new BoolValue().setValue(info.showOnTeamPage)); } Iif (info.displayName) { req.setDisplayName(new StringValue().setValue(info.displayName)); } Iif (info.displayLocation) { req.setDisplayLocation(new StringValue().setValue(info.displayLocation)); } Iif (info.linkType) { req.setLinkType(new StringValue().setValue(info.linkType)); } Iif (info.linkUrl) { req.setLinkType(new StringValue().setValue(info.linkUrl)); } Iif (info.linkText) { req.setLinkType(new StringValue().setValue(info.linkText)); } return client.account.updateMyVolunteerInfo(req); } export async function getMyVolunteerInfo() { return (await client.account.getMyVolunteerInfo(new Empty())).toObject(); } export async function createInviteCode() { const res = await client.account.createInviteCode(new CreateInviteCodeReq()); return res.toObject(); } export async function disableInviteCode(code: string) { const req = new DisableInviteCodeReq(); req.setCode(code); await client.account.disableInviteCode(req); } export async function listInviteCodes() { const res = await client.account.listInviteCodes(new Empty()); return res.toObject(); } |