anzar 1.2.6 → 1.2.7
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/dist/index.cjs +11 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -753,7 +753,7 @@ var Configuration = class {
|
|
|
753
753
|
// src/http/jwt_interceptor.ts
|
|
754
754
|
var JwtInterceptor = class {
|
|
755
755
|
apply(axiosInstance, options) {
|
|
756
|
-
const REFRESH_URI = "/auth/
|
|
756
|
+
const REFRESH_URI = "/auth/refresh-token";
|
|
757
757
|
axiosInstance.interceptors.request.use(
|
|
758
758
|
(config) => {
|
|
759
759
|
const accessToken = options?.getToken();
|
|
@@ -813,6 +813,7 @@ function Anzar(anzarConfig, options) {
|
|
|
813
813
|
new JwtInterceptor().apply(axiosInstance, options);
|
|
814
814
|
}
|
|
815
815
|
const generatedAuthApi = new AuthApi(configuration, basePath, axiosInstance);
|
|
816
|
+
const generatedUserApi = new UsersApi(configuration, basePath, axiosInstance);
|
|
816
817
|
return {
|
|
817
818
|
Auth: {
|
|
818
819
|
login: (body) => generatedAuthApi.login(body),
|
|
@@ -826,9 +827,17 @@ function Anzar(anzarConfig, options) {
|
|
|
826
827
|
},
|
|
827
828
|
...anzarConfig.auth?.strategy === "Session" /* Session */ && {
|
|
828
829
|
session: () => generatedAuthApi.getSession()
|
|
830
|
+
},
|
|
831
|
+
isAuthenticated: async () => {
|
|
832
|
+
try {
|
|
833
|
+
const response = await generatedUserApi.findUser();
|
|
834
|
+
return !!response.data;
|
|
835
|
+
} catch {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
829
838
|
}
|
|
830
839
|
},
|
|
831
|
-
User:
|
|
840
|
+
User: generatedUserApi,
|
|
832
841
|
Email: new EmailApi(configuration, basePath, axiosInstance)
|
|
833
842
|
};
|
|
834
843
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -399,6 +399,7 @@ interface SdkOptions {
|
|
|
399
399
|
|
|
400
400
|
declare function Anzar(anzarConfig: AnzarConfig, options?: SdkOptions): {
|
|
401
401
|
Auth: {
|
|
402
|
+
isAuthenticated: () => Promise<boolean>;
|
|
402
403
|
session?: (() => Promise<axios.AxiosResponse<Session, any, {}>>) | undefined;
|
|
403
404
|
login: (body: LoginRequest) => Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
|
|
404
405
|
register: (body: RegisterRequest) => Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -399,6 +399,7 @@ interface SdkOptions {
|
|
|
399
399
|
|
|
400
400
|
declare function Anzar(anzarConfig: AnzarConfig, options?: SdkOptions): {
|
|
401
401
|
Auth: {
|
|
402
|
+
isAuthenticated: () => Promise<boolean>;
|
|
402
403
|
session?: (() => Promise<axios.AxiosResponse<Session, any, {}>>) | undefined;
|
|
403
404
|
login: (body: LoginRequest) => Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
|
|
404
405
|
register: (body: RegisterRequest) => Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
|
package/dist/index.js
CHANGED
|
@@ -719,7 +719,7 @@ var Configuration = class {
|
|
|
719
719
|
// src/http/jwt_interceptor.ts
|
|
720
720
|
var JwtInterceptor = class {
|
|
721
721
|
apply(axiosInstance, options) {
|
|
722
|
-
const REFRESH_URI = "/auth/
|
|
722
|
+
const REFRESH_URI = "/auth/refresh-token";
|
|
723
723
|
axiosInstance.interceptors.request.use(
|
|
724
724
|
(config) => {
|
|
725
725
|
const accessToken = options?.getToken();
|
|
@@ -779,6 +779,7 @@ function Anzar(anzarConfig, options) {
|
|
|
779
779
|
new JwtInterceptor().apply(axiosInstance, options);
|
|
780
780
|
}
|
|
781
781
|
const generatedAuthApi = new AuthApi(configuration, basePath, axiosInstance);
|
|
782
|
+
const generatedUserApi = new UsersApi(configuration, basePath, axiosInstance);
|
|
782
783
|
return {
|
|
783
784
|
Auth: {
|
|
784
785
|
login: (body) => generatedAuthApi.login(body),
|
|
@@ -792,9 +793,17 @@ function Anzar(anzarConfig, options) {
|
|
|
792
793
|
},
|
|
793
794
|
...anzarConfig.auth?.strategy === "Session" /* Session */ && {
|
|
794
795
|
session: () => generatedAuthApi.getSession()
|
|
796
|
+
},
|
|
797
|
+
isAuthenticated: async () => {
|
|
798
|
+
try {
|
|
799
|
+
const response = await generatedUserApi.findUser();
|
|
800
|
+
return !!response.data;
|
|
801
|
+
} catch {
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
795
804
|
}
|
|
796
805
|
},
|
|
797
|
-
User:
|
|
806
|
+
User: generatedUserApi,
|
|
798
807
|
Email: new EmailApi(configuration, basePath, axiosInstance)
|
|
799
808
|
};
|
|
800
809
|
}
|