Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/responders/user-responders.js
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | import { | ||||
updateUserAvatar, | updateUserAvatar, | ||||
} from '../updaters/account-updaters.js'; | } from '../updaters/account-updaters.js'; | ||||
import { userSubscriptionUpdater } from '../updaters/user-subscription-updaters.js'; | import { userSubscriptionUpdater } from '../updaters/user-subscription-updaters.js'; | ||||
import { viewerAcknowledgmentUpdater } from '../updaters/viewer-acknowledgment-updater.js'; | import { viewerAcknowledgmentUpdater } from '../updaters/viewer-acknowledgment-updater.js'; | ||||
import { getOlmUtility } from '../utils/olm-utils.js'; | import { getOlmUtility } from '../utils/olm-utils.js'; | ||||
import { validateInput, validateOutput } from '../utils/validation-utils.js'; | import { validateInput, validateOutput } from '../utils/validation-utils.js'; | ||||
const subscriptionUpdateRequestInputValidator = tShape({ | const subscriptionUpdateRequestInputValidator = tShape({ | ||||
threadID: t.String, | threadID: tID, | ||||
updatedFields: tShape({ | updatedFields: tShape({ | ||||
pushNotifs: t.maybe(t.Boolean), | pushNotifs: t.maybe(t.Boolean), | ||||
home: t.maybe(t.Boolean), | home: t.maybe(t.Boolean), | ||||
}), | }), | ||||
}); | }); | ||||
export const subscriptionUpdateResponseValidator: TInterface<SubscriptionUpdateResponse> = | export const subscriptionUpdateResponseValidator: TInterface<SubscriptionUpdateResponse> = | ||||
tShape<SubscriptionUpdateResponse>({ | tShape<SubscriptionUpdateResponse>({ | ||||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | ): Promise<LogInResponse> { | ||||
} | } | ||||
return response; | return response; | ||||
} | } | ||||
const logInRequestInputValidator = tShape({ | const logInRequestInputValidator = tShape({ | ||||
username: t.maybe(t.String), | username: t.maybe(t.String), | ||||
usernameOrEmail: t.maybe(t.union([tEmail, tOldValidUsername])), | usernameOrEmail: t.maybe(t.union([tEmail, tOldValidUsername])), | ||||
password: tPassword, | password: tPassword, | ||||
watchedIDs: t.list(t.String), | watchedIDs: t.list(tID), | ||||
calendarQuery: t.maybe(entryQueryInputValidator), | calendarQuery: t.maybe(entryQueryInputValidator), | ||||
deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | ||||
platformDetails: tPlatformDetails, | platformDetails: tPlatformDetails, | ||||
source: t.maybe(t.enums.of(values(logInActionSources))), | source: t.maybe(t.enums.of(values(logInActionSources))), | ||||
// We include `primaryIdentityPublicKey` to avoid breaking | // We include `primaryIdentityPublicKey` to avoid breaking | ||||
// old clients, but we no longer do anything with it. | // old clients, but we no longer do anything with it. | ||||
primaryIdentityPublicKey: t.maybe(tRegex(primaryIdentityPublicKeyRegex)), | primaryIdentityPublicKey: t.maybe(tRegex(primaryIdentityPublicKeyRegex)), | ||||
signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), | signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
const siweAuthRequestInputValidator = tShape({ | const siweAuthRequestInputValidator = tShape({ | ||||
signature: t.String, | signature: t.String, | ||||
message: t.String, | message: t.String, | ||||
calendarQuery: entryQueryInputValidator, | calendarQuery: entryQueryInputValidator, | ||||
deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | ||||
platformDetails: tPlatformDetails, | platformDetails: tPlatformDetails, | ||||
watchedIDs: t.list(t.String), | watchedIDs: t.list(tID), | ||||
signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), | signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), | ||||
}); | }); | ||||
async function siweAuthResponder( | async function siweAuthResponder( | ||||
viewer: Viewer, | viewer: Viewer, | ||||
input: any, | input: any, | ||||
): Promise<LogInResponse> { | ): Promise<LogInResponse> { | ||||
await validateInput(viewer, siweAuthRequestInputValidator, input); | await validateInput(viewer, siweAuthRequestInputValidator, input); | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | const response = await processSuccessfulLogin({ | ||||
signedIdentityKeysBlob, | signedIdentityKeysBlob, | ||||
}); | }); | ||||
return validateOutput(viewer, logInResponseValidator, response); | return validateOutput(viewer, logInResponseValidator, response); | ||||
} | } | ||||
const updatePasswordRequestInputValidator = tShape({ | const updatePasswordRequestInputValidator = tShape({ | ||||
code: t.String, | code: t.String, | ||||
password: tPassword, | password: tPassword, | ||||
watchedIDs: t.list(t.String), | watchedIDs: t.list(tID), | ||||
calendarQuery: t.maybe(entryQueryInputValidator), | calendarQuery: t.maybe(entryQueryInputValidator), | ||||
deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | deviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator), | ||||
platformDetails: tPlatformDetails, | platformDetails: tPlatformDetails, | ||||
}); | }); | ||||
async function oldPasswordUpdateResponder( | async function oldPasswordUpdateResponder( | ||||
viewer: Viewer, | viewer: Viewer, | ||||
input: any, | input: any, | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |