From 19032140691806e07cf3b013e2afaeb01d6d8459 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Thu, 4 Apr 2024 14:58:20 -0700 Subject: [PATCH] feat: NFT.storage changes (#2560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make all (most?) of the requested changes from https://github.com/orgs/w3s-project/projects/1/views/1?pane=issue&itemId=57594940 Note that once this PR is deployed, new user signups will be disabled - I did not put these behind a feature flag as there doesn't seem to be a strong need for one. A few caveats: 1) I put the same banner at the top of every page - since the menu is in the global layout it's tricky to get different banners displaying on different pages. This means that the requests to have different pages link to different URLs are challenging to accommodate, so I've gone down the easy path. 2) The error message for new users is a little janky - I followed the letter of the request but it's not terribly pretty: Screenshot 2024-04-04 at 12 28 33 PM We could make this prettier but it's nontrivial work, so I'm proposing we ship with this and iterate but would be open to iterating before we ship. --- packages/api/src/errors.js | 24 + packages/api/src/utils/auth.js | 13 + .../website/components/deprecationBanner.js | 10 + packages/website/components/footer.js | 10 + packages/website/components/layout.js | 2 + packages/website/pages/files.js | 10 +- packages/website/pages/privacy.js | 672 ++++++++++++++++++ packages/website/pages/terms.js | 44 +- 8 files changed, 745 insertions(+), 40 deletions(-) create mode 100644 packages/website/components/deprecationBanner.js create mode 100644 packages/website/pages/privacy.js diff --git a/packages/api/src/errors.js b/packages/api/src/errors.js index 3458703967..0672eca40c 100644 --- a/packages/api/src/errors.js +++ b/packages/api/src/errors.js @@ -284,3 +284,27 @@ export class ErrorAgentDIDRequired extends HTTPError { } } ErrorAgentDIDRequired.CODE = 'ERROR_AGENT_DID_REQUIRED' + +/** + * Error indicating a new user signup was denied and probably will be indefinitely, + * and the user should try a new product instead. + */ +export class NewUserDeniedTryOtherProductError extends HTTPError { + /** + * @param {string} message + * @param {URL} otherProduct + */ + constructor(message, otherProduct) { + super(message, 403) + this.code = 'NEW_USER_DENIED_TRY_OTHER_PRODUCT' + this.otherProduct = otherProduct + } + + toJSON() { + return { + message: this.message, + code: this.code, + otherProduct: this.otherProduct.toString(), + } + } +} diff --git a/packages/api/src/utils/auth.js b/packages/api/src/utils/auth.js index 70f753cc74..70a9e7ae0f 100644 --- a/packages/api/src/utils/auth.js +++ b/packages/api/src/utils/auth.js @@ -7,6 +7,7 @@ import { ErrorUnauthenticated, ErrorTokenBlocked, ErrorAgentDIDRequired, + NewUserDeniedTryOtherProductError, } from '../errors.js' import { parseJWT, verifyJWT } from './jwt.js' import * as Ucan from 'ucan-storage/ucan-storage' @@ -137,6 +138,18 @@ export async function loginOrRegister(event, data, { db }) { ? await parseGithub(data.data, metadata) : parseMagic(metadata) + const dbUser = + data.type === 'github' + ? await db.getUser(parsed.sub) + : await db.getUser(parsed.issuer) + if (!dbUser) { + const otherProduct = new URL('https://nft.storage/') + throw new NewUserDeniedTryOtherProductError( + `We're no longer accepting new accounts for NFT.Storage Classic. Learn more about our new experience>> ${otherProduct.toString()}`, + otherProduct + ) + } + const upsert = await db.upsertUser({ email: parsed.email, github_id: parsed.sub, diff --git a/packages/website/components/deprecationBanner.js b/packages/website/components/deprecationBanner.js new file mode 100644 index 0000000000..200b86b109 --- /dev/null +++ b/packages/website/components/deprecationBanner.js @@ -0,0 +1,10 @@ +export function DeprecationBanner() { + return ( +
+ We're evolving our platform for you. Learn more >>  + + https://nft.storage/blog/the-next-chapter-of-nftstorage + +
+ ) +} diff --git a/packages/website/components/footer.js b/packages/website/components/footer.js index 07fdec4053..1e293df342 100644 --- a/packages/website/components/footer.js +++ b/packages/website/components/footer.js @@ -105,6 +105,16 @@ export default function Footer() { + + + Privacy + + + Need Help? { let bannerMessage = '' @@ -133,6 +134,7 @@ export default function Layout({ ) : ( <> +
{children({ user })}