Skip to content

Commit c16ea7b

Browse files
committed
refactor(golang)!: rename stackencrypt to encrypt and stackauth to auth
The two packages are `encrypt` and `auth`, at languages/golang/encrypt and languages/golang/auth, as the plan builder design names them: a package name does not repeat the product, and `encrypt.Cipher` reads as what it is where `stackencrypt.Cipher` repeated itself (SDK principle 13). A move with nothing else in it, so a review can read it as one: `git mv` of both directories, the guest crates with them, the package clauses, the import paths, the selectors, the error prefixes and the prose; every path in mise.toml, the root Cargo.toml exclude list, .gitignore, dependabot, tests-golang.yml, go-binding-test.sh, the scripts/__tests__ guards, AGENTS.md, SECURITY.md, stack-guest-abi's module doc, stack-encrypt's CONTEXT.md and the label-segments fixture comment. The task alias `go:stackencrypt:test` goes with the name it kept. The CI variable STACKENCRYPT_TESTS_REQUIRE_LOCK becomes STACK_ENCRYPT_TESTS_REQUIRE_LOCK. Two renames the compiler forced: the plan package's `encrypt` verdict constant collided with the package it now imports, so it is `sealed`; two test locals named `auth` shadowed the auth package and are `cts`. docs/plans and the ADRs keep the old names as history. Claude-Session: https://claude.ai/code/session_01V3WFXwax4J3uecpFEJ6yHc
1 parent 56260ac commit c16ea7b

106 files changed

Lines changed: 500 additions & 502 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/dependabot.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ updates:
211211
- /packages/stack-auth/fuzz
212212
- /packages/stack-kms/fuzz
213213
- /packages/stack-encrypt/fuzz
214-
- /languages/golang/stackencrypt/guest
215-
- /languages/golang/stackauth/guest
214+
- /languages/golang/encrypt/guest
215+
- /languages/golang/auth/guest
216216
# Monthly, matching the other two cargo entries.
217217
schedule:
218218
interval: monthly

‎.github/workflows/tests-golang.yml‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ jobs:
120120
with:
121121
workspaces: |
122122
.
123-
languages/golang/stackencrypt/guest
124-
languages/golang/stackauth/guest
123+
languages/golang/encrypt/guest
124+
languages/golang/auth/guest
125125
126126
# The HTTP-free core compiles for wasm32-wasip1 with no JS-host backend
127127
# and no native HTTP/TLS stack in its graph: the invariant the wazero
@@ -155,7 +155,7 @@ jobs:
155155
# same bytes rather than a stale or rebuilt guest.
156156
- name: Record the guests' checksums
157157
run: |
158-
for guest in stackencrypt/wasm/stack_encrypt_guest.wasm stackauth/wasm/stack_auth_guest.wasm; do
158+
for guest in encrypt/wasm/stack_encrypt_guest.wasm auth/wasm/stack_auth_guest.wasm; do
159159
(cd languages/golang && openssl dgst -sha256 "$guest" | awk '{print $NF}' > "$guest.sha256" && echo "$guest sha256 $(cat "$guest.sha256")")
160160
done
161161
@@ -164,20 +164,20 @@ jobs:
164164
with:
165165
name: wasm-guests
166166
path: |
167-
languages/golang/stackencrypt/wasm/stack_encrypt_guest.wasm
168-
languages/golang/stackencrypt/wasm/stack_encrypt_guest.wasm.sha256
169-
languages/golang/stackauth/wasm/stack_auth_guest.wasm
170-
languages/golang/stackauth/wasm/stack_auth_guest.wasm.sha256
167+
languages/golang/encrypt/wasm/stack_encrypt_guest.wasm
168+
languages/golang/encrypt/wasm/stack_encrypt_guest.wasm.sha256
169+
languages/golang/auth/wasm/stack_auth_guest.wasm
170+
languages/golang/auth/wasm/stack_auth_guest.wasm.sha256
171171
if-no-files-found: error
172172
retention-days: 1
173173

