@mosetta/services 0.0.9 → 0.0.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosetta/services",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "license": "MIT",
5
5
  "description": "Portable Mosetta cross-site services protocol: installation handshake, sealed connections, action forwarding, grant filtering, and SQL-guarded service IO.",
6
6
  "type": "module",
@@ -12,15 +12,15 @@
12
12
  "./protocol": "./src/protocolEntry.ts"
13
13
  },
14
14
  "dependencies": {
15
- "@mosetta/auth-service": "0.0.9",
16
- "@mosetta/core": "0.0.44",
17
- "@mosetta/content": "0.0.44",
18
- "@mosetta/host-platform": "0.0.9",
19
- "@mosetta/identity": "0.0.44",
20
- "@mosetta/media": "0.0.9",
21
- "@mosetta/server-action": "0.0.44",
22
- "@mosetta/server": "0.0.44",
23
- "@mosetta/tenancy": "0.0.44"
15
+ "@mosetta/auth-service": "0.0.10",
16
+ "@mosetta/content": "0.0.45",
17
+ "@mosetta/host-platform": "0.0.10",
18
+ "@mosetta/core": "0.0.45",
19
+ "@mosetta/identity": "0.0.45",
20
+ "@mosetta/media": "0.0.10",
21
+ "@mosetta/server": "0.0.45",
22
+ "@mosetta/tenancy": "0.0.45",
23
+ "@mosetta/server-action": "0.0.45"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
@@ -0,0 +1,71 @@
1
+ // Pure-JS synchronous SHA-256 and collision-free secret key suffix derivation for npm package brands.
2
+ const K = [
3
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
4
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
5
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
6
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
7
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
8
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
9
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
10
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
11
+ ];
12
+ const H0 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
13
+ const BASE32 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
14
+ const SIMPLE_BRAND_RE = /^[a-z0-9-]{1,53}$/;
15
+ const encoder = new TextEncoder();
16
+ const rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));
17
+
18
+ function sha256(input: Uint8Array): Uint8Array {
19
+ const paddedLen = Math.ceil((input.length + 9) / 64) * 64;
20
+ const padded = new Uint8Array(paddedLen);
21
+ padded.set(input);
22
+ padded[input.length] = 0x80;
23
+ const view = new DataView(padded.buffer);
24
+ view.setUint32(paddedLen - 8, Math.floor(input.length / 0x20000000), false);
25
+ view.setUint32(paddedLen - 4, (input.length * 8) >>> 0, false);
26
+ const h = [...H0];
27
+ const w = new Int32Array(64);
28
+ for (let offset = 0; offset < paddedLen; offset += 64) {
29
+ for (let i = 0; i < 16; i += 1) w[i] = view.getInt32(offset + i * 4, false);
30
+ for (let i = 16; i < 64; i += 1) {
31
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
32
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
33
+ w[i] = (w[i - 16] + s0 + w[i - 7] + s1) | 0;
34
+ }
35
+ let [a, b, c, d, e, f, g, hh] = h;
36
+ for (let i = 0; i < 64; i += 1) {
37
+ const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
38
+ const ch = (e & f) ^ (~e & g);
39
+ const t1 = (hh + S1 + ch + K[i] + w[i]) | 0;
40
+ const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
41
+ const maj = (a & b) ^ (a & c) ^ (b & c);
42
+ const t2 = (S0 + maj) | 0;
43
+ hh = g; g = f; f = e; e = (d + t1) | 0; d = c; c = b; b = a; a = (t1 + t2) | 0;
44
+ }
45
+ const next = [a, b, c, d, e, f, g, hh];
46
+ for (let i = 0; i < 8; i += 1) h[i] = (h[i] + next[i]) | 0;
47
+ }
48
+ const out = new Uint8Array(32);
49
+ const outView = new DataView(out.buffer);
50
+ for (let i = 0; i < 8; i += 1) outView.setUint32(i * 4, h[i] >>> 0, false);
51
+ return out;
52
+ }
53
+
54
+ function base32Of20(bytes: Uint8Array): string {
55
+ let out = '';
56
+ for (let i = 0; i < 20; i += 5) {
57
+ const [b0, b1, b2, b3, b4] = [bytes[i], bytes[i + 1], bytes[i + 2], bytes[i + 3], bytes[i + 4]];
58
+ out += BASE32[b0 >> 3] + BASE32[((b0 & 7) << 2) | (b1 >> 6)] + BASE32[(b1 >> 1) & 31]
59
+ + BASE32[((b1 & 1) << 4) | (b2 >> 4)] + BASE32[((b2 & 15) << 1) | (b3 >> 7)]
60
+ + BASE32[(b3 >> 2) & 31] + BASE32[((b3 & 3) << 3) | (b4 >> 5)] + BASE32[b4 & 31];
61
+ }
62
+ return out;
63
+ }
64
+
65
+ /** Collision-free uppercase secret key suffix (`<= 53` chars) for any valid npm package brand. */
66
+ export function brandSecretSuffix(brand: string): string {
67
+ if (SIMPLE_BRAND_RE.test(brand)) return brand.replace(/-/g, '_').toUpperCase();
68
+ const slug = brand.replace(/^@/, '').replace(/[^a-z0-9]+/gi, '_').replace(/^_+|_+$/g, '').toUpperCase().slice(0, 18);
69
+ const hash = base32Of20(sha256(encoder.encode(brand)));
70
+ return slug ? `_${slug}_${hash}` : `_${hash}`;
71
+ }
@@ -1,5 +1,8 @@
1
+ import { isValidPackageName, parseTileId } from '@mosetta/core/naming';
2
+ import { compareVersions } from '@mosetta/content/versions';
1
3
  import { workbenchRolesOf } from '@mosetta/content/workbench';
