@substrat-run/engine-invites 0.4.9 → 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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts +113 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +111 -0
- package/dist/operations.js.map +1 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { type OrgId } from '@substrat-run/contracts';
|
|
|
11
11
|
export declare const INVITES_CONFLICT_REASONS: readonly ['open_invite_limit'];
|
|
12
12
|
export type InvitesConflictReason = (typeof INVITES_CONFLICT_REASONS)[number];
|
|
13
13
|
export { invitation, invitesEntities, invitationRow } from './entities.js';
|
|
14
|
+
export { invitesOperations, INVITES_PERMISSIONS } from './operations.js';
|
|
14
15
|
import { type ModuleRegistration, type OperationContext } from '@substrat-run/kernel';
|
|
15
16
|
export declare const INVITES_PERM: {
|
|
16
17
|
send: string & import("zod").$brand<"PermissionKey">;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,KAAK,EACX,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,YACnC,mBAAmB,CACX,CAAC;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAS9E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EA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,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAyCzB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClD,OAAO,CAAC,UAAU,CAAC,CAyDrB;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAc9E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,GAAG,UAAU,EAAE,CAM7E;AA6BD,eAAO,MAAM,aAAa,EAAE,kBAW3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entityRef, moduleManifest, permissionKey, substratError } from '@substrat-run/contracts';
|
|
1
|
+
import { entityRef, moduleManifest, operationInputsOf, permissionKey, substratError, } from '@substrat-run/contracts';
|
|
2
2
|
/**
|
|
3
3
|
* The conflict reasons this engine raises — its own vocabulary, narrowing the platform's
|
|
4
4
|
* `conflict` code (#113). Exported so a vertical can branch on WHY a refusal happened
|
|
@@ -17,6 +17,10 @@ const conflict = (reason, message) => substratError('conflict', message, { reaso
|
|
|
17
17
|
// entity-type constants its relation edges name, and the row schema to declare
|
|
18
18
|
// an operation's output against without retyping this engine's shape.
|
|
19
19
|
export { invitation, invitesEntities, invitationRow } from './entities.js';
|
|
20
|
+
// The declared operation surface (#865): what each operation checks and takes,
|
|
21
|
+
// readable by the conformance kit and by a composing vertical's routes.
|
|
22
|
+
export { invitesOperations, INVITES_PERMISSIONS } from './operations.js';
|
|
23
|
+
import { invitesOperations } from './operations.js';
|
|
20
24
|
import { assertAllowed, ulid, } from '@substrat-run/kernel';
|
|
21
25
|
// ============================================================================
|
|
22
26
|
// The invites engine (membership.md §6; mechanics from booking-social.md
|
|
@@ -274,6 +278,8 @@ const revokeOp = async (ctx, input) => {
|
|
|
274
278
|
export const invitesModule = {
|
|
275
279
|
manifest: invitesManifest,
|
|
276
280
|
migrations: invitesMigrations,
|
|
281
|
+
// Parse, don't trust: the HOST applies the declared schemas, on every path in.
|
|
282
|
+
operationInputs: operationInputsOf(invitesOperations),
|
|
277
283
|
operations: {
|
|
278
284
|
'invites/send': sendOp,
|
|
279
285
|
'invites/accept': acceptOp,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,GAEd,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,mBAAmB;CACX,CAAC;AAGX,gGAAgG;AAChG,MAAM,QAAQ,GAAG,CAAC,MAA6B,EAAE,OAAe,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAGpH,4EAA4E;AAC5E,+EAA+E;AAC/E,sEAAsE;AACtE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,+EAA+E;AAC/E,wEAAwE;AACxE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO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gB,EAAE,QAAuD;KAC1E;CACF,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The invites engine's declared operation surface (#865, and #891's recipe
|
|
3
|
+
* applied to the last three packages that had none).
|
|
4
|
+
*
|
|
5
|
+
* ## Why this file exists now
|
|
6
|
+
*
|
|
7
|
+
* It used to not, and the consequence was stated rather than hidden: this
|
|
8
|
+
* engine's node-only claim was a `nodeOnlySuite` tripwire — a grep of
|
|
9
|
+
* `index.ts` for a two-argument `ctx.check`. That is lexical, it proves an
|
|
10
|
+
* absence rather than a behaviour, and a check assembled through a helper is
|
|
11
|
+
* invisible to it. A DECLARATION is exact: `planEntityCheckCoverage` reads these
|
|
12
|
+
* four entries the same way the conformance kit does, so "this engine narrows
|
|
13
|
+
* nowhere" becomes a fact about the surface instead of a fact about the text.
|
|
14
|
+
*
|
|
15
|
+
* The day one of these narrows, `declaredNodeOnlySuite` goes red and the change
|
|
16
|
+
* has to wire the real kit. That is the whole point of writing it down.
|
|
17
|
+
*
|
|
18
|
+
* ## The node checks are the design, not an omission
|
|
19
|
+
*
|
|
20
|
+
* An invitation is an administrative act about the SCOPE — who may join it — so
|
|
21
|
+
* the authority to send one, list them, or revoke one is authority over
|
|
22
|
+
* membership rather than over any single invite. There is no principal who
|
|
23
|
+
* should hold `invites:revoke` for one invitation and not the next. A vertical
|
|
24
|
+
* wanting "revoke only what you sent" is expressing a policy about the inviter,
|
|
25
|
+
* and it belongs to that vertical.
|
|
26
|
+
*
|
|
27
|
+
* ## `invites/accept` checks nothing, and says so
|
|
28
|
+
*
|
|
29
|
+
* Declared with `narrows`, `unchecked` and an empty `checks`, which is the
|
|
30
|
+
* reviewable way to state an exception rather than leave a gap. The recipient is
|
|
31
|
+
* not a member of anything yet, so there is no grant they could hold: the
|
|
32
|
+
* INVITATION is the authority, proven by re-hashing the identifier they present.
|
|
33
|
+
* An operation with no `permission` and no `narrows` would be indistinguishable
|
|
34
|
+
* from one somebody forgot to gate — which is exactly what
|
|
35
|
+
* `declaredNodeOnlySuite`'s third assertion refuses to let happen.
|
|
36
|
+
*
|
|
37
|
+
* `unchecked` is what keeps the conformance receipt honest. An empty `checks` on
|
|
38
|
+
* its own also describes a walk over a COMPOSED engine's key (the engine declares
|
|
39
|
+
* those, so a caller must not restate them), so without the flag this operation
|
|
40
|
+
* was counted as one per-entity proof walk directly under a header reporting zero
|
|
41
|
+
* narrowed checks.
|
|
42
|
+
*
|
|
43
|
+
* No `http`: an engine owns no URL shape. The path is the composing vertical's
|
|
44
|
+
* decision, declared with `defineEngineRoutes` against these names.
|
|
45
|
+
*/
|
|
46
|
+
import { z } from '@substrat-run/contracts';
|
|
47
|
+
/** The keys these operations check. Mirrors `INVITES_PERM` in index.ts. */
|
|
48
|
+
export declare const INVITES_PERMISSIONS: readonly ['invites:send', 'invites:read', 'invites:revoke'];
|
|
49
|
+
export declare const invitesOperations: {
|
|
50
|
+
readonly 'invites/send': {
|
|
51
|
+
readonly summary: "Invite someone to an organization";
|
|
52
|
+
readonly permission: "invites:send";
|
|
53
|
+
readonly input: z.ZodObject<{
|
|
54
|
+
orgId: z.ZodString;
|
|
55
|
+
identifier: z.ZodString;
|
|
56
|
+
roleKey: z.ZodString;
|
|
57
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
readonly output: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
};
|
|
63
|
+
readonly 'invites/accept': {
|
|
64
|
+
readonly narrows: {
|
|
65
|
+
readonly reason: string;
|
|
66
|
+
readonly checks: readonly [];
|
|
67
|
+
readonly unchecked: true;
|
|
68
|
+
};
|
|
69
|
+
readonly summary: "Accept an invitation by presenting the identifier it was sent to";
|
|
70
|
+
readonly input: z.ZodObject<{
|
|
71
|
+
invitationId: z.ZodString;
|
|
72
|
+
identifier: z.ZodString;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
readonly output: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
org_id: z.ZodString;
|
|
77
|
+
role_key: z.ZodString;
|
|
78
|
+
state: z.ZodString;
|
|
79
|
+
invited_by: z.ZodString;
|
|
80
|
+
accepted_by: z.ZodNullable<z.ZodString>;
|
|
81
|
+
created_at: z.ZodString;
|
|
82
|
+
expires_at: z.ZodString;
|
|
83
|
+
settled_at: z.ZodNullable<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
};
|
|
86
|
+
readonly 'invites/list': {
|
|
87
|
+
readonly summary: "Invitations for an organization, with state";
|
|
88
|
+
readonly permission: "invites:read";
|
|
89
|
+
readonly input: z.ZodObject<{
|
|
90
|
+
orgId: z.ZodString;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
readonly output: z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
org_id: z.ZodString;
|
|
95
|
+
role_key: z.ZodString;
|
|
96
|
+
state: z.ZodString;
|
|
97
|
+
invited_by: z.ZodString;
|
|
98
|
+
accepted_by: z.ZodNullable<z.ZodString>;
|
|
99
|
+
created_at: z.ZodString;
|
|
100
|
+
expires_at: z.ZodString;
|
|
101
|
+
settled_at: z.ZodNullable<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
};
|
|
104
|
+
readonly 'invites/revoke': {
|
|
105
|
+
readonly summary: "Withdraw an invitation before it is accepted";
|
|
106
|
+
readonly permission: "invites:revoke";
|
|
107
|
+
readonly input: z.ZodObject<{
|
|
108
|
+
invitationId: z.ZodString;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
readonly output: z.ZodVoid;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAoB,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAG9D,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,YAAI,cAAc,EAAE,cAAc,EAAE,gBAAgB,CAAU,CAAC;AAI/F,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+D5B,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The invites engine's declared operation surface (#865, and #891's recipe
|
|
3
|
+
* applied to the last three packages that had none).
|
|
4
|
+
*
|
|
5
|
+
* ## Why this file exists now
|
|
6
|
+
*
|
|
7
|
+
* It used to not, and the consequence was stated rather than hidden: this
|
|
8
|
+
* engine's node-only claim was a `nodeOnlySuite` tripwire — a grep of
|
|
9
|
+
* `index.ts` for a two-argument `ctx.check`. That is lexical, it proves an
|
|
10
|
+
* absence rather than a behaviour, and a check assembled through a helper is
|
|
11
|
+
* invisible to it. A DECLARATION is exact: `planEntityCheckCoverage` reads these
|
|
12
|
+
* four entries the same way the conformance kit does, so "this engine narrows
|
|
13
|
+
* nowhere" becomes a fact about the surface instead of a fact about the text.
|
|
14
|
+
*
|
|
15
|
+
* The day one of these narrows, `declaredNodeOnlySuite` goes red and the change
|
|
16
|
+
* has to wire the real kit. That is the whole point of writing it down.
|
|
17
|
+
*
|
|
18
|
+
* ## The node checks are the design, not an omission
|
|
19
|
+
*
|
|
20
|
+
* An invitation is an administrative act about the SCOPE — who may join it — so
|
|
21
|
+
* the authority to send one, list them, or revoke one is authority over
|
|
22
|
+
* membership rather than over any single invite. There is no principal who
|
|
23
|
+
* should hold `invites:revoke` for one invitation and not the next. A vertical
|
|
24
|
+
* wanting "revoke only what you sent" is expressing a policy about the inviter,
|
|
25
|
+
* and it belongs to that vertical.
|
|
26
|
+
*
|
|
27
|
+
* ## `invites/accept` checks nothing, and says so
|
|
28
|
+
*
|
|
29
|
+
* Declared with `narrows`, `unchecked` and an empty `checks`, which is the
|
|
30
|
+
* reviewable way to state an exception rather than leave a gap. The recipient is
|
|
31
|
+
* not a member of anything yet, so there is no grant they could hold: the
|
|
32
|
+
* INVITATION is the authority, proven by re-hashing the identifier they present.
|
|
33
|
+
* An operation with no `permission` and no `narrows` would be indistinguishable
|
|
34
|
+
* from one somebody forgot to gate — which is exactly what
|
|
35
|
+
* `declaredNodeOnlySuite`'s third assertion refuses to let happen.
|
|
36
|
+
*
|
|
37
|
+
* `unchecked` is what keeps the conformance receipt honest. An empty `checks` on
|
|
38
|
+
* its own also describes a walk over a COMPOSED engine's key (the engine declares
|
|
39
|
+
* those, so a caller must not restate them), so without the flag this operation
|
|
40
|
+
* was counted as one per-entity proof walk directly under a header reporting zero
|
|
41
|
+
* narrowed checks.
|
|
42
|
+
*
|
|
43
|
+
* No `http`: an engine owns no URL shape. The path is the composing vertical's
|
|
44
|
+
* decision, declared with `defineEngineRoutes` against these names.
|
|
45
|
+
*/
|
|
46
|
+
import { defineOperations, z } from '@substrat-run/contracts';
|
|
47
|
+
import { invitation, invitesEntities } from './entities.js';
|
|
48
|
+
/** The keys these operations check. Mirrors `INVITES_PERM` in index.ts. */
|
|
49
|
+
export const INVITES_PERMISSIONS = ['invites:send', 'invites:read', 'invites:revoke'];
|
|
50
|
+
const invitationId = z.object({ invitationId: z.string().min(1) });
|
|
51
|
+
export const invitesOperations = defineOperations(invitesEntities, INVITES_PERMISSIONS)({
|
|
52
|
+
'invites/send': {
|
|
53
|
+
summary: 'Invite someone to an organization',
|
|
54
|
+
permission: 'invites:send',
|
|
55
|
+
input: z.object({
|
|
56
|
+
orgId: z.string().min(1),
|
|
57
|
+
/** Plaintext. Hashed before it touches storage, and never persisted. */
|
|
58
|
+
identifier: z.string().min(1),
|
|
59
|
+
roleKey: z.string().min(1),
|
|
60
|
+
/**
|
|
61
|
+
* Overrides the default 14-day standing offer.
|
|
62
|
+
*
|
|
63
|
+
* Deliberately NOT constrained to positive: a negative TTL mints an
|
|
64
|
+
* already-lapsed invitation, which is how the expiry sweep is driven
|
|
65
|
+
* without waiting a fortnight (`invites.test.ts`). Declaring what the code
|
|
66
|
+
* accepts is the job here — a schema written to what it *ought* to accept
|
|
67
|
+
* would have failed a suite that has always passed.
|
|
68
|
+
*/
|
|
69
|
+
ttlMs: z.number().int().optional(),
|
|
70
|
+
}),
|
|
71
|
+
// The id and nothing else — the sender never learns whether the recipient
|
|
72
|
+
// already exists, is already a member, or declined before. That silence is
|
|
73
|
+
// what keeps the surface non-enumerable, so it is in the declared output too.
|
|
74
|
+
output: z.object({ id: z.string() }),
|
|
75
|
+
},
|
|
76
|
+
'invites/accept': {
|
|
77
|
+
narrows: {
|
|
78
|
+
reason: 'The recipient holds nothing yet — they are not a member of anything, so there is no ' +
|
|
79
|
+
'grant a check could resolve. The invitation IS the authority, proven by re-hashing ' +
|
|
80
|
+
'the identifier presented. Stated here so an ungated operation cannot pass for an ' +
|
|
81
|
+
'oversight.',
|
|
82
|
+
checks: [],
|
|
83
|
+
// Nothing is checked here OR in a composed module — which an empty `checks`
|
|
84
|
+
// alone cannot say, since that is also how a walk over an engine's own key
|
|
85
|
+
// reads. The receipt counts this row separately because of this flag.
|
|
86
|
+
unchecked: true,
|
|
87
|
+
},
|
|
88
|
+
summary: 'Accept an invitation by presenting the identifier it was sent to',
|
|
89
|
+
input: invitationId.extend({ identifier: z.string().min(1) }),
|
|
90
|
+
output: invitation,
|
|
91
|
+
},
|
|
92
|
+
'invites/list': {
|
|
93
|
+
summary: 'Invitations for an organization, with state',
|
|
94
|
+
permission: 'invites:read',
|
|
95
|
+
input: z.object({ orgId: z.string().min(1) }),
|
|
96
|
+
// The published projection, never `invitationRow`: returning the row would
|
|
97
|
+
// publish the identifier hash, which is the one thing hashing exists to keep
|
|
98
|
+
// unreadable.
|
|
99
|
+
output: invitation,
|
|
100
|
+
},
|
|
101
|
+
'invites/revoke': {
|
|
102
|
+
summary: 'Withdraw an invitation before it is accepted',
|
|
103
|
+
permission: 'invites:revoke',
|
|
104
|
+
input: invitationId,
|
|
105
|
+
// Nothing comes back, and the silence is the contract: revoking is
|
|
106
|
+
// idempotent, so an already-settled invitation and a live one answer the
|
|
107
|
+
// same way. Returning the row would let a caller tell them apart.
|
|
108
|
+
output: z.void(),
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,cAAc,EAAE,gBAAgB,CAAU,CAAC;AAE/F,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;IACtF,cAAc,EAAE;QACd,OAAO,EAAE,mCAAmC;QAC5C,UAAU,EAAE,cAAc;QAC1B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;YACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,wEAAwE;YACxE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GA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",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Substrat engine: invitations — invite by verified hashed identifier, accept-required, non-enumerable",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@substrat-run/
|
|
29
|
-
"@substrat-run/
|
|
28
|
+
"@substrat-run/contracts": "^0.91.0",
|
|
29
|
+
"@substrat-run/kernel": "^0.91.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^7.0.0",
|
|
33
33
|
"vitest": "^3.2.7",
|
|
34
34
|
"zod": "^4.4.3",
|
|
35
|
-
"@substrat-run/contract-tests": "^0.
|
|
36
|
-
"@substrat-run/
|
|
37
|
-
"@substrat-run/
|
|
35
|
+
"@substrat-run/contract-tests": "^0.91.0",
|
|
36
|
+
"@substrat-run/model-emit": "0.8.4",
|
|
37
|
+
"@substrat-run/engine-test-kit": "^0.3.18"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"zod": "^4.4.0"
|