@orangecheck/me-client 0.32.4 → 0.34.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 CHANGED
@@ -41,8 +41,27 @@ import { signInWithOc } from '@orangecheck/me-client/popup';
41
41
 
42
42
  const result = await signInWithOc();
43
43
  if (result) {
44
- // A token bound to your origin. Send it to your server as a Bearer.
45
- await fetch('/api/me', { headers: { Authorization: `Bearer ${result.token}` } });
44
+ // A token bound to your origin. Hand it to your server once; it keeps it
45
+ // in an httpOnly cookie, out of reach of your page's scripts.
46
+ await fetch('/api/auth/session', {
47
+ method: 'POST',
48
+ headers: { 'Content-Type': 'application/json' },
49
+ body: JSON.stringify({ token: result.token }),
50
+ });
51
+ }
52
+ ```
53
+
54
+ ```ts
55
+ // Server · pages/api/auth/session.ts
56
+ import { verifyOcToken } from '@orangecheck/me-client/server';
57
+
58
+ export default async function session(req, res) {
59
+ const token = String(req.body?.token ?? '');
60
+ const s = await verifyOcToken(token, { audience: 'https://your-site.example' });
61
+ if (!s) return res.status(401).json({ ok: false });
62
+ const maxAge = (s.exp ?? 0) - Math.floor(Date.now() / 1000);
63
+ res.setHeader('Set-Cookie', `oc_session=${token}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAge}`);
64
+ res.status(200).json({ ok: true });
46
65
  }
47
66
  ```
48
67
 
@@ -228,6 +247,10 @@ app.get('/api/me', (c) => {
228
247
 
229
248
  `getOcSession(headers)` is the framework-agnostic primitive: pass a Web `Headers` object or a plain `{ cookie, authorization }` object. Cookie auth (family `*.ochk.io`) and Bearer auth (cross-domain) are handled identically.
230
249
 
250
+ ### Sessions ended everywhere
251
+
252
+ Set `OC_PROJECT_KEY` and `OC_SIGNING_SECRET` (from ochk.app/me/projects) and `getOcSession`, `withOcAuth`, `ocAuthExpress` and `ocAuthHono` refuse a session the person ended everywhere: sign out everywhere, a passkey removed, the account deleted. They read those account cutoffs from me.ochk.io once a minute, with a request signed by your secret, so a refusal lands within about two minutes. If me.ochk.io can't be reached, reads go on and writes are refused until it can. Without the two variables, a token is checked by its signature alone and stays valid until it expires.
253
+
231
254
  ## Browser popup signin
232
255
 
233
256
  ```tsx
@@ -236,10 +259,14 @@ import { signInWithOc } from '@orangecheck/me-client/popup';
236
259
  button.addEventListener('click', async () => {
237
260
  const result = await signInWithOc();
238
261
  if (!result) return; // user cancelled or popup blocked
239
- // Cross-domain integrators only — same-origin family integrators
240
- // (.ochk.io) skip this; the cookie rides automatically.
241
- localStorage.setItem('oc-token', result.token);
242
- location.assign('/dashboard');
262
+ // Your server verifies it and keeps it in an httpOnly cookie. Not
263
+ // localStorage: any script on the page could read it there.
264
+ const r = await fetch('/api/auth/session', {
265
+ method: 'POST',
266
+ headers: { 'Content-Type': 'application/json' },
267
+ body: JSON.stringify({ token: result.token }),
268
+ });
269
+ if (r.ok) location.assign('/dashboard');
243
270
  });
244
271
  ```
245
272
 
@@ -41,6 +41,7 @@ interface VerifyActivityOptions {
41
41
  issuer?: string;
42
42
  jwk?: OcEnvelopePublicJwk;
43
43
  jwksCacheTtlMs?: number;
44
+ jwksMaxStaleMs?: number;
44
45
  now?: Date;
45
46
  }
46
47
  declare function verifyActivityAttestation(bundle: ActivityAttestationBundle, options?: VerifyActivityOptions): Promise<ActivityVerifyResult>;
@@ -41,6 +41,7 @@ interface VerifyActivityOptions {
41
41
  issuer?: string;
42
42
  jwk?: OcEnvelopePublicJwk;
43
43
  jwksCacheTtlMs?: number;
44
+ jwksMaxStaleMs?: number;
44
45
  now?: Date;
45
46
  }
46
47
  declare function verifyActivityAttestation(bundle: ActivityAttestationBundle, options?: VerifyActivityOptions): Promise<ActivityVerifyResult>;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-6pjtyKYh.mjs';
2
- export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-6pjtyKYh.mjs';
1
+ import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-DfxCvxuH.mjs';
2
+ export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-DfxCvxuH.mjs';
3
3
  import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-C-enR55c.mjs';
4
4
  export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as ClassASubtype, i as ClassBSubtype, j as ClassCSubtype, k as ComputedFees, D as DropCadence, l as DropClosedWebhookPayload, m as DropResponseBlock, n as DropScheduleSummary, o as EVENT_SUBTYPES, p as EventClass, q as EventSubtype, r as EventSubtypeMetadata, s as FederationStatus, t as IntegratorArchetype, u as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, v as MIN_INTEGRATOR_PRICE_SATS, w as PLATFORM_FEE_POLICY, x as SessionPolicy, y as SigningMethod, z as SiteFeeShape, G as SystemWebhookPayload, W as WebhookHeaders, H as WebhookPayload, J as computeFees, K as subtypesForClass, L as validateIntegratorConfig } from './integrator-C-enR55c.mjs';
5
5
 
@@ -69,6 +69,7 @@ interface VerifyOptions {
69
69
  issuer?: string;
70
70
  jwk?: OcPublicJwk;
71
71
  jwksCacheTtlMs?: number;
72
+ jwksMaxStaleMs?: number;
72
73
  }
73
74
  declare function verify$1(rawBody: string | Uint8Array, sigHex: string | null | undefined, kid: string | null | undefined, options?: VerifyOptions): Promise<VerifyResult>;
74
75
  declare function fetchJwksForce(issuer?: string): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-6pjtyKYh.js';
2
- export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-6pjtyKYh.js';
1
+ import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-DfxCvxuH.js';
2
+ export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-DfxCvxuH.js';
3
3
  import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-C-enR55c.js';
4
4
  export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as ClassASubtype, i as ClassBSubtype, j as ClassCSubtype, k as ComputedFees, D as DropCadence, l as DropClosedWebhookPayload, m as DropResponseBlock, n as DropScheduleSummary, o as EVENT_SUBTYPES, p as EventClass, q as EventSubtype, r as EventSubtypeMetadata, s as FederationStatus, t as IntegratorArchetype, u as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, v as MIN_INTEGRATOR_PRICE_SATS, w as PLATFORM_FEE_POLICY, x as SessionPolicy, y as SigningMethod, z as SiteFeeShape, G as SystemWebhookPayload, W as WebhookHeaders, H as WebhookPayload, J as computeFees, K as subtypesForClass, L as validateIntegratorConfig } from './integrator-C-enR55c.js';
5
5
 
@@ -69,6 +69,7 @@ interface VerifyOptions {
69
69
  issuer?: string;
70
70
  jwk?: OcPublicJwk;
71
71
  jwksCacheTtlMs?: number;
72
+ jwksMaxStaleMs?: number;
72
73
  }
73
74
  declare function verify$1(rawBody: string | Uint8Array, sigHex: string | null | undefined, kid: string | null | undefined, options?: VerifyOptions): Promise<VerifyResult>;
74
75
  declare function fetchJwksForce(issuer?: string): Promise<void>;