@mosetta/services 0.0.0-stage → 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/LICENSE +21 -0
- package/package.json +33 -3
- package/src/brandSecretKey.ts +71 -0
- package/src/errors.ts +59 -0
- package/src/platformServices.ts +221 -0
- package/src/protocol.ts +11 -0
- package/src/protocolCodec.ts +259 -0
- package/src/protocolEntry.ts +4 -0
- package/src/protocolTypes.ts +170 -0
- package/src/publisherServiceInvocation.ts +296 -0
- package/src/serviceCompositionIo.ts +109 -0
- package/src/serviceConnectionClient.ts +184 -0
- package/src/serviceDefaultsCoordinator.ts +184 -0
- package/src/serviceHandshakeController.ts +257 -0
- package/src/serviceHost.ts +234 -0
- package/src/serviceHostCall.ts +239 -0
- package/src/serviceInstallationsIo.ts +126 -0
- package/src/serviceInvocation.ts +176 -0
- package/src/serviceManagementController.ts +203 -0
- package/src/serviceManagementIo.ts +166 -0
- package/src/serviceProxyClient.ts +71 -0
- package/src/serviceSecretsIo.ts +138 -0
- package/src/serviceStores.ts +214 -0
- package/src/serviceTechnicalIo.ts +272 -0
- package/src/services.ts +15 -0
- package/README.md +0 -3
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { isValidPackageName, parseTileId } from '@mosetta/core/naming';
|
|
2
|
+
import { compareVersions } from '@mosetta/content/versions';
|
|
3
|
+
import { workbenchRolesOf } from '@mosetta/content/workbench';
|
|
4
|
+
import type { IServiceConnection } from '@mosetta/host-platform/host';
|
|
5
|
+
import { brandSecretSuffix } from './brandSecretKey';
|
|
6
|
+
import { GRANT_MAX } from './protocolTypes';
|
|
7
|
+
import type {
|
|
8
|
+
IInstallation,
|
|
9
|
+
IServiceActionAddress,
|
|
10
|
+
IServiceAsked,
|
|
11
|
+
IServiceOffer,
|
|
12
|
+
IServicePerson,
|
|
13
|
+
} from './protocolTypes';
|
|
14
|
+
|
|
15
|
+
const ORIGIN_RE = /^https?:\/\/[a-z0-9.-]+(:\d{1,5})?$/;
|
|
16
|
+
const VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]{1,40})?$/;
|
|
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/';
|
|
21
|
+
const KEY_ID_RE = /^msi_(ins_[a-f0-9]{32})\.[A-Za-z0-9_-]{32,}$/;
|
|
22
|
+
const BEARER_KEY_RE = /^Bearer\s+(msi_\S+)$/i;
|
|
23
|
+
|
|
24
|
+
export const CONNECTION_SECRET_PREFIX = 'SERVICE_';
|
|
25
|
+
export const DECLINED_SECRET_PREFIX = 'NO_SERVICE_';
|
|
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
|
+
|
|
45
|
+
function toHex(bytes: ArrayBuffer): string {
|
|
46
|
+
return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Pure encoding, parsing, validation, and cryptographic helpers for the
|
|
51
|
+
* cross-site services protocol.
|
|
52
|
+
*/
|
|
53
|
+
export class ServiceProtocolCodec {
|
|
54
|
+
private static parseOfferEntry(service: Record<string, unknown>): IServiceOffer | null {
|
|
55
|
+
const grant = ServiceProtocolCodec.grantOf(service.grant);
|
|
56
|
+
if (
|
|
57
|
+
!ServiceProtocolCodec.isValidBrand(service.brand)
|
|
58
|
+
|| !ServiceProtocolCodec.isValidVersion(service.version)
|
|
59
|
+
|| !grant
|
|
60
|
+
) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const roles = workbenchRolesOf(service.workbench);
|
|
64
|
+
return {
|
|
65
|
+
brand: service.brand,
|
|
66
|
+
version: service.version,
|
|
67
|
+
title: typeof service.title === 'string' ? service.title.slice(0, 200) : service.brand,
|
|
68
|
+
...(typeof service.description === 'string' ? { description: service.description.slice(0, 2000) } : {}),
|
|
69
|
+
grant,
|
|
70
|
+
...(roles ? { workbench: roles } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static actionOfPath(pathname: string): IServiceActionAddress | 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 };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static grantAllows(grant: readonly string[], brand: string, tile: string): boolean {
|
|
88
|
+
return grant.includes(brand) || grant.includes(`${brand}/${tile}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static grantOf(value: unknown): string[] | null {
|
|
92
|
+
if (
|
|
93
|
+
!Array.isArray(value)
|
|
94
|
+
|| value.length > GRANT_MAX
|
|
95
|
+
|| !value.every((entry): entry is string => typeof entry === 'string' && isValidGrantEntry(entry))
|
|
96
|
+
) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return [...new Set(value)];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static isValidOrigin(value: unknown): value is string {
|
|
103
|
+
return typeof value === 'string' && ORIGIN_RE.test(value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static isValidBrand(value: unknown): value is string {
|
|
107
|
+
return typeof value === 'string' && isValidPackageName(value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static isValidVersion(value: unknown): value is string {
|
|
111
|
+
return typeof value === 'string' && VERSION_RE.test(value);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static personOf(value: unknown): IServicePerson | null {
|
|
115
|
+
const raw = value as Partial<IServicePerson> | null;
|
|
116
|
+
if (
|
|
117
|
+
!raw
|
|
118
|
+
|| typeof raw !== 'object'
|
|
119
|
+
|| typeof raw.id !== 'string'
|
|
120
|
+
|| !raw.id
|
|
121
|
+
|| typeof raw.via !== 'string'
|
|
122
|
+
|| typeof raw.login !== 'string'
|
|
123
|
+
|| !raw.login
|
|
124
|
+
) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
id: raw.id.slice(0, 100),
|
|
129
|
+
via: raw.via.slice(0, 40),
|
|
130
|
+
login: raw.login.slice(0, 100),
|
|
131
|
+
...(typeof raw.email === 'string' ? { email: raw.email.slice(0, 200) } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static connectionOf(raw: string | null): IServiceConnection | null {
|
|
136
|
+
if (!raw) return null;
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(raw) as Partial<IServiceConnection>;
|
|
139
|
+
const grant = ServiceProtocolCodec.grantOf(parsed.grant);
|
|
140
|
+
if (
|
|
141
|
+
typeof parsed.brand !== 'string'
|
|
142
|
+
|| typeof parsed.publisher !== 'string'
|
|
143
|
+
|| typeof parsed.installation !== 'string'
|
|
144
|
+
|| typeof parsed.key !== 'string'
|
|
145
|
+
|| !grant
|
|
146
|
+
) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const roles = workbenchRolesOf(parsed.workbench);
|
|
150
|
+
return {
|
|
151
|
+
brand: parsed.brand,
|
|
152
|
+
publisher: parsed.publisher,
|
|
153
|
+
installation: parsed.installation,
|
|
154
|
+
key: parsed.key,
|
|
155
|
+
version: String(parsed.version ?? ''),
|
|
156
|
+
grant,
|
|
157
|
+
at: String(parsed.at ?? ''),
|
|
158
|
+
by: String(parsed.by ?? ''),
|
|
159
|
+
...(roles ? { workbench: roles } : {}),
|
|
160
|
+
};
|
|
161
|
+
} catch {
|
|
162
|
+
// fallback: malformed sealed JSON entry is treated as absent rather than crashing lookup
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static offersIn(listed: { readonly services?: unknown }): IServiceOffer[] {
|
|
168
|
+
if (!Array.isArray(listed.services)) return [];
|
|
169
|
+
const offers: IServiceOffer[] = [];
|
|
170
|
+
for (const entry of listed.services as Record<string, unknown>[]) {
|
|
171
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
172
|
+
const offer = ServiceProtocolCodec.parseOfferEntry(entry);
|
|
173
|
+
if (offer) offers.push(offer);
|
|
174
|
+
}
|
|
175
|
+
return offers;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static sameAsked(a: IServiceAsked, b: Partial<IServiceAsked>): boolean {
|
|
179
|
+
return a.publisher === b.publisher
|
|
180
|
+
&& a.brand === b.brand
|
|
181
|
+
&& a.version === b.version
|
|
182
|
+
&& Array.isArray(b.grant)
|
|
183
|
+
&& a.grant.length === b.grant.length
|
|
184
|
+
&& a.grant.every((item, index) => b.grant?.[index] === item);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static olderThan(a: string, b: string): boolean {
|
|
188
|
+
return compareVersions(a, b) < 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static proofAudience(hostname: string): string {
|
|
192
|
+
return `service-proof:${hostname.toLowerCase()}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static keyOfRequest(request: Request): string | null {
|
|
196
|
+
return BEARER_KEY_RE.exec(request.headers.get('authorization') ?? '')?.[1] ?? null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
static installationIdOfKey(key: string): string | null {
|
|
200
|
+
return KEY_ID_RE.exec(key)?.[1] ?? null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static async hashKey(key: string): Promise<string> {
|
|
204
|
+
return toHex(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(key)));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static randomSecret(): string {
|
|
208
|
+
const bytes = crypto.getRandomValues(new Uint8Array(32));
|
|
209
|
+
return btoa(String.fromCharCode(...bytes))
|
|
210
|
+
.replace(/\+/g, '-')
|
|
211
|
+
.replace(/\//g, '_')
|
|
212
|
+
.replace(/=+$/, '');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static secondsOf(now: Date): number {
|
|
216
|
+
return Math.floor(now.getTime() / 1000);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static jsonResponse(status: number, body: unknown): Response {
|
|
220
|
+
return new Response(JSON.stringify(body), {
|
|
221
|
+
status,
|
|
222
|
+
headers: {
|
|
223
|
+
'content-type': 'application/json; charset=utf-8',
|
|
224
|
+
'cache-control': 'no-store',
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static refusalResponse(status: number, code: string, message?: string): Response {
|
|
230
|
+
return ServiceProtocolCodec.jsonResponse(status, {
|
|
231
|
+
error: { code, ...(message ? { message } : {}) },
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static shownInstallation(installation: IInstallation): Omit<IInstallation, 'keyHash'> {
|
|
236
|
+
const { keyHash: _hash, ...shown } = installation;
|
|
237
|
+
return shown;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
static brandSecretName(brand: string): string {
|
|
241
|
+
return `${CONNECTION_SECRET_PREFIX}${brandSecretSuffix(brand)}`;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
static declinedSecretName(brand: string): string {
|
|
245
|
+
return `${DECLINED_SECRET_PREFIX}${brandSecretSuffix(brand)}`;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static async grantedListing(response: Response, grant: readonly string[]): Promise<Response> {
|
|
249
|
+
if (!response.ok) return response;
|
|
250
|
+
const listed = await response.json().catch(() => null) as { modules?: { module?: unknown }[] } | null;
|
|
251
|
+
const modules = (listed?.modules ?? []).filter((entry) => {
|
|
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;
|
|
256
|
+
});
|
|
257
|
+
return ServiceProtocolCodec.jsonResponse(200, { ...listed, modules });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { TWorkbenchRoles } from '@mosetta/content/workbench';
|
|
2
|
+
import { INSTALLATIONS_PATH, REPOSITORIES_GRANT, SERVICES_PATH } from '@mosetta/host-platform/host';
|
|
3
|
+
import type { IDefaultService, IServiceConnection, IServicesComposition } from '@mosetta/host-platform/host';
|
|
4
|
+
import type { ISession } from '@mosetta/host-platform/tokens';
|
|
5
|
+
import type { IServiceInvocationPort } from './serviceInvocation';
|
|
6
|
+
import type { IServiceTechnicalPort } from './serviceTechnicalIo';
|
|
7
|
+
|
|
8
|
+
export { INSTALLATIONS_PATH, REPOSITORIES_GRANT, SERVICES_PATH };
|
|
9
|
+
export type { IDefaultService, IServiceConnection, IServicesComposition, TWorkbenchRoles };
|
|
10
|
+
|
|
11
|
+
/** A connection's key, as the publisher gave it: `msi_<installation>.<secret>`. */
|
|
12
|
+
export const INSTALLATION_KEY_PREFIX = 'msi_';
|
|
13
|
+
|
|
14
|
+
/** Reserved legacy HTTP word: stripped at admission, never a human identity source. */
|
|
15
|
+
export const SERVICE_PERSON_HEADER = 'x-mosetta-service-person';
|
|
16
|
+
|
|
17
|
+
/** Reserved legacy credential-bearing site word; not accepted by private invocation. */
|
|
18
|
+
export const SERVICE_SITE_HEADER = 'x-mosetta-service-site';
|
|
19
|
+
|
|
20
|
+
/** The block the call comes from, as the consumer's runner read it off the consumer's page. */
|
|
21
|
+
export const SERVICE_BLOCK_HEADER = 'x-mosetta-service-block';
|
|
22
|
+
|
|
23
|
+
/** Maximum serialized size of a forwarded block context. */
|
|
24
|
+
export const SERVICE_BLOCK_MAX = 48 * 1024;
|
|
25
|
+
|
|
26
|
+
/** The server tile a palette offers itself as a service by, and the action that decides who connects. */
|
|
27
|
+
export const SERVICE_TILE = 'service';
|
|
28
|
+
export const INSTALL_ACTION = 'install';
|
|
29
|
+
|
|
30
|
+
/** Host-door grants a service may request beside the site's palettes. */
|
|
31
|
+
export const PREVIEWS_GRANT = '@previews';
|
|
32
|
+
export const MEDIA_GRANT = '@media';
|
|
33
|
+
|
|
34
|
+
/** The connection permits code callbacks; the child's code.edit/code.release still gate every API call. */
|
|
35
|
+
export const CODE_GRANT = '@code';
|
|
36
|
+
|
|
37
|
+
/** Reserved legacy code-key word; private invocation carries only safe code routing metadata. */
|
|
38
|
+
export const SERVICE_CODE_HEADER = 'x-mosetta-service-code';
|
|
39
|
+
|
|
40
|
+
export const PROOF_PREFIX = 'msp_';
|
|
41
|
+
export const PROOF_TTL_SECONDS = 5 * 60;
|
|
42
|
+
export const GRANT_MAX = 32;
|
|
43
|
+
export const LISTING_PATH = '/api/server-action/';
|
|
44
|
+
export const REVOKED_STATUS = 'revoked';
|
|
45
|
+
|
|
46
|
+
/** Parsed address of a server-action HTTP path. */
|
|
47
|
+
export interface IServiceActionAddress {
|
|
48
|
+
readonly fullId: string;
|
|
49
|
+
readonly brand: string;
|
|
50
|
+
readonly tile: string;
|
|
51
|
+
readonly action: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Unverified contact metadata on an installation record; never an identity or permission source. */
|
|
55
|
+
export interface IServicePerson {
|
|
56
|
+
/** Contact identifier supplied by the consumer; never used to authorize human operations. */
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly via: string;
|
|
59
|
+
readonly login: string;
|
|
60
|
+
readonly email?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The parts a service plays in a workbench (`@mosetta/content/workbench`), each `<tile>.<action>`. */
|
|
64
|
+
export interface IWorkbenchRoles {
|
|
65
|
+
readonly assistant?: string;
|
|
66
|
+
readonly transcribe?: string;
|
|
67
|
+
readonly translate?: string;
|
|
68
|
+
readonly tools?: string;
|
|
69
|
+
readonly icon?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The consumer's connections, kept where no code of the site reads them. */
|
|
73
|
+
export interface IServiceConnections {
|
|
74
|
+
list(): Promise<IServiceConnection[]>;
|
|
75
|
+
get(brand: string): Promise<IServiceConnection | null>;
|
|
76
|
+
put(connection: IServiceConnection): Promise<void>;
|
|
77
|
+
remove(brand: string): Promise<boolean>;
|
|
78
|
+
/** The owner ended a service the host gives every site: it stays ended — the host connects it no more. */
|
|
79
|
+
decline(brand: string, by: string): Promise<void>;
|
|
80
|
+
/** The brands the owner ended so — a connection made again takes the word back. */
|
|
81
|
+
declined(): Promise<Set<string>>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** An installation of one of this site's palettes at another site, as the publisher keeps it. */
|
|
85
|
+
export interface IInstallation {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly keyHash: string;
|
|
88
|
+
readonly consumer: string;
|
|
89
|
+
readonly brand: string;
|
|
90
|
+
readonly version: string;
|
|
91
|
+
readonly grant: readonly string[];
|
|
92
|
+
readonly person: IServicePerson | null;
|
|
93
|
+
/** `active`; `removed` — the consumer ended it; anything else (e.g. `revoked`) — refused. */
|
|
94
|
+
readonly status: string;
|
|
95
|
+
readonly createdAt: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The publisher's installations repository contract. */
|
|
99
|
+
export interface IInstallations {
|
|
100
|
+
create(installation: IInstallation): Promise<void>;
|
|
101
|
+
byId(id: string): Promise<IInstallation | null>;
|
|
102
|
+
/** Every installation, the newest first — who uses the site's services. */
|
|
103
|
+
list(): Promise<IInstallation[]>;
|
|
104
|
+
setStatus(id: string, status: string): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Scoped mutation session opened by the host's private service management port. */
|
|
108
|
+
export interface IServiceMutationSession {
|
|
109
|
+
readonly host: IServicesHost;
|
|
110
|
+
finish(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Trusted event-only factories; these ports are never application env or HTTP authority. */
|
|
114
|
+
export interface IServiceManagementPort {
|
|
115
|
+
human(request: Request): Promise<IServiceMutationSession>;
|
|
116
|
+
defaults(wanted: IDefaultService): Promise<IServiceMutationSession>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Host dependencies required to serve cross-site service handshakes and management. */
|
|
120
|
+
export interface IServicesHost {
|
|
121
|
+
/** Root-only one-use technical proof and local SQL fence. No human identity authority. */
|
|
122
|
+
readonly technical?: IServiceTechnicalPort | null;
|
|
123
|
+
readonly management?: IServiceManagementPort | null;
|
|
124
|
+
/** A request-local trusted same-installation bridge; absent means human handoff is unavailable. */
|
|
125
|
+
readonly invocation?: IServiceInvocationPort | null;
|
|
126
|
+
/** The site's composition — none: a service's actions are forwarded, its blocks are the site's own business. */
|
|
127
|
+
readonly composition?: IServicesComposition | null;
|
|
128
|
+
/** Only the technical connection-confirmation proof uses this host secret. */
|
|
129
|
+
readonly secret: string | null;
|
|
130
|
+
/** This site's connections — the consumer's side; none: it takes no services. */
|
|
131
|
+
readonly connections: IServiceConnections | null;
|
|
132
|
+
/** This site's installations — the publisher's side; none: it offers no services. */
|
|
133
|
+
readonly installations: IInstallations | null;
|
|
134
|
+
/** Outbound transport to another site. */
|
|
135
|
+
readonly fetch: typeof fetch;
|
|
136
|
+
/** An action of this site's own run as the host asks (the publisher's `install`). */
|
|
137
|
+
readonly runAction: ((request: Request) => Promise<Response>) | null;
|
|
138
|
+
/** The services the host gives every site of its own (e.g. the platform's assistant). */
|
|
139
|
+
readonly defaults?: readonly IDefaultService[];
|
|
140
|
+
readonly now?: () => Date;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Where a host keeps what only it may read — the site's secrets, in the host's own scope. */
|
|
144
|
+
export interface IHeldValues {
|
|
145
|
+
hold(projectId: string, name: string, value: string, by: string | null): Promise<void>;
|
|
146
|
+
held(projectId: string, name: string): Promise<string | null>;
|
|
147
|
+
heldNames(projectId: string): Promise<string[]>;
|
|
148
|
+
release(projectId: string, name: string): Promise<boolean>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Parameters a consumer asks to connect and signs in its confirmation proof. */
|
|
152
|
+
export interface IServiceAsked {
|
|
153
|
+
readonly publisher: string;
|
|
154
|
+
readonly brand: string;
|
|
155
|
+
readonly version: string;
|
|
156
|
+
readonly grant: readonly string[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Normalized description of a service offered by a publishing site. */
|
|
160
|
+
export interface IServiceOffer {
|
|
161
|
+
readonly brand: string;
|
|
162
|
+
readonly version: string;
|
|
163
|
+
readonly title: string;
|
|
164
|
+
readonly description?: string;
|
|
165
|
+
readonly grant: readonly string[];
|
|
166
|
+
readonly workbench?: TWorkbenchRoles;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Minimal session fields carried into handshake requests and default connections. */
|
|
170
|
+
export type TServiceSessionIdentity = Pick<ISession, 'sub' | 'via' | 'login'> & Partial<Pick<ISession, 'exp'>>;
|