@coffre/core 0.1.10 → 0.1.12

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/access.d.ts CHANGED
@@ -85,16 +85,6 @@ export type Holdings = {
85
85
  * `market/prod` does not let anyone rename `market`.
86
86
  */
87
87
  export declare function allows(holder: Holdings, permission: Permission, place: Place): boolean;
88
- /** A sync reads as a principal of its own, `sync:<id>`. */
89
- export declare function isSyncPrincipal(principal: string): boolean;
90
- /**
91
- * Whether `actor` may set `subject`'s role at `place`, or take it away
92
- * (`role` null). `grant.manage` on the project decides, with one addition:
93
- * whoever may manage a project's environments may let a sync read an
94
- * environment they can read themselves, and take that away again, since
95
- * adding and removing syncs is theirs to do.
96
- */
97
- export declare function mayManageAccess(actor: Holdings, subject: string, change: Place & {
98
- role: Role | null;
99
- }): boolean;
88
+ /** Whether the actor may manage grants on this project. */
89
+ export declare function mayManageAccess(actor: Holdings, place: Place): boolean;
100
90
  //#endregion
package/dist/access.js CHANGED
@@ -88,22 +88,9 @@ function allows(holder, permission, place) {
88
88
  if (environmentId === null && holder.isOwner && PROJECT_ONLY_PERMISSIONS.includes(permission)) return true;
89
89
  return holder.grants.some((grant) => grant.projectId === place.projectId && (grant.environmentId === null || grant.environmentId === environmentId) && roleGrants(grant.role, permission));
90
90
  }
91
- /** A sync reads as a principal of its own, `sync:<id>`. */
92
- function isSyncPrincipal(principal) {
93
- return principal.startsWith("sync:");
94
- }
95
- /**
96
- * Whether `actor` may set `subject`'s role at `place`, or take it away
97
- * (`role` null). `grant.manage` on the project decides, with one addition:
98
- * whoever may manage a project's environments may let a sync read an
99
- * environment they can read themselves, and take that away again, since
100
- * adding and removing syncs is theirs to do.
101
- */
102
- function mayManageAccess(actor, subject, change) {
103
- if (allows(actor, "grant.manage", { projectId: change.projectId })) return true;
104
- if (!isSyncPrincipal(subject) || !allows(actor, "environment.manage", { projectId: change.projectId })) return false;
105
- if (change.role === null) return true;
106
- return change.role === "viewer" && (change.environmentId ?? null) !== null && allows(actor, "secret.read", change);
91
+ /** Whether the actor may manage grants on this project. */
92
+ function mayManageAccess(actor, place) {
93
+ return allows(actor, "grant.manage", { projectId: place.projectId });
107
94
  }
108
95
  //#endregion
109
- export { PERMISSIONS, PROJECT_ONLY_PERMISSIONS, ROLES, ROLE_NAMES, allows, assignableToEnvironment, isRole, isSyncPrincipal, mayManageAccess, roleGrants };
96
+ export { PERMISSIONS, PROJECT_ONLY_PERMISSIONS, ROLES, ROLE_NAMES, allows, assignableToEnvironment, isRole, mayManageAccess, roleGrants };
package/dist/schemas.d.ts CHANGED
@@ -14,5 +14,4 @@ export declare const instanceRole: z.ZodEnum<{
14
14
  }>;
15
15
  export declare const grantId: z.ZodString;
16
16
  export declare const emailAddress: z.ZodString;
17
- export declare const syncId: z.ZodString;
18
17
  //#endregion
package/dist/schemas.js CHANGED
@@ -8,6 +8,5 @@ const principalId = z.string().trim().min(1).max(320);
8
8
  const instanceRole = z.enum(["user", "owner"]);
9
9
  const grantId = z.string().uuid();
10
10
  const emailAddress = z.string().email().max(320);
11
- const syncId = z.string().uuid();
12
11
  //#endregion
13
- export { displayName, emailAddress, grantId, instanceRole, principalId, principalType, secretKey, slug, syncId };
12
+ export { displayName, emailAddress, grantId, instanceRole, principalId, principalType, secretKey, slug };
package/dist/vault.d.ts CHANGED
@@ -256,7 +256,7 @@ export type KeyChecks = {
256
256
  })[];
257
257
  };
258
258
  /** Why someone reads: shown in the log, and the same rules apply to each. */