174174
# Format, vet and hermetic tests on amd64 and 386. The guest's memory
175175
# lock is best effort, so its test skips where RLIMIT_MEMLOCK refuses
176-
# it; CI raises the limit and sets STACKENCRYPT_TESTS_REQUIRE_LOCK so
176+
# it; CI raises the limit and sets STACK_ENCRYPT_TESTS_REQUIRE_LOCK so
177177
# the skip is an error here.
178178
- name: Go binding
179179
env:
180-
STACKENCRYPT_TESTS_REQUIRE_LOCK: "1"
180+
STACK_ENCRYPT_TESTS_REQUIRE_LOCK: "1"
181181
run: |
182182
ulimit -l "$(ulimit -H -l)"
183183
echo "RLIMIT_MEMLOCK: $(ulimit -l) KiB"
@@ -256,7 +256,7 @@ jobs:
256256
- name: The guests are the ones Linux built and checked
257257
run: |
258258
cd languages/golang
259-
for guest in stackencrypt/wasm/stack_encrypt_guest.wasm stackauth/wasm/stack_auth_guest.wasm; do
259+
for guest in encrypt/wasm/stack_encrypt_guest.wasm auth/wasm/stack_auth_guest.wasm; do
260260
want=$(cat "$guest.sha256")
261261
got=$(openssl dgst -sha256 "$guest" | awk '{print $NF}')
262262
if [ "$want" != "$got" ]; then
@@ -320,7 +320,7 @@ jobs:
320320
- name: The guests are the ones the wasi-check job built and checked
321321
run: |
322322
cd languages/golang
323-
for guest in stackencrypt/wasm/stack_encrypt_guest.wasm stackauth/wasm/stack_auth_guest.wasm; do
323+
for guest in encrypt/wasm/stack_encrypt_guest.wasm auth/wasm/stack_auth_guest.wasm; do
324324
want=$(cat "$guest.sha256")
325325
got=$(openssl dgst -sha256 "$guest" | awk '{print $NF}')
326326
if [ "$want" != "$got" ]; then
@@ -334,7 +334,7 @@ jobs:
334334
# call `liveClient`, and not all of them are named `TestLive*`.
335335
- name: Go live tests
336336
working-directory: languages/golang
337-
run: CGO_ENABLED=0 go test -v ./stackencrypt/...
337+
run: CGO_ENABLED=0 go test -v ./encrypt/...
338338

339339
- name: stack-encrypt examples
340340
run: |

‎.gitignore‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mutants.out/
108108

