@ontrails/permits 1.0.0-beta.39 → 1.0.0-beta.41
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/CHANGELOG.md +11 -0
- package/README.md +5 -5
- package/package.json +2 -2
- package/src/trails/auth-verify.ts +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ontrails/permits
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.41
|
|
4
|
+
|
|
5
|
+
## 1.0.0-beta.40
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- [`5adb995`](https://github.com/outfitter-dev/trails/commit/5adb99551c2dda6190d46cce7f60bb08d63c99aa): Complete the v1 hard cutover from the authored `blaze` field to
|
|
10
|
+
`implementation` across trail contracts, surface projections, tests, examples,
|
|
11
|
+
and public source-analysis helpers. Existing applications must rename authored
|
|
12
|
+
trail behavior fields and direct trail-object access before upgrading.
|
|
13
|
+
|
|
3
14
|
## 1.0.0-beta.39
|
|
4
15
|
|
|
5
16
|
## 1.0.0-beta.38
|
package/README.md
CHANGED
|
@@ -11,15 +11,15 @@ The permits package owns adapter-agnostic auth resources, adapters, and helpers.
|
|
|
11
11
|
```typescript
|
|
12
12
|
export const create = trail('gist.create', {
|
|
13
13
|
permit: { scopes: ['gist:write'] },
|
|
14
|
-
|
|
15
|
-
// executeTrail enforces scopes before execution enters the
|
|
14
|
+
implementation: async (input, ctx) => {
|
|
15
|
+
// executeTrail enforces scopes before execution enters the implementation
|
|
16
16
|
return Result.ok(newGist);
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
export const search = trail('gist.search', {
|
|
21
21
|
permit: 'public',
|
|
22
|
-
|
|
22
|
+
implementation: async (input, ctx) => {
|
|
23
23
|
// No authentication required
|
|
24
24
|
return Result.ok(results);
|
|
25
25
|
},
|
|
@@ -108,13 +108,13 @@ interface Permit {
|
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
Access the permit in your
|
|
111
|
+
Access the permit in your implementation:
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
114
|
import { getPermit } from '@ontrails/permits';
|
|
115
115
|
|
|
116
116
|
const myTrail = trail('do.something', {
|
|
117
|
-
|
|
117
|
+
implementation: async (_input, ctx) => {
|
|
118
118
|
const permit = getPermit(ctx);
|
|
119
119
|
if (!permit) return Result.err(new Error('Not authenticated'));
|
|
120
120
|
return Result.ok({ userId: permit.id });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/permits",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.41",
|
|
4
4
|
"files": [
|
|
5
5
|
"src/**/*.ts",
|
|
6
6
|
"!src/**/__tests__/**",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
27
|
+
"@ontrails/core": "^1.0.0-beta.41",
|
|
28
28
|
"zod": "^4.3.5"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -48,7 +48,13 @@ const getSurface = (ctx: TrailContext): PermitExtractionInput['surface'] => {
|
|
|
48
48
|
* succeeds with a null permit, so `testAll(app)` works without configuration.
|
|
49
49
|
*/
|
|
50
50
|
export const authVerify = trail('auth.verify', {
|
|
51
|
-
|
|
51
|
+
examples: [
|
|
52
|
+
{
|
|
53
|
+
input: { token: 'test-token' },
|
|
54
|
+
name: 'Verify a token',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
implementation: async (input, ctx) => {
|
|
52
58
|
const adapter = authResource.from(ctx);
|
|
53
59
|
const result = await adapter.authenticate({
|
|
54
60
|
bearerToken: input.token,
|
|
@@ -78,12 +84,6 @@ export const authVerify = trail('auth.verify', {
|
|
|
78
84
|
valid: true,
|
|
79
85
|
});
|
|
80
86
|
},
|
|
81
|
-
examples: [
|
|
82
|
-
{
|
|
83
|
-
input: { token: 'test-token' },
|
|
84
|
-
name: 'Verify a token',
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
87
|
input: z.object({
|
|
88
88
|
token: z.string().min(1).describe('Bearer token to verify'),
|
|
89
89
|
}),
|