@usearete/sdk 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/index.cjs +655 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.esm.js +654 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,37 @@ for await (const item of session.stacks.myStack.views.MyEntity.list.use()) {
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Authentication
|
|
29
|
+
|
|
30
|
+
Pick the key by where the code runs:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// Servers, agents and local scripts (Node, Bun, Deno, workers, SSR):
|
|
34
|
+
// an agent key (a4_ak_...) or secret key (a4_sk_...).
|
|
35
|
+
const server = await createSession(
|
|
36
|
+
{ stacks: { myStack: MY_STACK } },
|
|
37
|
+
{ auth: { secretKey: process.env.ARETE_API_KEY } },
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Anything shipped to a browser: an origin-bound publishable key (a4_pk_...).
|
|
41
|
+
// Create one with `a4 auth keys create-publishable --origin <scheme://host[:port]>`.
|
|
42
|
+
const browser = await createSession(
|
|
43
|
+
{ stacks: { myStack: MY_STACK } },
|
|
44
|
+
{ auth: { publishableKey: import.meta.env.VITE_ARETE_PUBLISHABLE_KEY } },
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Outside a browser, when no `auth` option is set, the SDK uses `ARETE_API_KEY`
|
|
49
|
+
if it is set, and otherwise the agent or secret key from your `a4` login
|
|
50
|
+
(`a4 auth login`, `a4 auth signup` or `a4 init`). So `createSession({ stacks })`
|
|
51
|
+
is enough in a script on a machine where you are logged in with `a4`. The login
|
|
52
|
+
is read in Node (20.16+ / 22.3+), Bun and Deno (only with read permission
|
|
53
|
+
already granted), never in a browser, and browser bundles contain no Node
|
|
54
|
+
imports for it. If several `a4` profiles hold a key, set `ARETE_PROFILE` to pick
|
|
55
|
+
one. `secretKey` throws in a browser, as does a secret or agent key passed as
|
|
56
|
+
`publishableKey`; a publishable key passed as `secretKey` is refused everywhere.
|
|
57
|
+
Keys are never included in error messages or logs.
|
|
58
|
+
|
|
28
59
|
## SDK Shapes
|
|
29
60
|
|
|
30
61
|
### Mental Model
|