@orangecheck/me-client 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/popup.js.map +1 -1
- package/dist/popup.mjs.map +1 -1
- package/dist/server.d.mts +14 -1
- package/dist/server.d.ts +14 -1
- package/dist/server.js +36 -3
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +36 -4
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,6 +99,19 @@ export default withOcAuth(handler, {
|
|
|
99
99
|
|
|
100
100
|
Or set it in code with `requireBond: { minSats: 100_000, minDays: 30, maxAgeSecs: 3600 }`. ochk.io re-checks the coin when its last check is over ten minutes old; `maxAgeSecs` refuses a claim checked longer ago than you accept. From 0.28.0, an account below the floor gets `403 { ok: false, reason: 'bond_required', need: { min_sats, min_days }, have: { sats_floor, days_floor } | null, back_url }`: link the person to `back_url` to back their account. If the project's setting can't be read, the last one read stands for ten minutes; with none read in that time, a signed-in request gets `503 { reason: 'bond_policy_unavailable' }` rather than being let through unchecked. A request with no session is not held to the project's setting and never waits on it (0.37.0); pass `required: true` to answer it 401. `readBondClaim(session)` and `bondMeets(session, { minSats, minDays, maxAgeSecs })` are exported for your own checks.
|
|
101
101
|
|
|
102
|
+
`verifyOcToken` and `checkOcToken` check the token alone, not the rule. Where you verify it yourself, apply the rule with one call in the route that starts your own session (0.43.0). It reads and holds the rule as `withOcAuth` does and answers with the same status and body:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { checkSignInRule, verifyOcToken } from '@orangecheck/me-client/server';
|
|
106
|
+
|
|
107
|
+
const session = await verifyOcToken(token, { audience: 'https://your-site.example' });
|
|
108
|
+
if (!session) return res.status(401).json({ ok: false });
|
|
109
|
+
const checked = await checkSignInRule(session, { projectKey: process.env.OC_PROJECT_KEY! });
|
|
110
|
+
if (!checked.ok) return res.status(checked.status).json(checked.body);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It takes only the session object `verifyOcToken`, `checkOcToken`, `getOcSession` or an adapter returned, and throws for anything else: claims read back from your own session store, or a copy, could name anyone. A floor with `maxAgeSecs` refuses a backing checked too long ago, so apply it where your session starts, not later.
|
|
114
|
+
|
|
102
115
|
## Pay your users, when you choose to
|
|
103
116
|
|
|
104
117
|
Paying the people who use your app is optional. In your project's dashboard you turn it on, schedule promos ("Launch week", Oct 20 to 27), or leave it off. While a pay period runs, each event you send earns the person their share and takes its fee from your balance. Outside every period an event earns and costs nothing, and me.ochk.io records nothing, so you can fire events from code that runs all the time:
|