@seliseblocks/client 0.1.0-beta.1 → 0.1.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.
|
@@ -234,9 +234,13 @@ export declare class BlocksAuthenticationClient {
|
|
|
234
234
|
*/
|
|
235
235
|
accessToken(): Promise<string | undefined>;
|
|
236
236
|
/**
|
|
237
|
-
* What:
|
|
238
|
-
* Why:
|
|
239
|
-
*
|
|
237
|
+
* What: validates the current session against IAM through `GET /iam/v4/auth/me`.
|
|
238
|
+
* Why: a caller-owned `accessToken` may be absent by design -- IAM's hosted IdP flow sets the
|
|
239
|
+
* session as a Secure, httpOnly cookie by default, so checking for a local token would report
|
|
240
|
+
* "signed out" even when the browser holds a valid session cookie. IAM is the source of truth.
|
|
241
|
+
* How: checks the raw response status rather than `userInfo()` -- `json()` intentionally never
|
|
242
|
+
* throws on non-2xx (auth endpoints can return protocol-shaped error bodies), so a 401 there
|
|
243
|
+
* would otherwise resolve as if the call had succeeded.
|
|
240
244
|
*/
|
|
241
245
|
isAuthenticated(): Promise<boolean>;
|
|
242
246
|
/**
|
package/dist/auth/auth-client.js
CHANGED
|
@@ -332,12 +332,22 @@ export class BlocksAuthenticationClient {
|
|
|
332
332
|
: this.clientConfig.accessToken;
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
|
-
* What:
|
|
336
|
-
* Why:
|
|
337
|
-
*
|
|
335
|
+
* What: validates the current session against IAM through `GET /iam/v4/auth/me`.
|
|
336
|
+
* Why: a caller-owned `accessToken` may be absent by design -- IAM's hosted IdP flow sets the
|
|
337
|
+
* session as a Secure, httpOnly cookie by default, so checking for a local token would report
|
|
338
|
+
* "signed out" even when the browser holds a valid session cookie. IAM is the source of truth.
|
|
339
|
+
* How: checks the raw response status rather than `userInfo()` -- `json()` intentionally never
|
|
340
|
+
* throws on non-2xx (auth endpoints can return protocol-shaped error bodies), so a 401 there
|
|
341
|
+
* would otherwise resolve as if the call had succeeded.
|
|
338
342
|
*/
|
|
339
343
|
async isAuthenticated() {
|
|
340
|
-
|
|
344
|
+
try {
|
|
345
|
+
const response = await this.raw("/iam/v4/auth/me", { method: "GET" });
|
|
346
|
+
return response.ok;
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
341
351
|
}
|
|
342
352
|
/**
|
|
343
353
|
* What: sends a JSON Auth/IdPController request and returns the parsed response body.
|
|
@@ -385,6 +395,9 @@ export class BlocksAuthenticationClient {
|
|
|
385
395
|
}
|
|
386
396
|
return this.fetchImpl(url, {
|
|
387
397
|
body: options.body,
|
|
398
|
+
// IAM's hosted IdP flow sets the session as a Secure, httpOnly cookie by default;
|
|
399
|
+
// without this the browser never sends it back on subsequent Auth/IdP requests.
|
|
400
|
+
credentials: "include",
|
|
388
401
|
headers,
|
|
389
402
|
method: options.method
|
|
390
403
|
});
|
package/dist/http/http-client.js
CHANGED
|
@@ -26,6 +26,9 @@ export class BlocksHttpClient {
|
|
|
26
26
|
}
|
|
27
27
|
const response = await this.fetchImpl(url, {
|
|
28
28
|
body: rawBody ?? (options.body === undefined ? undefined : JSON.stringify(options.body)),
|
|
29
|
+
// IAM's hosted IdP flow sets the session as a Secure, httpOnly cookie by default;
|
|
30
|
+
// without this the browser never sends it back on subsequent Blocks API calls.
|
|
31
|
+
credentials: "include",
|
|
29
32
|
headers,
|
|
30
33
|
method: options.method ?? (options.body === undefined ? "GET" : "POST")
|
|
31
34
|
});
|