@microsoft/teamsfx-react 3.0.0-alpha.46da7cd00.0 → 3.0.1-alpha.ru6q1vrv0.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/LICENSE +21 -21
- package/README.md +6 -0
- package/build/cjs/BaseDashboard.d.ts +54 -0
- package/build/cjs/BaseDashboard.d.ts.map +1 -0
- package/build/cjs/BaseDashboard.js +102 -0
- package/build/cjs/BaseWidget.d.ts +63 -0
- package/build/cjs/BaseWidget.d.ts.map +1 -0
- package/build/cjs/BaseWidget.js +149 -0
- package/build/cjs/index.d.ts +7 -5
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/index.js +20 -16
- package/build/cjs/useData.d.ts +33 -33
- package/build/cjs/useData.js +47 -47
- package/build/cjs/useGraph.d.ts +32 -32
- package/build/cjs/useGraph.js +151 -151
- package/build/cjs/useTeams.d.ts +30 -30
- package/build/cjs/useTeams.js +82 -82
- package/build/cjs/useTeamsFx.d.ts +41 -41
- package/build/cjs/useTeamsFx.js +34 -34
- package/build/cjs/useTeamsUserCredential.d.ts +41 -41
- package/build/cjs/useTeamsUserCredential.js +34 -34
- package/build/esm/BaseDashboard.d.ts +54 -0
- package/build/esm/BaseDashboard.d.ts.map +1 -0
- package/build/esm/BaseDashboard.js +99 -0
- package/build/esm/BaseWidget.d.ts +63 -0
- package/build/esm/BaseWidget.d.ts.map +1 -0
- package/build/esm/BaseWidget.js +146 -0
- package/build/esm/index.d.ts +7 -5
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +9 -7
- package/build/esm/useData.d.ts +33 -33
- package/build/esm/useData.js +43 -43
- package/build/esm/useGraph.d.ts +32 -32
- package/build/esm/useGraph.js +146 -146
- package/build/esm/useTeams.d.ts +30 -30
- package/build/esm/useTeams.js +78 -78
- package/build/esm/useTeamsFx.d.ts +41 -41
- package/build/esm/useTeamsFx.js +30 -30
- package/build/esm/useTeamsUserCredential.d.ts +41 -41
- package/build/esm/useTeamsUserCredential.js +30 -30
- package/package.json +6 -5
package/build/cjs/useGraph.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Data } from "./useData";
|
|
2
|
-
import { TeamsFx, TeamsUserCredential } from "@microsoft/teamsfx";
|
|
3
|
-
import { Client } from "@microsoft/microsoft-graph-client";
|
|
4
|
-
type GraphOption = {
|
|
5
|
-
scope?: string[];
|
|
6
|
-
teamsfx?: TeamsFx;
|
|
7
|
-
};
|
|
8
|
-
type GraphOptionWithCredential = {
|
|
9
|
-
scope?: string[];
|
|
10
|
-
credential?: TeamsUserCredential;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
14
|
-
*
|
|
15
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
16
|
-
* @param options - teamsfx instance and OAuth resource scope.
|
|
17
|
-
* @returns data, loading status, error and reload function
|
|
18
|
-
*
|
|
19
|
-
* @beta
|
|
20
|
-
*/
|
|
21
|
-
export declare function useGraph<T>(fetchGraphDataAsync: (graph: Client, teamsfx: TeamsFx, scope: string[]) => Promise<T>, options?: GraphOption): Data<T>;
|
|
22
|
-
/**
|
|
23
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
24
|
-
*
|
|
25
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
26
|
-
* @param options - Authentication configuration and OAuth resource scope.
|
|
27
|
-
* @returns data, loading status, error and reload function
|
|
28
|
-
*
|
|
29
|
-
* @beta
|
|
30
|
-
*/
|
|
31
|
-
export declare function useGraphWithCredential<T>(fetchGraphDataAsync: (graph: Client, credential: TeamsUserCredential, scope: string[]) => Promise<T>, options?: GraphOptionWithCredential): Data<T>;
|
|
32
|
-
export {};
|
|
1
|
+
import { Data } from "./useData";
|
|
2
|
+
import { TeamsFx, TeamsUserCredential } from "@microsoft/teamsfx";
|
|
3
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
4
|
+
type GraphOption = {
|
|
5
|
+
scope?: string[];
|
|
6
|
+
teamsfx?: TeamsFx;
|
|
7
|
+
};
|
|
8
|
+
type GraphOptionWithCredential = {
|
|
9
|
+
scope?: string[];
|
|
10
|
+
credential?: TeamsUserCredential;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
14
|
+
*
|
|
15
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
16
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
17
|
+
* @returns data, loading status, error and reload function
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare function useGraph<T>(fetchGraphDataAsync: (graph: Client, teamsfx: TeamsFx, scope: string[]) => Promise<T>, options?: GraphOption): Data<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
24
|
+
*
|
|
25
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
26
|
+
* @param options - Authentication configuration and OAuth resource scope.
|
|
27
|
+
* @returns data, loading status, error and reload function
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
export declare function useGraphWithCredential<T>(fetchGraphDataAsync: (graph: Client, credential: TeamsUserCredential, scope: string[]) => Promise<T>, options?: GraphOptionWithCredential): Data<T>;
|
|
32
|
+
export {};
|
|
33
33
|
//# sourceMappingURL=useGraph.d.ts.map
|
package/build/cjs/useGraph.js
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraphWithCredential = exports.useGraph = void 0;
|
|
6
|
-
var tslib_1 = require("tslib");
|
|
7
|
-
var useData_1 = require("./useData");
|
|
8
|
-
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
9
|
-
var microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
10
|
-
var react_1 = require("react");
|
|
11
|
-
/**
|
|
12
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
13
|
-
*
|
|
14
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
15
|
-
* @param options - teamsfx instance and OAuth resource scope.
|
|
16
|
-
* @returns data, loading status, error and reload function
|
|
17
|
-
*
|
|
18
|
-
* @beta
|
|
19
|
-
*/
|
|
20
|
-
function useGraph(fetchGraphDataAsync, options) {
|
|
21
|
-
var _this = this;
|
|
22
|
-
var _a = tslib_1.__assign({ scope: ["User.Read"], teamsfx: new teamsfx_1.TeamsFx() }, options), scope = _a.scope, teamsfx = _a.teamsfx;
|
|
23
|
-
var _b = (0, react_1.useState)(false), needConsent = _b[0], setNeedConsent = _b[1];
|
|
24
|
-
var _c = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
25
|
-
var err_1, helpLink, graph, graphData, err_2;
|
|
26
|
-
var _a, _b;
|
|
27
|
-
return tslib_1.__generator(this, function (_c) {
|
|
28
|
-
switch (_c.label) {
|
|
29
|
-
case 0:
|
|
30
|
-
if (!needConsent) return [3 /*break*/, 4];
|
|
31
|
-
_c.label = 1;
|
|
32
|
-
case 1:
|
|
33
|
-
_c.trys.push([1, 3, , 4]);
|
|
34
|
-
return [4 /*yield*/, teamsfx.login(scope)];
|
|
35
|
-
case 2:
|
|
36
|
-
_c.sent();
|
|
37
|
-
setNeedConsent(false);
|
|
38
|
-
return [3 /*break*/, 4];
|
|
39
|
-
case 3:
|
|
40
|
-
err_1 = _c.sent();
|
|
41
|
-
if (err_1 instanceof teamsfx_1.ErrorWithCode && ((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
42
|
-
helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
43
|
-
err_1.message +=
|
|
44
|
-
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
45
|
-
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
46
|
-
"cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ".concat(helpLink);
|
|
47
|
-
}
|
|
48
|
-
throw err_1;
|
|
49
|
-
case 4:
|
|
50
|
-
_c.trys.push([4, 6, , 7]);
|
|
51
|
-
graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
52
|
-
return [4 /*yield*/, fetchGraphDataAsync(graph, teamsfx, scope)];
|
|
53
|
-
case 5:
|
|
54
|
-
graphData = _c.sent();
|
|
55
|
-
return [2 /*return*/, graphData];
|
|
56
|
-
case 6:
|
|
57
|
-
err_2 = _c.sent();
|
|
58
|
-
if (err_2 instanceof microsoft_graph_client_1.GraphError && ((_b = err_2.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
59
|
-
// Silently fail for user didn't consent error
|
|
60
|
-
setNeedConsent(true);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
throw err_2;
|
|
64
|
-
}
|
|
65
|
-
return [3 /*break*/, 7];
|
|
66
|
-
case 7: return [2 /*return*/];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); }), data = _c.data, error = _c.error, loading = _c.loading, reload = _c.reload;
|
|
70
|
-
return { data: data, error: error, loading: loading, reload: reload };
|
|
71
|
-
}
|
|
72
|
-
exports.useGraph = useGraph;
|
|
73
|
-
/**
|
|
74
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
75
|
-
*
|
|
76
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
77
|
-
* @param options - Authentication configuration and OAuth resource scope.
|
|
78
|
-
* @returns data, loading status, error and reload function
|
|
79
|
-
*
|
|
80
|
-
* @beta
|
|
81
|
-
*/
|
|
82
|
-
function useGraphWithCredential(fetchGraphDataAsync, options) {
|
|
83
|
-
var _this = this;
|
|
84
|
-
var credential;
|
|
85
|
-
if (!(options === null || options === void 0 ? void 0 : options.credential)) {
|
|
86
|
-
var authConfig = {
|
|
87
|
-
clientId: process.env.REACT_APP_CLIENT_ID,
|
|
88
|
-
initiateLoginEndpoint: process.env.REACT_APP_START_LOGIN_PAGE_URL,
|
|
89
|
-
};
|
|
90
|
-
credential = new teamsfx_1.TeamsUserCredential(authConfig);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
credential = options === null || options === void 0 ? void 0 : options.credential;
|
|
94
|
-
}
|
|
95
|
-
var scope;
|
|
96
|
-
if (!(options === null || options === void 0 ? void 0 : options.scope)) {
|
|
97
|
-
scope = ["User.Read"];
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
scope = options.scope;
|
|
101
|
-
}
|
|
102
|
-
var _a = (0, react_1.useState)(false), needConsent = _a[0], setNeedConsent = _a[1];
|
|
103
|
-
var _b = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
104
|
-
var err_3, helpLink, graph, graphData, err_4;
|
|
105
|
-
var _a, _b;
|
|
106
|
-
return tslib_1.__generator(this, function (_c) {
|
|
107
|
-
switch (_c.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
if (!needConsent) return [3 /*break*/, 4];
|
|
110
|
-
_c.label = 1;
|
|
111
|
-
case 1:
|
|
112
|
-
_c.trys.push([1, 3, , 4]);
|
|
113
|
-
return [4 /*yield*/, credential.login(scope)];
|
|
114
|
-
case 2:
|
|
115
|
-
_c.sent();
|
|
116
|
-
setNeedConsent(false);
|
|
117
|
-
return [3 /*break*/, 4];
|
|
118
|
-
case 3:
|
|
119
|
-
err_3 = _c.sent();
|
|
120
|
-
if (err_3 instanceof teamsfx_1.ErrorWithCode && ((_a = err_3.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
121
|
-
helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
122
|
-
err_3.message +=
|
|
123
|
-
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
124
|
-
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
125
|
-
"cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ".concat(helpLink);
|
|
126
|
-
}
|
|
127
|
-
throw err_3;
|
|
128
|
-
case 4:
|
|
129
|
-
_c.trys.push([4, 6, , 7]);
|
|
130
|
-
graph = (0, teamsfx_1.createMicrosoftGraphClientWithCredential)(credential, scope);
|
|
131
|
-
return [4 /*yield*/, fetchGraphDataAsync(graph, credential, scope)];
|
|
132
|
-
case 5:
|
|
133
|
-
graphData = _c.sent();
|
|
134
|
-
return [2 /*return*/, graphData];
|
|
135
|
-
case 6:
|
|
136
|
-
err_4 = _c.sent();
|
|
137
|
-
if (err_4 instanceof microsoft_graph_client_1.GraphError && ((_b = err_4.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
138
|
-
// Silently fail for user didn't consent error
|
|
139
|
-
setNeedConsent(true);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
throw err_4;
|
|
143
|
-
}
|
|
144
|
-
return [3 /*break*/, 7];
|
|
145
|
-
case 7: return [2 /*return*/];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}); }), data = _b.data, error = _b.error, loading = _b.loading, reload = _b.reload;
|
|
149
|
-
return { data: data, error: error, loading: loading, reload: reload };
|
|
150
|
-
}
|
|
151
|
-
exports.useGraphWithCredential = useGraphWithCredential;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useGraphWithCredential = exports.useGraph = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var useData_1 = require("./useData");
|
|
8
|
+
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
9
|
+
var microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
10
|
+
var react_1 = require("react");
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
13
|
+
*
|
|
14
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
15
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
16
|
+
* @returns data, loading status, error and reload function
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
function useGraph(fetchGraphDataAsync, options) {
|
|
21
|
+
var _this = this;
|
|
22
|
+
var _a = tslib_1.__assign({ scope: ["User.Read"], teamsfx: new teamsfx_1.TeamsFx() }, options), scope = _a.scope, teamsfx = _a.teamsfx;
|
|
23
|
+
var _b = (0, react_1.useState)(false), needConsent = _b[0], setNeedConsent = _b[1];
|
|
24
|
+
var _c = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
25
|
+
var err_1, helpLink, graph, graphData, err_2;
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return tslib_1.__generator(this, function (_c) {
|
|
28
|
+
switch (_c.label) {
|
|
29
|
+
case 0:
|
|
30
|
+
if (!needConsent) return [3 /*break*/, 4];
|
|
31
|
+
_c.label = 1;
|
|
32
|
+
case 1:
|
|
33
|
+
_c.trys.push([1, 3, , 4]);
|
|
34
|
+
return [4 /*yield*/, teamsfx.login(scope)];
|
|
35
|
+
case 2:
|
|
36
|
+
_c.sent();
|
|
37
|
+
setNeedConsent(false);
|
|
38
|
+
return [3 /*break*/, 4];
|
|
39
|
+
case 3:
|
|
40
|
+
err_1 = _c.sent();
|
|
41
|
+
if (err_1 instanceof teamsfx_1.ErrorWithCode && ((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
42
|
+
helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
43
|
+
err_1.message +=
|
|
44
|
+
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
45
|
+
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
46
|
+
"cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ".concat(helpLink);
|
|
47
|
+
}
|
|
48
|
+
throw err_1;
|
|
49
|
+
case 4:
|
|
50
|
+
_c.trys.push([4, 6, , 7]);
|
|
51
|
+
graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
52
|
+
return [4 /*yield*/, fetchGraphDataAsync(graph, teamsfx, scope)];
|
|
53
|
+
case 5:
|
|
54
|
+
graphData = _c.sent();
|
|
55
|
+
return [2 /*return*/, graphData];
|
|
56
|
+
case 6:
|
|
57
|
+
err_2 = _c.sent();
|
|
58
|
+
if (err_2 instanceof microsoft_graph_client_1.GraphError && ((_b = err_2.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
59
|
+
// Silently fail for user didn't consent error
|
|
60
|
+
setNeedConsent(true);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw err_2;
|
|
64
|
+
}
|
|
65
|
+
return [3 /*break*/, 7];
|
|
66
|
+
case 7: return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}); }), data = _c.data, error = _c.error, loading = _c.loading, reload = _c.reload;
|
|
70
|
+
return { data: data, error: error, loading: loading, reload: reload };
|
|
71
|
+
}
|
|
72
|
+
exports.useGraph = useGraph;
|
|
73
|
+
/**
|
|
74
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
75
|
+
*
|
|
76
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
77
|
+
* @param options - Authentication configuration and OAuth resource scope.
|
|
78
|
+
* @returns data, loading status, error and reload function
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
function useGraphWithCredential(fetchGraphDataAsync, options) {
|
|
83
|
+
var _this = this;
|
|
84
|
+
var credential;
|
|
85
|
+
if (!(options === null || options === void 0 ? void 0 : options.credential)) {
|
|
86
|
+
var authConfig = {
|
|
87
|
+
clientId: process.env.REACT_APP_CLIENT_ID,
|
|
88
|
+
initiateLoginEndpoint: process.env.REACT_APP_START_LOGIN_PAGE_URL,
|
|
89
|
+
};
|
|
90
|
+
credential = new teamsfx_1.TeamsUserCredential(authConfig);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
credential = options === null || options === void 0 ? void 0 : options.credential;
|
|
94
|
+
}
|
|
95
|
+
var scope;
|
|
96
|
+
if (!(options === null || options === void 0 ? void 0 : options.scope)) {
|
|
97
|
+
scope = ["User.Read"];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
scope = options.scope;
|
|
101
|
+
}
|
|
102
|
+
var _a = (0, react_1.useState)(false), needConsent = _a[0], setNeedConsent = _a[1];
|
|
103
|
+
var _b = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
104
|
+
var err_3, helpLink, graph, graphData, err_4;
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return tslib_1.__generator(this, function (_c) {
|
|
107
|
+
switch (_c.label) {
|
|
108
|
+
case 0:
|
|
109
|
+
if (!needConsent) return [3 /*break*/, 4];
|
|
110
|
+
_c.label = 1;
|
|
111
|
+
case 1:
|
|
112
|
+
_c.trys.push([1, 3, , 4]);
|
|
113
|
+
return [4 /*yield*/, credential.login(scope)];
|
|
114
|
+
case 2:
|
|
115
|
+
_c.sent();
|
|
116
|
+
setNeedConsent(false);
|
|
117
|
+
return [3 /*break*/, 4];
|
|
118
|
+
case 3:
|
|
119
|
+
err_3 = _c.sent();
|
|
120
|
+
if (err_3 instanceof teamsfx_1.ErrorWithCode && ((_a = err_3.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
121
|
+
helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
122
|
+
err_3.message +=
|
|
123
|
+
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
124
|
+
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
125
|
+
"cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ".concat(helpLink);
|
|
126
|
+
}
|
|
127
|
+
throw err_3;
|
|
128
|
+
case 4:
|
|
129
|
+
_c.trys.push([4, 6, , 7]);
|
|
130
|
+
graph = (0, teamsfx_1.createMicrosoftGraphClientWithCredential)(credential, scope);
|
|
131
|
+
return [4 /*yield*/, fetchGraphDataAsync(graph, credential, scope)];
|
|
132
|
+
case 5:
|
|
133
|
+
graphData = _c.sent();
|
|
134
|
+
return [2 /*return*/, graphData];
|
|
135
|
+
case 6:
|
|
136
|
+
err_4 = _c.sent();
|
|
137
|
+
if (err_4 instanceof microsoft_graph_client_1.GraphError && ((_b = err_4.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
138
|
+
// Silently fail for user didn't consent error
|
|
139
|
+
setNeedConsent(true);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw err_4;
|
|
143
|
+
}
|
|
144
|
+
return [3 /*break*/, 7];
|
|
145
|
+
case 7: return [2 /*return*/];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}); }), data = _b.data, error = _b.error, loading = _b.loading, reload = _b.reload;
|
|
149
|
+
return { data: data, error: error, loading: loading, reload: reload };
|
|
150
|
+
}
|
|
151
|
+
exports.useGraphWithCredential = useGraphWithCredential;
|
package/build/cjs/useTeams.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { app } from "@microsoft/teams-js";
|
|
2
|
-
import { Theme } from "@fluentui/react-components";
|
|
3
|
-
/**
|
|
4
|
-
* Microsoft Teams React hook
|
|
5
|
-
* @param options optional options
|
|
6
|
-
* @returns A tuple with properties and methods
|
|
7
|
-
* properties:
|
|
8
|
-
* - inTeams: boolean = true if inside Microsoft Teams
|
|
9
|
-
* - fullscreen: boolean = true if in full screen mode
|
|
10
|
-
* - theme: Fluent UI Theme
|
|
11
|
-
* - themeString: string - representation of the theme (default, dark or contrast)
|
|
12
|
-
* - context - the Microsoft Teams JS SDK context
|
|
13
|
-
* methods:
|
|
14
|
-
* - setTheme - manually set the theme
|
|
15
|
-
*/
|
|
16
|
-
export declare function useTeams(options?: {
|
|
17
|
-
initialTheme?: string;
|
|
18
|
-
setThemeHandler?: (theme?: string) => void;
|
|
19
|
-
}): [
|
|
20
|
-
{
|
|
21
|
-
inTeams?: boolean;
|
|
22
|
-
fullScreen?: boolean;
|
|
23
|
-
theme: Theme;
|
|
24
|
-
themeString: string;
|
|
25
|
-
context?: app.Context;
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
setTheme: (theme: string | undefined) => void;
|
|
29
|
-
}
|
|
30
|
-
];
|
|
1
|
+
import { app } from "@microsoft/teams-js";
|
|
2
|
+
import { Theme } from "@fluentui/react-components";
|
|
3
|
+
/**
|
|
4
|
+
* Microsoft Teams React hook
|
|
5
|
+
* @param options optional options
|
|
6
|
+
* @returns A tuple with properties and methods
|
|
7
|
+
* properties:
|
|
8
|
+
* - inTeams: boolean = true if inside Microsoft Teams
|
|
9
|
+
* - fullscreen: boolean = true if in full screen mode
|
|
10
|
+
* - theme: Fluent UI Theme
|
|
11
|
+
* - themeString: string - representation of the theme (default, dark or contrast)
|
|
12
|
+
* - context - the Microsoft Teams JS SDK context
|
|
13
|
+
* methods:
|
|
14
|
+
* - setTheme - manually set the theme
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTeams(options?: {
|
|
17
|
+
initialTheme?: string;
|
|
18
|
+
setThemeHandler?: (theme?: string) => void;
|
|
19
|
+
}): [
|
|
20
|
+
{
|
|
21
|
+
inTeams?: boolean;
|
|
22
|
+
fullScreen?: boolean;
|
|
23
|
+
theme: Theme;
|
|
24
|
+
themeString: string;
|
|
25
|
+
context?: app.Context;
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
setTheme: (theme: string | undefined) => void;
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
31
|
//# sourceMappingURL=useTeams.d.ts.map
|
package/build/cjs/useTeams.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useTeams = void 0;
|
|
6
|
-
var react_1 = require("react");
|
|
7
|
-
var react_dom_1 = require("react-dom");
|
|
8
|
-
var teams_js_1 = require("@microsoft/teams-js");
|
|
9
|
-
var react_components_1 = require("@fluentui/react-components");
|
|
10
|
-
var getTheme = function () {
|
|
11
|
-
var urlParams = new URLSearchParams(window.location.search);
|
|
12
|
-
var theme = urlParams.get("theme");
|
|
13
|
-
return theme == null ? undefined : theme;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Microsoft Teams React hook
|
|
17
|
-
* @param options optional options
|
|
18
|
-
* @returns A tuple with properties and methods
|
|
19
|
-
* properties:
|
|
20
|
-
* - inTeams: boolean = true if inside Microsoft Teams
|
|
21
|
-
* - fullscreen: boolean = true if in full screen mode
|
|
22
|
-
* - theme: Fluent UI Theme
|
|
23
|
-
* - themeString: string - representation of the theme (default, dark or contrast)
|
|
24
|
-
* - context - the Microsoft Teams JS SDK context
|
|
25
|
-
* methods:
|
|
26
|
-
* - setTheme - manually set the theme
|
|
27
|
-
*/
|
|
28
|
-
function useTeams(options) {
|
|
29
|
-
var _a = (0, react_1.useState)(undefined), inTeams = _a[0], setInTeams = _a[1];
|
|
30
|
-
var _b = (0, react_1.useState)(undefined), fullScreen = _b[0], setFullScreen = _b[1];
|
|
31
|
-
var _c = (0, react_1.useState)(react_components_1.teamsLightTheme), theme = _c[0], setTheme = _c[1];
|
|
32
|
-
var _d = (0, react_1.useState)("default"), themeString = _d[0], setThemeString = _d[1];
|
|
33
|
-
var initialTheme = (0, react_1.useState)(options && options.initialTheme ? options.initialTheme : getTheme())[0];
|
|
34
|
-
var _e = (0, react_1.useState)(undefined), context = _e[0], setContext = _e[1];
|
|
35
|
-
var themeChangeHandler = function (theme) {
|
|
36
|
-
setThemeString(theme || "default");
|
|
37
|
-
switch (theme) {
|
|
38
|
-
case "dark":
|
|
39
|
-
setTheme(react_components_1.teamsDarkTheme);
|
|
40
|
-
break;
|
|
41
|
-
case "contrast":
|
|
42
|
-
setTheme(react_components_1.teamsHighContrastTheme);
|
|
43
|
-
break;
|
|
44
|
-
case "default":
|
|
45
|
-
default:
|
|
46
|
-
setTheme(react_components_1.teamsLightTheme);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var overrideThemeHandler = (options === null || options === void 0 ? void 0 : options.setThemeHandler)
|
|
50
|
-
? options.setThemeHandler
|
|
51
|
-
: themeChangeHandler;
|
|
52
|
-
(0, react_1.useEffect)(function () {
|
|
53
|
-
// set initial theme based on options or query string
|
|
54
|
-
overrideThemeHandler(initialTheme);
|
|
55
|
-
teams_js_1.app
|
|
56
|
-
.initialize()
|
|
57
|
-
.then(function () {
|
|
58
|
-
teams_js_1.app
|
|
59
|
-
.getContext()
|
|
60
|
-
.then(function (context) {
|
|
61
|
-
(0, react_dom_1.unstable_batchedUpdates)(function () {
|
|
62
|
-
setInTeams(true);
|
|
63
|
-
setContext(context);
|
|
64
|
-
setFullScreen(context.page.isFullScreen);
|
|
65
|
-
});
|
|
66
|
-
overrideThemeHandler(context.app.theme);
|
|
67
|
-
teams_js_1.app.registerOnThemeChangeHandler(overrideThemeHandler);
|
|
68
|
-
teams_js_1.pages.registerFullScreenHandler(function (isFullScreen) {
|
|
69
|
-
setFullScreen(isFullScreen);
|
|
70
|
-
});
|
|
71
|
-
})
|
|
72
|
-
.catch(function () {
|
|
73
|
-
setInTeams(false);
|
|
74
|
-
});
|
|
75
|
-
})
|
|
76
|
-
.catch(function () {
|
|
77
|
-
setInTeams(false);
|
|
78
|
-
});
|
|
79
|
-
}, []);
|
|
80
|
-
return [{ inTeams: inTeams, fullScreen: fullScreen, theme: theme, context: context, themeString: themeString }, { setTheme: overrideThemeHandler }];
|
|
81
|
-
}
|
|
82
|
-
exports.useTeams = useTeams;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useTeams = void 0;
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var react_dom_1 = require("react-dom");
|
|
8
|
+
var teams_js_1 = require("@microsoft/teams-js");
|
|
9
|
+
var react_components_1 = require("@fluentui/react-components");
|
|
10
|
+
var getTheme = function () {
|
|
11
|
+
var urlParams = new URLSearchParams(window.location.search);
|
|
12
|
+
var theme = urlParams.get("theme");
|
|
13
|
+
return theme == null ? undefined : theme;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Microsoft Teams React hook
|
|
17
|
+
* @param options optional options
|
|
18
|
+
* @returns A tuple with properties and methods
|
|
19
|
+
* properties:
|
|
20
|
+
* - inTeams: boolean = true if inside Microsoft Teams
|
|
21
|
+
* - fullscreen: boolean = true if in full screen mode
|
|
22
|
+
* - theme: Fluent UI Theme
|
|
23
|
+
* - themeString: string - representation of the theme (default, dark or contrast)
|
|
24
|
+
* - context - the Microsoft Teams JS SDK context
|
|
25
|
+
* methods:
|
|
26
|
+
* - setTheme - manually set the theme
|
|
27
|
+
*/
|
|
28
|
+
function useTeams(options) {
|
|
29
|
+
var _a = (0, react_1.useState)(undefined), inTeams = _a[0], setInTeams = _a[1];
|
|
30
|
+
var _b = (0, react_1.useState)(undefined), fullScreen = _b[0], setFullScreen = _b[1];
|
|
31
|
+
var _c = (0, react_1.useState)(react_components_1.teamsLightTheme), theme = _c[0], setTheme = _c[1];
|
|
32
|
+
var _d = (0, react_1.useState)("default"), themeString = _d[0], setThemeString = _d[1];
|
|
33
|
+
var initialTheme = (0, react_1.useState)(options && options.initialTheme ? options.initialTheme : getTheme())[0];
|
|
34
|
+
var _e = (0, react_1.useState)(undefined), context = _e[0], setContext = _e[1];
|
|
35
|
+
var themeChangeHandler = function (theme) {
|
|
36
|
+
setThemeString(theme || "default");
|
|
37
|
+
switch (theme) {
|
|
38
|
+
case "dark":
|
|
39
|
+
setTheme(react_components_1.teamsDarkTheme);
|
|
40
|
+
break;
|
|
41
|
+
case "contrast":
|
|
42
|
+
setTheme(react_components_1.teamsHighContrastTheme);
|
|
43
|
+
break;
|
|
44
|
+
case "default":
|
|
45
|
+
default:
|
|
46
|
+
setTheme(react_components_1.teamsLightTheme);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var overrideThemeHandler = (options === null || options === void 0 ? void 0 : options.setThemeHandler)
|
|
50
|
+
? options.setThemeHandler
|
|
51
|
+
: themeChangeHandler;
|
|
52
|
+
(0, react_1.useEffect)(function () {
|
|
53
|
+
// set initial theme based on options or query string
|
|
54
|
+
overrideThemeHandler(initialTheme);
|
|
55
|
+
teams_js_1.app
|
|
56
|
+
.initialize()
|
|
57
|
+
.then(function () {
|
|
58
|
+
teams_js_1.app
|
|
59
|
+
.getContext()
|
|
60
|
+
.then(function (context) {
|
|
61
|
+
(0, react_dom_1.unstable_batchedUpdates)(function () {
|
|
62
|
+
setInTeams(true);
|
|
63
|
+
setContext(context);
|
|
64
|
+
setFullScreen(context.page.isFullScreen);
|
|
65
|
+
});
|
|
66
|
+
overrideThemeHandler(context.app.theme);
|
|
67
|
+
teams_js_1.app.registerOnThemeChangeHandler(overrideThemeHandler);
|
|
68
|
+
teams_js_1.pages.registerFullScreenHandler(function (isFullScreen) {
|
|
69
|
+
setFullScreen(isFullScreen);
|
|
70
|
+
});
|
|
71
|
+
})
|
|
72
|
+
.catch(function () {
|
|
73
|
+
setInTeams(false);
|
|
74
|
+
});
|
|
75
|
+
})
|
|
76
|
+
.catch(function () {
|
|
77
|
+
setInTeams(false);
|
|
78
|
+
});
|
|
79
|
+
}, []);
|
|
80
|
+
return [{ inTeams: inTeams, fullScreen: fullScreen, theme: theme, context: context, themeString: themeString }, { setTheme: overrideThemeHandler }];
|
|
81
|
+
}
|
|
82
|
+
exports.useTeams = useTeams;
|