2
4
  import type { IServiceConnection } from '@mosetta/host-platform/host';
5
+ import { brandSecretSuffix } from './brandSecretKey';
3
6
  import { GRANT_MAX } from './protocolTypes';
4
7
  import type {
5
8
  IInstallation,
@@ -10,17 +13,35 @@ import type {
10
13
  } from './protocolTypes';
11
14
 
12
15
  const ORIGIN_RE = /^https?:\/\/[a-z0-9.-]+(:\d{1,5})?$/;
13
- const BRAND_RE = /^[a-z][a-z0-9-]{0,54}$/;
14
16
  const VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]{1,40})?$/;
15
- const GRANT_RE = /^(?:@(?:previews|media|code|repositories)|[a-z][a-z0-9-]{0,62}(?:\/[a-z][A-Za-z0-9]{0,63})?)$/;
16
- const ACTION_RE = /^\/api\/server-action\/(_ns_([a-z0-9-]+)_t_server_n_([A-Za-z0-9]+)_v_[A-Za-z0-9_]+)\/([A-Za-z0-9_]+)$/;
17
- const MODULE_RE = /^_ns_([a-z0-9-]+)_t_server_n_([A-Za-z0-9]+)_v_/;
17
+ const SYSTEM_GRANTS = new Set(['@previews', '@media', '@code', '@repositories']);
18
+ const TILE_GRANT_RE = /^[a-zA-Z0-9][A-Za-z0-9_.-]*(?:\/[a-zA-Z0-9][A-Za-z0-9_.-]*)*$/;
19
+ const ACTION_NAME_RE = /^[A-Za-z0-9_]+$/;
20
+ const SERVER_ACTION_PREFIX = '/api/server-action/';
18
21
  const KEY_ID_RE = /^msi_(ins_[a-f0-9]{32})\.[A-Za-z0-9_-]{32,}$/;
19
22
  const BEARER_KEY_RE = /^Bearer\s+(msi_\S+)$/i;
20
23
 
21
24
  export const CONNECTION_SECRET_PREFIX = 'SERVICE_';
22
25
  export const DECLINED_SECRET_PREFIX = 'NO_SERVICE_';
23
26
 
