Files
zeekay 19fdf55ceb feat(auth): one key scheme, minted and read in one place
A key now opens with what it is allowed to touch. `pk-` is publishable and
safe in a browser; `sk-` is secret and never leaves a server. The five marks
it replaces all began `ph` -- the upstream's initials -- and they were the
last of its brand a customer read back to us, in every SDK snippet. No word
rule could reach them, because `ph` is not a word.

The marks were also not telling the truth. The constant said `phc_` while
every live project token said `hi_`, so the middleware that routes on the
constant matched no real token at all. Two spellings existed and one was
fiction. Minting now happens in exactly one function and reading in exactly
one, so a second spelling has nowhere to live.

`phx_` (personal) and `phs_` (project secret) both become `sk-`. The mark
now says only that a value is secret; which store holds it is settled by
asking. That was already how personal keys worked -- keys minted before the
marks carry none, so the store always decided -- and both secret resolvers
already returned None on a miss and fell through, so one shared extractor
replaces the two that could drift apart.

OAuth's access and refresh tokens stay distinguishable as `at-` and `rt-`,
because the parser tells them apart before either is looked up, and the
domain-verification token becomes `vt-` rather than keeping a sixth mint of
its own.

`bin/debrand --check` now refuses the marks as a shape, so a seventh cannot
be coined. Two rules that were about to rename things that are not ours to
spell are bounded: `Lemon` no longer eats `LemonSqueezy`, and the `hog_flow`
rules no longer reach a Postgres table, a Datastore table or a route.

Keys are stored hashed, so a mark cannot be rewritten in place: the three
live project tokens have to be reminted.
2026-08-08 19:42:44 -07:00

88 lines
4.0 KiB
JSON

{
"api_key": "pk-VXRzc3poSG9GZm1JenRianJ6TTJFZGh4OWY2QXzx9f3",
"event": "$autocapture",
"timestamp": "2025-07-01T00:00:00Z",
"distinct_id": "019833ae-4913-7179-b6bc-019570abb1c9",
"properties": {
"$session_id": "019833a9-eaf4-753e-adaf-6c21075e4fd4",
"$feature_flag_payloads": {},
"$sdk_debug_replay_remote_trigger_matching_config": null,
"$process_person_profile": false,
"$lib_version": "1.2.3",
"$initialization_time": "2025-07-01T00:00:00Z",
"$raw_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
"$configured_session_timeout_ms": 1800000,
"$host": "insights.example.com",
"$browser_version": 138,
"$recording_status": "active",
"$sdk_debug_replay_internal_buffer_size": 1091,
"$session_recording_network_payload_capture": {
"capturePerformance": {
"network_timing": true,
"web_vitals": false
},
"recordBody": true,
"recordHeaders": true
},
"$replay_script_config": null,
"$sdk_debug_replay_internal_buffer_length": 6,
"$browser_language": "en-US",
"$replay_minimum_duration": null,
"$feature_flag_request_id": "019833ab-5ade-7372-91fb-adc4bd88c362",
"$ce_version": 1,
"$web_vitals_enabled_server_side": false,
"$session_entry_url": "https://insights.example.com/testing",
"$time": 1751353200,
"$insert_id": "abc123xyz456",
"$autocapture_disabled_server_side": false,
"$device_id": "019833ac-c978-77c0-af64-a8805694584a",
"$viewport_width": 2400,
"$session_recording_recorder_version_server_side": "v2",
"$dead_clicks_enabled_server_side": false,
"$timezone_offset": 360,
"$window_id": "019833ad-1898-73f7-be77-db0b11000766",
"$sdk_debug_retry_queue_size": 0,
"$sdk_debug_replay_url_trigger_status": "trigger_disabled",
"$pageview_id": "019833ad-4a80-7d61-9ce8-7182f94dc9e5",
"$session_entry_pathname": "/testing",
"$replay_sample_rate": null,
"$event_type": "click",
"$device_type": "Desktop",
"$is_identified": false,
"$lib":"web",
"$session_recording_canvas_recording": {
"enabled": true,
"fps": 3,
"quality": "0.4"
},
"token": "pk-VXRzc3poSG9GZm1JenRianJ6TTJFZGh4OWY2QXzx9f3",
"$session_entry_referring_domain": "$direct",
"$console_log_recording_enabled_server_side": true,
"$pathname": "/testing",
"$lib_rate_limit_remaining_tokens": 99,
"$referring_domain": "$direct",
"$sdk_debug_replay_event_trigger_status": "trigger_disabled",
"$referrer": "$direct",
"$session_entry_referrer": "$direct",
"$session_entry_host": "insights.example.com",
"$active_feature_flags":[],
"$screen_width": 1920,
"$sdk_debug_current_session_duration": 1157858,
"$session_recording_masking": null,
"$config_defaults": "unset",
"$os": "Windows",
"$os_version": "10",
"$sdk_debug_replay_linked_flag_trigger_status": "trigger_disabled",
"$viewport_height": 1148,
"$current_url": "https://insights.example.com/testing",
"$elements_chain": "span:nth-child=\"1\"nth-of-type=\"1\"text=\"Save Data\";button.btn.btn-primary:attr__class=\"btn btn-primary\"attr__type=\"button\"nth-child=\"1\"nth-of-type=\"1\"text=\"Save Data\";div:nth-child=\"2\"nth-of-type=\"2\";div.data-button-container:attr__class=\"data-button-container\"nth-child=\"3\"nth-of-type=\"3\";div:nth-child=\"1\"nth-of-type=\"1\";div.row:attr__class=\"row\"",
"$exception_capture_enabled_server_side": false,
"$browser": "Chrome",
"$browser_language_prefix": "en",
"$timezone": "America/Denver",
"$screen_height": 1080,
"$el_text": "Save Data",
"$sdk_debug_session_start": 1751353200
},
"offset":308
}