@sinequa/atomic 2.1.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.
Files changed (186) hide show
  1. package/README.md +28 -1
  2. package/dist/atomic.cjs +1 -1
  3. package/dist/atomic.js +2 -2
  4. package/dist/authentication/constants.d.ts +20 -0
  5. package/dist/authentication/constants.d.ts.map +1 -1
  6. package/dist/authentication/events/auth-events.d.ts +71 -0
  7. package/dist/authentication/events/auth-events.d.ts.map +1 -0
  8. package/dist/authentication/events/emit-authenticated-event.d.ts +9 -0
  9. package/dist/authentication/events/emit-authenticated-event.d.ts.map +1 -1
  10. package/dist/authentication/events/index.d.ts +1 -0
  11. package/dist/authentication/events/index.d.ts.map +1 -1
  12. package/dist/authentication/index.d.ts +3 -3
  13. package/dist/authentication/index.d.ts.map +1 -1
  14. package/dist/authentication/providers/oauth-authentication.d.ts +10 -1
  15. package/dist/authentication/providers/oauth-authentication.d.ts.map +1 -1
  16. package/dist/authentication/providers/redirect-to-identity-provider.d.ts +34 -0
  17. package/dist/authentication/providers/redirect-to-identity-provider.d.ts.map +1 -0
  18. package/dist/authentication/providers/saml-authentication.d.ts +10 -1
  19. package/dist/authentication/providers/saml-authentication.d.ts.map +1 -1
  20. package/dist/authentication/session/auth-mode-marker.d.ts +7 -0
  21. package/dist/authentication/session/auth-mode-marker.d.ts.map +1 -1
  22. package/dist/authentication/session/auth-state.d.ts +6 -1
  23. package/dist/authentication/session/auth-state.d.ts.map +1 -1
  24. package/dist/authentication/session/detect-auth-mode.d.ts +2 -1
  25. package/dist/authentication/session/detect-auth-mode.d.ts.map +1 -1
  26. package/dist/authentication/session/has-session.d.ts +26 -0
  27. package/dist/authentication/session/has-session.d.ts.map +1 -0
  28. package/dist/authentication/session/index.d.ts +2 -0
  29. package/dist/authentication/session/index.d.ts.map +1 -1
  30. package/dist/authentication/session/login.d.ts +12 -7
  31. package/dist/authentication/session/login.d.ts.map +1 -1
  32. package/dist/authentication/session/logout.d.ts +13 -2
  33. package/dist/authentication/session/logout.d.ts.map +1 -1
  34. package/dist/authentication/session/redirect-guard.d.ts +18 -0
  35. package/dist/authentication/session/redirect-guard.d.ts.map +1 -0
  36. package/dist/authentication/session/try-auto-authentication.d.ts +5 -2
  37. package/dist/authentication/session/try-auto-authentication.d.ts.map +1 -1
  38. package/dist/authentication/session/user-authentication.d.ts +7 -2
  39. package/dist/authentication/session/user-authentication.d.ts.map +1 -1
  40. package/dist/authentication/tokens/delete-web-token-cookie.d.ts +10 -5
  41. package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
  42. package/dist/authentication/tokens/get-csrf-token.d.ts +4 -1
  43. package/dist/authentication/tokens/get-csrf-token.d.ts.map +1 -1
  44. package/dist/authentication/tokens/get-jwt-token.d.ts +29 -5
  45. package/dist/authentication/tokens/get-jwt-token.d.ts.map +1 -1
  46. package/dist/authentication/tokens/get-token.d.ts +7 -1
  47. package/dist/authentication/tokens/get-token.d.ts.map +1 -1
  48. package/dist/authentication/tokens/index.d.ts +1 -1
  49. package/dist/authentication/tokens/index.d.ts.map +1 -1
  50. package/dist/authentication/tokens/set-token.d.ts +7 -1
  51. package/dist/authentication/tokens/set-token.d.ts.map +1 -1
  52. package/dist/client/atomic-context.d.ts +61 -0
  53. package/dist/client/atomic-context.d.ts.map +1 -0
  54. package/dist/client/create-api.d.ts +109 -0
  55. package/dist/client/create-api.d.ts.map +1 -0
  56. package/dist/client/create-atomic-client.d.ts +138 -0
  57. package/dist/client/create-atomic-client.d.ts.map +1 -0
  58. package/dist/client/http-adapter.d.ts +30 -0
  59. package/dist/client/http-adapter.d.ts.map +1 -0
  60. package/dist/client/index.d.ts +5 -0
  61. package/dist/client/index.d.ts.map +1 -0
  62. package/dist/configurations/auth-mode.d.ts +51 -1
  63. package/dist/configurations/auth-mode.d.ts.map +1 -1
  64. package/dist/configurations/auth-options.d.ts +78 -0
  65. package/dist/configurations/auth-options.d.ts.map +1 -0
  66. package/dist/configurations/global.config.d.ts +23 -3
  67. package/dist/configurations/global.config.d.ts.map +1 -1
  68. package/dist/configurations/index.d.ts +1 -0
  69. package/dist/configurations/index.d.ts.map +1 -1
  70. package/dist/helpers/filters.d.ts +24 -0
  71. package/dist/helpers/filters.d.ts.map +1 -1
  72. package/dist/helpers/index.d.ts +1 -0
  73. package/dist/helpers/index.d.ts.map +1 -1
  74. package/dist/helpers/pagination.d.ts +23 -0
  75. package/dist/helpers/pagination.d.ts.map +1 -0
  76. package/dist/helpers/ts-helper.d.ts +6 -0
  77. package/dist/helpers/ts-helper.d.ts.map +1 -1
  78. package/dist/index.d.ts +1 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/polyfills/storage.d.ts +12 -3
  81. package/dist/polyfills/storage.d.ts.map +1 -1
  82. package/dist/spfx/index.cjs +1 -1
  83. package/dist/spfx/index.d.ts +1 -0
  84. package/dist/spfx/index.d.ts.map +1 -1
  85. package/dist/spfx/index.js +2 -2
  86. package/dist/src-1RUu1uXc.cjs +1 -0
  87. package/dist/src-DFuZeDvd.js +2198 -0
  88. package/dist/types/api-endpoints.d.ts +1 -1
  89. package/dist/types/api-endpoints.d.ts.map +1 -1
  90. package/dist/types/document-upload/container-document.d.ts +22 -0
  91. package/dist/types/document-upload/container-document.d.ts.map +1 -0
  92. package/dist/types/document-upload/container.d.ts +31 -0
  93. package/dist/types/document-upload/container.d.ts.map +1 -0
  94. package/dist/types/document-upload/index.d.ts +3 -0
  95. package/dist/types/document-upload/index.d.ts.map +1 -0
  96. package/dist/types/index.d.ts +2 -0
  97. package/dist/types/index.d.ts.map +1 -1
  98. package/dist/types/search/Result.d.ts +36 -2
  99. package/dist/types/search/Result.d.ts.map +1 -1
  100. package/dist/types/search/index.d.ts +1 -1
  101. package/dist/types/search/index.d.ts.map +1 -1
  102. package/dist/types/security-principal/index.d.ts +2 -0
  103. package/dist/types/security-principal/index.d.ts.map +1 -0
  104. package/dist/types/security-principal/security-principal.d.ts +25 -0
  105. package/dist/types/security-principal/security-principal.d.ts.map +1 -0
  106. package/dist/utils/logger.d.ts +27 -16
  107. package/dist/utils/logger.d.ts.map +1 -1
  108. package/dist/web-api/helpers/aad-http-client-manager.d.ts +8 -0
  109. package/dist/web-api/helpers/aad-http-client-manager.d.ts.map +1 -1
  110. package/dist/web-api/helpers/create-headers.d.ts +9 -0
  111. package/dist/web-api/helpers/create-headers.d.ts.map +1 -1
  112. package/dist/web-api/helpers/errors/api-error.d.ts.map +1 -1
  113. package/dist/web-api/helpers/handle-response.d.ts +17 -1
  114. package/dist/web-api/helpers/handle-response.d.ts.map +1 -1
  115. package/dist/web-api/helpers/index.d.ts +1 -1
  116. package/dist/web-api/helpers/index.d.ts.map +1 -1
  117. package/dist/web-api/helpers/methods/del.d.ts +13 -11
  118. package/dist/web-api/helpers/methods/del.d.ts.map +1 -1
  119. package/dist/web-api/helpers/methods/get.d.ts +6 -12
  120. package/dist/web-api/helpers/methods/get.d.ts.map +1 -1
  121. package/dist/web-api/helpers/methods/patch.d.ts +6 -7
  122. package/dist/web-api/helpers/methods/patch.d.ts.map +1 -1
  123. package/dist/web-api/helpers/methods/post.d.ts +6 -8
  124. package/dist/web-api/helpers/methods/post.d.ts.map +1 -1
  125. package/dist/web-api/helpers/methods/put.d.ts +6 -7
  126. package/dist/web-api/helpers/methods/put.d.ts.map +1 -1
  127. package/dist/web-api/helpers/methods/send-request.d.ts +24 -0
  128. package/dist/web-api/helpers/methods/send-request.d.ts.map +1 -0
  129. package/dist/web-api/helpers/request-options.d.ts +35 -12
  130. package/dist/web-api/helpers/request-options.d.ts.map +1 -1
  131. package/dist/web-api/helpers/utils/build-request-url.d.ts +12 -0
  132. package/dist/web-api/helpers/utils/build-request-url.d.ts.map +1 -0
  133. package/dist/web-api/helpers/utils/{date-utils..d.ts → date-utils.d.ts} +1 -1
  134. package/dist/web-api/helpers/utils/date-utils.d.ts.map +1 -0
  135. package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts +9 -0
  136. package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts.map +1 -1
  137. package/dist/web-api/helpers/utils/with-retry.d.ts +10 -5
  138. package/dist/web-api/helpers/utils/with-retry.d.ts.map +1 -1
  139. package/dist/web-api/index.d.ts +2 -0
  140. package/dist/web-api/index.d.ts.map +1 -1
  141. package/dist/web-api/v1/fetch-aggregation.d.ts +2 -1
  142. package/dist/web-api/v1/fetch-aggregation.d.ts.map +1 -1
  143. package/dist/web-api/v1/fetch-app.d.ts +12 -5
  144. package/dist/web-api/v1/fetch-app.d.ts.map +1 -1
  145. package/dist/web-api/v1/fetch-audit.d.ts +2 -1
  146. package/dist/web-api/v1/fetch-audit.d.ts.map +1 -1
  147. package/dist/web-api/v1/fetch-dataset.d.ts +4 -3
  148. package/dist/web-api/v1/fetch-dataset.d.ts.map +1 -1
  149. package/dist/web-api/v1/fetch-labels.d.ts +9 -8
  150. package/dist/web-api/v1/fetch-labels.d.ts.map +1 -1
  151. package/dist/web-api/v1/fetch-preview.d.ts +2 -1
  152. package/dist/web-api/v1/fetch-preview.d.ts.map +1 -1
  153. package/dist/web-api/v1/fetch-principal.d.ts +8 -4
  154. package/dist/web-api/v1/fetch-principal.d.ts.map +1 -1
  155. package/dist/web-api/v1/fetch-query-export.d.ts +2 -1
  156. package/dist/web-api/v1/fetch-query-export.d.ts.map +1 -1
  157. package/dist/web-api/v1/fetch-query-intent.d.ts +2 -1
  158. package/dist/web-api/v1/fetch-query-intent.d.ts.map +1 -1
  159. package/dist/web-api/v1/fetch-query.d.ts +3 -2
  160. package/dist/web-api/v1/fetch-query.d.ts.map +1 -1
  161. package/dist/web-api/v1/fetch-security-principal.d.ts +23 -0
  162. package/dist/web-api/v1/fetch-security-principal.d.ts.map +1 -0
  163. package/dist/web-api/v1/fetch-similar-documents.d.ts +2 -1
  164. package/dist/web-api/v1/fetch-similar-documents.d.ts.map +1 -1
  165. package/dist/web-api/v1/fetch-sponsored-links.d.ts +2 -1
  166. package/dist/web-api/v1/fetch-sponsored-links.d.ts.map +1 -1
  167. package/dist/web-api/v1/fetch-suggest.d.ts +4 -3
  168. package/dist/web-api/v1/fetch-suggest.d.ts.map +1 -1
  169. package/dist/web-api/v1/fetch-text-chunk.d.ts +2 -1
  170. package/dist/web-api/v1/fetch-text-chunk.d.ts.map +1 -1
  171. package/dist/web-api/v1/fetch-user-settings.d.ts +5 -4
  172. package/dist/web-api/v1/fetch-user-settings.d.ts.map +1 -1
  173. package/dist/web-api/v2/fetch-change-password.d.ts +2 -1
  174. package/dist/web-api/v2/fetch-change-password.d.ts.map +1 -1
  175. package/dist/web-api/v2/fetch-document-upload-container.d.ts +83 -0
  176. package/dist/web-api/v2/fetch-document-upload-container.d.ts.map +1 -0
  177. package/dist/web-api/v2/fetch-forgot-password.d.ts +2 -1
  178. package/dist/web-api/v2/fetch-forgot-password.d.ts.map +1 -1
  179. package/dist/web-api/v2/fetch-user-profile.d.ts +5 -4
  180. package/dist/web-api/v2/fetch-user-profile.d.ts.map +1 -1
  181. package/dist/web-api/v2/fetch-version.d.ts +2 -1
  182. package/dist/web-api/v2/fetch-version.d.ts.map +1 -1
  183. package/package.json +10 -7
  184. package/dist/src-C3yJArxW.js +0 -1886
  185. package/dist/src-CGNARSYI.cjs +0 -1
  186. package/dist/web-api/helpers/utils/date-utils..d.ts.map +0 -1
