@eduzz/miau-client 1.1.0 → 1.2.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.
- package/.turbo/turbo-build$colon$types.log +1 -1
- package/dist/MiauClient.d.ts +0 -1
- package/dist/index.js +23 -11
- package/dist/index.js.map +2 -2
- package/dist/miau-types/index.js +15 -5
- package/dist/miau-types/index.js.map +2 -2
- package/dist/miau-types/types/Environments.d.ts +4 -1
- package/dist/miau-types/types/Environments.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MiauClient.ts +12 -9
package/dist/MiauClient.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11716,6 +11716,7 @@ __export(index_exports, {
|
|
|
11716
11716
|
HttpMethods: () => HttpMethods,
|
|
11717
11717
|
MiauClient: () => MiauClient,
|
|
11718
11718
|
ResourceProtocols: () => ResourceProtocols,
|
|
11719
|
+
SecretEnvShort: () => SecretEnvShort,
|
|
11719
11720
|
SecretEnvValues: () => SecretEnvValues,
|
|
11720
11721
|
UserPermissions: () => UserPermissions,
|
|
11721
11722
|
envMap: () => envMap,
|
|
@@ -11723,6 +11724,7 @@ __export(index_exports, {
|
|
|
11723
11724
|
expirationOptions: () => expirationOptions,
|
|
11724
11725
|
expirationOptionsValues: () => expirationOptionsValues,
|
|
11725
11726
|
expirationTimeToDate: () => expirationTimeToDate,
|
|
11727
|
+
inverseEnvMap: () => inverseEnvMap,
|
|
11726
11728
|
issuers: () => issuers,
|
|
11727
11729
|
networks: () => networks
|
|
11728
11730
|
});
|
|
@@ -11836,11 +11838,22 @@ var expirationTimeToDate = (option) => {
|
|
|
11836
11838
|
|
|
11837
11839
|
// ../types/src/types/Environments.ts
|
|
11838
11840
|
var SecretEnvValues = ["development", "test", "production"];
|
|
11841
|
+
var SecretEnvShort = ["d", "q", "p"];
|
|
11839
11842
|
var envs = {
|
|
11840
11843
|
development: "Development",
|
|
11841
11844
|
test: "Testing",
|
|
11842
11845
|
production: "Production"
|
|
11843
11846
|
};
|
|
11847
|
+
var envMap = {
|
|
11848
|
+
development: "d",
|
|
11849
|
+
test: "q",
|
|
11850
|
+
production: "p"
|
|
11851
|
+
};
|
|
11852
|
+
var inverseEnvMap = {
|
|
11853
|
+
d: "development",
|
|
11854
|
+
q: "test",
|
|
11855
|
+
p: "production"
|
|
11856
|
+
};
|
|
11844
11857
|
var networks = {
|
|
11845
11858
|
development: "127.0.0.0/8",
|
|
11846
11859
|
test: "127.0.0.0/8",
|
|
@@ -11851,11 +11864,6 @@ var issuers = {
|
|
|
11851
11864
|
test: "https://miau.testzz.ninja",
|
|
11852
11865
|
production: "https://miau.eduzz.com"
|
|
11853
11866
|
};
|
|
11854
|
-
var envMap = {
|
|
11855
|
-
development: "d",
|
|
11856
|
-
test: "q",
|
|
11857
|
-
production: "p"
|
|
11858
|
-
};
|
|
11859
11867
|
|
|
11860
11868
|
// ../types/src/types/User.ts
|
|
11861
11869
|
var UserPermissions = {
|
|
@@ -12026,11 +12034,8 @@ var MiauClient = class {
|
|
|
12026
12034
|
this.getJwksUrl = () => {
|
|
12027
12035
|
return `${this.config.apiUrl}/v1/jwks.json`;
|
|
12028
12036
|
};
|
|
12029
|
-
if (!config.apiUrl || !config.appSecret
|
|
12030
|
-
throw new Error("Invalid MiauClient configuration. Please provide apiUrl
|
|
12031
|
-
}
|
|
12032
|
-
if (!SecretEnvValues.includes(config.environment)) {
|
|
12033
|
-
throw new Error(`Invalid environment: ${config.environment}. Must be one of ${SecretEnvValues.join(", ")}`);
|
|
12037
|
+
if (!config.apiUrl || !config.appSecret) {
|
|
12038
|
+
throw new Error("Invalid MiauClient configuration. Please provide apiUrl and appSecret.");
|
|
12034
12039
|
}
|
|
12035
12040
|
this.config = config;
|
|
12036
12041
|
const apiKey = config.appSecret.substring(7, 32);
|
|
@@ -12038,7 +12043,12 @@ var MiauClient = class {
|
|
|
12038
12043
|
this.basicAuthToken = Buffer.from(`${apiKey}:${hashedSecret}`).toString("base64");
|
|
12039
12044
|
}
|
|
12040
12045
|
getEnvironment() {
|
|
12041
|
-
|
|
12046
|
+
const envValue = this.config.appSecret.substring(5, 6);
|
|
12047
|
+
const environment = inverseEnvMap[envValue];
|
|
12048
|
+
if (!environment) {
|
|
12049
|
+
throw new Error("Invalid environment in appSecret.");
|
|
12050
|
+
}
|
|
12051
|
+
return environment;
|
|
12042
12052
|
}
|
|
12043
12053
|
async getPublicKey(kid) {
|
|
12044
12054
|
if (!this.jwksClient) {
|
|
@@ -12087,6 +12097,7 @@ var MiauClient = class {
|
|
|
12087
12097
|
HttpMethods,
|
|
12088
12098
|
MiauClient,
|
|
12089
12099
|
ResourceProtocols,
|
|
12100
|
+
SecretEnvShort,
|
|
12090
12101
|
SecretEnvValues,
|
|
12091
12102
|
UserPermissions,
|
|
12092
12103
|
envMap,
|
|
@@ -12094,6 +12105,7 @@ var MiauClient = class {
|
|
|
12094
12105
|
expirationOptions,
|
|
12095
12106
|
expirationOptionsValues,
|
|
12096
12107
|
expirationTimeToDate,
|
|
12108
|
+
inverseEnvMap,
|
|
12097
12109
|
issuers,
|
|
12098
12110
|
networks
|
|
12099
12111
|
});
|