@eduzz/miau-client 1.4.0-rc.145 → 1.4.0-rc.147

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.
@@ -26,8 +26,8 @@ export declare class MiauClient {
26
26
  }): (request: FastifyRequest, reply: FastifyReply) => void;
27
27
  hasPermission(sourceAppId: string, resource: Resource): Promise<HasPermissionResponse>;
28
28
  verify(token: string, publicKey: string): Promise<MiauClientToken>;
29
- private getApiJwtUrl;
30
29
  private getJwksUrl;
31
30
  private getHasPermissionUrl;
31
+ private getOAuthTokenUrl;
32
32
  }
33
33
  export {};
package/dist/index.js CHANGED
@@ -12029,15 +12029,15 @@ var MiauClient = class {
12029
12029
  }
12030
12030
  return import_jsonwebtoken2.default.decode(token);
12031
12031
  };
12032
- this.getApiJwtUrl = () => {
12033
- return `${this.config.apiUrl}/v1/jwt`;
12034
- };
12035
12032
  this.getJwksUrl = () => {
12036
12033
  return `${this.config.apiUrl}/v1/jwks.json`;
12037
12034
  };
12038
12035
  this.getHasPermissionUrl = () => {
12039
12036
  return `${this.config.apiUrl}/v1/has-permission`;
12040
12037
  };
12038
+ this.getOAuthTokenUrl = () => {
12039
+ return `${this.config.apiUrl}/v1/oauth/token`;
12040
+ };
12041
12041
  if (!config.apiUrl || !config.appSecret) {
12042
12042
  throw new Error("Invalid MiauClient configuration. Please provide apiUrl and appSecret.");
12043
12043
  }
@@ -12069,7 +12069,7 @@ var MiauClient = class {
12069
12069
  return this.jwtToken;
12070
12070
  }
12071
12071
  }
12072
- const response = await fetch(this.getApiJwtUrl(), {
12072
+ const response = await fetch(this.getOAuthTokenUrl(), {
12073
12073
  headers: {
12074
12074
  "Authorization": `Basic ${this.basicAuthToken}`,
12075
12075
  "Content-Type": "application/json"
@@ -12079,7 +12079,7 @@ var MiauClient = class {
12079
12079
  if (response.status !== 200) {
12080
12080
  throw new Error(data.message || "Failed to fetch JWT token");
12081
12081
  }
12082
- this.jwtToken = data.jwt;
12082
+ this.jwtToken = data.access_token;
12083
12083
  return this.jwtToken;
12084
12084
  }
12085
12085
  middleware(config) {