@ministerjs/auth 1.0.0 → 1.0.1
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/Auth.d.mts +3 -20
- package/dist/Auth.d.ts +3 -20
- package/dist/Auth.js +11 -8
- package/dist/Auth.mjs +11 -8
- package/package.json +11 -8
package/dist/Auth.d.mts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface FetchOptions<T> {
|
|
6
|
-
method?: Methods | Uppercase<Methods>;
|
|
7
|
-
body?: RequestInit["body"];
|
|
8
|
-
query?: Record<string, any>;
|
|
9
|
-
transform?: (data: any) => T;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface FetchResponse<T> {
|
|
13
|
-
ok: boolean;
|
|
14
|
-
json(): Promise<T>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Fetch = <T>(
|
|
18
|
-
url: string,
|
|
19
|
-
options?: FetchOptions<T>,
|
|
20
|
-
) => Promise<FetchResponse<T>>;
|
|
2
|
+
import { Fetch } from '@ministerjs/ui/types';
|
|
3
|
+
export { Fetch, FetchOptions, FetchResponse } from '@ministerjs/ui/types';
|
|
21
4
|
|
|
22
5
|
interface Options<User extends Record<string, any>> {
|
|
23
6
|
fetch: Fetch;
|
|
@@ -48,4 +31,4 @@ declare class Auth<User extends Record<string, any>> {
|
|
|
48
31
|
private setUser;
|
|
49
32
|
}
|
|
50
33
|
|
|
51
|
-
export { Auth
|
|
34
|
+
export { Auth };
|
package/dist/Auth.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface FetchOptions<T> {
|
|
6
|
-
method?: Methods | Uppercase<Methods>;
|
|
7
|
-
body?: RequestInit["body"];
|
|
8
|
-
query?: Record<string, any>;
|
|
9
|
-
transform?: (data: any) => T;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface FetchResponse<T> {
|
|
13
|
-
ok: boolean;
|
|
14
|
-
json(): Promise<T>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Fetch = <T>(
|
|
18
|
-
url: string,
|
|
19
|
-
options?: FetchOptions<T>,
|
|
20
|
-
) => Promise<FetchResponse<T>>;
|
|
2
|
+
import { Fetch } from '@ministerjs/ui/types';
|
|
3
|
+
export { Fetch, FetchOptions, FetchResponse } from '@ministerjs/ui/types';
|
|
21
4
|
|
|
22
5
|
interface Options<User extends Record<string, any>> {
|
|
23
6
|
fetch: Fetch;
|
|
@@ -48,4 +31,4 @@ declare class Auth<User extends Record<string, any>> {
|
|
|
48
31
|
private setUser;
|
|
49
32
|
}
|
|
50
33
|
|
|
51
|
-
export { Auth
|
|
34
|
+
export { Auth };
|
package/dist/Auth.js
CHANGED
|
@@ -57,14 +57,17 @@ var Auth = class {
|
|
|
57
57
|
}
|
|
58
58
|
async login(payload) {
|
|
59
59
|
this.loading.value = true;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
try {
|
|
61
|
+
const response = await this.fetch(this.routes.login, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: JSON.stringify(payload)
|
|
64
|
+
});
|
|
65
|
+
this.on.value = true;
|
|
66
|
+
const { data } = await response.json();
|
|
67
|
+
this.setUser(data);
|
|
68
|
+
} finally {
|
|
69
|
+
this.loading.value = false;
|
|
70
|
+
}
|
|
68
71
|
}
|
|
69
72
|
async checkIn() {
|
|
70
73
|
this.loading.value = true;
|
package/dist/Auth.mjs
CHANGED
|
@@ -33,14 +33,17 @@ var Auth = class {
|
|
|
33
33
|
}
|
|
34
34
|
async login(payload) {
|
|
35
35
|
this.loading.value = true;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
try {
|
|
37
|
+
const response = await this.fetch(this.routes.login, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: JSON.stringify(payload)
|
|
40
|
+
});
|
|
41
|
+
this.on.value = true;
|
|
42
|
+
const { data } = await response.json();
|
|
43
|
+
this.setUser(data);
|
|
44
|
+
} finally {
|
|
45
|
+
this.loading.value = false;
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
async checkIn() {
|
|
46
49
|
this.loading.value = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministerjs/auth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,24 +20,27 @@
|
|
|
20
20
|
"vue": "^3.5.12"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@eslint/js": "^9.
|
|
24
|
-
"@ministerjs/build": "^2.
|
|
25
|
-
"@
|
|
23
|
+
"@eslint/js": "^9.22.0",
|
|
24
|
+
"@ministerjs/build": "^2.1.2",
|
|
25
|
+
"@ministerjs/ui": "^1.0.2",
|
|
26
|
+
"@types/node": "^22.13.10",
|
|
26
27
|
"cross-env": "^7.0.3",
|
|
27
28
|
"eslint": "^9.22.0",
|
|
28
29
|
"eslint-config-prettier": "^10.1.1",
|
|
29
|
-
"globals": "^15.
|
|
30
|
+
"globals": "^15.15.0",
|
|
30
31
|
"prettier": "3.5.3",
|
|
31
32
|
"tsup": "^8.4.0",
|
|
32
33
|
"tsx": "^4.19.3",
|
|
33
34
|
"typescript": "latest",
|
|
34
|
-
"typescript-eslint": "^8.
|
|
35
|
-
"
|
|
35
|
+
"typescript-eslint": "^8.26.1",
|
|
36
|
+
"vitest": "^3.0.9",
|
|
37
|
+
"vue": "^3.5.13"
|
|
36
38
|
},
|
|
37
39
|
"scripts": {
|
|
38
40
|
"dev": "tsup --watch",
|
|
39
41
|
"lint": "eslint ./src --fix",
|
|
40
|
-
"
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"build": "pnpm lint && pnpm test && tsup",
|
|
41
44
|
"release": "pnpm publish --no-git-checks"
|
|
42
45
|
}
|
|
43
46
|
}
|