C4: the vault keeps the forge token with the scopes it was minted with

The file beside the token that kept its scopes went with C4, and with it
the re-mint of a token carrying a scope beyond the tools' (write:admin).
The value written through own-put now holds the token and its scopes; a
token minted with other scopes, or a value naming none, is minted again
unasked and the one it replaces deleted at the forge. The Go bundles read
the token out of that value. The lost test is back as a row of the scope
test in test/token.test.ts.

Builds: design 47 H2 §808; H-A-439
This commit is contained in:
2026-11-22 01:52:24 +01:00
parent ed14a10006
commit 280adcce68
7 changed files with 97 additions and 26 deletions
+9 -2
View File
@@ -61,11 +61,18 @@ func (t *VaultToken) Load() error {
if err := json.Unmarshal(raw, &got); err != nil || got.Sealed == nil {
return fmt.Errorf("the vault answered no sealed %s", VaultName(t.Account))
}
token, err := seal.Open(*got.Sealed, t.keys.PrivateKey)
opened, err := seal.Open(*got.Sealed, t.keys.PrivateKey)
if err != nil {
return fmt.Errorf("%s does not open with this process's key: %w", VaultName(t.Account), err)
}
token = strings.TrimSpace(token)
// The value holds the token and the scopes it was minted with (H-A-439); the minter judges the scopes, this reads the token.
var value struct {
Token string `json:"token"`
}
if err := json.Unmarshal([]byte(opened), &value); err != nil {
return fmt.Errorf("the vault's %s is not a token with its scopes: %w", VaultName(t.Account), err)
}
token := strings.TrimSpace(value.Token)
if token == "" {
return fmt.Errorf("the vault's %s is empty", VaultName(t.Account))
}