package/README.md CHANGED
@@ -80,6 +80,25 @@ Call `initializeAadHttpClient(null)` to detach the client (e.g. in `onDispose`).
80
80
 
81
81
  ## Modules
82
82
 
83
+ ### Client (experimental)
84
+
85
+ `createAtomicClient(config)` returns an isolated client — its own configuration, session and event
86
+ subscribers — exposing `client.config`, `client.auth` and `client.http`. Several clients can target
87
+ different backends from the same page, and each takes its `fetch`/`storage`/`logger` as
88
+ configuration, which removes the need for module mocks in tests.
89
+
90
+ ```typescript
91
+ import { createAtomicClient } from '@sinequa/atomic';
92
+
93
+ const client = createAtomicClient({ app: 'myapp', backendUrl: 'https://backend' });
94
+ client.auth.on('unauthorized', () => client.auth.login());
95
+ const results = await client.http.post('api/v1/search.query', { text: 'hello' });
96
+ ```
97
+
98
+ The free functions below keep working unchanged: they run on a default client whose configuration
99
+ **is** `globalConfig`, and `getDefaultClient()` hands back that very instance — useful from code
100
+ that cannot receive one (a distributed web component, a plugin).
101
+
83
102
  ### Authentication
84
103
 
85
104
  Full auth lifecycle — from first handshake to logout.
@@ -95,6 +114,14 @@ Full auth lifecycle — from first handshake to logout.
95
114
  | `getJWToken(credentials?)` | Fetches a JWT from the server, returns the CSRF token |
96
115
  | `getCsrfToken()` | CSRF token for mutating requests |
97
116
  | `deleteWebTokenCookie()` | Explicitly removes the web token cookie |
117
+ | `onAuthEvent(event, handler)` | Typed subscription to the auth lifecycle (`authenticated`, `unauthorized`, `tokenRefreshed`, `loggedOut`) — returns the unsubscribe function |
118
+ | `tryAutoAuthentication()` | Probes the server for auto-authentication (OIDC) — used by `login()` in `unknown` mode |
119
+ | `tryOAuthAuthentication()` / `trySAMLAuthentication()` | Redirect to the configured identity provider (with a one-shot redirect-loop guard) |
120
+ | `emitAuthenticatedEvent(bool)` | Dispatches the DOM `'authenticated'` CustomEvent (on `document`, bubbles to `window`) |
121
+
122
+ The authentication layer is configurable via `setGlobalConfig({ auth: { … } })` (`AuthOptions`):
123
+ request timeout, auto-auth probe endpoint, injectable storage/logger/fetch, and the requests'
124
+ `credentials` mode.
98
125
 
99
126
  ```typescript
100
127
  import { isAuthenticated, login, logout } from '@sinequa/atomic';
@@ -276,7 +303,7 @@ console.log(globalConfig.backendUrl, globalConfig.authMode.kind);
276
303
  ## Testing
277
304
 
278
305
  ```bash
279
- npm test # run vitest (287 test cases across 25 files)
306
+ npm test # run the vitest suite
280
307
  npm test -- --ui # interactive UI
