Skip to content

Commit

Permalink
Remove unnecessary .label()s
Browse files Browse the repository at this point in the history
  • Loading branch information
xlisachan committed May 19, 2022
1 parent 6a0f4de commit c1c4e92
Show file tree
Hide file tree
Showing 26 changed files with 788 additions and 1,006 deletions.
282 changes: 124 additions & 158 deletions packages/fxa-auth-server/lib/routes/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1579,43 +1579,36 @@ export const accountRoutes = (
keys: isA.boolean().optional().description(DESCRIPTION.keys),
service: validators.service.description(DESCRIPTION.service),
}),
payload: isA
.object({
email: validators
.email()
.required()
.description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
service: validators.service.description(DESCRIPTION.service),
redirectTo: validators
.redirectTo(config.smtp.redirectDomain)
.optional()
.description(DESCRIPTION.redirectTo),
resume: isA
.string()
.max(2048)
.optional()
.description(DESCRIPTION.resume),
metricsContext: METRICS_CONTEXT_SCHEMA,
style: isA.string().allow(['trailhead']).optional(),
verificationMethod: validators.verificationMethod.optional(),
// preVerified is not available in production mode.
...(!(config as any).isProduction && {
preVerified: isA.boolean(),
}),
})
.label('Account.create_payload'),
payload: isA.object({
email: validators.email().required().description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
service: validators.service.description(DESCRIPTION.service),
redirectTo: validators
.redirectTo(config.smtp.redirectDomain)
.optional()
.description(DESCRIPTION.redirectTo),
resume: isA
.string()
.max(2048)
.optional()
.description(DESCRIPTION.resume),
metricsContext: METRICS_CONTEXT_SCHEMA,
style: isA.string().allow(['trailhead']).optional(),
verificationMethod: validators.verificationMethod.optional(),
// preVerified is not available in production mode.
...(!(config as any).isProduction && {
preVerified: isA.boolean(),
}),
}),
},
response: {
schema: isA
.object({
uid: isA.string().regex(HEX_STRING).required(),
sessionToken: isA.string().regex(HEX_STRING).required(),
keyFetchToken: isA.string().regex(HEX_STRING).optional(),
authAt: isA.number().integer().description(DESCRIPTION.authAt),
verificationMethod: validators.verificationMethod.optional(),
})
.label('Account.create_response'),
schema: isA.object({
uid: isA.string().regex(HEX_STRING).required(),
sessionToken: isA.string().regex(HEX_STRING).required(),
keyFetchToken: isA.string().regex(HEX_STRING).optional(),
authAt: isA.number().integer().description(DESCRIPTION.authAt),
verificationMethod: validators.verificationMethod.optional(),
}),
},
},
handler: (request: AuthRequest) => accountHandler.accountCreate(request),
Expand All @@ -1626,13 +1619,11 @@ export const accountRoutes = (
options: {
...MISC_DOCS.ACCOUNT_STUB_POST,
validate: {
payload: isA
.object({
email: validators.email().required(),
clientId: validators.clientId.required(),
metricsContext: METRICS_CONTEXT_SCHEMA,
})
.label('Account.stub_payload'),
payload: isA.object({
email: validators.email().required(),
clientId: validators.clientId.required(),
metricsContext: METRICS_CONTEXT_SCHEMA,
}),
},
},
handler: (request: AuthRequest) => accountHandler.accountStub(request),
Expand All @@ -1643,12 +1634,10 @@ export const accountRoutes = (
options: {
...MISC_DOCS.ACCOUNT_FINISH_SETUP_POST,
validate: {
payload: isA
.object({
token: validators.jwt,
authPW: validators.authPW,
})
.label('Account.finishSetup_payload'),
payload: isA.object({
token: validators.jwt,
authPW: validators.authPW,
}),
},
},
handler: (request: AuthRequest) => accountHandler.finishSetup(request),
Expand Down Expand Up @@ -1677,56 +1666,49 @@ export const accountRoutes = (
.optional()
.description(DESCRIPTION.verificationMethod),
}),
payload: isA
.object({
email: validators
.email()
.required()
.description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
service: validators.service.description(DESCRIPTION.service),
redirectTo: validators
.redirectTo(config.smtp.redirectDomain)
.optional(),
resume: isA.string().optional().description(DESCRIPTION.resume),
reason: isA
.string()
.max(16)
.optional()
.description(DESCRIPTION.reason),
unblockCode: signinUtils.validators.UNBLOCK_CODE.description(
DESCRIPTION.unblockCode
),
metricsContext: METRICS_CONTEXT_SCHEMA,
originalLoginEmail: validators
.email()
.optional()
.description(DESCRIPTION.originalLoginEmail),
verificationMethod: validators.verificationMethod
.optional()
.description(DESCRIPTION.verificationMethod),
})
.label('Account.login_payload'),
payload: isA.object({
email: validators.email().required().description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
service: validators.service.description(DESCRIPTION.service),
redirectTo: validators
.redirectTo(config.smtp.redirectDomain)
.optional(),
resume: isA.string().optional().description(DESCRIPTION.resume),
reason: isA
.string()
.max(16)
.optional()
.description(DESCRIPTION.reason),
unblockCode: signinUtils.validators.UNBLOCK_CODE.description(
DESCRIPTION.unblockCode
),
metricsContext: METRICS_CONTEXT_SCHEMA,
originalLoginEmail: validators
.email()
.optional()
.description(DESCRIPTION.originalLoginEmail),
verificationMethod: validators.verificationMethod
.optional()
.description(DESCRIPTION.verificationMethod),
}),
},
response: {
schema: isA
.object({
uid: isA.string().regex(HEX_STRING).required(),
sessionToken: isA.string().regex(HEX_STRING).required(),
keyFetchToken: isA.string().regex(HEX_STRING).optional(),
verificationMethod: isA
.string()
.optional()
.description(DESCRIPTION.verificationMethod),
verificationReason: isA
.string()
.optional()
.description(DESCRIPTION.verificationReason),
verified: isA.boolean().required(),
authAt: isA.number().integer().description(DESCRIPTION.authAt),
metricsEnabled: isA.boolean().required(),
})
.label('Account.login_response'),
schema: isA.object({
uid: isA.string().regex(HEX_STRING).required(),
sessionToken: isA.string().regex(HEX_STRING).required(),
keyFetchToken: isA.string().regex(HEX_STRING).optional(),
verificationMethod: isA
.string()
.optional()
.description(DESCRIPTION.verificationMethod),
verificationReason: isA
.string()
.optional()
.description(DESCRIPTION.verificationReason),
verified: isA.boolean().required(),
authAt: isA.number().integer().description(DESCRIPTION.authAt),
metricsEnabled: isA.boolean().required(),
}),
},
},
handler: (request: AuthRequest) => accountHandler.login(request),
Expand Down Expand Up @@ -1754,20 +1736,16 @@ export const accountRoutes = (
options: {
...ACCOUNT_DOCS.ACCOUNT_STATUS_POST,
validate: {
payload: isA
.object({
email: validators.email().required(),
checkDomain: isA.optional(),
})
.label('AccountStatusCheck_payload'),
payload: isA.object({
email: validators.email().required(),
checkDomain: isA.optional(),
}),
},
response: {
schema: isA
.object({
exists: isA.boolean().required(),
invalidDomain: isA.boolean().optional(),
})
.label('AccountStausCheck_response'),
schema: isA.object({
exists: isA.boolean().required(),
invalidDomain: isA.boolean().optional(),
}),
},
},
handler: (request: AuthRequest) =>
Expand All @@ -1782,20 +1760,18 @@ export const accountRoutes = (
strategies: ['sessionToken', 'oauthToken'],
},
response: {
schema: isA
.object({
email: isA.string().optional(),
locale: isA.string().optional().allow(null),
authenticationMethods: isA
.array()
.items(isA.string().required())
.optional(),
authenticatorAssuranceLevel: isA.number().min(0),
subscriptionsByClientId: isA.object().unknown(true).optional(),
profileChangedAt: isA.number().min(0),
metricsEnabled: isA.boolean().optional(),
})
.label('Account.profile_response'),
schema: isA.object({
email: isA.string().optional(),
locale: isA.string().optional().allow(null),
authenticationMethods: isA
.array()
.items(isA.string().required())
.optional(),
authenticatorAssuranceLevel: isA.number().min(0),
subscriptionsByClientId: isA.object().unknown(true).optional(),
profileChangedAt: isA.number().min(0),
metricsEnabled: isA.boolean().optional(),
}),
},
},
handler: (request: AuthRequest) => accountHandler.profile(request),
Expand All @@ -1809,14 +1785,12 @@ export const accountRoutes = (
strategy: 'keyFetchTokenWithVerificationStatus',
},
response: {
schema: isA
.object({
bundle: isA
.string()
.regex(HEX_STRING)
.description(DESCRIPTION.bundle),
})
.label('Account.keys_response'),
schema: isA.object({
bundle: isA
.string()
.regex(HEX_STRING)
.description(DESCRIPTION.bundle),
}),
},
},
handler: (request: AuthRequest) => accountHandler.keys(request),
Expand Down Expand Up @@ -1872,8 +1846,7 @@ export const accountRoutes = (
.optional()
.description(DESCRIPTION.sessionToken),
})
.and('wrapKb', 'recoveryKeyId')
.label('Account.reset_payload'),
.and('wrapKb', 'recoveryKeyId'),
},
},
handler: (request: AuthRequest) => accountHandler.reset(request),
Expand All @@ -1888,15 +1861,10 @@ export const accountRoutes = (
strategy: 'sessionToken',
},
validate: {
payload: isA
.object({
email: validators
.email()
.required()
.description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
})
.label('Account.destroy_payload'),
payload: isA.object({
email: validators.email().required().description(DESCRIPTION.email),
authPW: validators.authPW.description(DESCRIPTION.authPW),
}),
},
},
handler: (request: AuthRequest) => accountHandler.destroy(request),
Expand All @@ -1910,23 +1878,21 @@ export const accountRoutes = (
strategy: 'sessionToken',
},
response: {
schema: isA
.object({
// This endpoint is evolving, it's not just for subscriptions.
// Ultimately we want it to become a one-stop shop for all of
// the account data needed by the settings screen, so that we
// can drastically reduce how many requests are made to the
// backend. Discussion in:
//
// https://github.com/mozilla/fxa/issues/1808
subscriptions: isA
.array()
.items(
validators.subscriptionsSubscriptionValidator,
validators.subscriptionsGooglePlaySubscriptionValidator
),
})
.label('Account.subscriptions'),
schema: isA.object({
// This endpoint is evolving, it's not just for subscriptions.
// Ultimately we want it to become a one-stop shop for all of
// the account data needed by the settings screen, so that we
// can drastically reduce how many requests are made to the
// backend. Discussion in:
//
// https://github.com/mozilla/fxa/issues/1808
subscriptions: isA
.array()
.items(
validators.subscriptionsSubscriptionValidator,
validators.subscriptionsGooglePlaySubscriptionValidator
),
}),
},
},
handler: (request: AuthRequest) => accountHandler.getAccount(request),
Expand Down
Loading

0 comments on commit c1c4e92

Please sign in to comment.