@outpost-protocol/core 0.2.0 → 0.3.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/dist/wire.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { decodeFramed, encodeFramed, MAX_FRAMED_BASE32_LEN, splitFramed } from "./base32.js";
2
2
  import { parseUrSmeshFrame, UR_SMESH_PREFIX } from "./bcur.js";
3
+ import { decodeSmeshh1Bytes, HRP_SMESHH } from "./hw.js";
3
4
  import { assertBigInt, assertBytesLength, assertSortedUniqueWitnesses, assertU16, assertU32, assertU8, concatBytes, decodeI64Be, decodeU128Be, decodeU16Be, decodeU32Be, decodeU64Be, encodeI64Be, encodeU128Be, encodeU16Be, encodeU32Be, encodeU64Be, encodeU8, MAX_I128, MAX_I64, MAX_U128, MAX_U64, MAX_WITNESSES, } from "./digest.js";
4
5
  import { assertNetworkHint, assertValidWireAddress, decodeWireAddress, decodeWireToken, encodeWireAddress, encodeWireToken, WIRE_ADDRESS_BYTE_LENGTH, } from "./xdr.js";
5
6
  // ---------------------------------------------------------------------------
@@ -28,6 +29,9 @@ export const SREQ1_TLV_GATEWAY = 0x03;
28
29
  export const SREQ1_TLV_CLASSIC_ASSET = 0x04;
29
30
  export const SREQ1_TLV_ACCEPTED_FACTORY_VERS = 0x05;
30
31
  export const SREQ1_TLV_MEMO = 0x06;
32
+ /** Optional odd TLV (`0xF1`, safely ignored by v1.2 wallets): `1..=4` concatenated 32B Ed25519 pubkeys of trusted v2 Hardware Attestation Verifiers. */
33
+ export const SREQ1_TLV_HW_VERIFIER_PUBKEYS = 0xf1;
34
+ export const MAX_SREQ1_HW_VERIFIER_PUBKEYS = 4;
31
35
  const utf8Encoder = new TextEncoder();
32
36
  const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
33
37
  const ASSET_CODE_REGEX = /^[A-Za-z0-9]{1,12}$/;
@@ -182,6 +186,16 @@ export function encodeSreq1Bytes(packet) {
182
186
  }
183
187
  parts.push(encodeTlv(SREQ1_TLV_MEMO, memoBytes));
184
188
  }
189
+ if (packet.hwVerifierPubkeys !== undefined) {
190
+ if (packet.hwVerifierPubkeys.length < 1 ||
191
+ packet.hwVerifierPubkeys.length > MAX_SREQ1_HW_VERIFIER_PUBKEYS) {
192
+ throw new Error(`SREQ1 hwVerifierPubkeys count must be in 1..=${MAX_SREQ1_HW_VERIFIER_PUBKEYS}, got ${packet.hwVerifierPubkeys.length}`);
193
+ }
194
+ for (let i = 0; i < packet.hwVerifierPubkeys.length; i++) {
195
+ assertBytesLength(packet.hwVerifierPubkeys[i], 32, `hwVerifierPubkeys[${i}]`);
196
+ }
197
+ parts.push(encodeTlv(SREQ1_TLV_HW_VERIFIER_PUBKEYS, concatBytes(...packet.hwVerifierPubkeys)));
198
+ }
185
199
  return concatBytes(...parts);
186
200
  }
