@absolutejs/auth 0.57.7 → 0.57.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/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +66 -35
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/postgresStores.d.ts +586 -1
- package/dist/cli/migrate.js +152 -68
- package/dist/cli/migrate.js.map +6 -6
- package/dist/htmx/index.js +269 -111
- package/dist/htmx/index.js.map +3 -3
- package/dist/index.d.ts +6 -5
- package/dist/index.js +405 -168
- package/dist/index.js.map +12 -12
- package/dist/linkedProviders/index.js +269 -111
- package/dist/linkedProviders/index.js.map +3 -3
- package/dist/providers/clients.d.ts +30 -17
- package/dist/providers/index.js +269 -111
- package/dist/providers/index.js.map +3 -3
- package/dist/routes/profile.d.ts +6 -3
- package/dist/routes/refresh.d.ts +1 -1
- package/dist/routes/revoke.d.ts +1 -1
- package/dist/server.js +399 -168
- package/dist/server.js.map +12 -12
- package/dist/session/neonStore.d.ts +60 -0
- package/dist/types.d.ts +6 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +2 -2
package/dist/agents/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { agentHasScopes, resolveAgentPrincipal } from './principal';
|
|
|
10
10
|
export { agentAuthChallenge, agentAuthContextPlugin } from './context';
|
|
11
11
|
export { agentAuthPlugin } from './routes';
|
|
12
12
|
export { createInMemoryAgentDelegationStore, createInMemoryAgentIdentityRegistrationStore, createInMemoryAgentRegistrationStore } from './inMemoryStores';
|
|
13
|
-
export { agentDelegationsTable, agentIdentityRegistrationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentIdentityRegistrationStore, createNeonAgentRegistrationStore, createDrizzleAgentDelegationStore, createPostgresAgentDelegationStore, createPostgresAgentIdentityRegistrationStore, createPostgresAgentRegistrationStore } from './postgresStores';
|
|
13
|
+
export { agentDelegationsTable, agentDelegationsBunSqlTable, agentIdentityRegistrationsTable, agentIdentityRegistrationsBunSqlTable, agentRegistrationsTable, agentRegistrationsBunSqlTable, createBunSqlDrizzleAgentDelegationStore, createBunSqlDrizzleAgentIdentityRegistrationStore, createBunSqlDrizzleAgentRegistrationStore, createNeonAgentDelegationStore, createNeonAgentIdentityRegistrationStore, createNeonAgentRegistrationStore, createDrizzleAgentDelegationStore, createPostgresAgentDelegationStore, createPostgresAgentIdentityRegistrationStore, createPostgresAgentRegistrationStore } from './postgresStores';
|
package/dist/agents/index.js
CHANGED
|
@@ -13457,23 +13457,28 @@ var portableJsonb = customType({
|
|
|
13457
13457
|
fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
|
|
13458
13458
|
toDriver: (value) => JSON.stringify(value)
|
|
13459
13459
|
});
|
|
13460
|
-
var
|
|
13460
|
+
var bunSqlJsonb = customType({
|
|
13461
|
+
dataType: () => "jsonb",
|
|
13462
|
+
fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
|
|
13463
|
+
toDriver: (value) => value
|
|
13464
|
+
});
|
|
13465
|
+
var createAgentDelegationsTable = (json5) => pgTable("auth_agent_delegations", {
|
|
13461
13466
|
agent_id: varchar("agent_id", { length: ID_LENGTH }).notNull(),
|
|
13462
|
-
authorization_details:
|
|
13467
|
+
authorization_details: json5("authorization_details").$type(),
|
|
13463
13468
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
13464
13469
|
delegation_id: varchar("delegation_id", {
|
|
13465
13470
|
length: ID_LENGTH
|
|
13466
13471
|
}).primaryKey(),
|
|
13467
13472
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }),
|
|
13468
13473
|
organization_id: varchar("organization_id", { length: ID_LENGTH }),
|
|
13469
|
-
scopes:
|
|
13474
|
+
scopes: json5("scopes").$type().notNull().default([]),
|
|
13470
13475
|
status: varchar("status", { length: STATUS_LENGTH }).$type().notNull(),
|
|
13471
13476
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
|
|
13472
13477
|
user_id: varchar("user_id", { length: ID_LENGTH }).notNull()
|
|
13473
13478
|
});
|
|
13474
|
-
var
|
|
13479
|
+
var createAgentIdentityRegistrationsTable = (json5) => pgTable("auth_agent_identity_registrations", {
|
|
13475
13480
|
agent_id: varchar("agent_id", { length: ID_LENGTH }).notNull().unique(),
|
|
13476
|
-
claim_attempt:
|
|
13481
|
+
claim_attempt: json5("claim_attempt").$type(),
|
|
13477
13482
|
claim_attempt_token_hash: varchar("claim_attempt_token_hash", {
|
|
13478
13483
|
length: ID_LENGTH
|
|
13479
13484
|
}).unique(),
|
|
@@ -13483,8 +13488,12 @@ var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations
|
|
|
13483
13488
|
claim_token_hash: varchar("claim_token_hash", {
|
|
13484
13489
|
length: ID_LENGTH
|
|
13485
13490
|
}).notNull().unique(),
|
|
13486
|
-
created_at_ms: bigint("created_at_ms", {
|
|
13487
|
-
|
|
13491
|
+
created_at_ms: bigint("created_at_ms", {
|
|
13492
|
+
mode: "number"
|
|
13493
|
+
}).notNull(),
|
|
13494
|
+
expires_at_ms: bigint("expires_at_ms", {
|
|
13495
|
+
mode: "number"
|
|
13496
|
+
}).notNull(),
|
|
13488
13497
|
kind: varchar("kind", { length: 32 }).$type().notNull(),
|
|
13489
13498
|
last_polled_at_ms: bigint("last_polled_at_ms", { mode: "number" }),
|
|
13490
13499
|
login_hint: varchar("login_hint", { length: ID_LENGTH }),
|
|
@@ -13492,27 +13501,37 @@ var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations
|
|
|
13492
13501
|
length: ID_LENGTH
|
|
13493
13502
|
}).primaryKey(),
|
|
13494
13503
|
status: varchar("status", { length: STATUS_LENGTH }).$type().notNull(),
|
|
13495
|
-
updated_at_ms: bigint("updated_at_ms", {
|
|
13504
|
+
updated_at_ms: bigint("updated_at_ms", {
|
|
13505
|
+
mode: "number"
|
|
13506
|
+
}).notNull(),
|
|
13496
13507
|
upstream_client_id: varchar("upstream_client_id", {
|
|
13497
13508
|
length: ID_LENGTH
|
|
13498
13509
|
}),
|
|
13499
13510
|
upstream_issuer: varchar("upstream_issuer", { length: ID_LENGTH }),
|
|
13500
|
-
upstream_subject: varchar("upstream_subject", {
|
|
13511
|
+
upstream_subject: varchar("upstream_subject", {
|
|
13512
|
+
length: ID_LENGTH
|
|
13513
|
+
}),
|
|
13501
13514
|
user_id: varchar("user_id", { length: ID_LENGTH }),
|
|
13502
13515
|
version: integer("version").notNull()
|
|
13503
13516
|
}, (table) => [
|
|
13504
13517
|
uniqueIndex("auth_agent_identity_upstream_unique").on(table.upstream_issuer, table.upstream_subject, table.upstream_client_id)
|
|
13505
13518
|
]);
|
|
13506
|
-
var
|
|
13519
|
+
var createAgentRegistrationsTable = (json5) => pgTable("auth_agent_registrations", {
|
|
13507
13520
|
agent_id: varchar("agent_id", { length: ID_LENGTH }).primaryKey(),
|
|
13508
|
-
allowed_scopes:
|
|
13521
|
+
allowed_scopes: json5("allowed_scopes").$type().notNull().default([]),
|
|
13509
13522
|
client_id: varchar("client_id", { length: ID_LENGTH }).unique(),
|
|
13510
13523
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
13511
|
-
metadata:
|
|
13524
|
+
metadata: json5("metadata").$type(),
|
|
13512
13525
|
name: varchar("name", { length: NAME_LENGTH }).notNull(),
|
|
13513
13526
|
status: varchar("status", { length: STATUS_LENGTH }).$type().notNull(),
|
|
13514
13527
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
13515
13528
|
});
|
|
13529
|
+
var agentDelegationsBunSqlTable = createAgentDelegationsTable(bunSqlJsonb);
|
|
13530
|
+
var agentDelegationsTable = createAgentDelegationsTable(portableJsonb);
|
|
13531
|
+
var agentIdentityRegistrationsBunSqlTable = createAgentIdentityRegistrationsTable(bunSqlJsonb);
|
|
13532
|
+
var agentIdentityRegistrationsTable = createAgentIdentityRegistrationsTable(portableJsonb);
|
|
13533
|
+
var agentRegistrationsBunSqlTable = createAgentRegistrationsTable(bunSqlJsonb);
|
|
13534
|
+
var agentRegistrationsTable = createAgentRegistrationsTable(portableJsonb);
|
|
13516
13535
|
var toRegistration = (row) => ({
|
|
13517
13536
|
agentId: row.agent_id,
|
|
13518
13537
|
allowedScopes: row.allowed_scopes,
|
|
@@ -13579,24 +13598,24 @@ var identityRegistrationValues = (registration) => ({
|
|
|
13579
13598
|
var createNeonAgentDelegationStore = (databaseUrl) => createDrizzleAgentDelegationStore(createNeonDatabase(databaseUrl));
|
|
13580
13599
|
var createNeonAgentIdentityRegistrationStore = (databaseUrl) => createPostgresAgentIdentityRegistrationStore(createNeonDatabase(databaseUrl));
|
|
13581
13600
|
var createNeonAgentRegistrationStore = (databaseUrl) => createPostgresAgentRegistrationStore(createNeonDatabase(databaseUrl));
|
|
13582
|
-
var
|
|
13601
|
+
var createDrizzleAgentDelegationStoreFor = (db, table) => ({
|
|
13583
13602
|
findActiveDelegation: async ({
|
|
13584
13603
|
agentId,
|
|
13585
13604
|
now = Date.now(),
|
|
13586
13605
|
organizationId,
|
|
13587
13606
|
userId
|
|
13588
13607
|
}) => {
|
|
13589
|
-
const organizationCondition = organizationId === undefined ? isNull(
|
|
13590
|
-
const [row] = await db.select().from(
|
|
13608
|
+
const organizationCondition = organizationId === undefined ? isNull(table.organization_id) : eq(table.organization_id, organizationId);
|
|
13609
|
+
const [row] = await db.select().from(table).where(and(eq(table.agent_id, agentId), eq(table.user_id, userId), organizationCondition, eq(table.status, "active"), or(isNull(table.expires_at_ms), gt(table.expires_at_ms, now)))).orderBy(desc(table.updated_at_ms)).limit(1);
|
|
13591
13610
|
return row === undefined ? undefined : toDelegation(row);
|
|
13592
13611
|
},
|
|
13593
13612
|
findByDelegationId: async (delegationId) => {
|
|
13594
|
-
const [row] = await db.select().from(
|
|
13613
|
+
const [row] = await db.select().from(table).where(eq(table.delegation_id, delegationId)).limit(1);
|
|
13595
13614
|
return row === undefined ? undefined : toDelegation(row);
|
|
13596
13615
|
},
|
|
13597
13616
|
listDelegations: async (agentId) => {
|
|
13598
|
-
const base = db.select().from(
|
|
13599
|
-
const rows = await (agentId === undefined ? base.orderBy(desc(
|
|
13617
|
+
const base = db.select().from(table);
|
|
13618
|
+
const rows = await (agentId === undefined ? base.orderBy(desc(table.created_at_ms)) : base.where(eq(table.agent_id, agentId)).orderBy(desc(table.created_at_ms)));
|
|
13600
13619
|
return rows.map(toDelegation);
|
|
13601
13620
|
},
|
|
13602
13621
|
saveDelegation: async (delegation) => {
|
|
@@ -13612,36 +13631,38 @@ var createDrizzleAgentDelegationStore = (db) => ({
|
|
|
13612
13631
|
updated_at_ms: delegation.updatedAt,
|
|
13613
13632
|
user_id: delegation.userId
|
|
13614
13633
|
};
|
|
13615
|
-
await db.insert(
|
|
13634
|
+
await db.insert(table).values(values).onConflictDoUpdate({
|
|
13616
13635
|
set: values,
|
|
13617
|
-
target:
|
|
13636
|
+
target: table.delegation_id
|
|
13618
13637
|
});
|
|
13619
13638
|
}
|
|
13620
13639
|
});
|
|
13640
|
+
var createDrizzleAgentDelegationStore = (db) => createDrizzleAgentDelegationStoreFor(db, agentDelegationsTable);
|
|
13641
|
+
var createBunSqlDrizzleAgentDelegationStore = (db) => createDrizzleAgentDelegationStoreFor(db, agentDelegationsBunSqlTable);
|
|
13621
13642
|
var createPostgresAgentDelegationStore = createDrizzleAgentDelegationStore;
|
|
13622
|
-
var
|
|
13643
|
+
var createPostgresAgentIdentityRegistrationStoreFor = (db, table) => ({
|
|
13623
13644
|
create: async (registration) => {
|
|
13624
|
-
const rows = await db.insert(
|
|
13645
|
+
const rows = await db.insert(table).values(identityRegistrationValues(registration)).onConflictDoNothing().returning({ id: table.registration_id });
|
|
13625
13646
|
return rows.length === 1;
|
|
13626
13647
|
},
|
|
13627
13648
|
findByAgentId: async (agentId) => {
|
|
13628
|
-
const [row] = await db.select().from(
|
|
13649
|
+
const [row] = await db.select().from(table).where(eq(table.agent_id, agentId)).limit(1);
|
|
13629
13650
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
13630
13651
|
},
|
|
13631
13652
|
findByAttemptTokenHash: async (attemptTokenHash) => {
|
|
13632
|
-
const [row] = await db.select().from(
|
|
13653
|
+
const [row] = await db.select().from(table).where(eq(table.claim_attempt_token_hash, attemptTokenHash)).limit(1);
|
|
13633
13654
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
13634
13655
|
},
|
|
13635
13656
|
findByClaimTokenHash: async (claimTokenHash) => {
|
|
13636
|
-
const [row] = await db.select().from(
|
|
13657
|
+
const [row] = await db.select().from(table).where(eq(table.claim_token_hash, claimTokenHash)).limit(1);
|
|
13637
13658
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
13638
13659
|
},
|
|
13639
13660
|
findByRegistrationId: async (registrationId) => {
|
|
13640
|
-
const [row] = await db.select().from(
|
|
13661
|
+
const [row] = await db.select().from(table).where(eq(table.registration_id, registrationId)).limit(1);
|
|
13641
13662
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
13642
13663
|
},
|
|
13643
13664
|
findByUpstreamIdentity: async ({ clientId, issuer, subject }) => {
|
|
13644
|
-
const [row] = await db.select().from(
|
|
13665
|
+
const [row] = await db.select().from(table).where(and(eq(table.upstream_client_id, clientId), eq(table.upstream_issuer, issuer), eq(table.upstream_subject, subject))).limit(1);
|
|
13645
13666
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
13646
13667
|
},
|
|
13647
13668
|
replace: async (registration, expectedVersion) => {
|
|
@@ -13650,21 +13671,23 @@ var createPostgresAgentIdentityRegistrationStore = (db) => ({
|
|
|
13650
13671
|
version: expectedVersion + 1
|
|
13651
13672
|
};
|
|
13652
13673
|
const values = identityRegistrationValues(next);
|
|
13653
|
-
const rows = await db.update(
|
|
13674
|
+
const rows = await db.update(table).set(values).where(and(eq(table.registration_id, registration.registrationId), eq(table.version, expectedVersion))).returning({ id: table.registration_id });
|
|
13654
13675
|
return rows.length === 1;
|
|
13655
13676
|
}
|
|
13656
13677
|
});
|
|
13657
|
-
var
|
|
13678
|
+
var createBunSqlDrizzleAgentIdentityRegistrationStore = (db) => createPostgresAgentIdentityRegistrationStoreFor(db, agentIdentityRegistrationsBunSqlTable);
|
|
13679
|
+
var createPostgresAgentIdentityRegistrationStore = (db) => createPostgresAgentIdentityRegistrationStoreFor(db, agentIdentityRegistrationsTable);
|
|
13680
|
+
var createPostgresAgentRegistrationStoreFor = (db, table) => ({
|
|
13658
13681
|
findByAgentId: async (agentId) => {
|
|
13659
|
-
const [row] = await db.select().from(
|
|
13682
|
+
const [row] = await db.select().from(table).where(eq(table.agent_id, agentId)).limit(1);
|
|
13660
13683
|
return row === undefined ? undefined : toRegistration(row);
|
|
13661
13684
|
},
|
|
13662
13685
|
findByClientId: async (clientId) => {
|
|
13663
|
-
const [row] = await db.select().from(
|
|
13686
|
+
const [row] = await db.select().from(table).where(eq(table.client_id, clientId)).limit(1);
|
|
13664
13687
|
return row === undefined ? undefined : toRegistration(row);
|
|
13665
13688
|
},
|
|
13666
13689
|
listRegistrations: async () => {
|
|
13667
|
-
const rows = await db.select().from(
|
|
13690
|
+
const rows = await db.select().from(table).orderBy(desc(table.created_at_ms));
|
|
13668
13691
|
return rows.map(toRegistration);
|
|
13669
13692
|
},
|
|
13670
13693
|
saveRegistration: async (registration) => {
|
|
@@ -13678,12 +13701,14 @@ var createPostgresAgentRegistrationStore = (db) => ({
|
|
|
13678
13701
|
status: registration.status,
|
|
13679
13702
|
updated_at_ms: registration.updatedAt
|
|
13680
13703
|
};
|
|
13681
|
-
await db.insert(
|
|
13704
|
+
await db.insert(table).values(values).onConflictDoUpdate({
|
|
13682
13705
|
set: values,
|
|
13683
|
-
target:
|
|
13706
|
+
target: table.agent_id
|
|
13684
13707
|
});
|
|
13685
13708
|
}
|
|
13686
13709
|
});
|
|
13710
|
+
var createBunSqlDrizzleAgentRegistrationStore = (db) => createPostgresAgentRegistrationStoreFor(db, agentRegistrationsBunSqlTable);
|
|
13711
|
+
var createPostgresAgentRegistrationStore = (db) => createPostgresAgentRegistrationStoreFor(db, agentRegistrationsTable);
|
|
13687
13712
|
export {
|
|
13688
13713
|
validateClientIdMetadataDocument,
|
|
13689
13714
|
startAgentRegistration,
|
|
@@ -13708,6 +13733,9 @@ export {
|
|
|
13708
13733
|
createInMemoryAgentDelegationStore,
|
|
13709
13734
|
createDrizzleAgentDelegationStore,
|
|
13710
13735
|
createClientIdMetadataResolver,
|
|
13736
|
+
createBunSqlDrizzleAgentRegistrationStore,
|
|
13737
|
+
createBunSqlDrizzleAgentIdentityRegistrationStore,
|
|
13738
|
+
createBunSqlDrizzleAgentDelegationStore,
|
|
13711
13739
|
createAgentRegistrationCredentialVerifier,
|
|
13712
13740
|
createAgentRegistrationClient,
|
|
13713
13741
|
createAgentIdentityAssertionVerifier,
|
|
@@ -13715,14 +13743,17 @@ export {
|
|
|
13715
13743
|
clientIdMetadataToOAuthClient,
|
|
13716
13744
|
beginAgentClaim,
|
|
13717
13745
|
agentRegistrationsTable,
|
|
13746
|
+
agentRegistrationsBunSqlTable,
|
|
13718
13747
|
agentRegistrationEndpoints,
|
|
13719
13748
|
agentRegistrationDiscoveryMetadata,
|
|
13720
13749
|
agentProtectedResourceMetadata,
|
|
13721
13750
|
agentOAuthGuideUrl,
|
|
13722
13751
|
agentOAuthGuideRoute,
|
|
13723
13752
|
agentIdentityRegistrationsTable,
|
|
13753
|
+
agentIdentityRegistrationsBunSqlTable,
|
|
13724
13754
|
agentHasScopes,
|
|
13725
13755
|
agentDelegationsTable,
|
|
13756
|
+
agentDelegationsBunSqlTable,
|
|
13726
13757
|
agentAuthPlugin,
|
|
13727
13758
|
agentAuthContextPlugin,
|
|
13728
13759
|
agentAuthChallenge,
|
|
@@ -13732,5 +13763,5 @@ export {
|
|
|
13732
13763
|
AGENT_CLAIM_GRANT_TYPE
|
|
13733
13764
|
};
|
|
13734
13765
|
|
|
13735
|
-
//# debugId=
|
|
13766
|
+
//# debugId=1B1983E343EC324864756E2164756E21
|
|
13736
13767
|
//# sourceMappingURL=index.js.map
|