@orangecheck/me-client 0.38.3 → 0.40.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 +30 -1
- package/dist/connect-consent.d.mts +4 -0
- package/dist/connect-consent.d.ts +4 -0
- package/dist/connect-consent.js +10 -0
- package/dist/connect-consent.js.map +1 -0
- package/dist/connect-consent.mjs +7 -0
- package/dist/connect-consent.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +47 -3
- package/dist/server.d.ts +47 -3
- package/dist/server.js +222 -18
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +219 -17
- package/dist/server.mjs.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@ import { withOcAuth, ocAuthExpress, ocAuthHono } from '@orangecheck/me-client/se
|
|
|
23
23
|
|
|
24
24
|
// Browser-only popup orchestrator — same shape Google / GitHub use.
|
|
25
25
|
import { signInWithOc } from '@orangecheck/me-client/popup';
|
|
26
|
+
|
|
27
|
+
// Keep your own login: make an orangecheck account for your user (OC Connect).
|
|
28
|
+
import { connectProvision } from '@orangecheck/me-client/server';
|
|
29
|
+
import { CONNECT_CONSENT_LABEL } from '@orangecheck/me-client/connect-consent';
|
|
26
30
|
```
|
|
27
31
|
|
|
28
32
|
## Install
|
|
@@ -251,7 +255,30 @@ app.get('/api/me', (c) => {
|
|
|
251
255
|
|
|
252
256
|
### Sessions ended everywhere
|
|
253
257
|
|
|
254
|
-
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. A sign-in token carries `rh`, its revocation handle for your origin; they look it up in me.ochk.io's list of ended handles for that origin, read once a minute per origin with a request signed by your secret, so a refusal lands within about two minutes. The handles name nobody, and another site's handles for the same person never match yours. If the list can't be read, or is more than ten minutes old by its own clock, reads go on and writes are refused until it can: the adapters answer such a write `503 { reason: 'revocations_unavailable' }` (0.38.0), not 401, so a client retries instead of signing the person out, and `checkOcSession(headers, options)` tells the same apart for your own code (`signed_in`, `signed_out` or `unavailable`).
|
|
258
|
+
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. A sign-in token carries `rh`, its revocation handle for your origin; they look it up in me.ochk.io's list of ended handles for that origin, read once a minute per origin with a request signed by your secret, so a refusal lands within about two minutes. The handles name nobody, and another site's handles for the same person never match yours. If the list can't be read, or is more than ten minutes old by its own clock, reads go on and writes are refused until it can: the adapters answer such a write `503 { reason: 'revocations_unavailable' }` (0.38.0), not 401, so a client retries instead of signing the person out, and `checkOcSession(headers, options)` tells the same apart for your own code (`signed_in`, `signed_out` or `unavailable`). Every token while the two variables are unset is checked by its signature alone and stays valid until it expires. A token bound to your site without `rh` is refused (`no_session_handle`, 0.40.0 or later), since sign out everywhere can't reach it; every token from the sign-in popup carries one, and `requireHandle: false` accepts one minted some other way. Needs 0.35.0 or later.
|
|
259
|
+
|
|
260
|
+
## Keep your own login: OC Connect
|
|
261
|
+
|
|
262
|
+
A site that keeps its own login (Auth0, Clerk, NextAuth, email and password) makes an orangecheck account for its user from its backend. Your Connect API key is on ochk.app, under your project's **Sign-in → Your own login**. Server only: import these only from code that never reaches a client bundle. They refuse to run where there is a `document`, which catches the commonest slip but is not a guard (a browser Web Worker has none).
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { connectProvision, connectClaimLink, connectDelete } from '@orangecheck/me-client/server';
|
|
266
|
+
|
|
267
|
+
const r = await connectProvision({ apiKey: process.env.OCHK_CONNECT_KEY!, userId: user.id });
|
|
268
|
+
if (r.ok) await saveDid(user.id, r.did_oc); // keep it on your user record
|
|
269
|
+
// r.ok === false: r.reason is 'account_deleted', 'daily_limit', 'rate_limited',
|
|
270
|
+
// 'invalid_api_key', 'app_suspended', 'bad_request' or 'unavailable'
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
A refusal or an outage is a result, never a throw, so it can't block your own sign-in; a call is given up after `timeoutMs` (5 s, at most 30 s). Every call goes to `https://ochk.io` and nowhere else, and a redirect is an error. Only a mistake in the call throws: an option it does not read, a missing key or user id, or `consent: false`. Only your options object's own keys are read, once, so nothing inherited (a polluted `Object.prototype`) can tick consent.
|
|
274
|
+
|
|
275
|
+
**With or without asking.** Make the account with no prompt, or show an opt-in box on your sign-in or sign-up with the canonical words, from a module with no dependencies that any UI can use:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { CONNECT_CONSENT_LABEL, CONNECT_CONSENT_BLURB } from '@orangecheck/me-client/connect-consent';
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Show the box unticked, never pre-ticked and never bundled with your Terms. Ticked: `connectProvision({ apiKey, userId, consent: true })`. Unticked: make no call at all. A later tick upgrades an account made without asking. `connectClaimLink` mints a link for your signed-in user to claim their account at ochk.app; `connectDelete` deletes it when they delete their account with you. The full guide is [ochk.io/docs/connect](https://ochk.io/docs/connect). Needs 0.39.0 or later.
|
|
255
282
|
|
|
256
283
|
## Browser popup signin
|
|
257
284
|
|
|
@@ -295,6 +322,8 @@ import { setOrigin } from '@orangecheck/me-client';
|
|
|
295
322
|
setOrigin('https://me.example-staging.com');
|
|
296
323
|
```
|
|
297
324
|
|
|
325
|
+
The Connect calls in `/server` don't use it: a call that carries your Connect API key goes to `https://ochk.io` and nowhere else.
|
|
326
|
+
|
|
298
327
|
## License
|
|
299
328
|
|
|
300
329
|
MIT.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/connect-consent.ts
|
|
4
|
+
var CONNECT_CONSENT_LABEL = "Also create my orangecheck account";
|
|
5
|
+
var CONNECT_CONSENT_BLURB = "It stays with orangecheck until you claim it at ochk.app. Then you can use it on other sites, or delete it.";
|
|
6
|
+
|
|
7
|
+
exports.CONNECT_CONSENT_BLURB = CONNECT_CONSENT_BLURB;
|
|
8
|
+
exports.CONNECT_CONSENT_LABEL = CONNECT_CONSENT_LABEL;
|
|
9
|
+
//# sourceMappingURL=connect-consent.js.map
|
|
10
|
+
//# sourceMappingURL=connect-consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/connect-consent.ts"],"names":[],"mappings":";;;AAiBO,IAAM,qBAAA,GAAwB;AAG9B,IAAM,qBAAA,GACT","file":"connect-consent.js","sourcesContent":["/**\n * @orangecheck/me-client/connect-consent\n *\n * The words for an optional \"also make me an orangecheck account\" box on a\n * site that keeps its own login (OC Connect). Plain strings with no imports, so\n * any UI can render its own checkbox: React, Vue, a server template, plain HTML.\n *\n * import {\n * CONNECT_CONSENT_LABEL,\n * CONNECT_CONSENT_BLURB,\n * } from '@orangecheck/me-client/connect-consent';\n *\n * Show the box unticked, never pre-ticked and never bundled with your Terms.\n * Ticked: call connectProvision with `consent: true`. Unticked: make no call.\n */\n\n/** The checkbox label. */\nexport const CONNECT_CONSENT_LABEL = 'Also create my orangecheck account';\n\n/** The line under the label. */\nexport const CONNECT_CONSENT_BLURB =\n 'It stays with orangecheck until you claim it at ochk.app. Then you can use it on ' +\n 'other sites, or delete it.';\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/connect-consent.ts
|
|
2
|
+
var CONNECT_CONSENT_LABEL = "Also create my orangecheck account";
|
|
3
|
+
var CONNECT_CONSENT_BLURB = "It stays with orangecheck until you claim it at ochk.app. Then you can use it on other sites, or delete it.";
|
|
4
|
+
|
|
5
|
+
export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL };
|
|
6
|
+
//# sourceMappingURL=connect-consent.mjs.map
|
|
7
|
+
//# sourceMappingURL=connect-consent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/connect-consent.ts"],"names":[],"mappings":";AAiBO,IAAM,qBAAA,GAAwB;AAG9B,IAAM,qBAAA,GACT","file":"connect-consent.mjs","sourcesContent":["/**\n * @orangecheck/me-client/connect-consent\n *\n * The words for an optional \"also make me an orangecheck account\" box on a\n * site that keeps its own login (OC Connect). Plain strings with no imports, so\n * any UI can render its own checkbox: React, Vue, a server template, plain HTML.\n *\n * import {\n * CONNECT_CONSENT_LABEL,\n * CONNECT_CONSENT_BLURB,\n * } from '@orangecheck/me-client/connect-consent';\n *\n * Show the box unticked, never pre-ticked and never bundled with your Terms.\n * Ticked: call connectProvision with `consent: true`. Unticked: make no call.\n */\n\n/** The checkbox label. */\nexport const CONNECT_CONSENT_LABEL = 'Also create my orangecheck account';\n\n/** The line under the label. */\nexport const CONNECT_CONSENT_BLURB =\n 'It stays with orangecheck until you claim it at ochk.app. Then you can use it on ' +\n 'other sites, or delete it.';\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './iden
|
|
|
2
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
|
+
export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.mjs';
|
|
5
6
|
|
|
6
7
|
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count';
|
|
7
8
|
interface TrustAttestationCount {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './iden
|
|
|
2
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
|
+
export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.js';
|
|
5
6
|
|
|
6
7
|
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count';
|
|
7
8
|
interface TrustAttestationCount {
|
package/dist/index.js
CHANGED
|
@@ -1216,6 +1216,10 @@ async function scopes(verb, options) {
|
|
|
1216
1216
|
}
|
|
1217
1217
|
var family = { scopes };
|
|
1218
1218
|
|
|
1219
|
+
// src/connect-consent.ts
|
|
1220
|
+
var CONNECT_CONSENT_LABEL = "Also create my orangecheck account";
|
|
1221
|
+
var CONNECT_CONSENT_BLURB = "It stays with orangecheck until you claim it at ochk.app. Then you can use it on other sites, or delete it.";
|
|
1222
|
+
|
|
1219
1223
|
// src/identity.ts
|
|
1220
1224
|
var DEFAULT_ISSUER2 = "https://me.ochk.io";
|
|
1221
1225
|
var DEFAULT_TTL_MS2 = 60 * 60 * 1e3;
|
|
@@ -1622,6 +1626,8 @@ var oc = {
|
|
|
1622
1626
|
|
|
1623
1627
|
exports.ALL_EVENT_SUBTYPES = ALL_EVENT_SUBTYPES;
|
|
1624
1628
|
exports.ARCHETYPE_TEMPLATES = ARCHETYPE_TEMPLATES;
|
|
1629
|
+
exports.CONNECT_CONSENT_BLURB = CONNECT_CONSENT_BLURB;
|
|
1630
|
+
exports.CONNECT_CONSENT_LABEL = CONNECT_CONSENT_LABEL;
|
|
1625
1631
|
exports.EVENT_SUBTYPES = EVENT_SUBTYPES;
|
|
1626
1632
|
exports.MAX_DROP_WINDOW_DAYS = MAX_DROP_WINDOW_DAYS;
|
|
1627
1633
|
exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
|