delete the key predicates nothing asks

IsWidgetKey and IsAnalyticsKey, and the iam.IsWidget / iam.IsAnalytics
re-exports over them, had no caller. No door resolves hz-, hi- or ha-, so
a key with one of those prefixes reaches exactly what an anonymous caller
reaches — the classification answers a question nothing asks.

The prefix table above them documented six prefixes where three are
resolved; it now names the three.

apis: say what the file read does. viewRule is re-read for a field marked
Protected, against a file token; a field not so marked is reached by
knowing the address.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-08-24 06:56:48 -07:00
co-authored by Hanzo Dev
parent f909a97aa4
commit 415ad8efc8
3 changed files with 10 additions and 26 deletions
+3 -1
View File
@@ -105,7 +105,9 @@ func (api *fileApi) download(e *core.RequestEvent) error {
return e.NotFoundError("", nil)
}
// check whether the request is authorized to view the protected file
// A field marked Protected re-reads viewRule here, against a file token
// rather than the caller's own credential. A field not so marked is reached
// by knowing the address, which is what a file URL in a page is.
if fileField.Protected {
originalRequestInfo, err := e.RequestInfo()
if err != nil {
-6
View File
@@ -57,9 +57,3 @@ func IsSecret(token string) bool { return org.IsSecretKey(token) }
// IsAPIKey reports whether token is any IAM API key (pk-/sk-/hk-).
func IsAPIKey(token string) bool { return org.IsAPIKey(token) }
// IsAnalytics reports whether token is an insights (hi-) or analytics (ha-) key.
func IsAnalytics(token string) bool { return org.IsAnalyticsKey(token) }
// IsWidget reports whether token is a widget embed key (hz-).
func IsWidget(token string) bool { return org.IsWidgetKey(token) }
+7 -19
View File
@@ -270,16 +270,15 @@ type IAMKey struct {
State string `json:"state"`
}
// Hanzo key prefix standard (always hyphen, never underscore):
// The key prefixes this process resolves (always hyphen, never underscore):
//
// pk- publishable key (frontend-safe, read-only API access)
// sk- secret key (backend-only, full API access)
// hk- hanzo key (IAM user API key, legacy)
// hi- hanzo insights (analytics event ingestion)
// ha- hanzo analytics (lightweight web analytics)
// hz- hanzo widget (restricted chat/embed key)
// pk- publishable key (printed in a web page)
// sk- secret key (the org's own server)
// hk- hanzo key (a person's IAM key)
//
// All managed by IAM. One key store. One prefix convention.
// IAM mints them all and holds them in one store. A prefix a door here does not
// resolve reaches exactly what an anonymous caller reaches, so classifying one
// is a question with no consumer and no answer.
// IsPublishableKey returns true if the token has a publishable key prefix.
func IsPublishableKey(token string) bool {
@@ -298,17 +297,6 @@ func IsAPIKey(token string) bool {
strings.HasPrefix(token, "sk-")
}
// IsAnalyticsKey returns true if the token is an insights or analytics key.
func IsAnalyticsKey(token string) bool {
return strings.HasPrefix(token, "hi-") ||
strings.HasPrefix(token, "ha-")
}
// IsWidgetKey returns true if the token is a widget embed key.
func IsWidgetKey(token string) bool {
return strings.HasPrefix(token, "hz-")
}
// ResolveAPIKey resolves an IAM API key (hk-/pk-/sk-) to user + org context.
// Uses IAM's GET /v1/iam/keys/principal?accessKey= endpoint. Results are cached
// for tokenCacheTTL; concurrent resolves of the same key are coalesced via