Skip to content

Commit 8eb4306

Browse files
authored
Ports over the upload api changes in the above commit to upload service -- original commit message feat: add `app` to `access/authorize` and `access/confirm` (#264) ( We need a way to ensure users are redirected back to `https://bsky.storage` after completing the Stripe checkout process. To facilitate this, pass facts from `access/authorize` to`access/confirm` - users can now add a fact like `{app: 'bsky-backups'}` to `access/authorize`, which will tell the `access/confirm` handling code in `w3infra` to render the same pricing table we use on https://bsky.storage which sends the user back to that app after picking a plan via the email flow. Add support for this to the client code via a new `appName` option in the account creation functions that gets converted to a fact at the lowest level. There are a bunch of ways we could do this, but in the interest of shipping ASAP I think this is a reasonable and fast way to go. See storacha/w3infra#472 for the other part of this.
1 parent 198be45 commit 8eb4306

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

packages/access-client/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,7 @@ export type EncodedDelegation<C extends Capabilities = Capabilities> = string &
343343

344344
export type BytesDelegation<C extends Capabilities = Capabilities> =
345345
Uint8Array & Phantom<Delegation<C>>
346+
347+
export enum AppName {
348+
BskyBackups = 'bsky-backups',
349+
}

packages/upload-api/src/access/authorize.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ export const authorize = async ({ capability, invocation }, ctx) => {
8282
// Link to the invocation that requested the authorization.
8383
cause: invocation.cid,
8484
},
85+
// we copy the facts in so that information can be passed
86+
// from the invoker of this capability to the invoker of the confirm
87+
// capability - we use this, for example, to let bsky.storage users
88+
// specify that they should be redirected back to bsky.storage after
89+
// completing the Stripe plan selection flow
90+
facts: invocation.facts,
8591
})
8692
.delegate()
8793

packages/upload-api/src/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export async function authorize(encodedUcan, env) {
5959
email: DidMailto.toEmail(DidMailto.fromString(account.did())),
6060
audience: agent.did(),
6161
ucan: delegationsToString(confirmDelegations),
62+
facts: request.facts,
6263
},
6364
}
6465
} catch (error) {

packages/w3up-client/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { type Client } from './client.js'
2020
import { StorefrontService } from '@web3-storage/filecoin-client/storefront'
2121
export * from '@ucanto/interface'
2222
export * from '@web3-storage/did-mailto'
23+
export { AppName } from '@web3-storage/access/types'
2324
export type { Agent, CapabilityQuery } from '@web3-storage/access/agent'
2425
export type {
2526
Access,

0 commit comments

Comments
 (0)