@dads-framework/identity-better-auth 0.1.0 → 0.2.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/README.md +214 -16
- package/dist/identity-better-auth.tsbuildinfo +1 -1
- package/dist/impersonation-store/index.d.ts +3 -0
- package/dist/impersonation-store/index.d.ts.map +1 -0
- package/dist/impersonation-store/index.js +3 -0
- package/dist/impersonation-store/index.js.map +1 -0
- package/dist/impersonation-store/postgres-impersonation-store.d.ts +4 -0
- package/dist/impersonation-store/postgres-impersonation-store.d.ts.map +1 -0
- package/dist/impersonation-store/postgres-impersonation-store.js +75 -0
- package/dist/impersonation-store/postgres-impersonation-store.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/configure-better-auth.d.ts +1226 -5
- package/dist/lib/configure-better-auth.d.ts.map +1 -1
- package/dist/lib/configure-better-auth.js +21 -3
- package/dist/lib/configure-better-auth.js.map +1 -1
- package/dist/lib/create-better-auth-identity.d.ts +4 -0
- package/dist/lib/create-better-auth-identity.d.ts.map +1 -1
- package/dist/lib/create-better-auth-identity.js +22 -16
- package/dist/lib/create-better-auth-identity.js.map +1 -1
- package/dist/lib/enterprise-callback-context.d.ts +9 -0
- package/dist/lib/enterprise-callback-context.d.ts.map +1 -0
- package/dist/lib/enterprise-callback-context.js +9 -0
- package/dist/lib/enterprise-callback-context.js.map +1 -0
- package/dist/lib/enterprise-options.d.ts +31 -0
- package/dist/lib/enterprise-options.d.ts.map +1 -0
- package/dist/lib/enterprise-options.js +119 -0
- package/dist/lib/enterprise-options.js.map +1 -0
- package/dist/lib/enterprise-plugin.d.ts +1038 -0
- package/dist/lib/enterprise-plugin.d.ts.map +1 -0
- package/dist/lib/enterprise-plugin.js +211 -0
- package/dist/lib/enterprise-plugin.js.map +1 -0
- package/dist/lib/enterprise-routes.d.ts +5 -0
- package/dist/lib/enterprise-routes.d.ts.map +1 -0
- package/dist/lib/enterprise-routes.js +215 -0
- package/dist/lib/enterprise-routes.js.map +1 -0
- package/dist/lib/identity-handler.d.ts +2 -1
- package/dist/lib/identity-handler.d.ts.map +1 -1
- package/dist/lib/identity-handler.js +25 -5
- package/dist/lib/identity-handler.js.map +1 -1
- package/dist/lib/identity-session-readers.d.ts +23 -0
- package/dist/lib/identity-session-readers.d.ts.map +1 -0
- package/dist/lib/identity-session-readers.js +81 -0
- package/dist/lib/identity-session-readers.js.map +1 -0
- package/dist/lib/install-identity-schema-v2.d.ts +4 -0
- package/dist/lib/install-identity-schema-v2.d.ts.map +1 -0
- package/dist/lib/install-identity-schema-v2.js +8 -0
- package/dist/lib/install-identity-schema-v2.js.map +1 -0
- package/dist/lib/migrations/20261120070530_identity_jwks.migration.d.ts +5 -0
- package/dist/lib/migrations/20261120070530_identity_jwks.migration.d.ts.map +1 -0
- package/dist/lib/migrations/20261120070530_identity_jwks.migration.js +10 -0
- package/dist/lib/migrations/20261120070530_identity_jwks.migration.js.map +1 -0
- package/dist/lib/migrations/20261120070600_enterprise_sso.migration.d.ts +5 -0
- package/dist/lib/migrations/20261120070600_enterprise_sso.migration.d.ts.map +1 -0
- package/dist/lib/migrations/20261120070600_enterprise_sso.migration.js +33 -0
- package/dist/lib/migrations/20261120070600_enterprise_sso.migration.js.map +1 -0
- package/dist/lib/migrations/20261120070700_staff_impersonation.migration.d.ts +6 -0
- package/dist/lib/migrations/20261120070700_staff_impersonation.migration.d.ts.map +1 -0
- package/dist/lib/migrations/20261120070700_staff_impersonation.migration.js +37 -0
- package/dist/lib/migrations/20261120070700_staff_impersonation.migration.js.map +1 -0
- package/package.json +12 -5
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { enterpriseProviderBinding, } from "./enterprise-options.js";
|
|
2
|
+
import { forEmail } from "./enterprise-plugin.js";
|
|
3
|
+
export function createIdentitySessionReaders(vendor, providers) {
|
|
4
|
+
async function readCurrent(headers) {
|
|
5
|
+
const current = await vendor.api.getSession({ headers });
|
|
6
|
+
if (current === null || !current.user.emailVerified)
|
|
7
|
+
return null;
|
|
8
|
+
const provider = forEmail(providers, current.user.email);
|
|
9
|
+
const sessionBinding = "ssoProviderBinding" in current.session
|
|
10
|
+
? current.session.ssoProviderBinding
|
|
11
|
+
: undefined;
|
|
12
|
+
const hasProviderSession = sessionMatchesProvider(sessionBinding, provider);
|
|
13
|
+
if (!hasProviderSession &&
|
|
14
|
+
(provider?.mode === "required" || sessionBinding != null))
|
|
15
|
+
return null;
|
|
16
|
+
return { current, provider: hasProviderSession ? provider : undefined };
|
|
17
|
+
}
|
|
18
|
+
const readSession = async (headers) => {
|
|
19
|
+
const context = await readCurrent(headers);
|
|
20
|
+
return context === null ? null : identityView(context.current);
|
|
21
|
+
};
|
|
22
|
+
const readEnterpriseSession = async (headers, tenantId, maxAgeMs) => {
|
|
23
|
+
const context = await readCurrent(headers);
|
|
24
|
+
if (context === null || context.provider?.tenantId !== tenantId)
|
|
25
|
+
return null;
|
|
26
|
+
const authenticatedAt = context.current.session.createdAt;
|
|
27
|
+
if (!withinAge(authenticatedAt, maxAgeMs))
|
|
28
|
+
return null;
|
|
29
|
+
return {
|
|
30
|
+
...identityView(context.current),
|
|
31
|
+
providerId: context.provider.id,
|
|
32
|
+
tenantId,
|
|
33
|
+
authenticatedAt,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const requiredTenants = new Set(providers
|
|
37
|
+
.filter(({ mode }) => mode === "required")
|
|
38
|
+
.map(({ tenantId }) => tenantId));
|
|
39
|
+
const readTenantSessionPolicy = async (headers) => {
|
|
40
|
+
const context = await readCurrent(headers);
|
|
41
|
+
if (context === null)
|
|
42
|
+
return null;
|
|
43
|
+
const session = identityView(context.current);
|
|
44
|
+
const expiresAt = session.expiresAt.getTime();
|
|
45
|
+
const ssoTenantId = context.provider?.tenantId;
|
|
46
|
+
return {
|
|
47
|
+
session,
|
|
48
|
+
allowsTenant: (tenantId) => expiresAt > Date.now() &&
|
|
49
|
+
(ssoTenantId === tenantId || !requiredTenants.has(tenantId)),
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const readTenantSession = async (headers, tenantId) => {
|
|
53
|
+
const policy = await readTenantSessionPolicy(headers);
|
|
54
|
+
return policy?.allowsTenant(tenantId) ? policy.session : null;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
readSession,
|
|
58
|
+
readEnterpriseSession,
|
|
59
|
+
readTenantSession,
|
|
60
|
+
readTenantSessionPolicy,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function sessionMatchesProvider(binding, provider) {
|
|
64
|
+
return (typeof binding === "string" &&
|
|
65
|
+
provider !== undefined &&
|
|
66
|
+
binding === enterpriseProviderBinding(provider));
|
|
67
|
+
}
|
|
68
|
+
function withinAge(authenticatedAt, maxAgeMs) {
|
|
69
|
+
const age = Date.now() - authenticatedAt.getTime();
|
|
70
|
+
return (maxAgeMs === undefined ||
|
|
71
|
+
(Number.isFinite(maxAgeMs) && age >= 0 && age <= maxAgeMs));
|
|
72
|
+
}
|
|
73
|
+
function identityView(current) {
|
|
74
|
+
const { id, email, emailVerified } = current.user;
|
|
75
|
+
return {
|
|
76
|
+
account: { id, email, emailVerified },
|
|
77
|
+
expiresAt: current.session.expiresAt,
|
|
78
|
+
sessionId: current.session.id,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=identity-session-readers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-session-readers.js","sourceRoot":"","sources":["../../src/lib/identity-session-readers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,GAE1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA6BlD,MAAM,UAAU,4BAA4B,CAC1C,MAAkB,EAClB,SAA2C;IAE3C,KAAK,UAAU,WAAW,CAAC,OAAgB;QACzC,MAA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;AAKxD,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAGnE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { up as installIdentitySchemaV1 } from "./migrations/20261120070500_identity.migration.js";
|
|
2
|
+
import { up as installIdentitySigningKeyMetadataSchema } from "./migrations/20261120070530_identity_jwks.migration.js";
|
|
3
|
+
/** Installs the default identity schema in a fresh database. */
|
|
4
|
+
export function installIdentitySchemaV2(pgm) {
|
|
5
|
+
installIdentitySchemaV1(pgm);
|
|
6
|
+
installIdentitySigningKeyMetadataSchema(pgm);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=install-identity-schema-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-identity-schema-v2.js","sourceRoot":"","sources":["../../src/lib/install-identity-schema-v2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,IAAI,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAClG,OAAO,EAAE,EAAE,IAAI,uCAAuC,EAAE,MAAM,wDAAwD,CAAC;AAEvH,gEAAgE;AAChE,MAAM,UAAU,uBAAuB,CAAC,GAAqB;IAC3D,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC7B,uCAAuC,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MigrationBuilder } from "node-pg-migrate";
|
|
2
|
+
export declare const dependsOn: readonly string[];
|
|
3
|
+
export declare function up(migration: MigrationBuilder): void;
|
|
4
|
+
export declare function down(migration: MigrationBuilder): void;
|
|
5
|
+
//# sourceMappingURL=20261120070530_identity_jwks.migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070530_identity_jwks.migration.d.ts","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070530_identity_jwks.migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAEtC,CAAC;AAEF,wBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAIpD;AAED,wBAAgB,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAItD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const dependsOn = [
|
|
2
|
+
"20261120070500_identity.migration",
|
|
3
|
+
];
|
|
4
|
+
export function up(migration) {
|
|
5
|
+
migration.sql("ALTER TABLE identity_signing_keys ADD COLUMN alg text, ADD COLUMN crv text");
|
|
6
|
+
}
|
|
7
|
+
export function down(migration) {
|
|
8
|
+
migration.sql("ALTER TABLE identity_signing_keys DROP COLUMN alg, DROP COLUMN crv");
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=20261120070530_identity_jwks.migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070530_identity_jwks.migration.js","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070530_identity_jwks.migration.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,mCAAmC;CACpC,CAAC;AAEF,MAAM,UAAU,EAAE,CAAC,SAA2B;IAC5C,SAAS,CAAC,GAAG,CACX,4EAA4E,CAC7E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,SAA2B;IAC9C,SAAS,CAAC,GAAG,CACX,oEAAoE,CACrE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MigrationBuilder } from "node-pg-migrate";
|
|
2
|
+
export declare const dependsOn: readonly string[];
|
|
3
|
+
export declare function up(migration: MigrationBuilder): void;
|
|
4
|
+
export declare function down(migration: MigrationBuilder): void;
|
|
5
|
+
//# sourceMappingURL=20261120070600_enterprise_sso.migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070600_enterprise_sso.migration.d.ts","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070600_enterprise_sso.migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAEtC,CAAC;AAEF,wBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAoBpD;AAED,wBAAgB,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAOtD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const dependsOn = [
|
|
2
|
+
"20261120070500_identity.migration",
|
|
3
|
+
];
|
|
4
|
+
export function up(migration) {
|
|
5
|
+
migration.sql(`
|
|
6
|
+
CREATE TABLE identity_sso_providers (
|
|
7
|
+
id text PRIMARY KEY,
|
|
8
|
+
issuer text NOT NULL,
|
|
9
|
+
"oidcConfig" text,
|
|
10
|
+
"samlConfig" text,
|
|
11
|
+
"userId" text NOT NULL REFERENCES identity_users (id) ON DELETE CASCADE,
|
|
12
|
+
"providerId" text NOT NULL UNIQUE,
|
|
13
|
+
"organizationId" text,
|
|
14
|
+
domain text NOT NULL,
|
|
15
|
+
"domainVerified" boolean,
|
|
16
|
+
CONSTRAINT identity_sso_providers_configuration_only CHECK (false)
|
|
17
|
+
);
|
|
18
|
+
ALTER TABLE identity_sessions ADD COLUMN "ssoProviderBinding" text;
|
|
19
|
+
ALTER TABLE identity_credentials ADD COLUMN "ssoProviderBinding" text;
|
|
20
|
+
CREATE UNIQUE INDEX identity_credentials_enterprise_provider_user_idx
|
|
21
|
+
ON identity_credentials ("providerId", "userId")
|
|
22
|
+
WHERE "providerId" LIKE 'sso-%';
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
export function down(migration) {
|
|
26
|
+
migration.sql(`
|
|
27
|
+
DROP TABLE identity_sso_providers;
|
|
28
|
+
DROP INDEX identity_credentials_enterprise_provider_user_idx;
|
|
29
|
+
ALTER TABLE identity_sessions DROP COLUMN "ssoProviderBinding";
|
|
30
|
+
ALTER TABLE identity_credentials DROP COLUMN "ssoProviderBinding";
|
|
31
|
+
`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=20261120070600_enterprise_sso.migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070600_enterprise_sso.migration.js","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070600_enterprise_sso.migration.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,mCAAmC;CACpC,CAAC;AAEF,MAAM,UAAU,EAAE,CAAC,SAA2B;IAC5C,SAAS,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;GAkBb,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,SAA2B;IAC9C,SAAS,CAAC,GAAG,CAAC;;;;;GAKb,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MigrationBuilder } from "node-pg-migrate";
|
|
2
|
+
export declare const dependsOn: readonly string[];
|
|
3
|
+
export declare function installStaffImpersonationSchemaV1(migration: MigrationBuilder): void;
|
|
4
|
+
export declare function up(migration: MigrationBuilder): void;
|
|
5
|
+
export declare function down(migration: MigrationBuilder): void;
|
|
6
|
+
//# sourceMappingURL=20261120070700_staff_impersonation.migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070700_staff_impersonation.migration.d.ts","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070700_staff_impersonation.migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAEtC,CAAC;AAEF,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,gBAAgB,GAC1B,IAAI,CAuBN;AAED,wBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAEpD;AAED,wBAAgB,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAKtD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const dependsOn = [
|
|
2
|
+
"20261120070500_identity.migration",
|
|
3
|
+
];
|
|
4
|
+
export function installStaffImpersonationSchemaV1(migration) {
|
|
5
|
+
migration.sql(`
|
|
6
|
+
CREATE TABLE identity_staff_impersonation_grants (
|
|
7
|
+
id text PRIMARY KEY,
|
|
8
|
+
tenant_id text NOT NULL,
|
|
9
|
+
staff_account_id text NOT NULL,
|
|
10
|
+
staff_session_id text NOT NULL,
|
|
11
|
+
effective_account_id text NOT NULL,
|
|
12
|
+
expires_at_ms bigint NOT NULL,
|
|
13
|
+
CHECK (staff_account_id <> effective_account_id)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
CREATE INDEX identity_staff_impersonation_grants_expiry
|
|
17
|
+
ON identity_staff_impersonation_grants (expires_at_ms);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE identity_staff_impersonation_audit (
|
|
20
|
+
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
21
|
+
event jsonb NOT NULL
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE INDEX identity_staff_impersonation_audit_tenant
|
|
25
|
+
ON identity_staff_impersonation_audit ((event->>'tenantId'), id);
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
export function up(migration) {
|
|
29
|
+
installStaffImpersonationSchemaV1(migration);
|
|
30
|
+
}
|
|
31
|
+
export function down(migration) {
|
|
32
|
+
migration.sql(`
|
|
33
|
+
DROP TABLE identity_staff_impersonation_grants;
|
|
34
|
+
DROP TABLE identity_staff_impersonation_audit;
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=20261120070700_staff_impersonation.migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261120070700_staff_impersonation.migration.js","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070700_staff_impersonation.migration.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,mCAAmC;CACpC,CAAC;AAEF,MAAM,UAAU,iCAAiC,CAC/C,SAA2B;IAE3B,SAAS,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;GAqBb,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,EAAE,CAAC,SAA2B;IAC5C,iCAAiC,CAAC,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,SAA2B;IAC9C,SAAS,CAAC,GAAG,CAAC;;;GAGb,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dads-framework/identity-better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./impersonation-store": {
|
|
14
|
+
"types": "./dist/impersonation-store/index.d.ts",
|
|
15
|
+
"default": "./dist/impersonation-store/index.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
@@ -23,15 +27,18 @@
|
|
|
23
27
|
"typecheck": "tsc -b --pretty false"
|
|
24
28
|
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"better-auth": "1.
|
|
30
|
+
"@better-auth/core": "1.7.26",
|
|
31
|
+
"@better-auth/sso": "1.7.26",
|
|
32
|
+
"@dads-framework/identity": "0.2.0",
|
|
33
|
+
"better-auth": "1.7.26",
|
|
28
34
|
"kysely": "0.28.17",
|
|
29
35
|
"node-pg-migrate": "^9.0.0"
|
|
30
36
|
},
|
|
31
37
|
"devDependencies": {
|
|
32
|
-
"@dads-framework/migrations": "0.
|
|
33
|
-
"@dads-framework/postgres": "0.
|
|
38
|
+
"@dads-framework/migrations": "0.2.0",
|
|
39
|
+
"@dads-framework/postgres": "0.2.0",
|
|
34
40
|
"@testcontainers/postgresql": "^12.0.4",
|
|
41
|
+
"samlify": "2.15.1",
|
|
35
42
|
"testcontainers": "^12.0.4",
|
|
36
43
|
"vitest": "~4.1.0"
|
|
37
44
|
},
|