@microsoft/teamsfx 2.0.1-alpha.e8170e1dc.0 → 2.0.1-rc.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/dist/index.esm2017.js +83 -56
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +240 -81
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +85 -56
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +245 -80
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -7
- package/types/teamsfx.d.ts +2119 -1928
package/dist/index.esm2017.js
CHANGED
|
@@ -432,12 +432,6 @@ function validateScopesType(value) {
|
|
|
432
432
|
* Only works in in server side.
|
|
433
433
|
*/
|
|
434
434
|
class AppCredential {
|
|
435
|
-
/**
|
|
436
|
-
* Constructor of AppCredential.
|
|
437
|
-
*
|
|
438
|
-
* @remarks
|
|
439
|
-
* Only works in in server side.
|
|
440
|
-
*/
|
|
441
435
|
constructor(authConfig) {
|
|
442
436
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "AppCredential"), ErrorCode.RuntimeNotSupported);
|
|
443
437
|
}
|
|
@@ -460,12 +454,6 @@ class AppCredential {
|
|
|
460
454
|
* Can only be used in server side.
|
|
461
455
|
*/
|
|
462
456
|
class OnBehalfOfUserCredential {
|
|
463
|
-
/**
|
|
464
|
-
* Constructor of OnBehalfOfUserCredential
|
|
465
|
-
*
|
|
466
|
-
* @remarks
|
|
467
|
-
* Can Only works in in server side.
|
|
468
|
-
*/
|
|
469
457
|
constructor(ssoToken, config) {
|
|
470
458
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
|
|
471
459
|
}
|
|
@@ -498,28 +486,6 @@ const loginPageHeight = 535;
|
|
|
498
486
|
* Can only be used within Teams.
|
|
499
487
|
*/
|
|
500
488
|
class TeamsUserCredential {
|
|
501
|
-
/**
|
|
502
|
-
* Constructor of TeamsUserCredential.
|
|
503
|
-
*
|
|
504
|
-
* @example
|
|
505
|
-
* ```typescript
|
|
506
|
-
* const config = {
|
|
507
|
-
* authentication: {
|
|
508
|
-
* initiateLoginEndpoint: "https://localhost:3000/auth-start.html",
|
|
509
|
-
* clientId: "xxx"
|
|
510
|
-
* }
|
|
511
|
-
* }
|
|
512
|
-
* // Use default configuration provided by Teams Toolkit
|
|
513
|
-
* const credential = new TeamsUserCredential();
|
|
514
|
-
* // Use a customized configuration
|
|
515
|
-
* const anotherCredential = new TeamsUserCredential(config);
|
|
516
|
-
* ```
|
|
517
|
-
*
|
|
518
|
-
* @param {AuthenticationConfiguration} authConfig - The authentication configuration. Use environment variables if not provided.
|
|
519
|
-
*
|
|
520
|
-
* @throws {@link ErrorCode|InvalidConfiguration} when client id, initiate login endpoint or simple auth endpoint is not found in config.
|
|
521
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
522
|
-
*/
|
|
523
489
|
constructor(authConfig) {
|
|
524
490
|
internalLogger.info("Create teams user credential");
|
|
525
491
|
this.config = this.loadAndValidateConfig(authConfig);
|
|
@@ -826,18 +792,8 @@ const defaultScope = "https://graph.microsoft.com/.default";
|
|
|
826
792
|
* Microsoft Graph auth provider for Teams Framework
|
|
827
793
|
*/
|
|
828
794
|
class MsGraphAuthProvider {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
*
|
|
832
|
-
* @param {TeamsFx} teamsfx - Used to provide configuration and auth.
|
|
833
|
-
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
834
|
-
*
|
|
835
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
836
|
-
*
|
|
837
|
-
* @returns An instance of MsGraphAuthProvider.
|
|
838
|
-
*/
|
|
839
|
-
constructor(teamsfx, scopes) {
|
|
840
|
-
this.teamsfx = teamsfx;
|
|
795
|
+
constructor(credentialOrTeamsFx, scopes) {
|
|
796
|
+
this.credentialOrTeamsFx = credentialOrTeamsFx;
|
|
841
797
|
let scopesStr = defaultScope;
|
|
842
798
|
if (scopes) {
|
|
843
799
|
validateScopesType(scopes);
|
|
@@ -863,7 +819,15 @@ class MsGraphAuthProvider {
|
|
|
863
819
|
*/
|
|
864
820
|
async getAccessToken() {
|
|
865
821
|
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
|
|
866
|
-
|
|
822
|
+
let accessToken;
|
|
823
|
+
if (this.credentialOrTeamsFx.getCredential) {
|
|
824
|
+
accessToken = await this.credentialOrTeamsFx
|
|
825
|
+
.getCredential()
|
|
826
|
+
.getToken(this.scopes);
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
accessToken = await this.credentialOrTeamsFx.getToken(this.scopes);
|
|
830
|
+
}
|
|
867
831
|
return new Promise((resolve, reject) => {
|
|
868
832
|
if (accessToken) {
|
|
869
833
|
resolve(accessToken.token);
|
|
@@ -880,7 +844,6 @@ class MsGraphAuthProvider {
|
|
|
880
844
|
// Copyright (c) Microsoft Corporation.
|
|
881
845
|
/**
|
|
882
846
|
* Get Microsoft graph client.
|
|
883
|
-
*
|
|
884
847
|
* @example
|
|
885
848
|
* Get Microsoft graph client by TokenCredential
|
|
886
849
|
* ```typescript
|
|
@@ -934,6 +897,66 @@ function createMicrosoftGraphClient(teamsfx, scopes) {
|
|
|
934
897
|
authProvider,
|
|
935
898
|
});
|
|
936
899
|
return graphClient;
|
|
900
|
+
}
|
|
901
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
|
902
|
+
/**
|
|
903
|
+
* Get Microsoft graph client.
|
|
904
|
+
* @example
|
|
905
|
+
* Get Microsoft graph client by TokenCredential
|
|
906
|
+
* ```typescript
|
|
907
|
+
* // In browser: TeamsUserCredential
|
|
908
|
+
* const authConfig: TeamsUserCredentialAuthConfig = {
|
|
909
|
+
* clientId: "xxx",
|
|
910
|
+
initiateLoginEndpoint: "https://xxx/auth-start.html",
|
|
911
|
+
* };
|
|
912
|
+
|
|
913
|
+
* const credential = new TeamsUserCredential(authConfig);
|
|
914
|
+
|
|
915
|
+
* const scope = "User.Read";
|
|
916
|
+
* await credential.login(scope);
|
|
917
|
+
|
|
918
|
+
* const client = createMicrosoftGraphClientWithCredential(credential, scope);
|
|
919
|
+
|
|
920
|
+
* // In node: OnBehalfOfUserCredential
|
|
921
|
+
* const oboAuthConfig: OnBehalfOfCredentialAuthConfig = {
|
|
922
|
+
* authorityHost: "xxx",
|
|
923
|
+
* clientId: "xxx",
|
|
924
|
+
* tenantId: "xxx",
|
|
925
|
+
* clientSecret: "xxx",
|
|
926
|
+
* };
|
|
927
|
+
|
|
928
|
+
* const oboCredential = new OnBehalfOfUserCredential(ssoToken, oboAuthConfig);
|
|
929
|
+
* const scope = "User.Read";
|
|
930
|
+
* const client = createMicrosoftGraphClientWithCredential(oboCredential, scope);
|
|
931
|
+
|
|
932
|
+
* // In node: AppCredential
|
|
933
|
+
* const appAuthConfig: AppCredentialAuthConfig = {
|
|
934
|
+
* authorityHost: "xxx",
|
|
935
|
+
* clientId: "xxx",
|
|
936
|
+
* tenantId: "xxx",
|
|
937
|
+
* clientSecret: "xxx",
|
|
938
|
+
* };
|
|
939
|
+
* const appCredential = new AppCredential(appAuthConfig);
|
|
940
|
+
* const scope = "User.Read";
|
|
941
|
+
* const client = createMicrosoftGraphClientWithCredential(appCredential, scope);
|
|
942
|
+
*
|
|
943
|
+
* const profile = await client.api("/me").get();
|
|
944
|
+
* ```
|
|
945
|
+
*
|
|
946
|
+
* @param {TokenCredential} credential - Used to provide configuration and auth.
|
|
947
|
+
* @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.
|
|
948
|
+
*
|
|
949
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
950
|
+
*
|
|
951
|
+
* @returns Graph client with specified scopes.
|
|
952
|
+
*/
|
|
953
|
+
function createMicrosoftGraphClientWithCredential(credential, scopes) {
|
|
954
|
+
internalLogger.info("Create Microsoft Graph Client");
|
|
955
|
+
const authProvider = new MsGraphAuthProvider(credential, scopes);
|
|
956
|
+
const graphClient = Client.initWithMiddleware({
|
|
957
|
+
authProvider,
|
|
958
|
+
});
|
|
959
|
+
return graphClient;
|
|
937
960
|
}
|
|
938
961
|
|
|
939
962
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1461,13 +1484,7 @@ class ConversationBot {
|
|
|
1461
1484
|
* Sso execution dialog, use to handle sso command
|
|
1462
1485
|
*/
|
|
1463
1486
|
class BotSsoExecutionDialog {
|
|
1464
|
-
|
|
1465
|
-
* Creates a new instance of the BotSsoExecutionDialog.
|
|
1466
|
-
* @param dedupStorage Helper storage to remove duplicated messages
|
|
1467
|
-
* @param requiredScopes The list of scopes for which the token will have access
|
|
1468
|
-
* @param teamsfx {@link TeamsFx} instance for authentication
|
|
1469
|
-
*/
|
|
1470
|
-
constructor(dedupStorage, requiredScopes, teamsfx) {
|
|
1487
|
+
constructor(dedupStorage, ssoPromptSettings, authConfig, ...args) {
|
|
1471
1488
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1472
1489
|
}
|
|
1473
1490
|
/**
|
|
@@ -1794,6 +1811,7 @@ class NotificationBot {
|
|
|
1794
1811
|
}
|
|
1795
1812
|
/**
|
|
1796
1813
|
* Returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
1814
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
|
|
1797
1815
|
*
|
|
1798
1816
|
* @remarks
|
|
1799
1817
|
* Only work on server side.
|
|
@@ -1822,6 +1840,7 @@ class NotificationBot {
|
|
|
1822
1840
|
}
|
|
1823
1841
|
/**
|
|
1824
1842
|
* Returns all {@link Channel} where predicate is true, and empty array otherwise.
|
|
1843
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
|
|
1825
1844
|
*
|
|
1826
1845
|
* @remarks
|
|
1827
1846
|
* Only work on server side.
|
|
@@ -1960,7 +1979,15 @@ class CardActionBot {
|
|
|
1960
1979
|
*/
|
|
1961
1980
|
async function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
1962
1981
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "queryWithToken in message extension"), ErrorCode.RuntimeNotSupported);
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Users execute query with SSO or Access Token.
|
|
1985
|
+
* @remarks
|
|
1986
|
+
* Only works in in server side.
|
|
1987
|
+
*/
|
|
1988
|
+
async function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
|
1989
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "queryWithToken in message extension"), ErrorCode.RuntimeNotSupported);
|
|
1963
1990
|
}
|
|
1964
1991
|
|
|
1965
|
-
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, BotSsoExecutionDialog, CardActionBot, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, LogLevel, Member, MsGraphAuthProvider, NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, handleMessageExtensionQueryWithToken, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1992
|
+
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, BotSsoExecutionDialog, CardActionBot, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, LogLevel, Member, MsGraphAuthProvider, NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createMicrosoftGraphClientWithCredential, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, handleMessageExtensionQueryWithSSO, handleMessageExtensionQueryWithToken, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1966
1993
|
//# sourceMappingURL=index.esm2017.js.map
|