@convex-dev/workos-authkit 0.2.8 → 0.2.10
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 +4 -5
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -2
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +0 -1
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +0 -2
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/server.d.ts +12 -0
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +2 -0
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/backfill.d.ts +6 -6
- package/dist/component/backfill.d.ts.map +1 -1
- package/dist/component/backfill.js +12 -5
- package/dist/component/backfill.js.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +0 -2
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/lib.d.ts +7 -27
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +94 -122
- package/dist/component/lib.js.map +1 -1
- package/dist/component/schema.d.ts +13 -4
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +7 -14
- package/dist/component/schema.js.map +1 -1
- package/dist/validators.d.ts +30 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +17 -0
- package/dist/validators.js.map +1 -0
- package/package.json +5 -5
- package/src/client/index.test.ts +18 -0
- package/src/client/index.ts +10 -2
- package/src/component/_generated/api.ts +0 -1
- package/src/component/_generated/component.ts +0 -2
- package/src/component/_generated/server.ts +13 -0
- package/src/component/backfill.test.ts +19 -11
- package/src/component/backfill.ts +25 -18
- package/src/component/convex.config.ts +0 -2
- package/src/component/lib.test.ts +370 -0
- package/src/component/lib.ts +97 -133
- package/src/component/schema.ts +7 -14
- package/src/test.ts +0 -2
- package/src/validators.ts +17 -0
package/dist/component/lib.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { components, internal } from "./_generated/api.js";
|
|
4
|
-
import { omit, withoutSystemFields } from "convex-helpers";
|
|
5
|
-
import { WorkOS } from "@workos-inc/node";
|
|
6
|
-
import { Workpool } from "@convex-dev/workpool";
|
|
7
|
-
import schema from "./schema.js";
|
|
1
|
+
import {} from "@workos-inc/node";
|
|
2
|
+
import { withoutSystemFields } from "convex-helpers";
|
|
8
3
|
import { parse } from "convex-helpers/validators";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
4
|
+
import { v } from "convex/values";
|
|
5
|
+
import { vUser } from "../validators.js";
|
|
6
|
+
import { mutation, query } from "./_generated/server.js";
|
|
12
7
|
export const vEvent = v.object({
|
|
13
8
|
id: v.string(),
|
|
14
9
|
createdAt: v.string(),
|
|
@@ -16,10 +11,29 @@ export const vEvent = v.object({
|
|
|
16
11
|
data: v.record(v.string(), v.any()),
|
|
17
12
|
context: v.optional(v.record(v.string(), v.any())),
|
|
18
13
|
});
|
|
14
|
+
/**
|
|
15
|
+
* Returns the WorkOS user id an event is about, or undefined when the
|
|
16
|
+
* event is about something other than a user.
|
|
17
|
+
*/
|
|
18
|
+
function eventUserId(event) {
|
|
19
|
+
const data = event.data;
|
|
20
|
+
if (typeof data.userId === "string") {
|
|
21
|
+
return data.userId;
|
|
22
|
+
}
|
|
23
|
+
const isUserEvent = event.event === "user.created" ||
|
|
24
|
+
event.event === "user.updated" ||
|
|
25
|
+
event.event === "user.deleted";
|
|
26
|
+
if (isUserEvent && typeof data.id === "string") {
|
|
27
|
+
return data.id;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
19
31
|
async function processEventHandler(ctx, args) {
|
|
20
32
|
if (args.logLevel === "DEBUG") {
|
|
21
33
|
console.log("processing event", args.event);
|
|
22
34
|
}
|
|
35
|
+
const event = args.event;
|
|
36
|
+
const userId = eventUserId(args.event);
|
|
23
37
|
const dbEvent = await ctx.db
|
|
24
38
|
.query("events")
|
|
25
39
|
.withIndex("eventId", (q) => q.eq("eventId", args.event.id))
|
|
@@ -29,178 +43,136 @@ async function processEventHandler(ctx, args) {
|
|
|
29
43
|
return;
|
|
30
44
|
}
|
|
31
45
|
await ctx.db.insert("events", {
|
|
46
|
+
userId,
|
|
32
47
|
eventId: args.event.id,
|
|
33
48
|
event: args.event.event,
|
|
34
49
|
updatedAt: args.event.data.updatedAt,
|
|
35
50
|
});
|
|
36
|
-
|
|
51
|
+
let eventForCallback = event.event;
|
|
52
|
+
let dataForCallback = args.event.data;
|
|
37
53
|
switch (event.event) {
|
|
38
|
-
case "user.created":
|
|
39
|
-
const data = omit(event.data, ["object"]);
|
|
40
|
-
const existingUser = await ctx.db
|
|
41
|
-
.query("users")
|
|
42
|
-
.withIndex("id", (q) => q.eq("id", data.id))
|
|
43
|
-
.unique();
|
|
44
|
-
if (existingUser) {
|
|
45
|
-
console.warn("user already exists", data.id);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
await ctx.db.insert("users", data);
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
54
|
+
case "user.created":
|
|
51
55
|
case "user.updated": {
|
|
52
|
-
const data =
|
|
53
|
-
const
|
|
56
|
+
const data = parse(vUser, event.data);
|
|
57
|
+
const existingUser = await ctx.db
|
|
54
58
|
.query("users")
|
|
55
59
|
.withIndex("id", (q) => q.eq("id", data.id))
|
|
56
60
|
.unique();
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
if (!existingUser) {
|
|
62
|
+
const deletedUser = await ctx.db
|
|
63
|
+
.query("deletedUsers")
|
|
64
|
+
.withIndex("id", (q) => q.eq("id", data.id))
|
|
65
|
+
.unique();
|
|
66
|
+
if (deletedUser) {
|
|
67
|
+
console.warn("user already deleted, skipping", event.event, data.id);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await ctx.db.insert("users", data);
|
|
71
|
+
if (event.event === "user.updated") {
|
|
72
|
+
// WorkOS can deliver the update before the create. The update
|
|
73
|
+
// payload holds the whole user, so it is safe to insert.
|
|
74
|
+
console.warn("user not found for update, inserting", data.id);
|
|
75
|
+
eventForCallback = "user.created";
|
|
76
|
+
}
|
|
60
77
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
else {
|
|
79
|
+
if (event.event === "user.created") {
|
|
80
|
+
console.warn("user already exists", data.id);
|
|
81
|
+
// The callback already fired as user.created when this user was
|
|
82
|
+
// first inserted, so skip it here.
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
else if (existingUser.updatedAt >= data.updatedAt) {
|
|
86
|
+
console.warn(`user already updated for event ${event.id}, skipping`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await ctx.db.patch("users", existingUser._id, data);
|
|
64
90
|
}
|
|
65
|
-
await ctx.db.patch("users", user._id, data);
|
|
66
91
|
break;
|
|
67
92
|
}
|
|
68
93
|
case "user.deleted": {
|
|
69
|
-
|
|
94
|
+
// Only the id is needed, so a trimmed payload should not fail the webhook.
|
|
95
|
+
const { id } = parse(v.object({ id: v.string() }), event.data);
|
|
96
|
+
// Record the deletion even if the user was never inserted locally, so a
|
|
97
|
+
// late user.created or user.updated for this user is skipped.
|
|
98
|
+
const deletedUser = await ctx.db
|
|
99
|
+
.query("deletedUsers")
|
|
100
|
+
.withIndex("id", (q) => q.eq("id", id))
|
|
101
|
+
.unique();
|
|
102
|
+
if (!deletedUser) {
|
|
103
|
+
await ctx.db.insert("deletedUsers", { id });
|
|
104
|
+
}
|
|
70
105
|
const user = await ctx.db
|
|
71
106
|
.query("users")
|
|
72
|
-
.withIndex("id", (q) => q.eq("id",
|
|
107
|
+
.withIndex("id", (q) => q.eq("id", id))
|
|
73
108
|
.unique();
|
|
74
109
|
if (!user) {
|
|
75
|
-
console.warn("user not found",
|
|
110
|
+
console.warn("user not found, skipping deletion", id);
|
|
76
111
|
return;
|
|
77
112
|
}
|
|
78
113
|
await ctx.db.delete("users", user._id);
|
|
114
|
+
// The callback data is typed as a whole user, so fill anything the
|
|
115
|
+
// payload left out from the stored user.
|
|
116
|
+
dataForCallback = {
|
|
117
|
+
...withoutSystemFields(user),
|
|
118
|
+
object: "user",
|
|
119
|
+
...args.event.data,
|
|
120
|
+
};
|
|
79
121
|
break;
|
|
80
122
|
}
|
|
81
123
|
}
|
|
82
124
|
if (args.onEventHandle) {
|
|
83
125
|
await ctx.runMutation(args.onEventHandle, {
|
|
84
|
-
event:
|
|
85
|
-
data:
|
|
126
|
+
event: eventForCallback,
|
|
127
|
+
data: dataForCallback,
|
|
86
128
|
});
|
|
87
129
|
}
|
|
88
130
|
}
|
|
89
131
|
export const onWebhookEvent = mutation({
|
|
90
132
|
args: {
|
|
91
|
-
apiKey: v.string(),
|
|
92
133
|
event: vEvent,
|
|
93
134
|
onEventHandle: v.optional(v.string()),
|
|
94
|
-
eventTypes: v.optional(v.array(v.string())),
|
|
95
135
|
logLevel: v.optional(v.literal("DEBUG")),
|
|
96
136
|
},
|
|
97
137
|
returns: v.null(),
|
|
98
138
|
handler: async (ctx, args) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Process create events immediately
|
|
102
|
-
await processEventHandler(ctx, args);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
// Enqueue update/delete events to workpool
|
|
106
|
-
await eventWorkpool.enqueueAction(ctx, internal.lib.updateEvents, {
|
|
107
|
-
apiKey: args.apiKey,
|
|
108
|
-
onEventHandle: args.onEventHandle,
|
|
109
|
-
eventTypes: args.eventTypes,
|
|
110
|
-
logLevel: args.logLevel,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
export const getCursor = internalQuery({
|
|
117
|
-
args: {},
|
|
118
|
-
returns: v.union(v.string(), v.null()),
|
|
119
|
-
handler: async (ctx) => {
|
|
120
|
-
const lastProcessedEvent = await ctx.db
|
|
121
|
-
.query("events")
|
|
122
|
-
.order("desc")
|
|
123
|
-
.first();
|
|
124
|
-
return lastProcessedEvent?.eventId;
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
export const updateEvents = internalAction({
|
|
128
|
-
args: {
|
|
129
|
-
apiKey: v.string(),
|
|
130
|
-
onEventHandle: v.optional(v.string()),
|
|
131
|
-
eventTypes: v.optional(v.array(v.string())),
|
|
132
|
-
logLevel: v.optional(v.literal("DEBUG")),
|
|
133
|
-
},
|
|
134
|
-
handler: async (ctx, args) => {
|
|
135
|
-
// Cancel other pending workpool jobs since this run will
|
|
136
|
-
// process all available events from the WorkOS API.
|
|
137
|
-
await eventWorkpool.cancelAll(ctx);
|
|
138
|
-
const workos = new WorkOS(args.apiKey);
|
|
139
|
-
const cursor = await ctx.runQuery(internal.lib.getCursor);
|
|
140
|
-
let nextCursor = cursor ?? undefined;
|
|
141
|
-
const eventTypes = [
|
|
142
|
-
"user.created",
|
|
143
|
-
"user.updated",
|
|
144
|
-
"user.deleted",
|
|
145
|
-
...(args.eventTypes ?? []),
|
|
146
|
-
];
|
|
147
|
-
// No cursor should mean we haven't handled any events - set
|
|
148
|
-
// a start time of 5 minutes ago
|
|
149
|
-
let rangeStart = nextCursor
|
|
150
|
-
? undefined
|
|
151
|
-
: new Date(Date.now() - 1000 * 60 * 5).toISOString();
|
|
152
|
-
do {
|
|
153
|
-
const { data, listMetadata } = await workos.events.listEvents({
|
|
154
|
-
events: eventTypes,
|
|
155
|
-
after: nextCursor,
|
|
156
|
-
rangeStart,
|
|
157
|
-
});
|
|
158
|
-
for (const event of data) {
|
|
159
|
-
await ctx.runMutation(internal.lib.processEvent, {
|
|
160
|
-
event: parse(vEvent, event),
|
|
161
|
-
logLevel: args.logLevel,
|
|
162
|
-
onEventHandle: args.onEventHandle,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
nextCursor = listMetadata.after ?? undefined;
|
|
166
|
-
rangeStart = undefined;
|
|
167
|
-
} while (nextCursor);
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
export const processEvent = internalMutation({
|
|
171
|
-
args: {
|
|
172
|
-
event: vEvent,
|
|
173
|
-
logLevel: v.optional(v.literal("DEBUG")),
|
|
174
|
-
onEventHandle: v.optional(v.string()),
|
|
175
|
-
},
|
|
176
|
-
handler: async (ctx, args) => {
|
|
139
|
+
// The payload is signature-verified and dedupes on eventId, so all
|
|
140
|
+
// event types can be processed inline.
|
|
177
141
|
await processEventHandler(ctx, args);
|
|
142
|
+
return null;
|
|
178
143
|
},
|
|
179
144
|
});
|
|
180
145
|
export const getAuthUser = query({
|
|
181
146
|
args: {
|
|
182
147
|
id: v.string(),
|
|
183
148
|
},
|
|
184
|
-
returns: v.union(
|
|
149
|
+
returns: v.union(vUser, v.null()),
|
|
185
150
|
handler: async (ctx, args) => {
|
|
186
151
|
const user = await ctx.db
|
|
187
152
|
.query("users")
|
|
188
153
|
.withIndex("id", (q) => q.eq("id", args.id))
|
|
189
154
|
.unique();
|
|
190
|
-
return
|
|
155
|
+
return publicUser(user);
|
|
191
156
|
},
|
|
192
157
|
});
|
|
193
158
|
export const getAuthUserByExternalId = query({
|
|
194
159
|
args: {
|
|
195
160
|
externalId: v.string(),
|
|
196
161
|
},
|
|
197
|
-
returns: v.union(
|
|
162
|
+
returns: v.union(vUser, v.null()),
|
|
198
163
|
handler: async (ctx, args) => {
|
|
199
164
|
const user = await ctx.db
|
|
200
165
|
.query("users")
|
|
201
166
|
.withIndex("externalId", (q) => q.eq("externalId", args.externalId))
|
|
202
167
|
.unique();
|
|
203
|
-
return
|
|
168
|
+
return publicUser(user);
|
|
204
169
|
},
|
|
205
170
|
});
|
|
171
|
+
/** Drops the Convex system fields so the user matches the public vUser shape. */
|
|
172
|
+
function publicUser(user) {
|
|
173
|
+
if (!user) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return withoutSystemFields(user);
|
|
177
|
+
}
|
|
206
178
|
//# sourceMappingURL=lib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAc,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAS,WAAW,CAAC,KAA2B;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,IAA0C,CAAC;IAC9D,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,MAAM,WAAW,GAC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CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
2
|
events: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
3
|
updatedAt?: string | undefined;
|
|
4
|
+
userId?: string | undefined;
|
|
4
5
|
event: string;
|
|
5
6
|
eventId: string;
|
|
6
7
|
}, {
|
|
7
8
|
eventId: import("convex/values").VString<string, "required">;
|
|
8
9
|
event: import("convex/values").VString<string, "required">;
|
|
9
10
|
updatedAt: import("convex/values").VString<string | undefined, "optional">;
|
|
10
|
-
|
|
11
|
+
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
12
|
+
}, "required", "updatedAt" | "event" | "eventId" | "userId">, {
|
|
11
13
|
eventId: ["eventId", "_creationTime"];
|
|
12
14
|
}, {}, {}>;
|
|
13
15
|
backfillState: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
@@ -16,19 +18,19 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
16
18
|
apiKey: import("convex/values").VString<string, "required">;
|
|
17
19
|
}, "required", "apiKey">, {}, {}, {}>;
|
|
18
20
|
users: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
19
|
-
externalId?: string | null | undefined;
|
|
20
21
|
name?: string | null | undefined;
|
|
21
22
|
firstName?: string | null | undefined;
|
|
22
23
|
lastName?: string | null | undefined;
|
|
23
24
|
profilePictureUrl?: string | null | undefined;
|
|
24
25
|
lastSignInAt?: string | null | undefined;
|
|
26
|
+
externalId?: string | null | undefined;
|
|
25
27
|
locale?: string | null | undefined;
|
|
26
28
|
id: string;
|
|
27
|
-
updatedAt: string;
|
|
28
29
|
email: string;
|
|
29
30
|
emailVerified: boolean;
|
|
30
31
|
metadata: Record<string, any>;
|
|
31
32
|
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
32
34
|
}, {
|
|
33
35
|
id: import("convex/values").VString<string, "required">;
|
|
34
36
|
email: import("convex/values").VString<string, "required">;
|
|
@@ -43,10 +45,17 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
43
45
|
locale: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
44
46
|
createdAt: import("convex/values").VString<string, "required">;
|
|
45
47
|
updatedAt: import("convex/values").VString<string, "required">;
|
|
46
|
-
}, "required", "id" | "
|
|
48
|
+
}, "required", "id" | "email" | "name" | "firstName" | "lastName" | "emailVerified" | "profilePictureUrl" | "lastSignInAt" | "externalId" | "metadata" | "locale" | "createdAt" | "updatedAt" | `metadata.${string}`>, {
|
|
47
49
|
id: ["id", "_creationTime"];
|
|
48
50
|
externalId: ["externalId", "_creationTime"];
|
|
49
51
|
}, {}, {}>;
|
|
52
|
+
deletedUsers: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
53
|
+
id: string;
|
|
54
|
+
}, {
|
|
55
|
+
id: import("convex/values").VString<string, "required">;
|
|
56
|
+
}, "required", "id">, {
|
|
57
|
+
id: ["id", "_creationTime"];
|
|
58
|
+
}, {}, {}>;
|
|
50
59
|
}, true>;
|
|
51
60
|
export default _default;
|
|
52
61
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAgBG"}
|
package/dist/component/schema.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
2
|
import { v } from "convex/values";
|
|
3
|
+
import { vUser } from "../validators.js";
|
|
3
4
|
export default defineSchema({
|
|
4
5
|
events: defineTable({
|
|
5
6
|
eventId: v.string(),
|
|
6
7
|
event: v.string(),
|
|
7
8
|
updatedAt: v.optional(v.string()),
|
|
9
|
+
userId: v.optional(v.string()),
|
|
8
10
|
}).index("eventId", ["eventId"]),
|
|
9
11
|
backfillState: defineTable({
|
|
10
12
|
apiKey: v.string(),
|
|
11
13
|
}),
|
|
12
|
-
users: defineTable(
|
|
14
|
+
users: defineTable(vUser)
|
|
15
|
+
.index("id", ["id"])
|
|
16
|
+
.index("externalId", ["externalId"]),
|
|
17
|
+
deletedUsers: defineTable({
|
|
13
18
|
id: v.string(),
|
|
14
|
-
|
|
15
|
-
name: v.optional(v.union(v.null(), v.string())),
|
|
16
|
-
firstName: v.optional(v.union(v.null(), v.string())),
|
|
17
|
-
lastName: v.optional(v.union(v.null(), v.string())),
|
|
18
|
-
emailVerified: v.boolean(),
|
|
19
|
-
profilePictureUrl: v.optional(v.union(v.null(), v.string())),
|
|
20
|
-
lastSignInAt: v.optional(v.union(v.null(), v.string())),
|
|
21
|
-
externalId: v.optional(v.union(v.null(), v.string())),
|
|
22
|
-
metadata: v.record(v.string(), v.any()),
|
|
23
|
-
locale: v.optional(v.union(v.null(), v.string())),
|
|
24
|
-
createdAt: v.string(),
|
|
25
|
-
updatedAt: v.string(),
|
|
26
|
-
}).index("id", ["id"]).index("externalId", ["externalId"]),
|
|
19
|
+
}).index("id", ["id"]),
|
|
27
20
|
});
|
|
28
21
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,eAAe,YAAY,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;QAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC/B,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC;IAChC,aAAa,EAAE,WAAW,CAAC;QACzB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC;IACF,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC;SACtB,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;SACnB,KAAK,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC;IACtC,YAAY,EAAE,WAAW,CAAC;QACxB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;KACf,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const vUser: import("convex/values").VObject<{
|
|
2
|
+
name?: string | null | undefined;
|
|
3
|
+
firstName?: string | null | undefined;
|
|
4
|
+
lastName?: string | null | undefined;
|
|
5
|
+
profilePictureUrl?: string | null | undefined;
|
|
6
|
+
lastSignInAt?: string | null | undefined;
|
|
7
|
+
externalId?: string | null | undefined;
|
|
8
|
+
locale?: string | null | undefined;
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
emailVerified: boolean;
|
|
12
|
+
metadata: Record<string, any>;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
}, {
|
|
16
|
+
id: import("convex/values").VString<string, "required">;
|
|
17
|
+
email: import("convex/values").VString<string, "required">;
|
|
18
|
+
name: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
19
|
+
firstName: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
20
|
+
lastName: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
21
|
+
emailVerified: import("convex/values").VBoolean<boolean, "required">;
|
|
22
|
+
profilePictureUrl: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
23
|
+
lastSignInAt: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
24
|
+
externalId: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
25
|
+
metadata: import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>;
|
|
26
|
+
locale: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
|
|
27
|
+
createdAt: import("convex/values").VString<string, "required">;
|
|
28
|
+
updatedAt: import("convex/values").VString<string, "required">;
|
|
29
|
+
}, "required", "id" | "email" | "name" | "firstName" | "lastName" | "emailVerified" | "profilePictureUrl" | "lastSignInAt" | "externalId" | "metadata" | "locale" | "createdAt" | "updatedAt" | `metadata.${string}`>;
|
|
30
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;qNAchB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
export const vUser = v.object({
|
|
3
|
+
id: v.string(),
|
|
4
|
+
email: v.string(),
|
|
5
|
+
name: v.optional(v.union(v.null(), v.string())),
|
|
6
|
+
firstName: v.optional(v.union(v.null(), v.string())),
|
|
7
|
+
lastName: v.optional(v.union(v.null(), v.string())),
|
|
8
|
+
emailVerified: v.boolean(),
|
|
9
|
+
profilePictureUrl: v.optional(v.union(v.null(), v.string())),
|
|
10
|
+
lastSignInAt: v.optional(v.union(v.null(), v.string())),
|
|
11
|
+
externalId: v.optional(v.union(v.null(), v.string())),
|
|
12
|
+
metadata: v.record(v.string(), v.any()),
|
|
13
|
+
locale: v.optional(v.union(v.null(), v.string())),
|
|
14
|
+
createdAt: v.string(),
|
|
15
|
+
updatedAt: v.string(),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACpD,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5D,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/get-convex/workos-authkit/issues"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.10",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"convex",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@arethetypeswrong/cli": "0.18.5",
|
|
70
|
-
"@convex-dev/eslint-plugin": "
|
|
70
|
+
"@convex-dev/eslint-plugin": "5.0.0",
|
|
71
71
|
"@edge-runtime/vm": "5.0.0",
|
|
72
72
|
"@eslint/eslintrc": "3.3.6",
|
|
73
73
|
"@eslint/js": "9.39.5",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/react-dom": "19.2.3",
|
|
77
77
|
"@vitejs/plugin-react": "6.0.4",
|
|
78
78
|
"chokidar-cli": "3.0.0",
|
|
79
|
-
"convex": "1.
|
|
79
|
+
"convex": "1.44.0",
|
|
80
80
|
"convex-test": "0.0.54",
|
|
81
81
|
"eslint": "9.39.5",
|
|
82
82
|
"eslint-plugin-react": "7.37.5",
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
"typescript": "5.9.3",
|
|
91
91
|
"typescript-eslint": "8.65.0",
|
|
92
92
|
"vite": "8.1.5",
|
|
93
|
-
"vitest": "
|
|
93
|
+
"vitest": "5.0.0"
|
|
94
94
|
},
|
|
95
95
|
"types": "./dist/client/index.d.ts",
|
|
96
96
|
"module": "./dist/client/index.js",
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@convex-dev/workflow": "^0.4.0",
|
|
99
99
|
"@convex-dev/workos": "^0.0.3",
|
|
100
|
-
"@convex-dev/workpool": "^0.4.
|
|
100
|
+
"@convex-dev/workpool": "^0.4.4",
|
|
101
101
|
"convex-helpers": "^0.1.111",
|
|
102
102
|
"type-fest": "^5.1.0"
|
|
103
103
|
}
|
package/src/client/index.test.ts
CHANGED
|
@@ -59,6 +59,24 @@ describe("AuthKit constructor", () => {
|
|
|
59
59
|
expect.objectContaining({ clientId: "client_test" })
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
test("warns when additionalEventTypes is set", () => {
|
|
64
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
65
|
+
|
|
66
|
+
new AuthKit(fakeComponent, { additionalEventTypes: ["session.created"] });
|
|
67
|
+
|
|
68
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
69
|
+
warnSpy.mockRestore();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("does not warn when additionalEventTypes is unset", () => {
|
|
73
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
74
|
+
|
|
75
|
+
new AuthKit(fakeComponent);
|
|
76
|
+
|
|
77
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
78
|
+
warnSpy.mockRestore();
|
|
79
|
+
});
|
|
62
80
|
});
|
|
63
81
|
|
|
64
82
|
describe("AuthKit.getAuthConfigProviders", () => {
|
package/src/client/index.ts
CHANGED
|
@@ -33,6 +33,11 @@ type Options = {
|
|
|
33
33
|
apiHostname?: string;
|
|
34
34
|
webhookSecret?: string;
|
|
35
35
|
webhookPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Unused. Events arrive by webhook, so select the event
|
|
38
|
+
* types in the WorkOS webhook configuration and add a handler for each
|
|
39
|
+
* in `events()`.
|
|
40
|
+
*/
|
|
36
41
|
additionalEventTypes?: WorkOSEvent["event"][];
|
|
37
42
|
actionSecret?: string;
|
|
38
43
|
logLevel?: "DEBUG";
|
|
@@ -71,6 +76,11 @@ export class AuthKit<DataModel extends GenericDataModel> {
|
|
|
71
76
|
public component: ComponentApi,
|
|
72
77
|
public options?: Options
|
|
73
78
|
) {
|
|
79
|
+
if (options?.additionalEventTypes?.length) {
|
|
80
|
+
console.warn(
|
|
81
|
+
"additionalEventTypes is deprecated and ignored. Select event types in your WorkOS webhook configuration and add a handler for each in events()."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
74
84
|
const missingEnvVars: string[] = [];
|
|
75
85
|
const clientId = requireEnvVar(
|
|
76
86
|
options?.clientId ?? process.env.WORKOS_CLIENT_ID,
|
|
@@ -257,12 +267,10 @@ export class AuthKit<DataModel extends GenericDataModel> {
|
|
|
257
267
|
console.log("received event", event);
|
|
258
268
|
}
|
|
259
269
|
await ctx.runMutation(this.component.lib.onWebhookEvent, {
|
|
260
|
-
apiKey: this.config.apiKey,
|
|
261
270
|
event: parse(vEvent, event),
|
|
262
271
|
onEventHandle: this.config.authFunctions?.authKitEvent
|
|
263
272
|
? await createFunctionHandle(this.config.authFunctions.authKitEvent)
|
|
264
273
|
: undefined,
|
|
265
|
-
eventTypes: this.config.additionalEventTypes,
|
|
266
274
|
logLevel: this.config.logLevel,
|
|
267
275
|
});
|
|
268
276
|
return new Response("OK", { status: 200 });
|
|
@@ -50,6 +50,5 @@ export const internal: FilterApi<
|
|
|
50
50
|
> = anyApi as any;
|
|
51
51
|
|
|
52
52
|
export const components = componentsGeneric() as unknown as {
|
|
53
|
-
eventWorkpool: import("@convex-dev/workpool/_generated/component.js").ComponentApi<"eventWorkpool">;
|
|
54
53
|
backfillWorkflow: import("@convex-dev/workflow/_generated/component.js").ComponentApi<"backfillWorkflow">;
|
|
55
54
|
};
|