Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
FromEveryLanguage
everylang
Repository navigation
Code
Issues
36
(36)
Pull requests
17
(17)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
everylang
/
write_key.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
35 lines (25 loc) · 1.38 KB
main
Breadcrumbs
everylang
/
write_key.py
Copy path
Top
File metadata and controls
Code
Blame
35 lines (25 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Presenting this service's shared write key to the live-notes server.
The server authorizes *devices* rather than users (see ``writeAuth.ts``): a short list of
shared keys, one of which belongs to this Proclaim machine. The key is read from
``PROCLAIM_WRITE_KEY`` — set by the installer into the LaunchAgent plist — and attached to
the two privileged calls this service makes: asking for a full Y-Sweet token, and asking
the server to translate an item.
Deliberately tolerant of an unset key: during the rollout the server runs in ``observe``
mode, where a missing key is recorded and allowed, and a service that refused to start
without one would be a worse outage than the problem it guards against.
"""
from __future__ import annotations
import os
from typing import Dict, Optional
#: Must match WRITE_KEY_HEADER in writeAuth.ts.
WRITE_KEY_HEADER = "X-Write-Key"
ENV_VAR = "PROCLAIM_WRITE_KEY"
def get_write_key(env: Optional[Dict[str, str]] = None) -> Optional[str]:
"""The configured write key, or None when unset/blank."""
raw = (env if env is not None else os.environ).get(ENV_VAR, "")
return raw.strip() or None
def write_key_headers(write_key: Optional[str]) -> Dict[str, str]:
"""Headers presenting ``write_key``, or an empty dict when there is none."""
if not write_key or not write_key.strip():
return {}
return {WRITE_KEY_HEADER: write_key.strip()}
You can’t perform that action at this time.