diff --git a/packages/access-api/src/index.js b/packages/access-api/src/index.js
index b67819f83..46f318360 100644
--- a/packages/access-api/src/index.js
+++ b/packages/access-api/src/index.js
@@ -4,7 +4,7 @@ import { notFound } from '@web3-storage/worker-utils/response'
import { Router } from '@web3-storage/worker-utils/router'
import { postRaw } from './routes/raw.js'
import { postRoot } from './routes/root.js'
-import { validateEmail } from './routes/validate-email.js'
+import { preValidateEmail, validateEmail } from './routes/validate-email.js'
import { validateWS } from './routes/validate-ws.js'
import { version } from './routes/version.js'
import { getContext } from './utils/context.js'
@@ -14,7 +14,8 @@ const r = new Router({ onNotFound: notFound })
r.add('options', '*', preflight)
r.add('get', '/version', version)
-r.add('get', '/validate-email', validateEmail)
+r.add('get', '/validate-email', preValidateEmail)
+r.add('post', '/validate-email', validateEmail)
r.add('get', '/validate-ws', validateWS)
r.add('post', '/', postRoot)
r.add('post', '/raw', postRaw)
diff --git a/packages/access-api/src/routes/validate-email.js b/packages/access-api/src/routes/validate-email.js
index 3da06bce7..bb91b696f 100644
--- a/packages/access-api/src/routes/validate-email.js
+++ b/packages/access-api/src/routes/validate-email.js
@@ -6,8 +6,23 @@ import {
HtmlResponse,
ValidateEmail,
ValidateEmailError,
+ PendingValidateEmail,
} from '../utils/html.js'
+/**
+ * @param {import('@web3-storage/worker-utils/router').ParsedRequest} req
+ * @param {import('../bindings.js').RouteContext} env
+ */
+export async function preValidateEmail(req, env) {
+ if (!req.query?.ucan) {
+ return new HtmlResponse(
+
+ )
+ }
+
+ return new HtmlResponse()
+}
+
/**
* @param {import('@web3-storage/worker-utils/router').ParsedRequest} req
* @param {import('../bindings.js').RouteContext} env
diff --git a/packages/access-api/src/utils/html.js b/packages/access-api/src/utils/html.js
index 9db97041b..56814b4b8 100644
--- a/packages/access-api/src/utils/html.js
+++ b/packages/access-api/src/utils/html.js
@@ -95,6 +95,40 @@ export class HtmlResponse extends Response {
}
}
+/**
+ *
+ * @param {object} props
+ * @param {boolean} [props.autoApprove]
+ */
+export const PendingValidateEmail = ({ autoApprove }) => (
+
+
+
+
Validating Email
+
+ {autoApprove ? (
+
+ ) : undefined}
+
+
+)
+
/**
*
* @param {object} param0
diff --git a/packages/access-api/test/access-authorize.test.js b/packages/access-api/test/access-authorize.test.js
index 4ed890713..a4ec35d6d 100644
--- a/packages/access-api/test/access-authorize.test.js
+++ b/packages/access-api/test/access-authorize.test.js
@@ -88,7 +88,7 @@ describe('access/authorize', function () {
/** @type {import('@web3-storage/access/types').EncodedDelegation<[import('@web3-storage/capabilities/types').AccessSession]>} */ (
url.searchParams.get('ucan')
)
- const rsp = await mf.dispatchFetch(url)
+ const rsp = await mf.dispatchFetch(url, { method: 'POST' })
const html = await rsp.text()
assert(html.includes(encoded))
@@ -119,7 +119,7 @@ describe('access/authorize', function () {
const url = new URL(inv)
// click email url
- await mf.dispatchFetch(url)
+ await mf.dispatchFetch(url, { method: 'POST' })
// ws
const res = await mf.dispatchFetch('http://localhost:8787/validate-ws', {
diff --git a/packages/access-api/test/space-recover.test.js b/packages/access-api/test/space-recover.test.js
index 3545a8578..391c720f9 100644
--- a/packages/access-api/test/space-recover.test.js
+++ b/packages/access-api/test/space-recover.test.js
@@ -68,7 +68,7 @@ describe('space-recover', function () {
assert.deepEqual(del.audience.did(), issuer.did())
assert.deepEqual(del.issuer.did(), service.did())
assert.deepEqual(del.capabilities[0].can, 'space/recover')
- const rsp = await mf.dispatchFetch(url)
+ const rsp = await mf.dispatchFetch(url, { method: 'POST' })
const html = await rsp.text()
assert(html.includes(encoded))