proton-alias-send 0.1.0__py3-none-any.whl
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.
- proton_alias_send/__init__.py +7 -0
- proton_alias_send/__main__.py +8 -0
- proton_alias_send/cli.py +578 -0
- proton_alias_send/py.typed +0 -0
- proton_alias_send-0.1.0.dist-info/METADATA +157 -0
- proton_alias_send-0.1.0.dist-info/RECORD +9 -0
- proton_alias_send-0.1.0.dist-info/WHEEL +4 -0
- proton_alias_send-0.1.0.dist-info/entry_points.txt +2 -0
- proton_alias_send-0.1.0.dist-info/licenses/LICENSE +203 -0
proton_alias_send/cli.py
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
proton-alias-send - Create a Proton Pass / SimpleLogin reverse alias
|
|
4
|
+
(contact) for sending email from an alias without going through the dashboard.
|
|
5
|
+
|
|
6
|
+
Config file (create with --init-config):
|
|
7
|
+
Linux/macOS : ~/.config/proton-alias-send/config.toml (or $XDG_CONFIG_HOME)
|
|
8
|
+
Windows : %APPDATA%\\proton-alias-send\\config.toml
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
proton-alias-send --init-config # first-time setup
|
|
12
|
+
proton-alias-send recipient@example.com # alias + key come from config
|
|
13
|
+
proton-alias-send -a alias@sl.io --copy recipient@example.com
|
|
14
|
+
|
|
15
|
+
The reverse alias is written to stdout; progress/status goes to stderr, so
|
|
16
|
+
the result can be piped or captured cleanly.
|
|
17
|
+
|
|
18
|
+
Requires Python 3.11+ (stdlib tomllib).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import http.client
|
|
25
|
+
import ipaddress
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import platform
|
|
29
|
+
import stat
|
|
30
|
+
import subprocess
|
|
31
|
+
import sys
|
|
32
|
+
import tomllib
|
|
33
|
+
import urllib.error
|
|
34
|
+
import urllib.parse
|
|
35
|
+
import urllib.request
|
|
36
|
+
from pathlib import Path
|
|
37
|
+
from typing import Any
|
|
38
|
+
|
|
39
|
+
APP_NAME = "proton-alias-send"
|
|
40
|
+
DEFAULT_BASE_URL = "https://app.simplelogin.io"
|
|
41
|
+
|
|
42
|
+
# Seconds to wait on any single API call before giving up.
|
|
43
|
+
REQUEST_TIMEOUT = 30
|
|
44
|
+
|
|
45
|
+
# Safety net for paginating alias search results: a server that ignores page_id
|
|
46
|
+
# would otherwise loop forever. The API returns 20 aliases per page, so this is
|
|
47
|
+
# 400 results, which is plenty because the search narrows them to near-matches.
|
|
48
|
+
MAX_ALIAS_PAGES = 20
|
|
49
|
+
|
|
50
|
+
# Keys recognised in the config file.
|
|
51
|
+
KNOWN_CONFIG_KEYS = {"api_key", "alias", "base_url", "copy", "quiet"}
|
|
52
|
+
|
|
53
|
+
SAMPLE_CONFIG = """\
|
|
54
|
+
# proton-alias-send configuration
|
|
55
|
+
# Run `proton-alias-send --init-config` to recreate this file.
|
|
56
|
+
#
|
|
57
|
+
# Tip: restrict read access after creation (already done on Unix):
|
|
58
|
+
# chmod 600 {config_path}
|
|
59
|
+
|
|
60
|
+
# Your SimpleLogin API key (required if not passed via --api-key).
|
|
61
|
+
# Get it at: https://app.simplelogin.io/dashboard/api_key
|
|
62
|
+
# Leave empty to fall back to the $SIMPLELOGIN_API_KEY environment variable.
|
|
63
|
+
api_key = ""
|
|
64
|
+
|
|
65
|
+
# Default alias to send from. Override per-invocation with -a / --alias.
|
|
66
|
+
# alias = "you@simplelogin.io"
|
|
67
|
+
|
|
68
|
+
# SimpleLogin API base URL. Change only for self-hosted instances.
|
|
69
|
+
base_url = "{base_url}"
|
|
70
|
+
|
|
71
|
+
# Copy the reverse alias to the clipboard automatically after printing.
|
|
72
|
+
copy = false
|
|
73
|
+
|
|
74
|
+
# Suppress progress messages (stderr). Only the reverse alias is printed.
|
|
75
|
+
quiet = false
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# ---------------------------------------------------------------------------
|
|
80
|
+
# Config path
|
|
81
|
+
# ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
def get_config_dir() -> Path:
|
|
84
|
+
system = platform.system()
|
|
85
|
+
if system == "Windows":
|
|
86
|
+
base = Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming")
|
|
87
|
+
else:
|
|
88
|
+
# Linux, macOS, BSDs - honour XDG_CONFIG_HOME. Empty counts as unset, per
|
|
89
|
+
# the XDG spec; otherwise the config would land in the current directory.
|
|
90
|
+
base = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
|
|
91
|
+
return base / APP_NAME
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_config_path() -> Path:
|
|
95
|
+
return get_config_dir() / "config.toml"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
# Config loading and merging
|
|
100
|
+
# ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
def load_config(config_path: Path) -> dict[str, Any]:
|
|
103
|
+
"""Load and return the TOML config, or {} if the file doesn't exist."""
|
|
104
|
+
if not config_path.exists():
|
|
105
|
+
return {}
|
|
106
|
+
try:
|
|
107
|
+
with open(config_path, "rb") as fh:
|
|
108
|
+
config = tomllib.load(fh)
|
|
109
|
+
except OSError as exc:
|
|
110
|
+
sys.exit(f"Error reading config file {config_path}: {exc}")
|
|
111
|
+
except (tomllib.TOMLDecodeError, UnicodeDecodeError) as exc:
|
|
112
|
+
sys.exit(f"Error parsing config file {config_path}: {exc}")
|
|
113
|
+
|
|
114
|
+
unknown = set(config.keys()) - KNOWN_CONFIG_KEYS
|
|
115
|
+
if unknown:
|
|
116
|
+
print(
|
|
117
|
+
f"Warning: unknown config key(s) will be ignored: {', '.join(sorted(unknown))}",
|
|
118
|
+
file=sys.stderr,
|
|
119
|
+
)
|
|
120
|
+
return config
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def merge(cli_val: Any, config_val: Any, fallback: Any) -> Any:
|
|
124
|
+
"""
|
|
125
|
+
Return the highest-priority set value: CLI > config > env/hardcoded default.
|
|
126
|
+
|
|
127
|
+
An empty string counts as unset so that the `api_key = ""` line in the
|
|
128
|
+
generated sample config still falls through to $SIMPLELOGIN_API_KEY.
|
|
129
|
+
"""
|
|
130
|
+
for value in (cli_val, config_val):
|
|
131
|
+
if value is not None and value != "":
|
|
132
|
+
return value
|
|
133
|
+
return fallback
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# ---------------------------------------------------------------------------
|
|
137
|
+
# Config initialisation
|
|
138
|
+
# ---------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
def cmd_init_config(config_path: Path) -> int:
|
|
141
|
+
"""Write a sample config file and set restrictive permissions on Unix."""
|
|
142
|
+
if config_path.exists():
|
|
143
|
+
try:
|
|
144
|
+
answer = input(
|
|
145
|
+
f"Config already exists at {config_path}. Overwrite? [y/N] "
|
|
146
|
+
).strip().lower()
|
|
147
|
+
except EOFError:
|
|
148
|
+
# Non-interactive stdin: refuse rather than clobber the file.
|
|
149
|
+
print(
|
|
150
|
+
f"Error: config already exists at {config_path} and stdin is not "
|
|
151
|
+
"interactive. Remove the file first to recreate it.",
|
|
152
|
+
file=sys.stderr,
|
|
153
|
+
)
|
|
154
|
+
return 1
|
|
155
|
+
if answer != "y":
|
|
156
|
+
print("Aborted.", file=sys.stderr)
|
|
157
|
+
return 0
|
|
158
|
+
|
|
159
|
+
try:
|
|
160
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
161
|
+
config_path.write_text(
|
|
162
|
+
SAMPLE_CONFIG.format(config_path=config_path, base_url=DEFAULT_BASE_URL),
|
|
163
|
+
encoding="utf-8",
|
|
164
|
+
)
|
|
165
|
+
if platform.system() != "Windows":
|
|
166
|
+
config_path.chmod(stat.S_IRUSR | stat.S_IWUSR) # 600
|
|
167
|
+
print(f"Created {config_path} (permissions: 600)", file=sys.stderr)
|
|
168
|
+
else:
|
|
169
|
+
print(f"Created {config_path}", file=sys.stderr)
|
|
170
|
+
except OSError as exc:
|
|
171
|
+
print(f"Error writing config file {config_path}: {exc}", file=sys.stderr)
|
|
172
|
+
return 1
|
|
173
|
+
|
|
174
|
+
print("Edit the file to add your API key and default alias.", file=sys.stderr)
|
|
175
|
+
return 0
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# ---------------------------------------------------------------------------
|
|
179
|
+
# SimpleLogin API
|
|
180
|
+
# ---------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
def _require_http_url(url: str) -> None:
|
|
183
|
+
"""Reject anything but http(s), which urllib would otherwise happily open (e.g. file://)."""
|
|
184
|
+
try:
|
|
185
|
+
scheme = urllib.parse.urlsplit(url).scheme.lower()
|
|
186
|
+
except ValueError:
|
|
187
|
+
scheme = ""
|
|
188
|
+
if scheme not in ("http", "https"):
|
|
189
|
+
raise RuntimeError(f"Invalid base URL in {url}: it must start with https:// or http://")
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _error_text(payload: Any) -> str:
|
|
193
|
+
"""Pull a human-readable message out of whatever the API returned."""
|
|
194
|
+
if isinstance(payload, dict):
|
|
195
|
+
for key in ("error", "message"):
|
|
196
|
+
value = payload.get(key)
|
|
197
|
+
if isinstance(value, str) and value:
|
|
198
|
+
return value
|
|
199
|
+
return str(payload)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _request(
|
|
203
|
+
method: str, url: str, api_key: str, body: dict[str, Any] | None = None
|
|
204
|
+
) -> dict[str, Any]:
|
|
205
|
+
"""
|
|
206
|
+
Perform a JSON API call and return the decoded object.
|
|
207
|
+
|
|
208
|
+
Every failure mode - HTTP error, transport error, malformed body - is
|
|
209
|
+
normalised into RuntimeError so callers have a single thing to catch.
|
|
210
|
+
"""
|
|
211
|
+
_require_http_url(url)
|
|
212
|
+
data = json.dumps(body).encode() if body is not None else None
|
|
213
|
+
req = urllib.request.Request(
|
|
214
|
+
url, data=data, headers={"Content-Type": "application/json"}, method=method
|
|
215
|
+
)
|
|
216
|
+
# Unredirected, so a redirect can't carry the key to another host. SimpleLogin
|
|
217
|
+
# spells this header `Authentication`, not `Authorization`.
|
|
218
|
+
req.add_unredirected_header("Authentication", api_key)
|
|
219
|
+
try:
|
|
220
|
+
with urllib.request.urlopen(req, timeout=REQUEST_TIMEOUT) as resp:
|
|
221
|
+
raw = resp.read()
|
|
222
|
+
except urllib.error.HTTPError as exc:
|
|
223
|
+
try:
|
|
224
|
+
error_body = exc.read()
|
|
225
|
+
except (OSError, http.client.HTTPException):
|
|
226
|
+
error_body = b""
|
|
227
|
+
try:
|
|
228
|
+
payload = json.loads(error_body)
|
|
229
|
+
except (json.JSONDecodeError, UnicodeDecodeError):
|
|
230
|
+
payload = error_body.decode(errors="replace").strip()
|
|
231
|
+
hint = ""
|
|
232
|
+
if exc.code == 401:
|
|
233
|
+
hint = " (check your API key)"
|
|
234
|
+
raise RuntimeError(f"HTTP {exc.code} from {url}: {_error_text(payload)}{hint}") from None
|
|
235
|
+
except urllib.error.URLError as exc:
|
|
236
|
+
raise RuntimeError(f"Could not reach {url}: {exc.reason}") from None
|
|
237
|
+
except TimeoutError:
|
|
238
|
+
raise RuntimeError(f"Timed out after {REQUEST_TIMEOUT}s waiting for {url}") from None
|
|
239
|
+
except (OSError, http.client.HTTPException) as exc:
|
|
240
|
+
raise RuntimeError(f"Could not reach {url}: {exc}") from None
|
|
241
|
+
except ValueError:
|
|
242
|
+
# http.client quotes the offending header in this exception, so never
|
|
243
|
+
# include it here: the bad value is usually the API key.
|
|
244
|
+
raise RuntimeError(
|
|
245
|
+
f"Could not send the request to {url}: the API key or URL contains "
|
|
246
|
+
"invalid characters."
|
|
247
|
+
) from None
|
|
248
|
+
|
|
249
|
+
try:
|
|
250
|
+
decoded = json.loads(raw)
|
|
251
|
+
except (json.JSONDecodeError, UnicodeDecodeError):
|
|
252
|
+
snippet = raw[:200].decode(errors="replace").strip()
|
|
253
|
+
raise RuntimeError(f"Non-JSON response from {url}: {snippet!r}") from None
|
|
254
|
+
|
|
255
|
+
if not isinstance(decoded, dict):
|
|
256
|
+
raise RuntimeError(f"Unexpected response from {url}: expected an object, got {decoded!r}")
|
|
257
|
+
return decoded
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def find_alias_id(base_url: str, api_key: str, alias_email: str) -> int | None:
|
|
261
|
+
"""Search the account's aliases and return the ID for alias_email, or None."""
|
|
262
|
+
alias_email = alias_email.lower().strip()
|
|
263
|
+
base_url = base_url.rstrip("/")
|
|
264
|
+
for page in range(MAX_ALIAS_PAGES):
|
|
265
|
+
# The query is a loose server-side match, so results still need the exact
|
|
266
|
+
# comparison below. POST is the documented way to send it in a body.
|
|
267
|
+
data = _request(
|
|
268
|
+
"POST",
|
|
269
|
+
f"{base_url}/api/v2/aliases?page_id={page}",
|
|
270
|
+
api_key,
|
|
271
|
+
body={"query": alias_email},
|
|
272
|
+
)
|
|
273
|
+
aliases = data.get("aliases") or []
|
|
274
|
+
if not aliases:
|
|
275
|
+
return None
|
|
276
|
+
if not isinstance(aliases, list):
|
|
277
|
+
raise RuntimeError(f"Unexpected API response (aliases is not a list): {data}")
|
|
278
|
+
for alias in aliases:
|
|
279
|
+
if not isinstance(alias, dict):
|
|
280
|
+
raise RuntimeError(f"Unexpected API response (malformed alias): {alias!r}")
|
|
281
|
+
if str(alias.get("email", "")).lower() == alias_email:
|
|
282
|
+
try:
|
|
283
|
+
return int(alias["id"])
|
|
284
|
+
except (KeyError, TypeError, ValueError):
|
|
285
|
+
raise RuntimeError(
|
|
286
|
+
f"Alias '{alias_email}' returned without a valid id field."
|
|
287
|
+
) from None
|
|
288
|
+
raise RuntimeError(
|
|
289
|
+
f"Gave up after {MAX_ALIAS_PAGES} pages of search results without finding "
|
|
290
|
+
f"'{alias_email}'. Check the alias address for typos."
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def create_contact(base_url: str, api_key: str, alias_id: int, contact_email: str) -> str:
|
|
295
|
+
"""
|
|
296
|
+
Create a contact for alias_id and return the reverse alias address.
|
|
297
|
+
Idempotent: returns the existing reverse alias if the contact already exists.
|
|
298
|
+
"""
|
|
299
|
+
data = _request(
|
|
300
|
+
"POST",
|
|
301
|
+
f"{base_url.rstrip('/')}/api/aliases/{alias_id}/contacts",
|
|
302
|
+
api_key,
|
|
303
|
+
body={"contact": contact_email},
|
|
304
|
+
)
|
|
305
|
+
# Not `reverse_alias`, which is a display string: "Name a@b.c <ra+x@sl.co>".
|
|
306
|
+
address = data.get("reverse_alias_address")
|
|
307
|
+
if not isinstance(address, str) or not address:
|
|
308
|
+
raise RuntimeError(f"Unexpected API response (no reverse_alias_address field): {data}")
|
|
309
|
+
return address
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
# ---------------------------------------------------------------------------
|
|
313
|
+
# Clipboard
|
|
314
|
+
# ---------------------------------------------------------------------------
|
|
315
|
+
|
|
316
|
+
def copy_to_clipboard(text: str) -> bool:
|
|
317
|
+
"""Try to copy text to the system clipboard. Returns True on success."""
|
|
318
|
+
system = platform.system()
|
|
319
|
+
candidates: list[list[str]] = []
|
|
320
|
+
if system == "Darwin":
|
|
321
|
+
candidates = [["pbcopy"]]
|
|
322
|
+
elif system == "Linux":
|
|
323
|
+
candidates = [
|
|
324
|
+
["wl-copy"], # Wayland
|
|
325
|
+
["xclip", "-selection", "clipboard"],
|
|
326
|
+
["xsel", "--clipboard", "--input"],
|
|
327
|
+
]
|
|
328
|
+
elif system == "Windows":
|
|
329
|
+
candidates = [["clip"]]
|
|
330
|
+
|
|
331
|
+
for cmd in candidates:
|
|
332
|
+
try:
|
|
333
|
+
subprocess.run(
|
|
334
|
+
cmd, input=text.encode(), check=True,
|
|
335
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
|
336
|
+
)
|
|
337
|
+
return True
|
|
338
|
+
except (FileNotFoundError, OSError, subprocess.CalledProcessError):
|
|
339
|
+
continue
|
|
340
|
+
return False
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# ---------------------------------------------------------------------------
|
|
344
|
+
# CLI
|
|
345
|
+
# ---------------------------------------------------------------------------
|
|
346
|
+
|
|
347
|
+
def build_parser(default_config_path: Path) -> argparse.ArgumentParser:
|
|
348
|
+
parser = argparse.ArgumentParser(
|
|
349
|
+
prog=APP_NAME,
|
|
350
|
+
description=(
|
|
351
|
+
"Create a SimpleLogin reverse alias so you can send email from an alias "
|
|
352
|
+
"to a new contact without touching the dashboard."
|
|
353
|
+
),
|
|
354
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
355
|
+
epilog=f"""\
|
|
356
|
+
config file (default): {default_config_path}
|
|
357
|
+
Run --init-config to create it. CLI flags always override config values.
|
|
358
|
+
|
|
359
|
+
examples:
|
|
360
|
+
# First-time setup
|
|
361
|
+
proton-alias-send --init-config
|
|
362
|
+
|
|
363
|
+
# Minimal - alias, api_key, and other settings come from config
|
|
364
|
+
proton-alias-send boss@example.com
|
|
365
|
+
|
|
366
|
+
# Override the alias just for this invocation
|
|
367
|
+
proton-alias-send -a work@simplelogin.io boss@example.com
|
|
368
|
+
|
|
369
|
+
# Force clipboard copy regardless of config setting
|
|
370
|
+
proton-alias-send --copy boss@example.com
|
|
371
|
+
|
|
372
|
+
# Suppress config's copy=true for one run
|
|
373
|
+
proton-alias-send --no-copy boss@example.com
|
|
374
|
+
|
|
375
|
+
# Pipe the result directly (quiet suppresses progress noise on stderr)
|
|
376
|
+
open "mailto:$(proton-alias-send -q boss@example.com)"
|
|
377
|
+
|
|
378
|
+
# Use a non-default config file
|
|
379
|
+
proton-alias-send --config ~/work-sl.toml boss@example.com
|
|
380
|
+
""",
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
from proton_alias_send import __version__
|
|
384
|
+
|
|
385
|
+
parser.add_argument(
|
|
386
|
+
"--version",
|
|
387
|
+
action="version",
|
|
388
|
+
version=f"%(prog)s {__version__}",
|
|
389
|
+
)
|
|
390
|
+
parser.add_argument(
|
|
391
|
+
"--init-config",
|
|
392
|
+
action="store_true",
|
|
393
|
+
help="Write a sample config file to the default path (or --config path) and exit.",
|
|
394
|
+
)
|
|
395
|
+
parser.add_argument(
|
|
396
|
+
"--config",
|
|
397
|
+
default=None,
|
|
398
|
+
metavar="PATH",
|
|
399
|
+
help=f"Path to config file. Default: {default_config_path}",
|
|
400
|
+
)
|
|
401
|
+
parser.add_argument(
|
|
402
|
+
"contact",
|
|
403
|
+
metavar="CONTACT_EMAIL",
|
|
404
|
+
nargs="?",
|
|
405
|
+
default=None,
|
|
406
|
+
help="Recipient address to create a contact (reverse alias) for.",
|
|
407
|
+
)
|
|
408
|
+
parser.add_argument(
|
|
409
|
+
"-a", "--alias",
|
|
410
|
+
default=None,
|
|
411
|
+
metavar="EMAIL",
|
|
412
|
+
help="SimpleLogin alias to send from. Overrides config 'alias'.",
|
|
413
|
+
)
|
|
414
|
+
parser.add_argument(
|
|
415
|
+
"-k", "--api-key",
|
|
416
|
+
default=None,
|
|
417
|
+
metavar="KEY",
|
|
418
|
+
help="SimpleLogin API key. Overrides config 'api_key' and $SIMPLELOGIN_API_KEY.",
|
|
419
|
+
)
|
|
420
|
+
parser.add_argument(
|
|
421
|
+
"--base-url",
|
|
422
|
+
default=None,
|
|
423
|
+
metavar="URL",
|
|
424
|
+
help=f"SimpleLogin base URL. Overrides config 'base_url'. Default: {DEFAULT_BASE_URL}",
|
|
425
|
+
)
|
|
426
|
+
# BooleanOptionalAction generates the --no-* form itself; spelling it out
|
|
427
|
+
# here too would register duplicate and --no-no-* options.
|
|
428
|
+
parser.add_argument(
|
|
429
|
+
"--copy",
|
|
430
|
+
dest="copy",
|
|
431
|
+
action=argparse.BooleanOptionalAction,
|
|
432
|
+
default=None,
|
|
433
|
+
help="Copy the reverse alias to clipboard. Overrides config 'copy'.",
|
|
434
|
+
)
|
|
435
|
+
parser.add_argument(
|
|
436
|
+
"-q", "--quiet",
|
|
437
|
+
dest="quiet",
|
|
438
|
+
action=argparse.BooleanOptionalAction,
|
|
439
|
+
default=None,
|
|
440
|
+
help="Suppress progress messages. Overrides config 'quiet'.",
|
|
441
|
+
)
|
|
442
|
+
return parser
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def log(msg: str, quiet: bool) -> None:
|
|
446
|
+
if not quiet:
|
|
447
|
+
print(msg, file=sys.stderr)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def _config_type_errors(strings: dict[str, Any], booleans: dict[str, Any]) -> list[str]:
|
|
451
|
+
"""Report wrongly typed settings by name. Values stay out of it: one may be the API key."""
|
|
452
|
+
errors = [
|
|
453
|
+
f"Setting '{name}' must be a string."
|
|
454
|
+
for name, value in strings.items()
|
|
455
|
+
if value is not None and not isinstance(value, str)
|
|
456
|
+
]
|
|
457
|
+
errors += [
|
|
458
|
+
f"Setting '{name}' must be true or false."
|
|
459
|
+
for name, value in booleans.items()
|
|
460
|
+
if not isinstance(value, bool)
|
|
461
|
+
]
|
|
462
|
+
return errors
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def _is_plaintext_remote(base_url: str) -> bool:
|
|
466
|
+
"""True for an http:// URL off this machine, where the API key travels unencrypted."""
|
|
467
|
+
try:
|
|
468
|
+
parts = urllib.parse.urlsplit(base_url)
|
|
469
|
+
host = parts.hostname or ""
|
|
470
|
+
except ValueError:
|
|
471
|
+
return False
|
|
472
|
+
if parts.scheme.lower() != "http" or host.lower() == "localhost":
|
|
473
|
+
return False
|
|
474
|
+
try:
|
|
475
|
+
return not ipaddress.ip_address(host).is_loopback
|
|
476
|
+
except ValueError:
|
|
477
|
+
return True
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def run(argv: list[str] | None = None) -> int:
|
|
481
|
+
default_config_path = get_config_path()
|
|
482
|
+
parser = build_parser(default_config_path)
|
|
483
|
+
args = parser.parse_args(argv)
|
|
484
|
+
|
|
485
|
+
config_path = Path(args.config).expanduser() if args.config else default_config_path
|
|
486
|
+
|
|
487
|
+
if args.init_config:
|
|
488
|
+
return cmd_init_config(config_path)
|
|
489
|
+
|
|
490
|
+
config = load_config(config_path)
|
|
491
|
+
|
|
492
|
+
# Resolve each setting: CLI > config file > env var / hardcoded default
|
|
493
|
+
api_key = merge(args.api_key, config.get("api_key"), os.environ.get("SIMPLELOGIN_API_KEY"))
|
|
494
|
+
alias = merge(args.alias, config.get("alias"), None)
|
|
495
|
+
base_url = merge(args.base_url, config.get("base_url"), DEFAULT_BASE_URL)
|
|
496
|
+
do_copy = merge(args.copy, config.get("copy"), False)
|
|
497
|
+
quiet = merge(args.quiet, config.get("quiet"), False)
|
|
498
|
+
|
|
499
|
+
# Validate - collect all errors before printing so the user can fix them in one go
|
|
500
|
+
errors = _config_type_errors(
|
|
501
|
+
strings={"api_key": api_key, "alias": alias, "base_url": base_url},
|
|
502
|
+
booleans={"copy": do_copy, "quiet": quiet},
|
|
503
|
+
)
|
|
504
|
+
if isinstance(api_key, str):
|
|
505
|
+
api_key = api_key.strip()
|
|
506
|
+
if not args.contact:
|
|
507
|
+
errors.append("CONTACT_EMAIL is required.")
|
|
508
|
+
if not api_key:
|
|
509
|
+
errors.append(
|
|
510
|
+
"No API key found. Set 'api_key' in the config file, use -k / --api-key, "
|
|
511
|
+
"or set $SIMPLELOGIN_API_KEY."
|
|
512
|
+
)
|
|
513
|
+
if not alias:
|
|
514
|
+
errors.append(
|
|
515
|
+
"No alias specified. Set 'alias' in the config file or use -a / --alias."
|
|
516
|
+
)
|
|
517
|
+
if errors:
|
|
518
|
+
for msg in errors:
|
|
519
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
520
|
+
return 1
|
|
521
|
+
|
|
522
|
+
if _is_plaintext_remote(base_url):
|
|
523
|
+
print(
|
|
524
|
+
f"Warning: {base_url} is not HTTPS, so your API key is sent unencrypted.",
|
|
525
|
+
file=sys.stderr,
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
try:
|
|
529
|
+
log(f"Looking up alias ID for {alias} ...", quiet)
|
|
530
|
+
alias_id = find_alias_id(base_url, api_key, alias)
|
|
531
|
+
if alias_id is None:
|
|
532
|
+
print(
|
|
533
|
+
f"Error: alias '{alias}' not found in your SimpleLogin account.",
|
|
534
|
+
file=sys.stderr,
|
|
535
|
+
)
|
|
536
|
+
return 1
|
|
537
|
+
log(f" Found alias ID: {alias_id}", quiet)
|
|
538
|
+
|
|
539
|
+
log(f"Creating contact for {args.contact} ...", quiet)
|
|
540
|
+
reverse_alias = create_contact(base_url, api_key, alias_id, args.contact)
|
|
541
|
+
log(" Done.", quiet)
|
|
542
|
+
except RuntimeError as exc:
|
|
543
|
+
print(f"Error: {exc}", file=sys.stderr)
|
|
544
|
+
return 1
|
|
545
|
+
|
|
546
|
+
# Flush here so a closed pipe surfaces inside main(), not at interpreter exit.
|
|
547
|
+
print(reverse_alias, flush=True)
|
|
548
|
+
|
|
549
|
+
if do_copy:
|
|
550
|
+
if copy_to_clipboard(reverse_alias):
|
|
551
|
+
log("Copied to clipboard.", quiet)
|
|
552
|
+
else:
|
|
553
|
+
print(
|
|
554
|
+
"Warning: clipboard copy failed. No supported tool found "
|
|
555
|
+
"(pbcopy / xclip / xsel / wl-copy / clip).",
|
|
556
|
+
file=sys.stderr,
|
|
557
|
+
)
|
|
558
|
+
return 0
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def main(argv: list[str] | None = None) -> int:
|
|
562
|
+
"""Console-script entry point."""
|
|
563
|
+
try:
|
|
564
|
+
return run(argv)
|
|
565
|
+
except KeyboardInterrupt:
|
|
566
|
+
print("Interrupted.", file=sys.stderr)
|
|
567
|
+
return 130
|
|
568
|
+
except BrokenPipeError:
|
|
569
|
+
# e.g. `proton-alias-send ... | head` - exit quietly like other CLI tools.
|
|
570
|
+
# Point stdout at devnull so the flush at interpreter exit can't fail too.
|
|
571
|
+
devnull = os.open(os.devnull, os.O_WRONLY)
|
|
572
|
+
os.dup2(devnull, sys.stdout.fileno())
|
|
573
|
+
os.close(devnull)
|
|
574
|
+
return 0
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
if __name__ == "__main__":
|
|
578
|
+
sys.exit(main())
|
|
File without changes
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: proton-alias-send
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Create Proton Pass / SimpleLogin reverse aliases from the command line
|
|
5
|
+
Project-URL: Homepage, https://github.com/fictiontoreality/proton-alias-send
|
|
6
|
+
Project-URL: Repository, https://github.com/fictiontoreality/proton-alias-send
|
|
7
|
+
Project-URL: Issues, https://github.com/fictiontoreality/proton-alias-send/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/fictiontoreality/proton-alias-send/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Jesse Johnson <gpg@fictiontoreality.dev>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: alias,cli,email,privacy,proton,proton-pass,simplelogin
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Communications :: Email
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# proton-alias-send
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/proton-alias-send/)
|
|
32
|
+
[](https://pypi.org/project/proton-alias-send/)
|
|
33
|
+
[](https://github.com/fictiontoreality/proton-alias-send/blob/main/LICENSE)
|
|
34
|
+
|
|
35
|
+
Create a Proton Pass / SimpleLogin **reverse alias** from the command line or Python, so you can
|
|
36
|
+
send mail *from* one of your aliases without opening the web dashboard.
|
|
37
|
+
|
|
38
|
+
SimpleLogin aliases forward mail to you out of the box, but replying from an alias to a
|
|
39
|
+
brand-new recipient requires creating a "contact" first. The dashboard makes you click
|
|
40
|
+
through several screens for this. This tool does it in one command and prints the reverse
|
|
41
|
+
alias address you actually put in your mail client's To: field.
|
|
42
|
+
|
|
43
|
+
```console
|
|
44
|
+
$ proton-alias-send boss@example.com
|
|
45
|
+
Looking up alias ID for work@simplelogin.io ...
|
|
46
|
+
Found alias ID: 1234567
|
|
47
|
+
Creating contact for boss@example.com ...
|
|
48
|
+
Done.
|
|
49
|
+
ra+abc123xyz@simplelogin.co
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Mail sent to `ra+abc123xyz@simplelogin.co` arrives at `boss@example.com`
|
|
53
|
+
appearing to come from `work@simplelogin.io`. Send it from a mailbox linked to that alias;
|
|
54
|
+
SimpleLogin only accepts mail to a reverse alias from those mailboxes.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```console
|
|
59
|
+
pipx install proton-alias-send
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
or
|
|
63
|
+
|
|
64
|
+
```console
|
|
65
|
+
uv tool install proton-alias-send
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It has **no dependencies** outside the standard library and needs Python 3.11+.
|
|
69
|
+
|
|
70
|
+
## Setup
|
|
71
|
+
|
|
72
|
+
```console
|
|
73
|
+
$ proton-alias-send --init-config
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
That writes a commented config file (mode `600` on Unix) to:
|
|
77
|
+
|
|
78
|
+
| Platform | Path |
|
|
79
|
+
| ------------ | ----------------------------------------------------------------- |
|
|
80
|
+
| Linux / BSD | `$XDG_CONFIG_HOME/proton-alias-send/config.toml`, else `~/.config/...` |
|
|
81
|
+
| macOS | `~/.config/proton-alias-send/config.toml` |
|
|
82
|
+
| Windows | `%APPDATA%\proton-alias-send\config.toml` |
|
|
83
|
+
|
|
84
|
+
Fill in your API key from <https://app.simplelogin.io/dashboard/api_key> and the alias you
|
|
85
|
+
usually send from. The key must belong to the SimpleLogin account that holds the alias.
|
|
86
|
+
|
|
87
|
+
```toml
|
|
88
|
+
api_key = "your-api-key-here"
|
|
89
|
+
alias = "work@simplelogin.io"
|
|
90
|
+
copy = true
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
If you'd rather not keep the key on disk, leave `api_key = ""` and export
|
|
94
|
+
the environment variable `SIMPLELOGIN_API_KEY` instead. Avoid `-k` on shared machines: a
|
|
95
|
+
key on the command line is visible in `ps` and saved in your shell history.
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
```console
|
|
100
|
+
$ proton-alias-send --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Flag | Purpose |
|
|
104
|
+
| ------------------- | -------------------------------------------------------------- |
|
|
105
|
+
| `-a`, `--alias` | Alias to send from, overriding the config default |
|
|
106
|
+
| `-k`, `--api-key` | API key, overriding config and `$SIMPLELOGIN_API_KEY` |
|
|
107
|
+
| `--base-url` | Point at a self-hosted SimpleLogin instance (warns on plain `http://`) |
|
|
108
|
+
| `--copy/--no-copy` | Copy the result to the clipboard (`pbcopy`/`wl-copy`/`xclip`/`xsel`/`clip`) |
|
|
109
|
+
| `-q`, `--quiet` | Silence progress output on stderr |
|
|
110
|
+
| `--config PATH` | Use an alternate config file |
|
|
111
|
+
| `--init-config` | Write the sample config and exit |
|
|
112
|
+
|
|
113
|
+
Settings resolve as **command line > config file > environment / built-in default**, so any
|
|
114
|
+
config value can be overridden for a single run — including booleans, via `--no-copy` and
|
|
115
|
+
`--no-quiet`.
|
|
116
|
+
|
|
117
|
+
### Scripting
|
|
118
|
+
|
|
119
|
+
The reverse alias is the only thing written to stdout; all progress and errors go to
|
|
120
|
+
stderr. That makes it safe to capture:
|
|
121
|
+
|
|
122
|
+
```console
|
|
123
|
+
$ open "mailto:$(proton-alias-send -q boss@example.com)"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Exit status is `0` on success, `1` on any error, `130` if interrupted.
|
|
127
|
+
|
|
128
|
+
Creating a contact is idempotent — running it twice for the same recipient returns the
|
|
129
|
+
same reverse alias rather than failing.
|
|
130
|
+
|
|
131
|
+
### As a library
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from proton_alias_send import create_contact, find_alias_id
|
|
135
|
+
|
|
136
|
+
alias_id = find_alias_id("https://app.simplelogin.io", api_key, "work@simplelogin.io")
|
|
137
|
+
reverse = create_contact("https://app.simplelogin.io", api_key, alias_id, "boss@example.com")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Both raise `RuntimeError` with a readable message on any API, network, or protocol failure.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```console
|
|
145
|
+
$ uv sync # create the venv, including dev tools
|
|
146
|
+
$ uv run pytest # tests
|
|
147
|
+
$ uv run pytest tests/test_config.py::test_merge_prefers_cli # a single test
|
|
148
|
+
$ uv run ruff check . # lint (formatting is deliberately not enforced)
|
|
149
|
+
$ uv run mypy # type check (strict)
|
|
150
|
+
$ uv build # build sdist + wheel into dist/
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
Apache-2.0. See [LICENSE](https://github.com/fictiontoreality/proton-alias-send/blob/main/LICENSE).
|
|
156
|
+
|
|
157
|
+
Not affiliated with Proton AG or SimpleLogin.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
proton_alias_send/__init__.py,sha256=9NFFUIWNbI-nRyif0iVngYw-zcmqvhpM41XebF-ZsGY,242
|
|
2
|
+
proton_alias_send/__main__.py,sha256=OXGLAvzDMRGOcx9yrkYLeTku3cFvEQxyQYRqVZ2Xr3s,154
|
|
3
|
+
proton_alias_send/cli.py,sha256=tn7nxb9_YdEqEXZ16iEp4ke-xXMKSjy4IjGNX58mJnw,20686
|
|
4
|
+
proton_alias_send/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
proton_alias_send-0.1.0.dist-info/METADATA,sha256=NSt1FMgeZzu8m24U0Ee1otiJtO7gIYNiuByOPYs84ew,6308
|
|
6
|
+
proton_alias_send-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
7
|
+
proton_alias_send-0.1.0.dist-info/entry_points.txt,sha256=dHaQ4ziTamj-34pQNPY3xSMDolFAUvvaHZ7WtR9LT7w,65
|
|
8
|
+
proton_alias_send-0.1.0.dist-info/licenses/LICENSE,sha256=qJcNSp67HYSDsPGjsxBQ215BxQ1zEZUgJZF7jhJ2cjk,11345
|
|
9
|
+
proton_alias_send-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jesse Johnson
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|