@eduzz/miau-client 1.0.5 → 1.1.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @eduzz/miau-client@1.0.5 build:types /home/runner/work/eduzz-miau/eduzz-miau/packages/client
2
+ > @eduzz/miau-client@1.1.0 build:types /home/runner/work/eduzz-miau/eduzz-miau/packages/client
3
3
  > tsc --emitDeclarationOnly --outDir dist
4
4
 
package/dist/index.js CHANGED
@@ -11723,6 +11723,7 @@ __export(index_exports, {
11723
11723
  expirationOptions: () => expirationOptions,
11724
11724
  expirationOptionsValues: () => expirationOptionsValues,
11725
11725
  expirationTimeToDate: () => expirationTimeToDate,
11726
+ issuers: () => issuers,
11726
11727
  networks: () => networks
11727
11728
  });
11728
11729
  module.exports = __toCommonJS(index_exports);
@@ -11834,6 +11835,7 @@ var expirationTimeToDate = (option) => {
11834
11835
  };
11835
11836
 
11836
11837
  // ../types/src/types/Environments.ts
11838
+ var SecretEnvValues = ["development", "test", "production"];
11837
11839
  var envs = {
11838
11840
  development: "Development",
11839
11841
  test: "Testing",
@@ -11844,7 +11846,11 @@ var networks = {
11844
11846
  test: "127.0.0.0/8",
11845
11847
  production: "127.0.0.0/8"
11846
11848
  };
11847
- var SecretEnvValues = ["development", "test", "production"];
11849
+ var issuers = {
11850
+ development: "https://miau.devopzz.ninja",
11851
+ test: "https://miau.testzz.ninja",
11852
+ production: "https://miau.eduzz.com"
11853
+ };
11848
11854
  var envMap = {
11849
11855
  development: "d",
11850
11856
  test: "q",
@@ -11910,9 +11916,15 @@ var miauMiddleware = (miauClient, requestAugmentation, fallbackMiddleware) => {
11910
11916
  throw new HttpError(400, "Invalid Token", "Token not provided");
11911
11917
  }
11912
11918
  const decodedToken = import_jsonwebtoken.default.decode(token, { complete: true });
11913
- if (!decodedToken?.header?.kid) {
11919
+ if (!decodedToken) {
11920
+ throw new HttpError(400, "Invalid Token", "Token could not be decoded");
11921
+ }
11922
+ if (!decodedToken.header?.kid) {
11914
11923
  throw new HttpError(400, "Invalid Token", "Missing kid in token header");
11915
11924
  }
11925
+ if (decodedToken.payload.iss !== issuers["production"]) {
11926
+ throw new HttpError(400, "Invalid Token", "Token issuer is invalid");
11927
+ }
11916
11928
  const publicKey = await miauClient.getPublicKey(decodedToken.header.kid);
11917
11929
  const clientToken = import_jsonwebtoken.default.verify(token, publicKey, { algorithms: ["RS256"] });
11918
11930
  if (!clientToken || !clientToken.application || !clientToken.secret || !clientToken.application.id || !clientToken.secret.id || !clientToken.secret.environment) {
@@ -12082,6 +12094,7 @@ var MiauClient = class {
12082
12094
  expirationOptions,
12083
12095
  expirationOptionsValues,
12084
12096
  expirationTimeToDate,
12097
+ issuers,
12085
12098
  networks
12086
12099
  });
12087
12100
  /*! Bundled license information: