@docyrus/signin 0.18.1 → 0.18.2
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 +2 -2
|
@@ -19,6 +19,8 @@ declare class AuthManager {
|
|
|
19
19
|
private error;
|
|
20
20
|
private client;
|
|
21
21
|
private user;
|
|
22
|
+
/** In-flight `/v1/users/me` request, tied to the client that issued it. */
|
|
23
|
+
private userFetch;
|
|
22
24
|
private standaloneAuth;
|
|
23
25
|
private iframeAuth;
|
|
24
26
|
private guidyBridge;
|
|
@@ -171,7 +173,16 @@ declare class AuthManager {
|
|
|
171
173
|
* one fires once the user is fetched.
|
|
172
174
|
*/
|
|
173
175
|
private setAuthenticated;
|
|
174
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* Fetch the current user from /v1/users/me. Silently sets user to null on failure.
|
|
178
|
+
*
|
|
179
|
+
* Concurrent calls share one request: `setAuthenticated` fetches whenever the
|
|
180
|
+
* user is still missing, so a second token push that lands while the first
|
|
181
|
+
* fetch is in flight (e.g. stored tokens restored on load, then the host or a
|
|
182
|
+
* bridge pushing its session) would otherwise fire a duplicate request. A
|
|
183
|
+
* result is dropped if the client changed meanwhile (sign-out or a new
|
|
184
|
+
* session), so a stale user never overwrites the current one.
|
|
185
|
+
*/
|
|
175
186
|
private fetchUser;
|
|
176
187
|
/**
|
|
177
188
|
* Create a RestApiClient with a custom TokenManager that proactively
|
package/dist/core-index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthManager, f as AuthStateListener, D as DEFAULT_API_URL, d as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, g as getAllRoles, b as getAllowedOperations, h as hasPermission, c as hasRole } from './constants-
|
|
1
|
+
export { A as AuthManager, f as AuthStateListener, D as DEFAULT_API_URL, d as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, g as getAllRoles, b as getAllowedOperations, h as hasPermission, c as hasRole } from './constants-CvMiR-RM.js';
|
|
2
2
|
import { OAuth2Tokens } from '@docyrus/api-client';
|
|
3
3
|
import { D as DocyrusAuthConfig, T as GuidyElementsMessage, W as GuidyRoutesMessage, U as GuidyPointAckMessage, G as GuidyRoute, Q as GuidyCommandMessage, c as AuthMode } from './types-BcLDyMdw.js';
|
|
4
4
|
export { A as AclOperation, a as AclTargetType, b as AdaptiveCard, x as AppNavigationRequestMessage, y as AppRouteChangeMessage, e as AuthStatus, C as CalendarSendAckMessage, z as CalendarSendMessage, B as ChatSendAckMessage, E as ChatSendMessage, F as DocySendAckMessage, I as DocySendMessage, f as DocyrusAclRule, g as DocyrusAuthContextValue, h as DocyrusCalendarEventPayload, i as DocyrusEmailPayload, J as DocyrusNotification, j as DocyrusPermission, k as DocyrusRole, l as DocyrusShareAdaptiveCardPayload, m as DocyrusSharePayload, n as DocyrusShareTextPayload, o as DocyrusUser, K as EmailSendAckMessage, L as EmailSendMessage, N as GuidyCommandHandler, S as GuidyElement, V as GuidyPointMessage, X as GuidyScanMessage, H as HostNavigationHandler, Y as HostNavigationMessage, w as HostNavigationRequestOptions, v as HostNotificationHandler, Z as HostNotificationMessage, _ as HostSignInMessage, $ as IframeAuth, M as MsGraphAccount, p as MsGraphClient, 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';
|
package/dist/core-index.js
CHANGED
|
@@ -1104,6 +1104,8 @@ var AuthManager = class {
|
|
|
1104
1104
|
error = null;
|
|
1105
1105
|
client = null;
|
|
1106
1106
|
user = null;
|
|
1107
|
+
/** In-flight `/v1/users/me` request, tied to the client that issued it. */
|
|
1108
|
+
userFetch = null;
|
|
1107
1109
|
standaloneAuth = null;
|
|
1108
1110
|
iframeAuth = null;
|
|
1109
1111
|
guidyBridge = null;
|
|
@@ -1547,20 +1549,40 @@ var AuthManager = class {
|
|
|
1547
1549
|
this.scheduleTokenRefresh(tokens);
|
|
1548
1550
|
this.notify();
|
|
1549
1551
|
if (isNewSession || !this.user) {
|
|
1550
|
-
this.fetchUser();
|
|
1552
|
+
void this.fetchUser();
|
|
1551
1553
|
}
|
|
1552
1554
|
}
|
|
1553
|
-
/**
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1555
|
+
/**
|
|
1556
|
+
* Fetch the current user from /v1/users/me. Silently sets user to null on failure.
|
|
1557
|
+
*
|
|
1558
|
+
* Concurrent calls share one request: `setAuthenticated` fetches whenever the
|
|
1559
|
+
* user is still missing, so a second token push that lands while the first
|
|
1560
|
+
* fetch is in flight (e.g. stored tokens restored on load, then the host or a
|
|
1561
|
+
* bridge pushing its session) would otherwise fire a duplicate request. A
|
|
1562
|
+
* result is dropped if the client changed meanwhile (sign-out or a new
|
|
1563
|
+
* session), so a stale user never overwrites the current one.
|
|
1564
|
+
*/
|
|
1565
|
+
fetchUser() {
|
|
1566
|
+
const { client } = this;
|
|
1567
|
+
if (!client) return Promise.resolve();
|
|
1568
|
+
if (this.userFetch?.client === client) return this.userFetch.promise;
|
|
1569
|
+
const promise = (async () => {
|
|
1570
|
+
let user = null;
|
|
1571
|
+
try {
|
|
1572
|
+
const response = await client.get("/v1/users/me");
|
|
1573
|
+
const maybeUser = response;
|
|
1574
|
+
user = maybeUser && typeof maybeUser === "object" && "id" in maybeUser && "email" in maybeUser ? maybeUser : response.data;
|
|
1575
|
+
} catch {
|
|
1576
|
+
user = null;
|
|
1577
|
+
}
|
|
1578
|
+
if (this.client !== client) return;
|
|
1579
|
+
this.user = user;
|
|
1580
|
+
this.notify();
|
|
1581
|
+
})().finally(() => {
|
|
1582
|
+
if (this.userFetch?.promise === promise) this.userFetch = null;
|
|
1583
|
+
});
|
|
1584
|
+
this.userFetch = { client, promise };
|
|
1585
|
+
return promise;
|
|
1564
1586
|
}
|
|
1565
1587
|
/**
|
|
1566
1588
|
* Create a RestApiClient with a custom TokenManager that proactively
|