@microsoft/teamsfx 1.2.1-rc.1 → 2.0.0-alpha.7f7c9560f.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "1.2.1-rc.1",
3
+ "version": "2.0.0-alpha.7f7c9560f.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.node.cjs.js",
6
6
  "browser": "dist/index.esm2017.js",
@@ -49,7 +49,7 @@
49
49
  "@azure/identity": "^2.0.1",
50
50
  "@azure/msal-browser": "^2.21.0",
51
51
  "@azure/msal-node": "~1.1.0",
52
- "@microsoft/adaptivecards-tools": "^1.1.0-rc.0",
52
+ "@microsoft/adaptivecards-tools": "1.1.1-alpha.7f7c9560f.0",
53
53
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
54
  "axios": "^0.27.2",
55
55
  "botbuilder": ">=4.15.0 <5.0.0",
@@ -61,7 +61,7 @@
61
61
  "uuid": "^8.3.2"
62
62
  },
63
63
  "peerDependencies": {
64
- "@microsoft/teams-js": "^1.9.0"
64
+ "@microsoft/teams-js": "^2.0.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@azure/arm-sql": "^9.0.0",
@@ -70,7 +70,7 @@
70
70
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
71
71
  "@microsoft/api-documenter": "^7.14.1",
72
72
  "@microsoft/api-extractor": "^7.19.4",
73
- "@microsoft/teams-js": "^1.9.0",
73
+ "@microsoft/teams-js": "^2.0.0",
74
74
  "@rollup/plugin-json": "^4.1.0",
75
75
  "@types/chai": "^4.2.22",
76
76
  "@types/chai-as-promised": "^7.1.4",
@@ -129,7 +129,7 @@
129
129
  "webpack": "^5.62.1",
130
130
  "yargs": "^17.2.1"
131
131
  },
