@apoa/core 0.2.2 → 0.2.3
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 +22 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,10 +55,15 @@ const denied = await apoa.authorizations.check(
|
|
|
55
55
|
- **Browser mode**: credential vault injection config (the AI never sees passwords)
|
|
56
56
|
- **Comprehensive test suite** with cross-SDK fixture verification against the [Python SDK](https://pypi.org/project/apoa/)
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Usage Styles
|
|
59
|
+
|
|
60
|
+
### Application facade
|
|
61
|
+
|
|
62
|
+
Recommended for apps. Configure keys once, then use namespaced resources.
|
|
59
63
|
|
|
60
64
|
```typescript
|
|
61
|
-
|
|
65
|
+
import { APOA } from '@apoa/core';
|
|
66
|
+
|
|
62
67
|
const apoa = new APOA({ privateKey: keys.privateKey });
|
|
63
68
|
const token = await apoa.tokens.createGrant({
|
|
64
69
|
principal: "did:apoa:you",
|
|
@@ -68,17 +73,30 @@ const token = await apoa.tokens.createGrant({
|
|
|
68
73
|
expiresIn: "30d",
|
|
69
74
|
});
|
|
70
75
|
await apoa.authorizations.check(token, "service.com", "action:read");
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Protocol client
|
|
79
|
+
|
|
80
|
+
Use this when you want direct access to stores, resolvers, and protocol-level options.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { createClient, MemoryAuditStore, MemoryRevocationStore } from '@apoa/core';
|
|
71
84
|
|
|
72
|
-
// Style 2: Protocol client
|
|
73
85
|
const client = createClient({
|
|
74
86
|
revocationStore: new MemoryRevocationStore(),
|
|
75
87
|
auditStore: new MemoryAuditStore(),
|
|
76
88
|
defaultSigningOptions: { privateKey: keys.privateKey },
|
|
77
89
|
});
|
|
78
90
|
await client.authorize(token, "service.com", "action:read");
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Standalone imports
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
Useful for scripts, tests, adapters, and focused protocol operations.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
81
98
|
import { checkScope, authorize, createToken } from '@apoa/core';
|
|
99
|
+
|
|
82
100
|
checkScope(token, "service.com", "action:read");
|
|
83
101
|
```
|
|
84
102
|
|