@gjermundgaraba/clankerauth-admin-api 0.0.0-stage → 0.24.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/LICENSE +21 -0
- package/README.md +47 -2
- package/dist/index.d.ts +937 -0
- package/dist/index.js +359 -0
- package/package.json +38 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gjermund Garaba
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gjermundgaraba/clankerauth-admin-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The administration contract of a [clankerauth](https://github.com/gjermundgaraba/clankerauth) issuer: every owner action as an [effect-actions](https://www.npmjs.com/package/@gjermundgaraba/effect-actions) action, with its input and output schemas, its tagged errors, and the HTTP bindings the issuer serves them on. The issuer, its dashboard, its MCP endpoint and the `clankerauth` CLI all derive from it, so a program calling it gets the same actions, typed, with no CLI in between.
|
|
4
|
+
|
|
5
|
+
Its version follows the issuer's: use the one matching the issuer you call.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
vp add @gjermundgaraba/clankerauth-admin-api effect @gjermundgaraba/effect-actions@^0.18.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Effect and effect-actions are peers, shared with the program.
|
|
14
|
+
|
|
15
|
+
## Call administration from a program
|
|
16
|
+
|
|
17
|
+
`OwnerHttp` is the binding served at `/api/owner/<action>`, authenticated by an owner's access token for the administration resource, the issuer's origin root. The owner's sign-in that `clankerauth login <issuer>` keeps gives one: `authorizing` of [`@gjermundgaraba/clankerauth-sdk/credentials`](../sdk/README.md) sends it with each request, refreshed as it expires, and the methods fail with `SignInRequired` when there is none.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Effect } from "effect";
|
|
21
|
+
import { FetchHttpClient } from "effect/http";
|
|
22
|
+
import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
|
|
23
|
+
import * as Credentials from "@gjermundgaraba/clankerauth-sdk/credentials";
|
|
24
|
+
import { OwnerHttp } from "@gjermundgaraba/clankerauth-admin-api";
|
|
25
|
+
|
|
26
|
+
const issuer = "https://clankerauth.home.example";
|
|
27
|
+
|
|
28
|
+
const program = Effect.gen(function* () {
|
|
29
|
+
const admin = yield* ActionHttp.client(OwnerHttp, {
|
|
30
|
+
baseUrl: issuer,
|
|
31
|
+
transformClient: Credentials.authorizing({ url: issuer }),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const { created } = yield* admin.putResource({
|
|
35
|
+
identifier: "https://notes.home.example/",
|
|
36
|
+
name: "Notes",
|
|
37
|
+
scopes: ["notes:read", "notes:write"],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return created;
|
|
41
|
+
}).pipe(Effect.provide(FetchHttpClient.layer));
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
A refusal fails with its tagged error, such as `ResourceNotFound` from `getResource` or `deleteResource`; each action declares the ones it can produce. `getResource` reads one resource, `putResource` creates or updates one to exactly the name and scopes given, so a deployment tool states what it wants without choosing between create and update, and `deleteResource` removes one.
|
|
45
|
+
|
|
46
|
+
Administration takes no API keys: the token is always an owner's.
|
|
47
|
+
|
|
48
|
+
MIT licensed.
|