@microsoft/teams-js 2.8.1-beta.0 → 2.9.0

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
@@ -24,7 +24,7 @@ To install the stable [version](https://learn.microsoft.com/javascript/api/overv
24
24
 
25
25
  ### Production
26
26
 
27
- You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.8.0/js/MicrosoftTeams.min.js) or point your package manager at them.
27
+ You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.9.0/js/MicrosoftTeams.min.js) or point your package manager at them.
28
28
 
29
29
  ## Usage
30
30
 
@@ -45,13 +45,13 @@ Reference the library inside of your `.html` page using:
45
45
  ```html
46
46
  <!-- Microsoft Teams JavaScript API (via CDN) -->
47
47
  <script
48
- src="https://res.cdn.office.net/teams-js/2.8.0/js/MicrosoftTeams.min.js"
49
- integrity="sha384-/DJ9oJEFZSpGiUQx9Na5Yb5svOPPqSb3khKxJ/YgoZ2GtrkzWgSTBpESy3LvMPVk"
48
+ src="https://res.cdn.office.net/teams-js/2.9.0/js/MicrosoftTeams.min.js"
49
+ integrity="sha384-wh4L8gn9alg8jFXiHwEw/IgcfK7aT/6Pyby/p5B7zHM+a0Jek5MxzO7AvSlRFvsC"
50
50
  crossorigin="anonymous"
51
51
  ></script>
52
52
 
53
53
  <!-- Microsoft Teams JavaScript API (via npm) -->
54
- <script src="node_modules/@microsoft/teams-js@2.8.0/dist/MicrosoftTeams.min.js"></script>
54
+ <script src="node_modules/@microsoft/teams-js@2.9.0/dist/MicrosoftTeams.min.js"></script>
55
55
 
56
56
  <!-- Microsoft Teams JavaScript API (via local) -->
57
57
  <script src="MicrosoftTeams.min.js"></script>
@@ -2075,7 +2075,7 @@ export namespace videoEx {
2075
2075
  * @internal
2076
2076
  * Limited to Microsoft-internal use
2077
2077
  */
2078
- interface VideoFrame extends video.VideoFrame {
2078
+ interface VideoFrame extends video.VideoFrameData {
2079
2079
  /**
2080
2080
  * @hidden
2081
2081
  * The model output if you passed in an {@linkcode VideoFrameConfig.audioInferenceModel}
@@ -2208,26 +2208,45 @@ export namespace videoEx {
2208
2208
  * This object is used for starting or completing authentication flows.
2209
2209
  */
2210
2210
  export namespace authentication {
2211
+ /**
2212
+ * @hidden
2213
+ * @internal
2214
+ * Limited to Microsoft-internal use; automatically called when library is initialized
2215
+ */
2211
2216
  function initialize(): void;
2212
2217
  /**
2213
2218
  * @deprecated
2214
- * As of 2.0.0, this function has been deprecated in favor of a Promise-based pattern.
2215
- * Registers the authentication Communication.handlers
2219
+ * As of 2.0.0, this function has been deprecated in favor of a Promise-based pattern using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}
2216
2220
  *
2217
- * @param authenticateParameters - A set of values that configure the authentication pop-up.
2221
+ * Registers handlers to be called with the result of an authentication flow triggered using {@link authentication.authenticate authentication.authenticate(authenticateParameters?: AuthenticateParameters): void}
2222
+ *
2223
+ * @param authenticateParameters - Configuration for authentication flow pop-up result communication
2218
2224
  */
2219
2225
  function registerAuthenticationHandlers(authenticateParameters: AuthenticateParameters): void;
2220
2226
  /**
2221
- * Initiates an authentication request, which opens a new window with the specified settings.
2227
+ * Initiates an authentication flow which requires a new window.
2228
+ * There are two primary uses for this function:
2229
+ * 1. When your app needs to authenticate using a 3rd-party identity provider (not Azure Active Directory)
2230
+ * 2. When your app needs to show authentication UI that is blocked from being shown in an iframe (e.g., Azure Active Directory consent prompts)
2231
+ *
2232
+ * For more details, see [Enable authentication using third-party OAuth provider](https://learn.microsoft.com/microsoftteams/platform/tabs/how-to/authentication/auth-flow-tab)
2233
+ *
2234
+ * This function is *not* needed for "standard" Azure SSO usage. Using {@link getAuthToken} is usually sufficient in that case. For more, see
2235
+ * [Enable SSO for tab apps](https://learn.microsoft.com/microsoftteams/platform/tabs/how-to/authentication/tab-sso-overview))
2222
2236
  *
2223
2237
  * @remarks
2224
2238
  * The authentication flow must start and end from the same domain, otherwise success and failure messages won't be returned to the window that initiated the call.
2239
+ * The [Teams authentication flow](https://learn.microsoft.com/microsoftteams/platform/tabs/how-to/authentication/auth-flow-tab) starts and ends at an endpoint on
2240
+ * your own service (with a redirect round-trip to the 3rd party identity provider in the middle).
2225
2241
  *
2226
- * @param authenticateParameters - The parameters for the authentication request. It is a required parameter since v2 upgrade
2242
+ * @param authenticateParameters - Parameters describing the authentication window used for executing the authentication flow
2227
2243
  *
2228
- * @returns Promise that will be fulfilled with the result from the authentication pop-up if successful.
2244
+ * @returns `Promise` that will be fulfilled with the result from the authentication pop-up, if successful. The string in this result is provided in the parameter
2245
+ * passed by your app when it calls {@link notifySuccess} in the pop-up window after returning from the identity provider redirect.
2229
2246
  *
2230
- * @throws Error if the authentication request fails or is canceled by the user.
2247
+ * @throws `Error` if the authentication request fails or is canceled by the user. This error is provided in the parameter passed by your app when it calls
2248
+ * {@link notifyFailure} in the pop-up window after returning from the identity provider redirect. However, in some cases it can also be provided by
2249
+ * the infrastructure depending on the failure (e.g., a user cancelation)
2231
2250
  *
2232
2251
  */
2233
2252
  function authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise<string>;
@@ -2235,30 +2254,36 @@ export namespace authentication {
2235
2254
  * @deprecated
2236
2255
  * As of 2.0.0, please use {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} instead.
2237
2256
  *
2238
- * Initiates an authentication request, which opens a new window with the specified settings.
2257
+ * The documentation for {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} applies
2258
+ * to this function.
2259
+ * The one difference is that instead of the result being returned via the `Promise`, the result is returned to the callback functions provided in the
2260
+ * `authenticateParameters` parameter.
2239
2261
  *
2240
- * @remarks
2241
- * The authentication flow must start and end from the same domain, otherwise success and failure messages won't be returned to the window that initiated the call.
2242
- *
2243
- * @param authenticateParameters - The parameters for the authentication request.
2262
+ * @param authenticateParameters - Parameters describing the authentication window used for executing the authentication flow and callbacks used for indicating the result
2244
2263
  *
2245
2264
  */
2246
2265
  function authenticate(authenticateParameters?: AuthenticateParameters): void;
2247
2266
  /**
2248
- * Requests an Azure AD token to be issued on behalf of the app. The token is acquired from the cache
2249
- * if it is not expired. Otherwise a request is sent to Azure AD to obtain a new token.
2267
+ * Requests an Azure AD token to be issued on behalf of your app in an SSO flow.
2268
+ * The token is acquired from the cache if it is not expired. Otherwise a request is sent to Azure AD to
2269
+ * obtain a new token.
2270
+ * This function is used to enable SSO scenarios. See [Enable SSO for tab apps](https://learn.microsoft.com/microsoftteams/platform/tabs/how-to/authentication/tab-sso-overview)
2271
+ * for more details.
2250
2272
  *
2251
2273
  * @param authTokenRequest - An optional set of values that configure the token request.
2252
2274
  *
2253
- * @returns Promise that will be fulfilled with the token if successful.
2275
+ * @returns `Promise` that will be resolved with the token, if successful.
2276
+ *
2277
+ * @throws `Error` if the request fails in some way
2254
2278
  */
2255
2279
  function getAuthToken(authTokenRequest?: AuthTokenRequestParameters): Promise<string>;
2256
2280
  /**
2257
2281
  * @deprecated
2258
2282
  * As of 2.0.0, please use {@link authentication.getAuthToken authentication.getAuthToken(authTokenRequest: AuthTokenRequestParameters): Promise\<string\>} instead.
2259
2283
  *
2260
- * Requests an Azure AD token to be issued on behalf of the app. The token is acquired from the cache
2261
- * if it is not expired. Otherwise a request is sent to Azure AD to obtain a new token.
2284
+ * The documentation {@link authentication.getAuthToken authentication.getAuthToken(authTokenRequest: AuthTokenRequestParameters): Promise\<string\>} applies to this
2285
+ * function as well. The one difference when using this function is that the result is provided in the callbacks in the `authTokenRequest` parameter
2286
+ * instead of as a `Promise`.
2262
2287
  *
2263
2288
  * @param authTokenRequest - An optional set of values that configure the token request.
2264
2289
  * It contains callbacks to call in case of success/failure
@@ -2287,30 +2312,39 @@ export namespace authentication {
2287
2312
  */
2288
2313
  function getUser(userRequest: UserRequest): void;
2289
2314
  /**
2290
- * Notifies the frame that initiated this authentication request that the request was successful.
2315
+ * When using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}, the
2316
+ * window that was opened to execute the authentication flow should call this method after authentiction to notify the caller of
2317
+ * {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} that the
2318
+ * authentication request was successful.
2291
2319
  *
2292
2320
  * @remarks
2293
- * This function is usable only on the authentication window.
2321
+ * This function is usable only from the authentication window.
2294
2322
  * This call causes the authentication window to be closed.
2295
2323
  *
2296
- * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives this value in its callback.
2324
+ * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives
2325
+ * this value in its callback or via the `Promise` return value
2297
2326
  * @param callbackUrl - Specifies the url to redirect back to if the client is Win32 Outlook.
2298
2327
  */
2299
2328
  function notifySuccess(result?: string, callbackUrl?: string): void;
2300
2329
  /**
2301
- * Notifies the frame that initiated this authentication request that the request failed.
2330
+ * When using {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}, the
2331
+ * window that was opened to execute the authentication flow should call this method after authentiction to notify the caller of
2332
+ * {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} that the
2333
+ * authentication request failed.
2334
+
2302
2335
  *
2303
2336
  * @remarks
2304
2337
  * This function is usable only on the authentication window.
2305
2338
  * This call causes the authentication window to be closed.
2306
2339
  *
2307
- * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives this value in its callback.
2340
+ * @param result - Specifies a result for the authentication. If specified, the frame that initiated the authentication pop-up receives
2341
+ * this value in its callback or via the `Promise` return value
2308
2342
  * @param callbackUrl - Specifies the url to redirect back to if the client is Win32 Outlook.
2309
2343
  */
2310
2344
  function notifyFailure(reason?: string, callbackUrl?: string): void;
2311
2345
  /**
2312
2346
  * @deprecated
2313
- * As of 2.0.0, this interface has been deprecated in favor of a Promise-based pattern.
2347
+ * As of 2.0.0, this interface has been deprecated in favor of leveraging the `Promise` returned from {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>}
2314
2348
  *-------------------------
2315
2349
  * Used in {@link AuthenticateParameters} and {@link AuthTokenRequest}
2316
2350
  */
@@ -2318,12 +2352,14 @@ export namespace authentication {
2318
2352
  /**
2319
2353
  * @deprecated
2320
2354
  * As of 2.0.0, this property has been deprecated in favor of a Promise-based pattern.
2355
+ *
2321
2356
  * A function that is called if the request succeeds.
2322
2357
  */
2323
2358
  successCallback?: (result: string) => void;
2324
2359
  /**
2325
2360
  * @deprecated
2326
2361
  * As of 2.0.0, this property has been deprecated in favor of a Promise-based pattern.
2362
+ *
2327
2363
  * A function that is called if the request fails, with the reason for the failure.
2328
2364
  */
2329
2365
  failureCallback?: (reason: string) => void;
@@ -2345,13 +2381,22 @@ export namespace authentication {
2345
2381
  */
2346
2382
  height?: number;
2347
2383
  /**
2348
- * The flag which indicates whether the auth page should be opened in an external browser. This flag has no effect on the web client.
2384
+ * Some identity providers restrict their authentication pages from being displayed in embedded browsers (e.g., a web view inside of a native application)
2385
+ * If the identity provider you are using prevents embedded browser usage, this flag should be set to `true` to enable the authentication page specified in
2386
+ * the {@link url} property to be opened in an external browser.
2387
+ * If this flag is `false`, the page will be opened directly within the current hosting application.
2388
+ *
2389
+ * This flag is ignored when the host for the application is a web app (as opposed to a native application) as the behavior is unnecessary in a web-only
2390
+ * environment without an embedded browser.
2349
2391
  */
2350
2392
  isExternal?: boolean;
2351
2393
  }
2352
2394
  /**
2353
2395
  * @deprecated
2354
- * As of 2.0.0, please use {@link AuthenticatePopUpParameters} instead.
2396
+ * As of 2.0.0, please use {@link authentication.authenticate authentication.authenticate(authenticateParameters: AuthenticatePopUpParameters): Promise\<string\>} and
2397
+ * the associated {@link AuthenticatePopUpParameters} instead.
2398
+ *
2399
+ * @see {@link LegacyCallBacks}
2355
2400
  */
2356
2401
  type AuthenticateParameters = AuthenticatePopUpParameters & LegacyCallBacks;
2357
2402
  /**
@@ -2359,7 +2404,9 @@ export namespace authentication {
2359
2404
  */
2360
2405
  interface AuthTokenRequestParameters {
2361
2406
  /**
2362
- * An optional list of resource for which to acquire the access token; only used for full trust apps.
2407
+ * @hidden
2408
+ * @internal
2409
+ * An list of resources for which to acquire the access token; only for internal Microsoft usage
2363
2410
  */
2364
2411
  resources?: string[];
2365
2412
  /**
@@ -6624,7 +6671,7 @@ export namespace video {
6624
6671
  * Represents a video frame
6625
6672
  * @beta
6626
6673
  */
6627
- interface VideoFrame {
6674
+ interface VideoFrameData {
6628
6675
  /**
6629
6676
  * Video frame width
6630
6677
  */
@@ -6636,7 +6683,7 @@ export namespace video {
6636
6683
  /**
6637
6684
  * Video frame buffer
6638
6685
  */
6639
- data: Uint8ClampedArray;
6686
+ videoFrameBuffer: Uint8ClampedArray;
6640
6687
  /**
6641
6688
  * NV12 luma stride, valid only when video frame format is NV12
6642
6689
  */
@@ -6659,7 +6706,7 @@ export namespace video {
6659
6706
  * @beta
6660
6707
  */
6661
6708
  enum VideoFrameFormat {
6662
- NV12 = 0
6709
+ NV12 = "NV12"
6663
6710
  }
6664
6711
  /**
6665
6712
  * Video frame configuration supplied to the host to customize the generated video frame parameters, like format
@@ -6689,12 +6736,28 @@ export namespace video {
6689
6736
  * Video frame call back function definition
6690
6737
  * @beta
6691
6738
  */
6692
- type VideoFrameCallback = (frame: VideoFrame, notifyVideoFrameProcessed: () => void, notifyError: (errorMessage: string) => void) => void;
6739
+ type VideoFrameCallback = (frame: VideoFrameData, notifyVideoFrameProcessed: () => void, notifyError: (errorMessage: string) => void) => void;
6740
+ /**
6741
+ * Predefined failure reasons for preparing the selected video effect
6742
+ * @beta
6743
+ */
6744
+ enum EffectFailureReason {
6745
+ /**
6746
+ * A wrong effect id is provide.
6747
+ * Use this reason when the effect id is not found or empty, this may indicate a mismatch between the app and its manifest or a bug of the host.
6748
+ */
6749
+ InvalidEffectId = "InvalidEffectId",
6750
+ /**
6751
+ * The effect can't be initialized
6752
+ */
6753
+ InitializationFailure = "InitializationFailure"
6754
+ }
6693
6755
  /**
6694
6756
  * Video effect change call back function definition
6757
+ * Return a Promise which will be resolved when the effect is prepared, or throw an {@link EffectFailureReason} on error.
6695
6758
  * @beta
6696
6759
  */
6697
- type VideoEffectCallBack = (effectId: string | undefined) => void;
6760
+ type VideoEffectCallback = (effectId: string | undefined) => Promise<void>;
6698
6761
  /**
6699
6762
  * Register to read the video frames in Permissions section
6700
6763
  * @beta
@@ -6712,11 +6775,11 @@ export namespace video {
6712
6775
  */
6713
6776
  function notifySelectedVideoEffectChanged(effectChangeType: EffectChangeType, effectId: string | undefined): void;
6714
6777
  /**
6715
- * Register the video effect callback, host uses this to notify the video extension the new video effect will by applied
6778
+ * Register a callback to be notified when a new video effect is applied.
6716
6779
  * @beta
6717
- * @param callback - The VideoEffectCallback to invoke when registerForVideoEffect has completed
6780
+ * @param callback - Function to be called when new video effect is applied.
6718
6781
  */
6719
- function registerForVideoEffect(callback: VideoEffectCallBack): void;
6782
+ function registerForVideoEffect(callback: VideoEffectCallback): void;
6720
6783
  /**
6721
6784
  * Checks if video capability is supported by the host
6722
6785
  * @beta
@@ -6726,6 +6789,56 @@ export namespace video {
6726
6789
  *
6727
6790
  */
6728
6791
  function isSupported(): boolean;
6792
+ /**
6793
+ * @beta
6794
+ * Namespace to get video frames from a media stream.
6795
+ * When the host supports this capability, developer should call {@link mediaStream.registerForVideoFrame} to get the video frames instead of {@link registerForVideoFrame} to get the video frames, callback of {@link registerForVideoFrame} will be ignored when the host supports this capability.
6796
+ */
6797
+ namespace mediaStream {
6798
+ /**
6799
+ * @beta
6800
+ * Checks if video.mediaStream capability is supported by the host
6801
+ * @returns boolean to represent whether the video.medisStream capability is supported
6802
+ *
6803
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
6804
+ *
6805
+ */
6806
+ function isSupported(): boolean;
6807
+ /**
6808
+ * @beta
6809
+ * Video frame data extracted from the media stream. More properties may be added in the future.
6810
+ */
6811
+ type MediaStreamFrameData = {
6812
+ /**
6813
+ * The video frame from the media stream.
6814
+ */
6815
+ videoFrame: VideoFrame;
6816
+ };
6817
+ /**
6818
+ * @beta
6819
+ * Video effect change call back function definition.
6820
+ * The video app should resolve the promise to notify a successfully processed video frame.
6821
+ * The video app should reject the promise to notify a failure.
6822
+ */
6823
+ type VideoFrameCallback = (receivedVideoFrame: MediaStreamFrameData) => Promise<VideoFrame>;
6824
+ /**
6825
+ * @beta
6826
+ * Register to read the video frames from the media stream provided by the host.
6827
+ * @param frameCallback - The callback to invoke when recieve a video frame from the media stream.
6828
+ * @example
6829
+ * ```typescript
6830
+ * video.mediaStream.registerForVideoFrame(async (receivedVideoFrame) => {
6831
+ * const { videoFrame } = receivedVideoFrame;
6832
+ * try {
6833
+ * return await processVideoFrame(videoFrame);
6834
+ * } catch (error) {
6835
+ * throw error;
6836
+ * }
6837
+ * });
6838
+ * ```
6839
+ */
6840
+ function registerForVideoFrame(frameCallback: VideoFrameCallback): void;
6841
+ }
6729
6842
  }
6730
6843
 
6731
6844
  /**