@synap-core/sdk 1.5.0 → 1.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/CHANGELOG.md +82 -0
- package/README.md +16 -0
- package/dist/connect.cjs +9 -2
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +17 -1
- package/dist/connect.d.ts +17 -1
- package/dist/connect.js +9 -2
- package/dist/connect.js.map +1 -1
- package/dist/testing.cjs +124 -11
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +50 -1
- package/dist/testing.d.ts +50 -1
- package/dist/testing.js +124 -11
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/src/connect/auth.ts +15 -2
- package/src/connect/client.ts +3 -0
- package/src/connect/hub-types.ts +17 -0
- package/src/connect/index.ts +1 -0
- package/src/testing/auth-server.ts +120 -12
- package/src/testing/roles.ts +27 -0
- package/src/testing/seed.ts +78 -2
package/dist/connect.d.cts
CHANGED
|
@@ -94,8 +94,20 @@ interface PodEntity {
|
|
|
94
94
|
/** ISO 8601. */
|
|
95
95
|
createdAt?: string;
|
|
96
96
|
updatedAt?: string;
|
|
97
|
+
/** The roles it wears, with `includeFacets`; absent when it wears none. */
|
|
98
|
+
facetSlugs?: string[];
|
|
99
|
+
/** Each role's overlay, with `includeFacets`; absent when it wears none. */
|
|
100
|
+
facets?: PodEntityFacet[];
|
|
97
101
|
[key: string]: unknown;
|
|
98
102
|
}
|
|
103
|
+
/** One role an entity wears (`FacetRowAnnotation`). */
|
|
104
|
+
interface PodEntityFacet {
|
|
105
|
+
facetId: string;
|
|
106
|
+
/** The role, e.g. `lead`. */
|
|
107
|
+
slug: string;
|
|
108
|
+
properties: Record<string, unknown>;
|
|
109
|
+
status: string | null;
|
|
110
|
+
}
|
|
99
111
|
interface ListEntitiesOptions {
|
|
100
112
|
/** One granted space. Omitted: every space the connection can read. */
|
|
101
113
|
workspaceId?: string;
|
|
@@ -108,6 +120,10 @@ interface ListEntitiesOptions {
|
|
|
108
120
|
sort?: string;
|
|
109
121
|
/** With `workspaceId`: also the person's pod-wide rows (the pod's default: true). */
|
|
110
122
|
includePodWide?: boolean;
|
|
123
|
+
/** Only the entities wearing this role, e.g. `lead`. */
|
|
124
|
+
facetSlug?: string;
|
|
125
|
+
/** Put `facetSlugs` and `facets` on each row that wears a role. */
|
|
126
|
+
includeFacets?: boolean;
|
|
111
127
|
}
|
|
112
128
|
type PodConnectionSource = "graph" | "property" | "thread" | "context_channel" | "focus_session";
|
|
113
129
|
/** One edge of `GET /entities/:id/connections` (`EntityConnection`). */
|
|
@@ -1012,4 +1028,4 @@ declare function revokeConnection(connection: PodConnection, opts?: FlowOptions)
|
|
|
1012
1028
|
/** RFC 7636 §4.2: `BASE64URL(SHA256(ASCII(code_verifier)))`. */
|
|
1013
1029
|
declare function pkceChallenge(verifier: string): Promise<string>;
|
|
1014
1030
|
|
|
1015
|
-
export { type AcceptCloudReturnOptions, AppRequest, type AppSecret, type ApproveProposalOptions, CLOUD_TRANSACTION_TTL_MS, CONNECT_ERROR_CODES, type CallbackResult, ClientMetadataDocument, type CloudConnectConfig, type CloudReturn, type CloudTransaction, ConnectError, type ConnectErrorCode, type ConnectTransaction, type ConnectionStore, type CookieNames, DEFAULT_PATHS, DEFAULT_REFRESH_IDLE_MS, type DiscoverOptions, type FlowOptions, type GetDocumentOptions, type GetEntityConnectionsOptions, type HandleCallbackOptions, type LaunchHint, type ListEntitiesOptions, type ListFocusSessionsOptions, type ListPendingProposalsOptions, MARKER_TTL_SEC, MIN_SECRET_LENGTH, type Opened, type PendingProposal, type PendingProposals, PodActsAs, type PodAppAuth, type PodAppAuthConfig, type PodAppClientOptions, type PodAppPaths, type PodApproval, type PodClient, type PodClientOptions, PodConnection, type PodConnectionSource, type PodDocument, type PodDocumentSection, type PodEntity, type PodEntityConnection, type PodEntityConnections, type PodError, type PodErrorCode, type PodFileUrl, type PodFocusSession, PodGrant, PodIssuer, type PodRefusalReason, type PodResult, type PodSessionSlot, type PodSessionStatus, PodSpace, type PodWriteResult, type QueryValue, REFRESH_WINDOW_MS, ROTATION_MEMORY_MS, type RefreshOptions, type RefreshOutcome, type RefreshStatus, type SealPurpose, type SealedCloudTransaction, type SealedCookieStoreOptions, type SealedTransaction, type StartCloudConnectOptions, type StartConnectOptions, type StartedCloudConnect, type StartedConnect, TRANSACTION_TTL_MS, acceptCloudReturn, acceptLaunch, applySetCookies, buildClientMetadata, can, canonicalPodUrl, cloudBaseUrl, cloudConnectAvailable, connectionActsAs, connectionExpiresAt, cookieNames, createPodAppAuth, createPodClient, createSealedCookieStore, discoverPod, handleCallback, humanSlots, isBrowserRuntime, isConnectError, isPrefetchOrAsset, markerCookie, openTransaction, parseConnectErrorCode, parseTokenResponse, pkceChallenge, readMarker, refreshConnection, reviewUrlFor, revokeConnection, safeNextPath, seal, spaces, startCloudConnect, startConnect, unseal };
|
|
1031
|
+
export { type AcceptCloudReturnOptions, AppRequest, type AppSecret, type ApproveProposalOptions, CLOUD_TRANSACTION_TTL_MS, CONNECT_ERROR_CODES, type CallbackResult, ClientMetadataDocument, type CloudConnectConfig, type CloudReturn, type CloudTransaction, ConnectError, type ConnectErrorCode, type ConnectTransaction, type ConnectionStore, type CookieNames, DEFAULT_PATHS, DEFAULT_REFRESH_IDLE_MS, type DiscoverOptions, type FlowOptions, type GetDocumentOptions, type GetEntityConnectionsOptions, type HandleCallbackOptions, type LaunchHint, type ListEntitiesOptions, type ListFocusSessionsOptions, type ListPendingProposalsOptions, MARKER_TTL_SEC, MIN_SECRET_LENGTH, type Opened, type PendingProposal, type PendingProposals, PodActsAs, type PodAppAuth, type PodAppAuthConfig, type PodAppClientOptions, type PodAppPaths, type PodApproval, type PodClient, type PodClientOptions, PodConnection, type PodConnectionSource, type PodDocument, type PodDocumentSection, type PodEntity, type PodEntityConnection, type PodEntityConnections, type PodEntityFacet, type PodError, type PodErrorCode, type PodFileUrl, type PodFocusSession, PodGrant, PodIssuer, type PodRefusalReason, type PodResult, type PodSessionSlot, type PodSessionStatus, PodSpace, type PodWriteResult, type QueryValue, REFRESH_WINDOW_MS, ROTATION_MEMORY_MS, type RefreshOptions, type RefreshOutcome, type RefreshStatus, type SealPurpose, type SealedCloudTransaction, type SealedCookieStoreOptions, type SealedTransaction, type StartCloudConnectOptions, type StartConnectOptions, type StartedCloudConnect, type StartedConnect, TRANSACTION_TTL_MS, acceptCloudReturn, acceptLaunch, applySetCookies, buildClientMetadata, can, canonicalPodUrl, cloudBaseUrl, cloudConnectAvailable, connectionActsAs, connectionExpiresAt, cookieNames, createPodAppAuth, createPodClient, createSealedCookieStore, discoverPod, handleCallback, humanSlots, isBrowserRuntime, isConnectError, isPrefetchOrAsset, markerCookie, openTransaction, parseConnectErrorCode, parseTokenResponse, pkceChallenge, readMarker, refreshConnection, reviewUrlFor, revokeConnection, safeNextPath, seal, spaces, startCloudConnect, startConnect, unseal };
|
package/dist/connect.d.ts
CHANGED
|
@@ -94,8 +94,20 @@ interface PodEntity {
|
|
|
94
94
|
/** ISO 8601. */
|
|
95
95
|
createdAt?: string;
|
|
96
96
|
updatedAt?: string;
|
|
97
|
+
/** The roles it wears, with `includeFacets`; absent when it wears none. */
|
|
98
|
+
facetSlugs?: string[];
|
|
99
|
+
/** Each role's overlay, with `includeFacets`; absent when it wears none. */
|
|
100
|
+
facets?: PodEntityFacet[];
|
|
97
101
|
[key: string]: unknown;
|
|
98
102
|
}
|
|
103
|
+
/** One role an entity wears (`FacetRowAnnotation`). */
|
|
104
|
+
interface PodEntityFacet {
|
|
105
|
+
facetId: string;
|
|
106
|
+
/** The role, e.g. `lead`. */
|
|
107
|
+
slug: string;
|
|
108
|
+
properties: Record<string, unknown>;
|
|
109
|
+
status: string | null;
|
|
110
|
+
}
|
|
99
111
|
interface ListEntitiesOptions {
|
|
100
112
|
/** One granted space. Omitted: every space the connection can read. */
|
|
101
113
|
workspaceId?: string;
|
|
@@ -108,6 +120,10 @@ interface ListEntitiesOptions {
|
|
|
108
120
|
sort?: string;
|
|
109
121
|
/** With `workspaceId`: also the person's pod-wide rows (the pod's default: true). */
|
|
110
122
|
includePodWide?: boolean;
|
|
123
|
+
/** Only the entities wearing this role, e.g. `lead`. */
|
|
124
|
+
facetSlug?: string;
|
|
125
|
+
/** Put `facetSlugs` and `facets` on each row that wears a role. */
|
|
126
|
+
includeFacets?: boolean;
|
|
111
127
|
}
|
|
112
128
|
type PodConnectionSource = "graph" | "property" | "thread" | "context_channel" | "focus_session";
|
|
113
129
|
/** One edge of `GET /entities/:id/connections` (`EntityConnection`). */
|
|
@@ -1012,4 +1028,4 @@ declare function revokeConnection(connection: PodConnection, opts?: FlowOptions)
|
|
|
1012
1028
|
/** RFC 7636 §4.2: `BASE64URL(SHA256(ASCII(code_verifier)))`. */
|
|
1013
1029
|
declare function pkceChallenge(verifier: string): Promise<string>;
|
|
1014
1030
|
|
|
1015
|
-
export { type AcceptCloudReturnOptions, AppRequest, type AppSecret, type ApproveProposalOptions, CLOUD_TRANSACTION_TTL_MS, CONNECT_ERROR_CODES, type CallbackResult, ClientMetadataDocument, type CloudConnectConfig, type CloudReturn, type CloudTransaction, ConnectError, type ConnectErrorCode, type ConnectTransaction, type ConnectionStore, type CookieNames, DEFAULT_PATHS, DEFAULT_REFRESH_IDLE_MS, type DiscoverOptions, type FlowOptions, type GetDocumentOptions, type GetEntityConnectionsOptions, type HandleCallbackOptions, type LaunchHint, type ListEntitiesOptions, type ListFocusSessionsOptions, type ListPendingProposalsOptions, MARKER_TTL_SEC, MIN_SECRET_LENGTH, type Opened, type PendingProposal, type PendingProposals, PodActsAs, type PodAppAuth, type PodAppAuthConfig, type PodAppClientOptions, type PodAppPaths, type PodApproval, type PodClient, type PodClientOptions, PodConnection, type PodConnectionSource, type PodDocument, type PodDocumentSection, type PodEntity, type PodEntityConnection, type PodEntityConnections, type PodError, type PodErrorCode, type PodFileUrl, type PodFocusSession, PodGrant, PodIssuer, type PodRefusalReason, type PodResult, type PodSessionSlot, type PodSessionStatus, PodSpace, type PodWriteResult, type QueryValue, REFRESH_WINDOW_MS, ROTATION_MEMORY_MS, type RefreshOptions, type RefreshOutcome, type RefreshStatus, type SealPurpose, type SealedCloudTransaction, type SealedCookieStoreOptions, type SealedTransaction, type StartCloudConnectOptions, type StartConnectOptions, type StartedCloudConnect, type StartedConnect, TRANSACTION_TTL_MS, acceptCloudReturn, acceptLaunch, applySetCookies, buildClientMetadata, can, canonicalPodUrl, cloudBaseUrl, cloudConnectAvailable, connectionActsAs, connectionExpiresAt, cookieNames, createPodAppAuth, createPodClient, createSealedCookieStore, discoverPod, handleCallback, humanSlots, isBrowserRuntime, isConnectError, isPrefetchOrAsset, markerCookie, openTransaction, parseConnectErrorCode, parseTokenResponse, pkceChallenge, readMarker, refreshConnection, reviewUrlFor, revokeConnection, safeNextPath, seal, spaces, startCloudConnect, startConnect, unseal };
|
|
1031
|
+
export { type AcceptCloudReturnOptions, AppRequest, type AppSecret, type ApproveProposalOptions, CLOUD_TRANSACTION_TTL_MS, CONNECT_ERROR_CODES, type CallbackResult, ClientMetadataDocument, type CloudConnectConfig, type CloudReturn, type CloudTransaction, ConnectError, type ConnectErrorCode, type ConnectTransaction, type ConnectionStore, type CookieNames, DEFAULT_PATHS, DEFAULT_REFRESH_IDLE_MS, type DiscoverOptions, type FlowOptions, type GetDocumentOptions, type GetEntityConnectionsOptions, type HandleCallbackOptions, type LaunchHint, type ListEntitiesOptions, type ListFocusSessionsOptions, type ListPendingProposalsOptions, MARKER_TTL_SEC, MIN_SECRET_LENGTH, type Opened, type PendingProposal, type PendingProposals, PodActsAs, type PodAppAuth, type PodAppAuthConfig, type PodAppClientOptions, type PodAppPaths, type PodApproval, type PodClient, type PodClientOptions, PodConnection, type PodConnectionSource, type PodDocument, type PodDocumentSection, type PodEntity, type PodEntityConnection, type PodEntityConnections, type PodEntityFacet, type PodError, type PodErrorCode, type PodFileUrl, type PodFocusSession, PodGrant, PodIssuer, type PodRefusalReason, type PodResult, type PodSessionSlot, type PodSessionStatus, PodSpace, type PodWriteResult, type QueryValue, REFRESH_WINDOW_MS, ROTATION_MEMORY_MS, type RefreshOptions, type RefreshOutcome, type RefreshStatus, type SealPurpose, type SealedCloudTransaction, type SealedCookieStoreOptions, type SealedTransaction, type StartCloudConnectOptions, type StartConnectOptions, type StartedCloudConnect, type StartedConnect, TRANSACTION_TTL_MS, acceptCloudReturn, acceptLaunch, applySetCookies, buildClientMetadata, can, canonicalPodUrl, cloudBaseUrl, cloudConnectAvailable, connectionActsAs, connectionExpiresAt, cookieNames, createPodAppAuth, createPodClient, createSealedCookieStore, discoverPod, handleCallback, humanSlots, isBrowserRuntime, isConnectError, isPrefetchOrAsset, markerCookie, openTransaction, parseConnectErrorCode, parseTokenResponse, pkceChallenge, readMarker, refreshConnection, reviewUrlFor, revokeConnection, safeNextPath, seal, spaces, startCloudConnect, startConnect, unseal };
|
package/dist/connect.js
CHANGED
|
@@ -733,7 +733,10 @@ function createPodClient(connection, opts = {}) {
|
|
|
733
733
|
limit: clamp(opts2.limit, 1, 1e3),
|
|
734
734
|
offset: clamp(opts2.offset, 0, Number.MAX_SAFE_INTEGER),
|
|
735
735
|
sort: opts2.sort,
|
|
736
|
-
includePodWide: opts2.includePodWide
|
|
736
|
+
includePodWide: opts2.includePodWide,
|
|
737
|
+
facetSlug: opts2.facetSlug,
|
|
738
|
+
// Sent only when asked: the default request stays the 1.5.0 one.
|
|
739
|
+
includeFacets: opts2.includeFacets ? true : void 0
|
|
737
740
|
}, (data) => Array.isArray(data) ? data.filter(hasId) : null);
|
|
738
741
|
}
|
|
739
742
|
async function getEntity(id) {
|
|
@@ -1297,6 +1300,10 @@ var PERMISSION_SEGMENT_RE = /^[a-z0-9][a-z0-9_-]*$/;
|
|
|
1297
1300
|
function isSynapAppOrigin(origin) {
|
|
1298
1301
|
return /^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?\.synap\.live$/.test(origin);
|
|
1299
1302
|
}
|
|
1303
|
+
function isMockModeOrigin(origin) {
|
|
1304
|
+
const url = new URL(origin);
|
|
1305
|
+
return url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname);
|
|
1306
|
+
}
|
|
1300
1307
|
function assertAppPermission(permission, origin) {
|
|
1301
1308
|
const segs = permission.split(".");
|
|
1302
1309
|
const fail = (why) => {
|
|
@@ -1306,7 +1313,7 @@ function assertAppPermission(permission, origin) {
|
|
|
1306
1313
|
fail("is not <subject>[.<kind>].<action> in lowercase (no *)");
|
|
1307
1314
|
}
|
|
1308
1315
|
if (segs.length === 3 && segs[0] !== "entity") fail(`names a kind, but "${segs[0]}" has none (only entity does)`);
|
|
1309
|
-
if (SYNAP_APP_REVIEW_PERMISSIONS.includes(permission) && isSynapAppOrigin(origin)) return;
|
|
1316
|
+
if (SYNAP_APP_REVIEW_PERMISSIONS.includes(permission) && (isSynapAppOrigin(origin) || isMockModeOrigin(origin))) return;
|
|
1310
1317
|
if (!GRANT_ACTIONS.includes(segs[segs.length - 1])) {
|
|
1311
1318
|
fail(`asks for "${segs[segs.length - 1]}", which an app cannot be granted (read, create, update, delete)`);
|
|
1312
1319
|
}
|