Skip to content

Bindings: encode the new value kinds from JavaScript and Go (BigInt to 128 bits, Date, narrow integers) #375

Closed

Description

@coderdan

Background

A binding turns a host-language value into a Value. Node's aead-napi does
this in-process. Go's vcffi serialises the value across WebAssembly memory.

Problem

  1. aead-napi rejects a BigInt above u64::MAX (convert.rs:13, 256) and
    refuses JavaScript Date (convert.rs:321).
  2. Go widens int8, int16 and int32 to Int32, and the unsigned widths to
    UInt32 (bindings/go/vcffi/encoder.go:443-446, 550-556).
  3. Neither binding knows Date, Timestamp or Decimal.

Proposal

  1. JavaScript:
    • a BigInt maps to the smallest integer kind that holds it, up to 128
      bits, and always decodes as a BigInt;
    • Date maps to Timestamp;
    • a date has its own wrapper, { date: "YYYY-MM-DD" }, or PlainDate
      where Temporal exists.
  2. Go:
    • each integer width maps to its own kind;
    • SDK value types Int128 and Uint128;
    • time.Time maps to Timestamp;
    • a Date value type for dates.
  3. Decimal: NaN and ±Infinity are refused with a typed error in both
    bindings.
  4. Both bindings run the shared value-level vectors from aead-value: a cross-language conformance corpus for the FFI transport codec #332.

Needs #372. Decided in ADR-0002 (cipherstash/stack#1139).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions