@microsoft/teamsfx 1.1.2-alpha.988c78cba.0 → 1.1.2-alpha.9bd0cb559.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 +180 -17
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +492 -32
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +192 -17
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +513 -29
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +336 -29
package/dist/index.esm2017.js
CHANGED
|
@@ -31,6 +31,30 @@ var ErrorCode;
|
|
|
31
31
|
* Channel is not supported error.
|
|
32
32
|
*/
|
|
33
33
|
ErrorCode["ChannelNotSupported"] = "ChannelNotSupported";
|
|
34
|
+
/**
|
|
35
|
+
* Failed to retrieve sso token
|
|
36
|
+
*/
|
|
37
|
+
ErrorCode["FailedToRetrieveSsoToken"] = "FailedToRetrieveSsoToken";
|
|
38
|
+
/**
|
|
39
|
+
* Failed to process sso handler
|
|
40
|
+
*/
|
|
41
|
+
ErrorCode["FailedToProcessSsoHandler"] = "FailedToProcessSsoHandler";
|
|
42
|
+
/**
|
|
43
|
+
* Cannot find command
|
|
44
|
+
*/
|
|
45
|
+
ErrorCode["CannotFindCommand"] = "CannotFindCommand";
|
|
46
|
+
/**
|
|
47
|
+
* Failed to run sso step
|
|
48
|
+
*/
|
|
49
|
+
ErrorCode["FailedToRunSsoStep"] = "FailedToRunSsoStep";
|
|
50
|
+
/**
|
|
51
|
+
* Failed to run dedup step
|
|
52
|
+
*/
|
|
53
|
+
ErrorCode["FailedToRunDedupStep"] = "FailedToRunDedupStep";
|
|
54
|
+
/**
|
|
55
|
+
* Sso activity handler is undefined
|
|
56
|
+
*/
|
|
57
|
+
ErrorCode["SsoActivityHandlerIsUndefined"] = "SsoActivityHandlerIsUndefined";
|
|
34
58
|
/**
|
|
35
59
|
* Runtime is not supported error.
|
|
36
60
|
*/
|
|
@@ -86,6 +110,15 @@ ErrorMessage.NodejsRuntimeNotSupported = "{0} is not supported in Node.";
|
|
|
86
110
|
ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token on behalf of user: {0}";
|
|
87
111
|
// ChannelNotSupported Error
|
|
88
112
|
ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
|
|
113
|
+
ErrorMessage.FailedToProcessSsoHandler = "Failed to process sso handler: {0}";
|
|
114
|
+
// FailedToRetrieveSsoToken Error
|
|
115
|
+
ErrorMessage.FailedToRetrieveSsoToken = "Failed to retrieve sso token, user failed to finish the AAD consent flow.";
|
|
116
|
+
// CannotFindCommand Error
|
|
117
|
+
ErrorMessage.CannotFindCommand = "Cannot find command: {0}";
|
|
118
|
+
ErrorMessage.FailedToRunSsoStep = "Failed to run dialog to retrieve sso token: {0}";
|
|
119
|
+
ErrorMessage.FailedToRunDedupStep = "Failed to run dialog to remove duplicated messages: {0}";
|
|
120
|
+
// SsoActivityHandlerIsUndefined Error
|
|
121
|
+
ErrorMessage.SsoActivityHandlerIsNull = "Sso command can only be used or added when sso activity handler is not undefined";
|
|
89
122
|
// IdentityTypeNotSupported Error
|
|
90
123
|
ErrorMessage.IdentityTypeNotSupported = "{0} identity is not supported in {1}";
|
|
91
124
|
// AuthorizationInfoError
|
|
@@ -506,18 +539,19 @@ class TeamsUserCredential {
|
|
|
506
539
|
* await credential.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
507
540
|
* ```
|
|
508
541
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
542
|
+
* @param { string[] } resources - The optional list of resources for full trust Teams apps.
|
|
509
543
|
*
|
|
510
544
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
511
545
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
512
546
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
513
547
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
514
548
|
*/
|
|
515
|
-
async login(scopes) {
|
|
549
|
+
async login(scopes, resources) {
|
|
516
550
|
validateScopesType(scopes);
|
|
517
551
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
518
552
|
internalLogger.info(`Popup login page to get user's access token with scopes: ${scopesStr}`);
|
|
519
553
|
if (!this.initialized) {
|
|
520
|
-
await this.init();
|
|
554
|
+
await this.init(resources);
|
|
521
555
|
}
|
|
522
556
|
return new Promise((resolve, reject) => {
|
|
523
557
|
microsoftTeams.initialize(() => {
|
|
@@ -569,6 +603,9 @@ class TeamsUserCredential {
|
|
|
569
603
|
* Get access token from credential.
|
|
570
604
|
*
|
|
571
605
|
* Important: Access tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
|
|
606
|
+
* Important: Full trust applications do not read the resource information from the webApplicationInfo section of the app
|
|
607
|
+
* manifest. Instead, this resource (along with any additional resources from which to request tokens) must be provided
|
|
608
|
+
* as a list of resources to the getToken() method through a GetTeamsUserTokenOptions object.
|
|
572
609
|
*
|
|
573
610
|
* @example
|
|
574
611
|
* ```typescript
|
|
@@ -582,6 +619,9 @@ class TeamsUserCredential {
|
|
|
582
619
|
* await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
|
|
583
620
|
* await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
|
|
584
621
|
* await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
|
|
622
|
+
*
|
|
623
|
+
* const options: GetTeamsUserTokenOptions = { resources: ["https://domain.example.com"] }; // set up resources for full trust apps.
|
|
624
|
+
* await credential.getToken([], options) // Get sso token from teams client - only use this approach for full trust apps.
|
|
585
625
|
* ```
|
|
586
626
|
*
|
|
587
627
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
@@ -598,8 +638,10 @@ class TeamsUserCredential {
|
|
|
598
638
|
* Throw error if get access token failed.
|
|
599
639
|
*/
|
|
600
640
|
async getToken(scopes, options) {
|
|
641
|
+
var _a;
|
|
601
642
|
validateScopesType(scopes);
|
|
602
|
-
const
|
|
643
|
+
const resources = (_a = options) === null || _a === void 0 ? void 0 : _a.resources;
|
|
644
|
+
const ssoToken = await this.getSSOToken(resources);
|
|
603
645
|
const scopeStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
604
646
|
if (scopeStr === "") {
|
|
605
647
|
internalLogger.info("Get SSO token");
|
|
@@ -608,7 +650,7 @@ class TeamsUserCredential {
|
|
|
608
650
|
else {
|
|
609
651
|
internalLogger.info("Get access token with scopes: " + scopeStr);
|
|
610
652
|
if (!this.initialized) {
|
|
611
|
-
await this.init();
|
|
653
|
+
await this.init(resources);
|
|
612
654
|
}
|
|
613
655
|
let tokenResponse;
|
|
614
656
|
const scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
|
|
@@ -654,6 +696,8 @@ class TeamsUserCredential {
|
|
|
654
696
|
/**
|
|
655
697
|
* Get basic user info from SSO token
|
|
656
698
|
*
|
|
699
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
700
|
+
*
|
|
657
701
|
* @example
|
|
658
702
|
* ```typescript
|
|
659
703
|
* const currentUser = await credential.getUserInfo();
|
|
@@ -665,13 +709,13 @@ class TeamsUserCredential {
|
|
|
665
709
|
*
|
|
666
710
|
* @returns Basic user info with user displayName, objectId and preferredUserName.
|
|
667
711
|
*/
|
|
668
|
-
async getUserInfo() {
|
|
712
|
+
async getUserInfo(resources) {
|
|
669
713
|
internalLogger.info("Get basic user info from SSO token");
|
|
670
|
-
const ssoToken = await this.getSSOToken();
|
|
714
|
+
const ssoToken = await this.getSSOToken(resources);
|
|
671
715
|
return getUserInfoFromSsoToken(ssoToken.token);
|
|
672
716
|
}
|
|
673
|
-
async init() {
|
|
674
|
-
const ssoToken = await this.getSSOToken();
|
|
717
|
+
async init(resources) {
|
|
718
|
+
const ssoToken = await this.getSSOToken(resources);
|
|
675
719
|
const info = getTenantIdAndLoginHintFromSsoToken(ssoToken.token);
|
|
676
720
|
this.loginHint = info.loginHint;
|
|
677
721
|
this.tid = info.tid;
|
|
@@ -690,9 +734,12 @@ class TeamsUserCredential {
|
|
|
690
734
|
/**
|
|
691
735
|
* Get SSO token using teams SDK
|
|
692
736
|
* It will try to get SSO token from memory first, if SSO token doesn't exist or about to expired, then it will using teams SDK to get SSO token
|
|
737
|
+
*
|
|
738
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
739
|
+
*
|
|
693
740
|
* @returns SSO token
|
|
694
741
|
*/
|
|
695
|
-
getSSOToken() {
|
|
742
|
+
getSSOToken(resources) {
|
|
696
743
|
return new Promise((resolve, reject) => {
|
|
697
744
|
if (this.ssoToken) {
|
|
698
745
|
if (this.ssoToken.expiresOnTimestamp - Date.now() > tokenRefreshTimeSpanInMillisecond) {
|
|
@@ -730,7 +777,7 @@ class TeamsUserCredential {
|
|
|
730
777
|
internalLogger.error(errorMsg);
|
|
731
778
|
reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
|
|
732
779
|
},
|
|
733
|
-
resources: [],
|
|
780
|
+
resources: resources !== null && resources !== void 0 ? resources : [],
|
|
734
781
|
});
|
|
735
782
|
});
|
|
736
783
|
}
|
|
@@ -1247,8 +1294,9 @@ class TeamsFx {
|
|
|
1247
1294
|
this.configuration = new Map();
|
|
1248
1295
|
this.loadFromEnv();
|
|
1249
1296
|
if (customConfig) {
|
|
1250
|
-
|
|
1251
|
-
|
|
1297
|
+
const myConfig = Object.assign({}, customConfig);
|
|
1298
|
+
for (const key of Object.keys(myConfig)) {
|
|
1299
|
+
const value = myConfig[key];
|
|
1252
1300
|
if (value) {
|
|
1253
1301
|
this.configuration.set(key, value);
|
|
1254
1302
|
}
|
|
@@ -1296,11 +1344,11 @@ class TeamsFx {
|
|
|
1296
1344
|
}
|
|
1297
1345
|
return this.teamsUserCredential;
|
|
1298
1346
|
}
|
|
1299
|
-
async getUserInfo() {
|
|
1300
|
-
return await this.getCredential().getUserInfo();
|
|
1347
|
+
async getUserInfo(resources) {
|
|
1348
|
+
return await this.getCredential().getUserInfo(resources);
|
|
1301
1349
|
}
|
|
1302
|
-
async login(scopes) {
|
|
1303
|
-
await this.getCredential().login(scopes);
|
|
1350
|
+
async login(scopes, resources) {
|
|
1351
|
+
await this.getCredential().login(scopes, resources);
|
|
1304
1352
|
}
|
|
1305
1353
|
setSsoToken(ssoToken) {
|
|
1306
1354
|
return this;
|
|
@@ -1423,6 +1471,105 @@ class ConversationBot {
|
|
|
1423
1471
|
}
|
|
1424
1472
|
}
|
|
1425
1473
|
|
|
1474
|
+
// Copyright (c) Microsoft Corporation.
|
|
1475
|
+
/*
|
|
1476
|
+
* Sso execution dialog, use to handle sso command
|
|
1477
|
+
*/
|
|
1478
|
+
class BotSsoExecutionDialog {
|
|
1479
|
+
/**
|
|
1480
|
+
* Creates a new instance of the BotSsoExecutionDialog.
|
|
1481
|
+
* @param dedupStorage Helper storage to remove duplicated messages
|
|
1482
|
+
* @param requiredScopes The list of scopes for which the token will have access
|
|
1483
|
+
* @param teamsfx {@link TeamsFx} instance for authentication
|
|
1484
|
+
*/
|
|
1485
|
+
constructor(dedupStorage, requiredScopes, teamsfx) {
|
|
1486
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Add TeamsFxBotSsoCommandHandler instance
|
|
1490
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
1491
|
+
* @param triggerPatterns The trigger pattern
|
|
1492
|
+
*/
|
|
1493
|
+
addCommand(handler, triggerPatterns) {
|
|
1494
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* The run method handles the incoming activity (in the form of a DialogContext) and passes it through the dialog system.
|
|
1498
|
+
*
|
|
1499
|
+
* @param context The context object for the current turn.
|
|
1500
|
+
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
|
1501
|
+
*/
|
|
1502
|
+
async run(context, accessor) {
|
|
1503
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Called when the component is ending.
|
|
1507
|
+
*
|
|
1508
|
+
* @param context Context for the current turn of conversation.
|
|
1509
|
+
*/
|
|
1510
|
+
async onEndDialog(context) {
|
|
1511
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// Copyright (c) Microsoft Corporation.
|
|
1516
|
+
/**
|
|
1517
|
+
* Default sso execution activity handler
|
|
1518
|
+
*/
|
|
1519
|
+
class DefaultBotSsoExecutionActivityHandler {
|
|
1520
|
+
/**
|
|
1521
|
+
* Creates a new instance of the DefaultBotSsoExecutionActivityHandler.
|
|
1522
|
+
* @param ssoConfig configuration for sso command bot
|
|
1523
|
+
*/
|
|
1524
|
+
constructor(ssoConfig) {
|
|
1525
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Add TeamsFxBotSsoCommandHandler instance to sso execution dialog
|
|
1529
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
1530
|
+
* @param triggerPatterns The trigger pattern
|
|
1531
|
+
*/
|
|
1532
|
+
addCommand(handler, triggerPatterns) {
|
|
1533
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Called to initiate the event emission process.
|
|
1537
|
+
* @param context The context object for the current turn.
|
|
1538
|
+
*/
|
|
1539
|
+
async run(context) {
|
|
1540
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Receives invoke activities with Activity name of 'signin/verifyState'.
|
|
1544
|
+
* @param context A context object for this turn.
|
|
1545
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query.
|
|
1546
|
+
* @returns A promise that represents the work queued.
|
|
1547
|
+
*/
|
|
1548
|
+
async handleTeamsSigninVerifyState(context, query) {
|
|
1549
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Receives invoke activities with Activity name of 'signin/tokenExchange'
|
|
1553
|
+
* @param context A context object for this turn.
|
|
1554
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query
|
|
1555
|
+
* @returns A promise that represents the work queued.
|
|
1556
|
+
*/
|
|
1557
|
+
async handleTeamsSigninTokenExchange(context, query) {
|
|
1558
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Handle signin invoke activity type.
|
|
1562
|
+
*
|
|
1563
|
+
* @param context The context object for the current turn.
|
|
1564
|
+
*
|
|
1565
|
+
* @remarks
|
|
1566
|
+
* Override this method to support channel-specific behavior across multiple channels.
|
|
1567
|
+
*/
|
|
1568
|
+
async onSignInInvoke(context) {
|
|
1569
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultBotSsoExecutionActivityHandler"), ErrorCode.RuntimeNotSupported);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1426
1573
|
// Copyright (c) Microsoft Corporation.
|
|
1427
1574
|
/**
|
|
1428
1575
|
* Send a plain text message to a notification target.
|
|
@@ -1727,6 +1874,22 @@ class CommandBot {
|
|
|
1727
1874
|
registerCommands(commands) {
|
|
1728
1875
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
|
|
1729
1876
|
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Registers a sso command into the command bot.
|
|
1879
|
+
*
|
|
1880
|
+
* @param command The command to register.
|
|
1881
|
+
*/
|
|
1882
|
+
registerSsoCommand(ssoCommand) {
|
|
1883
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Registers commands into the command bot.
|
|
1887
|
+
*
|
|
1888
|
+
* @param commands The commands to register.
|
|
1889
|
+
*/
|
|
1890
|
+
registerSsoCommands(ssoCommands) {
|
|
1891
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
|
|
1892
|
+
}
|
|
1730
1893
|
}
|
|
1731
1894
|
|
|
1732
1895
|
/**
|
|
@@ -1767,5 +1930,5 @@ class CardActionBot {
|
|
|
1767
1930
|
}
|
|
1768
1931
|
}
|
|
1769
1932
|
|
|
1770
|
-
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, 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, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1933
|
+
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, BotSsoExecutionDialog, CardActionBot, CertificateAuthProvider, Channel, CommandBot, ConversationBot, DefaultBotSsoExecutionActivityHandler, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, LogLevel, Member, MsGraphAuthProvider, NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1771
1934
|
//# sourceMappingURL=index.esm2017.js.map
|