27
+ function isValidGrantEntry(entry: string): boolean {
28
+ if (SYSTEM_GRANTS.has(entry)) return true;
29
+ if (entry.startsWith('@')) {
30
+ const first = entry.indexOf('/');
31
+ if (first < 0 || SYSTEM_GRANTS.has(entry.slice(0, first))) return false;
32
+ const second = entry.indexOf('/', first + 1);
33
+ if (second < 0) return isValidPackageName(entry);
34
+ const pkg = entry.slice(0, second);
35
+ const tile = entry.slice(second + 1);
36
+ return isValidPackageName(pkg) && TILE_GRANT_RE.test(tile) && tile.split('/').every((s) => s !== '.' && s !== '..');
37
+ }
38
+ const slash = entry.indexOf('/');
39
+ if (slash < 0) return isValidPackageName(entry);
40
+ const pkg = entry.slice(0, slash);
41
+ const tile = entry.slice(slash + 1);
42
+ return isValidPackageName(pkg) && TILE_GRANT_RE.test(tile) && tile.split('/').every((s) => s !== '.' && s !== '..');
43
+ }
44
+
24
45
  function toHex(bytes: ArrayBuffer): string {
25
46
  return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
26
47
  }
@@ -51,10 +72,16 @@ export class ServiceProtocolCodec {
51
72
  }
52
73
 
53
74
  static actionOfPath(pathname: string): IServiceActionAddress | null {
54
- const match = ACTION_RE.exec(pathname);
55
- return match
56
- ? { fullId: match[1], brand: match[2], tile: match[3], action: match[4] }
57
- : null;
75
+ if (!pathname.startsWith(SERVER_ACTION_PREFIX)) return null;
76
+ const rest = pathname.slice(SERVER_ACTION_PREFIX.length);
77
+ const slash = rest.lastIndexOf('/');
78
+ if (slash <= 0) return null;
79
+ const fullId = rest.slice(0, slash);
80
+ const action = rest.slice(slash + 1);
81
+ if (!ACTION_NAME_RE.test(action)) return null;
82
+ const parsed = parseTileId(fullId);
83
+ if (!parsed || parsed.facet !== 'server' || parsed.version === 'live') return null;
84
+ return { fullId, brand: parsed.pkg, tile: parsed.tile, action };
58
85
  }
59
86
 