281
308
  ```
282
309
 
package/dist/atomic.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-CGNARSYI.cjs");exports.API=e.F,exports.ApiError=e.Ut,exports.Audit=e.$,exports.AuditEventType=e.wt,exports.AuthMode=e.Dn,exports.DidYouMeanKind=e.bt,exports.EngineType=e.Ct,exports.EngineTypeModifier=e.St,exports.LogLevel=e.rn,exports.MINIMUM_COMPATIBLE_SERVER_API_VERSION=e.xt,exports.RFMDisplay=e.yt,exports.ServerError=e.Ht,exports.TimeoutError=e.Vt,exports.UnauthorizedError=e.Bt,exports.addAuditAdditionalInfo=e.et,exports.addConcepts=e.fn,exports.addSessionId=e.tt,exports.addUrl=e.nt,exports.aggItemRegex=e.yn,exports.aggregationItemStrictCompare=e.bn,exports.appInitializerFn=e.q,exports.bisect=e.vn,exports.buildPathsAndLevels=e.M,exports.clearSessionTokens=e.n,exports.configureLogger=e.in,exports.createHeaders=e.Wt,exports.createTimeoutController=e.At,exports.createUserProfile=e.m,exports.debug=e.an,exports.del=e.Ft,exports.deleteUserProfileProperty=e.h,exports.deleteUserSettings=e.b,exports.deleteWebTokenCookie=e.i,exports.detectAuthMode=e.Z,exports.emitAuthenticatedEvent=e.kn,exports.error=e.on,exports.escapeExpr=e.rt,exports.expiresSoon=e.Dt,exports.extraColumns=e._t,exports.fetchAggregation=e.Q,exports.fetchApp=e.J,exports.fetchAppPreLogin=e.Y,exports.fetchBulkQuery=e.N,exports.fetchChangePassword=e.y,exports.fetchDataset=e.W,exports.fetchDatasetList=e.G,exports.fetchDatasets=e.K,exports.fetchLabels=e.H,exports.fetchPreview=e.B,exports.fetchPreviewUrl=e.V,exports.fetchPrincipal=e.I,exports.fetchPrincipalList=e.L,exports.fetchPrincipalUserid=e.R,exports.fetchPrincipalUserids=e.z,exports.fetchQuery=e.P,exports.fetchQueryExport=e.j,exports.fetchQueryIntent=e.A,exports.fetchSendPasswordResetEmail=e.v,exports.fetchSimilarDocuments=e.k,exports.fetchSponsoredLinks=e.O,exports.fetchSuggest=e.T,exports.fetchSuggestField=e.E,exports.fetchSuggestQuery=e.D,exports.fetchTextChunks=e.w,exports.fetchUserProfile=e.g,exports.fetchUserSettings=e.x,exports.fetchVersion=e.p,exports.filter=e.ht,exports.get=e.Pt,exports.getConcepts=e.pn,exports.getCsrfToken=e.l,exports.getFiltersFromURI=e.qt,exports.getFiltersFromUrl=e.Jt,exports.getHelpIndexUrl=e.Gt,exports.getIdFromUrl=e.Yt,exports.getJWToken=e.c,exports.getMetadata=e.pt,exports.getMetadataWithValues=e.mt,exports.getOffsetFromDates=e.un,exports.getQueryPageFromUrl=e.Xt,exports.getQueryParamsFromUrl=e.Zt,exports.getQueryTabFromUrl=e.Qt,exports.getQueryTextFromUrl=e.$t,exports.getRelativeDate=e.dn,exports.getTime=e.it,exports.getToken=e.s,exports.getUrlParamsFromQueryParams=e.en,exports.globalConfig=e.Tn,exports.guid=e.at,exports.handleResponse=e.zt,exports.info=e.sn,exports.initializeAppConfig=e.X,exports.isArrayBuffer=e.ot,exports.isAuthenticated=e.t,exports.isBlob=e.st,exports.isDate=e.ct,exports.isExpired=e.Ot,exports.isJsonable=e.lt,exports.isNotInputEvent=e.ln,exports.isObject=e.ut,exports.isString=e.dt,exports.labels=e.U,exports.legacyBooleansToAuthMode=e.On,exports.legacyFilterToFilter=e.gt,exports.login=e.a,exports.logout=e.r,exports.makeColumn=e.vt,exports.notify=e.nn,exports.openParentNodes=e.xn,exports.parseText=e.mn,exports.parseValueAndOperatorFromItem=e.Sn,exports.patch=e.Nt,exports.patchUserProfile=e._,exports.patchUserSettings=e.S,exports.post=e.Mt,exports.put=e.jt,exports.queryParamsFromUrl=e.tn,exports.removeConcept=e.hn,exports.removeConcepts=e.gn,exports.resolveNoAutoAuthentication=e.It,exports.resolveToColumnName=e.Tt,exports.rewriteText=e._n,exports.saveUserSettings=e.C,exports.setGlobalConfig=e.En,exports.setToken=e.u,exports.sha512=e.ft,exports.suggestionsToTreeAggregationNodes=e.Cn,exports.sysLang=e.Kt,exports.toDate=e.kt,exports.translateAggregationToDateOptions=e.wn,exports.tryAutoAuthentication=e.o,exports.tryOAuthAuthentication=e.f,exports.trySAMLAuthentication=e.d,exports.warn=e.cn,exports.withRetry=e.Et;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-1RUu1uXc.cjs");exports.API=e.st,exports.ApiError=e.In,exports.Audit=e.bt,exports.AuditEventType=e.Kt,exports.AuthMode=e.qn,exports.DidYouMeanKind=e.Ht,exports.EngineType=e.Gt,exports.EngineTypeModifier=e.Wt,exports.LogLevel=e.$n,exports.MINIMUM_COMPATIBLE_SERVER_API_VERSION=e.Ut,exports.RFMDisplay=e.Vt,exports.ServerError=e.Nn,exports.TimeoutError=e.En,exports.UnauthorizedError=e.Fn,exports.addAuditAdditionalInfo=e.xt,exports.addConcepts=e.g,exports.addSessionId=e.St,exports.addUrl=e.Ct,exports.aggItemRegex=e.C,exports.aggregationItemStrictCompare=e.w,exports.appInitializerFn=e.Qt,exports.applyConfig=e.Wn,exports.assertNever=e._n,exports.bisect=e.S,exports.buildPathsAndLevels=e.it,exports.clearSessionTokens=e.un,exports.configureLogger=e.er,exports.createAtomicClient=e.k,exports.createContainer=e.L,exports.createHeaders=e.Ln,exports.createHeadersWithContext=e.Rn,exports.createTimeoutController=e.Tn,exports.createUserProfile=e.M,Object.defineProperty(exports,"debug",{enumerable:!0,get:function(){return e.tr}}),exports.del=e.on,exports.delWithContext=e.sn,exports.deleteContainerDocuments=e.R,exports.deleteContainers=e.z,exports.deleteUserProfileProperty=e.N,exports.deleteUserSettings=e.G,exports.deleteWebTokenCookie=e.fn,exports.detectAuthMode=e.Sn,exports.emitAuthenticatedEvent=e.Bn,Object.defineProperty(exports,"error",{enumerable:!0,get:function(){return e.nr}}),exports.escapeExpr=e.wt,exports.expiresSoon=e.Yt,exports.extraColumns=e.zt,exports.fetchAggregation=e.yt,exports.fetchApp=e.$t,exports.fetchAppPreLogin=e.en,exports.fetchBulkQuery=e.at,exports.fetchChangePassword=e.W,exports.fetchDataset=e.gt,exports.fetchDatasetList=e._t,exports.fetchDatasets=e.vt,exports.fetchLabels=e.mt,exports.fetchPreview=e.ft,exports.fetchPreviewUrl=e.pt,exports.fetchPrincipal=e.ct,exports.fetchPrincipalList=e.lt,exports.fetchPrincipalUserid=e.ut,exports.fetchPrincipalUserids=e.dt,exports.fetchQuery=e.ot,exports.fetchQueryExport=e.rt,exports.fetchQueryIntent=e.nt,exports.fetchSendPasswordResetEmail=e.I,exports.fetchSimilarDocuments=e.et,exports.fetchSponsoredLinks=e.$,exports.fetchSuggest=e.X,exports.fetchSuggestField=e.Z,exports.fetchSuggestQuery=e.Q,exports.fetchTextChunks=e.Y,exports.fetchUserProfile=e.P,exports.fetchUserSettings=e.K,exports.fetchVersion=e.j,exports.filter=e.Lt,exports.get=e.bn,exports.getConcepts=e._,exports.getContainer=e.B,exports.getCsrfToken=e.yn,exports.getDefaultClient=e.A,exports.getFiltersFromURI=e.r,exports.getFiltersFromUrl=e.i,exports.getHelpIndexUrl=e.t,exports.getIdFromUrl=e.a,exports.getJWToken=e.hn,exports.getMetadata=e.Ft,exports.getMetadataWithValues=e.It,exports.getOffsetFromDates=e.m,exports.getQueryPageFromUrl=e.o,exports.getQueryParamsFromUrl=e.s,exports.getQueryTabFromUrl=e.c,exports.getQueryTextFromUrl=e.l,exports.getRelativeDate=e.h,exports.getTime=e.Tt,exports.getToken=e.zn,exports.getUrlParamsFromQueryParams=e.u,exports.getWithContext=e.xn,exports.globalConfig=e.Gn,exports.guid=e.Et,exports.handleResponse=e.jn,exports.handleResponseWithContext=e.Mn,exports.hasSession=e.vn,Object.defineProperty(exports,"info",{enumerable:!0,get:function(){return e.rr}}),exports.initializeAppConfig=e.tn,exports.isArrayBuffer=e.Dt,exports.isAuthenticated=e.cn,exports.isBlob=e.Ot,exports.isDate=e.kt,exports.isExpired=e.Xt,exports.isExternalAuthMode=e.Jn,exports.isJsonable=e.At,exports.isNotInputEvent=e.p,exports.isObject=e.jt,exports.isRedirectPending=e.ln,exports.isString=e.Mt,exports.labels=e.ht,exports.legacyBooleansToAuthMode=e.Yn,exports.legacyFilterToFilter=e.Rt,exports.listContainerDocuments=e.V,exports.listContainers=e.H,exports.login=e.pn,exports.logout=e.dn,exports.makeColumn=e.Bt,exports.notify=e.f,exports.onAuthEvent=e.ar,exports.openParentNodes=e.T,exports.parseText=e.v,exports.parseValueAndOperatorFromItem=e.E,exports.patch=e.in,exports.patchUserProfile=e.F,exports.patchUserSettings=e.q,exports.patchWithContext=e.an,exports.post=e.Dn,exports.postWithContext=e.On,exports.put=e.nn,exports.putWithContext=e.rn,exports.queryParamsFromUrl=e.d,exports.removeConcept=e.y,exports.removeConcepts=e.b,exports.requestWebTokenSession=e.gn,exports.resolveBearerToken=e.Xn,exports.resolveNoAutoAuthentication=e.kn,exports.resolveNoAutoAuthenticationWithContext=e.An,exports.resolveOAuthProvider=e.Zn,exports.resolveSAMLProvider=e.Qn,exports.resolveToColumnName=e.qt,exports.resultPages=e.Pt,exports.rewriteText=e.x,exports.saveUserSettings=e.J,exports.searchPrincipals=e.tt,exports.setGlobalConfig=e.Kn,exports.setToken=e.Pn,exports.sha512=e.Nt,exports.suggestionsToTreeAggregationNodes=e.D,exports.sysLang=e.n,exports.toDate=e.Zt,exports.translateAggregationToDateOptions=e.O,exports.tryAutoAuthentication=e.mn,exports.tryOAuthAuthentication=e.wn,exports.trySAMLAuthentication=e.Cn,exports.updateContainer=e.U,Object.defineProperty(exports,"warn",{enumerable:!0,get:function(){return e.ir}}),exports.withRetry=e.Jt;
package/dist/atomic.js CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as e, $t as t, A as n, At as r, B as i, Bt as a, C as o, Cn as s, Ct as c, D as l, Dn as u, Dt as d, E as f, En as p, Et as m, F as h, Ft as g, G as _, Gt as v, H as y, Ht as b, I as x, It as S, J as C, Jt as w, K as T, Kt as E, L as D, M as O, Mt as k, N as A, Nt as j, O as M, On as N, Ot as P, P as F, Pt as I, Q as L, Qt as R, R as z, S as B, Sn as V, St as H, T as U, Tn as W, Tt as G, U as K, Ut as q, V as J, Vt as Y, W as X, Wt as Z, X as Q, Xt as $, Y as ee, Yt as te, Z as ne, Zt as re, _ as ie, _n as ae, _t as oe, a as se, an as ce, at as le, b as ue, bn as de, bt as fe, c as pe, cn as me, ct as he, d as ge, dn as _e, dt as ve, en as ye, et as be, f as xe, fn as Se, ft as Ce, g as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as ke, i as Ae, in as je, it as Me, j as Ne, jt as Pe, k as Fe, kn as Ie, kt as Le, l as Re, ln as ze, lt as Be, m as Ve, mn as He, mt as Ue, n as We, nn as Ge, nt as Ke, o as qe, on as Je, ot as Ye, p as Xe, pn as Ze, pt as Qe, q as $e, qt as et, r as tt, rn as nt, rt, s as it, sn as at, st as ot, t as st, tn as ct, tt as lt, u as ut, un as dt, ut as ft, v as pt, vn as mt, vt as ht, w as gt, wn as _t, wt as vt, x as yt, xn as bt, xt, y as St, yn as Ct, yt as wt, z as Tt, zt as Et } from "./src-C3yJArxW.js";
2
- export { h as API, q as ApiError, e as Audit, vt as AuditEventType, u as AuthMode, fe as DidYouMeanKind, c as EngineType, H as EngineTypeModifier, nt as LogLevel, xt as MINIMUM_COMPATIBLE_SERVER_API_VERSION, wt as RFMDisplay, b as ServerError, Y as TimeoutError, a as UnauthorizedError, be as addAuditAdditionalInfo, Se as addConcepts, lt as addSessionId, Ke as addUrl, Ct as aggItemRegex, de as aggregationItemStrictCompare, $e as appInitializerFn, mt as bisect, O as buildPathsAndLevels, We as clearSessionTokens, je as configureLogger, Z as createHeaders, r as createTimeoutController, Ve as createUserProfile, ce as debug, g as del, De as deleteUserProfileProperty, ue as deleteUserSettings, Ae as deleteWebTokenCookie, ne as detectAuthMode, Ie as emitAuthenticatedEvent, Je as error, rt as escapeExpr, d as expiresSoon, oe as extraColumns, L as fetchAggregation, C as fetchApp, ee as fetchAppPreLogin, A as fetchBulkQuery, St as fetchChangePassword, X as fetchDataset, _ as fetchDatasetList, T as fetchDatasets, y as fetchLabels, i as fetchPreview, J as fetchPreviewUrl, x as fetchPrincipal, D as fetchPrincipalList, z as fetchPrincipalUserid, Tt as fetchPrincipalUserids, F as fetchQuery, Ne as fetchQueryExport, n as fetchQueryIntent, pt as fetchSendPasswordResetEmail, Fe as fetchSimilarDocuments, M as fetchSponsoredLinks, U as fetchSuggest, f as fetchSuggestField, l as fetchSuggestQuery, gt as fetchTextChunks, we as fetchUserProfile, yt as fetchUserSettings, Xe as fetchVersion, ke as filter, I as get, Ze as getConcepts, Re as getCsrfToken, et as getFiltersFromURI, w as getFiltersFromUrl, v as getHelpIndexUrl, te as getIdFromUrl, pe as getJWToken, Qe as getMetadata, Ue as getMetadataWithValues, dt as getOffsetFromDates, $ as getQueryPageFromUrl, re as getQueryParamsFromUrl, R as getQueryTabFromUrl, t as getQueryTextFromUrl, _e as getRelativeDate, Me as getTime, it as getToken, ye as getUrlParamsFromQueryParams, W as globalConfig, le as guid, Et as handleResponse, at as info, Q as initializeAppConfig, Ye as isArrayBuffer, st as isAuthenticated, ot as isBlob, he as isDate, P as isExpired, Be as isJsonable, ze as isNotInputEvent, ft as isObject, ve as isString, K as labels, N as legacyBooleansToAuthMode, Ee as legacyFilterToFilter, se as login, tt as logout, ht as makeColumn, Ge as notify, bt as openParentNodes, He as parseText, V as parseValueAndOperatorFromItem, j as patch, ie as patchUserProfile, B as patchUserSettings, k as post, Pe as put, ct as queryParamsFromUrl, Oe as removeConcept, Te as removeConcepts, S as resolveNoAutoAuthentication, G as resolveToColumnName, ae as rewriteText, o as saveUserSettings, p as setGlobalConfig, ut as setToken, Ce as sha512, s as suggestionsToTreeAggregationNodes, E as sysLang, Le as toDate, _t as translateAggregationToDateOptions, qe as tryAutoAuthentication, xe as tryOAuthAuthentication, ge as trySAMLAuthentication, me as warn, m as withRetry };
1
+ import { $ as e, $n as t, $t as n, A as r, An as i, At as a, B as o, Bn as s, Bt as c, C as l, Cn as u, Ct as d, D as f, Dn as p, Dt as m, E as h, En as g, Et as _, F as v, Fn as y, Ft as b, G as x, Gn as S, Gt as C, H as w, Ht as T, I as E, In as D, It as O, J as k, Jn as A, Jt as j, K as M, Kn as N, Kt as P, L as F, Ln as I, Lt as L, M as R, Mn as z, Mt as B, N as V, Nn as H, Nt as U, O as W, On as G, Ot as K, P as q, Pn as J, Pt as Y, Q as X, Qn as Z, Qt as Q, R as $, Rn as ee, Rt as te, S as ne, Sn as re, St as ie, T as ae, Tn as oe, Tt as se, U as ce, Ut as le, V as ue, Vt as de, W as fe, Wn as pe, Wt as me, X as he, Xn as ge, Xt as _e, Y as ve, Yn as ye, Yt as be, Z as xe, Zn as Se, Zt as Ce, _ as we, _n as Te, _t as Ee, a as De, an as Oe, ar as ke, at as Ae, b as je, bn as Me, bt as Ne, c as Pe, cn as Fe, ct as Ie, d as Le, dn as Re, dt as ze, en as Be, er as Ve, et as He, f as Ue, fn as We, ft as Ge, g as Ke, gn as qe, gt as Je, h as Ye, hn as Xe, ht as Ze, i as Qe, in as $e, ir as et, it as tt, j as nt, jn as rt, jt as it, k as at, kn as ot, kt as st, l as ct, ln as lt, lt as ut, m as dt, mn as ft, mt as pt, n as mt, nn as ht, nr as gt, nt as _t, o as vt, on as yt, ot as bt, p as xt, pn as St, pt as Ct, q as wt, qn as Tt, qt as Et, r as Dt, rn as Ot, rr as kt, rt as At, s as jt, sn as Mt, st as Nt, t as Pt, tn as Ft, tr as It, tt as Lt, u as Rt, un as zt, ut as Bt, v as Vt, vn as Ht, vt as Ut, w as Wt, wn as Gt, wt as Kt, x as qt, xn as Jt, xt as Yt, y as Xt, yn as Zt, yt as Qt, z as $t, zn as en, zt as tn } from "./src-DFuZeDvd.js";
2
+ export { Nt as API, D as ApiError, Ne as Audit, P as AuditEventType, Tt as AuthMode, T as DidYouMeanKind, C as EngineType, me as EngineTypeModifier, t as LogLevel, le as MINIMUM_COMPATIBLE_SERVER_API_VERSION, de as RFMDisplay, H as ServerError, g as TimeoutError, y as UnauthorizedError, Yt as addAuditAdditionalInfo, Ke as addConcepts, ie as addSessionId, d as addUrl, l as aggItemRegex, Wt as aggregationItemStrictCompare, Q as appInitializerFn, pe as applyConfig, Te as assertNever, ne as bisect, tt as buildPathsAndLevels, zt as clearSessionTokens, Ve as configureLogger, at as createAtomicClient, F as createContainer, I as createHeaders, ee as createHeadersWithContext, oe as createTimeoutController, R as createUserProfile, It as debug, yt as del, Mt as delWithContext, $ as deleteContainerDocuments, $t as deleteContainers, V as deleteUserProfileProperty, x as deleteUserSettings, We as deleteWebTokenCookie, re as detectAuthMode, s as emitAuthenticatedEvent, gt as error, Kt as escapeExpr, be as expiresSoon, tn as extraColumns, Qt as fetchAggregation, n as fetchApp, Be as fetchAppPreLogin, Ae as fetchBulkQuery, fe as fetchChangePassword, Je as fetchDataset, Ee as fetchDatasetList, Ut as fetchDatasets, pt as fetchLabels, Ge as fetchPreview, Ct as fetchPreviewUrl, Ie as fetchPrincipal, ut as fetchPrincipalList, Bt as fetchPrincipalUserid, ze as fetchPrincipalUserids, bt as fetchQuery, At as fetchQueryExport, _t as fetchQueryIntent, E as fetchSendPasswordResetEmail, He as fetchSimilarDocuments, e as fetchSponsoredLinks, he as fetchSuggest, xe as fetchSuggestField, X as fetchSuggestQuery, ve as fetchTextChunks, q as fetchUserProfile, M as fetchUserSettings, nt as fetchVersion, L as filter, Me as get, we as getConcepts, o as getContainer, Zt as getCsrfToken, r as getDefaultClient, Dt as getFiltersFromURI, Qe as getFiltersFromUrl, Pt as getHelpIndexUrl, De as getIdFromUrl, Xe as getJWToken, b as getMetadata, O as getMetadataWithValues, dt as getOffsetFromDates, vt as getQueryPageFromUrl, jt as getQueryParamsFromUrl, Pe as getQueryTabFromUrl, ct as getQueryTextFromUrl, Ye as getRelativeDate, se as getTime, en as getToken, Rt as getUrlParamsFromQueryParams, Jt as getWithContext, S as globalConfig, _ as guid, rt as handleResponse, z as handleResponseWithContext, Ht as hasSession, kt as info, Ft as initializeAppConfig, m as isArrayBuffer, Fe as isAuthenticated, K as isBlob, st as isDate, _e as isExpired, A as isExternalAuthMode, a as isJsonable, xt as isNotInputEvent, it as isObject, lt as isRedirectPending, B as isString, Ze as labels, ye as legacyBooleansToAuthMode, te as legacyFilterToFilter, ue as listContainerDocuments, w as listContainers, St as login, Re as logout, c as makeColumn, Ue as notify, ke as onAuthEvent, ae as openParentNodes, Vt as parseText, h as parseValueAndOperatorFromItem, $e as patch, v as patchUserProfile, wt as patchUserSettings, Oe as patchWithContext, p as post, G as postWithContext, ht as put, Ot as putWithContext, Le as queryParamsFromUrl, Xt as removeConcept, je as removeConcepts, qe as requestWebTokenSession, ge as resolveBearerToken, ot as resolveNoAutoAuthentication, i as resolveNoAutoAuthenticationWithContext, Se as resolveOAuthProvider, Z as resolveSAMLProvider, Et as resolveToColumnName, Y as resultPages, qt as rewriteText, k as saveUserSettings, Lt as searchPrincipals, N as setGlobalConfig, J as setToken, U as sha512, f as suggestionsToTreeAggregationNodes, mt as sysLang, Ce as toDate, W as translateAggregationToDateOptions, ft as tryAutoAuthentication, Gt as tryOAuthAuthentication, u as trySAMLAuthentication, ce as updateContainer, et as warn, j as withRetry };
@@ -1,7 +1,27 @@
1
+ import { type AtomicContext } from "../client/atomic-context";
1
2
  /**
2
3
  * Default timeout in milliseconds for all authentication network requests.
4
+ * Override it per application via `setGlobalConfig({ auth: { timeoutMs } })`.
3
5
  */
4
6
  export declare const AUTH_TIMEOUT_MS = 10000;
7
+ /** The auth request timeout of a context: its configured `auth.timeoutMs`, or the default. */
8
+ export declare const getAuthTimeoutMsWithContext: (ctx: AtomicContext) => number;
9
+ /** The effective auth request timeout: the configured `auth.timeoutMs`, or the default. */
10
+ export declare const getAuthTimeoutMs: () => number;
11
+ /**
12
+ * Web Storage keys used by the authentication layer — single source of truth (they used to be
13
+ * duplicated as string literals across the token/session modules).
14
+ */
15
+ export declare const STORAGE_KEYS: {
16
+ /** sessionStorage — JSON envelope holding the CSRF token (see `setToken`/`getToken`). */
17
+ readonly credentials: "sinequa-credentials";
18
+ /** localStorage — legacy location of the CSRF token: still read and cleared, never written. */
19
+ readonly legacyCsrfToken: "csrfToken";
20
+ /** sessionStorage — token-less authenticated flag (ambient SSO: IIS/proxy). */
21
+ readonly authenticated: "sinequa-authenticated";
22
+ /** localStorage — marker of the last successful credentials login (disambiguates `unknown`). */
23
+ readonly lastAuthMode: "sinequa-last-auth-mode";
24
+ };
5
25
  /**
6
26
  * Session-storage key marking that a provider redirect (OAuth/SAML) has already been initiated.
7
27
  * Used as a one-shot loop guard: if we come back from the provider still without a session, we must
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/authentication/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,kCAAkC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/authentication/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,8FAA8F;AAC9F,eAAO,MAAM,2BAA2B,GAAI,KAAK,aAAa,KAAG,MAClB,CAAC;AAEhD,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,QAAO,MACS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,YAAY;IACvB,yFAAyF;;IAEzF,+FAA+F;;IAE/F,+EAA+E;;IAE/E,gGAAgG;;CAExF,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,kCAAkC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { ApiError } from "../../web-api/helpers/errors/api-error";
2
+ import type { UnauthorizedError } from "../../web-api/helpers/errors/unauthorized-error";
3
+ /**
4
+ * Typed client events and their payloads.
5
+ *
6
+ * - `authenticated` — the authentication state changed (mirrors the DOM `authenticated` event);
7
+ * - `unauthorized` — a request was rejected with a 401 (fires just before the
8
+ * {@link UnauthorizedError} is thrown). Use it to **observe**; to actually recover the session
9
+ * and have the request replayed, configure `auth.recoverFromUnauthorized` instead;
10
+ * - `requestFailed` — any request that ended on an error status, 401 included. The place to
11
+ * surface a notification without wrapping every call site;
12
+ * - `tokenRefreshed` — the CSRF token was stored or refreshed (`sinequa-jwt-refresh` header);
13
+ * - `loggedOut` — an explicit `logout()` completed its local cleanup.
14
+ */
15
+ export type AuthEventMap = {
16
+ authenticated: {
17
+ authenticated: boolean;
18
+ };
19
+ unauthorized: {
20
+ endpoint: string;
21
+ error: UnauthorizedError;
22
+ };
23
+ requestFailed: {
24
+ endpoint: string;
25
+ status: number;
26
+ error: ApiError;
27
+ };
28
+ tokenRefreshed: {
29
+ token: string;
30
+ };
31
+ loggedOut: Record<string, never>;
32
+ };
33
+ export type AuthEventName = keyof AuthEventMap;
34
+ /** Detaches the handler registered by {@link onAuthEvent}. */
35
+ export type Unsubscribe = () => void;
36
+ /**
37
+ * A set of authentication-event subscribers. Each client owns one, so events raised by a client
38
+ * only reach the handlers registered on that client.
39
+ */
40
+ export interface AuthEventBus {
41
+ on<K extends AuthEventName>(event: K, handler: (payload: AuthEventMap[K]) => void): Unsubscribe;
42
+ emit<K extends AuthEventName>(event: K, payload: AuthEventMap[K]): void;
43
+ }
44
+ /** Creates an independent event bus. */
45
+ export declare function createAuthEventBus(): AuthEventBus;
46
+ /** The bus backing the free functions (`login`, `logout`, …) and the default client. */
47
+ export declare const defaultAuthEventBus: AuthEventBus;
48
+ /**
49
+ * Subscribes to an authentication event of the default client. Unlike the DOM `authenticated`
50
+ * CustomEvent, this channel is fully typed, works without a DOM (SSR, Node) and covers the whole
51
+ * auth lifecycle.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const off = onAuthEvent("unauthorized", ({ endpoint, error }) => {
56
+ * // e.g. trigger a silent re-authentication
57
+ * });
58
+ * // later: off();
59
+ * ```
60
+ *
61
+ * @returns The unsubscribe function.
62
+ */
63
+ export declare function onAuthEvent<K extends AuthEventName>(event: K, handler: (payload: AuthEventMap[K]) => void): Unsubscribe;
64
+ /**
65
+ * Internal — notifies the subscribers of the default bus.
66
+ *
67
+ * @deprecated Internal helper kept for the free functions; context-aware code emits through
68
+ * `ctx.events` instead.
69
+ */
70
+ export declare function emitAuthEvent<K extends AuthEventName>(event: K, payload: AuthEventMap[K]): void;
71
+ //# sourceMappingURL=auth-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-events.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/auth-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE;QAAE,aAAa,EAAE,OAAO,CAAA;KAAE,CAAC;IAC1C,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,iBAAiB,CAAA;KAAE,CAAC;IAC7D,aAAa,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAA;KAAE,CAAC;IACrE,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC;AAE/C,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,CAAC,SAAS,aAAa,EACxB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,WAAW,CAAC;IACf,IAAI,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACzE;AAED,wCAAwC;AACxC,wBAAgB,kBAAkB,IAAI,YAAY,CA8BjD;AAED,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,cAAuB,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,EACjD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,WAAW,CAEb;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,aAAa,EACnD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GACvB,IAAI,CAEN"}
@@ -1,6 +1,15 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /**
3
+ * Notifies the subscribers of a context that the authentication state changed, and mirrors it as a
4
+ * DOM `authenticated` CustomEvent.
5
+ */
6
+ export declare function emitAuthenticatedEventWithContext(ctx: AtomicContext, authenticated: boolean): void;
1
7
  /**
2
8
  * Emits a custom 'authenticated' event with the provided authentication status.
3
9
  *
10
+ * The event is dispatched on `document` and bubbles up to `window`, so listeners attached on
11
+ * either target receive it.
12
+ *
4
13
  * @param authenticated - A boolean indicating whether the user is authenticated.
5
14
  *
6
15
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"emit-authenticated-event.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/emit-authenticated-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,QAa5D"}
1
+ {"version":3,"file":"emit-authenticated-event.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/emit-authenticated-event.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,OAAO,QAqBvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,QAE5D"}
@@ -1,2 +1,3 @@
1
+ export { type AuthEventMap, type AuthEventName, onAuthEvent, type Unsubscribe, } from "./auth-events";
1
2
  export { emitAuthenticatedEvent } from "./emit-authenticated-event";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,5 +1,5 @@
1
- export { emitAuthenticatedEvent } from "./events";
1
+ export { type AuthEventMap, type AuthEventName, emitAuthenticatedEvent, onAuthEvent, type Unsubscribe, } from "./events";
2
2
  export { tryOAuthAuthentication, trySAMLAuthentication } from "./providers";
3
- export { clearSessionTokens, detectAuthMode, isAuthenticated, login, logout, tryAutoAuthentication, } from "./session";
4
- export { deleteWebTokenCookie, getCsrfToken, getJWToken, getToken, setToken, } from "./tokens";
3
+ export { clearSessionTokens, detectAuthMode, hasSession, isAuthenticated, isRedirectPending, login, logout, tryAutoAuthentication, } from "./session";
4
+ export { deleteWebTokenCookie, getCsrfToken, getJWToken, getToken, requestWebTokenSession, setToken, } from "./tokens";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,KAAK,EACL,MAAM,EACN,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,sBAAsB,EACtB,WAAW,EACX,KAAK,WAAW,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,KAAK,EACL,MAAM,EACN,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,sBAAsB,EACtB,QAAQ,GACT,MAAM,UAAU,CAAC"}
@@ -1,8 +1,17 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /** @see tryOAuthAuthentication */
3
+ export declare const tryOAuthAuthenticationWithContext: (ctx: AtomicContext) => Promise<{
4
+ redirectUrl: string;
5
+ }>;
1
6
  /**
2
7
  * Initiates the OAuth authentication process by sending a POST request to the backend.
3
8
  * The server responds with a redirect URL which is used to send the user to the OAuth provider's login page.
9
+ *
10
+ * The provider comes from `authMode: AuthMode.oauth(provider)` first, then the `autoOAuthProvider`
11
+ * configuration key.
12
+ *
4
13
  * @returns A promise that resolves to the server response containing the `redirectUrl`.
5
- * @throws An error if `autoOAuthProvider` is not configured in `globalConfig` or if the request fails.
14
+ * @throws An error if no OAuth provider is configured, or if the request fails.
6
15
  */
