@collective-intelligence/external-apps-client-sdk 0.5.1 → 0.6.0
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/AGENTS.md +3 -0
- package/README.md +80 -0
- package/dist/chat.d.ts +2 -2
- package/dist/{client-CLXDeli1.d.ts → client-NsqWRz1M.d.ts} +1 -1
- package/dist/effect.d.ts +5 -5
- package/dist/effect.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -2
- package/dist/{resources-CO-xhsst.d.ts → resources-D_PdfDpJ.d.ts} +124 -7
- package/dist/resources.d.ts +1 -1
- package/dist/{service-D7n-Bu3T.js → service-DCSU2Gqc.js} +122 -9
- package/docs/effect.md +4 -0
- package/docs/errors.md +5 -0
- package/package.json +4 -4
package/AGENTS.md
CHANGED
|
@@ -18,6 +18,9 @@ package `README.md` holds the full API.
|
|
|
18
18
|
- Treat realtime event ids as opaque: store and resend them unchanged.
|
|
19
19
|
- Branch on an error by its class (`instanceof`, `Effect.catchTag`) and its
|
|
20
20
|
`code`, not by its `message`.
|
|
21
|
+
- Branch on the `step` of a `SignInStep` for every sign-in outcome of
|
|
22
|
+
`createServerSessionAuth().signIn`; a call rejects only when it gets no
|
|
23
|
+
step. Send the next step only after the call in flight ends.
|
|
21
24
|
- Keep server credentials out of this package: they belong to
|
|
22
25
|
`external-apps-server-sdk`.
|
|
23
26
|
|
package/README.md
CHANGED
|
@@ -87,6 +87,82 @@ An SDK version from before session renewal ignores the Renewal credential and
|
|
|
87
87
|
keeps the 300 second session against the same CI. The CI wire contract is in
|
|
88
88
|
[Access token renewal](../../../docs/architecture/external-app-gateway.md#access-token-renewal).
|
|
89
89
|
|
|
90
|
+
## Embedded Sign-In on a BFF session
|
|
91
|
+
|
|
92
|
+
`createServerSessionAuth({ basePath })` is the client of a sealed-cookie BFF:
|
|
93
|
+
the app server runs the federated auth handler of
|
|
94
|
+
`@collective-intelligence/external-apps-server-sdk`, and the access token
|
|
95
|
+
stays there. When the app has Embedded Sign-In, `auth.signIn` signs a person
|
|
96
|
+
in on the app's own page. It calls the sign-in routes at
|
|
97
|
+
`<basePath>/sign-in/*`; the client secret, the PKCE verifier and the
|
|
98
|
+
challenge stay on the server. `createFederatedAuth` has no `signIn`: an app
|
|
99
|
+
with no server keeps the CI page.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { createServerSessionAuth } from "@collective-intelligence/external-apps-client-sdk"
|
|
103
|
+
|
|
104
|
+
const auth = createServerSessionAuth({ basePath: "/api/auth" })
|
|
105
|
+
|
|
106
|
+
let step = await auth.signIn.start({ email, uiLocales: "it en" })
|
|
107
|
+
if (step.step === "code_sent") {
|
|
108
|
+
step = await auth.signIn.verify({ code })
|
|
109
|
+
}
|
|
110
|
+
if (step.step === "registration_required") {
|
|
111
|
+
step = await auth.signIn.complete({ name })
|
|
112
|
+
}
|
|
113
|
+
if (step.step === "signed_in") {
|
|
114
|
+
// auth.getState().status is "authenticated".
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Call | What it does |
|
|
119
|
+
| ----------------------------------------- | ------------------------------------------------------------------------- |
|
|
120
|
+
| `methods({ uiLocales?, returnTo? })` | Opens a Sign-In Challenge; resolves the `methods` step |
|
|
121
|
+
| `start({ email, uiLocales?, returnTo? })` | The email step; opens a challenge when the browser holds none |
|
|
122
|
+
| `verify({ code, returnTo? })` | The code step |
|
|
123
|
+
| `complete({ name, returnTo? })` | The name step of a new person, after `registration_required` |
|
|
124
|
+
| `sso({ provider, returnTo? })` | Sends the browser to `<basePath>/sign-in/sso`; resolves `redirect_to_web` |
|
|
125
|
+
|
|
126
|
+
`.` exports the input type of each call: `SignInMethodsInput`,
|
|
127
|
+
`SignInStartInput`, `SignInVerifyInput`, `SignInCompleteInput` and
|
|
128
|
+
`SignInSsoInput`.
|
|
129
|
+
|
|
130
|
+
Each call resolves one `SignInStep`, on `step`:
|
|
131
|
+
|
|
132
|
+
| `step` | Fields | What the app does |
|
|
133
|
+
| -------------------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
134
|
+
| `methods` | `emailCode`, `password`, `registrationOpen`, `ssoProviders` (`displayName`, `id`) | Show only the allowed methods |
|
|
135
|
+
| `code_sent` | | Ask for the code that CI sent by email |
|
|
136
|
+
| `registration_required` | | A new person: ask for the name, then call `complete` |
|
|
137
|
+
| `signed_in` | `registered` | The state is `authenticated`; `registered` is true for a new account |
|
|
138
|
+
| `invalid_code` | `attemptsLeft` | Ask for the code again |
|
|
139
|
+
| `retry_after` | `seconds` | Wait before a new code |
|
|
140
|
+
| `email_domain_not_allowed` | `allowedDomains` | Ask for an address in one of the domains |
|
|
141
|
+
| `sso_required` | `provider` (`displayName`, `id`) | Call `sso({ provider: provider.id })` |
|
|
142
|
+
| `redirect_to_web` | | The SDK has sent the browser to the CI page or the SSO provider |
|
|
143
|
+
| `access_denied` | | This person cannot sign in to the app |
|
|
144
|
+
| `code_expired` | | The challenge ended: start again with `start` |
|
|
145
|
+
| `no_sign_in_method` | | The app allows no sign-in method |
|
|
146
|
+
|
|
147
|
+
- A refusal is a step, not an error. A call rejects only when it gets no
|
|
148
|
+
step, with `CiTransportError`: a network error, or an answer of the BFF
|
|
149
|
+
other than a step with HTTP 200, such as `400 invalid_request`,
|
|
150
|
+
`403 invalid_origin`, `409 login_conflict` or `503 user_auth_unavailable`.
|
|
151
|
+
Its `cause` names the HTTP status. `sso`, and a call that answers
|
|
152
|
+
`redirect_to_web`, reject with `FederatedAuthError` `configuration_error`
|
|
153
|
+
when the SDK cannot navigate.
|
|
154
|
+
- The calls of one client run one at a time: a call waits for the call in
|
|
155
|
+
flight, so the challenge gets one request at a time.
|
|
156
|
+
- `signed_in` reads `<basePath>/session`, as `completeLogin` does. A `logout`
|
|
157
|
+
or a `beginLogin` during the call ends its result: the state does not
|
|
158
|
+
become `authenticated`.
|
|
159
|
+
- On `redirect_to_web` the SDK runs `beginLogin({ returnTo })`. `returnTo`
|
|
160
|
+
(default `/`) is also the page that `sso` returns to.
|
|
161
|
+
- Send `uiLocales` (the `ui_locales` list of the person) on the call that
|
|
162
|
+
opens the challenge: `methods`, or the first `start`.
|
|
163
|
+
- The routes answer only requests of the app's own pages: the browser sends
|
|
164
|
+
the page's `Origin`.
|
|
165
|
+
|
|
90
166
|
## Workflow results and read recovery
|
|
91
167
|
|
|
92
168
|
A successful Workflow with a declared output contract exposes its persisted
|
|
@@ -760,6 +836,9 @@ runtime. A failure gives one of these outcomes:
|
|
|
760
836
|
- `createFederatedAuth` and `createServerSessionAuth` reject with
|
|
761
837
|
`FederatedAuthError`. A bad option throws `FederatedAuthError`
|
|
762
838
|
`configuration_error` when you create the client.
|
|
839
|
+
- `createServerSessionAuth().signIn` resolves a `SignInStep` for every
|
|
840
|
+
sign-in outcome and rejects with `CiTransportError` when it gets no step.
|
|
841
|
+
See [Embedded Sign-In on a BFF session](#embedded-sign-in-on-a-bff-session).
|
|
763
842
|
- `createDelegatedApplicationRuntime().followRun` without a session rejects
|
|
764
843
|
with `FederatedAuthError` `reauthorization_required`.
|
|
765
844
|
- `createResourceClient` and `createEntityHttpTransport` keep the
|
|
@@ -794,6 +873,7 @@ a layer that reads Effect `Config`:
|
|
|
794
873
|
| `Runs` (`follow`) | `layerRuns` (needs `CiClient`) | `followRun`, `client.runs.follow` |
|
|
795
874
|
| `Chat` (the `client.chat` groups) | `layerChat` (needs `CiClient`) | `client.chat` |
|
|
796
875
|
| `FederatedAuth` | `layerFederatedAuth`, `layerServerSessionAuth`, and their `…Config` forms | `createFederatedAuth`, `createServerSessionAuth` |
|
|
876
|
+
| `SignIn` (the `signIn` steps) | `layerServerSessionAuth` and its `…Config` form, with `FederatedAuth` | `createServerSessionAuth().signIn` |
|
|
797
877
|
| `FixedWorkflows` (`invoke`) | `layerFixedWorkflows`, `layerFixedWorkflowsConfig` | `createFixedWorkflowClient` |
|
|
798
878
|
| `DelegatedRuntime` | `layerDelegatedRuntime`, `layerDelegatedRuntimeConfig` | `createDelegatedApplicationRuntime` |
|
|
799
879
|
| `Resources` (`bind(definition)`) | `layerResources`, `layerResourcesConfig`, `layerResourcesFromEntityTransport` | `createResourceClient` with `protocol: "entity"`, `createEntityHttpTransport` |
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as OrganizationClient } from "./client-
|
|
1
|
+
import { en as ClientOperationMap } from "./resources-D_PdfDpJ.js";
|
|
2
|
+
import { i as OrganizationClient } from "./client-NsqWRz1M.js";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
import { Place } from "@collective-intelligence/ai-core";
|
|
5
5
|
import { AccessCheckPort } from "@collective-intelligence/ai-core/access";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as ClientOperationInput, An as ExternalApplicationIntentDispatchOutcome, Cn as KnowledgeQuery, Dn as AccessCheckResponse, En as WorkflowInvokeTarget, Et as ProxyTransportOptions, Mt as FederatedSessionIdentity, On as AccessTarget, Ot as ClientFetch, Qt as ClientOperationId, Sn as JsonObject, Tn as SearchQuery, Zt as ClientOperationDefinition, _n as AgentInvokeTarget, bn as ExternalApplicationChatOperationId, cn as CiTransportError, dn as CiError$2, en as ClientOperationMap, jn as ExternalApplicationIntentDispatchState, jt as FederatedAuthState, kn as ExternalApplicationIntent, mn as JsonValue, nn as OperationExecutionOptions, on as CiError$1, pn as CiResult, rn as TypedOperationExecutor, tn as ClientOperationOutput, vn as ConversationContinueTarget, wn as QueryFilter, xn as ExternalApplicationIntentDispatchInput, yn as ConversationHistory } from "./resources-D_PdfDpJ.js";
|
|
2
2
|
import "effect/Clock";
|
|
3
3
|
import * as Config from "effect/Config";
|
|
4
4
|
import * as Context from "effect/Context";
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as layerDirect, A as DEFAULT_FOLLOW_RUN_DEADLINE_MS, J as ChatValue, L as CiStreamPage$1, M as Runs, N as RunsValue, P as layer$5, Q as ExecuteResult, U as DelegatedApplicationRuntimeOptions, W as DelegatedRuntimeState, X as CiClient, Y as layer, Z as CiClientValue, _ as RealtimeTopicFilter, et as layerDirectConfig, g as RealtimeTopic, h as RealtimeChange, j as RunFollowOptions, nt as layerProxy, q as Chat, rt as layerProxyConfig, tt as layerFromExecutor } from "./client-
|
|
1
|
+
import { Ft as FederatedAuthValue, It as layerFederated, Jt as SignInStep, Lt as layerFederatedConfig, Ot as ClientFetch, Pt as FederatedAuth, Rt as layerServerSession, Ut as SignIn, Yt as SignInValue, _ as layerLegacy, a as LegacyResourceClient, c as LegacyResourcesValue, cn as CiTransportError, d as ResourcesFromEntityTransportOptions, f as ResourcesLayerOptions, g as layerFromEntityTransport, h as layerConfig$3, i as makeEntityHttpExecute, l as ResourceEntityClient, ln as FederatedAuthError, m as layer$4, o as LegacyResources, on as CiError, p as ResourcesValue, s as LegacyResourcesLayerOptions, sn as CiErrorCode, u as Resources, un as FederatedAuthErrorCode, v as layerLegacyConfig, zt as layerServerSessionConfig } from "./resources-D_PdfDpJ.js";
|
|
2
|
+
import { $ as layerDirect, A as DEFAULT_FOLLOW_RUN_DEADLINE_MS, J as ChatValue, L as CiStreamPage$1, M as Runs, N as RunsValue, P as layer$5, Q as ExecuteResult, U as DelegatedApplicationRuntimeOptions, W as DelegatedRuntimeState, X as CiClient, Y as layer, Z as CiClientValue, _ as RealtimeTopicFilter, et as layerDirectConfig, g as RealtimeTopic, h as RealtimeChange, j as RunFollowOptions, nt as layerProxy, q as Chat, rt as layerProxyConfig, tt as layerFromExecutor } from "./client-NsqWRz1M.js";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
import * as Config from "effect/Config";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
@@ -142,7 +142,7 @@ declare class DelegatedRuntime extends DelegatedRuntime_base {}
|
|
|
142
142
|
* `FederatedAuth`, `CiClient` and `Runs`. A bad `authBasePath` fails with
|
|
143
143
|
* `configuration_error`; a bad `origin` or `proxyPath` dies with `TypeError`.
|
|
144
144
|
*/
|
|
145
|
-
declare const layer$1: (options: DelegatedApplicationRuntimeOptions) => Layer.Layer<FederatedAuth | CiClient | Runs | DelegatedRuntime, FederatedAuthError, never>;
|
|
145
|
+
declare const layer$1: (options: DelegatedApplicationRuntimeOptions) => Layer.Layer<FederatedAuth | SignIn | CiClient | Runs | DelegatedRuntime, FederatedAuthError, never>;
|
|
146
146
|
/** `layer` with options that Effect `Config` reads. */
|
|
147
|
-
declare const layerConfig: (config: Config.Wrap<DelegatedApplicationRuntimeOptions>) => Layer.Layer<FederatedAuth | CiClient | Runs | DelegatedRuntime, FederatedAuthError | Config.ConfigError, never>;
|
|
148
|
-
export { Chat, type ChatValue, CiClient, type CiClientValue, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, type DelegatedRuntimeValue, type ExecuteResult, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, type FederatedAuthValue, type FixedWorkflowRequest, FixedWorkflows, type FixedWorkflowsLayerOptions, type FixedWorkflowsValue, type LegacyResourceClient, LegacyResources, type LegacyResourcesLayerOptions, type LegacyResourcesValue, type RealtimeChange, RealtimeClient, type RealtimeClientLayerOptions, type RealtimeResync, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeUpdate, type ResourceEntityClient, Resources, type ResourcesFromEntityTransportOptions, type ResourcesLayerOptions, type ResourcesValue, type RunFollowOptions, Runs, type RunsValue, layer as layerChat, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer$1 as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$2 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$3 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$4 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$5 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, makeEntityHttpExecute, subscribe };
|
|
147
|
+
declare const layerConfig: (config: Config.Wrap<DelegatedApplicationRuntimeOptions>) => Layer.Layer<FederatedAuth | SignIn | CiClient | Runs | DelegatedRuntime, FederatedAuthError | Config.ConfigError, never>;
|
|
148
|
+
export { Chat, type ChatValue, CiClient, type CiClientValue, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, type DelegatedRuntimeValue, type ExecuteResult, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, type FederatedAuthValue, type FixedWorkflowRequest, FixedWorkflows, type FixedWorkflowsLayerOptions, type FixedWorkflowsValue, type LegacyResourceClient, LegacyResources, type LegacyResourcesLayerOptions, type LegacyResourcesValue, type RealtimeChange, RealtimeClient, type RealtimeClientLayerOptions, type RealtimeResync, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeUpdate, type ResourceEntityClient, Resources, type ResourcesFromEntityTransportOptions, type ResourcesLayerOptions, type ResourcesValue, type RunFollowOptions, Runs, type RunsValue, SignIn, type SignInStep, type SignInValue, layer as layerChat, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer$1 as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$2 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$3 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$4 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$5 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, makeEntityHttpExecute, subscribe };
|
package/dist/effect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as FederatedAuthErrorCode, i as FederatedAuthError, n as CiErrorCode, r as CiTransportError, t as CiError } from "./errors-DRzZfurr.js";
|
|
2
2
|
import { a as layerConfig$3, c as layerLegacyConfig, f as makeEntityHttpExecute, i as layer$4, n as Resources, o as layerFromEntityTransport, s as layerLegacy, t as LegacyResources } from "./service-B0QOswoK.js";
|
|
3
|
-
import {
|
|
3
|
+
import { C as layerFromExecutor, D as RealtimeClient, O as layer$3, S as layerDirectConfig, T as layerProxyConfig, _ as Runs, a as layer$2, b as CiClient, c as layerFederated, d as layerServerSessionConfig, f as SignIn, g as DEFAULT_FOLLOW_RUN_DEADLINE_MS, i as FixedWorkflows, j as subscribe, k as layerConfig$2, l as layerFederatedConfig, m as layer, n as layer$1, o as layerConfig$1, p as Chat, r as layerConfig, s as FederatedAuth, t as DelegatedRuntime, u as layerServerSession, w as layerProxy, x as layerDirect, y as layer$5 } from "./service-DCSU2Gqc.js";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
/**
|
|
6
6
|
* The wire Schemas of the CI envelopes that `./effect` exports. The Type of
|
|
@@ -30,4 +30,4 @@ const CiStreamPage = Schema.Struct({
|
|
|
30
30
|
events: Schema.mutableKey(Schema.mutable(Schema.Array(Schema.JsonObject))),
|
|
31
31
|
nextCursor: Schema.mutableKey(Schema.NullOr(Schema.String))
|
|
32
32
|
});
|
|
33
|
-
export { Chat, CiClient, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, FixedWorkflows, LegacyResources, RealtimeClient, Resources, Runs, layer as layerChat, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer$1 as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$2 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$3 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$4 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$5 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, makeEntityHttpExecute, subscribe };
|
|
33
|
+
export { Chat, CiClient, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, FixedWorkflows, LegacyResources, RealtimeClient, Resources, Runs, SignIn, layer as layerChat, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer$1 as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$2 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$3 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$4 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$5 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, makeEntityHttpExecute, subscribe };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as ResourceDefinition, $t as
|
|
2
|
-
import { A as DEFAULT_FOLLOW_RUN_DEADLINE_MS, B as FixedWorkflowClientOptions, C as RealtimeStreamEnd, D as FollowRunOptions, E as createFetchEventSourceFactory, F as CiRunCancellation, G as createDelegatedApplicationRuntime, H as DelegatedApplicationRuntime, I as CiStreamEvent, K as ChatClient, L as CiStreamPage, O as FollowRunSource, R as nextStreamCursor, S as RealtimeEventSourceFactory, T as RealtimeStreamHandlers, U as DelegatedApplicationRuntimeOptions, V as createFixedWorkflowClient, W as DelegatedRuntimeState, _ as RealtimeTopicFilter, a as clientSdkProtocolVersion, at as createDirectTransport, b as RealtimeWindow, c as CiError, d as RealtimeClientState, f as RealtimeClientStatus, g as RealtimeTopic, h as RealtimeChange, i as OrganizationClient, it as DirectTransportOptions, k as followRun, l as RealtimeClient, m as createRealtimeClient, n as ClientSdkClient, o as createClient, p as RealtimeTimers, r as ClientSdkEntrypoint, s as IntentsClient, t as ClientDomains, u as RealtimeClientOptions, v as realtimeTopicKey, w as RealtimeStreamEvent, x as RealtimeEventSource, y as RealtimeDocument, z as FixedWorkflowClient } from "./client-
|
|
3
|
-
export { type ChatClient, CiError, type CiErrorCode, type CiResult, type CiRunCancellation, type CiStreamEvent, type CiStreamPage, CiTransportError, type ClientDomains, type ClientFetch, type ClientOperationDefinition, type ClientOperationId, type ClientOperationInput, type ClientOperationMap, type ClientOperationOutput, type ClientSdkClient, type ClientSdkEntrypoint, DEFAULT_FOLLOW_RUN_DEADLINE_MS, type DelegatedApplicationRuntime, type DelegatedApplicationRuntimeOptions, type DelegatedRuntimeState, type DirectTransportOptions, type EntityBatchInput, type EntityBatchOp, type EntityBatchRefusal, type EntityBatchRefusedDetails, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityRestoreInput, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type FederatedAuth, FederatedAuthError, type FederatedAuthErrorCode, type FederatedAuthOptions, type FederatedAuthState, type FederatedSessionIdentity, type FixedWorkflowClient, type FixedWorkflowClientOptions, type FollowRunOptions, type FollowRunSource, type IdempotencyKey, type IntentsClient, type JsonObject, type JsonValue, type KnowledgeQuery, type OperationExecutionOptions, type OperationRequest, type OperationSuccess, type OrganizationClient, type PortableResourceSchema, type ProxyAuthentication, type ProxyTransportOptions, type QueryFilter, type RealtimeChange, type RealtimeClient, type RealtimeClientOptions, type RealtimeClientState, type RealtimeClientStatus, type RealtimeDocument, type RealtimeEventSource, type RealtimeEventSourceFactory, type RealtimeStreamEnd, type RealtimeStreamEvent, type RealtimeStreamHandlers, type RealtimeTimers, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeWindow, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordAccess, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, type SearchQuery, type ServerSessionAuthOptions, type TypedOperationExecutor, type WorkflowInvokeTarget, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFetchEventSourceFactory, createFixedWorkflowClient, createProxyTransport, createRealtimeClient, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, isEntityBatchRefusedError, isEntityReadLimitError, nextStreamCursor, realtimeTopicKey };
|
|
1
|
+
import { $ as ResourceDefinition, $t as ClientOperationInput, A as EntityFileFieldWrite, At as FederatedAuthOptions, B as EntityRequest, Bt as ServerSessionAuth, C as EntityBatchInput, Cn as KnowledgeQuery, Ct as ResourceTransportRequest, D as EntityClient, Dt as createProxyTransport, E as EntityBatchRefusedDetails, En as WorkflowInvokeTarget, Et as ProxyTransportOptions, F as EntityOperation, G as EntityUploadSlot, Gt as SignInMethodsInput, H as EntityTransport, Ht as createServerSessionAuth, I as EntityOperationResult, J as ResourceCapabilities, Jt as SignInStep, K as IdempotencyKey, Kt as SignInSsoInput, L as EntityPage, M as EntityFileWrite, Mt as FederatedSessionIdentity, N as EntityListQuery, Nt as createFederatedAuth, O as EntityCreateInput, Ot as ClientFetch, P as EntityMemberValue, Q as ResourceCursor, Qt as ClientOperationId, R as EntityProtocol, S as createResourceClient, Sn as JsonObject, St as ResourceTransport, T as EntityBatchRefusal, Tn as SearchQuery, Tt as ProxyAuthentication, U as EntityUpdateInput, V as EntityRestoreInput, Vt as ServerSessionAuthOptions, W as EntityUploadInput, Wt as SignInCompleteInput, X as ResourceCreateInput, Xt as SignInVerifyInput, Y as ResourceClient, Z as ResourceCreateRequest, Zt as ClientOperationDefinition, _t as ResourceRecordId, an as isClientOperationId, at as ResourceIdentityField, b as isEntityBatchRefusedError, bt as ResourceRevision, cn as CiTransportError, ct as ResourceLifecycleRequest, dt as ResourceListResult, en as ClientOperationMap, et as ResourceError, fn as CiErrorCode, ft as ResourceMutationInput, gn as OperationSuccess, gt as ResourceRecordAccess, hn as OperationRequest, ht as ResourceRecord, in as clientOperationIds, it as ResourceId, j as EntityFileValue, jt as FederatedAuthState, k as EntityDeleteInput, kt as FederatedAuth, ln as FederatedAuthError, lt as ResourceListQuery, mn as JsonValue, mt as ResourcePaginationMode, n as EntityHttpTransportOptions, nn as OperationExecutionOptions, nt as ResourceFilter, ot as ResourceJsonValue, pn as CiResult, pt as ResourcePagination, q as PortableResourceSchema, qt as SignInStartInput, r as createEntityHttpTransport, rn as TypedOperationExecutor, rt as ResourceGetRequest, st as ResourceLifecycleInput, t as EntityHttpDestination, tn as ClientOperationOutput, tt as ResourceErrorCode, un as FederatedAuthErrorCode, ut as ResourceListRequest, vt as ResourceRequestOptions, w as EntityBatchOp, wn as QueryFilter, wt as ResourceUpdateRequest, x as isEntityReadLimitError, xt as ResourceSort, y as createEntityProtocol, yt as ResourceResult, z as EntityReadLimitDetails } from "./resources-D_PdfDpJ.js";
|
|
2
|
+
import { A as DEFAULT_FOLLOW_RUN_DEADLINE_MS, B as FixedWorkflowClientOptions, C as RealtimeStreamEnd, D as FollowRunOptions, E as createFetchEventSourceFactory, F as CiRunCancellation, G as createDelegatedApplicationRuntime, H as DelegatedApplicationRuntime, I as CiStreamEvent, K as ChatClient, L as CiStreamPage, O as FollowRunSource, R as nextStreamCursor, S as RealtimeEventSourceFactory, T as RealtimeStreamHandlers, U as DelegatedApplicationRuntimeOptions, V as createFixedWorkflowClient, W as DelegatedRuntimeState, _ as RealtimeTopicFilter, a as clientSdkProtocolVersion, at as createDirectTransport, b as RealtimeWindow, c as CiError, d as RealtimeClientState, f as RealtimeClientStatus, g as RealtimeTopic, h as RealtimeChange, i as OrganizationClient, it as DirectTransportOptions, k as followRun, l as RealtimeClient, m as createRealtimeClient, n as ClientSdkClient, o as createClient, p as RealtimeTimers, r as ClientSdkEntrypoint, s as IntentsClient, t as ClientDomains, u as RealtimeClientOptions, v as realtimeTopicKey, w as RealtimeStreamEvent, x as RealtimeEventSource, y as RealtimeDocument, z as FixedWorkflowClient } from "./client-NsqWRz1M.js";
|
|
3
|
+
export { type ChatClient, CiError, type CiErrorCode, type CiResult, type CiRunCancellation, type CiStreamEvent, type CiStreamPage, CiTransportError, type ClientDomains, type ClientFetch, type ClientOperationDefinition, type ClientOperationId, type ClientOperationInput, type ClientOperationMap, type ClientOperationOutput, type ClientSdkClient, type ClientSdkEntrypoint, DEFAULT_FOLLOW_RUN_DEADLINE_MS, type DelegatedApplicationRuntime, type DelegatedApplicationRuntimeOptions, type DelegatedRuntimeState, type DirectTransportOptions, type EntityBatchInput, type EntityBatchOp, type EntityBatchRefusal, type EntityBatchRefusedDetails, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityRestoreInput, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type FederatedAuth, FederatedAuthError, type FederatedAuthErrorCode, type FederatedAuthOptions, type FederatedAuthState, type FederatedSessionIdentity, type FixedWorkflowClient, type FixedWorkflowClientOptions, type FollowRunOptions, type FollowRunSource, type IdempotencyKey, type IntentsClient, type JsonObject, type JsonValue, type KnowledgeQuery, type OperationExecutionOptions, type OperationRequest, type OperationSuccess, type OrganizationClient, type PortableResourceSchema, type ProxyAuthentication, type ProxyTransportOptions, type QueryFilter, type RealtimeChange, type RealtimeClient, type RealtimeClientOptions, type RealtimeClientState, type RealtimeClientStatus, type RealtimeDocument, type RealtimeEventSource, type RealtimeEventSourceFactory, type RealtimeStreamEnd, type RealtimeStreamEvent, type RealtimeStreamHandlers, type RealtimeTimers, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeWindow, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordAccess, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, type SearchQuery, type ServerSessionAuth, type ServerSessionAuthOptions, type SignInCompleteInput, type SignInMethodsInput, type SignInSsoInput, type SignInStartInput, type SignInStep, type SignInVerifyInput, type TypedOperationExecutor, type WorkflowInvokeTarget, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFetchEventSourceFactory, createFixedWorkflowClient, createProxyTransport, createRealtimeClient, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, isEntityBatchRefusedError, isEntityReadLimitError, nextStreamCursor, realtimeTopicKey };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as FederatedAuthError, o as errors_exports, r as CiTransportError } from "./errors-DRzZfurr.js";
|
|
2
2
|
import { C as isClientOperationId, T as createFetchEventSourceFactory, b as proxyHttpOptions, d as createEntityHttpTransport, g as isEntityReadLimitError, h as isEntityBatchRefusedError, m as createEntityProtocol, v as directHttpOptions, w as toCiResult, x as clientOperationIds, y as makeHttpExecute } from "./service-B0QOswoK.js";
|
|
3
|
-
import {
|
|
3
|
+
import { A as makeConnection, C as layerFromExecutor, E as make, F as layerBrowser, I as currentLink, M as realtimeTopicKey, N as layer$3, P as layerFromFactory, _ as Runs, a as layer$2, b as CiClient, c as layerFederated, f as SignIn, g as DEFAULT_FOLLOW_RUN_DEADLINE_MS, h as mapChatOperations, i as FixedWorkflows, n as layer$1, s as FederatedAuth, t as DelegatedRuntime, u as layerServerSession, v as followSource, y as layer } from "./service-DCSU2Gqc.js";
|
|
4
4
|
import { t as createResourceClient } from "./resources-Vd7ESXEA.js";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
import * as Clock from "effect/Clock";
|
|
@@ -79,9 +79,17 @@ const createFederatedAuth = (options) => {
|
|
|
79
79
|
*/
|
|
80
80
|
const createServerSessionAuth = (options) => {
|
|
81
81
|
const runtime = ManagedRuntime.make(layerServerSession(options));
|
|
82
|
+
const run = (step) => runPromise(runtime, SignIn.use(step));
|
|
82
83
|
return {
|
|
83
84
|
...authFacade(runtime),
|
|
84
|
-
close: () => runtime.dispose()
|
|
85
|
+
close: () => runtime.dispose(),
|
|
86
|
+
signIn: {
|
|
87
|
+
complete: (input) => run((signIn) => signIn.complete(input)),
|
|
88
|
+
methods: (input) => run((signIn) => signIn.methods(input)),
|
|
89
|
+
sso: (input) => run((signIn) => signIn.sso(input)),
|
|
90
|
+
start: (input) => run((signIn) => signIn.start(input)),
|
|
91
|
+
verify: (input) => run((signIn) => signIn.verify(input))
|
|
92
|
+
}
|
|
85
93
|
};
|
|
86
94
|
};
|
|
87
95
|
/**
|
|
@@ -3081,6 +3081,97 @@ type OperationExecutionOptions = Readonly<{
|
|
|
3081
3081
|
interface TypedOperationExecutor<Operations extends ClientOperationMap> {
|
|
3082
3082
|
readonly execute: <Id extends ClientOperationId>(operationId: Id, input: ClientOperationInput<Operations, Id>, options?: OperationExecutionOptions) => Promise<CiResult<ClientOperationOutput<Operations, Id>>>;
|
|
3083
3083
|
}
|
|
3084
|
+
/** A sign-in step, as a sign-in route answers it with HTTP 200. */
|
|
3085
|
+
declare const SignInStep: Schema.Union<readonly [Schema.Struct<{
|
|
3086
|
+
readonly emailCode: Schema.Boolean;
|
|
3087
|
+
readonly password: Schema.Boolean;
|
|
3088
|
+
readonly registrationOpen: Schema.Boolean;
|
|
3089
|
+
readonly ssoProviders: Schema.$Array<Schema.Struct<{
|
|
3090
|
+
readonly displayName: Schema.String;
|
|
3091
|
+
readonly id: Schema.String;
|
|
3092
|
+
}>>;
|
|
3093
|
+
readonly step: Schema.Literal<"methods">;
|
|
3094
|
+
}>, Schema.Struct<{
|
|
3095
|
+
readonly attemptsLeft: Schema.Int;
|
|
3096
|
+
readonly step: Schema.Literal<"invalid_code">;
|
|
3097
|
+
}>, Schema.Struct<{
|
|
3098
|
+
readonly allowedDomains: Schema.$Array<Schema.String>;
|
|
3099
|
+
readonly step: Schema.Literal<"email_domain_not_allowed">;
|
|
3100
|
+
}>, Schema.Struct<{
|
|
3101
|
+
readonly provider: Schema.Struct<{
|
|
3102
|
+
readonly displayName: Schema.String;
|
|
3103
|
+
readonly id: Schema.String;
|
|
3104
|
+
}>;
|
|
3105
|
+
readonly step: Schema.Literal<"sso_required">;
|
|
3106
|
+
}>, Schema.Struct<{
|
|
3107
|
+
readonly registered: Schema.Boolean;
|
|
3108
|
+
readonly step: Schema.Literal<"signed_in">;
|
|
3109
|
+
}>, Schema.Struct<{
|
|
3110
|
+
readonly seconds: Schema.Int;
|
|
3111
|
+
readonly step: Schema.Literal<"retry_after">;
|
|
3112
|
+
}>, Schema.Struct<{
|
|
3113
|
+
readonly step: Schema.Literals<readonly ["access_denied", "code_expired", "code_sent", "no_sign_in_method", "redirect_to_web", "registration_required"]>;
|
|
3114
|
+
}>]>;
|
|
3115
|
+
/**
|
|
3116
|
+
* The one result of every `auth.signIn` call. `redirect_to_web` means that
|
|
3117
|
+
* the sign-in continues on the CI page: the SDK has sent the browser there.
|
|
3118
|
+
*/
|
|
3119
|
+
type SignInStep = typeof SignInStep.Type;
|
|
3120
|
+
/** The page that the browser returns to after a sign-in on the CI page; `/` when absent. */
|
|
3121
|
+
type ReturnTarget$1 = Readonly<{
|
|
3122
|
+
returnTo?: string;
|
|
3123
|
+
}>;
|
|
3124
|
+
/** The languages of the person, as `ui_locales`; CI takes them when it opens a challenge. */
|
|
3125
|
+
type Languages = Readonly<{
|
|
3126
|
+
uiLocales?: string;
|
|
3127
|
+
}>;
|
|
3128
|
+
type SignInMethodsInput = ReturnTarget$1 & Languages;
|
|
3129
|
+
type SignInStartInput = ReturnTarget$1 & Languages & Readonly<{
|
|
3130
|
+
email: string;
|
|
3131
|
+
}>;
|
|
3132
|
+
type SignInVerifyInput = ReturnTarget$1 & Readonly<{
|
|
3133
|
+
code: string;
|
|
3134
|
+
}>;
|
|
3135
|
+
type SignInCompleteInput = ReturnTarget$1 & Readonly<{
|
|
3136
|
+
name: string;
|
|
3137
|
+
}>;
|
|
3138
|
+
/** `provider` is the `id` of an SSO provider of a `methods` or `sso_required` step. */
|
|
3139
|
+
type SignInSsoInput = ReturnTarget$1 & Readonly<{
|
|
3140
|
+
provider: string;
|
|
3141
|
+
}>;
|
|
3142
|
+
type SignInCallError = CiTransportError | FederatedAuthError;
|
|
3143
|
+
type SignInValue = Readonly<{
|
|
3144
|
+
/** Opens a Sign-In Challenge and answers the methods that the app allows. */
|
|
3145
|
+
methods: (input?: SignInMethodsInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3146
|
+
/** The email step; it opens a challenge when the browser holds none. */
|
|
3147
|
+
start: (input: SignInStartInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3148
|
+
/** The code step. */
|
|
3149
|
+
verify: (input: SignInVerifyInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3150
|
+
/** The name step of a new person, after `registration_required`. */
|
|
3151
|
+
complete: (input: SignInCompleteInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3152
|
+
/**
|
|
3153
|
+
* Sends the browser to the SSO provider through the BFF, as `beginLogin`
|
|
3154
|
+
* sends it to the CI page; it gives `redirect_to_web`.
|
|
3155
|
+
*/
|
|
3156
|
+
sso: (input: SignInSsoInput) => Effect.Effect<SignInStep, FederatedAuthError>;
|
|
3157
|
+
}>;
|
|
3158
|
+
declare const SignIn_base: Context.ServiceClass<SignIn, "@collective-intelligence/external-apps-client-sdk/SignIn", Readonly<{
|
|
3159
|
+
/** Opens a Sign-In Challenge and answers the methods that the app allows. */
|
|
3160
|
+
methods: (input?: SignInMethodsInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3161
|
+
/** The email step; it opens a challenge when the browser holds none. */
|
|
3162
|
+
start: (input: SignInStartInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3163
|
+
/** The code step. */
|
|
3164
|
+
verify: (input: SignInVerifyInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3165
|
+
/** The name step of a new person, after `registration_required`. */
|
|
3166
|
+
complete: (input: SignInCompleteInput) => Effect.Effect<SignInStep, SignInCallError>;
|
|
3167
|
+
/**
|
|
3168
|
+
* Sends the browser to the SSO provider through the BFF, as `beginLogin`
|
|
3169
|
+
* sends it to the CI page; it gives `redirect_to_web`.
|
|
3170
|
+
*/
|
|
3171
|
+
sso: (input: SignInSsoInput) => Effect.Effect<SignInStep, FederatedAuthError>;
|
|
3172
|
+
}>>;
|
|
3173
|
+
/** `auth.signIn` of a sealed-cookie BFF session; `layerServerSessionAuth` provides it. */
|
|
3174
|
+
declare class SignIn extends SignIn_base {}
|
|
3084
3175
|
type ServerSessionAuthOptions = Readonly<{
|
|
3085
3176
|
basePath: string;
|
|
3086
3177
|
fetch?: ClientFetch;
|
|
@@ -3088,14 +3179,37 @@ type ServerSessionAuthOptions = Readonly<{
|
|
|
3088
3179
|
now?: () => number;
|
|
3089
3180
|
origin?: string;
|
|
3090
3181
|
}>;
|
|
3182
|
+
/**
|
|
3183
|
+
* `FederatedAuth` of a sealed-cookie BFF, with the headless steps of
|
|
3184
|
+
* Embedded Sign-In. Each `signIn` call resolves one `SignInStep`, also for a
|
|
3185
|
+
* refusal such as `invalid_code`; it rejects only with `CiTransportError`,
|
|
3186
|
+
* when it gets no step, or with `FederatedAuthError` `configuration_error`,
|
|
3187
|
+
* when it cannot navigate. The calls run one at a time.
|
|
3188
|
+
*/
|
|
3189
|
+
type ServerSessionAuth = FederatedAuth & Readonly<{
|
|
3190
|
+
close: () => Promise<void>;
|
|
3191
|
+
signIn: Readonly<{
|
|
3192
|
+
/** Opens a Sign-In Challenge and resolves the `methods` step. */
|
|
3193
|
+
methods: (input?: SignInMethodsInput) => Promise<SignInStep>;
|
|
3194
|
+
/** The email step; it opens a challenge when the browser holds none. */
|
|
3195
|
+
start: (input: SignInStartInput) => Promise<SignInStep>;
|
|
3196
|
+
/** The code step. */
|
|
3197
|
+
verify: (input: SignInVerifyInput) => Promise<SignInStep>;
|
|
3198
|
+
/** The name step of a new person, after `registration_required`. */
|
|
3199
|
+
complete: (input: SignInCompleteInput) => Promise<SignInStep>;
|
|
3200
|
+
/**
|
|
3201
|
+
* Sends the browser to the SSO provider through the BFF, as
|
|
3202
|
+
* `beginLogin` sends it to the CI page; it resolves `redirect_to_web`.
|
|
3203
|
+
*/
|
|
3204
|
+
sso: (input: SignInSsoInput) => Promise<SignInStep>;
|
|
3205
|
+
}>;
|
|
3206
|
+
}>;
|
|
3091
3207
|
/**
|
|
3092
3208
|
* Browser session client for a sealed-cookie BFF. The access token never
|
|
3093
3209
|
* leaves the server. A bad option throws `FederatedAuthError`
|
|
3094
3210
|
* `configuration_error`. `close` disposes the runtime of the client.
|
|
3095
3211
|
*/
|
|
3096
|
-
declare const createServerSessionAuth: (options: ServerSessionAuthOptions) =>
|
|
3097
|
-
close: () => Promise<void>;
|
|
3098
|
-
}>;
|
|
3212
|
+
declare const createServerSessionAuth: (options: ServerSessionAuthOptions) => ServerSessionAuth;
|
|
3099
3213
|
type ReturnTarget = Readonly<{
|
|
3100
3214
|
returnTo: string;
|
|
3101
3215
|
}>;
|
|
@@ -3132,12 +3246,15 @@ declare const FederatedAuth_base: Context.ServiceClass<FederatedAuth$1, "@collec
|
|
|
3132
3246
|
declare class FederatedAuth$1 extends FederatedAuth_base {}
|
|
3133
3247
|
/** `FederatedAuth` of browser federated sign-in; a bad option fails with `configuration_error`. */
|
|
3134
3248
|
declare const layerFederated: (options: FederatedAuthOptions) => Layer.Layer<FederatedAuth$1, FederatedAuthError, never>;
|
|
3135
|
-
/**
|
|
3136
|
-
|
|
3249
|
+
/**
|
|
3250
|
+
* `FederatedAuth` and `SignIn` of a sealed-cookie BFF session, over one
|
|
3251
|
+
* Session; a bad option fails with `configuration_error`.
|
|
3252
|
+
*/
|
|
3253
|
+
declare const layerServerSession: (options: ServerSessionAuthOptions) => Layer.Layer<FederatedAuth$1 | SignIn, FederatedAuthError, never>;
|
|
3137
3254
|
/** `layerFederated` with options that Effect `Config` reads. */
|
|
3138
3255
|
declare const layerFederatedConfig: (config: Config.Wrap<FederatedAuthOptions>) => Layer.Layer<FederatedAuth$1, FederatedAuthError | Config.ConfigError, never>;
|
|
3139
3256
|
/** `layerServerSession` with options that Effect `Config` reads. */
|
|
3140
|
-
declare const layerServerSessionConfig: (config: Config.Wrap<ServerSessionAuthOptions>) => Layer.Layer<FederatedAuth$1, FederatedAuthError | Config.ConfigError, never>;
|
|
3257
|
+
declare const layerServerSessionConfig: (config: Config.Wrap<ServerSessionAuthOptions>) => Layer.Layer<FederatedAuth$1 | SignIn, FederatedAuthError | Config.ConfigError, never>;
|
|
3141
3258
|
/**
|
|
3142
3259
|
* The signed-in CI user as the application's BFF reports it: the fields of
|
|
3143
3260
|
* CI's `/oauth/identity`, read live by the server, plus email and name.
|
|
@@ -3812,4 +3929,4 @@ declare const makeEntityHttpExecute: (options: EntityHttpTransportOptions) => En
|
|
|
3812
3929
|
declare const createEntityHttpTransport: (options: EntityHttpTransportOptions) => EntityTransport & Readonly<{
|
|
3813
3930
|
close: () => Promise<void>;
|
|
3814
3931
|
}>;
|
|
3815
|
-
export { ResourceDefinition as $,
|
|
3932
|
+
export { ResourceDefinition as $, ClientOperationInput as $t, EntityFileFieldWrite as A, ExternalApplicationIntentDispatchOutcome as An, FederatedAuthOptions as At, EntityRequest as B, ServerSessionAuth as Bt, EntityBatchInput as C, KnowledgeQuery as Cn, ResourceTransportRequest as Ct, EntityClient as D, AccessCheckResponse as Dn, createProxyTransport as Dt, EntityBatchRefusedDetails as E, WorkflowInvokeTarget as En, ProxyTransportOptions as Et, EntityOperation as F, FederatedAuthValue as Ft, EntityUploadSlot as G, SignInMethodsInput as Gt, EntityTransport as H, createServerSessionAuth as Ht, EntityOperationResult as I, layerFederated as It, ResourceCapabilities as J, SignInStep as Jt, IdempotencyKey as K, SignInSsoInput as Kt, EntityPage as L, layerFederatedConfig as Lt, EntityFileWrite as M, FederatedSessionIdentity as Mt, EntityListQuery as N, createFederatedAuth as Nt, EntityCreateInput as O, AccessTarget as On, ClientFetch as Ot, EntityMemberValue as P, FederatedAuth$1 as Pt, ResourceCursor as Q, ClientOperationId as Qt, EntityProtocol as R, layerServerSession as Rt, createResourceClient as S, JsonObject as Sn, ResourceTransport as St, EntityBatchRefusal as T, SearchQuery as Tn, ProxyAuthentication as Tt, EntityUpdateInput as U, SignIn as Ut, EntityRestoreInput as V, ServerSessionAuthOptions as Vt, EntityUploadInput as W, SignInCompleteInput as Wt, ResourceCreateInput as X, SignInVerifyInput as Xt, ResourceClient as Y, SignInValue as Yt, ResourceCreateRequest as Z, ClientOperationDefinition as Zt, layerLegacy as _, AgentInvokeTarget as _n, ResourceRecordId as _t, LegacyResourceClient as a, isClientOperationId as an, ResourceIdentityField as at, isEntityBatchRefusedError as b, ExternalApplicationChatOperationId as bn, ResourceRevision as bt, LegacyResourcesValue as c, CiTransportError as cn, ResourceLifecycleRequest as ct, ResourcesFromEntityTransportOptions as d, CiError$1 as dn, ResourceListResult as dt, ClientOperationMap as en, ResourceError as et, ResourcesLayerOptions as f, CiErrorCode$1 as fn, ResourceMutationInput as ft, layerFromEntityTransport as g, OperationSuccess as gn, ResourceRecordAccess as gt, layerConfig as h, OperationRequest as hn, ResourceRecord as ht, makeEntityHttpExecute as i, clientOperationIds as in, ResourceId as it, EntityFileValue as j, ExternalApplicationIntentDispatchState as jn, FederatedAuthState as jt, EntityDeleteInput as k, ExternalApplicationIntent as kn, FederatedAuth as kt, ResourceEntityClient as l, FederatedAuthError as ln, ResourceListQuery as lt, layer as m, JsonValue as mn, ResourcePaginationMode as mt, EntityHttpTransportOptions as n, OperationExecutionOptions as nn, ResourceFilter as nt, LegacyResources as o, CiError as on, ResourceJsonValue as ot, ResourcesValue as p, CiResult as pn, ResourcePagination as pt, PortableResourceSchema as q, SignInStartInput as qt, createEntityHttpTransport as r, TypedOperationExecutor as rn, ResourceGetRequest as rt, LegacyResourcesLayerOptions as s, CiErrorCode as sn, ResourceLifecycleInput as st, EntityHttpDestination as t, ClientOperationOutput as tn, ResourceErrorCode as tt, Resources as u, FederatedAuthErrorCode as un, ResourceListRequest as ut, layerLegacyConfig as v, ConversationContinueTarget as vn, ResourceRequestOptions as vt, EntityBatchOp as w, QueryFilter as wn, ResourceUpdateRequest as wt, isEntityReadLimitError as x, ExternalApplicationIntentDispatchInput as xn, ResourceSort as xt, createEntityProtocol as y, ConversationHistory as yn, ResourceResult as yt, EntityReadLimitDetails as z, layerServerSessionConfig as zt };
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ResourceDefinition, A as EntityFileFieldWrite, B as EntityRequest, C as EntityBatchInput, Ct as ResourceTransportRequest, D as EntityClient, E as EntityBatchRefusedDetails, F as EntityOperation, G as EntityUploadSlot, H as EntityTransport, I as EntityOperationResult, J as ResourceCapabilities, K as IdempotencyKey, L as EntityPage, M as EntityFileWrite, N as EntityListQuery, O as EntityCreateInput, P as EntityMemberValue, Q as ResourceCursor, R as EntityProtocol, S as createResourceClient, St as ResourceTransport, T as EntityBatchRefusal, U as EntityUpdateInput, V as EntityRestoreInput, W as EntityUploadInput, X as ResourceCreateInput, Y as ResourceClient, Z as ResourceCreateRequest, _t as ResourceRecordId, at as ResourceIdentityField, b as isEntityBatchRefusedError, bt as ResourceRevision, ct as ResourceLifecycleRequest, dt as ResourceListResult, et as ResourceError, ft as ResourceMutationInput, gt as ResourceRecordAccess, ht as ResourceRecord, it as ResourceId, j as EntityFileValue, k as EntityDeleteInput, lt as ResourceListQuery, mt as ResourcePaginationMode, n as EntityHttpTransportOptions, nt as ResourceFilter, ot as ResourceJsonValue, pt as ResourcePagination, q as PortableResourceSchema, r as createEntityHttpTransport, rt as ResourceGetRequest, st as ResourceLifecycleInput, t as EntityHttpDestination, tt as ResourceErrorCode, ut as ResourceListRequest, vt as ResourceRequestOptions, w as EntityBatchOp, wt as ResourceUpdateRequest, x as isEntityReadLimitError, xt as ResourceSort, y as createEntityProtocol, yt as ResourceResult, z as EntityReadLimitDetails } from "./resources-
|
|
1
|
+
import { $ as ResourceDefinition, A as EntityFileFieldWrite, B as EntityRequest, C as EntityBatchInput, Ct as ResourceTransportRequest, D as EntityClient, E as EntityBatchRefusedDetails, F as EntityOperation, G as EntityUploadSlot, H as EntityTransport, I as EntityOperationResult, J as ResourceCapabilities, K as IdempotencyKey, L as EntityPage, M as EntityFileWrite, N as EntityListQuery, O as EntityCreateInput, P as EntityMemberValue, Q as ResourceCursor, R as EntityProtocol, S as createResourceClient, St as ResourceTransport, T as EntityBatchRefusal, U as EntityUpdateInput, V as EntityRestoreInput, W as EntityUploadInput, X as ResourceCreateInput, Y as ResourceClient, Z as ResourceCreateRequest, _t as ResourceRecordId, at as ResourceIdentityField, b as isEntityBatchRefusedError, bt as ResourceRevision, ct as ResourceLifecycleRequest, dt as ResourceListResult, et as ResourceError, ft as ResourceMutationInput, gt as ResourceRecordAccess, ht as ResourceRecord, it as ResourceId, j as EntityFileValue, k as EntityDeleteInput, lt as ResourceListQuery, mt as ResourcePaginationMode, n as EntityHttpTransportOptions, nt as ResourceFilter, ot as ResourceJsonValue, pt as ResourcePagination, q as PortableResourceSchema, r as createEntityHttpTransport, rt as ResourceGetRequest, st as ResourceLifecycleInput, t as EntityHttpDestination, tt as ResourceErrorCode, ut as ResourceListRequest, vt as ResourceRequestOptions, w as EntityBatchOp, wt as ResourceUpdateRequest, x as isEntityReadLimitError, xt as ResourceSort, y as createEntityProtocol, yt as ResourceResult, z as EntityReadLimitDetails } from "./resources-D_PdfDpJ.js";
|
|
2
2
|
export { type EntityBatchInput, type EntityBatchOp, type EntityBatchRefusal, type EntityBatchRefusedDetails, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityRestoreInput, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type IdempotencyKey, type PortableResourceSchema, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordAccess, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, createEntityHttpTransport, createEntityProtocol, createResourceClient, isEntityBatchRefusedError, isEntityReadLimitError };
|
|
@@ -27,6 +27,7 @@ import * as Stream from "effect/Stream";
|
|
|
27
27
|
import * as Deferred from "effect/Deferred";
|
|
28
28
|
import * as Equal from "effect/Equal";
|
|
29
29
|
import * as Data from "effect/Data";
|
|
30
|
+
import * as Semaphore from "effect/Semaphore";
|
|
30
31
|
import * as Exit from "effect/Exit";
|
|
31
32
|
const topicSetDebounceMilliseconds = 300;
|
|
32
33
|
const pingTimeoutMilliseconds = 45e3;
|
|
@@ -1100,6 +1101,102 @@ const toPublicState = (session) => matchSession(session, {
|
|
|
1100
1101
|
}),
|
|
1101
1102
|
Redirecting: () => ({ status: "redirecting" })
|
|
1102
1103
|
});
|
|
1104
|
+
/**
|
|
1105
|
+
* Embedded Sign-In on the session of a sealed-cookie BFF (ARC-017): the
|
|
1106
|
+
* headless `auth.signIn` steps over the sign-in routes of the server SDK at
|
|
1107
|
+
* `<basePath>/sign-in/*`. Each call gives one `SignInStep` (Q85). It fails
|
|
1108
|
+
* only when it gets no step, with `CiTransportError`: a network error, or an
|
|
1109
|
+
* answer that is not a step with HTTP 200, such as `409 login_conflict` or
|
|
1110
|
+
* `503 user_auth_unavailable`. The calls of one client run one at a time, so
|
|
1111
|
+
* the Sign-In Challenge of the browser gets one request at a time (AC-221).
|
|
1112
|
+
*/
|
|
1113
|
+
const SsoProvider = Schema.Struct({
|
|
1114
|
+
displayName: Schema.String,
|
|
1115
|
+
id: Schema.String
|
|
1116
|
+
});
|
|
1117
|
+
/** A sign-in step, as a sign-in route answers it with HTTP 200. */
|
|
1118
|
+
const SignInStep = Schema.Union([
|
|
1119
|
+
Schema.Struct({
|
|
1120
|
+
emailCode: Schema.Boolean,
|
|
1121
|
+
password: Schema.Boolean,
|
|
1122
|
+
registrationOpen: Schema.Boolean,
|
|
1123
|
+
ssoProviders: Schema.Array(SsoProvider),
|
|
1124
|
+
step: Schema.Literal("methods")
|
|
1125
|
+
}),
|
|
1126
|
+
Schema.Struct({
|
|
1127
|
+
attemptsLeft: Schema.Int,
|
|
1128
|
+
step: Schema.Literal("invalid_code")
|
|
1129
|
+
}),
|
|
1130
|
+
Schema.Struct({
|
|
1131
|
+
allowedDomains: Schema.Array(Schema.String),
|
|
1132
|
+
step: Schema.Literal("email_domain_not_allowed")
|
|
1133
|
+
}),
|
|
1134
|
+
Schema.Struct({
|
|
1135
|
+
provider: SsoProvider,
|
|
1136
|
+
step: Schema.Literal("sso_required")
|
|
1137
|
+
}),
|
|
1138
|
+
Schema.Struct({
|
|
1139
|
+
registered: Schema.Boolean,
|
|
1140
|
+
step: Schema.Literal("signed_in")
|
|
1141
|
+
}),
|
|
1142
|
+
Schema.Struct({
|
|
1143
|
+
seconds: Schema.Int,
|
|
1144
|
+
step: Schema.Literal("retry_after")
|
|
1145
|
+
}),
|
|
1146
|
+
Schema.Struct({ step: Schema.Literals([
|
|
1147
|
+
"access_denied",
|
|
1148
|
+
"code_expired",
|
|
1149
|
+
"code_sent",
|
|
1150
|
+
"no_sign_in_method",
|
|
1151
|
+
"redirect_to_web",
|
|
1152
|
+
"registration_required"
|
|
1153
|
+
]) })
|
|
1154
|
+
]);
|
|
1155
|
+
/** `auth.signIn` of a sealed-cookie BFF session; `layerServerSessionAuth` provides it. */
|
|
1156
|
+
var SignIn = class extends Context.Service()("@collective-intelligence/external-apps-client-sdk/SignIn") {};
|
|
1157
|
+
/** The JSON text of a request body; the bodies are records of strings. */
|
|
1158
|
+
const encodeJsonText$1 = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
1159
|
+
const decodeStep = Schema.decodeUnknownEffect(SignInStep);
|
|
1160
|
+
const fault = (cause) => new CiTransportError({ cause });
|
|
1161
|
+
const redirectToWeb = { step: "redirect_to_web" };
|
|
1162
|
+
/** The step of an answer; any other answer is a fault. */
|
|
1163
|
+
const stepOf = (response) => response.status === 200 ? Effect.tryPromise({
|
|
1164
|
+
catch: fault,
|
|
1165
|
+
try: () => response.json()
|
|
1166
|
+
}).pipe(Effect.flatMap((body) => decodeStep(body).pipe(Effect.mapError(fault)))) : Effect.fail(fault(/* @__PURE__ */ new Error(`The sign-in route answered HTTP ${response.status}`)));
|
|
1167
|
+
const makeSignIn = Effect.fnUntraced(function* makeSignIn(session) {
|
|
1168
|
+
const oneAtATime = (yield* Semaphore.make(1)).withPermits(1);
|
|
1169
|
+
const { fetch } = session;
|
|
1170
|
+
/** One step of the challenge: a POST of the JSON `body` to the route. */
|
|
1171
|
+
const send = (route, { returnTo = "/", ...body }) => Effect.gen(function* sendStep() {
|
|
1172
|
+
const started = session.epoch();
|
|
1173
|
+
const text = yield* encodeJsonText$1(body).pipe(Effect.orDie);
|
|
1174
|
+
const response = yield* Effect.tryPromise({
|
|
1175
|
+
catch: fault,
|
|
1176
|
+
try: (signal) => fetch(session.url(`/sign-in/${route}`), {
|
|
1177
|
+
body: text,
|
|
1178
|
+
credentials: "same-origin",
|
|
1179
|
+
headers: { "content-type": "application/json" },
|
|
1180
|
+
method: "POST",
|
|
1181
|
+
signal
|
|
1182
|
+
})
|
|
1183
|
+
});
|
|
1184
|
+
const step = yield* stepOf(response);
|
|
1185
|
+
if (step.step === "signed_in") yield* session.readSession(started);
|
|
1186
|
+
if (step.step === "redirect_to_web") yield* session.beginLogin({ returnTo });
|
|
1187
|
+
return step;
|
|
1188
|
+
}).pipe(oneAtATime);
|
|
1189
|
+
return SignIn.of({
|
|
1190
|
+
complete: Effect.fn("SignIn.complete")((input) => send("complete", input)),
|
|
1191
|
+
methods: Effect.fn("SignIn.methods")((input) => send("methods", input ?? {})),
|
|
1192
|
+
sso: Effect.fn("SignIn.sso")(({ provider, returnTo = "/" }) => session.redirect(session.url(`/sign-in/sso?${new URLSearchParams({
|
|
1193
|
+
provider,
|
|
1194
|
+
returnTo
|
|
1195
|
+
})}`), returnTo), Effect.as(redirectToWeb), oneAtATime),
|
|
1196
|
+
start: Effect.fn("SignIn.start")((input) => send("start", input)),
|
|
1197
|
+
verify: Effect.fn("SignIn.verify")((input) => send("verify", input))
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1103
1200
|
var FederatedAuth = class extends Context.Service()("@collective-intelligence/external-apps-client-sdk/FederatedAuth") {};
|
|
1104
1201
|
const configurationError = (message) => new FederatedAuthError("configuration_error", message);
|
|
1105
1202
|
const transportError = (cause) => new CiTransportError({ cause });
|
|
@@ -1556,8 +1653,11 @@ const makeServerSession = Effect.fnUntraced(function* makeServerSession(options)
|
|
|
1556
1653
|
const { changes, dispatch, epoch, getState, subscribe } = makeState();
|
|
1557
1654
|
const completion = makeCompletion();
|
|
1558
1655
|
let rememberedReturnTo;
|
|
1559
|
-
|
|
1560
|
-
|
|
1656
|
+
/**
|
|
1657
|
+
* Reads the session of the BFF and settles it under `started`. A logout
|
|
1658
|
+
* increments the epoch, so a read that ends after it changes nothing.
|
|
1659
|
+
*/
|
|
1660
|
+
const readSession = Effect.fnUntraced(function* readSession(started) {
|
|
1561
1661
|
const settle = (session) => {
|
|
1562
1662
|
dispatch(Settled({
|
|
1563
1663
|
epoch: started,
|
|
@@ -1599,17 +1699,26 @@ const makeServerSession = Effect.fnUntraced(function* makeServerSession(options)
|
|
|
1599
1699
|
renewAt: expiresAt
|
|
1600
1700
|
}));
|
|
1601
1701
|
});
|
|
1602
|
-
|
|
1702
|
+
/** A sign-in on a page: the browser leaves for `url`, then returns to `returnTo`. */
|
|
1703
|
+
const redirect = (url, returnTo) => Effect.suspend(() => {
|
|
1603
1704
|
rememberedReturnTo = returnTo;
|
|
1604
|
-
const url = `${origin}${basePath}/login?returnTo=${encodeURIComponent(returnTo)}`;
|
|
1605
1705
|
completion.reset();
|
|
1606
1706
|
dispatch(LoginStarted());
|
|
1607
1707
|
return Effect.as(navigate(url), url);
|
|
1608
1708
|
});
|
|
1609
|
-
|
|
1709
|
+
const beginLogin = ({ returnTo }) => redirect(`${origin}${basePath}/login?returnTo=${encodeURIComponent(returnTo)}`, returnTo);
|
|
1710
|
+
const signIn = yield* makeSignIn({
|
|
1711
|
+
beginLogin,
|
|
1712
|
+
epoch,
|
|
1713
|
+
fetch,
|
|
1714
|
+
readSession,
|
|
1715
|
+
redirect,
|
|
1716
|
+
url: (path) => `${origin}${basePath}${path}`
|
|
1717
|
+
});
|
|
1718
|
+
const auth = FederatedAuth.of({
|
|
1610
1719
|
beginLogin,
|
|
1611
1720
|
changes,
|
|
1612
|
-
completeLogin: () => completion.run(Effect.flatMap(
|
|
1721
|
+
completeLogin: () => completion.run(Effect.flatMap(Effect.suspend(() => readSession(epoch())), () => {
|
|
1613
1722
|
const state = getState();
|
|
1614
1723
|
return state.status === "error" ? Effect.fail(state.error) : Effect.succeed({ returnTo: rememberedReturnTo ?? "/" });
|
|
1615
1724
|
})),
|
|
@@ -1630,11 +1739,15 @@ const makeServerSession = Effect.fnUntraced(function* makeServerSession(options)
|
|
|
1630
1739
|
}),
|
|
1631
1740
|
subscribe
|
|
1632
1741
|
});
|
|
1742
|
+
return Context.make(FederatedAuth, auth).pipe(Context.add(SignIn, signIn));
|
|
1633
1743
|
});
|
|
1634
1744
|
/** `FederatedAuth` of browser federated sign-in; a bad option fails with `configuration_error`. */
|
|
1635
1745
|
const layerFederated = (options) => Layer.effect(FederatedAuth, makeFederated(options));
|
|
1636
|
-
/**
|
|
1637
|
-
|
|
1746
|
+
/**
|
|
1747
|
+
* `FederatedAuth` and `SignIn` of a sealed-cookie BFF session, over one
|
|
1748
|
+
* Session; a bad option fails with `configuration_error`.
|
|
1749
|
+
*/
|
|
1750
|
+
const layerServerSession = (options) => Layer.effectContext(makeServerSession(options));
|
|
1638
1751
|
/** `layerFederated` with options that Effect `Config` reads. */
|
|
1639
1752
|
const layerFederatedConfig = (config) => Layer.unwrap(Effect.map(Config.unwrap(config), layerFederated));
|
|
1640
1753
|
/** `layerServerSession` with options that Effect `Config` reads. */
|
|
@@ -1883,4 +1996,4 @@ const layer = (options) => {
|
|
|
1883
1996
|
};
|
|
1884
1997
|
/** `layer` with options that Effect `Config` reads. */
|
|
1885
1998
|
const layerConfig = (config) => Layer.unwrap(Effect.map(Config.unwrap(config), layer));
|
|
1886
|
-
export {
|
|
1999
|
+
export { makeConnection as A, layerFromExecutor as C, RealtimeClient as D, make$4 as E, layerBrowser as F, currentLink as I, realtimeTopicKey as M, layer$5 as N, layer$4 as O, layerFromFactory as P, layerDirectConfig as S, layerProxyConfig as T, Runs as _, layer$1 as a, CiClient as b, layerFederated as c, layerServerSessionConfig as d, SignIn as f, DEFAULT_FOLLOW_RUN_DEADLINE_MS as g, mapChatOperations as h, FixedWorkflows as i, subscribe as j, layerConfig$2 as k, layerFederatedConfig as l, layer$2 as m, layer as n, layerConfig$1 as o, Chat as p, layerConfig as r, FederatedAuth as s, DelegatedRuntime as t, layerServerSession as u, followSource as v, layerProxy as w, layerDirect as x, layer$3 as y };
|
package/docs/effect.md
CHANGED
|
@@ -23,6 +23,7 @@ reads Effect `Config`.
|
|
|
23
23
|
| `CiClient` | `layerCiClientDirect`, `layerCiClientProxy`, `layerCiClientFromExecutor`, `...Config` | `createClient`, `createDirectTransport`, `createProxyTransport` |
|
|
24
24
|
| `Runs` | `layerRuns` (needs `CiClient`) | `followRun`, `client.runs.follow` |
|
|
25
25
|
| `FederatedAuth` | `layerFederatedAuth`, `layerServerSessionAuth`, `...Config` | `createFederatedAuth`, `createServerSessionAuth` |
|
|
26
|
+
| `SignIn` | `layerServerSessionAuth`, `...Config` (with `FederatedAuth`) | `createServerSessionAuth().signIn` |
|
|
26
27
|
| `FixedWorkflows` | `layerFixedWorkflows`, `layerFixedWorkflowsConfig` | `createFixedWorkflowClient` |
|
|
27
28
|
| `DelegatedRuntime` | `layerDelegatedRuntime`, `layerDelegatedRuntimeConfig` | `createDelegatedApplicationRuntime` |
|
|
28
29
|
| `Resources` | `layerResources`, `layerResourcesConfig`, `layerResourcesFromEntityTransport` | `createResourceClient` (`protocol: "entity"`), `createEntityHttpTransport` |
|
|
@@ -31,6 +32,9 @@ reads Effect `Config`.
|
|
|
31
32
|
|
|
32
33
|
- `CiClient.execute` puts the `CiError` of CI in the error channel;
|
|
33
34
|
`executeResult` keeps the `CiResult` envelope with the correlation id.
|
|
35
|
+
- `SignIn` succeeds with a `SignInStep` for every sign-in outcome; it fails
|
|
36
|
+
only with `CiTransportError` (no step) or `FederatedAuthError`
|
|
37
|
+
`configuration_error` (no navigation).
|
|
34
38
|
- A `...Config` layer takes `Config.Wrap` of the layer options: give each
|
|
35
39
|
field as a `Config`, and a function field as `Config.succeed(fn)`.
|
|
36
40
|
|
package/docs/errors.md
CHANGED
|
@@ -25,6 +25,11 @@ class extends `Error`, and `.` and `/effect` export the same class.
|
|
|
25
25
|
`outcome` `rejected` for a read and `uncertain` for a write.
|
|
26
26
|
- A run that does not finish before `deadlineMs` rejects with `CiError`
|
|
27
27
|
`unavailable` (`retryable: true`).
|
|
28
|
+
- `createServerSessionAuth().signIn` resolves a `SignInStep` for every
|
|
29
|
+
sign-in outcome, also a refusal such as `invalid_code`: branch on `step`.
|
|
30
|
+
It rejects with `CiTransportError` only when it gets no step: a network
|
|
31
|
+
error, or a BFF answer other than a step with HTTP 200 (`cause` names the
|
|
32
|
+
status).
|
|
28
33
|
|
|
29
34
|
## `getAccessToken` failures
|
|
30
35
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/external-apps-client-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Framework-neutral client for Collective Intelligence external applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"ajv-formats": "3.0.1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@collective-intelligence/ai-core": "0.
|
|
65
|
+
"@collective-intelligence/ai-core": "0.6.0",
|
|
66
66
|
"effect": "^4.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@collective-intelligence/ai-core": "0.
|
|
74
|
+
"@collective-intelligence/ai-core": "0.6.0",
|
|
75
75
|
"@effect/eslint-plugin": "0.3.2",
|
|
76
76
|
"@effect/vitest": "4.1.4",
|
|
77
77
|
"@oxlint/plugins": "1.94.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"ultracite": "7.10.7",
|
|
89
89
|
"vitest": "5.0.2"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "94535cc59ece904d4a9374a368edb09222688bb6"
|
|
92
92
|
}
|