@collective-intelligence/external-apps-server-sdk 0.1.5 → 0.1.7
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/README.md +94 -1
- package/dist/admin.d.ts +60 -12
- package/dist/auth/federated.d.ts +4 -0
- package/dist/auth/federated.js +1 -1
- package/dist/express.d.ts +60 -60
- package/dist/gateway/contracts.d.ts +60 -60
- package/dist/gateway.d.ts +60 -60
- package/dist/gateway.js +1 -1
- package/dist/persistence/drizzle.d.ts +4 -0
- package/dist/persistence/drizzle.js +1 -1
- package/dist/runtime/effect.d.ts +75 -75
- package/dist/runtime/effect.js +1 -1
- package/dist/runtime/express.d.ts +60 -60
- package/dist/runtime/nestjs.d.ts +60 -60
- package/dist/runtime/next.d.ts +60 -60
- package/dist/runtime/web.d.ts +60 -60
- package/dist/tools/ai-sdk.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1204,7 +1204,100 @@ The store persists only hashed opaque-cookie state, token grants and revisions;
|
|
|
1204
1204
|
the browser receives a `Secure`, `HttpOnly`, `SameSite=Lax` host cookie. Every
|
|
1205
1205
|
session lookup revalidates the short-lived CI identity. Revoked or expired CI
|
|
1206
1206
|
access ends application authorization on the next validation. A confidential
|
|
1207
|
-
OAuth client may supply `clientSecret`; a public PKCE client omits it.
|
|
1207
|
+
OAuth client may supply `clientSecret`; a public PKCE client omits it. The
|
|
1208
|
+
client type decides how long the User session lasts; see
|
|
1209
|
+
[Session lifetime and renewal](#session-lifetime-and-renewal).
|
|
1210
|
+
|
|
1211
|
+
### Session lifetime and renewal
|
|
1212
|
+
|
|
1213
|
+
`sessionTtlSeconds` sets the Session lifetime: the time from sign-in to the
|
|
1214
|
+
end of the User session. The default is `86400` (one day). The SDK accepts an
|
|
1215
|
+
integer from `300` to `604800` (seven days).
|
|
1216
|
+
|
|
1217
|
+
A User session lasts its Session lifetime only with renewal. Without renewal,
|
|
1218
|
+
the User session ends when its Access token expires, 300 seconds after
|
|
1219
|
+
sign-in, whatever the value of `sessionTtlSeconds`. The Access token lifetime
|
|
1220
|
+
is always 300 seconds. There is no setting for it.
|
|
1221
|
+
|
|
1222
|
+
Renewal needs these three conditions:
|
|
1223
|
+
|
|
1224
|
+
- The external Application is confidential at CI.
|
|
1225
|
+
- `createFederatedAuth` gets the `clientSecret` of that Application.
|
|
1226
|
+
- The user signed in after the upgrade to an SDK version that renews. An
|
|
1227
|
+
earlier cookie or store record holds no Renewal credential. That User
|
|
1228
|
+
session ends at its Access token expiry.
|
|
1229
|
+
|
|
1230
|
+
When the three conditions are true, CI returns a Renewal credential at
|
|
1231
|
+
sign-in. On the wire it is the OAuth `refresh_token`. The SDK keeps it in the
|
|
1232
|
+
session record and uses it to get a new Access token with no browser redirect.
|
|
1233
|
+
The application code does not change.
|
|
1234
|
+
|
|
1235
|
+
A public client has no client secret, so it gets no Renewal credential. Its
|
|
1236
|
+
User session lasts 300 seconds. To continue, the application sends the browser
|
|
1237
|
+
to `<basePath>/login` again, as before. A `fetch` call or a form post cannot
|
|
1238
|
+
follow that redirect. For a public client, `createFederatedAuth` still accepts
|
|
1239
|
+
each `sessionTtlSeconds` value in the range and gives no warning.
|
|
1240
|
+
|
|
1241
|
+
`getSession`, `getAccessToken`, `getEntityContext` and
|
|
1242
|
+
`GET <basePath>/session` are the session lookups. With renewal, each lookup
|
|
1243
|
+
first gets a new Access token when the current one is expired or expires in 30
|
|
1244
|
+
seconds or less. Then it checks the current identity at `/oauth/identity`. A
|
|
1245
|
+
lookup never returns an expired Access token. Lookups at the same time share
|
|
1246
|
+
one renewal request.
|
|
1247
|
+
|
|
1248
|
+
The SDK writes the cookie or the store record one time, at sign-in. A renewal
|
|
1249
|
+
writes no cookie and no store record. A renewed Access token stays only in
|
|
1250
|
+
process memory. Each `createFederatedAuth` instance keeps at most 5000 of
|
|
1251
|
+
them, separate from each other instance. A restart loses them, and the next
|
|
1252
|
+
lookup renews again.
|
|
1253
|
+
|
|
1254
|
+
A Federated authorization is the record that CI keeps of one sign-in to one
|
|
1255
|
+
external Application. It lasts at most 604800 seconds from sign-in, and never
|
|
1256
|
+
longer than the CI session of the user. The User session ends at the earlier
|
|
1257
|
+
of these two times:
|
|
1258
|
+
|
|
1259
|
+
- sign-in plus `sessionTtlSeconds`;
|
|
1260
|
+
- the end of the Federated authorization.
|
|
1261
|
+
|
|
1262
|
+
`expiresAt` of the session reports that end. It is the same at each lookup,
|
|
1263
|
+
because a lookup does not extend the User session. Without a Renewal
|
|
1264
|
+
credential, `expiresAt` stays the Access token expiry.
|
|
1265
|
+
|
|
1266
|
+
A lookup has one of three results:
|
|
1267
|
+
|
|
1268
|
+
- **A session.** CI accepts the identity, after a renewal when one is
|
|
1269
|
+
necessary.
|
|
1270
|
+
- **`null`**, and `401` on `GET <basePath>/session`. CI refuses the user or
|
|
1271
|
+
the Federated authorization: it answers `invalid_grant` to the renewal, or
|
|
1272
|
+
it refuses the identity. The result is also `null` after the end of the User
|
|
1273
|
+
session. Send the user to the login route.
|
|
1274
|
+
- **`ApplicationUserAuthUnavailableError`**, and `503` on
|
|
1275
|
+
`GET <basePath>/session`. The client secret is wrong or rotated
|
|
1276
|
+
(`invalid_client`), CI gives another OAuth error, or CI does not answer. The
|
|
1277
|
+
User session stays. It returns when the fault is corrected, with no
|
|
1278
|
+
sign-in.
|
|
1279
|
+
|
|
1280
|
+
A renewal applies the same admission rule as `/oauth/identity`:
|
|
1281
|
+
|
|
1282
|
+
- the external Application is enabled;
|
|
1283
|
+
- the CI session is live;
|
|
1284
|
+
- the user is not banned and is still admitted to the Organization, which
|
|
1285
|
+
today means the Organization membership of the user and its role;
|
|
1286
|
+
- the scopes of the sign-in are still allowed.
|
|
1287
|
+
|
|
1288
|
+
A refusal ends nothing. When the condition is corrected, the same Renewal
|
|
1289
|
+
credential renews again. A Federated authorization ends for good only by one
|
|
1290
|
+
of these events: logout, a new sign-in in the same User session, its limit of
|
|
1291
|
+
604800 seconds, or the end of the CI session.
|
|
1292
|
+
|
|
1293
|
+
`POST <basePath>/logout` presents the Renewal credential to CI, and CI ends
|
|
1294
|
+
the Federated authorization. If CI does not answer, the route answers `503`
|
|
1295
|
+
and still clears the User session. That Federated authorization then ends at
|
|
1296
|
+
its limit or with its CI session.
|
|
1297
|
+
|
|
1298
|
+
An application that does not use this SDK finds the CI token and logout
|
|
1299
|
+
contract in
|
|
1300
|
+
[Access token renewal](../../../docs/architecture/external-app-gateway.md#access-token-renewal).
|
|
1208
1301
|
|
|
1209
1302
|
### Configure from the CLI enrollment
|
|
1210
1303
|
|
package/dist/admin.d.ts
CHANGED
|
@@ -368,6 +368,11 @@ export type UpdatePackageInstallationRequestEncoded = {
|
|
|
368
368
|
};
|
|
369
369
|
};
|
|
370
370
|
};
|
|
371
|
+
variables?: {
|
|
372
|
+
[key: string]: {
|
|
373
|
+
link: string;
|
|
374
|
+
} | unknown;
|
|
375
|
+
};
|
|
371
376
|
};
|
|
372
377
|
export type PackageOperationAccepted2 = {
|
|
373
378
|
operationId: string;
|
|
@@ -457,6 +462,12 @@ export type ExtensionReleaseManifestEncoded = {
|
|
|
457
462
|
size: number;
|
|
458
463
|
[key: string]: unknown | string | string | "backend" | "dashboard" | "studio" | number | undefined;
|
|
459
464
|
}>;
|
|
465
|
+
media?: Array<{
|
|
466
|
+
digest: string;
|
|
467
|
+
path: string;
|
|
468
|
+
size: number;
|
|
469
|
+
[key: string]: unknown | string | string | number;
|
|
470
|
+
}>;
|
|
460
471
|
package: {
|
|
461
472
|
fqn: string;
|
|
462
473
|
version: string;
|
|
@@ -492,6 +503,11 @@ export type ExtensionReleaseManifestEncoded = {
|
|
|
492
503
|
host: "backend" | "dashboard" | "studio";
|
|
493
504
|
size: number;
|
|
494
505
|
[key: string]: unknown | string | string | "backend" | "dashboard" | "studio" | number | undefined;
|
|
506
|
+
}> | Array<{
|
|
507
|
+
digest: string;
|
|
508
|
+
path: string;
|
|
509
|
+
size: number;
|
|
510
|
+
[key: string]: unknown | string | string | number;
|
|
495
511
|
}> | {
|
|
496
512
|
fqn: string;
|
|
497
513
|
version: string;
|
|
@@ -1537,6 +1553,11 @@ export type ExtensionPackagesInstallData = {
|
|
|
1537
1553
|
};
|
|
1538
1554
|
};
|
|
1539
1555
|
};
|
|
1556
|
+
variables?: {
|
|
1557
|
+
[key: string]: {
|
|
1558
|
+
link: string;
|
|
1559
|
+
} | unknown;
|
|
1560
|
+
};
|
|
1540
1561
|
};
|
|
1541
1562
|
headers: {
|
|
1542
1563
|
authorization?: string;
|
|
@@ -2904,6 +2925,7 @@ export type OrganizationsGetData = {
|
|
|
2904
2925
|
};
|
|
2905
2926
|
export type OrganizationsUpdateData = {
|
|
2906
2927
|
body: {
|
|
2928
|
+
applicationConsentRequired?: boolean;
|
|
2907
2929
|
availableLanguages?: Array<string>;
|
|
2908
2930
|
coverFileId?: string | null;
|
|
2909
2931
|
defaultKnowledgePropertyCase?: "camel_case" | "snake_case";
|
|
@@ -3737,6 +3759,7 @@ export type OrganizationExternalAppsListResponses = {
|
|
|
3737
3759
|
200: {
|
|
3738
3760
|
data: Array<{
|
|
3739
3761
|
allowedOrigins: Array<string>;
|
|
3762
|
+
applicationConsent: "inherit" | "ask" | "skip";
|
|
3740
3763
|
applicationType: "public" | "confidential";
|
|
3741
3764
|
audience: string;
|
|
3742
3765
|
clientId: string;
|
|
@@ -3774,6 +3797,7 @@ export type OrganizationExternalAppsCreateResponses = {
|
|
|
3774
3797
|
201: {
|
|
3775
3798
|
application: {
|
|
3776
3799
|
allowedOrigins: Array<string>;
|
|
3800
|
+
applicationConsent: "inherit" | "ask" | "skip";
|
|
3777
3801
|
applicationType: "public" | "confidential";
|
|
3778
3802
|
audience: string;
|
|
3779
3803
|
clientId: string;
|
|
@@ -3805,6 +3829,7 @@ export type OrganizationExternalAppsCreateResponses = {
|
|
|
3805
3829
|
} | {
|
|
3806
3830
|
application: {
|
|
3807
3831
|
allowedOrigins: Array<string>;
|
|
3832
|
+
applicationConsent: "inherit" | "ask" | "skip";
|
|
3808
3833
|
applicationType: "public" | "confidential";
|
|
3809
3834
|
audience: string;
|
|
3810
3835
|
clientId: string;
|
|
@@ -3843,6 +3868,7 @@ export type OrganizationExternalAppsGetResponses = {
|
|
|
3843
3868
|
*/
|
|
3844
3869
|
200: {
|
|
3845
3870
|
allowedOrigins: Array<string>;
|
|
3871
|
+
applicationConsent: "inherit" | "ask" | "skip";
|
|
3846
3872
|
applicationType: "public" | "confidential";
|
|
3847
3873
|
audience: string;
|
|
3848
3874
|
clientId: string;
|
|
@@ -3875,6 +3901,7 @@ export type OrganizationExternalAppsGetResponse = OrganizationExternalAppsGetRes
|
|
|
3875
3901
|
export type OrganizationExternalAppsUpdateData = {
|
|
3876
3902
|
body: {
|
|
3877
3903
|
allowedOrigins?: Array<string>;
|
|
3904
|
+
applicationConsent?: "inherit" | "ask" | "skip";
|
|
3878
3905
|
audience?: string;
|
|
3879
3906
|
enabled?: boolean;
|
|
3880
3907
|
name?: string;
|
|
@@ -3914,6 +3941,7 @@ export type OrganizationExternalAppsRotateCredentialResponses = {
|
|
|
3914
3941
|
200: {
|
|
3915
3942
|
application: {
|
|
3916
3943
|
allowedOrigins: Array<string>;
|
|
3944
|
+
applicationConsent: "inherit" | "ask" | "skip";
|
|
3917
3945
|
applicationType: "public" | "confidential";
|
|
3918
3946
|
audience: string;
|
|
3919
3947
|
clientId: string;
|
|
@@ -4655,18 +4683,26 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
4655
4683
|
type: string;
|
|
4656
4684
|
}>;
|
|
4657
4685
|
listSsoProviders: (options: Pick<Options$1<OrganizationAuthenticationListProvidersData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<{
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4686
|
+
applicationConsentRequired: boolean;
|
|
4687
|
+
managedSettings: {
|
|
4688
|
+
keys: Array<"identity.name" | "identity.companyDomains" | "branding.logo" | "branding.icon" | "branding.cover" | "authentication.password" | "authentication.otp" | "authentication.sso" | "authentication.applicationConsent" | "locale.defaultLanguage" | "locale.languages" | "locale.timezone" | "governance.accessAuditRetentionMonths" | "governance.maxGroupHierarchyDepth">;
|
|
4689
|
+
packageFqn: string;
|
|
4690
|
+
readonly: boolean;
|
|
4691
|
+
} | null;
|
|
4692
|
+
providers: Array<{
|
|
4693
|
+
connectionId: string | null;
|
|
4694
|
+
connectionName: string | null;
|
|
4695
|
+
connectionStatus: string | null;
|
|
4696
|
+
defaultRole: "organization_admin" | "organization_user";
|
|
4697
|
+
domains: Array<string>;
|
|
4698
|
+
enabled: boolean;
|
|
4699
|
+
id: string;
|
|
4700
|
+
provisionMembers: boolean;
|
|
4701
|
+
testedAt: string | null;
|
|
4702
|
+
testedEmail: string | null;
|
|
4703
|
+
type: string;
|
|
4704
|
+
}>;
|
|
4705
|
+
}>;
|
|
4670
4706
|
testSsoProvider: (options: Pick<Options$1<OrganizationAuthenticationStartSsoTestData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<{
|
|
4671
4707
|
callbackUrl: string;
|
|
4672
4708
|
url: string;
|
|
@@ -6985,6 +7021,7 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
6985
7021
|
teardownId: string;
|
|
6986
7022
|
}>;
|
|
6987
7023
|
get: (options: Pick<Options$1<OrganizationsGetData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<{
|
|
7024
|
+
applicationConsentRequired: boolean;
|
|
6988
7025
|
availableLanguages: Array<string>;
|
|
6989
7026
|
coverFileId: string | null;
|
|
6990
7027
|
createdAt: string | null;
|
|
@@ -6996,6 +7033,11 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
6996
7033
|
iconFileId: string | null;
|
|
6997
7034
|
id: string;
|
|
6998
7035
|
logoFileId: string | null;
|
|
7036
|
+
managedSettings?: {
|
|
7037
|
+
keys: Array<"identity.name" | "identity.companyDomains" | "branding.logo" | "branding.icon" | "branding.cover" | "authentication.password" | "authentication.otp" | "authentication.sso" | "authentication.applicationConsent" | "locale.defaultLanguage" | "locale.languages" | "locale.timezone" | "governance.accessAuditRetentionMonths" | "governance.maxGroupHierarchyDepth">;
|
|
7038
|
+
packageFqn: string;
|
|
7039
|
+
readonly: boolean;
|
|
7040
|
+
} | null;
|
|
6999
7041
|
maxGroupHierarchyDepth: number;
|
|
7000
7042
|
meta: string | null;
|
|
7001
7043
|
name: string;
|
|
@@ -7017,6 +7059,7 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
7017
7059
|
}>;
|
|
7018
7060
|
list: (options: Pick<Options$1<OrganizationsSearchData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<{
|
|
7019
7061
|
data: Array<{
|
|
7062
|
+
applicationConsentRequired: boolean;
|
|
7020
7063
|
availableLanguages: Array<string>;
|
|
7021
7064
|
coverFileId: string | null;
|
|
7022
7065
|
createdAt: string | null;
|
|
@@ -7028,6 +7071,11 @@ declare const createAdministrationApi: (client: Client$1) => {
|
|
|
7028
7071
|
iconFileId: string | null;
|
|
7029
7072
|
id: string;
|
|
7030
7073
|
logoFileId: string | null;
|
|
7074
|
+
managedSettings?: {
|
|
7075
|
+
keys: Array<"identity.name" | "identity.companyDomains" | "branding.logo" | "branding.icon" | "branding.cover" | "authentication.password" | "authentication.otp" | "authentication.sso" | "authentication.applicationConsent" | "locale.defaultLanguage" | "locale.languages" | "locale.timezone" | "governance.accessAuditRetentionMonths" | "governance.maxGroupHierarchyDepth">;
|
|
7076
|
+
packageFqn: string;
|
|
7077
|
+
readonly: boolean;
|
|
7078
|
+
} | null;
|
|
7031
7079
|
maxGroupHierarchyDepth: number;
|
|
7032
7080
|
meta: string | null;
|
|
7033
7081
|
name: string;
|
package/dist/auth/federated.d.ts
CHANGED
|
@@ -125,6 +125,10 @@ declare class FederatedAuthRejectedError extends Error {
|
|
|
125
125
|
export type FederatedGrant = Readonly<{
|
|
126
126
|
accessToken: string;
|
|
127
127
|
expiresAt: number;
|
|
128
|
+
/** Renewal credential of the Federated authorization; set together with `refreshExpiresAt`. */
|
|
129
|
+
refreshToken?: string;
|
|
130
|
+
/** Epoch milliseconds at which the Renewal credential stops; set together with `refreshToken`. */
|
|
131
|
+
refreshExpiresAt?: number;
|
|
128
132
|
}>;
|
|
129
133
|
export type FederatedLogin = Readonly<{
|
|
130
134
|
status: "idle";
|