From a5e10b286f28e367c91c64108e0fcb7d29389d55 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Thu, 25 Apr 2024 16:49:17 -0700 Subject: [PATCH 1/6] feat: implement "create admin session" capability TODO - [ ] add tests --- package-lock.json | 161 +++++------------- upload-api/billing.js | 28 ++- .../functions/ucan-invocation-router.js | 2 +- upload-api/package.json | 2 +- upload-api/stores/plans.js | 4 +- upload-api/test/billing.test.js | 11 +- upload-api/types.ts | 3 +- 7 files changed, 80 insertions(+), 131 deletions(-) diff --git a/package-lock.json b/package-lock.json index b27e57b9..68404f81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,42 @@ "typescript": "^4.9.3" } }, + "../w3up/packages/upload-api": { + "version": "10.0.1", + "dependencies": { + "@ucanto/client": "^9.0.1", + "@ucanto/interface": "^10.0.1", + "@ucanto/principal": "^9.0.1", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "@ucanto/validator": "^9.0.2", + "@web3-storage/access": "workspace:^", + "@web3-storage/capabilities": "workspace:^", + "@web3-storage/content-claims": "^4.0.4", + "@web3-storage/did-mailto": "workspace:^", + "@web3-storage/filecoin-api": "workspace:^", + "multiformats": "^12.1.2", + "p-retry": "^5.1.2", + "uint8arrays": "^5.0.3" + }, + "devDependencies": { + "@ipld/car": "^5.1.1", + "@ipld/dag-ucan": "^3.4.0", + "@types/mocha": "^10.0.1", + "@ucanto/core": "^10.0.1", + "@web-std/blob": "^3.0.5", + "@web3-storage/eslint-config-w3up": "workspace:^", + "@web3-storage/sigv4": "^1.0.2", + "is-subset": "^0.1.1", + "mocha": "^10.2.0", + "one-webcrypto": "git://github.com/web3-storage/one-webcrypto", + "p-defer": "^4.0.1", + "typescript": "5.2.2" + }, + "engines": { + "node": ">=16.15" + } + }, "billing": { "name": "@web3-storage/w3infra-billing", "version": "0.0.0", @@ -5924,127 +5960,8 @@ } }, "node_modules/@web3-storage/upload-api": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@web3-storage/upload-api/-/upload-api-10.0.0.tgz", - "integrity": "sha512-aYC7iFv+WJt8rEDjkptZNvL03oo3g9xatm3PqcZPb9kOIIsoKrUjx1DUP3IsOZv3jTjeuhgGY+hzFWsg8ZII4Q==", - "dependencies": { - "@ucanto/client": "^9.0.1", - "@ucanto/interface": "^10.0.1", - "@ucanto/principal": "^9.0.1", - "@ucanto/server": "^10.0.0", - "@ucanto/transport": "^9.1.1", - "@ucanto/validator": "^9.0.2", - "@web3-storage/access": "^18.3.1", - "@web3-storage/capabilities": "^14.0.0", - "@web3-storage/content-claims": "^4.0.4", - "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/filecoin-api": "^5.0.0", - "multiformats": "^12.1.2", - "p-retry": "^5.1.2", - "uint8arrays": "^5.0.3" - }, - "engines": { - "node": ">=16.15" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/@types/retry": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", - "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" - }, - "node_modules/@web3-storage/upload-api/node_modules/@ucanto/server": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@ucanto/server/-/server-10.0.0.tgz", - "integrity": "sha512-JMDMT3tFRE0S1cdtx/Hhh7v9FizV6IS0fPrh6pcli7AzKvXVy8Xu6EQ/66Fax4AQM2tkGxNNxjj2wHM7P4CqAg==", - "dependencies": { - "@ucanto/core": "^10.0.0", - "@ucanto/interface": "^10.0.0", - "@ucanto/principal": "^9.0.0", - "@ucanto/validator": "^9.0.1" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/@web3-storage/capabilities": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@web3-storage/capabilities/-/capabilities-14.0.0.tgz", - "integrity": "sha512-i57wEzIjBsz5iCdBJJZCCAN/j0Vknns2NDFEpV732Vo/VxW2PbYqVb0eqEKegDwxdAmkZwyTT6iZQfsebgK7hw==", - "dependencies": { - "@ucanto/core": "^10.0.1", - "@ucanto/interface": "^10.0.1", - "@ucanto/principal": "^9.0.1", - "@ucanto/transport": "^9.1.1", - "@ucanto/validator": "^9.0.2", - "@web3-storage/data-segment": "^3.2.0", - "uint8arrays": "^5.0.3" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/@web3-storage/content-claims": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@web3-storage/content-claims/-/content-claims-4.0.4.tgz", - "integrity": "sha512-zt5psR3SkLbPPHzGzhFXYSJEssDl/ELYbNhEez+tNZLZiagv3Vl0RSt+x3CFFgR5ovO6Zn+pLJJcMjpMiHw0Yw==", - "dependencies": { - "@ucanto/client": "^9.0.1", - "@ucanto/interface": "^10.0.0", - "@ucanto/server": "^10.0.0", - "@ucanto/transport": "^9.1.1", - "carstream": "^1.0.2", - "multiformats": "^12.0.1" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/@web3-storage/data-segment": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@web3-storage/data-segment/-/data-segment-3.2.0.tgz", - "integrity": "sha512-SM6eNumXzrXiQE2/J59+eEgCRZNYPxKhRoHX2QvV3/scD4qgcf4g+paWBc3UriLEY1rCboygGoPsnqYJNyZyfA==", - "dependencies": { - "@ipld/dag-cbor": "^9.0.5", - "multiformats": "^11.0.2", - "sync-multihash-sha2": "^1.0.0" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/@web3-storage/data-segment/node_modules/multiformats": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-11.0.2.tgz", - "integrity": "sha512-b5mYMkOkARIuVZCpvijFj9a6m5wMVLC7cf/jIPd5D/ARDOfLC5+IFkbgDXQgcU2goIsTD/O9NY4DI/Mt4OGvlg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/multiformats": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", - "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/p-retry": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-5.1.2.tgz", - "integrity": "sha512-couX95waDu98NfNZV+i/iLt+fdVxmI7CbrrdC2uDWfPdUAApyxT4wmDlyOtR5KtTDmkDO0zDScDjDou9YHhd9g==", - "dependencies": { - "@types/retry": "0.12.1", - "retry": "^0.13.1" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/uint8arrays": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.0.3.tgz", - "integrity": "sha512-6LBuKji28kHjgPJMkQ6GDaBb1lRwIhyOYq6pDGwYMoDPfImE9SkuYENVmR0yu9yGgs2clHUSY9fKDukR+AXfqQ==", - "dependencies": { - "multiformats": "^13.0.0" - } - }, - "node_modules/@web3-storage/upload-api/node_modules/uint8arrays/node_modules/multiformats": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", - "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" + "resolved": "../w3up/packages/upload-api", + "link": true }, "node_modules/@web3-storage/upload-client": { "version": "13.0.1", @@ -18412,7 +18329,7 @@ "@web3-storage/access": "^18.3.1", "@web3-storage/capabilities": "^14.0.0", "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/upload-api": "^10.0.0", + "@web3-storage/upload-api": "file:../../w3up/packages/upload-api", "multiformats": "^13.1.0", "nanoid": "^5.0.2", "preact": "^10.14.1", diff --git a/upload-api/billing.js b/upload-api/billing.js index ded7a189..851d6edb 100644 --- a/upload-api/billing.js +++ b/upload-api/billing.js @@ -35,10 +35,11 @@ export class BillingProviderUpdateError extends Failure { /** * - * @param {import('stripe').Stripe} stripe + * @param {import('stripe').Stripe} stripe + * @param {import("@web3-storage/w3infra-billing/lib/api").CustomerStore} customerStore * @returns {import("./types").BillingProvider} */ -export function createStripeBillingProvider(stripe) { +export function createStripeBillingProvider(stripe, customerStore) { return { async hasCustomer(customer) { const customersResponse = await stripe.customers.list({ email: toEmail(/** @type {import('@web3-storage/did-mailto').DidMailto} */(customer)) }) @@ -84,6 +85,29 @@ export function createStripeBillingProvider(stripe) { } catch (/** @type {any} */ err) { return { error: new BillingProviderUpdateError(err.message, { cause: err }) } } + }, + + async createAdminSession(account, returnURL) { + const response = await customerStore.get({ customer: account }) + if (response.error) { + return { + error: { + name: 'CustomerNotFound', + message: 'Error getting customer', + cause: response.error + } + } + } + const customer = response.ok.account.slice('stripe:'.length) + const session = await stripe.billingPortal.sessions.create({ + customer, + return_url: returnURL + }) + return { + ok: { + url: session.url + } + } } } } \ No newline at end of file diff --git a/upload-api/functions/ucan-invocation-router.js b/upload-api/functions/ucan-invocation-router.js index 5cdb8be3..8c8a9cf6 100644 --- a/upload-api/functions/ucan-invocation-router.js +++ b/upload-api/functions/ucan-invocation-router.js @@ -183,7 +183,7 @@ export async function ucanInvocationRouter(request) { const customerStore = createCustomerStore({ region: AWS_REGION }, { tableName: customerTableName }) if (!STRIPE_SECRET_KEY) throw new Error('missing secret: STRIPE_SECRET_KEY') const stripe = new Stripe(STRIPE_SECRET_KEY, { apiVersion: '2023-10-16' }) - const plansStorage = usePlansStore(customerStore, createStripeBillingProvider(stripe)) + const plansStorage = usePlansStore(customerStore, createStripeBillingProvider(stripe, customerStore)) const rateLimitsStorage = createRateLimitTable(AWS_REGION, rateLimitTableName) const spaceMetricsTable = createSpaceMetricsTable(AWS_REGION, spaceMetricsTableName) diff --git a/upload-api/package.json b/upload-api/package.json index 436c1e1f..743ec8f2 100644 --- a/upload-api/package.json +++ b/upload-api/package.json @@ -25,7 +25,7 @@ "@web3-storage/access": "^18.3.1", "@web3-storage/capabilities": "^14.0.0", "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/upload-api": "^10.0.0", + "@web3-storage/upload-api": "file:../../w3up/packages/upload-api", "multiformats": "^13.1.0", "nanoid": "^5.0.2", "preact": "^10.14.1", diff --git a/upload-api/stores/plans.js b/upload-api/stores/plans.js index 9bea792f..eb668ab7 100644 --- a/upload-api/stores/plans.js +++ b/upload-api/stores/plans.js @@ -88,6 +88,8 @@ export function usePlansStore(customerStore, billingProvider) { } } return { ok: {} } - } + }, + + createAdminSession: async (account, returnURL) => billingProvider.createAdminSession(account, returnURL) } } \ No newline at end of file diff --git a/upload-api/test/billing.test.js b/upload-api/test/billing.test.js index f6b6e557..f418484c 100644 --- a/upload-api/test/billing.test.js +++ b/upload-api/test/billing.test.js @@ -5,6 +5,8 @@ import dotenv from 'dotenv' import Stripe from 'stripe' import { fileURLToPath } from 'node:url' +import { createCustomerStore, customerTableProps } from '@web3-storage/w3infra-billing/tables/customer.js' +import { createTable } from './helpers/resources.js' dotenv.config({ path: fileURLToPath(new URL('../../.env', import.meta.url)) }) @@ -51,8 +53,11 @@ async function setupCustomer(stripe, email) { test('stripe plan can be updated', async (t) => { const stripeSecretKey = process.env.STRIPE_TEST_SECRET_KEY if (stripeSecretKey) { + const stripe = new Stripe(stripeSecretKey, { apiVersion: '2023-10-16' }) - const billingProvider = createStripeBillingProvider(stripe) + const { dynamo } = t.context + const customerStore = createCustomerStore(dynamo, {tableName: await createTable(dynamo, customerTableProps}) + const billingProvider = createStripeBillingProvider(stripe, customerStore) const customerDID = /** @type {import('@web3-storage/did-mailto').DidMailto} */( `did:mailto:example.com:w3up-billing-test-${Date.now()}` ) @@ -63,14 +68,14 @@ test('stripe plan can be updated', async (t) => { const prices = await stripe.prices.list({ lookup_keys: [initialPlan] }) const initialPriceID = prices.data.find(price => price.lookup_key === initialPlan)?.id - if (!initialPriceID){ + if (!initialPriceID) { t.fail(`could not find Stripe price with lookup_key ${initialPlan}`) } let customer try { // create a new customer and set up its subscription with "initialPlan" customer = await setupCustomer(stripe, email) - + // create a subscription to initialPlan await stripe.subscriptions.create({ customer: customer.id, items: [{ price: initialPriceID }] }) diff --git a/upload-api/types.ts b/upload-api/types.ts index 02d67779..5996dccc 100644 --- a/upload-api/types.ts +++ b/upload-api/types.ts @@ -3,7 +3,7 @@ import { DID, Link, Delegation, Signature, Block, UCANLink, ByteView, DIDKey, Re import { UnknownLink } from 'multiformats' import { CID } from 'multiformats/cid' import { Kinesis } from '@aws-sdk/client-kinesis' -import { AccountDID, ProviderDID, Service, SpaceDID, CarStoreBucket } from '@web3-storage/upload-api' +import { AccountDID, ProviderDID, Service, SpaceDID, CarStoreBucket, PlanCreateAdminSessionSuccess, PlanCreateAdminSessionFailure } from '@web3-storage/upload-api' export interface StoreOperationError extends Error { name: 'StoreOperationFailed' @@ -280,6 +280,7 @@ type SetPlanFailure = InvalidSubscriptionState | BillingProviderUpdateError export interface BillingProvider { hasCustomer: (customer: AccountDID) => Promise> setPlan: (customer: AccountDID, plan: DID) => Promise> + createAdminSession: (customer: AccountDID, returnURL: string) => Promise> } export {} From a0f7d8b5069c32346f0e9e031ba2d8509b0064b9 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Wed, 8 May 2024 16:54:49 -0700 Subject: [PATCH 2/6] fix: clean up tests --- billing/utils/stripe.js | 11 ++- upload-api/test/billing.test.js | 146 ++++++++++++++++++++--------- upload-api/test/helpers/billing.js | 4 + 3 files changed, 114 insertions(+), 47 deletions(-) diff --git a/billing/utils/stripe.js b/billing/utils/stripe.js index a0f44274..b47b3ded 100644 --- a/billing/utils/stripe.js +++ b/billing/utils/stripe.js @@ -6,6 +6,15 @@ import * as DidMailto from '@web3-storage/did-mailto' * @typedef {import('stripe').Stripe.CustomerSubscriptionCreatedEvent} CustomerSubscriptionCreatedEvent */ +/** + * + * @param {string} stripeID + * @returns {AccountID} + */ +export function stripeIDToAccountID(stripeID) { + return /** @type {AccountID} */(`stripe:${stripeID}`) +} + /** * * @param {Stripe} stripe @@ -21,7 +30,7 @@ export async function handleCustomerSubscriptionCreated(stripe, event, customerS return { error: new Error(`Invalid product: ${product}`) } } - const account = /** @type {AccountID} */ (`stripe:${customerId}`) + const account = stripeIDToAccountID(customerId) const stripeCustomer = await stripe.customers.retrieve(customerId) if (stripeCustomer.deleted) { return { diff --git a/upload-api/test/billing.test.js b/upload-api/test/billing.test.js index f418484c..c5d53c82 100644 --- a/upload-api/test/billing.test.js +++ b/upload-api/test/billing.test.js @@ -7,9 +7,24 @@ import Stripe from 'stripe' import { fileURLToPath } from 'node:url' import { createCustomerStore, customerTableProps } from '@web3-storage/w3infra-billing/tables/customer.js' import { createTable } from './helpers/resources.js' +import { createDynamoDB } from '@web3-storage/w3infra-billing/test/helpers/aws.js' +import { stripeIDToAccountID } from '@web3-storage/w3infra-billing/utils/stripe.js' dotenv.config({ path: fileURLToPath(new URL('../../.env', import.meta.url)) }) +/** + * @typedef {object} BillingContext + * @property {import('@web3-storage/w3infra-billing/lib/api.js').CustomerStore} BillingContext.customerStore + * @property {Stripe} BillingContext.stripe + * @property {import('../types.js').BillingProvider} BillingContext.billingProvider + */ + +const customerDID = /** @type {import('@web3-storage/did-mailto').DidMailto} */( + `did:mailto:example.com:w3up-billing-test-${Date.now()}` +) +const email = toEmail(customerDID) +const initialPlan = 'did:web:starter.web3.storage' + /** * * @param {Stripe} stripe @@ -29,10 +44,20 @@ async function getCustomerPlanByEmail(stripe, email) { * * @param {Stripe} stripe * @param {string} email + * @param {import('@web3-storage/w3infra-billing/lib/api.js').CustomerStore} customerStore * @returns {Promise} */ -async function setupCustomer(stripe, email) { +async function setupCustomer(stripe, email, customerStore) { const customer = await stripe.customers.create({ email }) + const customerCreation = await customerStore.put({ + customer: customerDID, + account: stripeIDToAccountID(customer.id), + product: initialPlan, + insertedAt: new Date() + }) + if (!customerCreation.ok){ + throw customerCreation.error + } // set up a payment method - otherwise we won't be able to update the plan later let setupIntent = await stripe.setupIntents.create({ @@ -47,55 +72,84 @@ async function setupCustomer(stripe, email) { ) const paymentMethod = /** @type {string} */(setupIntent.payment_method) await stripe.customers.update(customer.id, { invoice_settings: { default_payment_method: paymentMethod } }) + // create a subscription to initialPlan + const prices = await stripe.prices.list({ lookup_keys: [initialPlan] }) + const initialPriceID = prices.data.find(price => price.lookup_key === initialPlan)?.id + if (!initialPriceID) { + throw new Error(`could not find priceID ${initialPlan} in Stripe`) + } + await stripe.subscriptions.create({ customer: customer.id, items: [{ price: initialPriceID }] }) return customer } -test('stripe plan can be updated', async (t) => { +/** + * + * @param {BillingContext} context + * @param {(c: BillingContext) => Promise} testFn + */ +async function withCustomer(context, testFn) { + const { stripe, customerStore } = context + let customer + try { + // create a new customer and set up its subscription with "initialPlan" + customer = await setupCustomer(stripe, email, customerStore) + await testFn(context) + } finally { + if (customer) { + // clean up the user we created + await stripe.customers.del(customer.id) + } + } +} + +test.before(async t => { const stripeSecretKey = process.env.STRIPE_TEST_SECRET_KEY - if (stripeSecretKey) { - - const stripe = new Stripe(stripeSecretKey, { apiVersion: '2023-10-16' }) - const { dynamo } = t.context - const customerStore = createCustomerStore(dynamo, {tableName: await createTable(dynamo, customerTableProps}) - const billingProvider = createStripeBillingProvider(stripe, customerStore) - const customerDID = /** @type {import('@web3-storage/did-mailto').DidMailto} */( - `did:mailto:example.com:w3up-billing-test-${Date.now()}` - ) - const email = toEmail(customerDID) - - const initialPlan = 'did:web:starter.web3.storage' - const updatedPlan = 'did:web:lite.web3.storage' - const prices = await stripe.prices.list({ lookup_keys: [initialPlan] }) - const initialPriceID = prices.data.find(price => price.lookup_key === initialPlan)?.id - if (!initialPriceID) { - t.fail(`could not find Stripe price with lookup_key ${initialPlan}`) - } - let customer - try { - // create a new customer and set up its subscription with "initialPlan" - customer = await setupCustomer(stripe, email) - - // create a subscription to initialPlan - await stripe.subscriptions.create({ customer: customer.id, items: [{ price: initialPriceID }] }) - - // use the stripe API to verify plan has been initialized correctly - const initialStripePlan = await getCustomerPlanByEmail(stripe, email) - t.deepEqual(initialPlan, initialStripePlan) - - // this is the actual code under test! - await billingProvider.setPlan(customerDID, updatedPlan) - - // use the stripe API to verify plan has been updated - const updatedStripePlan = await getCustomerPlanByEmail(stripe, email) - t.deepEqual(updatedPlan, updatedStripePlan) - } finally { - if (customer) { - // clean up the user we created - await stripe.customers.del(customer.id) - } - } - } else { - t.fail('STRIPE_TEST_SECRET_KEY environment variable is not set') + if (!stripeSecretKey) { + throw new Error('STRIPE_TEST_SECRET_KEY environment variable is not set') } + const { client: dynamo } = await createDynamoDB() + + const stripe = new Stripe(stripeSecretKey, { apiVersion: '2023-10-16' }) + + const customerStore = createCustomerStore(dynamo, { tableName: await createTable(dynamo, customerTableProps) }) + const billingProvider = createStripeBillingProvider(stripe, customerStore) + + Object.assign(t.context, { + dynamo, + customerStore, + stripe, + billingProvider + }) +}) + +test('stripe plan can be updated', async (t) => { + const context = /** @type {typeof t.context & BillingContext } */(t.context) + const { stripe, billingProvider } = context + + await withCustomer(context, async () => { + // use the stripe API to verify plan has been initialized correctly + const initialStripePlan = await getCustomerPlanByEmail(stripe, email) + t.deepEqual(initialPlan, initialStripePlan) + + // this is the actual code under test! + const updatedPlan = 'did:web:lite.web3.storage' + await billingProvider.setPlan(customerDID, updatedPlan) + + // use the stripe API to verify plan has been updated + const updatedStripePlan = await getCustomerPlanByEmail(stripe, email) + t.deepEqual(updatedPlan, updatedStripePlan) + }) }) + +test('stripe billing session can be generated', async (t) => { + const context = /** @type {typeof t.context & BillingContext } */(t.context) + const { billingProvider } = context + + await withCustomer(context, async () => { + const response = await billingProvider.createAdminSession(customerDID, 'https://example.com/return-url') + console.log(response) + t.assert(response.ok) + t.assert(response.ok?.url) + }) +}) \ No newline at end of file diff --git a/upload-api/test/helpers/billing.js b/upload-api/test/helpers/billing.js index 7c874595..b835d39c 100644 --- a/upload-api/test/helpers/billing.js +++ b/upload-api/test/helpers/billing.js @@ -14,6 +14,10 @@ export function createTestBillingProvider() { async setPlan(customer, product) { customers[customer] = product return { ok: {} } + }, + + async createAdminSession(customer) { + return { ok: { url: 'https://example/test-billing-admin-session' } } } } } \ No newline at end of file From e77845db960d641cc4283f492bc57cd8b0b6132c Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Wed, 8 May 2024 16:55:26 -0700 Subject: [PATCH 3/6] fix: remove errant console.log --- upload-api/test/billing.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/upload-api/test/billing.test.js b/upload-api/test/billing.test.js index c5d53c82..3287beca 100644 --- a/upload-api/test/billing.test.js +++ b/upload-api/test/billing.test.js @@ -148,7 +148,6 @@ test('stripe billing session can be generated', async (t) => { await withCustomer(context, async () => { const response = await billingProvider.createAdminSession(customerDID, 'https://example.com/return-url') - console.log(response) t.assert(response.ok) t.assert(response.ok?.url) }) From 702fa99577aa3abe3830d38f3acb74ae592c8e88 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Tue, 14 May 2024 11:58:33 -0700 Subject: [PATCH 4/6] fix: update to released dep --- package-lock.json | 173 ++++++++++++++++++++++++++++------------ upload-api/package.json | 2 +- 2 files changed, 121 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index 423f0c81..dec0aaac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5654,9 +5654,9 @@ } }, "node_modules/@web3-storage/access": { - "version": "18.3.2", - "resolved": "https://registry.npmjs.org/@web3-storage/access/-/access-18.3.2.tgz", - "integrity": "sha512-Ry+lMzWkXnr7UXSWWwSBTlbTDfLAfBiwZvocLvrTe1BdBPMI/eQfbI+SNuvMdar0cvJLaLspjkK/IVADsdlBVg==", + "version": "18.4.0", + "resolved": "https://registry.npmjs.org/@web3-storage/access/-/access-18.4.0.tgz", + "integrity": "sha512-EQQxSCip9FNgiNGwpKTnpff7/5A6MSn/Etf1Xpei3Au2oQkUe25DHwRJd/mbUzjnhcYh6UMGk2f0dIJ4Me00LA==", "dependencies": { "@ipld/car": "^5.1.1", "@ipld/dag-ucan": "^3.4.0", @@ -5667,7 +5667,7 @@ "@ucanto/principal": "^9.0.1", "@ucanto/transport": "^9.1.1", "@ucanto/validator": "^9.0.2", - "@web3-storage/capabilities": "^14.0.2", + "@web3-storage/capabilities": "^17.1.0", "@web3-storage/did-mailto": "^2.1.0", "bigint-mod-arith": "^3.1.2", "conf": "11.0.2", @@ -5678,65 +5678,43 @@ "uint8arrays": "^4.0.6" } }, - "node_modules/@web3-storage/access/node_modules/@web3-storage/capabilities": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/@web3-storage/capabilities/-/capabilities-14.0.2.tgz", - "integrity": "sha512-0BTzzn60S7eC2xwZjla3v2SNiyxSuVYD2bAokHuO4ztfi0O7L76R2pVDpOI67ZnIL+Cl3FX022NKt+qLxFIoSg==", + "node_modules/@web3-storage/access/node_modules/multiformats": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", + "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/@web3-storage/blob-index": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@web3-storage/blob-index/-/blob-index-1.0.1.tgz", + "integrity": "sha512-mW6jO7O0ycpIWvt0na/bP1gu9vht4Je/ULVS7ulNHrANg8ESjbbLeeev4JAXbpZVYxTKiFMDhna5mHlOWxzLcA==", "dependencies": { + "@ipld/dag-cbor": "^9.0.6", "@ucanto/core": "^10.0.1", "@ucanto/interface": "^10.0.1", - "@ucanto/principal": "^9.0.1", - "@ucanto/transport": "^9.1.1", - "@ucanto/validator": "^9.0.2", - "@web3-storage/data-segment": "^3.2.0", + "@web3-storage/capabilities": "^17.0.0", + "multiformats": "^13.0.1", "uint8arrays": "^5.0.3" + }, + "engines": { + "node": ">=16.15" } }, - "node_modules/@web3-storage/access/node_modules/@web3-storage/capabilities/node_modules/multiformats": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", - "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" - }, - "node_modules/@web3-storage/access/node_modules/@web3-storage/capabilities/node_modules/uint8arrays": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.0.3.tgz", - "integrity": "sha512-6LBuKji28kHjgPJMkQ6GDaBb1lRwIhyOYq6pDGwYMoDPfImE9SkuYENVmR0yu9yGgs2clHUSY9fKDukR+AXfqQ==", + "node_modules/@web3-storage/blob-index/node_modules/uint8arrays": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.1.0.tgz", + "integrity": "sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww==", "dependencies": { "multiformats": "^13.0.0" } }, - "node_modules/@web3-storage/access/node_modules/@web3-storage/data-segment": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@web3-storage/data-segment/-/data-segment-3.2.0.tgz", - "integrity": "sha512-SM6eNumXzrXiQE2/J59+eEgCRZNYPxKhRoHX2QvV3/scD4qgcf4g+paWBc3UriLEY1rCboygGoPsnqYJNyZyfA==", - "dependencies": { - "@ipld/dag-cbor": "^9.0.5", - "multiformats": "^11.0.2", - "sync-multihash-sha2": "^1.0.0" - } - }, - "node_modules/@web3-storage/access/node_modules/@web3-storage/data-segment/node_modules/multiformats": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-11.0.2.tgz", - "integrity": "sha512-b5mYMkOkARIuVZCpvijFj9a6m5wMVLC7cf/jIPd5D/ARDOfLC5+IFkbgDXQgcU2goIsTD/O9NY4DI/Mt4OGvlg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/@web3-storage/access/node_modules/multiformats": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", - "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, "node_modules/@web3-storage/capabilities": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@web3-storage/capabilities/-/capabilities-17.0.0.tgz", - "integrity": "sha512-rUz5CJiygpq5S4BUrMYoECzEUGfMFiLM4niv+m/JW/jXv06o/pe5CW+NiL/cGLSZGax4yuqs/Zl9m9/OH0/1SQ==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@web3-storage/capabilities/-/capabilities-17.1.0.tgz", + "integrity": "sha512-p5Wn2O3TSEZ7JFSph2KY9OuFnofbkhKi7Tp+1zcPEYAUsEvDWGabd1NvSPDDMpFBE74UX4ZljE8aQzDAtI3qRw==", "dependencies": { "@ucanto/core": "^10.0.1", "@ucanto/interface": "^10.0.1", @@ -18349,7 +18327,7 @@ "@web3-storage/access": "^18.3.2", "@web3-storage/capabilities": "^17.0.0", "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/upload-api": "file:../../w3up/packages/upload-api", + "@web3-storage/upload-api": "14.0.0", "multiformats": "^13.1.0", "nanoid": "^5.0.2", "preact": "^10.14.1", @@ -18377,6 +18355,11 @@ "node": ">=16.15" } }, + "upload-api/node_modules/@types/retry": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", + "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" + }, "upload-api/node_modules/@ucanto/server": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/@ucanto/server/-/server-10.0.0.tgz", @@ -18407,6 +18390,90 @@ "web-streams-polyfill": "^3.1.1" } }, + "upload-api/node_modules/@web3-storage/content-claims": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@web3-storage/content-claims/-/content-claims-4.0.5.tgz", + "integrity": "sha512-+WpCkTN8aRfUCrCm0kOMZad+FRnFymVDFvS6/+PJMPGP17cci1/c5lqYdrjFV+5MkhL+BkUJVtRTx02G31FHmQ==", + "dependencies": { + "@ucanto/client": "^9.0.1", + "@ucanto/interface": "^10.0.0", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "carstream": "^1.0.2", + "multiformats": "^12.0.1" + } + }, + "upload-api/node_modules/@web3-storage/content-claims/node_modules/multiformats": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", + "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "upload-api/node_modules/@web3-storage/upload-api": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@web3-storage/upload-api/-/upload-api-14.0.0.tgz", + "integrity": "sha512-/HFunNPUY+q1Uz1fT+a2IGn3IxSg9p9nsPxD5phG285ermjPtwFcNsG0bUvxjO69Ur37eDzwAcf7iZ09e0vOmg==", + "dependencies": { + "@ucanto/client": "^9.0.1", + "@ucanto/interface": "^10.0.1", + "@ucanto/principal": "^9.0.1", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "@ucanto/validator": "^9.0.2", + "@web3-storage/access": "^18.4.0", + "@web3-storage/blob-index": "^1.0.1", + "@web3-storage/capabilities": "^17.1.0", + "@web3-storage/content-claims": "^4.0.4", + "@web3-storage/did-mailto": "^2.1.0", + "@web3-storage/filecoin-api": "^6.0.1", + "multiformats": "^12.1.2", + "p-retry": "^5.1.2", + "uint8arrays": "^5.0.3" + }, + "engines": { + "node": ">=16.15" + } + }, + "upload-api/node_modules/@web3-storage/upload-api/node_modules/multiformats": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", + "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "upload-api/node_modules/@web3-storage/upload-api/node_modules/p-retry": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-5.1.2.tgz", + "integrity": "sha512-couX95waDu98NfNZV+i/iLt+fdVxmI7CbrrdC2uDWfPdUAApyxT4wmDlyOtR5KtTDmkDO0zDScDjDou9YHhd9g==", + "dependencies": { + "@types/retry": "0.12.1", + "retry": "^0.13.1" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "upload-api/node_modules/@web3-storage/upload-api/node_modules/uint8arrays": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.1.0.tgz", + "integrity": "sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww==", + "dependencies": { + "multiformats": "^13.0.0" + } + }, + "upload-api/node_modules/@web3-storage/upload-api/node_modules/uint8arrays/node_modules/multiformats": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", + "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" + }, "upload-api/node_modules/nanoid": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.6.tgz", diff --git a/upload-api/package.json b/upload-api/package.json index 16a3854f..317bd38e 100644 --- a/upload-api/package.json +++ b/upload-api/package.json @@ -25,7 +25,7 @@ "@web3-storage/access": "^18.3.2", "@web3-storage/capabilities": "^17.0.0", "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/upload-api": "file:../../w3up/packages/upload-api", + "@web3-storage/upload-api": "14.0.0", "multiformats": "^13.1.0", "nanoid": "^5.0.2", "preact": "^10.14.1", From b4ea20083859d8b6c413e8b6417ce930c3e2d630 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Tue, 14 May 2024 13:27:13 -0700 Subject: [PATCH 5/6] fix: update top level upload-api dep --- package-lock.json | 221 +++++++++++++++++++--------------------------- package.json | 2 +- 2 files changed, 91 insertions(+), 132 deletions(-) diff --git a/package-lock.json b/package-lock.json index dec0aaac..e2451ba1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "dependencies": { "@ipld/dag-json": "^10.1.5", "@web-std/stream": "^1.0.3", - "@web3-storage/upload-api": "^13.0.2", + "@web3-storage/upload-api": "^14.0.0", "aws-cdk-lib": "2.124.0", "sst": "^2.40.3" }, @@ -55,45 +55,6 @@ "typescript": "^4.9.3" } }, - "../w3up/packages/upload-api": { - "name": "@web3-storage/upload-api", - "version": "13.0.2", - "dependencies": { - "@ipld/dag-cbor": "^9.0.6", - "@ucanto/client": "^9.0.1", - "@ucanto/interface": "^10.0.1", - "@ucanto/principal": "^9.0.1", - "@ucanto/server": "^10.0.0", - "@ucanto/transport": "^9.1.1", - "@ucanto/validator": "^9.0.2", - "@web3-storage/access": "workspace:^", - "@web3-storage/capabilities": "workspace:^", - "@web3-storage/content-claims": "^4.0.4", - "@web3-storage/did-mailto": "workspace:^", - "@web3-storage/filecoin-api": "workspace:^", - "carstream": "^2.1.0", - "multiformats": "^12.1.2", - "p-retry": "^5.1.2", - "uint8arrays": "^5.0.3" - }, - "devDependencies": { - "@ipld/car": "^5.1.1", - "@ipld/dag-ucan": "^3.4.0", - "@types/mocha": "^10.0.1", - "@ucanto/core": "^10.0.1", - "@web-std/blob": "^3.0.5", - "@web3-storage/eslint-config-w3up": "workspace:^", - "@web3-storage/sigv4": "^1.0.2", - "is-subset": "^0.1.1", - "mocha": "^10.2.0", - "one-webcrypto": "git://github.com/web3-storage/one-webcrypto", - "p-defer": "^4.0.1", - "typescript": "5.2.2" - }, - "engines": { - "node": ">=16.15" - } - }, "billing": { "name": "@web3-storage/w3infra-billing", "version": "0.0.0", @@ -5979,8 +5940,95 @@ } }, "node_modules/@web3-storage/upload-api": { - "resolved": "../w3up/packages/upload-api", - "link": true + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@web3-storage/upload-api/-/upload-api-14.0.0.tgz", + "integrity": "sha512-/HFunNPUY+q1Uz1fT+a2IGn3IxSg9p9nsPxD5phG285ermjPtwFcNsG0bUvxjO69Ur37eDzwAcf7iZ09e0vOmg==", + "dependencies": { + "@ucanto/client": "^9.0.1", + "@ucanto/interface": "^10.0.1", + "@ucanto/principal": "^9.0.1", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "@ucanto/validator": "^9.0.2", + "@web3-storage/access": "^18.4.0", + "@web3-storage/blob-index": "^1.0.1", + "@web3-storage/capabilities": "^17.1.0", + "@web3-storage/content-claims": "^4.0.4", + "@web3-storage/did-mailto": "^2.1.0", + "@web3-storage/filecoin-api": "^6.0.1", + "multiformats": "^12.1.2", + "p-retry": "^5.1.2", + "uint8arrays": "^5.0.3" + }, + "engines": { + "node": ">=16.15" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/@types/retry": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", + "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" + }, + "node_modules/@web3-storage/upload-api/node_modules/@ucanto/server": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@ucanto/server/-/server-10.0.0.tgz", + "integrity": "sha512-JMDMT3tFRE0S1cdtx/Hhh7v9FizV6IS0fPrh6pcli7AzKvXVy8Xu6EQ/66Fax4AQM2tkGxNNxjj2wHM7P4CqAg==", + "dependencies": { + "@ucanto/core": "^10.0.0", + "@ucanto/interface": "^10.0.0", + "@ucanto/principal": "^9.0.0", + "@ucanto/validator": "^9.0.1" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/@web3-storage/content-claims": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@web3-storage/content-claims/-/content-claims-4.0.5.tgz", + "integrity": "sha512-+WpCkTN8aRfUCrCm0kOMZad+FRnFymVDFvS6/+PJMPGP17cci1/c5lqYdrjFV+5MkhL+BkUJVtRTx02G31FHmQ==", + "dependencies": { + "@ucanto/client": "^9.0.1", + "@ucanto/interface": "^10.0.0", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "carstream": "^1.0.2", + "multiformats": "^12.0.1" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/multiformats": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", + "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/p-retry": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-5.1.2.tgz", + "integrity": "sha512-couX95waDu98NfNZV+i/iLt+fdVxmI7CbrrdC2uDWfPdUAApyxT4wmDlyOtR5KtTDmkDO0zDScDjDou9YHhd9g==", + "dependencies": { + "@types/retry": "0.12.1", + "retry": "^0.13.1" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/uint8arrays": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.1.0.tgz", + "integrity": "sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww==", + "dependencies": { + "multiformats": "^13.0.0" + } + }, + "node_modules/@web3-storage/upload-api/node_modules/uint8arrays/node_modules/multiformats": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", + "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" }, "node_modules/@web3-storage/upload-client": { "version": "13.2.2", @@ -18355,11 +18403,6 @@ "node": ">=16.15" } }, - "upload-api/node_modules/@types/retry": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", - "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" - }, "upload-api/node_modules/@ucanto/server": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/@ucanto/server/-/server-10.0.0.tgz", @@ -18390,90 +18433,6 @@ "web-streams-polyfill": "^3.1.1" } }, - "upload-api/node_modules/@web3-storage/content-claims": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@web3-storage/content-claims/-/content-claims-4.0.5.tgz", - "integrity": "sha512-+WpCkTN8aRfUCrCm0kOMZad+FRnFymVDFvS6/+PJMPGP17cci1/c5lqYdrjFV+5MkhL+BkUJVtRTx02G31FHmQ==", - "dependencies": { - "@ucanto/client": "^9.0.1", - "@ucanto/interface": "^10.0.0", - "@ucanto/server": "^10.0.0", - "@ucanto/transport": "^9.1.1", - "carstream": "^1.0.2", - "multiformats": "^12.0.1" - } - }, - "upload-api/node_modules/@web3-storage/content-claims/node_modules/multiformats": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", - "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "upload-api/node_modules/@web3-storage/upload-api": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@web3-storage/upload-api/-/upload-api-14.0.0.tgz", - "integrity": "sha512-/HFunNPUY+q1Uz1fT+a2IGn3IxSg9p9nsPxD5phG285ermjPtwFcNsG0bUvxjO69Ur37eDzwAcf7iZ09e0vOmg==", - "dependencies": { - "@ucanto/client": "^9.0.1", - "@ucanto/interface": "^10.0.1", - "@ucanto/principal": "^9.0.1", - "@ucanto/server": "^10.0.0", - "@ucanto/transport": "^9.1.1", - "@ucanto/validator": "^9.0.2", - "@web3-storage/access": "^18.4.0", - "@web3-storage/blob-index": "^1.0.1", - "@web3-storage/capabilities": "^17.1.0", - "@web3-storage/content-claims": "^4.0.4", - "@web3-storage/did-mailto": "^2.1.0", - "@web3-storage/filecoin-api": "^6.0.1", - "multiformats": "^12.1.2", - "p-retry": "^5.1.2", - "uint8arrays": "^5.0.3" - }, - "engines": { - "node": ">=16.15" - } - }, - "upload-api/node_modules/@web3-storage/upload-api/node_modules/multiformats": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.3.tgz", - "integrity": "sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "upload-api/node_modules/@web3-storage/upload-api/node_modules/p-retry": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-5.1.2.tgz", - "integrity": "sha512-couX95waDu98NfNZV+i/iLt+fdVxmI7CbrrdC2uDWfPdUAApyxT4wmDlyOtR5KtTDmkDO0zDScDjDou9YHhd9g==", - "dependencies": { - "@types/retry": "0.12.1", - "retry": "^0.13.1" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "upload-api/node_modules/@web3-storage/upload-api/node_modules/uint8arrays": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.1.0.tgz", - "integrity": "sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww==", - "dependencies": { - "multiformats": "^13.0.0" - } - }, - "upload-api/node_modules/@web3-storage/upload-api/node_modules/uint8arrays/node_modules/multiformats": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", - "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" - }, "upload-api/node_modules/nanoid": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.6.tgz", diff --git a/package.json b/package.json index a265592f..2eb8cc14 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "dependencies": { "@ipld/dag-json": "^10.1.5", "@web-std/stream": "^1.0.3", - "@web3-storage/upload-api": "^13.0.2", + "@web3-storage/upload-api": "^14.0.0", "aws-cdk-lib": "2.124.0", "sst": "^2.40.3" }, From eb30cdba69f3dcdfbaa9dd284c28702115e23b2c Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Tue, 14 May 2024 13:52:56 -0700 Subject: [PATCH 6/6] fix: update blob dep also remove explicit JSDoc dep - I'm not sure why this doesn't work, but something about the way that type is being exported is freaking out our builder. probably needs to be resolved a different way, but I want to get my PR green before shaving that yak --- package-lock.json | 1 + upload-api/external-services/ipni-service.js | 1 - upload-api/package.json | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index e2451ba1..d5471589 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18391,6 +18391,7 @@ "@ipld/car": "^5.2.6", "@types/aws-lambda": "^8.10.108", "@web-std/blob": "3.0.4", + "@web3-storage/blob-index": "^1.0.1", "@web3-storage/sigv4": "^1.0.2", "ava": "^4.3.3", "aws-lambda-test-utils": "^1.3.0", diff --git a/upload-api/external-services/ipni-service.js b/upload-api/external-services/ipni-service.js index 626f1eb2..d09cd3cf 100644 --- a/upload-api/external-services/ipni-service.js +++ b/upload-api/external-services/ipni-service.js @@ -33,7 +33,6 @@ export const createIPNIService = (multihashesQueueConfig, blocksCarsPositionConf * @returns {import('@web3-storage/upload-api').IPNIService} */ export const useIPNIService = (blockAdvertPublisher, blockIndexStore) => ({ - /** @param {import('@web3-storage/upload-api').ShardedDAGIndex} index */ async publish (index) { /** @type {import('multiformats').MultihashDigest[]} */ const items = [] diff --git a/upload-api/package.json b/upload-api/package.json index 317bd38e..02d3cc95 100644 --- a/upload-api/package.json +++ b/upload-api/package.json @@ -41,6 +41,7 @@ "@ipld/car": "^5.2.6", "@types/aws-lambda": "^8.10.108", "@web-std/blob": "3.0.4", + "@web3-storage/blob-index": "^1.0.1", "@web3-storage/sigv4": "^1.0.2", "ava": "^4.3.3", "aws-lambda-test-utils": "^1.3.0",