Skip to content

Per field tokenization - #9

Merged
stremovsky merged 7 commits into
mainfrom
per-field-tokenization
Aug 20, 2026
Merged

Per field tokenization#9
stremovsky merged 7 commits into
mainfrom
per-field-tokenization

Conversation

@stremovsky

Copy link
Copy Markdown
Contributor

No description provided.

stremovsky and others added 7 commits August 20, 2026 18:04
json.dumps renders Python None as JSON null, so a key assigned
options.get(k) was still present on the wire. The server builds its
required-parameter set by testing key presence, so a null counted as
supplied and got validated:

  - create_shared_record sent "appname": null and was rejected every
    time with "The appname parameter has an incorrect format", making
    the method unusable unless the caller passed an appname.
  - create_legal_basis sent "requiredflag": null, which panicked the
    server outright.

The sibling SDKs avoid this for free — JSON.stringify drops undefined,
PHP guards with isset(), Java checks != null — so Python needs the
guard spelled out. _add_options() copies only supplied options into the
body; an AST scan for keys assigned a possibly-None value found seven
methods, all now routed through it.

tests/test_field_tokenization.py covers the two flows a customer needs
for per-field tokenization, each with single and bulk requests:

  - Per-field shared identities: a 10-field profile exposed through one
    SharedRecordCreate UUID per field, redeemed with no X-Bunker-Token,
    including field scoping and expiry.
  - Format-preserving tokenization: every value stringified through
    TokenCreate/TokenCreateBulk with unique set, round-tripped, with
    Luhn and length checks on the card token.

Two tests track server-side work that is fixed in source but not yet
deployed to pro.databunker.org: the bulk `unique` dedup assertion
fails, and the `string` type alias skips.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
FORMAT_PRESERVING_TYPES listed unixtimestamp, uint64 and uint32
alongside creditcard, but _token_type only ever returns creditcard or
text, so those three could never be reached. The set documented the
server's wider capabilities rather than anything this file exercises.

Drop it and test the one distinction that applies here: the card gets a
tokenbase, every string field does not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The customer's "create a user token" is the record token UserCreate
returns, which is what the shared records are keyed on. Minting a login
xtoken as well tested authenticated access, which is beside the point of
a flow whose whole premise is retrieval without a credential.

Replace it with a check that the record token reads back the stored
profile.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The test sent "string" only to prove it aliases "text", which made the
file depend on a pro.databunker.org deploy and put a skipTest in the way
of a real assertion. The alias belongs to the server and is covered
there by TestV2StringTokenTypeAlias.

Every field here goes through the canonical "text".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@stremovsky
stremovsky merged commit 58a28bf into main Aug 20, 2026
4 of 6 checks passed
@stremovsky
stremovsky deleted the per-field-tokenization branch August 20, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant