@microsoft/managed-apps 0.5.13 → 0.5.15
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
CHANGED
|
@@ -12,6 +12,36 @@ The package has no root entry; import from one of the subpaths below. Usage and
|
|
|
12
12
|
|
|
13
13
|
`getUser`, `IUser`.
|
|
14
14
|
|
|
15
|
+
`getUser()` returns the signed-in user's `fullName`, `objectId`, and `tenantId` supplied
|
|
16
|
+
by the host:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { getUser } from '@microsoft/managed-apps/auth';
|
|
20
|
+
|
|
21
|
+
const user = await getUser();
|
|
22
|
+
// Example host-supplied identity:
|
|
23
|
+
// {
|
|
24
|
+
// fullName: 'Alex Example',
|
|
25
|
+
// objectId: '11111111-1111-4111-8111-111111111111',
|
|
26
|
+
// tenantId: '22222222-2222-4222-8222-222222222222'
|
|
27
|
+
// }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Results are cached for the app-frame session only when both IDs contain
|
|
31
|
+
non-whitespace characters. The SDK relies on the host's typed response contract;
|
|
32
|
+
these checks determine cache eligibility, not response validation. An empty
|
|
33
|
+
`fullName` is valid when both IDs are present. Subsequent calls return the same
|
|
34
|
+
cached object without another host request; field values are never trimmed or normalized.
|
|
35
|
+
|
|
36
|
+
For compatibility, blank or partial identities still resolve successfully but are
|
|
37
|
+
not cached. A later explicit `getUser()` call requests identity from the host again;
|
|
38
|
+
there are no automatic retries. Genuine host/channel failures still reject.
|
|
39
|
+
|
|
40
|
+
An SDK-only update cannot supply IDs omitted by an older host or missing from the
|
|
41
|
+
signed-in account. Upgrade the host to receive its identity-wiring fix and open a
|
|
42
|
+
fresh host/app frame. Identity belongs to that lifetime; account changes also require
|
|
43
|
+
a fresh host/frame.
|
|
44
|
+
|
|
15
45
|
### `@microsoft/managed-apps/data`
|
|
16
46
|
|
|
17
47
|
`getClient`, `DataClient`, `IOperationOptions`, `IOperationResult`, `serializeMultiSelectPicklistFields`, `deserializeMultiSelectPicklistFields`.
|
|
@@ -5,8 +5,8 @@ import type { IUser } from './Auth.Types';
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the identity of the signed-in user from the host.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Results with nonblank IDs are cached for the app-frame session.
|
|
9
|
+
* Incomplete identities are returned unchanged without caching.
|
|
10
10
|
*/
|
|
11
11
|
export declare function getUser(): Promise<IUser>;
|
|
12
12
|
//# sourceMappingURL=UserProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProvider.d.ts","sourceRoot":"","sources":["../../src/auth/UserProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"UserProvider.d.ts","sourceRoot":"","sources":["../../src/auth/UserProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAK1C;;;;;GAKG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAyB9C"}
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { Methods } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { trackEvent } from '../internal/communication/trackEvent';
|
|
5
6
|
import { getSdkChannel } from '../internal/sdkChannel';
|
|
6
7
|
let user;
|
|
8
|
+
let hasReportedInvalidIdentity = false;
|
|
7
9
|
/**
|
|
8
10
|
* Returns the identity of the signed-in user from the host.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* Results with nonblank IDs are cached for the app-frame session.
|
|
13
|
+
* Incomplete identities are returned unchanged without caching.
|
|
12
14
|
*/
|
|
13
15
|
export async function getUser() {
|
|
14
16
|
if (user) {
|
|
@@ -16,11 +18,20 @@ export async function getUser() {
|
|
|
16
18
|
}
|
|
17
19
|
const channel = await getSdkChannel();
|
|
18
20
|
const response = await channel.send(Methods.Auth.getUser);
|
|
19
|
-
|
|
21
|
+
const result = {
|
|
20
22
|
fullName: response.fullName,
|
|
21
23
|
objectId: response.objectId,
|
|
22
24
|
tenantId: response.tenantId,
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
const hasObjectId = (result.objectId?.trim().length ?? 0) > 0;
|
|
27
|
+
const hasTenantId = (result.tenantId?.trim().length ?? 0) > 0;
|
|
28
|
+
if (hasObjectId && hasTenantId) {
|
|
29
|
+
user = result;
|
|
30
|
+
}
|
|
31
|
+
else if (!hasReportedInvalidIdentity) {
|
|
32
|
+
hasReportedInvalidIdentity = true;
|
|
33
|
+
trackEvent('Auth.GetUser.InvalidIdentity', { hasObjectId, hasTenantId });
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
25
36
|
}
|
|
26
37
|
//# sourceMappingURL=UserProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProvider.js","sourceRoot":"","sources":["../../src/auth/UserProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,IAAI,IAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"UserProvider.js","sourceRoot":"","sources":["../../src/auth/UserProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,IAAI,IAAuB,CAAC;AAC5B,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,aAAa,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAU;QACpB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAE9D,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC;SAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACvC,0BAA0B,GAAG,IAAI,CAAC;QAClC,UAAU,CAAC,8BAA8B,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/managed-apps",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Client SDK for Microsoft Managed Apps",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"clean": "bun ../../scripts/clean.ts dist .turbo tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@microsoft/managed-apps-common": "0.
|
|
39
|
+
"@microsoft/managed-apps-common": "0.22.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@repo/repo-config": "0.0.0",
|