109109
# The Go module's embedded WASI guests: build outputs of `mise run
110110
# wasm:guest:build` and `mise run wasm:auth-guest:build`.
111-
languages/golang/stackencrypt/wasm/*.wasm
112-
languages/golang/stackauth/wasm/*.wasm
113-
languages/golang/stackencrypt/wasm/*.sha256
114-
languages/golang/stackauth/wasm/*.sha256
111+
languages/golang/encrypt/wasm/*.wasm
112+
languages/golang/auth/wasm/*.wasm
113+
languages/golang/encrypt/wasm/*.sha256
114+
languages/golang/auth/wasm/*.sha256

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Every npm package except EQL lives under `languages/typescript/`: packages in `l
9292
links are provenance only.
9393
- `packages/stack-auth`, `packages/stack-profile`, `packages/stack-kms`, `packages/stack-encrypt`, `packages/stack-encrypt-derive`, `packages/stack-guest-abi`: The Rust crates imported from `cipherstash/cipherstash-suite` with their history — `stack-auth` and `stack-profile` (published to crates.io, one version group), `stack-kms` (published to crates.io from 0.1.0, its own version group, re-exported by `stack-encrypt` as `stack_encrypt::kms`), `stack-encrypt` and `stack-encrypt-derive` (published to crates.io from 0.1.0, one version group; `eql-bindings`' `stack-encrypt` feature depends on them from the registry), and `stack-guest-abi` (`publish = false`). They are the members of the **root Cargo workspace**, with the three node binding crates below. See "Working on the Rust crates".
9494
- `languages/typescript/packages/auth`, `languages/typescript/packages/profile`, `languages/typescript/packages/stack-auth-wasm`: The node bindings of those crates. `@cipherstash/auth` (napi-rs v2) and its six `platforms/*` packages are published to npm from this repository by `release.yml` (`auth-artifacts`, `publish-auth`); a change to what it ships, the `stack-auth` crate included, needs an `@cipherstash/auth` changeset (`require-auth-npm-changeset.yml`). `@cipherstash/profile` and its platforms are private and never published; `@cipherstash/stack-auth-wasm` is private and builds the wasm that `@cipherstash/auth` ships. Their `build` and `test` scripts never invoke cargo; `build:native`, `build:debug` and `test:cargo` do.
95-
- `languages/golang`: The Go module (`stackencrypt`, `stackauth`, `internal`), a wazero host with no cgo. Its two WASI guests (`*/guest`) are detached Cargo workspaces built by `mise run wasm:guest:build` and `mise run wasm:auth-guest:build`; the `.wasm` files they embed are gitignored. There is no Go release process yet.
95+
- `languages/golang`: The Go module (`encrypt`, `auth`, `internal`), a wazero host with no cgo. Its two WASI guests (`*/guest`) are detached Cargo workspaces built by `mise run wasm:guest:build` and `mise run wasm:auth-guest:build`; the `.wasm` files they embed are gitignored. There is no Go release process yet.
9696
- `e2e/*`: Cross-package end-to-end tests (package managers, supply chain, Prisma example README)
9797
- `languages/typescript/examples/*`: Working apps (basic, prisma, supabase-worker)
9898
- `docs/plans/*`: Internal design plans. User-facing documentation lives at https://cipherstash.com/docs (not in this repo).

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ exclude = [
2727
"packages/stack-encrypt/fuzz",
2828
# WASI guests for the Go module, built through `wasm:guest:build` and
2929
# `wasm:auth-guest:build`.
30-
"languages/golang/stackencrypt/guest",
31-
"languages/golang/stackauth/guest",
30+
"languages/golang/encrypt/guest",
31+
"languages/golang/auth/guest",
3232
]
3333

3434
[workspace.package]

‎SECURITY.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ It also carries the source of five Rust crates published to crates.io,
3333
`packages/stack-profile`) and **`stack-kms`**, **`stack-encrypt`** and
3434
**`stack-encrypt-derive`** (`packages/stack-kms`, `packages/stack-encrypt`,
3535
`packages/stack-encrypt-derive`), and of the **Go module** at
36-
`languages/golang` (`stackencrypt` and `stackauth`, over WASI guests built
36+
`languages/golang` (`encrypt` and `auth`, over WASI guests built
3737
from the stack-* crates), which has no release yet. All of these are in scope
3838
for security reports on the same terms as the npm packages above.
3939

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# stackauth
1+
# auth
22

33
The Go binding of the developer profile — the directory `stash auth login`
44
writes — read through the `stack-profile` Rust crate running inside a WASI
55
guest under [wazero], with `CGO_ENABLED=0`. It is the credential half of
6-
the Go SDK: it hands a [`stackencrypt`](../stackencrypt) client its client
6+
the Go SDK: it hands a [`encrypt`](../encrypt) client its client
77
key and its bearer token without either package re-deriving the profile's
88
layout, and without either importing the other.
99

@@ -16,30 +16,30 @@ cross-process refresh lock for device sessions.
1616

1717
## Use
1818

19-
Most applications never call this package directly: a `stackencrypt`
19+
Most applications never call this package directly: a `encrypt`
2020
client built with `NewClient(ctx)` and no options resolves its credentials with
21-
`stackencrypt.AutoCredentials`, which reads the environment first and then
21+
`encrypt.AutoCredentials`, which reads the environment first and then
2222
the profile, through this package. Use it directly to take the profile
2323
apart yourself:
2424

2525
```go
2626
import (
2727
"context"
2828

29-
"github.com/cipherstash/stack/languages/golang/stackauth"
30-
"github.com/cipherstash/stack/languages/golang/stackencrypt"
29+
"github.com/cipherstash/stack/languages/golang/auth"
30+
"github.com/cipherstash/stack/languages/golang/encrypt"
3131
)
3232

3333
func run(ctx context.Context) error {
34-
profile, err := stackauth.Resolve(ctx) // CS_CONFIG_PATH, else ~/.cipherstash
34+
profile, err := auth.Resolve(ctx) // CS_CONFIG_PATH, else ~/.cipherstash
3535
if err != nil {
3636
return err
3737
}
3838
defer profile.Close()
3939

4040
workspace, err := profile.CurrentWorkspaceStore(ctx)
4141
if err != nil {
42-
return err // stackauth.ErrNoCurrentWorkspace: run `stash auth login`
42+
return err // auth.ErrNoCurrentWorkspace: run `stash auth login`
4343
}
4444
clientID, clientKey, err := workspace.SecretKey(ctx)
4545
if err != nil {
@@ -50,9 +50,9 @@ func run(ctx context.Context) error {
5050
return err
5151
}
5252
defer source.Close()
53-
client, err := stackencrypt.NewClient(ctx,
53+
client, err := encrypt.NewClient(ctx,
5454
// The key is consumed and wiped by NewClient.
55-
stackencrypt.WithCredentials(stackencrypt.NewCredentials(clientID, clientKey, source)),
55+
encrypt.WithCredentials(encrypt.NewCredentials(clientID, clientKey, source)),
5656
)
5757
if err != nil {
5858
return err
@@ -63,31 +63,31 @@ func run(ctx context.Context) error {
6363
}
6464
```
6565

66-
`stackauth.ClientKey` and `stackencrypt.ClientKey` are one type, so the
66+
`auth.ClientKey` and `encrypt.ClientKey` are one type, so the
6767
key goes straight from the profile into the credentials. The profile and
6868
the strategy are the caller's: the client asks the strategy for a token on
6969
every request but never closes it, so both stay open until the client is
7070
closed (the deferred calls above run in that order).
7171

72-
A stackencrypt client takes its token only from a strategy, never a raw
72+
A encrypt client takes its token only from a strategy, never a raw
7373
string: a raw token cannot be refreshed when it expires, and would bypass
7474
the cross-process lock a device-session refresh holds with the `stash` CLI
7575
(the IdP revokes a whole refresh-token chain when one is used twice).
7676
`workspace.Token(ctx)` still reads the stored token, for inspection.
7777

7878
With no profile directory at all (CI, a container, a server authenticating
79-
by federation), `stackauth.OpenWithoutProfile(ctx)` runs the guest with
79+
by federation), `auth.OpenWithoutProfile(ctx)` runs the guest with
8080
nothing mounted: the access-key and OIDC strategies work, and every profile
8181
read is `ErrNoProfile`.
8282

8383
`profile.AccessKey(ctx, crn, key)`, `profile.OIDC(ctx, crn, provider)`, and
84-
`profile.Auto(ctx)` also return strategies that `stackencrypt.NewCredentials`
84+
`profile.Auto(ctx)` also return strategies that `encrypt.NewCredentials`
8585
takes. `Auto` checks `CS_CLIENT_ACCESS_KEY` and
8686
`CS_WORKSPACE_CRN` first, then the current workspace's stored device session.
8787
The OIDC provider is a one-method `Token(context.Context) (string, error)`
8888
interface, called on every token fetch for the JWT of the user the call is
8989
for; each distinct JWT is exchanged once while its CTS token lasts. Use
90-
`stackauth.OAuth2TokenSource(source)` to adapt a
90+
`auth.OAuth2TokenSource(source)` to adapt a
9191
`golang.org/x/oauth2.TokenSource`. `WithAuthBaseURL(url)` overrides service
9292
discovery for local tests or a custom CTS host; `WithCacheCapacity(n)` sets
9393
how many users' CTS tokens an OIDC strategy keeps (1024 unless set), sized to
@@ -107,7 +107,7 @@ session refresh call, on the path `ProfileStore.LockPath` names. A fresh
107107
token is read without the lock; on refresh the guest re-reads
108108
auth.json after acquisition and saves refreshed tokens before release.
109109

110-
The crypto guest behind `stackencrypt` is not widened by this package
110+
The crypto guest behind `encrypt` is not widened by this package
111111
existing: it still has no filesystem and no environment.
112112

113113
## Build
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package stackauth
1+
package auth
22

33
import "github.com/cipherstash/stack/languages/golang/internal/guest"
44

55
// ClientKey is the ZeroKMS client key as [ProfileStore.SecretKey] reads it
66
// out of secretkey.json: opaque (it prints a redaction under every verb and
77
// hands its bytes to no caller) and wiped once consumed. It is the same
8-
// type as stackencrypt.ClientKey, by identity, so a key read here goes
9-
// straight into stackencrypt.NewCredentials. This package does not import
10-
// stackencrypt: a binary that only wants the profile does not carry the
11-
// crypto guest. (stackencrypt imports this one, for AutoCredentials.)
8+
// type as encrypt.ClientKey, by identity, so a key read here goes
9+
// straight into encrypt.NewCredentials. This package does not import
10+
// encrypt: a binary that only wants the profile does not carry the
11+
// crypto guest. (encrypt imports this one, for AutoCredentials.)
1212
type ClientKey = guest.ClientKey
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package stackauth is the Go binding of the developer profile: the
1+
// Package auth is the Go binding of the developer profile: the
22
// directory `stash auth login` writes (~/.cipherstash, or CS_CONFIG_PATH),
33
// read through the stack-profile crate running unmodified inside a WASI
44
// guest under wazero (CGO_ENABLED=0), so the on-disk layout is never
@@ -21,27 +21,27 @@
2121
// one workspace ([ProfileStore.WorkspaceStore],
2222
// [ProfileStore.CurrentWorkspaceStore]), and the typed reads of the files a
2323
// workspace holds: [ProfileStore.SecretKey] hands out the ZeroKMS client key
24-
// as the opaque [ClientKey] that stackencrypt.NewCredentials takes,
24+
// as the opaque [ClientKey] that encrypt.NewCredentials takes,
2525
// [ProfileStore.Token] the stored access token, [ProfileStore.DeviceIdentity]
2626
// the identity the CLI created. [ProfileStore.Close] releases the guest;
2727
// stores scoped from it are closed with it.
2828
//
2929
// For authentication and refresh, use [ProfileStore.AccessKey],
3030
// [ProfileStore.OIDC], [ProfileStore.DeviceSession], or [ProfileStore.Auto].
31-
// Each returns a [Strategy], which is what stackencrypt.NewCredentials takes
32-
// for the bearer token: the only way a token reaches a stackencrypt client.
31+
// Each returns a [Strategy], which is what encrypt.NewCredentials takes
32+
// for the bearer token: the only way a token reaches a encrypt client.
3333
// A raw token — [ProfileStore.Token]'s included — cannot be refreshed when
3434
// it expires, and would bypass the cross-process lock a device-session
35-
// refresh holds with the CLI, so stackencrypt does not accept one. A
35+
// refresh holds with the CLI, so encrypt does not accept one. A
3636
// strategy lives in its store's guest, and closing the store closes it. A
37-
// stackencrypt client given one never closes the strategy or the store:
37+
// encrypt client given one never closes the strategy or the store:
3838
// both are the caller's, and stay open until the client is closed.
3939
// [OAuth2TokenSource] adapts an existing golang.org/x/oauth2.TokenSource
4040
// into the OIDC provider interface.
4141
//
4242
// # Why a second guest
4343
//
44-
// The crypto guest behind stackencrypt has no filesystem and no
44+
// The crypto guest behind encrypt has no filesystem and no
4545
// environment: a bug or compromise inside it cannot read credentials off
4646
// disk. Mounting the profile into it would trade that away, and it is the
4747
// module that handles plaintext and data keys. So the profile lives in its
@@ -63,9 +63,9 @@
6363
// # Memory
6464
//
6565
// The guest's memory holds the client key and the token while a read is
66-
// in flight. It is supplied the way stackencrypt's is — reserved once so it
66+
// in flight. It is supplied the way encrypt's is — reserved once so it
6767
// never moves, locked in RAM and excluded from core dumps where the
6868
// platform allows, wiped before release, none of it depending on Close
6969
// running — and [ProfileStore.MemoryLocked] reports whether the lock was
7070
// granted. [RequireLockedMemory] makes a refused lock an error from Open.
71-
package stackauth
71+
package auth
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stackauth
1+
package auth
22

33
import (
44
"errors"
@@ -9,7 +9,7 @@ import (
99
// Failure kinds the profile reports. The guest reports a status code from
1010
// the one table every guest shares, so these are the sentinels of the
1111
// shared decoder exposed under this package's names; an error from
12-
// stackencrypt of the same kind is the same value.
12+
// encrypt of the same kind is the same value.
1313
var (
1414
// ErrNotFound is a profile file that does not exist in the store asked:
1515
// no secretkey.json, auth.json or device.json there. For the workspace's
@@ -60,5 +60,5 @@ var (
6060

6161
// ErrNoProfile is a profile directory that does not exist: nothing has
6262
// logged in on this machine, or CS_CONFIG_PATH names the wrong place.
63-
ErrNoProfile = errors.New("stackauth: no profile directory; run `stash auth login`")
63+
ErrNoProfile = errors.New("auth: no profile directory; run `stash auth login`")
6464
)

0 commit comments

Comments
 (0)