@sinequa/atomic 2.2.0 → 2.3.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/README.md +28 -1
- package/dist/atomic.cjs +1 -1
- package/dist/atomic.js +2 -2
- package/dist/authentication/constants.d.ts +20 -0
- package/dist/authentication/constants.d.ts.map +1 -1
- package/dist/authentication/events/auth-events.d.ts +71 -0
- package/dist/authentication/events/auth-events.d.ts.map +1 -0
- package/dist/authentication/events/emit-authenticated-event.d.ts +9 -0
- package/dist/authentication/events/emit-authenticated-event.d.ts.map +1 -1
- package/dist/authentication/events/index.d.ts +1 -0
- package/dist/authentication/events/index.d.ts.map +1 -1
- package/dist/authentication/index.d.ts +3 -3
- package/dist/authentication/index.d.ts.map +1 -1
- package/dist/authentication/providers/oauth-authentication.d.ts +10 -1
- package/dist/authentication/providers/oauth-authentication.d.ts.map +1 -1
- package/dist/authentication/providers/redirect-to-identity-provider.d.ts +34 -0
- package/dist/authentication/providers/redirect-to-identity-provider.d.ts.map +1 -0
- package/dist/authentication/providers/saml-authentication.d.ts +10 -1
- package/dist/authentication/providers/saml-authentication.d.ts.map +1 -1
- package/dist/authentication/session/auth-mode-marker.d.ts +7 -0
- package/dist/authentication/session/auth-mode-marker.d.ts.map +1 -1
- package/dist/authentication/session/auth-state.d.ts +6 -1
- package/dist/authentication/session/auth-state.d.ts.map +1 -1
- package/dist/authentication/session/detect-auth-mode.d.ts +2 -1
- package/dist/authentication/session/detect-auth-mode.d.ts.map +1 -1
- package/dist/authentication/session/has-session.d.ts +26 -0
- package/dist/authentication/session/has-session.d.ts.map +1 -0
- package/dist/authentication/session/index.d.ts +2 -0
- package/dist/authentication/session/index.d.ts.map +1 -1
- package/dist/authentication/session/login.d.ts +12 -7
- package/dist/authentication/session/login.d.ts.map +1 -1
- package/dist/authentication/session/logout.d.ts +13 -2
- package/dist/authentication/session/logout.d.ts.map +1 -1
- package/dist/authentication/session/redirect-guard.d.ts +18 -0
- package/dist/authentication/session/redirect-guard.d.ts.map +1 -0
- package/dist/authentication/session/try-auto-authentication.d.ts +5 -2
- package/dist/authentication/session/try-auto-authentication.d.ts.map +1 -1
- package/dist/authentication/session/user-authentication.d.ts +7 -2
- package/dist/authentication/session/user-authentication.d.ts.map +1 -1
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts +10 -5
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
- package/dist/authentication/tokens/get-csrf-token.d.ts +4 -1
- package/dist/authentication/tokens/get-csrf-token.d.ts.map +1 -1
- package/dist/authentication/tokens/get-jwt-token.d.ts +29 -5
- package/dist/authentication/tokens/get-jwt-token.d.ts.map +1 -1
- package/dist/authentication/tokens/get-token.d.ts +7 -1
- package/dist/authentication/tokens/get-token.d.ts.map +1 -1
- package/dist/authentication/tokens/index.d.ts +1 -1
- package/dist/authentication/tokens/index.d.ts.map +1 -1
- package/dist/authentication/tokens/set-token.d.ts +7 -1
- package/dist/authentication/tokens/set-token.d.ts.map +1 -1
- package/dist/client/atomic-context.d.ts +61 -0
- package/dist/client/atomic-context.d.ts.map +1 -0
- package/dist/client/create-api.d.ts +109 -0
- package/dist/client/create-api.d.ts.map +1 -0
- package/dist/client/create-atomic-client.d.ts +138 -0
- package/dist/client/create-atomic-client.d.ts.map +1 -0
- package/dist/client/http-adapter.d.ts +30 -0
- package/dist/client/http-adapter.d.ts.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/configurations/auth-mode.d.ts +51 -1
- package/dist/configurations/auth-mode.d.ts.map +1 -1
- package/dist/configurations/auth-options.d.ts +78 -0
- package/dist/configurations/auth-options.d.ts.map +1 -0
- package/dist/configurations/global.config.d.ts +23 -3
- package/dist/configurations/global.config.d.ts.map +1 -1
- package/dist/configurations/index.d.ts +1 -0
- package/dist/configurations/index.d.ts.map +1 -1
- package/dist/helpers/filters.d.ts +24 -0
- package/dist/helpers/filters.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/pagination.d.ts +23 -0
- package/dist/helpers/pagination.d.ts.map +1 -0
- package/dist/helpers/ts-helper.d.ts +6 -0
- package/dist/helpers/ts-helper.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/polyfills/storage.d.ts +12 -3
- package/dist/polyfills/storage.d.ts.map +1 -1
- package/dist/spfx/index.cjs +1 -1
- package/dist/spfx/index.d.ts +1 -0
- package/dist/spfx/index.d.ts.map +1 -1
- package/dist/spfx/index.js +2 -2
- package/dist/src-1RUu1uXc.cjs +1 -0
- package/dist/src-DFuZeDvd.js +2198 -0
- package/dist/types/search/Result.d.ts +36 -2
- package/dist/types/search/Result.d.ts.map +1 -1
- package/dist/types/search/index.d.ts +1 -1
- package/dist/types/search/index.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +27 -16
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/web-api/helpers/aad-http-client-manager.d.ts +8 -0
- package/dist/web-api/helpers/aad-http-client-manager.d.ts.map +1 -1
- package/dist/web-api/helpers/create-headers.d.ts +9 -0
- package/dist/web-api/helpers/create-headers.d.ts.map +1 -1
- package/dist/web-api/helpers/errors/api-error.d.ts.map +1 -1
- package/dist/web-api/helpers/handle-response.d.ts +17 -1
- package/dist/web-api/helpers/handle-response.d.ts.map +1 -1
- package/dist/web-api/helpers/index.d.ts +1 -1
- package/dist/web-api/helpers/index.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/del.d.ts +13 -11
- package/dist/web-api/helpers/methods/del.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/get.d.ts +6 -12
- package/dist/web-api/helpers/methods/get.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/patch.d.ts +6 -7
- package/dist/web-api/helpers/methods/patch.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/post.d.ts +6 -8
- package/dist/web-api/helpers/methods/post.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/put.d.ts +6 -7
- package/dist/web-api/helpers/methods/put.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/send-request.d.ts +24 -0
- package/dist/web-api/helpers/methods/send-request.d.ts.map +1 -0
- package/dist/web-api/helpers/request-options.d.ts +35 -12
- package/dist/web-api/helpers/request-options.d.ts.map +1 -1
- package/dist/web-api/helpers/utils/build-request-url.d.ts +12 -0
- package/dist/web-api/helpers/utils/build-request-url.d.ts.map +1 -0
- package/dist/web-api/helpers/utils/{date-utils..d.ts → date-utils.d.ts} +1 -1
- package/dist/web-api/helpers/utils/date-utils.d.ts.map +1 -0
- package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts +9 -0
- package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts.map +1 -1
- package/dist/web-api/helpers/utils/with-retry.d.ts +10 -5
- package/dist/web-api/helpers/utils/with-retry.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-aggregation.d.ts +2 -1
- package/dist/web-api/v1/fetch-aggregation.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-app.d.ts +12 -5
- package/dist/web-api/v1/fetch-app.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-audit.d.ts +2 -1
- package/dist/web-api/v1/fetch-audit.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-dataset.d.ts +4 -3
- package/dist/web-api/v1/fetch-dataset.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-labels.d.ts +9 -8
- package/dist/web-api/v1/fetch-labels.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-preview.d.ts +2 -1
- package/dist/web-api/v1/fetch-preview.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-principal.d.ts +8 -4
- package/dist/web-api/v1/fetch-principal.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-query-export.d.ts +2 -1
- package/dist/web-api/v1/fetch-query-export.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-query-intent.d.ts +2 -1
- package/dist/web-api/v1/fetch-query-intent.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-query.d.ts +3 -2
- package/dist/web-api/v1/fetch-query.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-security-principal.d.ts +2 -1
- package/dist/web-api/v1/fetch-security-principal.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-similar-documents.d.ts +2 -1
- package/dist/web-api/v1/fetch-similar-documents.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-sponsored-links.d.ts +2 -1
- package/dist/web-api/v1/fetch-sponsored-links.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-suggest.d.ts +4 -3
- package/dist/web-api/v1/fetch-suggest.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-text-chunk.d.ts +2 -1
- package/dist/web-api/v1/fetch-text-chunk.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-user-settings.d.ts +5 -4
- package/dist/web-api/v1/fetch-user-settings.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-change-password.d.ts +2 -1
- package/dist/web-api/v2/fetch-change-password.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-document-upload-container.d.ts +8 -7
- package/dist/web-api/v2/fetch-document-upload-container.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-forgot-password.d.ts +2 -1
- package/dist/web-api/v2/fetch-forgot-password.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-user-profile.d.ts +5 -4
- package/dist/web-api/v2/fetch-user-profile.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-version.d.ts +2 -1
- package/dist/web-api/v2/fetch-version.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src-BCIlSfZp.js +0 -1923
- package/dist/src-Dg2926V9.cjs +0 -1
- package/dist/web-api/helpers/utils/date-utils..d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"try-auto-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/try-auto-authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"try-auto-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/try-auto-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAQrC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gCAAgC,GAC3C,KAAK,aAAa,KACjB,OAAO,CAAC,OAAO,CAiCjB,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,QAAO,OAAO,CAAC,OAAO,CACN,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
1
2
|
/**
|
|
2
|
-
* Checks if the user is authenticated.
|
|
3
|
+
* Checks if the user is authenticated on the given context.
|
|
3
4
|
*
|
|
4
5
|
* True when a CSRF token is stored, OR when a token-less authenticated session was recorded — the
|
|
5
6
|
* latter covers ambient SSO (IIS Integrated Windows Auth / proxy SSO), where the server authenticates
|
|
6
|
-
* every request but issues no client token, so
|
|
7
|
+
* every request but issues no client token, so the token is `null` despite the user being signed in.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isAuthenticatedWithContext: (ctx: AtomicContext) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the user is authenticated.
|
|
7
12
|
* @returns {boolean} True if the user is authenticated, false otherwise.
|
|
8
13
|
*/
|
|
9
14
|
export declare const isAuthenticated: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/user-authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/user-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAIrC;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,aAAa,KAAG,OACG,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,OACS,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
2
|
+
/** Response of the `deleteWebTokenCookie` challenge action. */
|
|
3
|
+
export type DeleteWebTokenCookieResult = {
|
|
4
|
+
methodresult: string;
|
|
5
|
+
logoutUrl?: string;
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
|
-
* Deletes the JSON Web Token (JWT) cookie by sending a GET request to the backend
|
|
8
|
+
* Deletes the JSON Web Token (JWT) cookie of a context by sending a GET request to the backend.
|
|
3
9
|
* @returns A promise that resolves to the server response, containing `methodresult` set to `"ok"` on success.
|
|
4
10
|
*/
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}>;
|
|
11
|
+
export declare const deleteWebTokenCookieWithContext: (ctx: AtomicContext) => Promise<DeleteWebTokenCookieResult>;
|
|
12
|
+
/** @see deleteWebTokenCookieWithContext */
|
|
13
|
+
export declare const deleteWebTokenCookie: () => Promise<DeleteWebTokenCookieResult>;
|
|
9
14
|
//# sourceMappingURL=delete-web-token-cookie.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-web-token-cookie.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/delete-web-token-cookie.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete-web-token-cookie.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/delete-web-token-cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAKrC,+DAA+D;AAC/D,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,GAC1C,KAAK,aAAa,KACjB,OAAO,CAAC,0BAA0B,CAcpC,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,QAAO,OAAO,CAAC,0BAA0B,CACzB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
1
2
|
/**
|
|
2
|
-
* Retrieves the CSRF token from the backend server.
|
|
3
|
+
* Retrieves the CSRF token from the backend server, on the given context.
|
|
3
4
|
*
|
|
4
5
|
* The endpoint is called with `suppressErrors=true`, so the server answers `200` **without a token**
|
|
5
6
|
* when there is no session (instead of an error status, and without running the auth challenge). A
|
|
@@ -12,5 +13,7 @@
|
|
|
12
13
|
* @returns The CSRF token string, or `null` when the server returns a `200` with no token.
|
|
13
14
|
* @throws The underlying error on a genuine network / timeout / HTTP failure.
|
|
14
15
|
*/
|
|
16
|
+
export declare const getCsrfTokenWithContext: (ctx: AtomicContext) => Promise<string | null>;
|
|
17
|
+
/** @see getCsrfTokenWithContext */
|
|
15
18
|
export declare const getCsrfToken: () => Promise<string | null>;
|
|
16
19
|
//# sourceMappingURL=get-csrf-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-csrf-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-csrf-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-csrf-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-csrf-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAMrC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,aAAa,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CA0BvB,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,YAAY,QAAO,OAAO,CAAC,MAAM,GAAG,IAAI,CACZ,CAAC"}
|
|
@@ -1,16 +1,40 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
1
2
|
import type { Credentials } from "../../types";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Authenticates against `security.webtoken` on the given context.
|
|
5
|
+
*
|
|
6
|
+
* The JWT itself never reaches the client: the server sets it as a cookie (`tokenInCookie`). What
|
|
7
|
+
* comes back — and what this function stores and returns — is the **CSRF token** accompanying it.
|
|
8
|
+
*
|
|
9
|
+
* @param credentials - Username and password. Omit them to authenticate with the context's
|
|
10
|
+
* configured `bearerToken`.
|
|
11
|
+
* @returns A promise that resolves to the CSRF token if successful, or `null` if none is returned.
|
|
12
|
+
* @throws An error if the request fails, or if no bearer token is configured for the
|
|
13
|
+
* credential-less flow.
|
|
14
|
+
*/
|
|
15
|
+
export declare function requestWebTokenSessionWithContext(ctx: AtomicContext, credentials?: Credentials): Promise<string | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Authenticates against `security.webtoken` with the provided credentials.
|
|
18
|
+
*
|
|
19
|
+
* The JWT itself never reaches the client: the server sets it as a cookie (`tokenInCookie`). What
|
|
20
|
+
* comes back — and what this function stores and returns — is the **CSRF token** accompanying it.
|
|
21
|
+
*
|
|
4
22
|
* @param credentials - The user's login credentials (username and password).
|
|
5
23
|
* @returns A promise that resolves to the CSRF token if successful, or `null` if no token is returned.
|
|
6
24
|
* @throws An error if the request to the backend fails.
|
|
7
25
|
*/
|
|
8
|
-
export declare function
|
|
26
|
+
export declare function requestWebTokenSession(credentials: Credentials): Promise<string | null>;
|
|
9
27
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
28
|
+
* Authenticates against `security.webtoken` without explicit credentials, relying on the bearer
|
|
29
|
+
* token configured in `globalConfig`. As above, the returned value is the CSRF token.
|
|
30
|
+
*
|
|
12
31
|
* @returns A promise that resolves to the CSRF token if successful, or `null` if no token is returned.
|
|
13
32
|
* @throws An error if `bearerToken` is missing from `globalConfig` or if the request to the backend fails.
|
|
14
33
|
*/
|
|
15
|
-
export declare function
|
|
34
|
+
export declare function requestWebTokenSession(): Promise<string | null>;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Renamed to {@link requestWebTokenSession}: the name was misleading, as the JWT lands
|
|
37
|
+
* in a cookie and the returned value is the CSRF token. The alias will be removed in the next major.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getJWToken: typeof requestWebTokenSession;
|
|
16
40
|
//# sourceMappingURL=get-jwt-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-jwt-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-jwt-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-jwt-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-jwt-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C;;;;;;;;;;;GAWG;AACH,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,aAAa,EAClB,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA2BxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAC1B;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAKjE;;;GAGG;AACH,eAAO,MAAM,UAAU,+BAAyB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the CSRF token of a context, first checking session storage then local storage.
|
|
4
|
+
* @returns The CSRF token string if found, or `null` if not present in either storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getTokenWithContext: (ctx: AtomicContext) => string | null;
|
|
1
7
|
/**
|
|
2
8
|
* Retrieves the CSRF token, first checking session storage then local storage.
|
|
3
9
|
* @returns The CSRF token string if found, or `null` if not present in either storage.
|
|
4
10
|
*/
|
|
5
|
-
export declare const getToken: () =>
|
|
11
|
+
export declare const getToken: () => string | null;
|
|
6
12
|
//# sourceMappingURL=get-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,aAAa,KAAG,MAAM,GAAG,IA0BjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAO,MAAM,GAAG,IACA,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { deleteWebTokenCookie } from "./delete-web-token-cookie";
|
|
2
2
|
export { getCsrfToken } from "./get-csrf-token";
|
|
3
|
-
export { getJWToken } from "./get-jwt-token";
|
|
3
|
+
export { getJWToken, requestWebTokenSession } from "./get-jwt-token";
|
|
4
4
|
export { getToken } from "./get-token";
|
|
5
5
|
export { setToken } from "./set-token";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { type AtomicContext } from "../../client/atomic-context";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Stores the CSRF token of a context and notifies its `tokenRefreshed` subscribers.
|
|
4
|
+
* @param token The CSRF token to store.
|
|
5
|
+
*/
|
|
6
|
+
export declare const setTokenWithContext: (ctx: AtomicContext, token: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Sets the CSRF token in session storage and notifies the `tokenRefreshed` subscribers.
|
|
3
9
|
* @param token The CSRF token to store.
|
|
4
10
|
*/
|
|
5
11
|
export declare const setToken: (token: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/set-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/set-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,aAAa,EAClB,OAAO,MAAM,KACZ,IAMF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,IACG,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type AuthEventBus } from "../authentication/events/auth-events";
|
|
2
|
+
import type { AtomicLogger, TokenStorage } from "../configurations/auth-options";
|
|
3
|
+
import type { AppGlobalConfig } from "../configurations/global.config";
|
|
4
|
+
import { type HttpAdapter } from "./http-adapter";
|
|
5
|
+
/**
|
|
6
|
+
* Everything the authentication and HTTP layers read at runtime — configuration, event subscribers,
|
|
7
|
+
* storage namespace and transport. Every internal function takes one, so two clients configured for
|
|
8
|
+
* two backends never see each other's state.
|
|
9
|
+
*
|
|
10
|
+
* This is internal plumbing: applications get it through `createAtomicClient()`, and the free
|
|
11
|
+
* functions (`login`, `get`, …) run on {@link defaultContext}.
|
|
12
|
+
*/
|
|
13
|
+
export interface AtomicContext {
|
|
14
|
+
/**
|
|
15
|
+
* Read on every call, never copied — the default context points straight at `globalConfig`, so
|
|
16
|
+
* `setGlobalConfig()` keeps driving the free functions.
|
|
17
|
+
*/
|
|
18
|
+
readonly config: Partial<AppGlobalConfig> & Record<string, unknown>;
|
|
19
|
+
/** Subscribers of this context only. */
|
|
20
|
+
readonly events: AuthEventBus;
|
|
21
|
+
/** Prepended to every Web Storage key, so two clients can keep separate sessions. */
|
|
22
|
+
readonly storagePrefix: string;
|
|
23
|
+
/** Resolved per call, so an SPFx client registered after start-up is still picked up. */
|
|
24
|
+
resolveHttpAdapter(): HttpAdapter | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The context backing the free functions. Its configuration IS `globalConfig` (by reference), and
|
|
28
|
+
* its storage keys are unprefixed — the historical behavior, unchanged.
|
|
29
|
+
*/
|
|
30
|
+
export declare const defaultContext: AtomicContext;
|
|
31
|
+
/**
|
|
32
|
+
* Creates an isolated context on top of its own configuration object.
|
|
33
|
+
*
|
|
34
|
+
* With no `httpAdapter` of its own, the context uses the page's SPFx transport when there is one —
|
|
35
|
+
* exactly like {@link defaultContext}. An SPFx application registers a single `AadHttpClient` for
|
|
36
|
+
* the whole page, and a client created by `provideAtomicClient()` has to go through it too:
|
|
37
|
+
* otherwise its requests leave without the Azure AD bearer token, silently, and the server answers
|
|
38
|
+
* anonymously. Pass an explicit `httpAdapter` to override it — a second client targeting another
|
|
39
|
+
* backend (hence another AAD resource) needs its own.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createContext(options: {
|
|
42
|
+
config: Partial<AppGlobalConfig> & Record<string, unknown>;
|
|
43
|
+
storagePrefix?: string;
|
|
44
|
+
httpAdapter?: HttpAdapter;
|
|
45
|
+
}): AtomicContext;
|
|
46
|
+
/** The logger of a context: the injected one, or the library logger. */
|
|
47
|
+
export declare function contextLogger(ctx: AtomicContext): AtomicLogger;
|
|
48
|
+
/** The `fetch` implementation of a context: the injected one, or the global `fetch`. */
|
|
49
|
+
export declare function contextFetch(ctx: AtomicContext): typeof globalThis.fetch;
|
|
50
|
+
/** The `credentials` mode applied to the requests of a context. Defaults to `"include"`. */
|
|
51
|
+
export declare function contextCredentials(ctx: AtomicContext): RequestCredentials;
|
|
52
|
+
/** The storage backing a scope for a context (injected one, Web Storage, then memory). */
|
|
53
|
+
export declare function contextStorage(ctx: AtomicContext, scope: "session" | "local"): TokenStorage;
|
|
54
|
+
/** Namespaces a storage key with the context prefix. */
|
|
55
|
+
export declare function contextKey(ctx: AtomicContext, key: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Merges a partial configuration into the context's own configuration. On the default context this
|
|
58
|
+
* mutates `globalConfig`, exactly like `setGlobalConfig`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function patchConfig(ctx: AtomicContext, config: Partial<AppGlobalConfig> & Record<string, unknown>): void;
|
|
61
|
+
//# sourceMappingURL=atomic-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-context.d.ts","sourceRoot":"","sources":["../../src/client/atomic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACb,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIvE,O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AAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzD,IAAI,CAEN"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AtomicContext } from "./atomic-context";
|
|
2
|
+
/**
|
|
3
|
+
* The Sinequa API, bound to one client.
|
|
4
|
+
*
|
|
5
|
+
* Same functions as the free `fetchQuery`, `fetchPrincipal`, … exports, minus their trailing
|
|
6
|
+
* context parameter — every call goes to that client's backend, with that client's session.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createApi(ctx: AtomicContext): {
|
|
9
|
+
app: {
|
|
10
|
+
/** Full application configuration. */
|
|
11
|
+
get: (appName?: string | undefined) => Promise<import("..").CCApp>;
|
|
12
|
+
/** Pre-login information (auth providers declared by the server). */
|
|
13
|
+
preLogin: () => Promise<import("..").CCAppPreLogin>;
|
|
14
|
+
};
|
|
15
|
+
principal: {
|
|
16
|
+
get: (options?: import("..").RequestOptions | undefined) => Promise<import("..").Principal>;
|
|
17
|
+
list: (options: {
|
|
18
|
+
search?: string;
|
|
19
|
+
isuser?: boolean;
|
|
20
|
+
isgroup?: boolean;
|
|
21
|
+
}) => Promise<import("..").Principal[]>;
|
|
22
|
+
userid: (userid: string) => Promise<import("..").Principal>;
|
|
23
|
+
userids: (userids: string[]) => Promise<import("..").Principal[]>;
|
|
24
|
+
/** Search-as-you-type lookup over users and groups. */
|
|
25
|
+
search: (params: {
|
|
26
|
+
offset: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
search: string;
|
|
29
|
+
}, signal?: AbortSignal | undefined) => Promise<import("..").SecurityPrincipalSearchResponse>;
|
|
30
|
+
};
|
|
31
|
+
query: {
|
|
32
|
+
search: (query: import("..").Query, audit?: import("..").AuditEvents | undefined, queryIntentData?: import("..").QueryIntentData | undefined) => Promise<import("..").Result>;
|
|
33
|
+
bulk: (queries: import("..").Query[], mode?: "parallel" | undefined, auditEvents?: import("..").AuditEvents | undefined) => Promise<import("..").Result[]>;
|
|
34
|
+
intent: (query: import("..").Query) => Promise<import("..").QueryIntentMatch[]>;
|
|
35
|
+
export: (args_0: {
|
|
36
|
+
model: import("..").ExportQueryModel;
|
|
37
|
+
appName: string;
|
|
38
|
+
query: import("..").Query;
|
|
39
|
+
article?: import("..").Article;
|
|
40
|
+
}) => Promise<Response>;
|
|
41
|
+
aggregate: (aggregation: import("..").Aggregation, query: import("..").Query, audit?: import("..").AuditEvents | undefined) => Promise<import("..").Aggregation>;
|
|
42
|
+
sponsoredLinks: (webservice: string, query: import("..").Query) => Promise<import("..").LinkResult[]>;
|
|
43
|
+
similarDocuments: (documentId: string, queryName: string, signal?: AbortSignal | undefined) => Promise<import("..").Article[]>;
|
|
44
|
+
};
|
|
45
|
+
suggest: {
|
|
46
|
+
get: (suggestQueryName: string, text: string, filter?: Record<string, unknown> | undefined, kinds?: string[] | undefined, showSource?: boolean | undefined) => Promise<import("..").Suggestion[]>;
|
|
47
|
+
query: (suggestQueryName: string, text: string, queryName: string, fields?: string | string[] | undefined) => Promise<import("..").Suggestion[]>;
|
|
48
|
+
field: (text: string, fields: string[], query?: import("..").Query | undefined) => Promise<import("..").Suggestion[]>;
|
|
49
|
+
};
|
|
50
|
+
preview: {
|
|
51
|
+
get: (id: string, q: import("..").Query) => Promise<import("..").PreviewData>;
|
|
52
|
+
textChunks: (id: string, textChunks: import("..").TextLocation[], highlights: string[], query: import("..").Query, leftSentencesCount: number, rightSentencesCount: number) => Promise<{
|
|
53
|
+
chunks: import("..").TextChunk[];
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
labels: {
|
|
57
|
+
get: (prefix: string, publicOnly?: boolean | undefined, locale?: string | undefined) => Promise<string[]>;
|
|
58
|
+
rights: () => Promise<import("..").LabelsRights>;
|
|
59
|
+
add: (labels: string[], ids: string[], publicOnly?: boolean | undefined) => Promise<void>;
|
|
60
|
+
remove: (labels: string[], ids: string[], publicOnly?: boolean | undefined) => Promise<void>;
|
|
61
|
+
rename: (labels: string[], newLabel: string, publicOnly?: boolean | undefined) => Promise<void>;
|
|
62
|
+
delete: (labels: string[], publicOnly?: boolean | undefined) => Promise<void>;
|
|
63
|
+
bulkAdd: (labels: string[], query: import("..").Query, publicOnly?: boolean | undefined) => Promise<void>;
|
|
64
|
+
bulkRemove: (labels: string[], query: import("..").Query, publicOnly?: boolean | undefined) => Promise<void>;
|
|
65
|
+
};
|
|
66
|
+
dataset: {
|
|
67
|
+
get: <T extends import("..").Result = import("..").Result>(webserviceName: string, datasetName: string, parameters?: {} | undefined) => Promise<T>;
|
|
68
|
+
getMany: <T extends import("..").Result = import("..").Result>(webserviceName: string, options: {
|
|
69
|
+
parameters?: {};
|
|
70
|
+
datasets?: string[];
|
|
71
|
+
}) => Promise<import("..").DataSet<T>>;
|
|
72
|
+
list: (webserviceName: string) => Promise<import("..").DatasetDescription[]>;
|
|
73
|
+
};
|
|
74
|
+
userSettings: {
|
|
75
|
+
get: <T>() => Promise<T>;
|
|
76
|
+
save: <T>(userSettings: T, audit?: import("..").AuditEvents | undefined) => Promise<void>;
|
|
77
|
+
patch: <T>(userSettings: Partial<T>, audit?: import("..").AuditEvents | undefined) => Promise<T>;
|
|
78
|
+
reset: () => Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
userProfile: {
|
|
81
|
+
get: (userId: string) => Promise<import("..").UserProfile>;
|
|
82
|
+
create: (userProfile: Partial<import("..").UserProfile>) => Promise<import("..").UserProfile>;
|
|
83
|
+
patch: (userProfile: Partial<Omit<import("..").UserProfile, "modified" | "created">>, category: string, propertyName: string) => Promise<import("..").UserProfile>;
|
|
84
|
+
deleteProperty: (userProfile: Partial<Omit<import("..").UserProfile, "modified" | "created">>, category: string, propertyName: string) => Promise<boolean>;
|
|
85
|
+
};
|
|
86
|
+
containers: {
|
|
87
|
+
list: (params?: {
|
|
88
|
+
page?: number;
|
|
89
|
+
pageSize?: number;
|
|
90
|
+
} | undefined) => Promise<import("..").ContainerListResponse>;
|
|
91
|
+
get: (id: string) => Promise<import("..").Container>;
|
|
92
|
+
create: (body: import("..").CreateContainerInput) => Promise<import("..").Container>;
|
|
93
|
+
update: (id: string, patch: import("..").UpdateContainerInput) => Promise<import("..").Container>;
|
|
94
|
+
delete: (containerIds: string[]) => Promise<import("..").DeleteContainersResult>;
|
|
95
|
+
listDocuments: (id: string, params?: {
|
|
96
|
+
page?: number;
|
|
97
|
+
pageSize?: number;
|
|
98
|
+
} | undefined) => Promise<import("..").ContainerDocumentListResponse>;
|
|
99
|
+
deleteDocuments: (id: string, fileIds: string[]) => Promise<void>;
|
|
100
|
+
};
|
|
101
|
+
password: {
|
|
102
|
+
change: (newPassword: string, currentPassword?: string | undefined) => Promise<import("..").ChangePasswordResponse>;
|
|
103
|
+
sendResetEmail: (userName: string) => Promise<import("..").PasswordResetEmailResponse>;
|
|
104
|
+
};
|
|
105
|
+
version: () => Promise<import("..").VersionResponse>;
|
|
106
|
+
};
|
|
107
|
+
/** The API surface of a client. @see createApi */
|
|
108
|
+
export type AtomicApi = ReturnType<typeof createApi>;
|
|
109
|
+
//# sourceMappingURL=create-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-api.d.ts","sourceRoot":"","sources":["../../src/client/create-api.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBtD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa;;QAGtC,sCAAsC;;QAEtC,qEAAqE;;;;;;;;;;;;QAQrE,uDAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+D5D;AAED,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { AuthEventMap, AuthEventName, Unsubscribe } from "../authentication/events/auth-events";
|
|
2
|
+
import type { AppGlobalConfig } from "../configurations/global.config";
|
|
3
|
+
import type { API_ENDPOINTS, CCAppPreLogin, Credentials } from "../types";
|
|
4
|
+
import { type DeleteOptions } from "../web-api/helpers/methods/del";
|
|
5
|
+
import type { RequestOptions } from "../web-api/helpers/request-options";
|
|
6
|
+
import { type AtomicContext } from "./atomic-context";
|
|
7
|
+
import { type AtomicApi } from "./create-api";
|
|
8
|
+
import type { HttpAdapter } from "./http-adapter";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration of a client created with {@link createAtomicClient}.
|
|
11
|
+
*
|
|
12
|
+
* Derived from {@link AppGlobalConfig} rather than redeclared as a subset: `createAtomicClient`
|
|
13
|
+
* copies **every** key it is handed into the client's configuration, so a type listing only some of
|
|
14
|
+
* them rejected values the client honors nonetheless — `autoOAuthProvider`, `autoSAMLProvider`,
|
|
15
|
+
* `uiLanguage`, `logLevel`, `createRoutes`. Applications worked around it with a cast, which then
|
|
16
|
+
* hid genuine mistakes too.
|
|
17
|
+
*
|
|
18
|
+
* The deprecated `useCredentials` / `useSSO` / `useSAML` booleans are excluded: they are read-only
|
|
19
|
+
* getters defined on `globalConfig` alone and have no equivalent on a client's configuration. Pass
|
|
20
|
+
* an {@link AuthMode} instead.
|
|
21
|
+
*/
|
|
22
|
+
export type AtomicClientConfig = Partial<Omit<AppGlobalConfig, "useCredentials" | "useSSO" | "useSAML">> & {
|
|
23
|
+
/**
|
|
24
|
+
* Sinequa application name. Optional, like every other configuration key: `initializeConfig()`
|
|
25
|
+
* derives it from the browser URL (`/app/<name>`) when it is missing, which is how an SPFx host
|
|
26
|
+
* supplying it at start-up works. Requiring it made spreading an application `environment` — a
|
|
27
|
+
* `Partial<AppGlobalConfig>` — fail to typecheck for no benefit.
|
|
28
|
+
*/
|
|
29
|
+
app?: string;
|
|
30
|
+
/** Transport replacing `fetch` — e.g. `createSpfxHttpAdapter(aadHttpClient)`. */
|
|
31
|
+
httpAdapter?: HttpAdapter;
|
|
32
|
+
/**
|
|
33
|
+
* Prefix applied to the Web Storage keys. Defaults to `""`, so a client shares the session of the
|
|
34
|
+
* free functions — the common case. Give two clients distinct prefixes when they target different
|
|
35
|
+
* backends, otherwise they overwrite each other's token.
|
|
36
|
+
*/
|
|
37
|
+
storagePrefix?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* An isolated Sinequa client: its own configuration, session and event subscribers.
|
|
41
|
+
*
|
|
42
|
+
* @experimental The shape may still change before it replaces the free functions.
|
|
43
|
+
*/
|
|
44
|
+
export interface AtomicClient {
|
|
45
|
+
/** Live view of the client's configuration (mutated by `configure`). */
|
|
46
|
+
readonly config: Readonly<Partial<AppGlobalConfig> & Record<string, unknown>>;
|
|
47
|
+
/**
|
|
48
|
+
* The prefix this client applies to its Web Storage keys — `""` when it shares the session of the
|
|
49
|
+
* free functions.
|
|
50
|
+
*
|
|
51
|
+
* Deliberately **not** part of `config`: the prefix is fixed when the client is created and
|
|
52
|
+
* `configure()` cannot change it, so exposing it there would be settable without effect. Read it
|
|
53
|
+
* to log or debug two clients apart.
|
|
54
|
+
*/
|
|
55
|
+
readonly storagePrefix: string;
|
|
56
|
+
/** Merges values into the client's configuration. */
|
|
57
|
+
configure(config: Partial<AppGlobalConfig> & Record<string, unknown>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the rest of the configuration before anything else runs: `backendUrl` and `app` from
|
|
60
|
+
* the browser URL when they were not provided, then the authentication mode from the server's
|
|
61
|
+
* pre-login response. Call it once, at start-up, before `auth.login()`.
|
|
62
|
+
*/
|
|
63
|
+
initializeConfig(): Promise<CCAppPreLogin>;
|
|
64
|
+
auth: {
|
|
65
|
+
/** @see loginWithContext */
|
|
66
|
+
login(credentials?: Credentials): Promise<boolean>;
|
|
67
|
+
/** @see logoutWithContext */
|
|
68
|
+
logout(): Promise<string | undefined>;
|
|
69
|
+
/** Whether a token or a token-less session is recorded for this client. */
|
|
70
|
+
isAuthenticated(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether a session is available, asking the server when nothing is stored — and **never
|
|
73
|
+
* redirecting**, unlike `login()`. @see hasSessionWithContext
|
|
74
|
+
*/
|
|
75
|
+
hasSession(): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a provider redirect (oauth / saml) is in flight for this client and has not established
|
|
78
|
+
* a session yet. @see isRedirectPendingWithContext
|
|
79
|
+
*/
|
|
80
|
+
isRedirectPending(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Drops the client's local session (tokens, token-less flag, redirect guard) and notifies its
|
|
83
|
+
* subscribers, without any server round-trip. Use `logout()` to also delete the cookie.
|
|
84
|
+
*/
|
|
85
|
+
clearSession(): void;
|
|
86
|
+
/** The stored CSRF token of this client, or `null`. */
|
|
87
|
+
getToken(): string | null;
|
|
88
|
+
/** Stores a CSRF token for this client and notifies its `tokenRefreshed` subscribers. */
|
|
89
|
+
setToken(token: string): void;
|
|
90
|
+
/** Subscribes to this client's authentication events. */
|
|
91
|
+
on<K extends AuthEventName>(event: K, handler: (payload: AuthEventMap[K]) => void): Unsubscribe;
|
|
92
|
+
};
|
|
93
|
+
http: {
|
|
94
|
+
get<T>(endpoint: API_ENDPOINTS, params?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
95
|
+
post<T>(endpoint: API_ENDPOINTS, body: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
96
|
+
put<T>(endpoint: API_ENDPOINTS, body: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
97
|
+
patch<T>(endpoint: API_ENDPOINTS, body: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
98
|
+
del<T>(endpoint: API_ENDPOINTS, params?: URLSearchParams, options?: DeleteOptions): Promise<T>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The Sinequa API bound to this client: `client.api.query.search(query)`,
|
|
102
|
+
* `client.api.principal.get()`, … Same functions as the free `fetchQuery`/`fetchPrincipal`
|
|
103
|
+
* exports, minus their trailing context parameter.
|
|
104
|
+
*/
|
|
105
|
+
api: AtomicApi;
|
|
106
|
+
/** @internal The context every call of this client runs on. */
|
|
107
|
+
readonly context: AtomicContext;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates an independent Sinequa client.
|
|
111
|
+
*
|
|
112
|
+
* Unlike the free functions — which all share `globalConfig` — each client owns its configuration,
|
|
113
|
+
* its event subscribers and (with a `storagePrefix`) its session, so several backends can be
|
|
114
|
+
* queried from the same page.
|
|
115
|
+
*
|
|
116
|
+
* @experimental The shape may still change before it replaces the free functions.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const client = createAtomicClient({ app: "myapp", backendUrl: "https://backend" });
|
|
121
|
+
*
|
|
122
|
+
* client.auth.on("unauthorized", () => client.auth.login());
|
|
123
|
+
* await client.auth.login({ username, password });
|
|
124
|
+
* const results = await client.http.post("api/v1/search.query", { text: "hello" });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function createAtomicClient(config: AtomicClientConfig): AtomicClient;
|
|
128
|
+
/**
|
|
129
|
+
* The client backing the free functions (`login`, `get`, …) — its configuration IS `globalConfig`.
|
|
130
|
+
*
|
|
131
|
+
* Use it to reach the object-oriented API from code that cannot receive a client instance (a
|
|
132
|
+
* distributed web component, a plugin), while keeping the very same session as the rest of the
|
|
133
|
+
* application.
|
|
134
|
+
*
|
|
135
|
+
* @experimental
|
|
136
|
+
*/
|
|
137
|
+
export declare function getDefaultClient(): AtomicClient;
|
|
138
|
+
//# sourceMappingURL=create-atomic-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-atomic-client.d.ts","sourceRoot":"","sources":["../../src/client/create-atomic-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,sCAAsC,CAAC;AAW9C,OAAO,KAAK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AAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,EACH,QAAQ,EAAE,aAAa,EACvB,MAAM,CAAC,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,CAAC,CAAC,CAAC;KACf,CAAC;IAEF;;;;OAIG;IACH,GAAG,EAAE,SAAS,CAAC;IAEf,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC;AAyCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAO3E;AAKD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAE/C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AadHttpClientLike, AadHttpResponseLike } from "../web-api/helpers/aad-http-client-manager";
|
|
2
|
+
/** The request shape an {@link HttpAdapter} receives, mirroring the `fetch` init object. */
|
|
3
|
+
export interface HttpAdapterRequest {
|
|
4
|
+
method: string;
|
|
5
|
+
headers: Headers;
|
|
6
|
+
body?: string;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Transport used instead of `fetch`. It exists for hosts that must issue requests through their own
|
|
11
|
+
* client — the SharePoint `AadHttpClient` being the reference case, since it attaches the Azure AD
|
|
12
|
+
* token itself.
|
|
13
|
+
*/
|
|
14
|
+
export interface HttpAdapter {
|
|
15
|
+
fetch(url: string, request: HttpAdapterRequest): Promise<AadHttpResponseLike | Response>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wraps an SPFx `AadHttpClient` into an {@link HttpAdapter}, so a client can be given the SharePoint
|
|
19
|
+
* transport explicitly instead of relying on the `initializeAadHttpClient` global.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const client = createAtomicClient({
|
|
24
|
+
* app, backendUrl,
|
|
25
|
+
* httpAdapter: createSpfxHttpAdapter(await context.aadHttpClientFactory.getClient(resource)),
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSpfxHttpAdapter(client: AadHttpClientLike): HttpAdapter;
|
|
30
|
+
//# sourceMappingURL=http-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-adapter.d.ts","sourceRoot":"","sources":["../../src/client/http-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,4CAA4C,CAAC;AAEpD,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CACH,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,GAAG,QAAQ,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAyB5E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { AtomicContext } from "./atomic-context";
|
|
2
|
+
export type { AtomicApi } from "./create-api";
|
|
3
|
+
export { type AtomicClient, type AtomicClientConfig, createAtomicClient, getDefaultClient, } from "./create-atomic-client";
|
|
4
|
+
export type { HttpAdapter, HttpAdapterRequest } from "./http-adapter";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|