@absolutejs/auth 0.84.0 → 0.86.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/CHANGELOG.md +18 -0
- package/changelog.json +47 -0
- package/dist/bun.js +48 -1
- package/dist/bun.js.map +4 -4
- package/dist/cli/migrate.js +32 -6
- package/dist/cli/migrate.js.map +4 -4
- package/dist/cli/setup.d.ts +1 -1
- package/dist/htmx/index.js +27 -1
- package/dist/htmx/index.js.map +3 -3
- package/dist/index.js +83 -22
- package/dist/index.js.map +8 -8
- package/dist/linkedProviders/index.js +27 -1
- package/dist/linkedProviders/index.js.map +3 -3
- package/dist/organizations/config.d.ts +2 -0
- package/dist/organizations/operations.d.ts +6 -4
- package/dist/organizations/routes.d.ts +1 -1
- package/dist/organizations/types.d.ts +8 -0
- package/dist/providers/clients.d.ts +28 -3
- package/dist/providers/index.js +28 -28
- package/dist/providers/index.js.map +4 -4
- package/dist/providers/neon.d.ts +27 -27
- package/dist/server.js +83 -22
- package/dist/server.js.map +8 -8
- package/docs/neon.md +12 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1397,6 +1397,32 @@ var providers = defineProviders({
|
|
|
1397
1397
|
url: "https://nid.naver.com/oauth2.0/token"
|
|
1398
1398
|
}
|
|
1399
1399
|
},
|
|
1400
|
+
neon: {
|
|
1401
|
+
authorizationUrl: "https://oauth2.neon.tech/oauth2/auth",
|
|
1402
|
+
isOIDC: true,
|
|
1403
|
+
isRefreshable: true,
|
|
1404
|
+
PKCEMethod: "S256",
|
|
1405
|
+
profileRequest: {
|
|
1406
|
+
authIn: "header",
|
|
1407
|
+
encoding: "application/json",
|
|
1408
|
+
method: "GET",
|
|
1409
|
+
url: "https://oauth2.neon.tech/userinfo"
|
|
1410
|
+
},
|
|
1411
|
+
revocationRequest: {
|
|
1412
|
+
authIn: "body",
|
|
1413
|
+
encoding: "application/x-www-form-urlencoded",
|
|
1414
|
+
tokenParamName: "token",
|
|
1415
|
+
url: "https://oauth2.neon.tech/oauth2/revoke"
|
|
1416
|
+
},
|
|
1417
|
+
scopeRequired: true,
|
|
1418
|
+
subject: ["sub"],
|
|
1419
|
+
subjectType: "string",
|
|
1420
|
+
tokenRequest: {
|
|
1421
|
+
authIn: "body",
|
|
1422
|
+
encoding: "application/x-www-form-urlencoded",
|
|
1423
|
+
url: "https://oauth2.neon.tech/oauth2/token"
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1400
1426
|
notion: {
|
|
1401
1427
|
authorizationUrl: "https://api.notion.com/v1/oauth/authorize",
|
|
1402
1428
|
email: ["bot", "owner", "user", "person", "email"],
|
|
@@ -10217,29 +10243,17 @@ init_crypto();
|
|
|
10217
10243
|
var acceptInvitation = async ({
|
|
10218
10244
|
organizationStore,
|
|
10219
10245
|
token,
|
|
10220
|
-
userId
|
|
10246
|
+
userId,
|
|
10247
|
+
verifiedEmail
|
|
10221
10248
|
}) => {
|
|
10222
|
-
|
|
10223
|
-
if (!invitation || invitation.state !== "pending")
|
|
10249
|
+
if (!verifiedEmail?.trim() || !organizationStore.acceptInvitation)
|
|
10224
10250
|
return;
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
acceptedAt: now,
|
|
10231
|
-
state: "accepted"
|
|
10251
|
+
return organizationStore.acceptInvitation({
|
|
10252
|
+
now: Date.now(),
|
|
10253
|
+
tokenHash: await hashToken(token),
|
|
10254
|
+
userId,
|
|
10255
|
+
verifiedEmail: verifiedEmail.trim().toLowerCase()
|
|
10232
10256
|
});
|
|
10233
|
-
const membership = {
|
|
10234
|
-
createdAt: now,
|
|
10235
|
-
organizationId: invitation.organizationId,
|
|
10236
|
-
roles: invitation.roles,
|
|
10237
|
-
status: "active",
|
|
10238
|
-
updatedAt: now,
|
|
10239
|
-
userId
|
|
10240
|
-
};
|
|
10241
|
-
await organizationStore.saveMembership(membership);
|
|
10242
|
-
return membership;
|
|
10243
10257
|
};
|
|
10244
10258
|
var createOrganization = async ({
|
|
10245
10259
|
metadata,
|
|
@@ -10310,6 +10324,7 @@ var organizationRoutes = ({
|
|
|
10310
10324
|
canManageMembers,
|
|
10311
10325
|
emit,
|
|
10312
10326
|
getUserId,
|
|
10327
|
+
getVerifiedEmail,
|
|
10313
10328
|
invitationDurationMs,
|
|
10314
10329
|
onMembershipAdded,
|
|
10315
10330
|
onMembershipRemoved,
|
|
@@ -10498,7 +10513,8 @@ var organizationRoutes = ({
|
|
|
10498
10513
|
const membership = await acceptInvitation({
|
|
10499
10514
|
organizationStore,
|
|
10500
10515
|
token,
|
|
10501
|
-
userId: getUserId(user)
|
|
10516
|
+
userId: getUserId(user),
|
|
10517
|
+
verifiedEmail: await getVerifiedEmail?.(user)
|
|
10502
10518
|
});
|
|
10503
10519
|
if (!membership) {
|
|
10504
10520
|
return status("Bad Request", "Invalid or expired invitation");
|
|
@@ -39395,6 +39411,27 @@ var toInvitation = (row) => ({
|
|
|
39395
39411
|
});
|
|
39396
39412
|
var createNeonOrganizationStore = (databaseUrl) => createPostgresOrganizationStore(createNeonDatabase(databaseUrl));
|
|
39397
39413
|
var createPostgresOrganizationStore = (db) => ({
|
|
39414
|
+
acceptInvitation: async ({ now, tokenHash, userId, verifiedEmail }) => {
|
|
39415
|
+
const claimed = db.$with("claimed").as(db.update(organizationInvitationsTable).set({ accepted_at_ms: now, state: "accepted" }).where(and(eq(organizationInvitationsTable.token_hash, tokenHash), eq(organizationInvitationsTable.state, "pending"), gt(organizationInvitationsTable.expires_at_ms, now), sql`lower(trim(${organizationInvitationsTable.email})) = ${verifiedEmail}`, exists(db.select().from(organizationsTable).where(eq(organizationsTable.organization_id, organizationInvitationsTable.organization_id))), notExists(db.select().from(organizationMembershipsTable).where(and(eq(organizationMembershipsTable.organization_id, organizationInvitationsTable.organization_id), eq(organizationMembershipsTable.user_id, userId), eq(organizationMembershipsTable.status, "suspended")))))).returning({
|
|
39416
|
+
organizationId: organizationInvitationsTable.organization_id,
|
|
39417
|
+
roles: organizationInvitationsTable.roles
|
|
39418
|
+
}));
|
|
39419
|
+
const [row] = await db.with(claimed).insert(organizationMembershipsTable).select(db.select({
|
|
39420
|
+
created_at_ms: sql`${now}`.as("created_at_ms"),
|
|
39421
|
+
organization_id: claimed.organizationId,
|
|
39422
|
+
roles: claimed.roles,
|
|
39423
|
+
status: sql`'active'`.as("status"),
|
|
39424
|
+
updated_at_ms: sql`${now}`.as("updated_at_ms"),
|
|
39425
|
+
user_id: sql`${userId}`.as("user_id")
|
|
39426
|
+
}).from(claimed)).onConflictDoUpdate({
|
|
39427
|
+
set: { user_id: userId },
|
|
39428
|
+
target: [
|
|
39429
|
+
organizationMembershipsTable.organization_id,
|
|
39430
|
+
organizationMembershipsTable.user_id
|
|
39431
|
+
]
|
|
39432
|
+
}).returning();
|
|
39433
|
+
return row && row.status === "active" ? toMembership(row) : undefined;
|
|
39434
|
+
},
|
|
39398
39435
|
deleteOrganization: async (organizationId) => {
|
|
39399
39436
|
await db.delete(organizationsTable).where(eq(organizationsTable.organization_id, organizationId));
|
|
39400
39437
|
},
|
|
@@ -40445,6 +40482,30 @@ var createInMemoryOrganizationStore = () => {
|
|
|
40445
40482
|
const memberships = new Map;
|
|
40446
40483
|
const invitations = new Map;
|
|
40447
40484
|
return {
|
|
40485
|
+
acceptInvitation: async ({ tokenHash, userId, verifiedEmail, now }) => {
|
|
40486
|
+
const invitation = [...invitations.values()].find((value) => value.tokenHash === tokenHash);
|
|
40487
|
+
if (!invitation || invitation.state !== "pending" || invitation.expiresAt <= now || invitation.email.trim().toLowerCase() !== verifiedEmail || !organizations.has(invitation.organizationId))
|
|
40488
|
+
return;
|
|
40489
|
+
const key = membershipKey(invitation.organizationId, userId);
|
|
40490
|
+
const existing = memberships.get(key);
|
|
40491
|
+
if (existing?.status === "suspended")
|
|
40492
|
+
return;
|
|
40493
|
+
const membership = existing ?? {
|
|
40494
|
+
createdAt: now,
|
|
40495
|
+
organizationId: invitation.organizationId,
|
|
40496
|
+
roles: [...invitation.roles],
|
|
40497
|
+
status: "active",
|
|
40498
|
+
updatedAt: now,
|
|
40499
|
+
userId
|
|
40500
|
+
};
|
|
40501
|
+
invitations.set(invitation.invitationId, {
|
|
40502
|
+
...invitation,
|
|
40503
|
+
acceptedAt: now,
|
|
40504
|
+
state: "accepted"
|
|
40505
|
+
});
|
|
40506
|
+
memberships.set(key, membership);
|
|
40507
|
+
return cloneMembership(membership);
|
|
40508
|
+
},
|
|
40448
40509
|
deleteOrganization: async (organizationId) => {
|
|
40449
40510
|
organizations.delete(organizationId);
|
|
40450
40511
|
},
|
|
@@ -41547,5 +41608,5 @@ export {
|
|
|
41547
41608
|
writeWarrant
|
|
41548
41609
|
};
|
|
41549
41610
|
|
|
41550
|
-
//# debugId=
|
|
41611
|
+
//# debugId=466F05C3ADFAC39864756E2164756E21
|
|
41551
41612
|
//# sourceMappingURL=index.js.map
|