@eduzz/miau-client 0.0.20 → 0.0.22

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@0.0.20 build:types /home/runner/work/eduzz-miau/eduzz-miau/packages/client
2
+ > @eduzz/miau-client@0.0.22 build:types /home/runner/work/eduzz-miau/eduzz-miau/packages/client
3
3
  > tsc --emitDeclarationOnly --outDir dist
4
4
 
@@ -7,8 +7,7 @@ type MiauClientConfig = {
7
7
  environment: SecretEnv;
8
8
  };
9
9
  export declare class MiauClient {
10
- private apiUrl;
11
- private environment;
10
+ private config;
12
11
  private jwtToken;
13
12
  private jwksClient;
14
13
  private basicAuthToken;
package/dist/index.js CHANGED
@@ -11716,11 +11716,14 @@ __export(index_exports, {
11716
11716
  HttpMethods: () => HttpMethods,
11717
11717
  MiauClient: () => MiauClient,
11718
11718
  ResourceProtocols: () => ResourceProtocols,
11719
+ SecretEnvValues: () => SecretEnvValues,
11720
+ UserPermissions: () => UserPermissions,
11719
11721
  envMap: () => envMap,
11720
11722
  envs: () => envs,
11721
11723
  expirationOptions: () => expirationOptions,
11722
11724
  expirationOptionsValues: () => expirationOptionsValues,
11723
- expirationTimeToDate: () => expirationTimeToDate
11725
+ expirationTimeToDate: () => expirationTimeToDate,
11726
+ networks: () => networks
11724
11727
  });
11725
11728
  module.exports = __toCommonJS(index_exports);
11726
11729
 
@@ -11836,12 +11839,30 @@ var envs = {
11836
11839
  test: "Testing",
11837
11840
  production: "Production"
11838
11841
  };
11842
+ var networks = {
11843
+ development: "127.0.0.0/8",
11844
+ test: "127.0.0.0/8",
11845
+ production: "127.0.0.0/8"
11846
+ };
11847
+ var SecretEnvValues = ["development", "test", "production"];
11839
11848
  var envMap = {
11840
11849
  development: "d",
11841
11850
  test: "q",
11842
11851
  production: "p"
11843
11852
  };
11844
11853
 
11854
+ // ../types/src/types/User.ts
11855
+ var UserPermissions = {
11856
+ admin: "Administrator",
11857
+ manageApplications: "Manage Applications",
11858
+ deleteApplications: "Delete Applications",
11859
+ managePermissions: "Manage Permissions",
11860
+ manageResources: "Manage Resources",
11861
+ manageMetadata: "Manage Metadata",
11862
+ createSecrets: "Create Secrets",
11863
+ deleteSecrets: "Delete Secrets"
11864
+ };
11865
+
11845
11866
  // src/MiauClient.ts
11846
11867
  var import_node_crypto = __toESM(require("node:crypto"));
11847
11868
  var import_jsonwebtoken2 = __toESM(require_jsonwebtoken());
@@ -11934,22 +11955,27 @@ var MiauClient = class {
11934
11955
  this.permissionsCache = /* @__PURE__ */ new Map();
11935
11956
  this.permissionsRequests = /* @__PURE__ */ new Map();
11936
11957
  this.getApiJwtUrl = () => {
11937
- return `${this.apiUrl}/v1/jwt`;
11958
+ return `${this.config.apiUrl}/v1/jwt`;
11938
11959
  };
11939
11960
  this.getPermissionsUrl = () => {
11940
- return `${this.apiUrl}/v1/permissions`;
11961
+ return `${this.config.apiUrl}/v1/permissions`;
11941
11962
  };
11942
11963
  this.getJwksUrl = () => {
11943
- return `${this.apiUrl}/v1/jwks.json`;
11964
+ return `${this.config.apiUrl}/v1/jwks.json`;
11944
11965
  };
11945
- this.apiUrl = config.apiUrl;
11946
- this.environment = config.environment;
11966
+ if (!config.apiUrl || !config.appSecret || !config.environment) {
11967
+ throw new Error("Invalid MiauClient configuration. Please provide apiUrl, appSecret, and environment.");
11968
+ }
11969
+ if (!SecretEnvValues.includes(config.environment)) {
11970
+ throw new Error(`Invalid environment: ${config.environment}. Must be one of ${SecretEnvValues.join(", ")}`);
11971
+ }
11972
+ this.config = config;
11947
11973
  const apiKey = config.appSecret.substring(7, 32);
11948
11974
  const hashedSecret = import_node_crypto.default.createHash("sha256").update(config.appSecret).digest("hex");
11949
11975
  this.basicAuthToken = Buffer.from(`${apiKey}:${hashedSecret}`).toString("base64");
11950
11976
  }
11951
11977
  getEnvironment() {
11952
- return this.environment;
11978
+ return this.config.environment;
11953
11979
  }
11954
11980
  async getPublicKey(kid) {
11955
11981
  if (!this.jwksClient) {
@@ -12018,11 +12044,14 @@ var MiauClient = class {
12018
12044
  HttpMethods,
12019
12045
  MiauClient,
12020
12046
  ResourceProtocols,
12047
+ SecretEnvValues,
12048
+ UserPermissions,
12021
12049
  envMap,
12022
12050
  envs,
12023
12051
  expirationOptions,
12024
12052
  expirationOptionsValues,
12025
- expirationTimeToDate
12053
+ expirationTimeToDate,
12054
+ networks
12026
12055
  });
12027
12056
  /*! Bundled license information:
12028
12057