@inixiative/signet 0.5.0 → 0.5.1
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/package.json +3 -2
- package/src/threads.ts +7 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inixiative/signet",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Present Kingdom Signets: the wire contracts, DPoP proofs, device pairing and a renewing client shared by Kingdom, Archive, Foundry and Oracle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"jose": "^6.2.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@asteasolutions/zod-to-openapi": "^9.1.0",
|
|
36
37
|
"@biomejs/biome": "2.5.2",
|
|
37
|
-
"@inixiative/config": "^0.5.
|
|
38
|
+
"@inixiative/config": "^0.5.116",
|
|
38
39
|
"@types/bun": "1.4.2",
|
|
39
40
|
"lefthook": "2.1.9",
|
|
40
41
|
"typescript": "6.0.3",
|
package/src/threads.ts
CHANGED
|
@@ -27,16 +27,15 @@ export const threadIdSchema = foundryIdSchema;
|
|
|
27
27
|
export const unbuiltThreadSelectorForms = ['withMember', 'tag'] as const;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* set only by approving a request for a selector form narrowed
|
|
32
|
-
* `ids ∩ within`)
|
|
30
|
+
* `ids` takes `within` only once a non-`ids` form exists: `within` will hold exactly one such form
|
|
31
|
+
* (never a selector, so it can't nest), set only by approving a request for a selector form narrowed
|
|
32
|
+
* to `ids` (the grant is then `ids ∩ within`), and approval may never drop or widen it. Until then
|
|
33
|
+
* the strict object refuses `within` like any unknown key: structural, and representable in Kingdom's
|
|
34
|
+
* OpenAPI (a `z.never()` placeholder is not).
|
|
33
35
|
*/
|
|
34
|
-
export const threadSelectorWithinSchema = z.never();
|
|
35
|
-
|
|
36
36
|
export const idsThreadSelectorSchema = z.strictObject({
|
|
37
37
|
form: z.literal('ids'),
|
|
38
38
|
ids: z.array(threadIdSchema).min(1).max(100),
|
|
39
|
-
within: threadSelectorWithinSchema.optional(),
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
/** Which threads a grant reaches. A discriminated union on `form`; v1 builds only `ids`. */
|
|
@@ -78,12 +77,8 @@ export const narrowsThreadSelector = (
|
|
|
78
77
|
): boolean => {
|
|
79
78
|
switch (requested.form) {
|
|
80
79
|
case 'ids':
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
granted.ids.every((id) => requested.ids.includes(id)) &&
|
|
84
|
-
// `within` can only be kept as asked: never dropped, never added to a plain id list.
|
|
85
|
-
(requested.within === undefined) === (granted.within === undefined)
|
|
86
|
-
);
|
|
80
|
+
// When `within` exists, it must also be kept as asked: never dropped, never added.
|
|
81
|
+
return granted.form === 'ids' && granted.ids.every((id) => requested.ids.includes(id));
|
|
87
82
|
}
|
|
88
83
|
};
|
|
89
84
|
|