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
//! Signs the `X-MountOS-Dashboard-User` header for dashboard operator context.
//!
//! Mirrors the Go and TypeScript SDKs. The HMAC key is derived from a dedicated
//! secret (appserv `DASHBOARD_USER_HMAC_KEY`, distinct from the public
//! verification key) with domain separation, and the value is
//! `base64url(json).base64url(hmac-sha256(base64url(json), derived_key))`.
use ;
use Engine;
use URL_SAFE_NO_PAD;
use ;
use Sha256;
use crateError;
use crateDashboardUser;
type HmacSha256 = ;
const DEFAULT_TTL_SECS: i64 = 10 * 60;
/// Produces the signed `X-MountOS-Dashboard-User` header value, stamping `exp`
/// at now + 10 minutes. `hmac_secret` is the dedicated dashboard-user HMAC
/// secret shared with appserv (`DASHBOARD_USER_HMAC_KEY`), never the public
/// verification key.
/// Derives a dedicated HMAC key from the shared secret with domain separation.