Remove custom token generation machinery (#840)
This commit is contained in:
parent
245627a347
commit
d1e1937195
|
@ -1,33 +0,0 @@
|
||||||
import * as admin from 'firebase-admin'
|
|
||||||
import {
|
|
||||||
APIError,
|
|
||||||
EndpointDefinition,
|
|
||||||
lookupUser,
|
|
||||||
parseCredentials,
|
|
||||||
writeResponseError,
|
|
||||||
} from './api'
|
|
||||||
|
|
||||||
const opts = {
|
|
||||||
method: 'GET',
|
|
||||||
minInstances: 1,
|
|
||||||
concurrency: 100,
|
|
||||||
memory: '2GiB',
|
|
||||||
cpu: 1,
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export const getcustomtoken: EndpointDefinition = {
|
|
||||||
opts,
|
|
||||||
handler: async (req, res) => {
|
|
||||||
try {
|
|
||||||
const credentials = await parseCredentials(req)
|
|
||||||
if (credentials.kind != 'jwt') {
|
|
||||||
throw new APIError(403, 'API keys cannot mint custom tokens.')
|
|
||||||
}
|
|
||||||
const user = await lookupUser(credentials)
|
|
||||||
const token = await admin.auth().createCustomToken(user.uid)
|
|
||||||
res.status(200).json({ token: token })
|
|
||||||
} catch (e) {
|
|
||||||
writeResponseError(e, res)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -72,7 +72,6 @@ import { unsubscribe } from './unsubscribe'
|
||||||
import { stripewebhook, createcheckoutsession } from './stripe'
|
import { stripewebhook, createcheckoutsession } from './stripe'
|
||||||
import { getcurrentuser } from './get-current-user'
|
import { getcurrentuser } from './get-current-user'
|
||||||
import { acceptchallenge } from './accept-challenge'
|
import { acceptchallenge } from './accept-challenge'
|
||||||
import { getcustomtoken } from './get-custom-token'
|
|
||||||
import { createpost } from './create-post'
|
import { createpost } from './create-post'
|
||||||
|
|
||||||
const toCloudFunction = ({ opts, handler }: EndpointDefinition) => {
|
const toCloudFunction = ({ opts, handler }: EndpointDefinition) => {
|
||||||
|
@ -98,7 +97,6 @@ const stripeWebhookFunction = toCloudFunction(stripewebhook)
|
||||||
const createCheckoutSessionFunction = toCloudFunction(createcheckoutsession)
|
const createCheckoutSessionFunction = toCloudFunction(createcheckoutsession)
|
||||||
const getCurrentUserFunction = toCloudFunction(getcurrentuser)
|
const getCurrentUserFunction = toCloudFunction(getcurrentuser)
|
||||||
const acceptChallenge = toCloudFunction(acceptchallenge)
|
const acceptChallenge = toCloudFunction(acceptchallenge)
|
||||||
const getCustomTokenFunction = toCloudFunction(getcustomtoken)
|
|
||||||
const createPostFunction = toCloudFunction(createpost)
|
const createPostFunction = toCloudFunction(createpost)
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -122,6 +120,5 @@ export {
|
||||||
createCheckoutSessionFunction as createcheckoutsession,
|
createCheckoutSessionFunction as createcheckoutsession,
|
||||||
getCurrentUserFunction as getcurrentuser,
|
getCurrentUserFunction as getcurrentuser,
|
||||||
acceptChallenge as acceptchallenge,
|
acceptChallenge as acceptchallenge,
|
||||||
getCustomTokenFunction as getcustomtoken,
|
|
||||||
createPostFunction as createpost,
|
createPostFunction as createpost,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import { resolvemarket } from './resolve-market'
|
||||||
import { unsubscribe } from './unsubscribe'
|
import { unsubscribe } from './unsubscribe'
|
||||||
import { stripewebhook, createcheckoutsession } from './stripe'
|
import { stripewebhook, createcheckoutsession } from './stripe'
|
||||||
import { getcurrentuser } from './get-current-user'
|
import { getcurrentuser } from './get-current-user'
|
||||||
import { getcustomtoken } from './get-custom-token'
|
|
||||||
import { createpost } from './create-post'
|
import { createpost } from './create-post'
|
||||||
|
|
||||||
type Middleware = (req: Request, res: Response, next: NextFunction) => void
|
type Middleware = (req: Request, res: Response, next: NextFunction) => void
|
||||||
|
@ -66,7 +65,6 @@ addJsonEndpointRoute('/resolvemarket', resolvemarket)
|
||||||
addJsonEndpointRoute('/unsubscribe', unsubscribe)
|
addJsonEndpointRoute('/unsubscribe', unsubscribe)
|
||||||
addJsonEndpointRoute('/createcheckoutsession', createcheckoutsession)
|
addJsonEndpointRoute('/createcheckoutsession', createcheckoutsession)
|
||||||
addJsonEndpointRoute('/getcurrentuser', getcurrentuser)
|
addJsonEndpointRoute('/getcurrentuser', getcurrentuser)
|
||||||
addEndpointRoute('/getcustomtoken', getcustomtoken)
|
|
||||||
addEndpointRoute('/stripewebhook', stripewebhook, express.raw())
|
addEndpointRoute('/stripewebhook', stripewebhook, express.raw())
|
||||||
addEndpointRoute('/createpost', createpost)
|
addEndpointRoute('/createpost', createpost)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user