187
201
  export function decodeSreq1Bytes(raw) {
@@ -227,6 +241,7 @@ export function decodeSreq1Bytes(raw) {
227
241
  let classicAsset;
228
242
  let acceptedFactoryVers;
229
243
  let memo;
244
+ let hwVerifierPubkeys;
230
245
  const seenKnownTlvs = new Set();
231
246
  let unknownOddTlvCount = 0;
232
247
  while (offset < raw.length) {
@@ -313,6 +328,19 @@ export function decodeSreq1Bytes(raw) {
313
328
  memo = utf8Decoder.decode(val);
314
329
  break;
315
330
  }
331
+ case SREQ1_TLV_HW_VERIFIER_PUBKEYS: {
332
+ if (seenKnownTlvs.has(tlvType))
333
+ throw new Error("Duplicate SREQ1 hw_verifier_pubkeys TLV");
334
+ seenKnownTlvs.add(tlvType);
335
+ if (tlvLen === 0 || tlvLen % 32 !== 0 || tlvLen / 32 > MAX_SREQ1_HW_VERIFIER_PUBKEYS) {
336
+ throw new Error(`Invalid SREQ1 hw_verifier_pubkeys TLV length: ${tlvLen} (must be 32..=${MAX_SREQ1_HW_VERIFIER_PUBKEYS * 32}, multiple of 32)`);
337
+ }
338
+ hwVerifierPubkeys = [];
339
+ for (let i = 0; i < tlvLen; i += 32) {
340
+ hwVerifierPubkeys.push(val.slice(i, i + 32));
341
+ }
342
+ break;
343
+ }
316
344
  default: {
317
345
  // WIRE-FORMAT-v1.2.md §4.1: Even unknown types MUST fail; odd unknown types skip.
318
346
  if ((tlvType & 1) === 0) {
@@ -350,6 +378,7 @@ export function decodeSreq1Bytes(raw) {
350
378
  ...(classicAsset !== undefined ? { classicAsset } : {}),
351
379
  ...(acceptedFactoryVers !== undefined ? { acceptedFactoryVers } : {}),
352
380
  ...(memo !== undefined ? { memo } : {}),
381
+ ...(hwVerifierPubkeys !== undefined ? { hwVerifierPubkeys } : {}),
353
382
  };
354
383
  }
355
384
  export function encodeSreq1(packet) {
@@ -991,6 +1020,8 @@ export function classifyPayload(encoded) {
991
1020
  };
992
1021
  case HRP_SMESHC:
993
1022
  return { mode: "witnessed_vault_cert", prefix: "SMESHC1", decoded: decodeSmeshc1Bytes(payload) };
1023
+ case HRP_SMESHH:
1024
+ return { mode: "hw_roaming_payment", prefix: "SMESHH1", decoded: decodeSmeshh1Bytes(payload) };
994
1025
  default:
995
1026
  throw new Error(`Unknown Outpost wire prefix "${hrp}1"`);
996
1027
  }
@@ -36,9 +36,12 @@ export interface WitnessChallengeResponseDto {
36
36
  readonly instance_uuid: string;
37
37
  readonly latest_known_ledger: number;
38
38
  readonly signature: string;
39
+ readonly signature_v2?: string;
40
+ readonly signature_v3?: string;
39
41
  }
40
42
  export interface WitnessInfoResponse {
41
43
  readonly station_id?: string;
44
+ readonly moniker?: string;
42
45
  readonly version: string;
43
46
  readonly protocol_version?: string;
44
47
  readonly network_hint?: number;
@@ -74,6 +77,10 @@ export interface StoredGenesisCertMeta {
74
77
  readonly witness_threshold: number;
75
78
  readonly witnesses: readonly string[];
76
79
  readonly genesis_sigs: readonly WitnessSigEntryDto[];
80
+ /** Optional token symbol (e.g. `"XLM"`, `"USDC"`, or on-chain SEP-41 symbol) learned at L1 genesis or canonical wire token. */
81
+ readonly token_symbol?: string;
82
+ /** Optional token decimals (`0..=18`) learned at L1 genesis or canonical wire token (omitted if unknown). */
83
+ readonly token_decimals?: number;
77
84
  }
78
85
  /**
79
86
  * Canonical `"SMW1_FRESH"` checkpoint DTO exchanged with Rust `witness-node` (`DS-05`).
@@ -147,6 +154,18 @@ export interface WitnessPendingLock {
147
154
  /** Optional `SMESHC1` quorum cert (`seq < first_link.seq`) proving pre-chain base for out-of-order locks (`V1-NEW-1` / `R5-H8`). */
148
155
  readonly base_cert?: string;
149
156
  }
157
+ /**
158
+ * Non-authoritative per-`seq` settlement relay hint returned by a Station on `GET /state`.
159
+ *
160
+ * Security invariant (`AGENTS.md` §1.6): wallets/receivers may show this as an informational
161
+ * UX hint while still offline, but MUST NEVER treat a single Station's claim as terminal
162
+ * `L1_FINAL` finality or delete `SMESHC1` without direct Stellar L1 confirmation.
163
+ */
164
+ export interface RelayedReceiptHintDto {
165
+ readonly seq: number;
166
+ readonly relayed_at: number;
167
+ readonly tx_hash?: string;
168
+ }
150
169
  export interface GetStateResponse {
151
170
  readonly cert_0?: string | null;
152
171
  readonly cert_0_meta?: StoredGenesisCertMeta;
@@ -160,6 +179,7 @@ export interface GetStateResponse {
160
179
  readonly closed?: boolean;
161
180
  readonly frozen?: boolean;
162
181
  readonly equivocation_proof?: Record<string, unknown> | null;
182
+ readonly relayed_receipts?: readonly RelayedReceiptHintDto[];
163
183
  }
164
184
  export interface WitnessSignRequest {
165
185
  /** Framed `SMESHI1...` unwitnessed intent string. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outpost-protocol/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Outpost v1.2 offline Stellar payment wire codec, cryptographic digests, BLE transport, and wallet SDK",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://outpost.cash",