60
87
  static grantAllows(grant: readonly string[], brand: string, tile: string): boolean {
@@ -65,7 +92,7 @@ export class ServiceProtocolCodec {
65
92
  if (
66
93
  !Array.isArray(value)
67
94
  || value.length > GRANT_MAX
68
- || !value.every((entry): entry is string => typeof entry === 'string' && GRANT_RE.test(entry))
95
+ || !value.every((entry): entry is string => typeof entry === 'string' && isValidGrantEntry(entry))
69
96
  ) {
70
97
  return null;
71
98
  }
@@ -77,7 +104,7 @@ export class ServiceProtocolCodec {
77
104
  }
78
105
 
79
106
  static isValidBrand(value: unknown): value is string {
80
- return typeof value === 'string' && BRAND_RE.test(value);
107
+ return typeof value === 'string' && isValidPackageName(value);
81
108
  }
82
109
 
83
110
  static isValidVersion(value: unknown): value is string {
@@ -158,13 +185,7 @@ export class ServiceProtocolCodec {
158
185
  }
159
186
 
160
187
  static olderThan(a: string, b: string): boolean {
161
- const [left, right] = [a, b].map((ver) => ver.split(/[-+]/)[0].split('.').map(Number));
162
- for (let index = 0; index < 3; index += 1) {
163
- if ((left[index] ?? 0) !== (right[index] ?? 0)) {
164
- return (left[index] ?? 0) < (right[index] ?? 0);
165
- }
166
- }
167
- return false;
188
+ return compareVersions(a, b) < 0;
168
189
  }
169
190
 
170
191
  static proofAudience(hostname: string): string {
@@ -217,19 +238,21 @@ export class ServiceProtocolCodec {
217
238
  }
218
239
 
219
240
  static brandSecretName(brand: string): string {
220
- return `${CONNECTION_SECRET_PREFIX}${brand.toUpperCase().replace(/-/g, '_')}`;
241
+ return `${CONNECTION_SECRET_PREFIX}${brandSecretSuffix(brand)}`;
221
242
  }
222
243
 
223
244
  static declinedSecretName(brand: string): string {
224
- return `${DECLINED_SECRET_PREFIX}${brand.toUpperCase().replace(/-/g, '_')}`;
245
+ return `${DECLINED_SECRET_PREFIX}${brandSecretSuffix(brand)}`;
225
246
  }
226
247
 
227
248
  static async grantedListing(response: Response, grant: readonly string[]): Promise<Response> {
228
249
  if (!response.ok) return response;
229
250
  const listed = await response.json().catch(() => null) as { modules?: { module?: unknown }[] } | null;
230
251
  const modules = (listed?.modules ?? []).filter((entry) => {
231
- const match = typeof entry.module === 'string' ? MODULE_RE.exec(entry.module) : null;
232
- return match ? ServiceProtocolCodec.grantAllows(grant, match[1], match[2]) : false;
252
+ const parsed = typeof entry.module === 'string' ? parseTileId(entry.module) : null;
253
+ return parsed && parsed.facet === 'server'
254
+ ? ServiceProtocolCodec.grantAllows(grant, parsed.pkg, parsed.tile)
255
+ : false;
233
256
  });
234
257
  return ServiceProtocolCodec.jsonResponse(200, { ...listed, modules });
235
258
  }
@@ -1,3 +1,4 @@
1
+ import { isValidPackageName } from '@mosetta/core/naming';
1
2
  import { CONTENT_COMMAND_PATH, PROJECT_MEMORY_PATH } from '@mosetta/content';
2
3
  import { IdentityError } from '@mosetta/identity';
3
4
  import type { IIdentityRequestCaller } from '@mosetta/identity';
@@ -28,9 +29,26 @@ interface IFreshService {
28
29
  readonly grants: readonly (readonly string[])[];
29
30
  }
30
31
 
31
- const BRAND_RE = /^[a-z][a-z0-9-]{0,54}$/;
32
32
  const VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]{1,40})?$/;
33
- const PALETTE_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
33
+ const SOURCE_OPS = new Set(['sources', 'check', 'draft', 'release']);
34
+ const BUILT_OPS = new Set(['plan', 'push', 'draft', 'drafts']);
35
+
36
+ function tailAfterPalette(pathname: string, kind: string, palette: string): string | null {
37
+ for (const seg of [palette, encodeURIComponent(palette)]) {
38
+ const prefix = `${kind}${seg}/`;
39
+ if (pathname.startsWith(prefix)) return pathname.slice(prefix.length);
40
+ }
41
+ return null;
42
+ }
43
+
44
+ function codeCallbackOperation(pathname: string, palette: string, method: string): 'code.edit' | 'code.release' | null {
45
+ const srcOp = tailAfterPalette(pathname, '/v1/palettes/', palette);
46
+ if (srcOp && SOURCE_OPS.has(srcOp)) return method === (srcOp === 'sources' ? 'GET' : 'POST') ? (srcOp === 'release' ? 'code.release' : 'code.edit') : null;
47
+ if (method !== 'POST') return null;
48
+ const builtOp = tailAfterPalette(pathname, '/v1/code/palettes/', palette);
49
+ if (builtOp && BUILT_OPS.has(builtOp)) return builtOp === 'plan' || builtOp === 'push' ? 'code.release' : 'code.edit';
50
+ return pathname === `/v1/builds/palettes/${palette}` || pathname === `/v1/builds/palettes/${encodeURIComponent(palette)}` ? 'code.edit' : null;
51
+ }
34
52
  const PERSONAL_MEMORY_ACTIONS = new Set([
35
53
  'listConversations',
36
54
  'readConversation',
@@ -46,7 +64,7 @@ function validatePlan(plan: IServiceInvocationPlan): IServiceInvocationPlan {
46
64
  if (
47
65
  !ProjectAllowances.isId(plan.consumerProjectId)
48
66
  || !ProjectAllowances.isId(plan.installation)
49
- || !BRAND_RE.test(plan.brand)
67
+ || !isValidPackageName(plan.brand)
50
68
  || !VERSION_RE.test(plan.version)
51
69
  || !grant
52
70
  || (plan.block !== null && (typeof plan.block !== 'string' || plan.block.length > SERVICE_BLOCK_MAX))
@@ -124,7 +142,7 @@ export class PublisherServiceInvocation {
124
142
  if (!fresh.grants.every((grant) => grant.includes(CODE_GRANT)) || !this.ports.code) return null;
125
143
  const code = await this.ports.code();
126
144
  if (!code) return null;
127
- if (code.projectId !== this.plan.consumerProjectId || !PALETTE_RE.test(code.palette)) {
145
+ if (code.projectId !== this.plan.consumerProjectId || !isValidPackageName(code.palette)) {
128
146
  throw new IdentityError('FORBIDDEN');
129
147
  }
130
148
  assertValidServiceOrigin(code.api);
@@ -184,16 +202,8 @@ export class PublisherServiceInvocation {
184
202
  private authorizeCodeCallback(request: Request, url: URL, context: { readonly fresh: IFreshService; readonly code: ISiteCode }): void {
185
203
  const { fresh, code } = context;
186
204
  if (!fresh.grants.every((set) => set.includes(CODE_GRANT))) throw new IdentityError('FORBIDDEN');
187
- const source = new RegExp(`^/v1/palettes/${code.palette}/(sources|check|draft|release)$`).exec(url.pathname);
188
- const built = new RegExp(`^/v1/code/palettes/${code.palette}/(plan|push|draft|drafts)$`).exec(url.pathname);
189
- const build = url.pathname === `/v1/builds/palettes/${code.palette}`;
190
- const readSources = source?.[1] === 'sources' && request.method === 'GET';
191
- if ((!source && !built && !build) || (!readSources && request.method !== 'POST')) {
192
- throw new IdentityError('FORBIDDEN');
193
- }
194
- const operation = source?.[1] === 'release' || (built && ['plan', 'push'].includes(built[1]))
195
- ? 'code.release'
196
- : 'code.edit';
205
+ const operation = codeCallbackOperation(url.pathname, code.palette, request.method);
206
+ if (!operation) throw new IdentityError('FORBIDDEN');
197
207
  const policy = new AccessPolicy(fresh.caller.current.projectId, fresh.caller.current.scopeIds);
198
208
  if (!policy.can(fresh.caller.current, operation, '*')) throw new IdentityError('FORBIDDEN');
199
209
  }
@@ -227,7 +237,7 @@ export class PublisherServiceInvocation {
227
237
  if (url.pathname === '/__mosetta__/project') {
228
238
  return send.fetch(stripServiceRequestHeaders(request));
229
239
  }
230
- if (url.pathname === '/__mosetta__/scopes' && fresh.grants.every((grant) => ServiceProtocolCodec.grantAllows(grant, 'mosetta-editor', 'content'))) {
240
+ if (url.pathname === '/__mosetta__/scopes' && fresh.grants.every((grant) => ServiceProtocolCodec.grantAllows(grant, '@mosetta/editor', 'content'))) {
231
241
  return send.fetch(stripServiceRequestHeaders(request));
232
242
  }
233
243
  if (url.pathname === '/api/server-action/') {
@@ -242,7 +252,7 @@ export class PublisherServiceInvocation {
242
252
  const { fresh, send } = context;
243
253
  if (url.pathname === PROJECT_MEMORY_PATH || url.pathname === CONTENT_COMMAND_PATH) {
244
254
  const tile = url.pathname === PROJECT_MEMORY_PATH ? 'memory' : 'content';
245
- const allowed = fresh.grants.every((grant) => ServiceProtocolCodec.grantAllows(grant, 'mosetta-editor', tile));
255
+ const allowed = fresh.grants.every((grant) => ServiceProtocolCodec.grantAllows(grant, '@mosetta/editor', tile));
246
256
  if (request.method !== 'POST' || !this.ports.contentAllowed?.() || !allowed) {
247
257
  throw new IdentityError('FORBIDDEN');
248
258
  }
@@ -1,3 +1,10 @@
1
+ // Architectural invariants for consumer-to-publisher service invocation:
2
+ // - Service palette calls ALWAYS proxy through the consumer host (browser never calls publisher
3
+ // directly -> no CORS required, and the connection key never leaves the consumer host).
4
+ // - Outgoing requests strip `authorization`, `cookie`, and all reserved internal headers via
5
+ // `stripServiceRequestHeaders()`; the consumer host mints a short-lived human delegation on the
6
+ // private dispatch transport instead of forwarding raw credentials.
7
+ // - Action handler code remains identical across local code mode and remote service mode.
1
8
  import { IdentityError } from '@mosetta/identity';
2
9
  import { ProjectAllowances, PROJECT_ACCESS_HEADER } from '@mosetta/server-action/access';
3
10
  import {
@@ -5,7 +5,7 @@ import { IdentityError, IdentitySecrets, ProjectCataloguePolicy } from '@mosetta
5
5
  import type { ProjectSecrets } from '@mosetta/server/secrets';
6
6
  import { SqlProjectIo } from '@mosetta/tenancy';
7
7
  import type { IProjectIoOperation, IProjectIoTarget, IProjectRecord, ISqlDatabase } from '@mosetta/tenancy';
8
- import { SealedServiceConnections } from './protocol';
8
+ import { SealedServiceConnections, ServiceProtocolCodec } from './protocol';
9
9
  import type {
10
10
  IDefaultService,
11
11
  IServiceConnections,
@@ -116,7 +116,7 @@ export function serviceManagementOf(identity: IHostInvocationIdentity, config: I
116
116
  };
117
117
  const executor = new SqlProjectIo(config.database, () => authority.read(target));
118
118
  const handle = await executor.open(operation);
119
- const defaults = wanted ? new Set([`SERVICE_${wanted.brand.toUpperCase().replace(/-/g, '_')}`]) : undefined;
119
+ const defaults = wanted ? new Set([ServiceProtocolCodec.brandSecretName(wanted.brand)]) : undefined;
120
120
  const secrets = config.secrets.withStore(
121
121
  (store) => new GuardedServiceSecrets({
122
122
  db: config.database,
@@ -3,7 +3,7 @@ import { HOST_HELD_SCOPE } from '@mosetta/server/secrets';
3
3
  import type { ISecretEntry, ISecretsStore } from '@mosetta/server/secrets';
4
4
  import type { IProjectIoOperation, ISqlDatabase, SqlProjectIo } from '@mosetta/tenancy';
5
5
 
6
- const SERVICE_SECRET_NAME_RE = /^(?:SERVICE_|NO_SERVICE_)[A-Z0-9_]{1,54}$/;
6
+ const SERVICE_SECRET_NAME_RE = /^(?:SERVICE_[A-Z0-9_]{1,54}|NO_SERVICE_[A-Z0-9_]{1,53})$/;
7
7
  const SEALED_VALUE_RE = /^v1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
8
8
 
9
9
  /** Configuration for `GuardedServiceSecrets`. */
package/src/services.ts CHANGED
@@ -1,3 +1,10 @@
1
+ // Architectural invariants for @mosetta/services:
2
+ // - All service palette calls MUST route through the consumer host (never browser direct to
3
+ // publisher): avoids cross-origin CORS exposure and guarantees the connection key never leaves
4
+ // the consumer host.
5
+ // - Consumer host strips incoming credentials/internal headers and mints a short-lived delegation
6
+ // bound to the calling human before dispatching to the publisher over private transport.
7
+ // - Tile server-action code stays 100% identical between code mode and service mode.
1
8
  export * from './protocolEntry';
2
9
  export * from './serviceCompositionIo';
3
10
  export * from './serviceInstallationsIo';