@segmentstream/ontology 0.170.0 → 0.170.2
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/CHANGELOG.md +13 -0
- package/dist/connection.d.ts +2 -2
- package/dist/service/authentication.d.ts +1 -1
- package/dist/service/authentication.js +5 -4
- package/dist/service/config.d.ts +2 -0
- package/dist/service/config.js +10 -1
- package/dist/service/connections.js +4 -2
- package/dist/service/service.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.170.2
|
|
4
|
+
|
|
5
|
+
Workspace apps and ontology services call the production API at segmentstream.com. Existing signed token issuers, OAuth registrations and custom API origins continue to work.
|
|
6
|
+
|
|
7
|
+
## 0.170.1
|
|
8
|
+
|
|
9
|
+
A connection call that names no `api` reaches the connection's `default_api` or, when the
|
|
10
|
+
connection declares exactly one API and no default, that API, as the connections SDK's HTTP
|
|
11
|
+
client already chooses. Calls such as `nowpayments.get("/payment/123")` through a preset with one
|
|
12
|
+
API, such as `NowPaymentsConnection` or `CoinGateConnection`, no longer fail for want of a default.
|
|
13
|
+
Cloud applies the same rule to deployed ontologies without an upgrade; this release brings it to
|
|
14
|
+
local runs.
|
|
15
|
+
|
|
3
16
|
## 0.170.0
|
|
4
17
|
|
|
5
18
|
An `hmac` webhook signature can sign the body as `{ body: "sorted-json" }`: the body parsed as a
|
package/dist/connection.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class ConnectionError extends ConnectionError_base {
|
|
|
47
47
|
}
|
|
48
48
|
/** One HTTP request through the connection proxy, before it is bound to a connection key. */
|
|
49
49
|
export interface ConnectionCall {
|
|
50
|
-
/** One of the connection's declared APIs;
|
|
50
|
+
/** One of the connection's declared APIs; when omitted, its `default_api`, or its only API. */
|
|
51
51
|
readonly api?: string;
|
|
52
52
|
readonly method: ConnectionMethod;
|
|
53
53
|
/** The path and query, relative to the API's base URL, such as `/people/match?reveal=true`. */
|
|
@@ -121,7 +121,7 @@ export type ConnectionHeaders = Readonly<Record<string, string>> | ReadonlyArray
|
|
|
121
121
|
export type QueryValue = string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
122
122
|
/** The options of `request` and the method helpers. */
|
|
123
123
|
export interface ConnectionRequestOptions {
|
|
124
|
-
/** One of the connection's declared APIs;
|
|
124
|
+
/** One of the connection's declared APIs; when omitted, its `default_api`, or its only API. */
|
|
125
125
|
readonly api?: string;
|
|
126
126
|
/** Appended to the path as a query string. `undefined` values are skipped. */
|
|
127
127
|
readonly query?: Readonly<Record<string, QueryValue | undefined>>;
|
|
@@ -6,7 +6,7 @@ import { type DeploymentObservation } from "../deployment.js";
|
|
|
6
6
|
import { type BrowserRevision } from "./federation-status.js";
|
|
7
7
|
import type { WorkloadExecution } from "../runtime/workload.js";
|
|
8
8
|
import type { ChatProvenance, Principal } from "../runtime.js";
|
|
9
|
-
import type
|
|
9
|
+
import { type NeonAuthEnvironment } from "./config.js";
|
|
10
10
|
import { RequestId } from "./errors.js";
|
|
11
11
|
import { CurrentCaller, type VerifiedCaller } from "./caller-context.js";
|
|
12
12
|
import { OntologyBackend, type SignInIdentity } from "./runtime-contract.js";
|
|
@@ -8,6 +8,7 @@ import { previewRunsAgent, requireDeploymentCapability, } from "../deployment.js
|
|
|
8
8
|
import { API_KEY_PREFIX } from "../runtime/principals.js";
|
|
9
9
|
import { FEDERATION_TOKEN_PREFIX, federationDigest } from "../runtime/federation.js";
|
|
10
10
|
import { browserRevisionAdmitted, browserRevisionObservation, browserSessionAdmission, federationStatus, } from "./federation-status.js";
|
|
11
|
+
import { platformTokenIssuer } from "./config.js";
|
|
11
12
|
import { RequestId, crossOriginSession, forbidden, internalError, notInvited, toServerResponse, unauthorized, unavailable, } from "./errors.js";
|
|
12
13
|
import { ACCESS_TOKEN_PREFIX, appSessionResource, publicOrigin, callerOfAccessToken, READ_SCOPE, rejectedAccessToken, scopedPrincipal, } from "./oauth/protocol.js";
|
|
13
14
|
import { CurrentCaller } from "./caller-context.js";
|
|
@@ -71,7 +72,7 @@ function identityFromClaims(config, payload) {
|
|
|
71
72
|
if (!mapping ||
|
|
72
73
|
typeof mapping !== "object" ||
|
|
73
74
|
mapping.issuer !==
|
|
74
|
-
(config.oidc?.issuer ?? `${
|
|
75
|
+
(config.oidc?.issuer ?? `${platformTokenIssuer(config.segmentstreamUrl)}/oidc`) ||
|
|
75
76
|
typeof mapping.subject !== "string" ||
|
|
76
77
|
!mapping.subject) {
|
|
77
78
|
return undefined;
|
|
@@ -91,7 +92,7 @@ function identityFromClaims(config, payload) {
|
|
|
91
92
|
* `SEGMENTSTREAM_URL` for this application (`aud: app:<application id>`), organization and workspace.
|
|
92
93
|
*/
|
|
93
94
|
export function makeTokenVerifier(config, keySet) {
|
|
94
|
-
const issuer =
|
|
95
|
+
const issuer = platformTokenIssuer(config.segmentstreamUrl);
|
|
95
96
|
const audience = `app:${config.applicationId}`;
|
|
96
97
|
return async function verifyToken(token) {
|
|
97
98
|
let payload;
|
|
@@ -151,7 +152,7 @@ export function makeWorkloadTokenVerifier(config, keySet) {
|
|
|
151
152
|
const verified = await jwtVerify(token, keySet, {
|
|
152
153
|
algorithms: ["ES256"],
|
|
153
154
|
typ: WORKLOAD_TOKEN_TYPE,
|
|
154
|
-
issuer:
|
|
155
|
+
issuer: platformTokenIssuer(config.segmentstreamUrl),
|
|
155
156
|
audience: `ontology:${config.applicationId}`,
|
|
156
157
|
clockTolerance: CLOCK_TOLERANCE_SECONDS,
|
|
157
158
|
requiredClaims: [
|
|
@@ -333,7 +334,7 @@ export function tokenVerifier(config) {
|
|
|
333
334
|
}
|
|
334
335
|
};
|
|
335
336
|
const verifiers = new Map([
|
|
336
|
-
[
|
|
337
|
+
[platformTokenIssuer(config.segmentstreamUrl), platform],
|
|
337
338
|
]);
|
|
338
339
|
if (config.neonAuth !== undefined &&
|
|
339
340
|
(!config.browserMethods || config.browserMethods.includes("email"))) {
|
package/dist/service/config.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import type { PageCatalogV1 } from "../navigation-catalog.js";
|
|
|
9
9
|
import { type ConnectionTransportFactory, type LocalConnectionContext } from "./connections.js";
|
|
10
10
|
import type { OntologyServiceRuntime } from "./runtime-contract.js";
|
|
11
11
|
import type { RuntimeIdentityConfig } from "./runtime-identity.js";
|
|
12
|
+
/** A signed issuer stays stable when the platform API moves. */
|
|
13
|
+
export declare function platformTokenIssuer(apiUrl: string): string;
|
|
12
14
|
/** The environment of the workspace deployment's ontology service. */
|
|
13
15
|
export declare const ENVIRONMENT_VARIABLES: {
|
|
14
16
|
readonly databaseUrl: "SEGMENTSTREAM_ONTOLOGY_DATABASE_URL";
|
package/dist/service/config.js
CHANGED
|
@@ -3,6 +3,14 @@ import { Redacted, Schema } from "effect";
|
|
|
3
3
|
import { BlobStorageBinding } from "../storage/provider.js";
|
|
4
4
|
import { deploymentFromEnv, previewRunsAgent } from "../deployment.js";
|
|
5
5
|
import { LocalConnectionContextError, readLocalConnectionContext, RUNTIME_CONTEXT_FD, } from "./connections.js";
|
|
6
|
+
// @legacy website.cloud-domain-serving
|
|
7
|
+
const productionIssuer = "https://cloud.segmentstream.com";
|
|
8
|
+
const productionApi = "https://segmentstream.com";
|
|
9
|
+
/** A signed issuer stays stable when the platform API moves. */
|
|
10
|
+
export function platformTokenIssuer(apiUrl) {
|
|
11
|
+
const origin = new URL(apiUrl).origin;
|
|
12
|
+
return origin === productionApi ? productionIssuer : origin;
|
|
13
|
+
}
|
|
6
14
|
/** The environment of the workspace deployment's ontology service. */
|
|
7
15
|
export const ENVIRONMENT_VARIABLES = {
|
|
8
16
|
databaseUrl: "SEGMENTSTREAM_ONTOLOGY_DATABASE_URL",
|
|
@@ -190,11 +198,12 @@ export function configFromEnv(environment = process.env) {
|
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
const previews = telegramPreviewEnvironment(environment);
|
|
201
|
+
const apiOrigin = normalizeUrl(ENVIRONMENT_VARIABLES.segmentstreamUrl, read(ENVIRONMENT_VARIABLES.segmentstreamUrl));
|
|
193
202
|
return {
|
|
194
203
|
...previews,
|
|
195
204
|
deployment,
|
|
196
205
|
databaseUrl: checkDatabaseUrl(ENVIRONMENT_VARIABLES.databaseUrl, read(ENVIRONMENT_VARIABLES.databaseUrl)),
|
|
197
|
-
segmentstreamUrl:
|
|
206
|
+
segmentstreamUrl: apiOrigin === productionIssuer ? productionApi : apiOrigin,
|
|
198
207
|
applicationId: read(ENVIRONMENT_VARIABLES.applicationId),
|
|
199
208
|
workspaceId: read(ENVIRONMENT_VARIABLES.workspaceId),
|
|
200
209
|
organizationId: read(ENVIRONMENT_VARIABLES.organizationId),
|
|
@@ -223,10 +223,12 @@ export function localConnections(context, fetchImpl = fetch) {
|
|
|
223
223
|
if (granted === undefined) {
|
|
224
224
|
return Effect.fail(failure(call.connection, "not_granted", `Run the service with segmentstream exec --connection ${call.connection}.`));
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
// The connection's default API, or its only one, as the connections SDK's client chooses.
|
|
227
|
+
const declared = Object.keys(granted.apis);
|
|
228
|
+
const api = call.api ?? granted.defaultApi ?? (declared.length === 1 ? declared[0] : undefined);
|
|
227
229
|
if (api === undefined || !(api in granted.apis)) {
|
|
228
230
|
return Effect.fail(failure(call.connection, "invalid_request", api === undefined
|
|
229
|
-
? `The connection ${call.connection}
|
|
231
|
+
? `The connection ${call.connection} declares several APIs and no default; set api.`
|
|
230
232
|
: `The connection ${call.connection} declares no API named ${api}.`));
|
|
231
233
|
}
|
|
232
234
|
return Effect.succeed({
|
package/dist/service/service.js
CHANGED
|
@@ -34,7 +34,7 @@ import { platformWarehouseQueries, WarehouseQueries } from "./warehouse-platform
|
|
|
34
34
|
import { BASE_PATH, ErrorResponsesLive, buildApi } from "./api.js";
|
|
35
35
|
import { CurrentPrincipal, authenticationLayer, neonAuthSessionExchange, tokenVerifier, withPrincipal, } from "./authentication.js";
|
|
36
36
|
import { currentCaller } from "./caller-context.js";
|
|
37
|
-
import { OntologyServiceConfigError, } from "./config.js";
|
|
37
|
+
import { platformTokenIssuer, OntologyServiceConfigError, } from "./config.js";
|
|
38
38
|
import { RequestId, failureResponse, internalError, errorBodyForWire, routeNotFound, toServerResponse, } from "./errors.js";
|
|
39
39
|
import { deployedConnections, localConnections } from "./connections.js";
|
|
40
40
|
import { DocsRoute } from "./docs.js";
|
|
@@ -321,7 +321,7 @@ export function createOntologyService(ontology, config) {
|
|
|
321
321
|
? {
|
|
322
322
|
issuer: config.browserRevisionIssuer ??
|
|
323
323
|
config.oidc?.issuer ??
|
|
324
|
-
`${
|
|
324
|
+
`${platformTokenIssuer(config.segmentstreamUrl)}/oidc`,
|
|
325
325
|
clientId: config.browserRevisionClientId,
|
|
326
326
|
manifestDigest: ontology.manifest.hash,
|
|
327
327
|
...(config.browserEnvironment !== "local" ? { deploymentId: deployment.deploymentId } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.170.
|
|
3
|
+
"version": "0.170.2",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|