@haverstack/core 0.40.0 → 0.42.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 +121 -59
- package/dist/access.d.ts +34 -36
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +65 -42
- package/dist/access.js.map +1 -1
- package/dist/{combine.d.ts → adapter/combine.d.ts} +8 -1
- package/dist/adapter/combine.d.ts.map +1 -0
- package/dist/{combine.js → adapter/combine.js} +7 -0
- package/dist/adapter/combine.js.map +1 -0
- package/dist/{adapter-entry.d.ts → adapter/index.d.ts} +6 -5
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/{adapter-entry.js → adapter/index.js} +5 -4
- package/dist/adapter/index.js.map +1 -0
- package/dist/{sort.d.ts → adapter/sort.d.ts} +20 -20
- package/dist/adapter/sort.d.ts.map +1 -0
- package/dist/{sort.js → adapter/sort.js} +37 -27
- package/dist/adapter/sort.js.map +1 -0
- package/dist/associations/identity.d.ts +93 -0
- package/dist/associations/identity.d.ts.map +1 -0
- package/dist/associations/identity.js +198 -0
- package/dist/associations/identity.js.map +1 -0
- package/dist/associations/validation.d.ts +90 -0
- package/dist/associations/validation.d.ts.map +1 -0
- package/dist/associations/validation.js +339 -0
- package/dist/associations/validation.js.map +1 -0
- package/dist/attachment-records.d.ts +48 -0
- package/dist/attachment-records.d.ts.map +1 -0
- package/dist/attachment-records.js +52 -0
- package/dist/attachment-records.js.map +1 -0
- package/dist/collection.d.ts +182 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +407 -0
- package/dist/collection.js.map +1 -0
- package/dist/content-match.d.ts +25 -0
- package/dist/content-match.d.ts.map +1 -0
- package/dist/content-match.js +51 -0
- package/dist/content-match.js.map +1 -0
- package/dist/content-translation.d.ts +42 -0
- package/dist/content-translation.d.ts.map +1 -0
- package/dist/content-translation.js +108 -0
- package/dist/content-translation.js.map +1 -0
- package/dist/did/did.d.ts.map +1 -0
- package/dist/{did.js → did/did.js} +3 -4
- package/dist/did/did.js.map +1 -0
- package/dist/{did-entry.d.ts → did/index.d.ts} +1 -1
- package/dist/did/index.d.ts.map +1 -0
- package/dist/{did-entry.js → did/index.js} +3 -3
- package/dist/did/index.js.map +1 -0
- package/dist/errors.d.ts +36 -63
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +35 -58
- package/dist/errors.js.map +1 -1
- package/dist/grants.d.ts +20 -43
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +71 -134
- package/dist/grants.js.map +1 -1
- package/dist/id.d.ts +13 -31
- package/dist/id.d.ts.map +1 -1
- package/dist/id.js +13 -31
- package/dist/id.js.map +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +141 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +219 -0
- package/dist/install.js.map +1 -0
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +5 -11
- package/dist/merge.js.map +1 -1
- package/dist/migration-steps.d.ts +102 -0
- package/dist/migration-steps.d.ts.map +1 -0
- package/dist/migration-steps.js +293 -0
- package/dist/migration-steps.js.map +1 -0
- package/dist/query-validation.d.ts +28 -94
- package/dist/query-validation.d.ts.map +1 -1
- package/dist/query-validation.js +156 -336
- package/dist/query-validation.js.map +1 -1
- package/dist/record-changes.d.ts +2 -117
- package/dist/record-changes.d.ts.map +1 -1
- package/dist/record-changes.js +10 -212
- package/dist/record-changes.js.map +1 -1
- package/dist/schema.d.ts +18 -7
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +59 -30
- package/dist/schema.js.map +1 -1
- package/dist/scoped-stack/authority.d.ts +156 -0
- package/dist/scoped-stack/authority.d.ts.map +1 -0
- package/dist/scoped-stack/authority.js +384 -0
- package/dist/scoped-stack/authority.js.map +1 -0
- package/dist/scoped-stack/scoped-stack.d.ts +338 -0
- package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
- package/dist/scoped-stack/scoped-stack.js +776 -0
- package/dist/scoped-stack/scoped-stack.js.map +1 -0
- package/dist/scoped-stack/subscription.d.ts +55 -0
- package/dist/scoped-stack/subscription.d.ts.map +1 -0
- package/dist/scoped-stack/subscription.js +110 -0
- package/dist/scoped-stack/subscription.js.map +1 -0
- package/dist/stack/attachments.d.ts +24 -0
- package/dist/stack/attachments.d.ts.map +1 -0
- package/dist/stack/attachments.js +113 -0
- package/dist/stack/attachments.js.map +1 -0
- package/dist/{changes.d.ts → stack/changes.d.ts} +29 -65
- package/dist/stack/changes.d.ts.map +1 -0
- package/dist/{changes.js → stack/changes.js} +32 -66
- package/dist/stack/changes.js.map +1 -0
- package/dist/stack/client.d.ts +271 -0
- package/dist/stack/client.d.ts.map +1 -0
- package/dist/stack/client.js +9 -0
- package/dist/stack/client.js.map +1 -0
- package/dist/stack/identity-bindings.d.ts.map +1 -0
- package/dist/{identity-bindings.js → stack/identity-bindings.js} +8 -14
- package/dist/stack/identity-bindings.js.map +1 -0
- package/dist/stack/install-app.d.ts +22 -0
- package/dist/stack/install-app.d.ts.map +1 -0
- package/dist/stack/install-app.js +260 -0
- package/dist/stack/install-app.js.map +1 -0
- package/dist/stack/integrity.d.ts +94 -0
- package/dist/stack/integrity.d.ts.map +1 -0
- package/dist/stack/integrity.js +268 -0
- package/dist/stack/integrity.js.map +1 -0
- package/dist/{limits.d.ts → stack/limits.d.ts} +2 -5
- package/dist/stack/limits.d.ts.map +1 -0
- package/dist/{limits.js → stack/limits.js} +3 -6
- package/dist/stack/limits.js.map +1 -0
- package/dist/stack/migrations.d.ts +59 -0
- package/dist/stack/migrations.d.ts.map +1 -0
- package/dist/stack/migrations.js +141 -0
- package/dist/stack/migrations.js.map +1 -0
- package/dist/{stack-reads.d.ts → stack/reads.d.ts} +33 -6
- package/dist/stack/reads.d.ts.map +1 -0
- package/dist/{stack-reads.js → stack/reads.js} +49 -7
- package/dist/stack/reads.js.map +1 -0
- package/dist/stack/record-id.d.ts +35 -0
- package/dist/stack/record-id.d.ts.map +1 -0
- package/dist/stack/record-id.js +82 -0
- package/dist/stack/record-id.js.map +1 -0
- package/dist/stack/stack.d.ts +438 -0
- package/dist/stack/stack.d.ts.map +1 -0
- package/dist/stack/stack.js +1366 -0
- package/dist/stack/stack.js.map +1 -0
- package/dist/stack/system-types.d.ts +16 -0
- package/dist/stack/system-types.d.ts.map +1 -0
- package/dist/stack/system-types.js +111 -0
- package/dist/stack/system-types.js.map +1 -0
- package/dist/stack/type-grants.d.ts +20 -0
- package/dist/stack/type-grants.d.ts.map +1 -0
- package/dist/stack/type-grants.js +69 -0
- package/dist/stack/type-grants.js.map +1 -0
- package/dist/stack/write-expectation.d.ts +78 -0
- package/dist/stack/write-expectation.d.ts.map +1 -0
- package/dist/stack/write-expectation.js +71 -0
- package/dist/stack/write-expectation.js.map +1 -0
- package/dist/testing.d.ts +21 -26
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +50 -70
- package/dist/testing.js.map +1 -1
- package/dist/type-handle.d.ts +67 -78
- package/dist/type-handle.d.ts.map +1 -1
- package/dist/type-handle.js +44 -111
- package/dist/type-handle.js.map +1 -1
- package/dist/types/adapter.d.ts +223 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/adapter.js +5 -0
- package/dist/types/adapter.js.map +1 -0
- package/dist/types/associations.d.ts +156 -0
- package/dist/types/associations.d.ts.map +1 -0
- package/dist/types/associations.js +13 -0
- package/dist/types/associations.js.map +1 -0
- package/dist/types/capabilities.d.ts +89 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +5 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/events.d.ts +155 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +5 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/ids.d.ts +43 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +5 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/journal.d.ts +47 -0
- package/dist/types/journal.d.ts.map +1 -0
- package/dist/types/journal.js +5 -0
- package/dist/types/journal.js.map +1 -0
- package/dist/types/query.d.ts +185 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +10 -0
- package/dist/types/query.js.map +1 -0
- package/dist/types/records.d.ts +76 -0
- package/dist/types/records.d.ts.map +1 -0
- package/dist/types/records.js +5 -0
- package/dist/types/records.js.map +1 -0
- package/dist/types/schema.d.ts +74 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +5 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/types/system.d.ts +161 -0
- package/dist/types/system.d.ts.map +1 -0
- package/dist/types/system.js +32 -0
- package/dist/types/system.js.map +1 -0
- package/dist/types/tokens.d.ts +39 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/types/tokens.js +5 -0
- package/dist/types/tokens.js.map +1 -0
- package/dist/validate.d.ts +29 -70
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +65 -97
- package/dist/validate.js.map +1 -1
- package/dist/{attachment-download.d.ts → wire/attachment-download.d.ts} +0 -57
- package/dist/wire/attachment-download.d.ts.map +1 -0
- package/dist/{attachment-download.js → wire/attachment-download.js} +0 -61
- package/dist/wire/attachment-download.js.map +1 -0
- package/dist/{auth.d.ts → wire/auth.d.ts} +5 -8
- package/dist/wire/auth.d.ts.map +1 -0
- package/dist/{auth.js → wire/auth.js} +5 -8
- package/dist/wire/auth.js.map +1 -0
- package/dist/{wire-body.d.ts → wire/body.d.ts} +13 -5
- package/dist/wire/body.d.ts.map +1 -0
- package/dist/{wire-body.js → wire/body.js} +65 -7
- package/dist/wire/body.js.map +1 -0
- package/dist/{wire-entry.d.ts → wire/index.d.ts} +12 -12
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/{wire-entry.js → wire/index.js} +13 -17
- package/dist/wire/index.js.map +1 -0
- package/dist/{wire-record.d.ts → wire/record.d.ts} +10 -22
- package/dist/wire/record.d.ts.map +1 -0
- package/dist/{wire-record.js → wire/record.js} +12 -24
- package/dist/wire/record.js.map +1 -0
- package/dist/{wire-request.d.ts → wire/request.d.ts} +20 -37
- package/dist/wire/request.d.ts.map +1 -0
- package/dist/{wire-request.js → wire/request.js} +79 -54
- package/dist/wire/request.js.map +1 -0
- package/package.json +7 -7
- package/dist/adapter-entry.d.ts.map +0 -1
- package/dist/adapter-entry.js.map +0 -1
- package/dist/attachment-download.d.ts.map +0 -1
- package/dist/attachment-download.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/changes.d.ts.map +0 -1
- package/dist/changes.js.map +0 -1
- package/dist/combine.d.ts.map +0 -1
- package/dist/combine.js.map +0 -1
- package/dist/did-entry.d.ts.map +0 -1
- package/dist/did-entry.js.map +0 -1
- package/dist/did.d.ts.map +0 -1
- package/dist/did.js.map +0 -1
- package/dist/identity-bindings.d.ts.map +0 -1
- package/dist/identity-bindings.js.map +0 -1
- package/dist/limits.d.ts.map +0 -1
- package/dist/limits.js.map +0 -1
- package/dist/record-id.d.ts +0 -70
- package/dist/record-id.d.ts.map +0 -1
- package/dist/record-id.js +0 -127
- package/dist/record-id.js.map +0 -1
- package/dist/scoped-stack.d.ts +0 -532
- package/dist/scoped-stack.d.ts.map +0 -1
- package/dist/scoped-stack.js +0 -1219
- package/dist/scoped-stack.js.map +0 -1
- package/dist/sort.d.ts.map +0 -1
- package/dist/sort.js.map +0 -1
- package/dist/stack-reads.d.ts.map +0 -1
- package/dist/stack-reads.js.map +0 -1
- package/dist/stack.d.ts +0 -971
- package/dist/stack.d.ts.map +0 -1
- package/dist/stack.js +0 -2012
- package/dist/stack.js.map +0 -1
- package/dist/types.d.ts +0 -1250
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -49
- package/dist/types.js.map +0 -1
- package/dist/wire-body.d.ts.map +0 -1
- package/dist/wire-body.js.map +0 -1
- package/dist/wire-entry.d.ts.map +0 -1
- package/dist/wire-entry.js.map +0 -1
- package/dist/wire-record.d.ts.map +0 -1
- package/dist/wire-record.js.map +0 -1
- package/dist/wire-request.d.ts.map +0 -1
- package/dist/wire-request.js.map +0 -1
- /package/dist/{did.d.ts → did/did.d.ts} +0 -0
- /package/dist/{identity-bindings.d.ts → stack/identity-bindings.d.ts} +0 -0
package/dist/grants.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* See docs/spec/access-control.md § Type-level grants.
|
|
10
10
|
*/
|
|
11
|
-
import type { EntityId, GrantAction, GrantContent, GrantGrantee, GroupRole,
|
|
11
|
+
import type { BaseId, EntityId, GrantAction, GrantContent, GrantGrantee, GroupRole, RecordId, StackRecord, TypeId } from './types/index.js';
|
|
12
12
|
import type { ValidationError } from './validate.js';
|
|
13
13
|
/**
|
|
14
14
|
* Valid GrantAction values, for runtime validation in Stack.grantType(). Built
|
|
@@ -17,33 +17,18 @@ import type { ValidationError } from './validate.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const GRANT_ACTION_SET: ReadonlySet<GrantAction>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* cannot read is the drop-box, and it discloses nothing.
|
|
25
|
-
* See docs/spec/access-control.md § Write implies read.
|
|
26
|
-
*/
|
|
27
|
-
export declare const READ_COMPANIONS: ReadonlyMap<GrantAction, readonly GrantAction[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Whether one grant's action list conveys `action`. The companion has to
|
|
30
|
-
* sit in the same `_grant` Record: a grant is revoked whole, so a rule
|
|
31
|
-
* satisfied across two records would let revoking the read one leave a
|
|
32
|
-
* mutate-without-read grant standing.
|
|
33
|
-
*
|
|
34
|
-
* Takes the list grantReach() produced, never a stored field: `includes()`
|
|
35
|
-
* over a string is substring matching, so one would answer for every verb
|
|
36
|
-
* spelled inside it.
|
|
20
|
+
* Whether one grant's action list conveys `action`. The companion must sit
|
|
21
|
+
* in the same `_grant`: a grant is revoked whole, so a rule met across two
|
|
22
|
+
* records could leave mutate-without-read standing. Takes grantReach()'s
|
|
23
|
+
* list, never a stored field, whose `includes()` would match substrings.
|
|
37
24
|
*/
|
|
38
25
|
export declare function grantConveys(actions: readonly GrantAction[], action: GrantAction): boolean;
|
|
39
26
|
/**
|
|
40
27
|
* What a stored `_grant` reaches, or null where it names nothing the
|
|
41
|
-
* evaluator recognizes. Read as data
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* list, on the same terms an unknown grantee `kind` confers nothing.
|
|
46
|
-
* See docs/spec/access-control.md § Refused at the write, and again at evaluation.
|
|
28
|
+
* evaluator recognizes. Read as data — a grant can arrive from an import or
|
|
29
|
+
* a foreign server no schema saw — so an unknown action is dropped, as an
|
|
30
|
+
* unknown grantee confers nothing. See docs/spec/access-control.md
|
|
31
|
+
* § Refused at the write, and again at evaluation.
|
|
47
32
|
*/
|
|
48
33
|
export declare function grantReach(content: unknown): {
|
|
49
34
|
familyId: string;
|
|
@@ -61,6 +46,8 @@ export type GrantQuery = Exclude<GrantGrantee, {
|
|
|
61
46
|
groupId: RecordId;
|
|
62
47
|
role: GroupRole | 'any';
|
|
63
48
|
};
|
|
49
|
+
/** Whether two action lists name the same verbs, order and repeats aside. */
|
|
50
|
+
export declare function sameActions(a: readonly GrantAction[], b: readonly GrantAction[]): boolean;
|
|
64
51
|
/**
|
|
65
52
|
* Direct (non-roster) match between a stored _grant's content and a target:
|
|
66
53
|
* the whole grantee, `role` included. A target is the identity grantType()
|
|
@@ -69,13 +56,10 @@ export type GrantQuery = Exclude<GrantGrantee, {
|
|
|
69
56
|
*/
|
|
70
57
|
export declare function matchesGrantTarget(content: GrantContent, target: GrantQuery): boolean;
|
|
71
58
|
/**
|
|
72
|
-
* Reject a grant target that names no tier, or whose tier names nobody
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* body or an import has whatever shape it arrived with, so a key its tier
|
|
77
|
-
* does not define is refused too. `allowAny` admits
|
|
78
|
-
* the listing-only `role: 'any'`, which grantType() and revokeType() refuse.
|
|
59
|
+
* Reject a grant target that names no tier, or whose tier names nobody: it
|
|
60
|
+
* would store a grant that can only deny while looking like a share that
|
|
61
|
+
* worked. Read as data, so a key its tier does not define is refused too.
|
|
62
|
+
* `allowAny` admits the listing-only `role: 'any'`.
|
|
79
63
|
*/
|
|
80
64
|
export declare function validateGrantTarget(target: GrantQuery, allowAny?: boolean): void;
|
|
81
65
|
/**
|
|
@@ -109,20 +93,13 @@ export declare function grantCoversGrantee(c: GrantContent, grantee: EntityId, o
|
|
|
109
93
|
* System type families grantType() refuses to target: a grant on any of them
|
|
110
94
|
* would let the grantee mint their own grants, touch stack config, or
|
|
111
95
|
* register an app card claiming a DID that isn't theirs — the last of which
|
|
112
|
-
* is what verified app attribution rests on
|
|
96
|
+
* is what verified app attribution rests on — or approve an install, which
|
|
97
|
+
* decides grants and migration authority.
|
|
113
98
|
*/
|
|
114
99
|
export declare const UNGRANTABLE_SYSTEM_TYPES: ReadonlySet<string>;
|
|
115
100
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* itself sit behind a read check.
|
|
119
|
-
*
|
|
120
|
-
* `includeUnlisted`, because withholding a Record from enumeration decides
|
|
121
|
-
* nothing about what it confers. Deleted grants are excluded on the
|
|
122
|
-
* opposite grounds — a soft delete is how revokeType() withdraws one.
|
|
123
|
-
* See docs/spec/unlisted.md.
|
|
101
|
+
* Actions must be known GrantAction values; the target is held to the
|
|
102
|
+
* same rule every `_grant` write meets — see validateGrantBaseId().
|
|
124
103
|
*/
|
|
125
|
-
export declare function
|
|
126
|
-
content: GrantContent;
|
|
127
|
-
})[]>;
|
|
104
|
+
export declare function checkGrantValid(baseId: BaseId, actions: GrantAction[]): void;
|
|
128
105
|
//# sourceMappingURL=grants.d.ts.map
|
package/dist/grants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,WAAW,CAA0B,CAAC;AAejF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAI1F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,GAAG,IAAI,CAUhG;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,GACxC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAA;CAAE,CAAC;AAElE,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,WAAW,EAAE,EAAE,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAIzF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CASrF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,UAAQ,GAAG,IAAI,CAa9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,CAMnF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,CAiBvF;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,CAAC,EAAE,YAAY,EACf,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE;IACJ,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;IAC1C,aAAa,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC9D,GACA,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,CAKvD,CAAC;AAEH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CA2B5E"}
|
package/dist/grants.js
CHANGED
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
* See docs/spec/access-control.md § Type-level grants.
|
|
10
10
|
*/
|
|
11
11
|
import { baseIdOf, familyIdProblem } from './schema.js';
|
|
12
|
-
import { StackBadRequestError } from './errors.js';
|
|
13
|
-
import {
|
|
14
|
-
import { SYSTEM_TYPES, GRANT_ACTIONS } from './types.js';
|
|
15
|
-
import {
|
|
16
|
-
import { queryAllPages } from './stack-reads.js';
|
|
12
|
+
import { ARGUMENTS_INVALID, StackBadRequestError, StackValidationError } from './errors.js';
|
|
13
|
+
import { granteeErrors } from './associations/validation.js';
|
|
14
|
+
import { SYSTEM_TYPES, GRANT_ACTIONS } from './types/index.js';
|
|
15
|
+
import { resolveGroupRole, roleSatisfies } from './access.js';
|
|
17
16
|
/**
|
|
18
17
|
* Valid GrantAction values, for runtime validation in Stack.grantType(). Built
|
|
19
18
|
* from GRANT_ACTIONS, which GrantAction itself derives from, so the set and
|
|
@@ -21,28 +20,22 @@ import { queryAllPages } from './stack-reads.js';
|
|
|
21
20
|
*/
|
|
22
21
|
export const GRANT_ACTION_SET = new Set(GRANT_ACTIONS);
|
|
23
22
|
/**
|
|
24
|
-
* The read actions that make a mutate action coherent, scope for scope
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* verb to nobody. `create` has no companion — writing a Record you then
|
|
28
|
-
* cannot read is the drop-box, and it discloses nothing.
|
|
23
|
+
* The read actions that make a mutate action coherent, scope for scope. A
|
|
24
|
+
* grant carrying none conveys the verb to nobody. `create` has none:
|
|
25
|
+
* writing a Record you cannot read is the drop-box, and discloses nothing.
|
|
29
26
|
* See docs/spec/access-control.md § Write implies read.
|
|
30
27
|
*/
|
|
31
|
-
|
|
28
|
+
const READ_COMPANIONS = new Map([
|
|
32
29
|
['update-own', ['read-own', 'read-any']],
|
|
33
30
|
['delete-own', ['read-own', 'read-any']],
|
|
34
31
|
['update-any', ['read-any']],
|
|
35
32
|
['delete-any', ['read-any']],
|
|
36
33
|
]);
|
|
37
34
|
/**
|
|
38
|
-
* Whether one grant's action list conveys `action`. The companion
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Takes the list grantReach() produced, never a stored field: `includes()`
|
|
44
|
-
* over a string is substring matching, so one would answer for every verb
|
|
45
|
-
* spelled inside it.
|
|
35
|
+
* Whether one grant's action list conveys `action`. The companion must sit
|
|
36
|
+
* in the same `_grant`: a grant is revoked whole, so a rule met across two
|
|
37
|
+
* records could leave mutate-without-read standing. Takes grantReach()'s
|
|
38
|
+
* list, never a stored field, whose `includes()` would match substrings.
|
|
46
39
|
*/
|
|
47
40
|
export function grantConveys(actions, action) {
|
|
48
41
|
if (!actions.includes(action))
|
|
@@ -52,12 +45,10 @@ export function grantConveys(actions, action) {
|
|
|
52
45
|
}
|
|
53
46
|
/**
|
|
54
47
|
* What a stored `_grant` reaches, or null where it names nothing the
|
|
55
|
-
* evaluator recognizes. Read as data
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* list, on the same terms an unknown grantee `kind` confers nothing.
|
|
60
|
-
* See docs/spec/access-control.md § Refused at the write, and again at evaluation.
|
|
48
|
+
* evaluator recognizes. Read as data — a grant can arrive from an import or
|
|
49
|
+
* a foreign server no schema saw — so an unknown action is dropped, as an
|
|
50
|
+
* unknown grantee confers nothing. See docs/spec/access-control.md
|
|
51
|
+
* § Refused at the write, and again at evaluation.
|
|
61
52
|
*/
|
|
62
53
|
export function grantReach(content) {
|
|
63
54
|
const c = content;
|
|
@@ -73,6 +64,12 @@ export function grantReach(content) {
|
|
|
73
64
|
actions: c.actions.filter((a) => GRANT_ACTION_SET.has(a)),
|
|
74
65
|
};
|
|
75
66
|
}
|
|
67
|
+
/** Whether two action lists name the same verbs, order and repeats aside. */
|
|
68
|
+
export function sameActions(a, b) {
|
|
69
|
+
const as = new Set(a);
|
|
70
|
+
const bs = new Set(b);
|
|
71
|
+
return as.size === bs.size && [...bs].every((x) => as.has(x));
|
|
72
|
+
}
|
|
76
73
|
/**
|
|
77
74
|
* Direct (non-roster) match between a stored _grant's content and a target:
|
|
78
75
|
* the whole grantee, `role` included. A target is the identity grantType()
|
|
@@ -92,40 +89,21 @@ export function matchesGrantTarget(content, target) {
|
|
|
92
89
|
return g.kind === 'authenticated';
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
|
-
* Reject a grant target that names no tier, or whose tier names nobody
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* body or an import has whatever shape it arrived with, so a key its tier
|
|
100
|
-
* does not define is refused too. `allowAny` admits
|
|
101
|
-
* the listing-only `role: 'any'`, which grantType() and revokeType() refuse.
|
|
92
|
+
* Reject a grant target that names no tier, or whose tier names nobody: it
|
|
93
|
+
* would store a grant that can only deny while looking like a share that
|
|
94
|
+
* worked. Read as data, so a key its tier does not define is refused too.
|
|
95
|
+
* `allowAny` admits the listing-only `role: 'any'`.
|
|
102
96
|
*/
|
|
103
97
|
export function validateGrantTarget(target, allowAny = false) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
return;
|
|
115
|
-
case 'group':
|
|
116
|
-
if (typeof t.groupId !== 'string' || t.groupId.length === 0) {
|
|
117
|
-
throw new StackBadRequestError('A group grant target requires a non-empty groupId.');
|
|
118
|
-
}
|
|
119
|
-
if (t.role !== 'member' && t.role !== 'admin' && !(allowAny && t.role === 'any')) {
|
|
120
|
-
throw new StackBadRequestError(allowAny
|
|
121
|
-
? "A group grant target requires role 'member', 'admin' or 'any'."
|
|
122
|
-
: "A group grant target requires role 'member' or 'admin'.");
|
|
123
|
-
}
|
|
124
|
-
// No format check: groupId is a reference, like parentId or an
|
|
125
|
-
// association's recordId. One that resolves to nothing simply denies.
|
|
126
|
-
return;
|
|
127
|
-
default:
|
|
128
|
-
throw new StackBadRequestError("A grant target must name its tier: { kind: 'entity' }, { kind: 'group' } or { kind: 'authenticated' }.");
|
|
98
|
+
// No format check on a groupId: it is a reference, like parentId or an
|
|
99
|
+
// association's recordId. One that resolves to nothing simply denies.
|
|
100
|
+
const errors = granteeErrors(target, 'grant target', {
|
|
101
|
+
unknownKeys: 'throw',
|
|
102
|
+
authenticated: true,
|
|
103
|
+
anyRole: allowAny,
|
|
104
|
+
});
|
|
105
|
+
if (errors.length > 0) {
|
|
106
|
+
throw new StackBadRequestError(`Invalid grant target: ${errors.map((e) => e.message).join(' ')}`);
|
|
129
107
|
}
|
|
130
108
|
}
|
|
131
109
|
/**
|
|
@@ -137,55 +115,11 @@ export function validateGrantTarget(target, allowAny = false) {
|
|
|
137
115
|
export function validateGrantee(typeId, content) {
|
|
138
116
|
if (baseIdOf(typeId) !== SYSTEM_TYPES.GRANT)
|
|
139
117
|
return [];
|
|
140
|
-
const
|
|
141
|
-
const g = c?.grantee;
|
|
118
|
+
const g = content?.grantee;
|
|
142
119
|
// An absent or non-object grantee is the schema's to refuse, and it does.
|
|
143
120
|
if (!g || typeof g !== 'object')
|
|
144
121
|
return [];
|
|
145
|
-
|
|
146
|
-
const unknown = unknownKeys(g, GRANTEE_KEYS[g.kind]);
|
|
147
|
-
if (unknown.length > 0)
|
|
148
|
-
return unknown.map((key) => ({
|
|
149
|
-
path: `grantee.${key}`,
|
|
150
|
-
message: `A ${String(g.kind)} grantee does not carry ${key}`,
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
switch (g.kind) {
|
|
154
|
-
case 'authenticated':
|
|
155
|
-
return [];
|
|
156
|
-
case 'entity':
|
|
157
|
-
return typeof g.entityId === 'string' && g.entityId.length > 0
|
|
158
|
-
? []
|
|
159
|
-
: [
|
|
160
|
-
{
|
|
161
|
-
path: 'grantee.entityId',
|
|
162
|
-
message: 'An entity grantee requires a non-empty entityId',
|
|
163
|
-
},
|
|
164
|
-
];
|
|
165
|
-
case 'group': {
|
|
166
|
-
const errors = [];
|
|
167
|
-
if (typeof g.groupId !== 'string' || g.groupId.length === 0) {
|
|
168
|
-
errors.push({
|
|
169
|
-
path: 'grantee.groupId',
|
|
170
|
-
message: 'A group grantee requires a non-empty groupId',
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
if (g.role !== 'member' && g.role !== 'admin') {
|
|
174
|
-
errors.push({
|
|
175
|
-
path: 'grantee.role',
|
|
176
|
-
message: "A group grantee requires role 'member' or 'admin'",
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
return errors;
|
|
180
|
-
}
|
|
181
|
-
default:
|
|
182
|
-
return [
|
|
183
|
-
{
|
|
184
|
-
path: 'grantee.kind',
|
|
185
|
-
message: "A grantee must name its tier: 'entity', 'group' or 'authenticated'",
|
|
186
|
-
},
|
|
187
|
-
];
|
|
188
|
-
}
|
|
122
|
+
return granteeErrors(g, 'grantee', { unknownKeys: 'collect', authenticated: true });
|
|
189
123
|
}
|
|
190
124
|
/**
|
|
191
125
|
* A `_grant`'s target, asked of its content on every write: a bare baseId
|
|
@@ -237,54 +171,57 @@ export async function grantCoversGrantee(c, grantee, opts) {
|
|
|
237
171
|
return false;
|
|
238
172
|
if (g.role !== 'member' && g.role !== 'admin')
|
|
239
173
|
return false;
|
|
240
|
-
const role = await
|
|
241
|
-
return g.role
|
|
174
|
+
const role = await resolveGroupRole(g.groupId, grantee, opts.resolveRecord, opts.groupRoles);
|
|
175
|
+
return roleSatisfies(role, g.role);
|
|
242
176
|
}
|
|
243
177
|
default:
|
|
244
178
|
return false;
|
|
245
179
|
}
|
|
246
180
|
}
|
|
247
|
-
/**
|
|
248
|
-
* An entity's role on a `_group` roster, memoized in the caller's
|
|
249
|
-
* `groupRoles` map. That map is built per operation, so no resolved role
|
|
250
|
-
* outlives the operation that resolved it — removal from a group must never
|
|
251
|
-
* go stale.
|
|
252
|
-
*/
|
|
253
|
-
async function resolveGroupRoleMemoized(groupId, entityId, groupRoles, resolveRecord) {
|
|
254
|
-
const key = `${groupId}:${entityId}`;
|
|
255
|
-
const cached = groupRoles.get(key);
|
|
256
|
-
if (cached !== undefined)
|
|
257
|
-
return cached;
|
|
258
|
-
const group = await resolveRecord(groupId);
|
|
259
|
-
const role = group && carriesRoster(group) ? groupRoleFromAssociations(group.associations, entityId) : null;
|
|
260
|
-
groupRoles.set(key, role);
|
|
261
|
-
return role;
|
|
262
|
-
}
|
|
263
181
|
/**
|
|
264
182
|
* System type families grantType() refuses to target: a grant on any of them
|
|
265
183
|
* would let the grantee mint their own grants, touch stack config, or
|
|
266
184
|
* register an app card claiming a DID that isn't theirs — the last of which
|
|
267
|
-
* is what verified app attribution rests on
|
|
185
|
+
* is what verified app attribution rests on — or approve an install, which
|
|
186
|
+
* decides grants and migration authority.
|
|
268
187
|
*/
|
|
269
188
|
export const UNGRANTABLE_SYSTEM_TYPES = new Set([
|
|
270
189
|
SYSTEM_TYPES.GRANT,
|
|
271
190
|
SYSTEM_TYPES.CONFIG,
|
|
272
191
|
SYSTEM_TYPES.APP,
|
|
192
|
+
SYSTEM_TYPES.INSTALL,
|
|
273
193
|
]);
|
|
274
194
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* itself sit behind a read check.
|
|
278
|
-
*
|
|
279
|
-
* `includeUnlisted`, because withholding a Record from enumeration decides
|
|
280
|
-
* nothing about what it confers. Deleted grants are excluded on the
|
|
281
|
-
* opposite grounds — a soft delete is how revokeType() withdraws one.
|
|
282
|
-
* See docs/spec/unlisted.md.
|
|
195
|
+
* Actions must be known GrantAction values; the target is held to the
|
|
196
|
+
* same rule every `_grant` write meets — see validateGrantBaseId().
|
|
283
197
|
*/
|
|
284
|
-
export
|
|
285
|
-
const
|
|
286
|
-
|
|
198
|
+
export function checkGrantValid(baseId, actions) {
|
|
199
|
+
const errors = [];
|
|
200
|
+
actions.forEach((action, j) => {
|
|
201
|
+
if (!GRANT_ACTION_SET.has(action)) {
|
|
202
|
+
errors.push({ path: `actions[${j}]`, message: `Unknown grant action "${action}"` });
|
|
203
|
+
}
|
|
287
204
|
});
|
|
288
|
-
|
|
205
|
+
const problem = familyIdProblem(baseId, 'grantType');
|
|
206
|
+
if (problem) {
|
|
207
|
+
errors.push({ path: 'baseId', message: problem });
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
errors.push(...validateGrantBaseId(`${SYSTEM_TYPES.GRANT}@1`, { baseId }));
|
|
211
|
+
}
|
|
212
|
+
actions.forEach((action, j) => {
|
|
213
|
+
if (grantConveys(actions, action))
|
|
214
|
+
return;
|
|
215
|
+
const companions = READ_COMPANIONS.get(action);
|
|
216
|
+
if (!companions)
|
|
217
|
+
return;
|
|
218
|
+
errors.push({
|
|
219
|
+
path: `actions[${j}]`,
|
|
220
|
+
message: `"${action}" requires ${companions.map((c) => `"${c}"`).join(' or ')} in the same grant: a mutate verb reaches the record and its history, so it conveys nothing without read. Name both in one grant: actions: [${companions.map((c) => `'${c}'`).join(' | ')}, '${action}']`,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
if (errors.length > 0) {
|
|
224
|
+
throw new StackValidationError(errors, ARGUMENTS_INVALID);
|
|
225
|
+
}
|
|
289
226
|
}
|
|
290
227
|
//# sourceMappingURL=grants.js.map
|
package/dist/grants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,aAAa,E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MAAM,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,WAAW,CAAC,GAAG;YACrB,OAAO,EAAE,IAAI,MAAM,cAAc,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,+IAA+I,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,MAAM,IAAI;SACxR,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
package/dist/id.d.ts
CHANGED
|
@@ -23,43 +23,25 @@ export declare const _setLastTimestamp: (timestamp: number) => void;
|
|
|
23
23
|
/** Resets all module-level generator state. For test isolation only. */
|
|
24
24
|
export declare const _resetIdState: () => void;
|
|
25
25
|
/**
|
|
26
|
-
* Largest timestamp
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* would be minting an ID it rejects on the way back in. generateId() can't
|
|
31
|
-
* reach this, since it encodes Date.now(); generateIdForTimestamp() takes
|
|
32
|
-
* whatever timestamp the caller asks for, so it is the one that has to
|
|
33
|
-
* check.
|
|
26
|
+
* Largest timestamp that still encodes to the 9-character prefix an ID's
|
|
27
|
+
* format requires (32^9 - 1, 3084-12-12T12:41:28.831Z); past it the library
|
|
28
|
+
* would mint an ID it rejects. Only generateIdForTimestamp() can reach it,
|
|
29
|
+
* since generateId() encodes Date.now().
|
|
34
30
|
*/
|
|
35
31
|
export declare const MAX_ID_TIMESTAMP: number;
|
|
36
32
|
/**
|
|
37
|
-
* Generate a new
|
|
38
|
-
* matches creation order
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* A millisecond whose suffix space is spent carries into the next one
|
|
42
|
-
* rather than failing, so how many IDs a millisecond holds never depends
|
|
43
|
-
* on where its random suffix happened to start — which is what keeps the
|
|
44
|
-
* order total and the call free of a capacity a caller cannot see.
|
|
45
|
-
* See docs/spec/data-model.md § Record IDs.
|
|
46
|
-
*
|
|
47
|
-
* @param timestamp - Override the timestamp (ms since epoch). Defaults to Date.now().
|
|
33
|
+
* Generate a new record ID, `timestamp` defaulting to now; lexicographic
|
|
34
|
+
* order matches creation order. A spent millisecond carries into the next
|
|
35
|
+
* rather than failing, so capacity never depends on where the random suffix
|
|
36
|
+
* started. See docs/spec/data-model.md § Record IDs.
|
|
48
37
|
*/
|
|
49
38
|
export declare const generateId: (timestamp?: number) => string;
|
|
50
39
|
/**
|
|
51
|
-
* Mint an ID for an arbitrary
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* and would otherwise clamp a deliberately historical timestamp forward to
|
|
57
|
-
* "now" the moment the process has minted any live ID past it — silently
|
|
58
|
-
* defeating the backdate it was asked for. Same-millisecond uniqueness for
|
|
59
|
-
* a historical timestamp is therefore left to a fresh random suffix each
|
|
60
|
-
* call rather than the live incrementing scheme; a collision surfaces the
|
|
61
|
-
* same way any client-supplied id collision does, as StackConflictError
|
|
62
|
-
* from the adapter.
|
|
40
|
+
* Mint an ID for an arbitrary, typically past, timestamp — Stack.create()'s
|
|
41
|
+
* backdated import. Bypasses generateId()'s monotonic floor, which guards
|
|
42
|
+
* live minting from clock steps but would clamp a historical timestamp to
|
|
43
|
+
* now. Uniqueness rests on a fresh random suffix; a collision surfaces as
|
|
44
|
+
* the adapter's StackConflictError.
|
|
63
45
|
*/
|
|
64
46
|
export declare const generateIdForTimestamp: (timestamp: number) => string;
|
|
65
47
|
/**
|
package/dist/id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,IAAI,QAAoB,CAAC;AAGtC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAcpC,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,SAAK;CAIzB;AAMD,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,MAiB7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,MAe7C,CAAC;AAkCF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,IAK7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,IAKjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,KAAG,IAErD,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,aAAa,QAAO,IAIhC,CAAC;AAMF
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,IAAI,QAAoB,CAAC;AAGtC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAcpC,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,SAAK;CAIzB;AAMD,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,MAiB7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,MAe7C,CAAC;AAkCF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,IAK7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,IAKjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,KAAG,IAErD,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,aAAa,QAAO,IAIhC,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAA2C,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,YAAW,MAAmB,KAAG,MAgB3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,KAAG,MAS1D,CAAC;AASF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,KAAG,OAA6B,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,KAAG,MACa,CAAC"}
|
package/dist/id.js
CHANGED
|
@@ -115,28 +115,17 @@ export const _resetIdState = () => {
|
|
|
115
115
|
// Public API
|
|
116
116
|
// -------------------------------------------------------
|
|
117
117
|
/**
|
|
118
|
-
* Largest timestamp
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* would be minting an ID it rejects on the way back in. generateId() can't
|
|
123
|
-
* reach this, since it encodes Date.now(); generateIdForTimestamp() takes
|
|
124
|
-
* whatever timestamp the caller asks for, so it is the one that has to
|
|
125
|
-
* check.
|
|
118
|
+
* Largest timestamp that still encodes to the 9-character prefix an ID's
|
|
119
|
+
* format requires (32^9 - 1, 3084-12-12T12:41:28.831Z); past it the library
|
|
120
|
+
* would mint an ID it rejects. Only generateIdForTimestamp() can reach it,
|
|
121
|
+
* since generateId() encodes Date.now().
|
|
126
122
|
*/
|
|
127
123
|
export const MAX_ID_TIMESTAMP = Math.pow(BASE, MIN_TIMESTAMP_LENGTH) - 1;
|
|
128
124
|
/**
|
|
129
|
-
* Generate a new
|
|
130
|
-
* matches creation order
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* A millisecond whose suffix space is spent carries into the next one
|
|
134
|
-
* rather than failing, so how many IDs a millisecond holds never depends
|
|
135
|
-
* on where its random suffix happened to start — which is what keeps the
|
|
136
|
-
* order total and the call free of a capacity a caller cannot see.
|
|
137
|
-
* See docs/spec/data-model.md § Record IDs.
|
|
138
|
-
*
|
|
139
|
-
* @param timestamp - Override the timestamp (ms since epoch). Defaults to Date.now().
|
|
125
|
+
* Generate a new record ID, `timestamp` defaulting to now; lexicographic
|
|
126
|
+
* order matches creation order. A spent millisecond carries into the next
|
|
127
|
+
* rather than failing, so capacity never depends on where the random suffix
|
|
128
|
+
* started. See docs/spec/data-model.md § Record IDs.
|
|
140
129
|
*/
|
|
141
130
|
export const generateId = (timestamp = Date.now()) => {
|
|
142
131
|
let effectiveTimestamp = Math.max(timestamp, lastTimestamp);
|
|
@@ -153,18 +142,11 @@ export const generateId = (timestamp = Date.now()) => {
|
|
|
153
142
|
return nowId + randChars;
|
|
154
143
|
};
|
|
155
144
|
/**
|
|
156
|
-
* Mint an ID for an arbitrary
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* and would otherwise clamp a deliberately historical timestamp forward to
|
|
162
|
-
* "now" the moment the process has minted any live ID past it — silently
|
|
163
|
-
* defeating the backdate it was asked for. Same-millisecond uniqueness for
|
|
164
|
-
* a historical timestamp is therefore left to a fresh random suffix each
|
|
165
|
-
* call rather than the live incrementing scheme; a collision surfaces the
|
|
166
|
-
* same way any client-supplied id collision does, as StackConflictError
|
|
167
|
-
* from the adapter.
|
|
145
|
+
* Mint an ID for an arbitrary, typically past, timestamp — Stack.create()'s
|
|
146
|
+
* backdated import. Bypasses generateId()'s monotonic floor, which guards
|
|
147
|
+
* live minting from clock steps but would clamp a historical timestamp to
|
|
148
|
+
* now. Uniqueness rests on a fresh random suffix; a collision surfaces as
|
|
149
|
+
* the adapter's StackConflictError.
|
|
168
150
|
*/
|
|
169
151
|
export const generateIdForTimestamp = (timestamp) => {
|
|
170
152
|
if (!Number.isFinite(timestamp) || timestamp < 0 || timestamp > MAX_ID_TIMESTAMP) {
|
package/dist/id.js.map
CHANGED
|
@@ -1 +1 @@
|
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