@dads-framework/identity-better-auth 0.0.0-stage → 0.1.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.
Files changed (36) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +82 -2
  3. package/dist/identity-better-auth.tsbuildinfo +1 -0
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +4 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/account-invitations.d.ts +7 -0
  9. package/dist/lib/account-invitations.d.ts.map +1 -0
  10. package/dist/lib/account-invitations.js +46 -0
  11. package/dist/lib/account-invitations.js.map +1 -0
  12. package/dist/lib/configure-better-auth.d.ts +288 -0
  13. package/dist/lib/configure-better-auth.d.ts.map +1 -0
  14. package/dist/lib/configure-better-auth.js +67 -0
  15. package/dist/lib/configure-better-auth.js.map +1 -0
  16. package/dist/lib/create-better-auth-identity.d.ts +5 -0
  17. package/dist/lib/create-better-auth-identity.d.ts.map +1 -0
  18. package/dist/lib/create-better-auth-identity.js +31 -0
  19. package/dist/lib/create-better-auth-identity.js.map +1 -0
  20. package/dist/lib/identity-email.d.ts +4 -0
  21. package/dist/lib/identity-email.d.ts.map +1 -0
  22. package/dist/lib/identity-email.js +15 -0
  23. package/dist/lib/identity-email.js.map +1 -0
  24. package/dist/lib/identity-handler.d.ts +8 -0
  25. package/dist/lib/identity-handler.d.ts.map +1 -0
  26. package/dist/lib/identity-handler.js +82 -0
  27. package/dist/lib/identity-handler.js.map +1 -0
  28. package/dist/lib/identity-options.d.ts +15 -0
  29. package/dist/lib/identity-options.d.ts.map +1 -0
  30. package/dist/lib/identity-options.js +17 -0
  31. package/dist/lib/identity-options.js.map +1 -0
  32. package/dist/lib/migrations/20261120070500_identity.migration.d.ts +5 -0
  33. package/dist/lib/migrations/20261120070500_identity.migration.d.ts.map +1 -0
  34. package/dist/lib/migrations/20261120070500_identity.migration.js +81 -0
  35. package/dist/lib/migrations/20261120070500_identity.migration.js.map +1 -0
  36. package/package.json +43 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-options.d.ts","sourceRoot":"","sources":["../../src/lib/identity-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgBvD"}
