@microsoft/teamsfx 1.1.2-alpha.18494658a.0 → 1.1.2-alpha.7eddd6cf4.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 +31 -16
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +15 -6
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +31 -16
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +15 -6
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +21 -7
package/dist/index.esm5.js
CHANGED
|
@@ -511,19 +511,20 @@ class TeamsUserCredential {
|
|
|
511
511
|
* await credential.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
512
512
|
* ```
|
|
513
513
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
514
|
+
* @param { string[] } resources - The optional list of resources for full trust Teams apps.
|
|
514
515
|
*
|
|
515
516
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
516
517
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
517
518
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
518
519
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
519
520
|
*/
|
|
520
|
-
login(scopes) {
|
|
521
|
+
login(scopes, resources) {
|
|
521
522
|
return __awaiter(this, void 0, void 0, function* () {
|
|
522
523
|
validateScopesType(scopes);
|
|
523
524
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
524
525
|
internalLogger.info(`Popup login page to get user's access token with scopes: ${scopesStr}`);
|
|
525
526
|
if (!this.initialized) {
|
|
526
|
-
yield this.init();
|
|
527
|
+
yield this.init(resources);
|
|
527
528
|
}
|
|
528
529
|
return new Promise((resolve, reject) => {
|
|
529
530
|
microsoftTeams.initialize(() => {
|
|
@@ -576,6 +577,9 @@ class TeamsUserCredential {
|
|
|
576
577
|
* Get access token from credential.
|
|
577
578
|
*
|
|
578
579
|
* Important: Access tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
|
|
580
|
+
* Important: Full trust applications do not read the resource information from the webApplicationInfo section of the app
|
|
581
|
+
* manifest. Instead, this resource (along with any additional resources from which to request tokens) must be provided
|
|
582
|
+
* as a list of resources to the getToken() method through a GetTeamsUserTokenOptions object.
|
|
579
583
|
*
|
|
580
584
|
* @example
|
|
581
585
|
* ```typescript
|
|
@@ -589,6 +593,9 @@ class TeamsUserCredential {
|
|
|
589
593
|
* await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
|
|
590
594
|
* await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
|
|
591
595
|
* await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
|
|
596
|
+
*
|
|
597
|
+
* const options: GetTeamsUserTokenOptions = { resources: ["https://domain.example.com"] }; // set up resources for full trust apps.
|
|
598
|
+
* await credential.getToken([], options) // Get sso token from teams client - only use this approach for full trust apps.
|
|
592
599
|
* ```
|
|
593
600
|
*
|
|
594
601
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
@@ -605,9 +612,11 @@ class TeamsUserCredential {
|
|
|
605
612
|
* Throw error if get access token failed.
|
|
606
613
|
*/
|
|
607
614
|
getToken(scopes, options) {
|
|
615
|
+
var _a;
|
|
608
616
|
return __awaiter(this, void 0, void 0, function* () {
|
|
609
617
|
validateScopesType(scopes);
|
|
610
|
-
const
|
|
618
|
+
const resources = (_a = options) === null || _a === void 0 ? void 0 : _a.resources;
|
|
619
|
+
const ssoToken = yield this.getSSOToken(resources);
|
|
611
620
|
const scopeStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
612
621
|
if (scopeStr === "") {
|
|
613
622
|
internalLogger.info("Get SSO token");
|
|
@@ -616,7 +625,7 @@ class TeamsUserCredential {
|
|
|
616
625
|
else {
|
|
617
626
|
internalLogger.info("Get access token with scopes: " + scopeStr);
|
|
618
627
|
if (!this.initialized) {
|
|
619
|
-
yield this.init();
|
|
628
|
+
yield this.init(resources);
|
|
620
629
|
}
|
|
621
630
|
let tokenResponse;
|
|
622
631
|
const scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
|
|
@@ -663,6 +672,8 @@ class TeamsUserCredential {
|
|
|
663
672
|
/**
|
|
664
673
|
* Get basic user info from SSO token
|
|
665
674
|
*
|
|
675
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
676
|
+
*
|
|
666
677
|
* @example
|
|
667
678
|
* ```typescript
|
|
668
679
|
* const currentUser = await credential.getUserInfo();
|
|
@@ -674,16 +685,16 @@ class TeamsUserCredential {
|
|
|
674
685
|
*
|
|
675
686
|
* @returns Basic user info with user displayName, objectId and preferredUserName.
|
|
676
687
|
*/
|
|
677
|
-
getUserInfo() {
|
|
688
|
+
getUserInfo(resources) {
|
|
678
689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
679
690
|
internalLogger.info("Get basic user info from SSO token");
|
|
680
|
-
const ssoToken = yield this.getSSOToken();
|
|
691
|
+
const ssoToken = yield this.getSSOToken(resources);
|
|
681
692
|
return getUserInfoFromSsoToken(ssoToken.token);
|
|
682
693
|
});
|
|
683
694
|
}
|
|
684
|
-
init() {
|
|
695
|
+
init(resources) {
|
|
685
696
|
return __awaiter(this, void 0, void 0, function* () {
|
|
686
|
-
const ssoToken = yield this.getSSOToken();
|
|
697
|
+
const ssoToken = yield this.getSSOToken(resources);
|
|
687
698
|
const info = getTenantIdAndLoginHintFromSsoToken(ssoToken.token);
|
|
688
699
|
this.loginHint = info.loginHint;
|
|
689
700
|
this.tid = info.tid;
|
|
@@ -703,9 +714,12 @@ class TeamsUserCredential {
|
|
|
703
714
|
/**
|
|
704
715
|
* Get SSO token using teams SDK
|
|
705
716
|
* 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
|
|
717
|
+
*
|
|
718
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
719
|
+
*
|
|
706
720
|
* @returns SSO token
|
|
707
721
|
*/
|
|
708
|
-
getSSOToken() {
|
|
722
|
+
getSSOToken(resources) {
|
|
709
723
|
return new Promise((resolve, reject) => {
|
|
710
724
|
if (this.ssoToken) {
|
|
711
725
|
if (this.ssoToken.expiresOnTimestamp - Date.now() > tokenRefreshTimeSpanInMillisecond) {
|
|
@@ -743,7 +757,7 @@ class TeamsUserCredential {
|
|
|
743
757
|
internalLogger.error(errorMsg);
|
|
744
758
|
reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
|
|
745
759
|
},
|
|
746
|
-
resources: [],
|
|
760
|
+
resources: resources !== null && resources !== void 0 ? resources : [],
|
|
747
761
|
});
|
|
748
762
|
});
|
|
749
763
|
}
|
|
@@ -1278,8 +1292,9 @@ class TeamsFx {
|
|
|
1278
1292
|
this.configuration = new Map();
|
|
1279
1293
|
this.loadFromEnv();
|
|
1280
1294
|
if (customConfig) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1295
|
+
const myConfig = Object.assign({}, customConfig);
|
|
1296
|
+
for (const key of Object.keys(myConfig)) {
|
|
1297
|
+
const value = myConfig[key];
|
|
1283
1298
|
if (value) {
|
|
1284
1299
|
this.configuration.set(key, value);
|
|
1285
1300
|
}
|
|
@@ -1327,14 +1342,14 @@ class TeamsFx {
|
|
|
1327
1342
|
}
|
|
1328
1343
|
return this.teamsUserCredential;
|
|
1329
1344
|
}
|
|
1330
|
-
getUserInfo() {
|
|
1345
|
+
getUserInfo(resources) {
|
|
1331
1346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1332
|
-
return yield this.getCredential().getUserInfo();
|
|
1347
|
+
return yield this.getCredential().getUserInfo(resources);
|
|
1333
1348
|
});
|
|
1334
1349
|
}
|
|
1335
|
-
login(scopes) {
|
|
1350
|
+
login(scopes, resources) {
|
|
1336
1351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1337
|
-
yield this.getCredential().login(scopes);
|
|
1352
|
+
yield this.getCredential().login(scopes, resources);
|
|
1338
1353
|
});
|
|
1339
1354
|
}
|
|
1340
1355
|
setSsoToken(ssoToken) {
|