Skip to content

feat: add authorize hook and tempo subscriptions#331

Draft
brendanjryan wants to merge 4 commits intomainfrom
brendanryan/authorize-hook-subscriptions
Draft

feat: add authorize hook and tempo subscriptions#331
brendanjryan wants to merge 4 commits intomainfrom
brendanryan/authorize-hook-subscriptions

Conversation

@brendanjryan
Copy link
Copy Markdown
Collaborator

No description provided.

@brendanjryan brendanjryan force-pushed the brendanryan/authorize-hook-subscriptions branch from 992c30a to 313f314 Compare April 10, 2026 22:24
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/mppx@331

commit: 5929e02

@brendanjryan brendanjryan force-pushed the brendanryan/authorize-hook-subscriptions branch 2 times, most recently from a09cb0e to d651f09 Compare April 20, 2026 22:42
Comment thread src/tempo/server/Subscription.ts Outdated
)
const active = matches.filter((record) => isActive(record))

const subscription = (() => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels odd we have to have the client pass a subscription id in order to disambiguate, shouldn't the server be able to filter subscriptions to check if one is valid for the given route / user?

Comment thread src/tempo/subscription/Store.ts Outdated
import type { SubscriptionRecord } from './Types.js'

const recordPrefix = 'tempo:subscription:record:'
const resourcePrefix = 'tempo:subscription:resource:'
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow these to be customized

return records.filter((record: unknown): record is SubscriptionRecord => Boolean(record))
},
async put(record) {
await store.put(recordKey(record.subscriptionId), record)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments about what we are doing here

Comment thread src/tempo/server/Subscription.ts Outdated
return 'minute'
case 3_600:
return 'hour'
case 86_400:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make these constants

}
}

function formatBillingInterval(periodSeconds: string) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no way to manually bill users e.g. in a cron? we should add this

@brendanjryan brendanjryan force-pushed the brendanryan/authorize-hook-subscriptions branch from d651f09 to 5d333a6 Compare April 21, 2026 01:07
@brendanjryan brendanjryan force-pushed the brendanryan/authorize-hook-subscriptions branch from 5d333a6 to e776f4e Compare April 21, 2026 02:56
@jithinraj
Copy link
Copy Markdown

Great addition, @brendanjryan.

The main thing I’d pin down early is how a later charge proves linkage to the original authorization window.

A minimal stable tuple for that would already help a lot: authorization ref, cumulative spent, remaining window, and a verifier-facing record ref.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants