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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! `cratefield-push-auth`: the provider tokens the push adapters present
//! (issue #178).
//!
//! APNs signs an ES256 JWT with the `.p8` key from the Apple developer
//! portal. VAPID (RFC 8292) is the *same* construction with different claims
//! — `aud` is the push-service origin, `sub` a `mailto:`, `exp` at most 24
//! hours out — and the public key travels alongside it as `k=`. Google's
//! service-account flow signs an **RS256** JWT and trades it for a bearer
//! token. Three adapters, one signer, one cache; extracted here so the next
//! two adapters do not each grow their own copy of
//! `base64url(header).base64url(claims).base64url(sig)`.
//!
//! Everything is pure Rust and builds for `wasm32-unknown-unknown`: no
//! `jsonwebtoken`, no `ring`, no OpenSSL. Both signatures are deterministic
//! (RFC 6979 for ES256, PKCS#1 v1.5 for RS256), so no RNG is needed on a
//! Workers isolate.
//!
//! Verifying tokens is deliberately absent — that is the auth service's job.
pub use CachedToken;
pub use Es256Signer;
pub use Rs256Signer;
use Engine;
use URL_SAFE_NO_PAD;
use Value;
/// A private key did not parse.
/// The JWS signing input: `base64url(header) "." base64url(claims)`
/// (RFC 7515 §5.1). Compact serialisation, so the exact bytes signed are the
/// exact bytes sent.