@@ -0,0 +1,17 @@
1
+ export const IDENTITY_PATH = "/api/auth";
2
+ export function validatedOrigin(baseUrl) {
3
+ const url = new URL(baseUrl);
4
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
5
+ if (url.protocol !== "https:" && !(local && url.protocol === "http:")) {
6
+ throw new Error("Identity requires HTTPS or a loopback HTTP origin.");
7
+ }
8
+ if (url.username ||
9
+ url.password ||
10
+ url.pathname !== "/" ||
11
+ url.search ||
12
+ url.hash) {
13
+ throw new Error("Identity requires a bare origin.");
14
+ }
15
+ return url.origin;
16
+ }
17
+ //# sourceMappingURL=identity-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-options.js","sourceRoot":"","sources":["../../src/lib/identity-options.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAWzC,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzE,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,IACE,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,QAAQ,KAAK,GAAG;QACpB,GAAG,CAAC,MAAM;QACV,GAAG,CAAC,IAAI,EACR,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,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=20261120070500_identity.migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20261120070500_identity.migration.d.ts","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070500_identity.migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAAO,CAAC;AAE/C,wBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAoEpD;AAED,wBAAgB,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAStD"}
@@ -0,0 +1,81 @@
1
+ export const dependsOn = [];
2
+ export function up(migration) {
3
+ migration.sql(`
4
+ CREATE TABLE identity_users (
5
+ id text PRIMARY KEY,
6
+ name text NOT NULL,
7
+ email text NOT NULL UNIQUE,
8
+ "emailVerified" boolean NOT NULL DEFAULT false,
9
+ image text,
10
+ "createdAt" timestamptz NOT NULL,
11
+ "updatedAt" timestamptz NOT NULL
12
+ );
13
+
14
+ CREATE TABLE identity_credentials (
15
+ id text PRIMARY KEY,
16
+ "accountId" text NOT NULL,
17
+ "providerId" text NOT NULL,
18
+ "userId" text NOT NULL REFERENCES identity_users (id) ON DELETE CASCADE,
19
+ "accessToken" text,
20
+ "refreshToken" text,
21
+ "idToken" text,
22
+ "accessTokenExpiresAt" timestamptz,
23
+ "refreshTokenExpiresAt" timestamptz,
24
+ scope text,
25
+ password text,
26
+ "createdAt" timestamptz NOT NULL,
27
+ "updatedAt" timestamptz NOT NULL,
28
+ UNIQUE ("providerId", "accountId")
29
+ );
30
+ CREATE INDEX identity_credentials_user_id_idx ON identity_credentials ("userId");
31
+
32
+ CREATE TABLE identity_sessions (
33
+ id text PRIMARY KEY,
34
+ token text NOT NULL UNIQUE,
35
+ "expiresAt" timestamptz NOT NULL,
36
+ "createdAt" timestamptz NOT NULL,
37
+ "updatedAt" timestamptz NOT NULL,
38
+ "ipAddress" text,
39
+ "userAgent" text,
40
+ "userId" text NOT NULL REFERENCES identity_users (id) ON DELETE CASCADE
41
+ );
42
+ CREATE INDEX identity_sessions_user_id_idx ON identity_sessions ("userId");
43
+
44
+ CREATE TABLE identity_verifications (
45
+ id text PRIMARY KEY,
46
+ identifier text NOT NULL,
47
+ value text NOT NULL,
48
+ "expiresAt" timestamptz NOT NULL,
49
+ "createdAt" timestamptz NOT NULL,
50
+ "updatedAt" timestamptz NOT NULL
51
+ );
52
+ CREATE INDEX identity_verifications_identifier_idx ON identity_verifications (identifier);
53
+
54
+ CREATE TABLE identity_signing_keys (
55
+ id text PRIMARY KEY,
56
+ "publicKey" text NOT NULL,
57
+ "privateKey" text NOT NULL,
58
+ "createdAt" timestamptz NOT NULL,
59
+ "expiresAt" timestamptz
60
+ );
61
+
62
+ CREATE TABLE identity_account_invitations (
63
+ digest text PRIMARY KEY,
64
+ email text NOT NULL,
65
+ expires_at timestamptz NOT NULL,
66
+ issued_by text NOT NULL REFERENCES identity_users (id) ON DELETE CASCADE
67
+ );
68
+ CREATE INDEX identity_account_invitations_expires_at_idx ON identity_account_invitations (expires_at);
69
+ `);
70
+ }
71
+ export function down(migration) {
72
+ migration.sql(`
73
+ DROP TABLE identity_account_invitations;
74
+ DROP TABLE identity_signing_keys;
75
+ DROP TABLE identity_verifications;
76
+ DROP TABLE identity_sessions;
77
+ DROP TABLE identity_credentials;
78
+ DROP TABLE identity_users;
79
+ `);
80
+ }
81
+ //# sourceMappingURL=20261120070500_identity.migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20261120070500_identity.migration.js","sourceRoot":"","sources":["../../../src/lib/migrations/20261120070500_identity.migration.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsB,EAAE,CAAC;AAE/C,MAAM,UAAU,EAAE,CAAC,SAA2B;IAC5C,SAAS,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEb,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,SAA2B;IAC9C,SAAS,CAAC,GAAG,CAAC;;;;;;;GAOb,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@dads-framework/identity-better-auth",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "prepublishOnly": "node ../../../scripts/verify-prepublish.mjs",
20
+ "build": "tsc -b",
21
+ "test": "vitest run",
22
+ "test:integration": "VITEST_TIER=integration vitest run",
23
+ "typecheck": "tsc -b --pretty false"
24
+ },
25
+ "dependencies": {
26
+ "@dads-framework/identity": "0.1.0",
27
+ "better-auth": "1.6.23",
28
+ "kysely": "0.28.17",
29
+ "node-pg-migrate": "^9.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@dads-framework/migrations": "0.1.0",
33
+ "@dads-framework/postgres": "0.1.0",
34
+ "@testcontainers/postgresql": "^12.0.4",
35
+ "testcontainers": "^12.0.4",
36
+ "vitest": "~4.1.0"
37
+ },
38
+ "license": "MIT",
39
+ "author": "Bryton Cooper",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/brytoncooper/dads-framework.git",
43
+ "directory": "packages/server/identity-better-auth"
44
+ }
45
+ }