@microsoft/teamsfx 2.0.1-alpha.12611228.0 → 2.0.1-alpha.330ae315b.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 +86 -56
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +242 -81
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +88 -56
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +247 -80
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -7
- package/types/teamsfx.d.ts +2119 -1926
package/dist/index.esm5.js
CHANGED
|
@@ -433,12 +433,6 @@ function validateScopesType(value) {
|
|
|
433
433
|
* Only works in in server side.
|
|
434
434
|
*/
|
|
435
435
|
class AppCredential {
|
|
436
|
-
/**
|
|
437
|
-
* Constructor of AppCredential.
|
|
438
|
-
*
|
|
439
|
-
* @remarks
|
|
440
|
-
* Only works in in server side.
|
|
441
|
-
*/
|
|
442
436
|
constructor(authConfig) {
|
|
443
437
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "AppCredential"), ErrorCode.RuntimeNotSupported);
|
|
444
438
|
}
|
|
@@ -463,12 +457,6 @@ class AppCredential {
|
|
|
463
457
|
* Can only be used in server side.
|
|
464
458
|
*/
|
|
465
459
|
class OnBehalfOfUserCredential {
|
|
466
|
-
/**
|
|
467
|
-
* Constructor of OnBehalfOfUserCredential
|
|
468
|
-
*
|
|
469
|
-
* @remarks
|
|
470
|
-
* Can Only works in in server side.
|
|
471
|
-
*/
|
|
472
460
|
constructor(ssoToken, config) {
|
|
473
461
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
|
|
474
462
|
}
|
|
@@ -503,28 +491,6 @@ const loginPageHeight = 535;
|
|
|
503
491
|
* Can only be used within Teams.
|
|
504
492
|
*/
|
|
505
493
|
class TeamsUserCredential {
|
|
506
|
-
/**
|
|
507
|
-
* Constructor of TeamsUserCredential.
|
|
508
|
-
*
|
|
509
|
-
* @example
|
|
510
|
-
* ```typescript
|
|
511
|
-
* const config = {
|
|
512
|
-
* authentication: {
|
|
513
|
-
* initiateLoginEndpoint: "https://localhost:3000/auth-start.html",
|
|
514
|
-
* clientId: "xxx"
|
|
515
|
-
* }
|
|
516
|
-
* }
|
|
517
|
-
* // Use default configuration provided by Teams Toolkit
|
|
518
|
-
* const credential = new TeamsUserCredential();
|
|
519
|
-
* // Use a customized configuration
|
|
520
|
-
* const anotherCredential = new TeamsUserCredential(config);
|
|
521
|
-
* ```
|
|
522
|
-
*
|
|
523
|
-
* @param {AuthenticationConfiguration} authConfig - The authentication configuration. Use environment variables if not provided.
|
|
524
|
-
*
|
|
525
|
-
* @throws {@link ErrorCode|InvalidConfiguration} when client id, initiate login endpoint or simple auth endpoint is not found in config.
|
|
526
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
527
|
-
*/
|
|
528
494
|
constructor(authConfig) {
|
|
529
495
|
internalLogger.info("Create teams user credential");
|
|
530
496
|
this.config = this.loadAndValidateConfig(authConfig);
|
|
@@ -841,18 +807,8 @@ const defaultScope = "https://graph.microsoft.com/.default";
|
|
|
841
807
|
* Microsoft Graph auth provider for Teams Framework
|
|
842
808
|
*/
|
|
843
809
|
class MsGraphAuthProvider {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
*
|
|
847
|
-
* @param {TeamsFx} teamsfx - Used to provide configuration and auth.
|
|
848
|
-
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
849
|
-
*
|
|
850
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
851
|
-
*
|
|
852
|
-
* @returns An instance of MsGraphAuthProvider.
|
|
853
|
-
*/
|
|
854
|
-
constructor(teamsfx, scopes) {
|
|
855
|
-
this.teamsfx = teamsfx;
|
|
810
|
+
constructor(credentialOrTeamsFx, scopes) {
|
|
811
|
+
this.credentialOrTeamsFx = credentialOrTeamsFx;
|
|
856
812
|
let scopesStr = defaultScope;
|
|
857
813
|
if (scopes) {
|
|
858
814
|
validateScopesType(scopes);
|
|
@@ -879,7 +835,15 @@ class MsGraphAuthProvider {
|
|
|
879
835
|
getAccessToken() {
|
|
880
836
|
return __awaiter(this, void 0, void 0, function* () {
|
|
881
837
|
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
|
|
882
|
-
|
|
838
|
+
let accessToken;
|
|
839
|
+
if (this.credentialOrTeamsFx.getCredential) {
|
|
840
|
+
accessToken = yield this.credentialOrTeamsFx
|
|
841
|
+
.getCredential()
|
|
842
|
+
.getToken(this.scopes);
|
|
843
|
+
}
|
|
844
|
+
else {
|
|
845
|
+
accessToken = yield this.credentialOrTeamsFx.getToken(this.scopes);
|
|
846
|
+
}
|
|
883
847
|
return new Promise((resolve, reject) => {
|
|
884
848
|
if (accessToken) {
|
|
885
849
|
resolve(accessToken.token);
|
|
@@ -897,7 +861,6 @@ class MsGraphAuthProvider {
|
|
|
897
861
|
// Copyright (c) Microsoft Corporation.
|
|
898
862
|
/**
|
|
899
863
|
* Get Microsoft graph client.
|
|
900
|
-
*
|
|
901
864
|
* @example
|
|
902
865
|
* Get Microsoft graph client by TokenCredential
|
|
903
866
|
* ```typescript
|
|
@@ -951,11 +914,74 @@ function createMicrosoftGraphClient(teamsfx, scopes) {
|
|
|
951
914
|
authProvider,
|
|
952
915
|
});
|
|
953
916
|
return graphClient;
|
|
917
|
+
}
|
|
918
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
|
919
|
+
/**
|
|
920
|
+
* Get Microsoft graph client.
|
|
921
|
+
* @example
|
|
922
|
+
* Get Microsoft graph client by TokenCredential
|
|
923
|
+
* ```typescript
|
|
924
|
+
* // In browser: TeamsUserCredential
|
|
925
|
+
* const authConfig: TeamsUserCredentialAuthConfig = {
|
|
926
|
+
* clientId: "xxx",
|
|
927
|
+
initiateLoginEndpoint: "https://xxx/auth-start.html",
|
|
928
|
+
* };
|
|
929
|
+
|
|
930
|
+
* const credential = new TeamsUserCredential(authConfig);
|
|
931
|
+
|
|
932
|
+
* const scope = "User.Read";
|
|
933
|
+
* await credential.login(scope);
|
|
934
|
+
|
|
935
|
+
* const client = createMicrosoftGraphClientWithCredential(credential, scope);
|
|
936
|
+
|
|
937
|
+
* // In node: OnBehalfOfUserCredential
|
|
938
|
+
* const oboAuthConfig: OnBehalfOfCredentialAuthConfig = {
|
|
939
|
+
* authorityHost: "xxx",
|
|
940
|
+
* clientId: "xxx",
|
|
941
|
+
* tenantId: "xxx",
|
|
942
|
+
* clientSecret: "xxx",
|
|
943
|
+
* };
|
|
944
|
+
|
|
945
|
+
* const oboCredential = new OnBehalfOfUserCredential(ssoToken, oboAuthConfig);
|
|
946
|
+
* const scope = "User.Read";
|
|
947
|
+
* const client = createMicrosoftGraphClientWithCredential(oboCredential, scope);
|
|
948
|
+
|
|
949
|
+
* // In node: AppCredential
|
|
950
|
+
* const appAuthConfig: AppCredentialAuthConfig = {
|
|
951
|
+
* authorityHost: "xxx",
|
|
952
|
+
* clientId: "xxx",
|
|
953
|
+
* tenantId: "xxx",
|
|
954
|
+
* clientSecret: "xxx",
|
|
955
|
+
* };
|
|
956
|
+
* const appCredential = new AppCredential(appAuthConfig);
|
|
957
|
+
* const scope = "User.Read";
|
|
958
|
+
* const client = createMicrosoftGraphClientWithCredential(appCredential, scope);
|
|
959
|
+
*
|
|
960
|
+
* const profile = await client.api("/me").get();
|
|
961
|
+
* ```
|
|
962
|
+
*
|
|
963
|
+
* @param {TokenCredential} credential - Used to provide configuration and auth.
|
|
964
|
+
* @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.
|
|
965
|
+
*
|
|
966
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
967
|
+
*
|
|
968
|
+
* @returns Graph client with specified scopes.
|
|
969
|
+
*/
|
|
970
|
+
function createMicrosoftGraphClientWithCredential(credential, scopes) {
|
|
971
|
+
internalLogger.info("Create Microsoft Graph Client");
|
|
972
|
+
const authProvider = new MsGraphAuthProvider(credential, scopes);
|
|
973
|
+
const graphClient = Client.initWithMiddleware({
|
|
974
|
+
authProvider,
|
|
975
|
+
});
|
|
976
|
+
return graphClient;
|
|
954
977
|
}
|
|
955
978
|
|
|
956
979
|
// Copyright (c) Microsoft Corporation.
|
|
957
980
|
/**
|
|
958
981
|
* Generate connection configuration consumed by tedious.
|
|
982
|
+
*
|
|
983
|
+
* @deprecated we recommend you compose your own Tedious configuration for better flexibility.
|
|
984
|
+
*
|
|
959
985
|
* @remarks
|
|
960
986
|
* Only works in in server side.
|
|
961
987
|
*/
|
|
@@ -1497,13 +1523,7 @@ class ConversationBot {
|
|
|
1497
1523
|
* Sso execution dialog, use to handle sso command
|
|
1498
1524
|
*/
|
|
1499
1525
|
class BotSsoExecutionDialog {
|
|
1500
|
-
|
|
1501
|
-
* Creates a new instance of the BotSsoExecutionDialog.
|
|
1502
|
-
* @param dedupStorage Helper storage to remove duplicated messages
|
|
1503
|
-
* @param requiredScopes The list of scopes for which the token will have access
|
|
1504
|
-
* @param teamsfx {@link TeamsFx} instance for authentication
|
|
1505
|
-
*/
|
|
1506
|
-
constructor(dedupStorage, requiredScopes, teamsfx) {
|
|
1526
|
+
constructor(dedupStorage, ssoPromptSettings, authConfig, ...args) {
|
|
1507
1527
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1508
1528
|
}
|
|
1509
1529
|
/**
|
|
@@ -1848,6 +1868,7 @@ class NotificationBot {
|
|
|
1848
1868
|
}
|
|
1849
1869
|
/**
|
|
1850
1870
|
* Returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
1871
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
|
|
1851
1872
|
*
|
|
1852
1873
|
* @remarks
|
|
1853
1874
|
* Only work on server side.
|
|
@@ -1880,6 +1901,7 @@ class NotificationBot {
|
|
|
1880
1901
|
}
|
|
1881
1902
|
/**
|
|
1882
1903
|
* Returns all {@link Channel} where predicate is true, and empty array otherwise.
|
|
1904
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
|
|
1883
1905
|
*
|
|
1884
1906
|
* @remarks
|
|
1885
1907
|
* Only work on server side.
|
|
@@ -2022,7 +2044,17 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
|
2022
2044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2023
2045
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "queryWithToken in message extension"), ErrorCode.RuntimeNotSupported);
|
|
2024
2046
|
});
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Users execute query with SSO or Access Token.
|
|
2050
|
+
* @remarks
|
|
2051
|
+
* Only works in in server side.
|
|
2052
|
+
*/
|
|
2053
|
+
function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
|
2054
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2055
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "queryWithToken in message extension"), ErrorCode.RuntimeNotSupported);
|
|
2056
|
+
});
|
|
2025
2057
|
}
|
|
2026
2058
|
|
|
2027
|
-
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 };
|
|
2059
|
+
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 };
|
|
2028
2060
|
//# sourceMappingURL=index.esm5.js.map
|