@docyrus/signin 0.18.1 → 0.18.3
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/dist/{constants-BVfrHdk1.d.ts → constants-CvMiR-RM.d.ts} +12 -1
- package/dist/core-index.d.ts +1 -1
- package/dist/core-index.js +34 -12
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.js +34 -12
- package/dist/react-native/index.js.map +1 -1
- package/dist/vue/index.js +34 -12
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { G as GuidyRoute, H as HostNavigationHandler, v as HostNotificationHandl
|
|
|
3
3
|
export { A as AclOperation, a as AclTargetType, b as AdaptiveCard, x as AppNavigationRequestMessage, y as AppRouteChangeMessage, c as AuthMode, C as CalendarSendAckMessage, z as CalendarSendMessage, B as ChatSendAckMessage, E as ChatSendMessage, F as DocySendAckMessage, I as DocySendMessage, f as DocyrusAclRule, D as DocyrusAuthConfig, g as DocyrusAuthContextValue, J as DocyrusNotification, j as DocyrusPermission, k as DocyrusRole, l as DocyrusShareAdaptiveCardPayload, n as DocyrusShareTextPayload, o as DocyrusUser, K as EmailSendAckMessage, L as EmailSendMessage, N as GuidyCommandHandler, Q as GuidyCommandMessage, S as GuidyElement, T as GuidyElementsMessage, U as GuidyPointAckMessage, V as GuidyPointMessage, W as GuidyRoutesMessage, X as GuidyScanMessage, Y as HostNavigationMessage, Z as HostNotificationMessage, _ as HostSignInMessage, $ as IframeAuth, M as MsGraphAccount, q as MsGraphRequest, a0 as MsGraphRequestMessage, r as MsGraphRequestOptions, s as MsGraphResponse, a1 as MsGraphResponseMessage, t as MsGraphStatus, a2 as MsGraphStatusRequestMessage, a3 as MsGraphStatusResponseMessage, P as PermissionConfig, u as PermissionScope, R as RouteChangePayload, a4 as TokenRefreshRequestMessage } from './types-BcLDyMdw.js';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { CSSProperties, ReactNode } from 'react';
|
|
6
|
-
export { A as AuthManager, D as DEFAULT_API_URL, d as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, e as DEFAULT_SSR_COOKIE_KEY, g as getAllRoles, b as getAllowedOperations, h as hasPermission, c as hasRole } from './constants-
|
|
6
|
+
export { A as AuthManager, D as DEFAULT_API_URL, d as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, e as DEFAULT_SSR_COOKIE_KEY, g as getAllRoles, b as getAllowedOperations, h as hasPermission, c as hasRole } from './constants-CvMiR-RM.js';
|
|
7
7
|
export { GuidyBridge, StandaloneOAuth2Auth, detectAuthMode } from './core-index.js';
|
|
8
8
|
import '@docyrus/api-client';
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -1113,6 +1113,8 @@ var AuthManager = class {
|
|
|
1113
1113
|
error = null;
|
|
1114
1114
|
client = null;
|
|
1115
1115
|
user = null;
|
|
1116
|
+
/** In-flight `/v1/users/me` request, tied to the client that issued it. */
|
|
1117
|
+
userFetch = null;
|
|
1116
1118
|
standaloneAuth = null;
|
|
1117
1119
|
iframeAuth = null;
|
|
1118
1120
|
guidyBridge = null;
|
|
@@ -1556,20 +1558,40 @@ var AuthManager = class {
|
|
|
1556
1558
|
this.scheduleTokenRefresh(tokens);
|
|
1557
1559
|
this.notify();
|
|
1558
1560
|
if (isNewSession || !this.user) {
|
|
1559
|
-
this.fetchUser();
|
|
1561
|
+
void this.fetchUser();
|
|
1560
1562
|
}
|
|
1561
1563
|
}
|
|
1562
|
-
/**
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1564
|
+
/**
|
|
1565
|
+
* Fetch the current user from /v1/users/me. Silently sets user to null on failure.
|
|
1566
|
+
*
|
|
1567
|
+
* Concurrent calls share one request: `setAuthenticated` fetches whenever the
|
|
1568
|
+
* user is still missing, so a second token push that lands while the first
|
|
1569
|
+
* fetch is in flight (e.g. stored tokens restored on load, then the host or a
|
|
1570
|
+
* bridge pushing its session) would otherwise fire a duplicate request. A
|
|
1571
|
+
* result is dropped if the client changed meanwhile (sign-out or a new
|
|
1572
|
+
* session), so a stale user never overwrites the current one.
|
|
1573
|
+
*/
|
|
1574
|
+
fetchUser() {
|
|
1575
|
+
const { client } = this;
|
|
1576
|
+
if (!client) return Promise.resolve();
|
|
1577
|
+
if (this.userFetch?.client === client) return this.userFetch.promise;
|
|
1578
|
+
const promise = (async () => {
|
|
1579
|
+
let user = null;
|
|
1580
|
+
try {
|
|
1581
|
+
const response = await client.get("/v1/users/me");
|
|
1582
|
+
const maybeUser = response;
|
|
1583
|
+
user = maybeUser && typeof maybeUser === "object" && "id" in maybeUser && "email" in maybeUser ? maybeUser : response.data;
|
|
1584
|
+
} catch {
|
|
1585
|
+
user = null;
|
|
1586
|
+
}
|
|
1587
|
+
if (this.client !== client) return;
|
|
1588
|
+
this.user = user;
|
|
1589
|
+
this.notify();
|
|
1590
|
+
})().finally(() => {
|
|
1591
|
+
if (this.userFetch?.promise === promise) this.userFetch = null;
|
|
1592
|
+
});
|
|
1593
|
+
this.userFetch = { client, promise };
|
|
1594
|
+
return promise;
|
|
1573
1595
|
}
|
|
1574
1596
|
/**
|
|
1575
1597
|
* Create a RestApiClient with a custom TokenManager that proactively
|