@333eco/origin-verify 0.4.0 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +7 -4
  2. package/index.mjs +11 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,10 +33,13 @@ Four states. Each stands alone and none implies another.
33
33
  **What a record does not say:** who imagined the work, or that one person holds one account. Without a signer's reveal it says *the operator witnessed this claim at this time and cannot later remove it*. With the reveal, *a passkey whose public key is given here signed exactly this claim*.
34
34
 
35
35
  **Version-3 records** name their press, inside the log's signature: `press: { key: "passkey" }`, or for a key held by the B-PoH app
36
- `{ key: "b-poh", unlock, shown }` (how it was unlocked; whose screen showed the words). A revealed press must carry the origin its
37
- press allows: a press made in the app's own screen (`shown: "app"`) one of the trust file's `appOrigins` — none is listed yet, so such
38
- a reveal is refused until the app ships — and every other press sign.333.eco's, including an app key pressed through the phone's
39
- passkey sheet, whose origin the browser writes. Version-2 records read exactly as before.
36
+ `{ key: "b-poh", unlock, shown, platform }` (how it was unlocked; whose screen showed the words; `android` or `ios`). A revealed press
37
+ must carry the origin its press allows: a press made in the app's own screen (`shown: "app"`) one of the trust file's `appOrigins`, in
38
+ its platform's form (`android:apk-key-hash:<…>` or `ios:app-id:<team>.<bundle>`) — none is listed yet, so such a reveal is refused
39
+ until the app ships — and every other press sign.333.eco's, including an Android app key pressed through the phone's passkey sheet,
40
+ whose origin the browser writes. An iPhone press is made only in the app's own screen and has no key statement: Apple's App Attest
41
+ vouched for the app, which vouched for the key. A `b-poh` record without `platform` (the sandbox's, before v1.11) reads as Android.
42
+ Version-2 records read exactly as before.
40
43
 
41
44
  **Key statements and revocations** (b-poh-statements §5, §6.1). A press made with a B-PoH app key may travel with a *key statement*:
42
45
  what sign.333.eco found, when the key was enrolled, about where the key lives and what unlocks it, signed by the key statement key
package/index.mjs CHANGED
@@ -169,8 +169,15 @@ export async function checkReveal(entry, opening, trust) {
169
169
  // Version 3: the record names its press, inside the log's signature. A press made in the B-PoH app's own screen (shown "app")
170
170
  // carries an app origin the trust file must list; every other press carries sign.333.eco's — a passkey, every version-2 record,
171
171
  // and an app key pressed through the phone's passkey sheet (shown "site"), whose origin the browser writes.
172
- const appPress = entry.v >= 3 && entry.press?.key === "b-poh" && entry.press?.shown === "app";
173
- const originOk = appPress ? Array.isArray(trust.appOrigins) && trust.appOrigins.includes(cd.origin) : cd.origin === trust.webOrigin;
172
+ // v1.11: `platform` says which phone pressed, and with it what was attested at enrollment, and the origin's FORM must agree: `ios` (Apple's
173
+ // App Attest attested the APP, which vouched for the key) presses only in the app's own screen, from `ios:app-id:<team>.<bundle>`;
174
+ // `android` (the phone attested the KEY itself) from `android:apk-key-hash:<…>`. A b-poh record without it was written before v1.11, in
175
+ // the sandbox, on Android: read as `android`. So a record cannot name one platform and carry the other's press.
176
+ const bpoh = entry.v >= 3 && entry.press?.key === "b-poh", platform = entry.press?.platform ?? "android";
177
+ if (bpoh && !(platform === "android" || (platform === "ios" && entry.press.shown === "app"))) return fail("the record's press says something no app writes");
178
+ const appPress = bpoh && entry.press?.shown === "app";
179
+ const form = platform === "ios" ? "ios:app-id:" : "android:apk-key-hash:";
180
+ const originOk = appPress ? Array.isArray(trust.appOrigins) && trust.appOrigins.includes(cd.origin) && String(cd.origin).startsWith(form) : cd.origin === trust.webOrigin;
174
181
  if (cd.type !== "webauthn.get" || !originOk || cd.challenge !== entry.claimCommitment) return fail("the assertion was made elsewhere or for something else");
175
182
  const auth = raw.authenticatorData;
176
183
  if (auth.length < 37 || !eq(auth.subarray(0, 32), sha256(utf8(trust.rpId)))) return fail("the assertion names another site");
@@ -207,6 +214,8 @@ export async function checkKeyStatement(statement, entry, opening, trust, revoca
207
214
  if (!good) return fail("the key statement's signature does not verify");
208
215
  if (statement.key !== keyIdOf(b64u(String(opening?.credentialPublicKey ?? "")))) return fail("a key statement that doesn't belong to this press");
209
216
  if (!(entry?.v >= 3 && entry.press?.key === "b-poh")) return fail("this record was not pressed with a B-PoH app key");
217
+ // v1.11: a key statement is about a key the phone itself attested; an iPhone's (platform: "ios") has none.
218
+ if (entry.press.platform === "ios") return fail("an iPhone press has no key statement: Apple attested the app, not the key");
210
219
  if (entry.press.unlock !== statement.attested?.unlock) return fail("the record's unlock is not one this key allows");
211
220
  if (!(Date.parse(statement.checked) <= Date.parse(entry.witnessedAt))) return fail("the key statement is dated after the press");
212
221
  const base = { ok: true, key: statement.key, checked: statement.checked, attested: statement.attested, declared: statement.declared };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@333eco/origin-verify",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Checks a B-Origin record with no help from its operator: signatures, its place in the public log, witness cosignatures, RFC 3161 tokens, OpenTimestamps proofs against Bitcoin, and a signer's reveal. Browser or Node, no runtime dependencies.",
5
5
  "license": "CC0-1.0 OR Apache-2.0",
6
6
  "author": "Thon Ly",