@absolutejs/auth 0.30.0-beta.5 → 0.30.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/dist/index.d.ts +3 -0
- package/dist/index.js +312 -46
- package/dist/index.js.map +8 -5
- package/dist/sso/config.d.ts +38 -0
- package/dist/sso/inMemorySamlServiceProviderStore.d.ts +2 -0
- package/dist/sso/postgresSamlServiceProviderStore.d.ts +119 -0
- package/dist/sso/samlIdpRoutes.d.ts +139 -0
- package/dist/sso/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15143,8 +15143,11 @@ export { createInMemoryWarrantStore, warrantKey } from './fga/inMemoryStores';
|
|
|
15143
15143
|
export { createNeonWarrantStore, createPostgresWarrantStore, warrantsTable } from './fga/postgresStores';
|
|
15144
15144
|
export { ssoDiscoveryRoute } from './sso/discoveryRoute';
|
|
15145
15145
|
export { oidcSsoRoutes } from './sso/oidcRoutes';
|
|
15146
|
+
export { samlIdpRoutes } from './sso/samlIdpRoutes';
|
|
15146
15147
|
export { samlSsoRoutes } from './sso/samlRoutes';
|
|
15148
|
+
export { createInMemorySamlServiceProviderStore } from './sso/inMemorySamlServiceProviderStore';
|
|
15147
15149
|
export { createInMemorySsoConnectionStore } from './sso/inMemorySsoConnectionStore';
|
|
15150
|
+
export { createNeonSamlServiceProviderStore, createPostgresSamlServiceProviderStore, samlServiceProvidersTable } from './sso/postgresSamlServiceProviderStore';
|
|
15148
15151
|
export { createNeonSsoConnectionStore, createPostgresSsoConnectionStore, ssoConnectionsTable } from './sso/postgresSsoConnectionStore';
|
|
15149
15152
|
export * from './webauthn/adapter';
|
|
15150
15153
|
export * from './webauthn/config';
|
package/dist/index.js
CHANGED
|
@@ -2520,7 +2520,7 @@ var createOAuth2Client = async (providerName, config) => {
|
|
|
2520
2520
|
};
|
|
2521
2521
|
|
|
2522
2522
|
// src/index.ts
|
|
2523
|
-
import { Elysia as
|
|
2523
|
+
import { Elysia as Elysia36 } from "elysia";
|
|
2524
2524
|
|
|
2525
2525
|
// src/apikeys/routes.ts
|
|
2526
2526
|
import { Elysia, t } from "elysia";
|
|
@@ -22390,6 +22390,220 @@ var createPostgresWarrantStore = (db) => ({
|
|
|
22390
22390
|
}).onConflictDoNothing({ target: warrantsTable.id });
|
|
22391
22391
|
}
|
|
22392
22392
|
});
|
|
22393
|
+
// src/sso/samlIdpRoutes.ts
|
|
22394
|
+
import { Elysia as Elysia35, t as t31 } from "elysia";
|
|
22395
|
+
var HTTP_BAD_REQUEST3 = 400;
|
|
22396
|
+
var HTTP_UNAUTHORIZED3 = 401;
|
|
22397
|
+
var HTTP_FOUND2 = 302;
|
|
22398
|
+
var HTTP_OK3 = 200;
|
|
22399
|
+
var xmlResponse = (body) => new Response(body, {
|
|
22400
|
+
headers: { "content-type": "application/samlmetadata+xml" },
|
|
22401
|
+
status: HTTP_OK3
|
|
22402
|
+
});
|
|
22403
|
+
var htmlResponse = (body) => new Response(body, {
|
|
22404
|
+
headers: { "content-type": "text/html; charset=utf-8" },
|
|
22405
|
+
status: HTTP_OK3
|
|
22406
|
+
});
|
|
22407
|
+
var redirectTo2 = (url) => new Response(null, { headers: { location: url }, status: HTTP_FOUND2 });
|
|
22408
|
+
var errorJson = (status, error) => new Response(JSON.stringify({ error }), {
|
|
22409
|
+
headers: { "content-type": "application/json" },
|
|
22410
|
+
status
|
|
22411
|
+
});
|
|
22412
|
+
var samlIdpRoutes = ({
|
|
22413
|
+
authSessionStore,
|
|
22414
|
+
getNameId,
|
|
22415
|
+
getSamlAttributes,
|
|
22416
|
+
idpAdapter,
|
|
22417
|
+
idpEntityId,
|
|
22418
|
+
loginUrl,
|
|
22419
|
+
samlServiceProviderStore,
|
|
22420
|
+
ssoRoute = DEFAULT_SSO_ROUTE
|
|
22421
|
+
}) => {
|
|
22422
|
+
const ssoIdpRoute = `${ssoRoute}/saml/idp/sso`;
|
|
22423
|
+
const idpInitiateRoute = `${ssoRoute}/saml/idp/sso/initiate`;
|
|
22424
|
+
const idpMetadataRoute = `${ssoRoute}/saml/idp/metadata`;
|
|
22425
|
+
const ssoUrlFor = (requestUrl) => `${new URL(requestUrl).origin}${ssoIdpRoute}`;
|
|
22426
|
+
const renderResponse = async ({
|
|
22427
|
+
acsUrl,
|
|
22428
|
+
inResponseTo,
|
|
22429
|
+
relayState,
|
|
22430
|
+
serviceProviderEntityId,
|
|
22431
|
+
user
|
|
22432
|
+
}) => {
|
|
22433
|
+
const samlResponse = await idpAdapter.createSamlResponse({
|
|
22434
|
+
acsUrl,
|
|
22435
|
+
attributes: getSamlAttributes?.(user),
|
|
22436
|
+
audience: serviceProviderEntityId,
|
|
22437
|
+
idpEntityId,
|
|
22438
|
+
inResponseTo,
|
|
22439
|
+
nameId: getNameId(user),
|
|
22440
|
+
sessionIndex: crypto.randomUUID()
|
|
22441
|
+
});
|
|
22442
|
+
const html2 = idpAdapter.buildAutoPostForm({
|
|
22443
|
+
acsUrl,
|
|
22444
|
+
relayState,
|
|
22445
|
+
samlResponse
|
|
22446
|
+
});
|
|
22447
|
+
return htmlResponse(html2);
|
|
22448
|
+
};
|
|
22449
|
+
const handleSpInitiated = async ({
|
|
22450
|
+
binding,
|
|
22451
|
+
body,
|
|
22452
|
+
inMemorySession,
|
|
22453
|
+
request,
|
|
22454
|
+
userSessionIdValue
|
|
22455
|
+
}) => {
|
|
22456
|
+
if (body.SAMLRequest === undefined) {
|
|
22457
|
+
return errorJson(HTTP_BAD_REQUEST3, "missing_saml_request");
|
|
22458
|
+
}
|
|
22459
|
+
let firstPass;
|
|
22460
|
+
try {
|
|
22461
|
+
firstPass = await idpAdapter.parseAuthnRequest({
|
|
22462
|
+
binding,
|
|
22463
|
+
samlRequest: body.SAMLRequest
|
|
22464
|
+
});
|
|
22465
|
+
} catch {
|
|
22466
|
+
return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
|
|
22467
|
+
}
|
|
22468
|
+
const serviceProvider = await samlServiceProviderStore.findServiceProvider(firstPass.issuer);
|
|
22469
|
+
if (serviceProvider === undefined) {
|
|
22470
|
+
return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
|
|
22471
|
+
}
|
|
22472
|
+
let parsed;
|
|
22473
|
+
try {
|
|
22474
|
+
parsed = await idpAdapter.parseAuthnRequest({
|
|
22475
|
+
binding,
|
|
22476
|
+
samlRequest: body.SAMLRequest,
|
|
22477
|
+
serviceProvider,
|
|
22478
|
+
signature: body.Signature,
|
|
22479
|
+
signatureAlgorithm: body.SigAlg,
|
|
22480
|
+
signedQueryString: binding === "Redirect" ? new URL(request.url).search.slice(1) : undefined
|
|
22481
|
+
});
|
|
22482
|
+
} catch {
|
|
22483
|
+
return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
|
|
22484
|
+
}
|
|
22485
|
+
const userSession = await loadSessionFromSource({
|
|
22486
|
+
authSessionStore,
|
|
22487
|
+
session: inMemorySession,
|
|
22488
|
+
userSessionId: userSessionIdValue
|
|
22489
|
+
});
|
|
22490
|
+
if (userSession === undefined || parsed.forceAuthn === true) {
|
|
22491
|
+
if (loginUrl === undefined) {
|
|
22492
|
+
return errorJson(HTTP_UNAUTHORIZED3, "login_required");
|
|
22493
|
+
}
|
|
22494
|
+
return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
|
|
22495
|
+
}
|
|
22496
|
+
return renderResponse({
|
|
22497
|
+
acsUrl: parsed.acsUrl ?? serviceProvider.acsUrl,
|
|
22498
|
+
inResponseTo: parsed.id,
|
|
22499
|
+
relayState: parsed.relayState ?? body.RelayState,
|
|
22500
|
+
serviceProviderEntityId: serviceProvider.entityId,
|
|
22501
|
+
user: userSession.user
|
|
22502
|
+
});
|
|
22503
|
+
};
|
|
22504
|
+
return new Elysia35().use(sessionStore()).post(ssoIdpRoute, async ({
|
|
22505
|
+
body,
|
|
22506
|
+
cookie: { user_session_id },
|
|
22507
|
+
request,
|
|
22508
|
+
store
|
|
22509
|
+
}) => handleSpInitiated({
|
|
22510
|
+
binding: "POST",
|
|
22511
|
+
body,
|
|
22512
|
+
inMemorySession: store.session,
|
|
22513
|
+
request,
|
|
22514
|
+
userSessionIdValue: user_session_id.value
|
|
22515
|
+
}), {
|
|
22516
|
+
body: t31.Object({
|
|
22517
|
+
RelayState: t31.Optional(t31.String()),
|
|
22518
|
+
SAMLRequest: t31.Optional(t31.String())
|
|
22519
|
+
}),
|
|
22520
|
+
cookie: t31.Cookie({
|
|
22521
|
+
user_session_id: t31.Optional(userSessionIdTypebox)
|
|
22522
|
+
})
|
|
22523
|
+
}).get(ssoIdpRoute, async ({
|
|
22524
|
+
cookie: { user_session_id },
|
|
22525
|
+
query,
|
|
22526
|
+
request,
|
|
22527
|
+
store
|
|
22528
|
+
}) => handleSpInitiated({
|
|
22529
|
+
binding: "Redirect",
|
|
22530
|
+
body: query,
|
|
22531
|
+
inMemorySession: store.session,
|
|
22532
|
+
request,
|
|
22533
|
+
userSessionIdValue: user_session_id.value
|
|
22534
|
+
}), {
|
|
22535
|
+
cookie: t31.Cookie({
|
|
22536
|
+
user_session_id: t31.Optional(userSessionIdTypebox)
|
|
22537
|
+
}),
|
|
22538
|
+
query: t31.Object({
|
|
22539
|
+
RelayState: t31.Optional(t31.String()),
|
|
22540
|
+
SAMLRequest: t31.Optional(t31.String()),
|
|
22541
|
+
SigAlg: t31.Optional(t31.String()),
|
|
22542
|
+
Signature: t31.Optional(t31.String())
|
|
22543
|
+
})
|
|
22544
|
+
}).get(idpInitiateRoute, async ({
|
|
22545
|
+
cookie: { user_session_id },
|
|
22546
|
+
query: { sp: serviceProviderEntityId, RelayState: relayState },
|
|
22547
|
+
request,
|
|
22548
|
+
store
|
|
22549
|
+
}) => {
|
|
22550
|
+
if (serviceProviderEntityId === undefined) {
|
|
22551
|
+
return errorJson(HTTP_BAD_REQUEST3, "missing_sp");
|
|
22552
|
+
}
|
|
22553
|
+
const serviceProvider = await samlServiceProviderStore.findServiceProvider(serviceProviderEntityId);
|
|
22554
|
+
if (serviceProvider === undefined) {
|
|
22555
|
+
return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
|
|
22556
|
+
}
|
|
22557
|
+
const userSession = authSessionStore === undefined ? await loadSessionFromSource({
|
|
22558
|
+
session: store.session,
|
|
22559
|
+
userSessionId: user_session_id.value
|
|
22560
|
+
}) : await loadSessionFromSource({
|
|
22561
|
+
authSessionStore,
|
|
22562
|
+
session: store.session,
|
|
22563
|
+
userSessionId: user_session_id.value
|
|
22564
|
+
});
|
|
22565
|
+
if (userSession === undefined) {
|
|
22566
|
+
if (loginUrl === undefined) {
|
|
22567
|
+
return errorJson(HTTP_UNAUTHORIZED3, "login_required");
|
|
22568
|
+
}
|
|
22569
|
+
return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
|
|
22570
|
+
}
|
|
22571
|
+
return renderResponse({
|
|
22572
|
+
acsUrl: serviceProvider.acsUrl,
|
|
22573
|
+
relayState,
|
|
22574
|
+
serviceProviderEntityId: serviceProvider.entityId,
|
|
22575
|
+
user: userSession.user
|
|
22576
|
+
});
|
|
22577
|
+
}, {
|
|
22578
|
+
cookie: t31.Cookie({
|
|
22579
|
+
user_session_id: t31.Optional(userSessionIdTypebox)
|
|
22580
|
+
}),
|
|
22581
|
+
query: t31.Object({
|
|
22582
|
+
RelayState: t31.Optional(t31.String()),
|
|
22583
|
+
sp: t31.Optional(t31.String())
|
|
22584
|
+
})
|
|
22585
|
+
}).get(idpMetadataRoute, async ({ request }) => xmlResponse(await idpAdapter.getIdpMetadata({
|
|
22586
|
+
entityId: idpEntityId,
|
|
22587
|
+
ssoUrl: ssoUrlFor(request.url)
|
|
22588
|
+
})));
|
|
22589
|
+
};
|
|
22590
|
+
// src/sso/inMemorySamlServiceProviderStore.ts
|
|
22591
|
+
var createInMemorySamlServiceProviderStore = () => {
|
|
22592
|
+
const providers2 = new Map;
|
|
22593
|
+
return {
|
|
22594
|
+
deleteServiceProvider: async (entityId) => {
|
|
22595
|
+
providers2.delete(entityId);
|
|
22596
|
+
},
|
|
22597
|
+
findServiceProvider: async (entityId) => {
|
|
22598
|
+
const found = providers2.get(entityId);
|
|
22599
|
+
return found ? { ...found } : undefined;
|
|
22600
|
+
},
|
|
22601
|
+
listServiceProviders: async () => Array.from(providers2.values()).map((serviceProvider) => ({ ...serviceProvider })),
|
|
22602
|
+
saveServiceProvider: async (serviceProvider) => {
|
|
22603
|
+
providers2.set(serviceProvider.entityId, { ...serviceProvider });
|
|
22604
|
+
}
|
|
22605
|
+
};
|
|
22606
|
+
};
|
|
22393
22607
|
// src/sso/inMemorySsoConnectionStore.ts
|
|
22394
22608
|
var cloneConnection = (value) => value.type === "oidc" ? {
|
|
22395
22609
|
...value,
|
|
@@ -22415,16 +22629,63 @@ var createInMemorySsoConnectionStore = () => {
|
|
|
22415
22629
|
}
|
|
22416
22630
|
};
|
|
22417
22631
|
};
|
|
22418
|
-
// src/sso/
|
|
22632
|
+
// src/sso/postgresSamlServiceProviderStore.ts
|
|
22419
22633
|
var ID_LENGTH10 = 255;
|
|
22634
|
+
var URL_LENGTH2 = 2048;
|
|
22635
|
+
var samlServiceProvidersTable = pgTable("auth_saml_service_providers", {
|
|
22636
|
+
acs_url: varchar("acs_url", { length: URL_LENGTH2 }).notNull(),
|
|
22637
|
+
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22638
|
+
entity_id: varchar("entity_id", { length: URL_LENGTH2 }).primaryKey(),
|
|
22639
|
+
name_id_format: varchar("name_id_format", { length: ID_LENGTH10 }),
|
|
22640
|
+
signing_cert: text("signing_cert"),
|
|
22641
|
+
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
22642
|
+
});
|
|
22643
|
+
var toServiceProvider = (row) => ({
|
|
22644
|
+
acsUrl: row.acs_url,
|
|
22645
|
+
createdAt: row.created_at_ms,
|
|
22646
|
+
entityId: row.entity_id,
|
|
22647
|
+
nameIdFormat: row.name_id_format ?? undefined,
|
|
22648
|
+
signingCert: row.signing_cert ?? undefined,
|
|
22649
|
+
updatedAt: row.updated_at_ms
|
|
22650
|
+
});
|
|
22651
|
+
var toValues2 = (serviceProvider) => ({
|
|
22652
|
+
acs_url: serviceProvider.acsUrl,
|
|
22653
|
+
created_at_ms: serviceProvider.createdAt,
|
|
22654
|
+
entity_id: serviceProvider.entityId,
|
|
22655
|
+
name_id_format: serviceProvider.nameIdFormat ?? null,
|
|
22656
|
+
signing_cert: serviceProvider.signingCert ?? null,
|
|
22657
|
+
updated_at_ms: serviceProvider.updatedAt
|
|
22658
|
+
});
|
|
22659
|
+
var createNeonSamlServiceProviderStore = (databaseUrl) => createPostgresSamlServiceProviderStore(createNeonDatabase(databaseUrl));
|
|
22660
|
+
var createPostgresSamlServiceProviderStore = (db) => ({
|
|
22661
|
+
deleteServiceProvider: async (entityId) => {
|
|
22662
|
+
await db.delete(samlServiceProvidersTable).where(eq(samlServiceProvidersTable.entity_id, entityId));
|
|
22663
|
+
},
|
|
22664
|
+
findServiceProvider: async (entityId) => {
|
|
22665
|
+
const [row] = await db.select().from(samlServiceProvidersTable).where(eq(samlServiceProvidersTable.entity_id, entityId)).limit(1);
|
|
22666
|
+
return row === undefined ? undefined : toServiceProvider(row);
|
|
22667
|
+
},
|
|
22668
|
+
listServiceProviders: async () => {
|
|
22669
|
+
const rows = await db.select().from(samlServiceProvidersTable);
|
|
22670
|
+
return rows.map(toServiceProvider);
|
|
22671
|
+
},
|
|
22672
|
+
saveServiceProvider: async (serviceProvider) => {
|
|
22673
|
+
await db.insert(samlServiceProvidersTable).values(toValues2(serviceProvider)).onConflictDoUpdate({
|
|
22674
|
+
set: toValues2(serviceProvider),
|
|
22675
|
+
target: samlServiceProvidersTable.entity_id
|
|
22676
|
+
});
|
|
22677
|
+
}
|
|
22678
|
+
});
|
|
22679
|
+
// src/sso/postgresSsoConnectionStore.ts
|
|
22680
|
+
var ID_LENGTH11 = 255;
|
|
22420
22681
|
var TYPE_LENGTH2 = 16;
|
|
22421
22682
|
var ssoConnectionsTable = pgTable("auth_sso_connections", {
|
|
22422
22683
|
config: jsonb("config").$type().notNull(),
|
|
22423
|
-
connection_id: varchar("connection_id", { length:
|
|
22684
|
+
connection_id: varchar("connection_id", { length: ID_LENGTH11 }).primaryKey(),
|
|
22424
22685
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22425
22686
|
enabled: boolean("enabled").notNull().default(true),
|
|
22426
22687
|
organization_id: varchar("organization_id", {
|
|
22427
|
-
length:
|
|
22688
|
+
length: ID_LENGTH11
|
|
22428
22689
|
}).notNull(),
|
|
22429
22690
|
type: varchar("type", { length: TYPE_LENGTH2 }).$type().notNull(),
|
|
22430
22691
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
@@ -22491,7 +22752,7 @@ var toConnection = (row) => {
|
|
|
22491
22752
|
};
|
|
22492
22753
|
return connection;
|
|
22493
22754
|
};
|
|
22494
|
-
var
|
|
22755
|
+
var toValues3 = (connection) => ({
|
|
22495
22756
|
config: connection.config,
|
|
22496
22757
|
connection_id: connection.connectionId,
|
|
22497
22758
|
created_at_ms: connection.createdAt,
|
|
@@ -22521,7 +22782,7 @@ var createPostgresSsoConnectionStore = (db) => ({
|
|
|
22521
22782
|
});
|
|
22522
22783
|
},
|
|
22523
22784
|
saveConnection: async (connection) => {
|
|
22524
|
-
const values =
|
|
22785
|
+
const values = toValues3(connection);
|
|
22525
22786
|
await db.insert(ssoConnectionsTable).values(values).onConflictDoUpdate({
|
|
22526
22787
|
set: values,
|
|
22527
22788
|
target: ssoConnectionsTable.connection_id
|
|
@@ -22550,18 +22811,18 @@ var createInMemoryWebAuthnCredentialStore = () => {
|
|
|
22550
22811
|
};
|
|
22551
22812
|
};
|
|
22552
22813
|
// src/webauthn/postgresWebAuthnCredentialStore.ts
|
|
22553
|
-
var
|
|
22814
|
+
var ID_LENGTH12 = 255;
|
|
22554
22815
|
var DEVICE_TYPE_LENGTH = 32;
|
|
22555
22816
|
var webauthnCredentialsTable = pgTable("auth_webauthn_credentials", {
|
|
22556
22817
|
backed_up: boolean("backed_up"),
|
|
22557
22818
|
counter: bigint("counter", { mode: "number" }).notNull().default(0),
|
|
22558
22819
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22559
|
-
credential_id: varchar("credential_id", { length:
|
|
22820
|
+
credential_id: varchar("credential_id", { length: ID_LENGTH12 }).primaryKey(),
|
|
22560
22821
|
device_type: varchar("device_type", { length: DEVICE_TYPE_LENGTH }),
|
|
22561
22822
|
last_used_at_ms: bigint("last_used_at_ms", { mode: "number" }),
|
|
22562
22823
|
public_key: text("public_key").notNull(),
|
|
22563
22824
|
transports: jsonb("transports").$type(),
|
|
22564
|
-
user_id: varchar("user_id", { length:
|
|
22825
|
+
user_id: varchar("user_id", { length: ID_LENGTH12 }).notNull()
|
|
22565
22826
|
});
|
|
22566
22827
|
var toCredential = (row) => ({
|
|
22567
22828
|
backedUp: row.backed_up ?? undefined,
|
|
@@ -22574,7 +22835,7 @@ var toCredential = (row) => ({
|
|
|
22574
22835
|
transports: row.transports ?? undefined,
|
|
22575
22836
|
userId: row.user_id
|
|
22576
22837
|
});
|
|
22577
|
-
var
|
|
22838
|
+
var toValues4 = (credential) => ({
|
|
22578
22839
|
backed_up: credential.backedUp ?? null,
|
|
22579
22840
|
counter: credential.counter,
|
|
22580
22841
|
created_at_ms: credential.createdAt,
|
|
@@ -22599,7 +22860,7 @@ var createPostgresWebAuthnCredentialStore = (db) => ({
|
|
|
22599
22860
|
await db.delete(webauthnCredentialsTable).where(eq(webauthnCredentialsTable.credential_id, credentialId));
|
|
22600
22861
|
},
|
|
22601
22862
|
saveCredential: async (credential) => {
|
|
22602
|
-
const values =
|
|
22863
|
+
const values = toValues4(credential);
|
|
22603
22864
|
await db.insert(webauthnCredentialsTable).values(values).onConflictDoUpdate({
|
|
22604
22865
|
set: values,
|
|
22605
22866
|
target: webauthnCredentialsTable.credential_id
|
|
@@ -22654,41 +22915,41 @@ var createInMemoryOrganizationStore = () => {
|
|
|
22654
22915
|
};
|
|
22655
22916
|
};
|
|
22656
22917
|
// src/organizations/postgresOrganizationStore.ts
|
|
22657
|
-
var
|
|
22918
|
+
var ID_LENGTH13 = 255;
|
|
22658
22919
|
var NAME_LENGTH = 255;
|
|
22659
22920
|
var STATE_LENGTH = 16;
|
|
22660
22921
|
var organizationInvitationsTable = pgTable("auth_organization_invitations", {
|
|
22661
22922
|
accepted_at_ms: bigint("accepted_at_ms", { mode: "number" }),
|
|
22662
22923
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22663
|
-
email: varchar("email", { length:
|
|
22924
|
+
email: varchar("email", { length: ID_LENGTH13 }).notNull(),
|
|
22664
22925
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
22665
22926
|
invitation_id: varchar("invitation_id", {
|
|
22666
|
-
length:
|
|
22927
|
+
length: ID_LENGTH13
|
|
22667
22928
|
}).primaryKey(),
|
|
22668
|
-
inviter_user_id: varchar("inviter_user_id", { length:
|
|
22929
|
+
inviter_user_id: varchar("inviter_user_id", { length: ID_LENGTH13 }),
|
|
22669
22930
|
organization_id: varchar("organization_id", {
|
|
22670
|
-
length:
|
|
22931
|
+
length: ID_LENGTH13
|
|
22671
22932
|
}).notNull(),
|
|
22672
22933
|
roles: jsonb("roles").$type().notNull().default([]),
|
|
22673
22934
|
state: varchar("state", { length: STATE_LENGTH }).$type().notNull().default("pending"),
|
|
22674
|
-
token_hash: varchar("token_hash", { length:
|
|
22935
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH13 }).notNull().unique()
|
|
22675
22936
|
});
|
|
22676
22937
|
var organizationMembershipsTable = pgTable("auth_organization_memberships", {
|
|
22677
22938
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22678
22939
|
organization_id: varchar("organization_id", {
|
|
22679
|
-
length:
|
|
22940
|
+
length: ID_LENGTH13
|
|
22680
22941
|
}).notNull(),
|
|
22681
22942
|
roles: jsonb("roles").$type().notNull().default([]),
|
|
22682
22943
|
status: varchar("status", { length: STATE_LENGTH }).$type().notNull().default("active"),
|
|
22683
22944
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
|
|
22684
|
-
user_id: varchar("user_id", { length:
|
|
22945
|
+
user_id: varchar("user_id", { length: ID_LENGTH13 }).notNull()
|
|
22685
22946
|
}, (table) => [primaryKey({ columns: [table.organization_id, table.user_id] })]);
|
|
22686
22947
|
var organizationsTable = pgTable("auth_organizations", {
|
|
22687
22948
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22688
22949
|
metadata: jsonb("metadata").$type(),
|
|
22689
22950
|
name: varchar("name", { length: NAME_LENGTH }).notNull(),
|
|
22690
22951
|
organization_id: varchar("organization_id", {
|
|
22691
|
-
length:
|
|
22952
|
+
length: ID_LENGTH13
|
|
22692
22953
|
}).primaryKey(),
|
|
22693
22954
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
22694
22955
|
});
|
|
@@ -22862,12 +23123,12 @@ var createInMemoryRoleStore = () => {
|
|
|
22862
23123
|
};
|
|
22863
23124
|
};
|
|
22864
23125
|
// src/roles/postgresRoleStore.ts
|
|
22865
|
-
var
|
|
23126
|
+
var ID_LENGTH14 = 255;
|
|
22866
23127
|
var SLUG_LENGTH = 128;
|
|
22867
23128
|
var GLOBAL_SCOPE = "";
|
|
22868
23129
|
var rolesTable = pgTable("auth_roles", {
|
|
22869
23130
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22870
|
-
organization_id: varchar("organization_id", { length:
|
|
23131
|
+
organization_id: varchar("organization_id", { length: ID_LENGTH14 }).notNull().default(GLOBAL_SCOPE),
|
|
22871
23132
|
permissions: jsonb("permissions").$type().notNull().default([]),
|
|
22872
23133
|
slug: varchar("slug", { length: SLUG_LENGTH }).notNull(),
|
|
22873
23134
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
@@ -22922,11 +23183,11 @@ var createInMemoryPasswordlessTokenStore = () => {
|
|
|
22922
23183
|
};
|
|
22923
23184
|
};
|
|
22924
23185
|
// src/passwordless/postgresPasswordlessTokenStore.ts
|
|
22925
|
-
var
|
|
23186
|
+
var ID_LENGTH15 = 255;
|
|
22926
23187
|
var passwordlessTokensTable = pgTable("auth_passwordless_tokens", {
|
|
22927
|
-
email: varchar("email", { length:
|
|
23188
|
+
email: varchar("email", { length: ID_LENGTH15 }).notNull(),
|
|
22928
23189
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
22929
|
-
token_hash: varchar("token_hash", { length:
|
|
23190
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH15 }).primaryKey()
|
|
22930
23191
|
});
|
|
22931
23192
|
var toToken3 = (row) => ({
|
|
22932
23193
|
email: row.email,
|
|
@@ -22966,14 +23227,14 @@ var createInMemoryWebhookDeliveryStore = () => {
|
|
|
22966
23227
|
};
|
|
22967
23228
|
};
|
|
22968
23229
|
// src/webhooks/postgresStore.ts
|
|
22969
|
-
var
|
|
22970
|
-
var
|
|
23230
|
+
var ID_LENGTH16 = 255;
|
|
23231
|
+
var URL_LENGTH3 = 2048;
|
|
22971
23232
|
var DEFAULT_LIST_LIMIT4 = 100;
|
|
22972
23233
|
var webhookDeliveriesTable = pgTable("auth_webhook_deliveries", {
|
|
22973
23234
|
attempts: bigint("attempts", { mode: "number" }).notNull(),
|
|
22974
23235
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
22975
|
-
endpoint_url: varchar("endpoint_url", { length:
|
|
22976
|
-
envelope_id: varchar("envelope_id", { length:
|
|
23236
|
+
endpoint_url: varchar("endpoint_url", { length: URL_LENGTH3 }).notNull(),
|
|
23237
|
+
envelope_id: varchar("envelope_id", { length: ID_LENGTH16 }).primaryKey(),
|
|
22977
23238
|
envelope_json: jsonb("envelope_json").$type().notNull(),
|
|
22978
23239
|
last_error: text("last_error"),
|
|
22979
23240
|
last_status: bigint("last_status", { mode: "number" })
|
|
@@ -23028,19 +23289,19 @@ var createInMemorySetupSessionStore = () => {
|
|
|
23028
23289
|
};
|
|
23029
23290
|
};
|
|
23030
23291
|
// src/portal/postgresSetupSessionStore.ts
|
|
23031
|
-
var
|
|
23292
|
+
var ID_LENGTH17 = 255;
|
|
23032
23293
|
var setupSessionsTable = pgTable("auth_setup_sessions", {
|
|
23033
23294
|
capabilities: jsonb("capabilities").$type().notNull().default([]),
|
|
23034
23295
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
23035
|
-
created_by: varchar("created_by", { length:
|
|
23296
|
+
created_by: varchar("created_by", { length: ID_LENGTH17 }),
|
|
23036
23297
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
23037
23298
|
organization_id: varchar("organization_id", {
|
|
23038
|
-
length:
|
|
23299
|
+
length: ID_LENGTH17
|
|
23039
23300
|
}).notNull(),
|
|
23040
23301
|
setup_session_id: varchar("setup_session_id", {
|
|
23041
|
-
length:
|
|
23302
|
+
length: ID_LENGTH17
|
|
23042
23303
|
}).primaryKey(),
|
|
23043
|
-
token_hash: varchar("token_hash", { length:
|
|
23304
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH17 }).notNull().unique()
|
|
23044
23305
|
});
|
|
23045
23306
|
var toSession = (row) => ({
|
|
23046
23307
|
capabilities: row.capabilities,
|
|
@@ -23146,7 +23407,7 @@ var auth = async ({
|
|
|
23146
23407
|
const auditedOnCallbackSuccess = auditEmit ? composeCallbackAudit(onCallbackSuccess, auditEmit) : onCallbackSuccess;
|
|
23147
23408
|
const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
|
|
23148
23409
|
const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
|
|
23149
|
-
return new
|
|
23410
|
+
return new Elysia36().use(sessionCleanup({
|
|
23150
23411
|
authSessionStore,
|
|
23151
23412
|
cleanupIntervalMs,
|
|
23152
23413
|
maxSessions,
|
|
@@ -23192,42 +23453,42 @@ var auth = async ({
|
|
|
23192
23453
|
...auditedCredentials,
|
|
23193
23454
|
authSessionStore,
|
|
23194
23455
|
lockoutGuard
|
|
23195
|
-
}) : new
|
|
23456
|
+
}) : new Elysia36).use(auditedMfa ? mfaRoutes({ ...auditedMfa, authSessionStore }) : new Elysia36).use(passwordless ? passwordlessRoutes({
|
|
23196
23457
|
...passwordless,
|
|
23197
23458
|
authSessionStore,
|
|
23198
23459
|
emit: auditEmit
|
|
23199
|
-
}) : new
|
|
23460
|
+
}) : new Elysia36).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia36).use(sso ? oidcSsoRoutes({ ...sso, authSessionStore }) : new Elysia36).use(sso && sso.samlAdapter ? samlSsoRoutes({
|
|
23200
23461
|
...sso,
|
|
23201
23462
|
authSessionStore,
|
|
23202
23463
|
samlAdapter: sso.samlAdapter
|
|
23203
|
-
}) : new
|
|
23464
|
+
}) : new Elysia36).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
|
|
23204
23465
|
getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
|
|
23205
23466
|
ssoConnectionStore: sso.ssoConnectionStore,
|
|
23206
23467
|
ssoRoute: sso.ssoRoute
|
|
23207
|
-
}) : new
|
|
23468
|
+
}) : new Elysia36).use(scim ? scimRoutes(scim) : new Elysia36).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia36).use(oidc ? oidcProviderRoutes({ ...oidc, authSessionStore }) : new Elysia36).use(organizations ? organizationRoutes({
|
|
23208
23469
|
...organizations,
|
|
23209
23470
|
authSessionStore,
|
|
23210
23471
|
emit: auditEmit
|
|
23211
|
-
}) : new
|
|
23472
|
+
}) : new Elysia36).use(roles ? roleRoutes({
|
|
23212
23473
|
...roles,
|
|
23213
23474
|
authSessionStore,
|
|
23214
23475
|
emit: auditEmit
|
|
23215
|
-
}) : new
|
|
23476
|
+
}) : new Elysia36).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia36).use(webauthn ? webauthnRoutes({
|
|
23216
23477
|
...webauthn,
|
|
23217
23478
|
authSessionStore,
|
|
23218
23479
|
emit: auditEmit
|
|
23219
|
-
}) : new
|
|
23480
|
+
}) : new Elysia36).use(compliance ? complianceRoutes({
|
|
23220
23481
|
...compliance,
|
|
23221
23482
|
authSessionStore,
|
|
23222
23483
|
emit: auditEmit
|
|
23223
|
-
}) : new
|
|
23484
|
+
}) : new Elysia36).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
|
|
23224
23485
|
...authorization,
|
|
23225
23486
|
authSessionStore,
|
|
23226
23487
|
emit: auditEmit
|
|
23227
|
-
}) : new
|
|
23488
|
+
}) : new Elysia36).use(htmx ? createAuthHtmxRoutes({
|
|
23228
23489
|
...htmx,
|
|
23229
23490
|
authSessionStore
|
|
23230
|
-
}) : new
|
|
23491
|
+
}) : new Elysia36);
|
|
23231
23492
|
};
|
|
23232
23493
|
export {
|
|
23233
23494
|
writeWarrant,
|
|
@@ -23279,6 +23540,8 @@ export {
|
|
|
23279
23540
|
scimTokensTable,
|
|
23280
23541
|
scimRoutes,
|
|
23281
23542
|
samlSsoRoutes,
|
|
23543
|
+
samlServiceProvidersTable,
|
|
23544
|
+
samlIdpRoutes,
|
|
23282
23545
|
rotateVaultKey,
|
|
23283
23546
|
rotateMfaEncryptionKey,
|
|
23284
23547
|
rolesTable,
|
|
@@ -23434,6 +23697,7 @@ export {
|
|
|
23434
23697
|
createPostgresSsoConnectionStore,
|
|
23435
23698
|
createPostgresSetupSessionStore,
|
|
23436
23699
|
createPostgresScimTokenStore,
|
|
23700
|
+
createPostgresSamlServiceProviderStore,
|
|
23437
23701
|
createPostgresRoleStore,
|
|
23438
23702
|
createPostgresPushedAuthorizationRequestStore,
|
|
23439
23703
|
createPostgresPasswordlessTokenStore,
|
|
@@ -23464,6 +23728,7 @@ export {
|
|
|
23464
23728
|
createNeonSsoConnectionStore,
|
|
23465
23729
|
createNeonSetupSessionStore,
|
|
23466
23730
|
createNeonScimTokenStore,
|
|
23731
|
+
createNeonSamlServiceProviderStore,
|
|
23467
23732
|
createNeonRoleStore,
|
|
23468
23733
|
createNeonPushedAuthorizationRequestStore,
|
|
23469
23734
|
createNeonPasswordlessTokenStore,
|
|
@@ -23500,6 +23765,7 @@ export {
|
|
|
23500
23765
|
createInMemorySsoConnectionStore,
|
|
23501
23766
|
createInMemorySetupSessionStore,
|
|
23502
23767
|
createInMemoryScimTokenStore,
|
|
23768
|
+
createInMemorySamlServiceProviderStore,
|
|
23503
23769
|
createInMemoryRoleStore,
|
|
23504
23770
|
createInMemoryPushedAuthorizationRequestStore,
|
|
23505
23771
|
createInMemoryPasswordlessTokenStore,
|
|
@@ -23590,5 +23856,5 @@ export {
|
|
|
23590
23856
|
AuthIdentityConflictError
|
|
23591
23857
|
};
|
|
23592
23858
|
|
|
23593
|
-
//# debugId=
|
|
23859
|
+
//# debugId=B31AA1D09BAE440964756E2164756E21
|
|
23594
23860
|
//# sourceMappingURL=index.js.map
|