@orangecheck/me-client 0.51.0 → 0.53.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/CHANGELOG.md CHANGED
@@ -8,6 +8,27 @@ and [Semantic Versioning](https://semver.org/). Wire-format / canonical-message
8
8
  changes are coordinated via the relevant `oc-*-protocol` spec repo's CHANGELOG;
9
9
  this file tracks the package's TS / Node / runtime API surface.
10
10
 
11
+ ## [0.53.0] — 2026-10-25
12
+
13
+ ### Changed
14
+
15
+ - `requireBond` throws a TypeError when `withOcAuth`, `ocAuthExpress`,
16
+ `ocAuthHono`, `checkOcSession` or `checkSignInRule` is given one whose
17
+ `minSats`, `minDays` or `maxAgeSecs` is not left out or a whole number of 0
18
+ or more: NaN (an unset env var read with `Number()`), a string, a fraction or
19
+ null. `bondMeets`, from auth-core ^2.24.0, is false for such a floor.
20
+ `readBondNeed` is exported beside it. Held to auth-core's
21
+ `test-vectors/bond-need.json`.
22
+
23
+ ## [0.52.0] — 2026-10-25
24
+
25
+ ### Changed
26
+
27
+ - `connectProvision` checks the returned did with `isDidOc` from
28
+ `@orangecheck/auth-core/identifiers` (now `^2.22.0`) instead of a local copy.
29
+ `test-vectors/connect.json` adds a did with a trailing newline and one in
30
+ upper case; both answer `unavailable`, in sdk-py too.
31
+
11
32
  ## [0.51.0] — 2026-10-24
12
33
 
13
34
  ### Added
package/README.md CHANGED
@@ -101,7 +101,7 @@ export default withOcAuth(handler, {
101
101
  });
102
102
  ```
103
103
 
104
- 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.
104
+ 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. Each value is left out or a whole number of 0 or more; anything else (NaN from an unset env var, a string, a fraction) throws when the adapter is made. 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.
105
105
 
106
106
  `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:
107
107
 
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RevocationCheck, SessionPayload, VerifyOcOptions, SessionRequestHeaders } from '@orangecheck/auth-core';
2
- export { BondClaim, SessionPayload, VerifyOcOptions, bondMeets, readBondClaim } from '@orangecheck/auth-core';
2
+ export { BondClaim, SessionPayload, VerifyOcOptions, bondMeets, readBondClaim, readBondNeed } from '@orangecheck/auth-core';
3
3
  export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity, r as refreshEnvelopeJwks, v as verifyActivityAttestation } from './identity-DfxCvxuH.mjs';
4
4
  export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.mjs';
5
5
 
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RevocationCheck, SessionPayload, VerifyOcOptions, SessionRequestHeaders } from '@orangecheck/auth-core';
2
- export { BondClaim, SessionPayload, VerifyOcOptions, bondMeets, readBondClaim } from '@orangecheck/auth-core';
2
+ export { BondClaim, SessionPayload, VerifyOcOptions, bondMeets, readBondClaim, readBondNeed } from '@orangecheck/auth-core';
3
3
  export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity, r as refreshEnvelopeJwks, v as verifyActivityAttestation } from './identity-DfxCvxuH.js';
4
4
  export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.js';
5
5
 
package/dist/server.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var authCore = require('@orangecheck/auth-core');
4
+ var identifiers = require('@orangecheck/auth-core/identifiers');
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -568,12 +569,9 @@ var identity = {
568
569
  verifyActivityAttestation,
569
570
  refreshEnvelopeJwks
570
571
  };
571
-
572
- // src/connect.ts
573
572
  var ORIGIN = "https://ochk.io";
574
573
  var DEFAULT_TIMEOUT_MS = 5e3;
575
574
  var MAX_TIMEOUT_MS = 3e4;
576
- var DID_OC = /^did:oc:[0-9a-f]{32}$/;
577
575
  var BASE_KEYS = ["apiKey", "userId", "timeoutMs"];
578
576
  var PROVISION_KEYS = /* @__PURE__ */ new Set([...BASE_KEYS, "consent", "email", "emailVerified"]);
579
577
  var USER_KEYS = new Set(BASE_KEYS);
@@ -690,7 +688,7 @@ function connectProvision(options) {
690
688
  (answer) => {
691
689
  const b = answer.body;
692
690
  if (answer.status !== 200) return refused(answer, PROVISION_REASONS);
693
- const good = b?.ok === true && typeof b.did_oc === "string" && DID_OC.test(b.did_oc) && typeof b.is_new === "boolean";
691
+ const good = b?.ok === true && identifiers.isDidOc(b.did_oc) && typeof b.is_new === "boolean";
694
692
  return good ? { ok: true, did_oc: b.did_oc, is_new: b.is_new } : { ok: false, reason: "unavailable", status: 200 };
695
693
  }
696
694
  );
@@ -1170,6 +1168,11 @@ function checkOptions(options) {
1170
1168
  `@orangecheck/me-client: requireBond: unknown option ${extra.join(", ")}. It reads only ${[...BOND_OPTIONS].join(", ")}.`
1171
1169
  );
1172
1170
  }
1171
+ if (!authCore.readBondNeed(bond)) {
1172
+ throw new TypeError(
1173
+ "@orangecheck/me-client: requireBond: minSats, minDays and maxAgeSecs must each be left out or a whole number of 0 or more"
1174
+ );
1175
+ }
1173
1176
  }
1174
1177
  var BACK_ACCOUNT_URL = "https://ochk.app/me/account#backing";
1175
1178
  var stamp = () => ({ mono: performance.now(), wall: Date.now() });
@@ -1370,6 +1373,10 @@ Object.defineProperty(exports, "readBondClaim", {
1370
1373
  enumerable: true,
1371
1374
  get: function () { return authCore.readBondClaim; }
1372
1375
  });
1376
+ Object.defineProperty(exports, "readBondNeed", {
1377
+ enumerable: true,
1378
+ get: function () { return authCore.readBondNeed; }
1379
+ });
1373
1380
  exports.BACK_ACCOUNT_URL = BACK_ACCOUNT_URL;
1374
1381
  exports.CONNECT_CONSENT_BLURB = CONNECT_CONSENT_BLURB;
1375
1382
  exports.CONNECT_CONSENT_LABEL = CONNECT_CONSENT_LABEL;