7
16
  export declare const tryOAuthAuthentication: () => Promise<{
8
17
  redirectUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/oauth-authentication.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;iBAWI,MAAM;EAmD5C,CAAC"}
1
+ {"version":3,"file":"oauth-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/oauth-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAIrC,kCAAkC;AAClC,eAAO,MAAM,iCAAiC,GAC5C,KAAK,aAAa,KACjB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAUjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,QAAO,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CACtB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /** What differs between the OAuth and the SAML flows — everything else is shared. */
3
+ declare const PROVIDER_KINDS: {
4
+ readonly oauth: {
5
+ readonly label: "OAuth";
6
+ readonly endpoint: "api/v1/security.oauth";
7
+ readonly action: "getcode";
8
+ };
9
+ readonly saml: {
10
+ readonly label: "SAML";
11
+ readonly endpoint: "api/v1/security.saml";
12
+ readonly action: "getresponse";
13
+ };
14
+ };
15
+ export interface IdentityProviderRedirectOptions {
16
+ kind: keyof typeof PROVIDER_KINDS;
17
+ /** Provider name as configured on the Sinequa server (autoOAuthProvider / autoSAMLProvider). */
18
+ provider: string;
19
+ }
20
+ /**
21
+ * Internal — shared body of `tryOAuthAuthentication` / `trySAMLAuthentication`.
22
+ *
23
+ * Asks the server for the identity provider's sign-in URL, then redirects the browser to it. A
24
+ * one-shot loop guard ({@link AUTH_REDIRECT_ATTEMPT_KEY}) prevents an endless redirect loop when
25
+ * the provider keeps sending the user back without a session. In a Node environment there is no
26
+ * browser to redirect: the server response is simply returned.
27
+ *
28
+ * @returns The server response containing the `redirectUrl`.
29
+ */
30
+ export declare function redirectToIdentityProvider(ctx: AtomicContext, { kind, provider }: IdentityProviderRedirectOptions): Promise<{
31
+ redirectUrl: string;
32
+ }>;
33
+ export {};
34
+ //# sourceMappingURL=redirect-to-identity-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-to-identity-provider.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/redirect-to-identity-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,6BAA6B,CAAC;AAQrC,qFAAqF;AACrF,QAAA,MAAM,cAAc;;;;;;;;;;;CAWV,CAAC;AAEX,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,MAAM,OAAO,cAAc,CAAC;IAClC,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,aAAa,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,+BAA+B,GAClD,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAoDlC"}
@@ -1,8 +1,17 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /** @see trySAMLAuthentication */
3
+ export declare const trySAMLAuthenticationWithContext: (ctx: AtomicContext) => Promise<{
4
+ redirectUrl: string;
5
+ }>;
1
6
  /**
2
7
  * Initiates the SAML authentication process by sending a POST request to the backend.
3
8
  * The server responds with a redirect URL which is used to send the user to the SAML identity provider's login page.
9
+ *
10
+ * The provider comes from `authMode: AuthMode.saml(provider)` first, then the `autoSAMLProvider`
11
+ * configuration key.
12
+ *
4
13
  * @returns A promise that resolves to the server response containing the `redirectUrl`.
5
- * @throws An error if `autoSAMLProvider` is not configured in `globalConfig` or if the request fails.
14
+ * @throws An error if no SAML provider is configured, or if the request fails.
6
15
  */
7
16
  export declare const trySAMLAuthentication: () => Promise<{
8
17
  redirectUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"saml-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/saml-authentication.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;iBAWK,MAAM;EAmD5C,CAAC"}
1
+ {"version":3,"file":"saml-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/saml-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAIrC,iCAAiC;AACjC,eAAO,MAAM,gCAAgC,GAC3C,KAAK,aAAa,KACjB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAUjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,QAAO,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CACtB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
1
2
  /**
2
3
  * Persisted record — in `localStorage`, shared across tabs/windows unlike `sessionStorage` — of
3
4
  * whether the last successful authentication on this browser used `credentials`.
@@ -8,7 +9,13 @@
8
9
  * resolve that ambiguity back to `credentials` instead of guessing `sso`. Cleared on logout so a
9
10
  * later, genuinely different SSO session isn't mislabeled.
10
11
  */
12
+ export declare const rememberCredentialsAuthModeWithContext: (ctx: AtomicContext) => void;
13
+ export declare const wasLastAuthModeCredentialsWithContext: (ctx: AtomicContext) => boolean;
14
+ export declare const forgetAuthModeMarkerWithContext: (ctx: AtomicContext) => void;
15
+ /** @see rememberCredentialsAuthModeWithContext */
11
16
  export declare const rememberCredentialsAuthMode: () => void;
17
+ /** @see wasLastAuthModeCredentialsWithContext */
12
18
  export declare const wasLastAuthModeCredentials: () => boolean;
19
+ /** @see forgetAuthModeMarkerWithContext */
13
20
  export declare const forgetAuthModeMarker: () => void;
14
21
  //# sourceMappingURL=auth-mode-marker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-mode-marker.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/auth-mode-marker.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,QAAO,IAE9C,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,OACa,CAAC;AAE5D,eAAO,MAAM,oBAAoB,QAAO,IAEvC,CAAC"}
1
+ {"version":3,"file":"auth-mode-marker.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/auth-mode-marker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,6BAA6B,CAAC;AAQrC;;;;;;;;;GASG;AACH,eAAO,MAAM,sCAAsC,GACjD,KAAK,aAAa,KACjB,IAGF,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAChD,KAAK,aAAa,KACjB,OAGF,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,KAAK,aAAa,KAAG,IAGpE,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,2BAA2B,QAAO,IACS,CAAC;AAEzD,iDAAiD;AACjD,eAAO,MAAM,0BAA0B,QAAO,OACS,CAAC;AAExD,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,QAAO,IACS,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
1
2
  /**
2
3
  * Persisted "authenticated" flag for token-less ambient SSO — IIS Integrated Windows Authentication
3
4
  * or proxy SSO, where the server authenticates every request via the connection/cookie and issues
@@ -8,7 +9,11 @@
8
9
  * by `clearSessionTokens()` (and therefore by `logout()`). `isAuthenticated()` reads it as a fallback
9
10
  * when no token is stored.
10
11
  */
12
+ export declare const setAuthenticatedWithContext: (ctx: AtomicContext, authenticated: boolean) => void;
13
+ /** Whether a token-less authenticated session was recorded (see {@link setAuthenticatedWithContext}). */
14
+ export declare const isAuthenticatedFlagWithContext: (ctx: AtomicContext) => boolean;
15
+ /** @see setAuthenticatedWithContext */
11
16
  export declare const setAuthenticated: (authenticated: boolean) => void;
12
- /** Whether a token-less authenticated session was recorded (see {@link setAuthenticated}). */
17
+ /** @see isAuthenticatedFlagWithContext */
13
18
  export declare const isAuthenticatedFlag: () => boolean;
14
19
  //# sourceMappingURL=auth-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-state.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/auth-state.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,eAAe,OAAO,KAAG,IAMzD,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,QAAO,OACc,CAAC"}
1
+ {"version":3,"file":"auth-state.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/auth-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,6BAA6B,CAAC;AAGrC;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,KAAK,aAAa,EAClB,eAAe,OAAO,KACrB,IAQF,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,8BAA8B,GAAI,KAAK,aAAa,KAAG,OAGtD,CAAC;AAEf,uCAAuC;AACvC,eAAO,MAAM,gBAAgB,GAAI,eAAe,OAAO,KAAG,IACE,CAAC;AAE7D,0CAA0C;AAC1C,eAAO,MAAM,mBAAmB,QAAO,OACS,CAAC"}
@@ -4,7 +4,8 @@ import type { CCAppPreLogin } from "../../types";
4
4
  * Pure resolution of the authentication mode from the current configuration inputs and
5
5
  * the server pre-login response. No I/O, no `globalConfig` mutation, no `window` access.
6
6
  *
7
- * Precedence: explicit credentials preset > bearer token > OAuth provider > SAML provider > unknown.
7
+ * Precedence: any explicitly configured `authMode` other than `unknown` > bearer token > OAuth
8
+ * provider > SAML provider > unknown.
8
9
  * When both an OAuth and a SAML provider are present, OAuth wins (parity with the previous runtime,
9
10
  * which only used the SAML provider when no OAuth provider was configured).
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"detect-auth-mode.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/detect-auth-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE;IACN,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAChC,QAAQ,CAgBV"}
1
+ {"version":3,"file":"detect-auth-mode.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/detect-auth-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE;IACN,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAChC,QAAQ,CAsBV"}
@@ -0,0 +1,26 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /**
3
+ * Whether a session already exists for this context — **without ever redirecting**.
4
+ *
5
+ * A stored CSRF token answers immediately and offline. Failing that, the server is asked for one:
6
+ * `getCsrfToken` returns `200` with no token when there is no session, so a missing token is an
7
+ * expected answer rather than an error, and a genuine request failure (network / timeout / HTTP) is
8
+ * treated as "no session" — an outage must not be reported as a live session.
9
+ *
10
+ * This is the probe `login()` runs before any handshake, exposed on its own because `login()` is
11
+ * otherwise the only door and it **navigates away** for `oauth` and `saml`. An application that wants
12
+ * to know whether it is signed in — to decide between rendering a form and rendering the page, or to
13
+ * show two backends' states side by side — cannot afford a full-page redirect to find out.
14
+ *
15
+ * A successful probe stores the token it obtained (`getCsrfTokenWithContext` does), so the next
16
+ * request is authenticated, and clears the provider-redirect guard (see below). It deliberately does
17
+ * **not** emit `authenticated`: that event means "a sign-in completed", and `login()` remains the only
18
+ * thing that raises it. A probe that emitted it would make every listener believe a sign-in had just
19
+ * happened.
20
+ *
21
+ * @returns `true` when a session is available, `false` otherwise. Never throws.
22
+ */
23
+ export declare function hasSessionWithContext(ctx: AtomicContext): Promise<boolean>;
24
+ /** @see hasSessionWithContext */
25
+ export declare const hasSession: () => Promise<boolean>;
26
+ //# sourceMappingURL=has-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-session.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/has-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,6BAA6B,CAAC;AAKrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,OAAO,CAAC,CAwBlB;AAsBD,iCAAiC;AACjC,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,OAAO,CACN,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export { detectAuthMode } from "./detect-auth-mode";
2
+ export { hasSession } from "./has-session";
2
3
  export { login } from "./login";
3
4
  export { clearSessionTokens, logout } from "./logout";
5
+ export { isRedirectPending } from "./redirect-guard";
4
6
  export { tryAutoAuthentication } from "./try-auto-authentication";
5
7
  export { isAuthenticated } from "./user-authentication";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,21 +1,26 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
1
2
  import type { Credentials } from "../../types";
2
3
  /**
3
- * Signs the user in.
4
+ * Signs the user in on the given context.
4
5
  *
5
6
  * When `credentials` are provided, authentication is performed with them directly. Otherwise:
6
- * - `credentials` mode → nothing automatic, the form must collect the credentials;
7
7
  * - `bearer` mode → authenticate with the configured bearer token;
8
- * - `oauth` / `saml` / `sso` / `unknown` → first check whether a session already exists (an existing
9
- * token, or a successful CSRF retrieval — the latter also covers proxy/browser SSO). Only when no
10
- * session exists do we run the mode-specific handshake: redirect to the provider (`oauth`/`saml`),
11
- * or fall back to the credentials form (`sso`/`unknown`).
8
+ * - every other mode → first check whether a session already exists (an existing token, or a
9
+ * successful CSRF retrieval). Only when no session exists do we run the mode-specific handshake:
10
+ * redirect to the provider (`oauth`/`saml`), let the server authenticate the request
11
+ * (`sso`/`unknown`, see {@link establishAmbientSession}), or leave it to the form (`credentials`).
12
12
  *
13
13
  * Checking the existing session BEFORE redirecting is essential: otherwise every bootstrap would
14
14
  * redirect to the OAuth/SAML provider again even though the user is already authenticated, causing a
15
- * redirect/reload loop.
15
+ * redirect/reload loop. The check also runs in `credentials` mode: nothing can be authenticated
16
+ * automatically there, but the caller still deserves the truth about an already-established session
17
+ * — reporting `false` while the user is signed in silently breaks `login().then(ok => ok && …)`
18
+ * callers (this is what made an impersonation switch a no-op in credentials mode).
16
19
  *
17
20
  * @param credentials - Optional username/password.
18
21
  * @returns A promise resolving to `true` when the user is authenticated.
19
22
  */
23
+ export declare const loginWithContext: (ctx: AtomicContext, credentials?: Credentials) => Promise<boolean>;
24
+ /** @see loginWithContext */
20
25
  export declare const login: (credentials?: Credentials) => Promise<boolean>;
21
26
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAyB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,GAAU,cAAc,WAAW,KAAG,OAAO,CAAC,OAAO,CA6GtE,CAAC"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/login.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAMnB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgG/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,aAAa,EAClB,cAAc,WAAW,KACxB,OAAO,CAAC,OAAO,CAuFjB,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,KAAK,GAAI,cAAc,WAAW,KAAG,OAAO,CAAC,OAAO,CAClB,CAAC"}
@@ -1,8 +1,19 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
1
2
  /**
2
- * Logs out the user and delete the web Token Cookie.
3
- * @returns {Promise<string>} the logout redirectUrl
3
+ * Logs out the user of a context and deletes its web token cookie.
4
+ *
5
+ * @returns the logout `redirectUrl` returned by the server, or `undefined` when there is none to
6
+ * follow — either because an impersonation is active (the cookie is left untouched), because the
7
+ * server did not answer `ok`, or because the request failed (the failure is logged, not thrown).
8
+ * The local session is cleared in every case.
4
9
  */
10
+ export declare function logoutWithContext(ctx: AtomicContext): Promise<string | undefined>;
11
+ /** @see logoutWithContext */
5
12
  export declare function logout(): Promise<string | undefined>;
13
+ /**
14
+ * Clears the local authentication state of a context and emits an `authenticated: false` event.
15
+ */
16
+ export declare function clearSessionTokensWithContext(ctx: AtomicContext): void;
6
17
  /**
7
18
  * Clear the authentications tokens and emits authenticated event to false
8
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/logout.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAsB,MAAM,gCAsB3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,SAKjC"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,6BAA6B,CAAC;AAOrC;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA4B7B;AAED,6BAA6B;AAC7B,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE1D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAatE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -0,0 +1,18 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
2
+ /**
3
+ * Whether a provider redirect (oauth / saml) was started for this context and has not established a
4
+ * session yet.
5
+ *
6
+ * The flag is set right before the full-page navigation to the identity provider and cleared once a
7
+ * session is confirmed (or on `logout()`). It is the one-shot guard that turns a second failed
8
+ * attempt into a descriptive error instead of an endless redirect loop.
9
+ *
10
+ * Exposed because consumers need to read it and had no way to: the key was not exported, so
11
+ * `@sinequa/atomic-angular` mirrored the literal in its own source — and read it from
12
+ * `sessionStorage` **unprefixed**, which is correct only as long as no client sets a
13
+ * `storagePrefix`. Reading it through the context is what makes it right for two clients on one page.
14
+ */
15
+ export declare function isRedirectPendingWithContext(ctx: AtomicContext): boolean;
16
+ /** @see isRedirectPendingWithContext */
17
+ export declare const isRedirectPending: () => boolean;
18
+ //# sourceMappingURL=redirect-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-guard.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/redirect-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,6BAA6B,CAAC;AAGrC;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAMxE;AAED,wCAAwC;AACxC,eAAO,MAAM,iBAAiB,QAAO,OACS,CAAC"}
@@ -1,9 +1,10 @@
1
+ import { type AtomicContext } from "../../client/atomic-context";
1
2
  /**
2
3
  * Probes the server for **auto-authentication** (e.g. OIDC) before falling back to the credentials
3
4
  * form.
4
5
  *
5
- * Unlike {@link getCsrfToken} — which calls the challenge endpoint with `suppressErrors=true` and
6
- * therefore never triggers the server-side auth challenge — and unlike {@link fetchPrincipal} — which
6
+ * Unlike `getCsrfToken` — which calls the challenge endpoint with `suppressErrors=true` and
7
+ * therefore never triggers the server-side auth challenge — and unlike `fetchPrincipal` — which
7
8
  * sends `noAutoAuthentication=true` to explicitly disable it — this probe hits a protected endpoint
8
9
  * **allowing the server to auto-authenticate**. When the user already has a valid IdP session, the
9
10
  * server completes the handshake and answers `200`; otherwise it answers `401` (or redirects to the
@@ -15,5 +16,7 @@
15
16
  * @returns `true` when the server auto-authenticated the user (`200`), `false` otherwise (401,
16
17
  * redirect, timeout or any network error). Never throws.
17
18
  */
19
+ export declare const tryAutoAuthenticationWithContext: (ctx: AtomicContext) => Promise<boolean>;
20
+ /** @see tryAutoAuthenticationWithContext */
18
21
  export declare const tryAutoAuthentication: () => Promise<boolean>;
19
22
  //# sourceMappingURL=try-auto-authentication.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"try-auto-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/try-auto-authentication.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,QAAa,OAAO,CAAC,OAAO,CAgB7D,CAAC"}
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"}