wabe 0.6.8 → 0.6.9
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/README.md +3 -1
- package/dist/authentication/OTP.d.ts +3 -0
- package/dist/authentication/Session.d.ts +1 -1
- package/dist/authentication/interface.d.ts +9 -3
- package/dist/authentication/utils.d.ts +0 -1
- package/dist/database/DatabaseController.d.ts +10 -10
- package/dist/database/interface.d.ts +5 -13
- package/dist/hooks/authentication.d.ts +2 -0
- package/dist/index.js +503 -260
- package/dist/server/interface.d.ts +1 -0
- package/dist/utils/crypto.d.ts +11 -0
- package/dist/utils/export.d.ts +1 -0
- package/dist/utils/index.d.ts +16 -3
- package/generated/schema.graphql +2 -1
- package/generated/wabe.ts +2 -1
- package/package.json +52 -53
- package/bucket/b.txt +0 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
Wabe is an open-source backend as a service that allows you to create your own fully customizable backend in just a few minutes. It handles database access, automatic GraphQL API generation, authentication with various methods (classic or OAuth), permissions, security, emails, and more for you.
|
|
12
12
|
|
|
13
|
+
It requires Bun or Node > 24.7.
|
|
14
|
+
|
|
13
15
|
## Install
|
|
14
16
|
|
|
15
17
|
```sh
|
|
@@ -35,7 +37,7 @@ const run = async () => {
|
|
|
35
37
|
database: {
|
|
36
38
|
adapter: new MongoAdapter({
|
|
37
39
|
databaseName: "WabeApp",
|
|
38
|
-
|
|
40
|
+
databaseUrl: "mongodb://127.0.0.1:27045",
|
|
39
41
|
}),
|
|
40
42
|
},
|
|
41
43
|
port: 3001,
|
|
@@ -3,8 +3,11 @@ export declare class OTP {
|
|
|
3
3
|
private secret;
|
|
4
4
|
internalTotp: TOTP;
|
|
5
5
|
constructor(rootKey: string);
|
|
6
|
+
deriveSecret(userId: string): string;
|
|
6
7
|
generate(userId: string): string;
|
|
7
8
|
verify(otp: string, userId: string): boolean;
|
|
9
|
+
authenticatorGenerate(userId: string): string;
|
|
10
|
+
authenticatorVerify(otp: string, userId: string): boolean;
|
|
8
11
|
generateKeyuri({ userId, emailOrUsername, applicationName }: {
|
|
9
12
|
userId: string;
|
|
10
13
|
emailOrUsername: string;
|
|
@@ -15,7 +15,7 @@ export declare class Session {
|
|
|
15
15
|
refreshToken?: string | null;
|
|
16
16
|
}>;
|
|
17
17
|
create(userId: string, context: WabeContext<DevWabeTypes>);
|
|
18
|
+
refresh(accessToken: string, refreshToken: string, context: WabeContext<DevWabeTypes>);
|
|
18
19
|
delete(context: WabeContext<DevWabeTypes>);
|
|
19
20
|
_isRefreshTokenExpired(userRefreshTokenExpiresAt: Date, refreshTokenAgeInMs: number);
|
|
20
|
-
refresh(accessToken: string, refreshToken: string, context: WabeContext<DevWabeTypes>);
|
|
21
21
|
}
|
|
@@ -2,6 +2,7 @@ import type { User } from "../../generated/wabe";
|
|
|
2
2
|
import type { WabeContext } from "../server/interface";
|
|
3
3
|
import type { SchemaFields } from "../schema";
|
|
4
4
|
import type { WabeTypes, WobeCustomContext } from "../server";
|
|
5
|
+
import type { SelectType } from "../database/interface";
|
|
5
6
|
export declare enum ProviderEnum {
|
|
6
7
|
google = "google",
|
|
7
8
|
github = "github"
|
|
@@ -82,7 +83,7 @@ export type CustomAuthenticationMethods<
|
|
|
82
83
|
isSecondaryFactor?: boolean;
|
|
83
84
|
};
|
|
84
85
|
export type RoleConfig = Array<string>;
|
|
85
|
-
export interface SessionConfig {
|
|
86
|
+
export interface SessionConfig<T extends WabeTypes> {
|
|
86
87
|
/**
|
|
87
88
|
* The time in milliseconds that the access token will expire
|
|
88
89
|
*/
|
|
@@ -99,9 +100,13 @@ export interface SessionConfig {
|
|
|
99
100
|
* The JWT secret used to sign the session tokens
|
|
100
101
|
*/
|
|
101
102
|
jwtSecret: string;
|
|
103
|
+
/**
|
|
104
|
+
* A selection of fields to include in the JWT token in the "user" fields
|
|
105
|
+
*/
|
|
106
|
+
jwtTokenFields?: SelectType<T, "User", keyof T["types"]["User"]>;
|
|
102
107
|
}
|
|
103
108
|
export interface AuthenticationConfig<T extends WabeTypes> {
|
|
104
|
-
session?: SessionConfig
|
|
109
|
+
session?: SessionConfig<T>;
|
|
105
110
|
roles?: RoleConfig;
|
|
106
111
|
successRedirectPath?: string;
|
|
107
112
|
failureRedirectPath?: string;
|
|
@@ -129,5 +134,6 @@ export declare enum AuthenticationProvider {
|
|
|
129
134
|
PhonePassword = "phonePassword"
|
|
130
135
|
}
|
|
131
136
|
export declare enum SecondaryFactor {
|
|
132
|
-
EmailOTP = "emailOTP"
|
|
137
|
+
EmailOTP = "emailOTP",
|
|
138
|
+
QRCodeOTP = "qrcodeOTP"
|
|
133
139
|
}
|
|
@@ -33,7 +33,7 @@ export declare class DatabaseController<T extends WabeTypes> {
|
|
|
33
33
|
});
|
|
34
34
|
_getWhereObjectWithPointerOrRelation<U extends keyof T["types"]>(className: U, where: WhereType<T, U>, context: WabeContext<T>);
|
|
35
35
|
_buildWhereWithACL<K extends keyof T["types"]>(where: WhereType<T, K>, context: WabeContext<T>, operation: "write" | "read"): WhereType<T, K>;
|
|
36
|
-
_getFinalObjectWithPointerAndRelation({ pointers, context, originClassName, object,
|
|
36
|
+
_getFinalObjectWithPointerAndRelation({ pointers, context, originClassName, object, _skipHooks }: {
|
|
37
37
|
originClassName: string;
|
|
38
38
|
pointers: Record<string, {
|
|
39
39
|
className: string;
|
|
@@ -41,7 +41,7 @@ export declare class DatabaseController<T extends WabeTypes> {
|
|
|
41
41
|
}>;
|
|
42
42
|
context: WabeContext<any>;
|
|
43
43
|
object: Record<string, any>;
|
|
44
|
-
|
|
44
|
+
_skipHooks?: boolean;
|
|
45
45
|
});
|
|
46
46
|
close();
|
|
47
47
|
createClassIfNotExist(className: string, schema: SchemaInterface<T>): Promise<any>;
|
|
@@ -51,42 +51,42 @@ export declare class DatabaseController<T extends WabeTypes> {
|
|
|
51
51
|
getObject<
|
|
52
52
|
K extends keyof T["types"],
|
|
53
53
|
U extends keyof T["types"][K]
|
|
54
|
-
>({ select, className, context,
|
|
54
|
+
>({ select, className, context, _skipHooks, id, where }: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
55
55
|
getObjects<
|
|
56
56
|
K extends keyof T["types"],
|
|
57
57
|
U extends keyof T["types"][K],
|
|
58
58
|
W extends keyof T["types"][K]
|
|
59
|
-
>({ className, select, context, where,
|
|
59
|
+
>({ className, select, context, where, _skipHooks, first, offset, order }: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
60
60
|
createObject<
|
|
61
61
|
K extends keyof T["types"],
|
|
62
62
|
U extends keyof T["types"][K],
|
|
63
63
|
W extends keyof T["types"][K]
|
|
64
|
-
>({ className, context, data, select
|
|
64
|
+
>({ className, context, data, select }: CreateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
|
|
65
65
|
createObjects<
|
|
66
66
|
K extends keyof T["types"],
|
|
67
67
|
U extends keyof T["types"][K],
|
|
68
68
|
W extends keyof T["types"][K],
|
|
69
69
|
X extends keyof T["types"][K]
|
|
70
|
-
>({ data, select, className, context, first, offset, order
|
|
70
|
+
>({ data, select, className, context, first, offset, order }: CreateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
|
|
71
71
|
updateObject<
|
|
72
72
|
K extends keyof T["types"],
|
|
73
73
|
U extends keyof T["types"][K],
|
|
74
74
|
W extends keyof T["types"][K]
|
|
75
|
-
>({ id, className, context, data, select,
|
|
75
|
+
>({ id, className, context, data, select, _skipHooks }: UpdateObjectOptions<T, K, U, W>): Promise<OutputType<T, K, W>>;
|
|
76
76
|
updateObjects<
|
|
77
77
|
K extends keyof T["types"],
|
|
78
78
|
U extends keyof T["types"][K],
|
|
79
79
|
W extends keyof T["types"][K],
|
|
80
80
|
X extends keyof T["types"][K]
|
|
81
|
-
>({ className, where, context, select, data, first, offset, order,
|
|
81
|
+
>({ className, where, context, select, data, first, offset, order, _skipHooks }: UpdateObjectsOptions<T, K, U, W, X>): Promise<OutputType<T, K, W>[]>;
|
|
82
82
|
deleteObject<
|
|
83
83
|
K extends keyof T["types"],
|
|
84
84
|
U extends keyof T["types"][K]
|
|
85
|
-
>({ context, className, id, select
|
|
85
|
+
>({ context, className, id, select }: DeleteObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
86
86
|
deleteObjects<
|
|
87
87
|
K extends keyof T["types"],
|
|
88
88
|
U extends keyof T["types"][K],
|
|
89
89
|
W extends keyof T["types"][K]
|
|
90
|
-
>({ className, context, select, where, first, offset, order
|
|
90
|
+
>({ className, context, select, where, first, offset, order }: DeleteObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
91
91
|
}
|
|
92
92
|
export {};
|
|
@@ -95,9 +95,8 @@ export interface GetObjectOptions<
|
|
|
95
95
|
id: string;
|
|
96
96
|
where?: WhereType<T, K>;
|
|
97
97
|
context: WabeContext<T>;
|
|
98
|
-
|
|
98
|
+
_skipHooks?: boolean;
|
|
99
99
|
select?: SelectType<T, K, U>;
|
|
100
|
-
isGraphQLCall?: boolean;
|
|
101
100
|
}
|
|
102
101
|
export interface GetObjectsOptions<
|
|
103
102
|
T extends WabeTypes,
|
|
@@ -111,9 +110,8 @@ export interface GetObjectsOptions<
|
|
|
111
110
|
offset?: number;
|
|
112
111
|
first?: number;
|
|
113
112
|
context: WabeContext<T>;
|
|
114
|
-
|
|
113
|
+
_skipHooks?: boolean;
|
|
115
114
|
select?: SelectType<T, K, W>;
|
|
116
|
-
isGraphQLCall?: boolean;
|
|
117
115
|
}
|
|
118
116
|
export interface CreateObjectOptions<
|
|
119
117
|
T extends WabeTypes,
|
|
@@ -125,7 +123,6 @@ export interface CreateObjectOptions<
|
|
|
125
123
|
data: MutationData<T, K, U>;
|
|
126
124
|
context: WabeContext<T>;
|
|
127
125
|
select?: SelectType<T, K, W>;
|
|
128
|
-
isGraphQLCall?: boolean;
|
|
129
126
|
}
|
|
130
127
|
export interface CreateObjectsOptions<
|
|
131
128
|
T extends WabeTypes,
|
|
@@ -141,7 +138,6 @@ export interface CreateObjectsOptions<
|
|
|
141
138
|
order?: OrderType<T, U, X>;
|
|
142
139
|
context: WabeContext<T>;
|
|
143
140
|
select?: SelectType<T, K, W>;
|
|
144
|
-
isGraphQLCall?: boolean;
|
|
145
141
|
}
|
|
146
142
|
export interface UpdateObjectOptions<
|
|
147
143
|
T extends WabeTypes,
|
|
@@ -154,9 +150,8 @@ export interface UpdateObjectOptions<
|
|
|
154
150
|
where?: WhereType<T, K>;
|
|
155
151
|
data: MutationData<T, K, U>;
|
|
156
152
|
context: WabeContext<T>;
|
|
157
|
-
|
|
153
|
+
_skipHooks?: boolean;
|
|
158
154
|
select?: SelectType<T, K, W>;
|
|
159
|
-
isGraphQLCall?: boolean;
|
|
160
155
|
}
|
|
161
156
|
export interface UpdateObjectsOptions<
|
|
162
157
|
T extends WabeTypes,
|
|
@@ -172,9 +167,8 @@ export interface UpdateObjectsOptions<
|
|
|
172
167
|
offset?: number;
|
|
173
168
|
first?: number;
|
|
174
169
|
context: WabeContext<T>;
|
|
175
|
-
|
|
170
|
+
_skipHooks?: boolean;
|
|
176
171
|
select?: SelectType<T, K, W>;
|
|
177
|
-
isGraphQLCall?: boolean;
|
|
178
172
|
}
|
|
179
173
|
export interface DeleteObjectOptions<
|
|
180
174
|
T extends WabeTypes,
|
|
@@ -186,7 +180,6 @@ export interface DeleteObjectOptions<
|
|
|
186
180
|
where?: WhereType<T, K>;
|
|
187
181
|
context: WabeContext<T>;
|
|
188
182
|
select?: SelectType<T, K, U>;
|
|
189
|
-
isGraphQLCall?: boolean;
|
|
190
183
|
}
|
|
191
184
|
export interface DeleteObjectsOptions<
|
|
192
185
|
T extends WabeTypes,
|
|
@@ -201,11 +194,10 @@ export interface DeleteObjectsOptions<
|
|
|
201
194
|
first?: number;
|
|
202
195
|
context: WabeContext<T>;
|
|
203
196
|
select?: SelectType<T, K, W>;
|
|
204
|
-
isGraphQLCall?: boolean;
|
|
205
197
|
}
|
|
206
198
|
export interface DatabaseAdapter<T extends WabeTypes> {
|
|
207
199
|
close(): Promise<void>;
|
|
208
|
-
createClassIfNotExist(className: string, schema: SchemaInterface<T>): Promise<any
|
|
200
|
+
createClassIfNotExist(className: string, schema: SchemaInterface<T>): Promise<any> | any;
|
|
209
201
|
initializeDatabase(schema: SchemaInterface<T>): Promise<void>;
|
|
210
202
|
clearDatabase(): Promise<void>;
|
|
211
203
|
count<K extends keyof T["types"]>(params: CountOptions<T, K>): Promise<number>;
|