@eduzz/miau-client 0.0.15 → 0.0.16
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/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @eduzz/miau-client@0.0.
|
|
2
|
+
> @eduzz/miau-client@0.0.16 build /home/runner/work/eduzz-miau/eduzz-miau/packages/client
|
|
3
3
|
> esbuild src/index.ts --bundle --sourcemap --platform=node --target=es2020 --outfile=dist/index.js
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
dist/index.js 438.
|
|
7
|
-
dist/index.js.map 735.
|
|
6
|
+
dist/index.js 438.6kb
|
|
7
|
+
dist/index.js.map 735.5kb
|
|
8
8
|
|
|
9
|
-
⚡ Done in
|
|
9
|
+
⚡ Done in 515ms
|
package/dist/index.js
CHANGED
|
@@ -11715,12 +11715,12 @@ var index_exports = {};
|
|
|
11715
11715
|
__export(index_exports, {
|
|
11716
11716
|
HttpMethods: () => HttpMethods,
|
|
11717
11717
|
MiauClient: () => MiauClient,
|
|
11718
|
-
|
|
11718
|
+
ResourceProtocols: () => ResourceProtocols
|
|
11719
11719
|
});
|
|
11720
11720
|
module.exports = __toCommonJS(index_exports);
|
|
11721
11721
|
|
|
11722
11722
|
// ../types/src/types/Resource.ts
|
|
11723
|
-
var
|
|
11723
|
+
var ResourceProtocols = ["http", "websocket", "grpc"];
|
|
11724
11724
|
var HttpMethods = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"];
|
|
11725
11725
|
|
|
11726
11726
|
// src/MiauClient.ts
|
|
@@ -11748,20 +11748,20 @@ var miauMiddleware = (miauClient, requestAugmentation, fallbackMidlleware) => {
|
|
|
11748
11748
|
try {
|
|
11749
11749
|
const token = req.headers.authorization?.split(" ").pop();
|
|
11750
11750
|
if (!token) {
|
|
11751
|
-
throw new HttpError(
|
|
11751
|
+
throw new HttpError(400, "Invalid Token", "Token not provided");
|
|
11752
11752
|
}
|
|
11753
11753
|
const decodedToken = import_jsonwebtoken.default.decode(token, { complete: true });
|
|
11754
11754
|
if (!decodedToken?.header?.kid) {
|
|
11755
|
-
throw new HttpError(
|
|
11755
|
+
throw new HttpError(400, "Invalid Token", "Missing kid in token header");
|
|
11756
11756
|
}
|
|
11757
11757
|
const publicKey = await miauClient.getPublicKey(decodedToken.header.kid);
|
|
11758
11758
|
const appToken = import_jsonwebtoken.default.verify(token, publicKey, { algorithms: ["RS256"] });
|
|
11759
11759
|
if (!appToken || !appToken.id || !appToken.name) {
|
|
11760
|
-
throw new HttpError(
|
|
11760
|
+
throw new HttpError(400, "Invalid Token", "Token verification failed");
|
|
11761
11761
|
}
|
|
11762
11762
|
const permission = await miauClient.getPermissions(appToken.id);
|
|
11763
11763
|
if (!permission) {
|
|
11764
|
-
|
|
11764
|
+
throw new HttpError(401, "Unauthorized", "No permissions found for this application");
|
|
11765
11765
|
}
|
|
11766
11766
|
const resources = permission?.resources || [];
|
|
11767
11767
|
const isAllowed = resources.some((resource) => {
|
|
@@ -11778,7 +11778,8 @@ var miauMiddleware = (miauClient, requestAugmentation, fallbackMidlleware) => {
|
|
|
11778
11778
|
}
|
|
11779
11779
|
next();
|
|
11780
11780
|
} catch (err) {
|
|
11781
|
-
if (err instanceof HttpError && err.status ==
|
|
11781
|
+
if (err instanceof HttpError && err.status == 400 && fallbackMidlleware) {
|
|
11782
|
+
console.log("Using fallback middleware for 400 error");
|
|
11782
11783
|
return fallbackMidlleware(req, res, next);
|
|
11783
11784
|
}
|
|
11784
11785
|
const errorStatus = err.status || 403;
|
|
@@ -11883,7 +11884,7 @@ var MiauClient = class {
|
|
|
11883
11884
|
0 && (module.exports = {
|
|
11884
11885
|
HttpMethods,
|
|
11885
11886
|
MiauClient,
|
|
11886
|
-
|
|
11887
|
+
ResourceProtocols
|
|
11887
11888
|
});
|
|
11888
11889
|
/*! Bundled license information:
|
|
11889
11890
|
|