@chemmangat/msal-next 5.3.0 → 5.3.1
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.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -6
- package/dist/index.mjs +12 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1037,6 +1037,11 @@ interface GraphApiOptions extends RequestInit {
|
|
|
1037
1037
|
* @default false
|
|
1038
1038
|
*/
|
|
1039
1039
|
debug?: boolean;
|
|
1040
|
+
/**
|
|
1041
|
+
* Expected response type. Use 'blob' for binary data like images.
|
|
1042
|
+
* @default 'json'
|
|
1043
|
+
*/
|
|
1044
|
+
responseType?: 'json' | 'blob' | 'text';
|
|
1040
1045
|
}
|
|
1041
1046
|
interface UseGraphApiReturn {
|
|
1042
1047
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1037,6 +1037,11 @@ interface GraphApiOptions extends RequestInit {
|
|
|
1037
1037
|
* @default false
|
|
1038
1038
|
*/
|
|
1039
1039
|
debug?: boolean;
|
|
1040
|
+
/**
|
|
1041
|
+
* Expected response type. Use 'blob' for binary data like images.
|
|
1042
|
+
* @default 'json'
|
|
1043
|
+
*/
|
|
1044
|
+
responseType?: 'json' | 'blob' | 'text';
|
|
1040
1045
|
}
|
|
1041
1046
|
interface UseGraphApiReturn {
|
|
1042
1047
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1430,6 +1430,7 @@ function useGraphApi() {
|
|
|
1430
1430
|
scopes = ["User.Read"],
|
|
1431
1431
|
version = "v1.0",
|
|
1432
1432
|
debug = false,
|
|
1433
|
+
responseType = "json",
|
|
1433
1434
|
...fetchOptions
|
|
1434
1435
|
} = options;
|
|
1435
1436
|
try {
|
|
@@ -1455,9 +1456,16 @@ function useGraphApi() {
|
|
|
1455
1456
|
if (response.status === 204 || response.headers.get("content-length") === "0") {
|
|
1456
1457
|
return null;
|
|
1457
1458
|
}
|
|
1458
|
-
|
|
1459
|
+
let data;
|
|
1460
|
+
if (responseType === "blob") {
|
|
1461
|
+
data = await response.blob();
|
|
1462
|
+
} else if (responseType === "text") {
|
|
1463
|
+
data = await response.text();
|
|
1464
|
+
} else {
|
|
1465
|
+
data = await response.json();
|
|
1466
|
+
}
|
|
1459
1467
|
if (debug) {
|
|
1460
|
-
console.log("[GraphAPI] Response:", data);
|
|
1468
|
+
console.log("[GraphAPI] Response:", responseType === "blob" ? "[Blob]" : data);
|
|
1461
1469
|
}
|
|
1462
1470
|
return data;
|
|
1463
1471
|
} catch (error) {
|
|
@@ -1565,11 +1573,9 @@ function useUserProfile() {
|
|
|
1565
1573
|
try {
|
|
1566
1574
|
const photoBlob = await graph.get("/me/photo/$value", {
|
|
1567
1575
|
scopes: ["User.Read"],
|
|
1568
|
-
|
|
1569
|
-
"Content-Type": "image/jpeg"
|
|
1570
|
-
}
|
|
1576
|
+
responseType: "blob"
|
|
1571
1577
|
});
|
|
1572
|
-
if (photoBlob) {
|
|
1578
|
+
if (photoBlob instanceof Blob && photoBlob.size > 0) {
|
|
1573
1579
|
photoUrl = URL.createObjectURL(photoBlob);
|
|
1574
1580
|
}
|
|
1575
1581
|
} catch (photoError) {
|
package/dist/index.mjs
CHANGED
|
@@ -1371,6 +1371,7 @@ function useGraphApi() {
|
|
|
1371
1371
|
scopes = ["User.Read"],
|
|
1372
1372
|
version = "v1.0",
|
|
1373
1373
|
debug = false,
|
|
1374
|
+
responseType = "json",
|
|
1374
1375
|
...fetchOptions
|
|
1375
1376
|
} = options;
|
|
1376
1377
|
try {
|
|
@@ -1396,9 +1397,16 @@ function useGraphApi() {
|
|
|
1396
1397
|
if (response.status === 204 || response.headers.get("content-length") === "0") {
|
|
1397
1398
|
return null;
|
|
1398
1399
|
}
|
|
1399
|
-
|
|
1400
|
+
let data;
|
|
1401
|
+
if (responseType === "blob") {
|
|
1402
|
+
data = await response.blob();
|
|
1403
|
+
} else if (responseType === "text") {
|
|
1404
|
+
data = await response.text();
|
|
1405
|
+
} else {
|
|
1406
|
+
data = await response.json();
|
|
1407
|
+
}
|
|
1400
1408
|
if (debug) {
|
|
1401
|
-
console.log("[GraphAPI] Response:", data);
|
|
1409
|
+
console.log("[GraphAPI] Response:", responseType === "blob" ? "[Blob]" : data);
|
|
1402
1410
|
}
|
|
1403
1411
|
return data;
|
|
1404
1412
|
} catch (error) {
|
|
@@ -1506,11 +1514,9 @@ function useUserProfile() {
|
|
|
1506
1514
|
try {
|
|
1507
1515
|
const photoBlob = await graph.get("/me/photo/$value", {
|
|
1508
1516
|
scopes: ["User.Read"],
|
|
1509
|
-
|
|
1510
|
-
"Content-Type": "image/jpeg"
|
|
1511
|
-
}
|
|
1517
|
+
responseType: "blob"
|
|
1512
1518
|
});
|
|
1513
|
-
if (photoBlob) {
|
|
1519
|
+
if (photoBlob instanceof Blob && photoBlob.size > 0) {
|
|
1514
1520
|
photoUrl = URL.createObjectURL(photoBlob);
|
|
1515
1521
|
}
|
|
1516
1522
|
} catch (photoError) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chemmangat/msal-next",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Production-ready Microsoft/Azure AD authentication for Next.js App Router. Zero-config setup, TypeScript-first, multi-account support, auto token refresh. The easiest way to add Microsoft login to your Next.js app.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|