Skip to content

Commit

Permalink
(odsp-client): Add oid to audience interface (#18594)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
sonalideshpandemsft authored Dec 6, 2023
1 parent 7a8b0b1 commit 87967b7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 7 additions & 14 deletions packages/service-clients/odsp-client/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down
28 changes: 24 additions & 4 deletions packages/service-clients/odsp-client/src/odspAudience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 87967b7

Please sign in to comment.