From 87967b757897c615554f48025facdb42c49708c5 Mon Sep 17 00:00:00 2001 From: Sonali Deshpande <48232592+sonalideshpandemsft@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:34:04 -0800 Subject: [PATCH] (odsp-client): Add oid to audience interface (#18594) The returned audience payload contains the user's name, email, id and oid. Both the id and email fields share the same response, representing the user's email id. This PR introduces the addition of oid to the OdspUser interface. The OdpMember's userId is equal to OdspUser's oid. [AB#6278](https://dev.azure.com/fluidframework/internal/_workitems/edit/6276) --- .../odsp-client/api-report/odsp-client.api.md | 3 +- .../odsp-client/src/interfaces.ts | 21 +++++--------- .../odsp-client/src/odspAudience.ts | 28 ++++++++++++++++--- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/service-clients/odsp-client/api-report/odsp-client.api.md b/packages/service-clients/odsp-client/api-report/odsp-client.api.md index a158843c813e6..3c80184b49732 100644 --- a/packages/service-clients/odsp-client/api-report/odsp-client.api.md +++ b/packages/service-clients/odsp-client/api-report/odsp-client.api.md @@ -57,10 +57,9 @@ export interface OdspContainerServices { // @alpha export interface OdspMember extends IMember { - // (undocumented) email: string; - // (undocumented) name: string; + userId: string; } // (No @packageDocumentation comment for this package) diff --git a/packages/service-clients/odsp-client/src/interfaces.ts b/packages/service-clients/odsp-client/src/interfaces.ts index c5154d0e1318b..5fdb67c480f3d 100644 --- a/packages/service-clients/odsp-client/src/interfaces.ts +++ b/packages/service-clients/odsp-client/src/interfaces.ts @@ -4,7 +4,6 @@ */ import { type ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; import type { IMember, IServiceAudience } from "@fluidframework/fluid-static"; -import { type IUser } from "@fluidframework/protocol-definitions"; import { IConfigProviderBase } from "@fluidframework/core-interfaces"; import { IOdspTokenProvider } from "./token"; @@ -68,31 +67,25 @@ export interface OdspContainerServices { /** * Since ODSP provides user names and email for all of its members, we extend the * {@link @fluidframework/protocol-definitions#IMember} interface to include this service-specific value. + * It will be returned for all audience members connected. + * * @alpha */ -export interface OdspUser extends IUser { +export interface OdspMember extends IMember { + /** + * The object ID (oid) for the user, unique among each individual user connecting to the session. + */ + userId: string; /** * The user's name */ name: string; - /** * The user's email */ email: string; } -/** - * Since ODSP provides user names and email for all of its members, we extend the - * {@link @fluidframework/protocol-definitions#IMember} interface to include this service-specific value. - * It will be returned for all audience members connected. - * @alpha - */ -export interface OdspMember extends IMember { - name: string; - email: string; -} - /** * Audience object for ODSP containers * @alpha diff --git a/packages/service-clients/odsp-client/src/odspAudience.ts b/packages/service-clients/odsp-client/src/odspAudience.ts index 6e817abec0061..f930a49cef3ca 100644 --- a/packages/service-clients/odsp-client/src/odspAudience.ts +++ b/packages/service-clients/odsp-client/src/odspAudience.ts @@ -5,17 +5,37 @@ import { assert } from "@fluidframework/core-utils"; import { type IClient } from "@fluidframework/protocol-definitions"; -import { type OdspMember, OdspUser } from "./interfaces"; +import { type OdspMember } from "./interfaces"; + +/** + * Since ODSP provides user names, email and oids for all of its members, we extend the + * {@link @fluidframework/protocol-definitions#IMember} interface to include this service-specific value. + * @internal + */ +interface OdspUser { + /** + * The user's email address + */ + email: string; + /** + * The user's name + */ + name: string; + /** + * The object ID (oid). It is a unique identifier assigned to each user, group, or other entity within AAD or another Microsoft 365 service. It is a GUID that uniquely identifies the object. When making Microsoft Graph API calls, you might need to reference or manipulate objects within the directory, and the `oid` is used to identify these objects. + */ + oid: string; +} export function createOdspAudienceMember(audienceMember: IClient): OdspMember { - const user = audienceMember.user as OdspUser; + const user = audienceMember.user as unknown as OdspUser; assert( - user.name !== undefined || user.email !== undefined, + user.name !== undefined || user.email !== undefined || user.oid !== undefined, 0x836 /* Provided user was not an "OdspUser". */, ); return { - userId: user.id, + userId: user.oid, name: user.name, email: user.email, connections: [],