132
- "gitHead": "4a129d1ba158b94149387811fe2d58e6a2ef1801",
132
+ "gitHead": "4f3371e41a093a0187cdcebca076b4f491de004f",
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
@@ -127,6 +127,7 @@ export declare class AppCredential implements TokenCredential {
127
127
  * @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret or tenant id is not found in config.
128
128
  * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
129
129
  */
130
+ constructor(authConfig: AppCredentialAuthConfig);
130
131
  constructor(authConfig: AuthenticationConfiguration);
131
132
  /**
132
133
  * Get access token for credential.
@@ -163,6 +164,11 @@ export declare class AppCredential implements TokenCredential {
163
164
  private loadAndValidateConfig;
164
165
  }
165
166
 
167
+ /**
168
+ * Authentication configuration for AppCredential used in node environment
169
+ */
170
+ export declare type AppCredentialAuthConfig = OnBehalfOfCredentialAuthConfig;
171
+
166
172
  /**
167
173
  * Authentication related configuration.
168
174
  */
@@ -287,7 +293,9 @@ export declare interface BotSsoConfig {
287
293
  * The list of scopes for which the token will have access
288
294
  */
289
295
  scopes: string[];
290
- } & AuthenticationConfiguration;
296
+ } & ((OnBehalfOfCredentialAuthConfig & {
297
+ initiateLoginEndpoint: string;
298
+ }) | AuthenticationConfiguration);
291
299
  dialog?: {
292
300
  /**
293
301
  * Custom sso execution activity handler class which should implement the interface {@link BotSsoExecutionActivityHandler}. If not provided, it will use {@link DefaultBotSsoExecutionActivityHandler} by default
@@ -397,6 +405,7 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
397
405
  * @param teamsfx {@link TeamsFx} instance for authentication
398
406
  */
399
407
  constructor(dedupStorage: Storage_2, ssoPromptSettings: TeamsBotSsoPromptSettings, teamsfx: TeamsFx, dialogName?: string);
408
+ constructor(dedupStorage: Storage_2, ssoPromptSettings: TeamsBotSsoPromptSettings, authConfig: OnBehalfOfCredentialAuthConfig, initiateLoginEndpoint: string, dialogName?: string);
400
409
  /**
401
410
  * Add TeamsFxBotSsoCommandHandler instance
402
411
  * @param handler {@link BotSsoExecutionDialogHandler} callback function
@@ -803,7 +812,6 @@ export declare function createApiClient(apiEndpoint: string, authProvider: AuthP
803
812
 
804
813
  /**
805
814
  * Get Microsoft graph client.
806
- *
807
815
  * @example
808
816
  * Get Microsoft graph client by TokenCredential
809
817
  * ```typescript
@@ -852,6 +860,59 @@ export declare function createApiClient(apiEndpoint: string, authProvider: AuthP
852
860
  */
853
861
  export declare function createMicrosoftGraphClient(teamsfx: TeamsFxConfiguration, scopes?: string | string[]): Client;
854
862
 
863
+ /**
864
+ * Get Microsoft graph client.
865
+ * @example
866
+ * Get Microsoft graph client by TokenCredential
867
+ * ```typescript
868
+ * // In browser: TeamsUserCredential
869
+ * const authConfig: TeamsUserCredentialAuthConfig = {
870
+ * clientId: "xxx",
871
+ initiateLoginEndpoint: "https://xxx/auth-start.html",
872
+ * };
873
+
874
+ * const credential = new TeamsUserCredential(authConfig);
875
+
876
+ * const scope = "User.Read";
877
+ * await credential.login(scope);
878
+
879
+ * const client = createMicrosoftGraphClientWithCredential(credential, scope);
880
+
881
+ * // In node: OnBehalfOfUserCredential
882
+ * const oboAuthConfig: OnBehalfOfCredentialAuthConfig = {
883
+ * authorityHost: "xxx",
884
+ * clientId: "xxx",
885
+ * tenantId: "xxx",
886
+ * clientSecret: "xxx",
887
+ * };
888
+
889
+ * const oboCredential = new OnBehalfOfUserCredential(ssoToken, oboAuthConfig);
890
+ * const scope = "User.Read";
891
+ * const client = createMicrosoftGraphClientWithCredential(oboCredential, scope);
892
+
893
+ * // In node: AppCredential
894
+ * const appAuthConfig: AppCredentialAuthConfig = {
895
+ * authorityHost: "xxx",
896
+ * clientId: "xxx",
897
+ * tenantId: "xxx",
898
+ * clientSecret: "xxx",
899
+ * };
900
+ * const appCredential = new AppCredential(appAuthConfig);
901
+ * const scope = "User.Read";
902
+ * const client = createMicrosoftGraphClientWithCredential(appCredential, scope);
903
+ *
904
+ * const profile = await client.api("/me").get();
905
+ * ```
906
+ *
907
+ * @param {TokenCredential} credential - Used to provide configuration and auth.
908
+ * @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.
909
+ *
910
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
911
+ *
912
+ * @returns Graph client with specified scopes.
913
+ */
914
+ export declare function createMicrosoftGraphClientWithCredential(credential: TokenCredential, scopes?: string | string[]): Client;
915
+
855
916
  /**
856
917
  * Helper to create SecureContextOptions from PEM format cert
857
918
  *
@@ -1003,6 +1064,8 @@ export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
1003
1064
  /**
1004
1065
  * Generate connection configuration consumed by tedious.
1005
1066
  *
1067
+ * @deprecated we recommend you compose your own Tedious configuration for better flexibility.
1068
+ *
1006
1069
  * @param {TeamsFx} teamsfx - Used to provide configuration and auth
1007
1070
  * @param { string? } databaseName - specify database name to override default one if there are multiple databases.
1008
1071
  *
@@ -1018,6 +1081,27 @@ export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseNam
1018
1081
  * Users execute query in message extension with SSO or access token.
1019
1082
  *
1020
1083
  * @param {TurnContext} context - The context object for the current turn.
1084
+ * @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
1085
+ * @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
1086
+ * @param {string| string[]} scopes - The list of scopes for which the token will have access.
1087
+ * @param {function} logic - Business logic when executing the query in message extension with SSO or access token.
1088
+ *
1089
+ * @throws {@link ErrorCode|InternalError} when User invoke not response to message extension query.
1090
+ * @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
1091
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1092
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1093
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1094
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1095
+ *
1096
+ * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
1097
+ */
1098
+ export declare function handleMessageExtensionQueryWithSSO(context: TurnContext, config: OnBehalfOfCredentialAuthConfig, initiateLoginEndpoint: string, scopes: string | string[], logic: (token: MessageExtensionTokenResponse) => Promise<any>): Promise<void | MessagingExtensionResponse>;
1099
+
1100
+ /**
1101
+ * Users execute query in message extension with SSO or access token.
1102
+ *
1103
+ *
1104
+ * @param {TurnContext} context - The context object for the current turn.
1021
1105
  * @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
1022
1106
  * @param {string| string[]} scopes - The list of scopes for which the token will have access.
1023
1107
  * @param {function} logic - Business logic when executing the query in message extension with SSO or access token.
@@ -1380,7 +1464,7 @@ declare interface MessageResponse {
1380
1464
  * Microsoft Graph auth provider for Teams Framework
1381
1465
  */
1382
1466
  export declare class MsGraphAuthProvider implements AuthenticationProvider {
1383
- private teamsfx;
1467
+ private credentialOrTeamsFx;
1384
1468
  private scopes;
1385
1469
  /**
1386
1470
  * Constructor of MsGraphAuthProvider.
@@ -1393,6 +1477,7 @@ export declare class MsGraphAuthProvider implements AuthenticationProvider {
1393
1477
  * @returns An instance of MsGraphAuthProvider.
1394
1478
  */
1395
1479
  constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
1480
+ constructor(credential: TokenCredential, scopes?: string | string[]);
1396
1481
  /**
1397
1482
  * Get access token for Microsoft Graph API requests.
1398
1483
  *
@@ -1586,6 +1671,40 @@ export declare enum NotificationTargetType {
1586
1671
  Person = "Person"
1587
1672
  }
1588
1673
 
1674
+ /**
1675
+ * Authentication configuration for OnBehalfOfCredential used in node environment
1676
+ */
1677
+ export declare type OnBehalfOfCredentialAuthConfig = {
1678
+ /**
1679
+ * Hostname of AAD authority.
1680
+ */
1681
+ authorityHost: string;
1682
+ /**
1683
+ * The client (application) ID of an App Registration in the tenant
1684
+ */
1685
+ clientId: string;
1686
+ /**
1687
+ * AAD tenant id
1688
+ *
1689
+ * @readonly
1690
+ */
1691
+ tenantId: string;
1692
+ } & ({
1693
+ /**
1694
+ * Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal.
1695
+ */
1696
+ clientSecret: string;
1697
+ certificateContent?: never;
1698
+ } | {
1699
+ clientSecret?: never;
1700
+ /**
1701
+ * The content of a PEM-encoded public/private key certificate.
1702
+ *
1703
+ * @readonly
1704
+ */
1705
+ certificateContent: string;
1706
+ });
1707
+
1589
1708
  /**
1590
1709
  * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
1591
1710
  *
@@ -1613,6 +1732,7 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
1613
1732
  * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1614
1733
  * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1615
1734
  */
1735
+ constructor(ssoToken: string, config: OnBehalfOfCredentialAuthConfig);
1616
1736
  constructor(ssoToken: string, config: AuthenticationConfiguration);
1617
1737
  /**
1618
1738
  * Get access token from credential.
@@ -1875,7 +1995,8 @@ export declare class TeamsBotInstallation implements NotificationTarget {
1875
1995
  * ```
1876
1996
  */
1877
1997
  export declare class TeamsBotSsoPrompt extends Dialog {
1878
- private teamsfx;
1998
+ private authConfig;
1999
+ private initiateLoginEndpoint;
1879
2000
  private settings;
1880
2001
  /**
1881
2002
  * Constructor of TeamsBotSsoPrompt.
@@ -1888,6 +2009,7 @@ export declare class TeamsBotSsoPrompt extends Dialog {
1888
2009
  * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1889
2010
  */
1890
2011
  constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
2012
+ constructor(authConfig: OnBehalfOfCredentialAuthConfig, initiateLoginEndpoint: string, dialogId: string, settings: TeamsBotSsoPromptSettings);
1891
2013
  /**
1892
2014
  * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
1893
2015
  * @remarks
@@ -2256,6 +2378,7 @@ export declare class TeamsUserCredential implements TokenCredential {
2256
2378
  * @remarks
2257
2379
  * Can only be used within Teams.
2258
2380
  */
2381
+ constructor(authConfig: TeamsUserCredentialAuthConfig);
2259
2382
  constructor(authConfig: AuthenticationConfiguration);
2260
2383
  /**
2261
2384
  * Popup login page to get user's access token with specific scopes.
@@ -2283,6 +2406,20 @@ export declare class TeamsUserCredential implements TokenCredential {
2283
2406
  getUserInfo(resources?: string[]): Promise<UserInfo>;
2284
2407
  }
2285
2408
 
2409
+ /**
2410
+ * Authentication configuration for TeamsUserCredential used in browser environment
2411
+ */
2412
+ export declare type TeamsUserCredentialAuthConfig = {
2413
+ /**
2414
+ * Login page for Teams to redirect to.
2415
+ */
2416
+ initiateLoginEndpoint: string;
2417
+ /**
2418
+ * The client (application) ID of an App Registration in the tenant
2419
+ */
2420
+ clientId: string;
2421
+ };
2422
+
2286
2423
  /**
2287
2424
  * The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
2288
2425
  */