259
- export type Purpose = 'reveal' | 'run' | 'compare' | 'sync';
259
+ export type Purpose = 'reveal' | 'run' | 'compare';
260
260
  /** Ties the vault's entries to the app's request and audit rows. */
261
261
  type Correlation = {
262
262
  requestId?: string | null;
@@ -340,15 +340,6 @@ export type AdmitInput = Correlation & {
340
340
  export type RemoveInput = Correlation & {
341
341
  actor: string;
342
342
  principal: string;
343
- /**
344
- * For a sync: the environment it pushes from. Whoever may manage it there
345
- * may stop the sync, also once its grant there is revoked and only the
346
- * one on its credential is left.
347
- */
348
- source?: {
349
- projectId: string;
350
- environmentId: string;
351
- };
352
343
  };
353
344
  /**
354
345
  * A prefix of the log the vault signed: every entry up to `seq`, the last
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/core",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "What coffre's packages share: roles, envelopes, identity, the audit chain and the vault's contract.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -69,7 +69,7 @@
69
69
  "@types/node": "26.1.1",
70
70
  "tsdown": "0.23.0",
71
71
  "typescript": "5.9.3",
72
- "@coffre/conformance": "0.1.10"
72
+ "@coffre/conformance": "0.1.12"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown",
package/src/access.ts CHANGED
@@ -126,27 +126,7 @@ export function allows(holder: Holdings, permission: Permission, place: Place):
126
126
  );
127
127
  }
128
128
 
129
- /** A sync reads as a principal of its own, `sync:<id>`. */
130
- export function isSyncPrincipal(principal: string): boolean {
131
- return principal.startsWith('sync:');
132
- }
133
-
134
- /**
135
- * Whether `actor` may set `subject`'s role at `place`, or take it away
136
- * (`role` null). `grant.manage` on the project decides, with one addition:
137
- * whoever may manage a project's environments may let a sync read an
138
- * environment they can read themselves, and take that away again, since
139
- * adding and removing syncs is theirs to do.
140
- */
141
- export function mayManageAccess(
142
- actor: Holdings,
143
- subject: string,
144
- change: Place & { role: Role | null },
145
- ): boolean {
146
- if (allows(actor, 'grant.manage', { projectId: change.projectId })) return true;
147
- if (!isSyncPrincipal(subject) || !allows(actor, 'environment.manage', { projectId: change.projectId })) {
148
- return false;
149
- }
150
- if (change.role === null) return true;
151
- return change.role === 'viewer' && (change.environmentId ?? null) !== null && allows(actor, 'secret.read', change);
129
+ /** Whether the actor may manage grants on this project. */
130
+ export function mayManageAccess(actor: Holdings, place: Place): boolean {
131
+ return allows(actor, 'grant.manage', { projectId: place.projectId });
152
132
  }
package/src/schemas.ts CHANGED
@@ -8,4 +8,3 @@ export const principalId = z.string().trim().min(1).max(320);
8
8
  export const instanceRole = z.enum(['user', 'owner']);
9
9
  export const grantId = z.string().uuid();
10
10
  export const emailAddress = z.string().email().max(320);
11
- export const syncId = z.string().uuid();
package/src/vault.ts CHANGED
@@ -158,7 +158,7 @@ export type WrappedKey = { kekProvider: string; kekId: string; kekVersion: strin
158
158
  export type KeyChecks = { current: { kekProvider: string; kekId: string }; checks: (WrappedKey & { seq: number })[] };
159
159
 
160
160
  /** Why someone reads: shown in the log, and the same rules apply to each. */
161
- export type Purpose = 'reveal' | 'run' | 'compare' | 'sync';
161
+ export type Purpose = 'reveal' | 'run' | 'compare';
162
162
 
163
163
  /** Ties the vault's entries to the app's request and audit rows. */
164
164
  type Correlation = {
@@ -245,12 +245,7 @@ export type AdmitInput = Correlation & {
245
245
  export type RemoveInput = Correlation & {
246
246
  actor: string;
247
247
  principal: string;
248
- /**
249
- * For a sync: the environment it pushes from. Whoever may manage it there
250
- * may stop the sync, also once its grant there is revoked and only the
251
- * one on its credential is left.
252
- */
253
- source?: { projectId: string; environmentId: string };
248
+
254
249
  };
255
250
 
256
251
  /**