@tinyrack/tinyauth-server 0.0.11 → 0.0.13
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/LICENSE +21 -0
- package/dist/entities/bootstrap-state.entity.d.ts +40 -0
- package/dist/entities/bootstrap-state.entity.d.ts.map +1 -0
- package/dist/entities/bootstrap-state.entity.js +13 -0
- package/dist/entities/bootstrap-state.entity.js.map +1 -0
- package/dist/entrypoints/app.d.ts +3 -1
- package/dist/entrypoints/app.d.ts.map +1 -1
- package/dist/entrypoints/app.js +3 -3
- package/dist/entrypoints/app.js.map +1 -1
- package/dist/entrypoints/database/d1/cli.d.ts +3 -2
- package/dist/entrypoints/database/d1/cli.d.ts.map +1 -1
- package/dist/entrypoints/database/d1/cli.js +9 -2
- package/dist/entrypoints/database/d1/cli.js.map +1 -1
- package/dist/entrypoints/database/d1/compiled-functions.d.ts +185 -160
- package/dist/entrypoints/database/d1/compiled-functions.d.ts.map +1 -1
- package/dist/entrypoints/database/d1/compiled-functions.js +411 -160
- package/dist/entrypoints/database/d1/compiled-functions.js.map +1 -1
- package/dist/entrypoints/database/d1/d1.d.ts.map +1 -1
- package/dist/entrypoints/database/d1/d1.js +11 -15
- package/dist/entrypoints/database/d1/d1.js.map +1 -1
- package/dist/entrypoints/database/postgres/cli.d.ts +3 -2
- package/dist/entrypoints/database/postgres/cli.d.ts.map +1 -1
- package/dist/entrypoints/database/postgres/cli.js +12 -1
- package/dist/entrypoints/database/postgres/cli.js.map +1 -1
- package/dist/entrypoints/database/postgres/compiled-functions.d.ts +185 -160
- package/dist/entrypoints/database/postgres/compiled-functions.d.ts.map +1 -1
- package/dist/entrypoints/database/postgres/compiled-functions.js +411 -160
- package/dist/entrypoints/database/postgres/compiled-functions.js.map +1 -1
- package/dist/entrypoints/database/postgres/postgres.d.ts.map +1 -1
- package/dist/entrypoints/database/postgres/postgres.js +5 -3
- package/dist/entrypoints/database/postgres/postgres.js.map +1 -1
- package/dist/entrypoints/database/sqlite/cli.d.ts +3 -2
- package/dist/entrypoints/database/sqlite/cli.d.ts.map +1 -1
- package/dist/entrypoints/database/sqlite/cli.js +9 -1
- package/dist/entrypoints/database/sqlite/cli.js.map +1 -1
- package/dist/entrypoints/database/sqlite/compiled-functions.d.ts +185 -160
- package/dist/entrypoints/database/sqlite/compiled-functions.d.ts.map +1 -1
- package/dist/entrypoints/database/sqlite/compiled-functions.js +411 -160
- package/dist/entrypoints/database/sqlite/compiled-functions.js.map +1 -1
- package/dist/entrypoints/database/sqlite/sqlite.d.ts.map +1 -1
- package/dist/entrypoints/database/sqlite/sqlite.js +4 -0
- package/dist/entrypoints/database/sqlite/sqlite.js.map +1 -1
- package/dist/entrypoints/services.d.ts +1 -1
- package/dist/entrypoints/services.d.ts.map +1 -1
- package/dist/entrypoints/services.js.map +1 -1
- package/dist/lib/database/entities.d.ts.map +1 -1
- package/dist/lib/database/entities.js +2 -0
- package/dist/lib/database/entities.js.map +1 -1
- package/dist/migrations/d1/Migration20260509172833_initial.d.ts +5 -0
- package/dist/migrations/d1/Migration20260509172833_initial.d.ts.map +1 -0
- package/dist/migrations/d1/Migration20260509172833_initial.js +62 -0
- package/dist/migrations/d1/Migration20260509172833_initial.js.map +1 -0
- package/dist/migrations/d1/index.d.ts +3 -0
- package/dist/migrations/d1/index.d.ts.map +1 -0
- package/dist/migrations/d1/index.js +3 -0
- package/dist/migrations/d1/index.js.map +1 -0
- package/dist/migrations/postgres/Migration20260509171036_initial.d.ts +5 -0
- package/dist/migrations/postgres/Migration20260509171036_initial.d.ts.map +1 -0
- package/dist/migrations/postgres/Migration20260509171036_initial.js +246 -0
- package/dist/migrations/postgres/Migration20260509171036_initial.js.map +1 -0
- package/dist/migrations/postgres/index.d.ts +3 -0
- package/dist/migrations/postgres/index.d.ts.map +1 -0
- package/dist/migrations/postgres/index.js +3 -0
- package/dist/migrations/postgres/index.js.map +1 -0
- package/dist/migrations/sqlite/Migration20260509171226_initial.d.ts +5 -0
- package/dist/migrations/sqlite/Migration20260509171226_initial.d.ts.map +1 -0
- package/dist/migrations/sqlite/Migration20260509171226_initial.js +62 -0
- package/dist/migrations/sqlite/Migration20260509171226_initial.js.map +1 -0
- package/dist/migrations/sqlite/index.d.ts +3 -0
- package/dist/migrations/sqlite/index.d.ts.map +1 -0
- package/dist/migrations/sqlite/index.js +3 -0
- package/dist/migrations/sqlite/index.js.map +1 -0
- package/dist/seeders/config.seeder.d.ts +2 -0
- package/dist/seeders/config.seeder.d.ts.map +1 -1
- package/dist/seeders/config.seeder.js +87 -0
- package/dist/seeders/config.seeder.js.map +1 -1
- package/dist/services/container.d.ts +5 -1
- package/dist/services/container.d.ts.map +1 -1
- package/dist/services/container.js +4 -3
- package/dist/services/container.js.map +1 -1
- package/package.json +60 -156
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
export class Migration20260509171226_initial extends Migration {
|
|
3
|
+
up() {
|
|
4
|
+
this.addSql(`create table \`bootstrap_state\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`value\` text not null) /* Runtime bootstrap metadata */;`);
|
|
5
|
+
this.addSql(`create table \`jwt_key\` (\`kid\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`private_key\` text not null, \`public_key\` text not null, \`algorithm\` text not null default 'RS256', \`status\` text check (\`status\` in ('next', 'active', 'previous', 'retired')) not null default 'next', \`activated_at\` datetime null, \`deactivated_at\` datetime null, \`retired_at\` datetime null, \`expires_at\` datetime null) /* RSA key pairs for JWT signing (RS256) */;`);
|
|
6
|
+
this.addSql(`create index \`jwt_key_status_idx\` on \`jwt_key\` (\`status\`);`);
|
|
7
|
+
this.addSql(`create table \`oauth_client\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`client_id\` text not null, \`client_secret_hash\` text null, \`name\` text not null, \`grant_types\` json not null default '[]', \`response_types\` json not null default '[]', \`scopes\` json not null default '[]', \`redirect_uris\` json not null default '[]', \`enabled\` integer not null default true, \`managed_by\` text not null default 'database', \`logo_uri\` text null) /* Registered OAuth clients */;`);
|
|
8
|
+
this.addSql(`create index \`client_client_id_unique\` on \`oauth_client\` (\`client_id\`);`);
|
|
9
|
+
this.addSql(`create table \`pending_oauth_registration\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`token\` text not null, \`provider_id\` text not null, \`access_token\` text not null, \`refresh_token\` text null, \`expires_in\` integer null, \`token_type\` text not null, \`user_info\` json not null, \`return_url\` text null, \`expires_at\` datetime not null) /* Server-side store for pending OAuth registrations awaiting terms consent */;`);
|
|
10
|
+
this.addSql(`create unique index \`pending_oauth_registration_token_unique\` on \`pending_oauth_registration\` (\`token\`);`);
|
|
11
|
+
this.addSql(`create index \`pending_oauth_reg_token_idx\` on \`pending_oauth_registration\` (\`token\`);`);
|
|
12
|
+
this.addSql(`create index \`pending_oauth_reg_expires_at_idx\` on \`pending_oauth_registration\` (\`expires_at\`);`);
|
|
13
|
+
this.addSql(`create table \`terms\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`required\` integer not null default true, \`consent_mode\` text not null default 'explicit', \`version\` text not null, \`managed_by\` text not null default 'database') /* Terms of service definitions */;`);
|
|
14
|
+
this.addSql(`create table \`terms_content\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`terms_id\` text not null, \`lang\` text not null, \`title\` text not null, \`type\` text not null default 'link', \`content\` text not null, constraint \`terms_content_terms_id_foreign\` foreign key (\`terms_id\`) references \`terms\` (\`id\`) on delete cascade) /* Localized content for terms */;`);
|
|
15
|
+
this.addSql(`create index \`terms_content_terms_id_index\` on \`terms_content\` (\`terms_id\`);`);
|
|
16
|
+
this.addSql(`create unique index \`terms_content_terms_lang_unique\` on \`terms_content\` (\`terms_id\`, \`lang\`);`);
|
|
17
|
+
this.addSql(`create table \`user\` (\`sub\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`email\` text not null, \`email_verified\` integer not null default false, \`password_hash\` text null, \`managed_by\` text not null default 'database', \`role\` text not null default 'user', \`deleted_at\` datetime null) /* Registered users */;`);
|
|
18
|
+
this.addSql(`create index \`user_email_unique\` on \`user\` (\`email\`);`);
|
|
19
|
+
this.addSql(`create index \`user_deleted_at_idx\` on \`user\` (\`deleted_at\`);`);
|
|
20
|
+
this.addSql(`create table \`user_consent\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`client_id\` text not null, \`scopes\` json not null default '[]', \`granted_at\` datetime not null, \`revoked_at\` datetime null, constraint \`user_consent_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`), constraint \`user_consent_client_id_foreign\` foreign key (\`client_id\`) references \`oauth_client\` (\`id\`)) /* User consent decisions for OAuth clients */;`);
|
|
21
|
+
this.addSql(`create index \`user_consent_user_sub_index\` on \`user_consent\` (\`user_sub\`);`);
|
|
22
|
+
this.addSql(`create index \`user_consent_client_id_index\` on \`user_consent\` (\`client_id\`);`);
|
|
23
|
+
this.addSql(`create unique index \`user_consent_unique\` on \`user_consent\` (\`user_sub\`, \`client_id\`);`);
|
|
24
|
+
this.addSql(`create table \`revoked_tokens\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`jti\` text not null, \`token_type\` text check (\`token_type\` in ('access_token', 'refresh_token')) not null, \`client_id\` text not null, \`user_sub\` text not null, \`expires_at\` datetime not null, \`revoked_at\` datetime not null, constraint \`revoked_tokens_client_id_foreign\` foreign key (\`client_id\`) references \`oauth_client\` (\`id\`), constraint \`revoked_tokens_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`)) /* Revoked OAuth tokens for invalidation before expiry */;`);
|
|
25
|
+
this.addSql(`create unique index \`revoked_tokens_jti_unique\` on \`revoked_tokens\` (\`jti\`);`);
|
|
26
|
+
this.addSql(`create index \`revoked_tokens_client_id_index\` on \`revoked_tokens\` (\`client_id\`);`);
|
|
27
|
+
this.addSql(`create index \`revoked_tokens_user_sub_index\` on \`revoked_tokens\` (\`user_sub\`);`);
|
|
28
|
+
this.addSql(`create index \`revoked_token_jti_idx\` on \`revoked_tokens\` (\`jti\`);`);
|
|
29
|
+
this.addSql(`create index \`revoked_token_client_user_idx\` on \`revoked_tokens\` (\`client_id\`, \`user_sub\`);`);
|
|
30
|
+
this.addSql(`create index \`revoked_token_expires_at_idx\` on \`revoked_tokens\` (\`expires_at\`);`);
|
|
31
|
+
this.addSql(`create table \`password_reset\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`token\` text not null, \`expires_at\` datetime not null, \`used\` integer not null default false, \`used_at\` datetime null, constraint \`password_reset_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`)) /* Password reset tokens for user password recovery */;`);
|
|
32
|
+
this.addSql(`create index \`password_reset_user_sub_idx\` on \`password_reset\` (\`user_sub\`);`);
|
|
33
|
+
this.addSql(`create index \`password_reset_token_idx\` on \`password_reset\` (\`token\`);`);
|
|
34
|
+
this.addSql(`create table \`oauth_code\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`code_hash\` text not null, \`client_id\` text not null, \`user_sub\` text not null, \`redirect_uri\` text null, \`scope\` json not null default '[]', \`nonce\` text not null, \`code_challenge\` text not null, \`code_challenge_method\` text check (\`code_challenge_method\` in ('S256', 'plain')) not null default 'S256', \`expired_at\` datetime not null, \`consumed_at\` datetime null, \`auth_time\` integer null, constraint \`oauth_code_client_id_foreign\` foreign key (\`client_id\`) references \`oauth_client\` (\`id\`), constraint \`oauth_code_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`)) /* Issued OAuth authorization codes */;`);
|
|
35
|
+
this.addSql(`create unique index \`oauth_code_code_hash_unique\` on \`oauth_code\` (\`code_hash\`);`);
|
|
36
|
+
this.addSql(`create index \`oauth_code_client_id_index\` on \`oauth_code\` (\`client_id\`);`);
|
|
37
|
+
this.addSql(`create index \`oauth_code_user_sub_index\` on \`oauth_code\` (\`user_sub\`);`);
|
|
38
|
+
this.addSql(`create index \`auth_code_hash_idx\` on \`oauth_code\` (\`code_hash\`);`);
|
|
39
|
+
this.addSql(`create index \`oauth_code_client_consumed_idx\` on \`oauth_code\` (\`client_id\`, \`consumed_at\`);`);
|
|
40
|
+
this.addSql(`create index \`oauth_code_expired_at_idx\` on \`oauth_code\` (\`expired_at\`);`);
|
|
41
|
+
this.addSql(`create table \`email_verification\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`token\` text not null, \`expires_at\` datetime not null, \`verified\` integer not null default false, \`verified_at\` datetime null, constraint \`email_verification_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`)) /* Email verification tokens for user registration */;`);
|
|
42
|
+
this.addSql(`create index \`email_verification_user_sub_idx\` on \`email_verification\` (\`user_sub\`);`);
|
|
43
|
+
this.addSql(`create index \`email_verification_token_idx\` on \`email_verification\` (\`token\`);`);
|
|
44
|
+
this.addSql(`create table \`user_oauth\` (\`id\` integer not null primary key autoincrement, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`provider_name\` text not null, \`provider_user_id\` text not null, \`access_token\` text not null, \`refresh_token\` text not null, \`expires_at\` datetime null, constraint \`user_oauth_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`)) /* OAuth accounts linked to users */;`);
|
|
45
|
+
this.addSql(`create index \`user_oauth_user_sub_idx\` on \`user_oauth\` (\`user_sub\`);`);
|
|
46
|
+
this.addSql(`create index \`user_oauth_user_provider_idx\` on \`user_oauth\` (\`user_sub\`, \`provider_name\`);`);
|
|
47
|
+
this.addSql(`create unique index \`user_oauth_provider_unique\` on \`user_oauth\` (\`provider_name\`, \`provider_user_id\`);`);
|
|
48
|
+
this.addSql(`create table \`user_passkey\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`credential_id\` text not null, \`public_key\` text not null, \`counter\` integer not null default 0, \`device_type\` text not null default 'singleDevice', \`backed_up\` integer not null default false, \`transports\` json null, \`name\` text null, \`aaguid\` text null, constraint \`user_passkey_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`) on delete cascade) /* User passkeys for WebAuthn authentication */;`);
|
|
49
|
+
this.addSql(`create index \`user_passkey_user_sub_idx\` on \`user_passkey\` (\`user_sub\`);`);
|
|
50
|
+
this.addSql(`create index \`user_passkey_credential_id_unique\` on \`user_passkey\` (\`credential_id\`);`);
|
|
51
|
+
this.addSql(`create table \`user_terms_consent\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`terms_id\` text not null, \`terms_version\` text not null, \`agreed\` integer not null, \`consent_type\` text not null, \`agreed_at\` datetime not null, constraint \`user_terms_consent_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`) on delete cascade, constraint \`user_terms_consent_terms_id_foreign\` foreign key (\`terms_id\`) references \`terms\` (\`id\`) on delete cascade) /* User consent records for terms of service */;`);
|
|
52
|
+
this.addSql(`create index \`user_terms_consent_user_sub_index\` on \`user_terms_consent\` (\`user_sub\`);`);
|
|
53
|
+
this.addSql(`create index \`user_terms_consent_terms_id_index\` on \`user_terms_consent\` (\`terms_id\`);`);
|
|
54
|
+
this.addSql(`create index \`user_terms_consent_user_terms_index\` on \`user_terms_consent\` (\`user_sub\`, \`terms_id\`);`);
|
|
55
|
+
this.addSql(`create table \`user_totp\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`secret\` text not null, \`verified\` integer not null default false, \`recovery_confirmed\` integer not null default false, constraint \`user_totp_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`) on delete cascade) /* User TOTP secrets for two-factor authentication */;`);
|
|
56
|
+
this.addSql(`create index \`user_totp_user_sub_index\` on \`user_totp\` (\`user_sub\`);`);
|
|
57
|
+
this.addSql(`create unique index \`user_totp_user_unique\` on \`user_totp\` (\`user_sub\`);`);
|
|
58
|
+
this.addSql(`create table \`user_totp_recovery_code\` (\`id\` text not null primary key, \`created_at\` datetime not null, \`updated_at\` datetime not null, \`user_sub\` text not null, \`code_hash\` text not null, \`used\` integer not null default false, \`used_at\` datetime null, constraint \`user_totp_recovery_code_user_sub_foreign\` foreign key (\`user_sub\`) references \`user\` (\`sub\`) on delete cascade) /* One-time recovery codes for TOTP two-factor authentication */;`);
|
|
59
|
+
this.addSql(`create index \`user_totp_recovery_code_user_sub_idx\` on \`user_totp_recovery_code\` (\`user_sub\`);`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=Migration20260509171226_initial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260509171226_initial.js","sourceRoot":"","sources":["../../../src/migrations/sqlite/Migration20260509171226_initial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,OAAO,+BAAgC,SAAQ,SAAS;IACnD,EAAE;QACT,IAAI,CAAC,MAAM,CACT,oMAAoM,CACrM,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,ggBAAggB,CACjgB,CAAC;QACF,IAAI,CAAC,MAAM,CACT,kEAAkE,CACnE,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,iiBAAiiB,CACliB,CAAC;QACF,IAAI,CAAC,MAAM,CACT,+EAA+E,CAChF,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,6eAA6e,CAC9e,CAAC;QACF,IAAI,CAAC,MAAM,CACT,gHAAgH,CACjH,CAAC;QACF,IAAI,CAAC,MAAM,CACT,6FAA6F,CAC9F,CAAC;QACF,IAAI,CAAC,MAAM,CACT,uGAAuG,CACxG,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,8UAA8U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E,CACzE,CAAC;QACF,IAAI,CAAC,MAAM,CACT,qGAAqG,CACtG,CAAC;QACF,IAAI,CAAC,MAAM,CACT,gFAAgF,CACjF,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,mdAAmd,CACpd,CAAC;QACF,IAAI,CAAC,MAAM,CACT,4FAA4F,CAC7F,CAAC;QACF,IAAI,CAAC,MAAM,CACT,sFAAsF,CACvF,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,geAAge,CACje,CAAC;QACF,IAAI,CAAC,MAAM,CACT,4EAA4E,CAC7E,CAAC;QACF,IAAI,CAAC,MAAM,CACT,oGAAoG,CACrG,CAAC;QACF,IAAI,CAAC,MAAM,CACT,iHAAiH,CAClH,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,2lBAA2lB,CAC5lB,CAAC;QACF,IAAI,CAAC,MAAM,CACT,gFAAgF,CACjF,CAAC;QACF,IAAI,CAAC,MAAM,CACT,6FAA6F,CAC9F,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,knBAAknB,CACnnB,CAAC;QACF,IAAI,CAAC,MAAM,CACT,8FAA8F,CAC/F,CAAC;QACF,IAAI,CAAC,MAAM,CACT,8FAA8F,CAC/F,CAAC;QACF,IAAI,CAAC,MAAM,CACT,8GAA8G,CAC/G,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,0cAA0c,CAC3c,CAAC;QACF,IAAI,CAAC,MAAM,CACT,4EAA4E,CAC7E,CAAC;QACF,IAAI,CAAC,MAAM,CACT,gFAAgF,CACjF,CAAC;QAEF,IAAI,CAAC,MAAM,CACT,odAAod,CACrd,CAAC;QACF,IAAI,CAAC,MAAM,CACT,sGAAsG,CACvG,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,eAAO,MAAM,iBAAiB,4CAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,+BAA+B,CAAC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/core';
|
|
2
2
|
import type { TinyAuthRuntimeConfig } from '../lib/config/index.ts';
|
|
3
3
|
import type { SecurityService } from '../services/security.service.ts';
|
|
4
|
+
export type ConfigSeedMode = 'if-changed' | 'always' | 'skip';
|
|
5
|
+
export declare function seedConfigIfNeeded(em: EntityManager, config: TinyAuthRuntimeConfig, securityService: SecurityService, mode?: ConfigSeedMode): Promise<boolean>;
|
|
4
6
|
/**
|
|
5
7
|
* ConfigSeeder
|
|
6
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.seeder.d.ts","sourceRoot":"","sources":["../../src/seeders/config.seeder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.seeder.d.ts","sourceRoot":"","sources":["../../src/seeders/config.seeder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAKvE,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,CAAC;AA+E9D,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,qBAAqB,EAC7B,eAAe,EAAE,eAAe,EAChC,IAAI,GAAE,cAA6B,GAClC,OAAO,CAAC,OAAO,CAAC,CA6ClB;AAED;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,qBAAqB,EAC7B,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -1,7 +1,94 @@
|
|
|
1
|
+
import { BootstrapStateEntitySchema } from "../entities/bootstrap-state.entity.js";
|
|
1
2
|
import { OAuthClientEntitySchema } from "../entities/oauth-client.entity.js";
|
|
2
3
|
import { TermsEntitySchema } from "../entities/terms.entity.js";
|
|
3
4
|
import { TermsContentEntitySchema } from "../entities/terms-content.entity.js";
|
|
4
5
|
import { UserEntity } from "../entities/user.entity.js";
|
|
6
|
+
import { fromBase64Url, stringToBytes, toArrayBuffer, toBase64Url, } from "../lib/base64url.js";
|
|
7
|
+
const CONFIG_SEED_STATE_ID = 'config-seed';
|
|
8
|
+
const CONFIG_SEED_FINGERPRINT_VERSION = 1;
|
|
9
|
+
function canonicalJson(value) {
|
|
10
|
+
if (value === null) {
|
|
11
|
+
return 'null';
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'string' ||
|
|
14
|
+
typeof value === 'number' ||
|
|
15
|
+
typeof value === 'boolean') {
|
|
16
|
+
return JSON.stringify(value);
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
return `[${value.map((item) => canonicalJson(item)).join(',')}]`;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === 'object') {
|
|
22
|
+
const entries = Object.entries(value)
|
|
23
|
+
.filter((entry) => entry[1] !== undefined)
|
|
24
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
25
|
+
return `{${entries
|
|
26
|
+
.map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`)
|
|
27
|
+
.join(',')}}`;
|
|
28
|
+
}
|
|
29
|
+
return 'null';
|
|
30
|
+
}
|
|
31
|
+
async function createConfigSeedFingerprint(config) {
|
|
32
|
+
const payload = canonicalJson({
|
|
33
|
+
version: CONFIG_SEED_FINGERPRINT_VERSION,
|
|
34
|
+
pbkdf2_iterations: config.security.pbkdf2_iterations,
|
|
35
|
+
terms: config.terms,
|
|
36
|
+
users: config.users,
|
|
37
|
+
clients: config.clients,
|
|
38
|
+
});
|
|
39
|
+
const keyBytes = fromBase64Url(config.security.hash_secret);
|
|
40
|
+
const key = await crypto.subtle.importKey('raw', toArrayBuffer(keyBytes), {
|
|
41
|
+
name: 'HMAC',
|
|
42
|
+
hash: 'SHA-256',
|
|
43
|
+
}, false, ['sign']);
|
|
44
|
+
const signature = await crypto.subtle.sign('HMAC', key, toArrayBuffer(stringToBytes(payload)));
|
|
45
|
+
return `v${CONFIG_SEED_FINGERPRINT_VERSION}:${toBase64Url(new Uint8Array(signature))}`;
|
|
46
|
+
}
|
|
47
|
+
function isMissingBootstrapStateTableError(err) {
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
const normalized = message.toLowerCase();
|
|
50
|
+
return (normalized.includes('bootstrap_state') &&
|
|
51
|
+
(normalized.includes('no such table') ||
|
|
52
|
+
normalized.includes('does not exist') ||
|
|
53
|
+
normalized.includes('not found')));
|
|
54
|
+
}
|
|
55
|
+
export async function seedConfigIfNeeded(em, config, securityService, mode = 'if-changed') {
|
|
56
|
+
if (mode === 'skip') {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (mode === 'always') {
|
|
60
|
+
await seedConfig(em, config, securityService);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const fingerprint = await createConfigSeedFingerprint(config);
|
|
64
|
+
try {
|
|
65
|
+
const state = await em.findOne(BootstrapStateEntitySchema, {
|
|
66
|
+
id: CONFIG_SEED_STATE_ID,
|
|
67
|
+
});
|
|
68
|
+
if (state?.value === fingerprint) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (!isMissingBootstrapStateTableError(err)) {
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
await seedConfig(em, config, securityService);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
await seedConfig(em, config, securityService);
|
|
80
|
+
await em.upsert(BootstrapStateEntitySchema, {
|
|
81
|
+
id: CONFIG_SEED_STATE_ID,
|
|
82
|
+
value: fingerprint,
|
|
83
|
+
created_at: new Date(),
|
|
84
|
+
updated_at: new Date(),
|
|
85
|
+
}, {
|
|
86
|
+
onConflictFields: ['id'],
|
|
87
|
+
onConflictAction: 'merge',
|
|
88
|
+
onConflictExcludeFields: ['id', 'created_at'],
|
|
89
|
+
});
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
5
92
|
/**
|
|
6
93
|
* ConfigSeeder
|
|
7
94
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.seeder.js","sourceRoot":"","sources":["../../src/seeders/config.seeder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.seeder.js","sourceRoot":"","sources":["../../src/seeders/config.seeder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,aAAa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EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TinyAuthRuntimeConfig } from '../lib/config/index.ts';
|
|
2
2
|
import type { Logger } from '../lib/logger.ts';
|
|
3
|
+
import { type ConfigSeedMode } from '../seeders/config.seeder.ts';
|
|
3
4
|
import { CleanupService } from './cleanup.service.ts';
|
|
4
5
|
import { EmailService } from './email.service.ts';
|
|
5
6
|
import { JwtService } from './jwt.service.ts';
|
|
@@ -17,7 +18,10 @@ import { TermsService } from './terms.service.ts';
|
|
|
17
18
|
import { TotpService } from './totp.service.ts';
|
|
18
19
|
import { UserService } from './user.service.ts';
|
|
19
20
|
import { UserConsentService } from './user-consent.service.ts';
|
|
20
|
-
export
|
|
21
|
+
export interface InitializeServicesOptions {
|
|
22
|
+
seedConfig?: ConfigSeedMode;
|
|
23
|
+
}
|
|
24
|
+
export declare function initializeServices(config: TinyAuthRuntimeConfig, logger: Logger, options?: InitializeServicesOptions): Promise<{
|
|
21
25
|
services: {
|
|
22
26
|
config: {
|
|
23
27
|
server: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/services/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/services/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,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U,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { seedConfigIfNeeded, } from "../seeders/config.seeder.js";
|
|
2
2
|
import { CleanupService } from "./cleanup.service.js";
|
|
3
3
|
import { EmailService } from "./email.service.js";
|
|
4
4
|
import { JwtService } from "./jwt.service.js";
|
|
@@ -16,16 +16,17 @@ import { TermsService } from "./terms.service.js";
|
|
|
16
16
|
import { TotpService } from "./totp.service.js";
|
|
17
17
|
import { UserService } from "./user.service.js";
|
|
18
18
|
import { UserConsentService } from "./user-consent.service.js";
|
|
19
|
-
export async function initializeServices(config, logger) {
|
|
19
|
+
export async function initializeServices(config, logger, options = {}) {
|
|
20
20
|
const securityService = new SecurityService(config);
|
|
21
21
|
// 1. Initialize MikroORM
|
|
22
22
|
const mikroLogger = logger.child({ service: 'mikro' });
|
|
23
23
|
const mikro = await MikroService.initialize(config, mikroLogger);
|
|
24
24
|
// 2. Bootstrap: seed config users/clients
|
|
25
|
-
await
|
|
25
|
+
const seeded = await seedConfigIfNeeded(mikro.orm.em.fork(), config, securityService, options.seedConfig);
|
|
26
26
|
logger.info({
|
|
27
27
|
users: config.users.length,
|
|
28
28
|
clients: config.clients.length,
|
|
29
|
+
seeded,
|
|
29
30
|
}, 'Bootstrap complete');
|
|
30
31
|
// 3. Create services (respecting dependency order)
|
|
31
32
|
const emailLogger = logger.child({ service: 'email' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/services/container.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/services/container.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM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qB,GAAG,IAAI,qBAAqB,CACrD,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,CAChB,CAAC;IACF,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,CACjD,MAAM,EACN,WAAW,EACX,KAAK,EACL,YAAY,CACb,CAAC;IACF,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAC7C,MAAM,EACN,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,eAAe,CAChB,CAAC;IACF,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAErE,eAAe;IACf,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,IAAI,gBAAgB,CACpC,MAAM,CAAC,SAAS,EAChB,cAAc,EACd,eAAe,CAChB,CAAC;IAEF,MAAM,QAAQ,GAAG;QACf,MAAM;QACN,eAAe;QACf,KAAK;QACL,SAAS;QACT,YAAY;QACZ,UAAU;QACV,mBAAmB;QACnB,oBAAoB;QACpB,YAAY;QACZ,kBAAkB;QAClB,kBAAkB;QAClB,WAAW;QACX,cAAc;QACd,WAAW;QACX,qBAAqB;QACrB,mBAAmB;QACnB,iBAAiB;QACjB,cAAc;KACf,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinyrack/tinyauth-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenID Connect Provider with OAuth2 support",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,181 +13,130 @@
|
|
|
13
13
|
"public",
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
|
-
"publishConfig": {
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./dist/entrypoints/index.d.ts",
|
|
20
|
-
"default": "./dist/entrypoints/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./config": {
|
|
23
|
-
"types": "./dist/entrypoints/config/index.d.ts",
|
|
24
|
-
"default": "./dist/entrypoints/config/index.js"
|
|
25
|
-
},
|
|
26
|
-
"./services": {
|
|
27
|
-
"types": "./dist/entrypoints/services.d.ts",
|
|
28
|
-
"default": "./dist/entrypoints/services.js"
|
|
29
|
-
},
|
|
30
|
-
"./database/postgres": {
|
|
31
|
-
"types": "./dist/entrypoints/database/postgres/postgres.d.ts",
|
|
32
|
-
"default": "./dist/entrypoints/database/postgres/postgres.js"
|
|
33
|
-
},
|
|
34
|
-
"./database/sqlite": {
|
|
35
|
-
"types": "./dist/entrypoints/database/sqlite/sqlite.d.ts",
|
|
36
|
-
"default": "./dist/entrypoints/database/sqlite/sqlite.js"
|
|
37
|
-
},
|
|
38
|
-
"./database/d1": {
|
|
39
|
-
"types": "./dist/entrypoints/database/d1/d1.d.ts",
|
|
40
|
-
"default": "./dist/entrypoints/database/d1/d1.js"
|
|
41
|
-
},
|
|
42
|
-
"./mail/nodemailer": {
|
|
43
|
-
"types": "./dist/entrypoints/mail/nodemailer.d.ts",
|
|
44
|
-
"default": "./dist/entrypoints/mail/nodemailer.js"
|
|
45
|
-
},
|
|
46
|
-
"./scheduler/croner": {
|
|
47
|
-
"types": "./dist/entrypoints/scheduler/croner.d.ts",
|
|
48
|
-
"default": "./dist/entrypoints/scheduler/croner.js"
|
|
49
|
-
},
|
|
50
|
-
"./identity-providers/github": {
|
|
51
|
-
"types": "./dist/entrypoints/identity-providers/github.d.ts",
|
|
52
|
-
"default": "./dist/entrypoints/identity-providers/github.js"
|
|
53
|
-
},
|
|
54
|
-
"./identity-providers/google": {
|
|
55
|
-
"types": "./dist/entrypoints/identity-providers/google.d.ts",
|
|
56
|
-
"default": "./dist/entrypoints/identity-providers/google.js"
|
|
57
|
-
},
|
|
58
|
-
"./identity-providers/apple": {
|
|
59
|
-
"types": "./dist/entrypoints/identity-providers/apple.d.ts",
|
|
60
|
-
"default": "./dist/entrypoints/identity-providers/apple.js"
|
|
61
|
-
},
|
|
62
|
-
"./identity-providers/generic-oauth": {
|
|
63
|
-
"types": "./dist/entrypoints/identity-providers/generic-oauth.d.ts",
|
|
64
|
-
"default": "./dist/entrypoints/identity-providers/generic-oauth.js"
|
|
65
|
-
},
|
|
66
|
-
"./frontend": {
|
|
67
|
-
"types": "./dist/entrypoints/frontend/index.d.ts",
|
|
68
|
-
"default": "./dist/entrypoints/frontend/index.js"
|
|
69
|
-
},
|
|
70
|
-
"./frontend/static": {
|
|
71
|
-
"types": "./dist/entrypoints/frontend/static.d.ts",
|
|
72
|
-
"default": "./dist/entrypoints/frontend/static.js"
|
|
73
|
-
},
|
|
74
|
-
"./frontend/proxy": {
|
|
75
|
-
"types": "./dist/entrypoints/frontend/proxy.d.ts",
|
|
76
|
-
"default": "./dist/entrypoints/frontend/proxy.js"
|
|
77
|
-
},
|
|
78
|
-
"./frontend/cloudflare": {
|
|
79
|
-
"types": "./dist/entrypoints/frontend/cloudflare.d.ts",
|
|
80
|
-
"default": "./dist/entrypoints/frontend/cloudflare.js"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"imports": {
|
|
84
|
-
"#server/*.ts": "./dist/*.js",
|
|
85
|
-
"#server/*.tsx": "./dist/*.js",
|
|
86
|
-
"#server/*": {
|
|
87
|
-
"types": "./dist/*",
|
|
88
|
-
"default": "./dist/*"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
16
|
"exports": {
|
|
93
17
|
".": {
|
|
94
|
-
"@tinyauth/source": "./src/entrypoints/index.ts",
|
|
95
18
|
"types": "./dist/entrypoints/index.d.ts",
|
|
96
19
|
"default": "./dist/entrypoints/index.js"
|
|
97
20
|
},
|
|
98
21
|
"./config": {
|
|
99
|
-
"@tinyauth/source": "./src/entrypoints/config/index.ts",
|
|
100
22
|
"types": "./dist/entrypoints/config/index.d.ts",
|
|
101
23
|
"default": "./dist/entrypoints/config/index.js"
|
|
102
24
|
},
|
|
103
25
|
"./services": {
|
|
104
|
-
"@tinyauth/source": "./src/entrypoints/services.ts",
|
|
105
26
|
"types": "./dist/entrypoints/services.d.ts",
|
|
106
27
|
"default": "./dist/entrypoints/services.js"
|
|
107
28
|
},
|
|
108
29
|
"./database/postgres": {
|
|
109
|
-
"@tinyauth/source": "./src/entrypoints/database/postgres/postgres.ts",
|
|
110
30
|
"types": "./dist/entrypoints/database/postgres/postgres.d.ts",
|
|
111
31
|
"default": "./dist/entrypoints/database/postgres/postgres.js"
|
|
112
32
|
},
|
|
113
33
|
"./database/sqlite": {
|
|
114
|
-
"@tinyauth/source": "./src/entrypoints/database/sqlite/sqlite.ts",
|
|
115
34
|
"types": "./dist/entrypoints/database/sqlite/sqlite.d.ts",
|
|
116
35
|
"default": "./dist/entrypoints/database/sqlite/sqlite.js"
|
|
117
36
|
},
|
|
118
37
|
"./database/d1": {
|
|
119
|
-
"@tinyauth/source": "./src/entrypoints/database/d1/d1.ts",
|
|
120
38
|
"types": "./dist/entrypoints/database/d1/d1.d.ts",
|
|
121
39
|
"default": "./dist/entrypoints/database/d1/d1.js"
|
|
122
40
|
},
|
|
123
41
|
"./mail/nodemailer": {
|
|
124
|
-
"@tinyauth/source": "./src/entrypoints/mail/nodemailer.ts",
|
|
125
42
|
"types": "./dist/entrypoints/mail/nodemailer.d.ts",
|
|
126
43
|
"default": "./dist/entrypoints/mail/nodemailer.js"
|
|
127
44
|
},
|
|
128
45
|
"./scheduler/croner": {
|
|
129
|
-
"@tinyauth/source": "./src/entrypoints/scheduler/croner.ts",
|
|
130
46
|
"types": "./dist/entrypoints/scheduler/croner.d.ts",
|
|
131
47
|
"default": "./dist/entrypoints/scheduler/croner.js"
|
|
132
48
|
},
|
|
133
49
|
"./identity-providers/github": {
|
|
134
|
-
"@tinyauth/source": "./src/entrypoints/identity-providers/github.ts",
|
|
135
50
|
"types": "./dist/entrypoints/identity-providers/github.d.ts",
|
|
136
51
|
"default": "./dist/entrypoints/identity-providers/github.js"
|
|
137
52
|
},
|
|
138
53
|
"./identity-providers/google": {
|
|
139
|
-
"@tinyauth/source": "./src/entrypoints/identity-providers/google.ts",
|
|
140
54
|
"types": "./dist/entrypoints/identity-providers/google.d.ts",
|
|
141
55
|
"default": "./dist/entrypoints/identity-providers/google.js"
|
|
142
56
|
},
|
|
143
57
|
"./identity-providers/apple": {
|
|
144
|
-
"@tinyauth/source": "./src/entrypoints/identity-providers/apple.ts",
|
|
145
58
|
"types": "./dist/entrypoints/identity-providers/apple.d.ts",
|
|
146
59
|
"default": "./dist/entrypoints/identity-providers/apple.js"
|
|
147
60
|
},
|
|
148
61
|
"./identity-providers/generic-oauth": {
|
|
149
|
-
"@tinyauth/source": "./src/entrypoints/identity-providers/generic-oauth.ts",
|
|
150
62
|
"types": "./dist/entrypoints/identity-providers/generic-oauth.d.ts",
|
|
151
63
|
"default": "./dist/entrypoints/identity-providers/generic-oauth.js"
|
|
152
64
|
},
|
|
153
65
|
"./frontend": {
|
|
154
|
-
"@tinyauth/source": "./src/entrypoints/frontend/index.ts",
|
|
155
66
|
"types": "./dist/entrypoints/frontend/index.d.ts",
|
|
156
67
|
"default": "./dist/entrypoints/frontend/index.js"
|
|
157
68
|
},
|
|
158
69
|
"./frontend/static": {
|
|
159
|
-
"@tinyauth/source": "./src/entrypoints/frontend/static.ts",
|
|
160
70
|
"types": "./dist/entrypoints/frontend/static.d.ts",
|
|
161
71
|
"default": "./dist/entrypoints/frontend/static.js"
|
|
162
72
|
},
|
|
163
73
|
"./frontend/proxy": {
|
|
164
|
-
"@tinyauth/source": "./src/entrypoints/frontend/proxy.ts",
|
|
165
74
|
"types": "./dist/entrypoints/frontend/proxy.d.ts",
|
|
166
75
|
"default": "./dist/entrypoints/frontend/proxy.js"
|
|
167
76
|
},
|
|
168
77
|
"./frontend/cloudflare": {
|
|
169
|
-
"@tinyauth/source": "./src/entrypoints/frontend/cloudflare.ts",
|
|
170
78
|
"types": "./dist/entrypoints/frontend/cloudflare.d.ts",
|
|
171
79
|
"default": "./dist/entrypoints/frontend/cloudflare.js"
|
|
172
80
|
}
|
|
173
81
|
},
|
|
174
82
|
"imports": {
|
|
175
|
-
"#server/*.ts":
|
|
176
|
-
|
|
177
|
-
"types": "./dist/*.d.ts",
|
|
178
|
-
"default": "./dist/*.js"
|
|
179
|
-
},
|
|
180
|
-
"#server/*.tsx": {
|
|
181
|
-
"@tinyauth/source": "./src/*.tsx",
|
|
182
|
-
"types": "./dist/*.d.ts",
|
|
183
|
-
"default": "./dist/*.js"
|
|
184
|
-
},
|
|
83
|
+
"#server/*.ts": "./dist/*.js",
|
|
84
|
+
"#server/*.tsx": "./dist/*.js",
|
|
185
85
|
"#server/*": {
|
|
186
|
-
"@tinyauth/source": "./src/*",
|
|
187
86
|
"types": "./dist/*",
|
|
188
87
|
"default": "./dist/*"
|
|
189
88
|
}
|
|
190
89
|
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@biomejs/biome": "^2.4.14",
|
|
92
|
+
"@react-email/preview-server": "^5.2.10",
|
|
93
|
+
"@types/node": "^24.12.3",
|
|
94
|
+
"@types/nodemailer": "^8.0.0",
|
|
95
|
+
"@types/pg": "^8.20.0",
|
|
96
|
+
"@types/qrcode": "^1.5.6",
|
|
97
|
+
"@cloudflare/workers-types": "^4.20260508.1",
|
|
98
|
+
"@types/react": "^19.2.14",
|
|
99
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
100
|
+
"tsx": "^4.21.0",
|
|
101
|
+
"typescript": "^6.0.3",
|
|
102
|
+
"vitest": "^4.1.5",
|
|
103
|
+
"wrangler": "^4.90.0"
|
|
104
|
+
},
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@hono/standard-validator": "^0.2.2",
|
|
107
|
+
"@mikro-orm/cli": "^7.0.14",
|
|
108
|
+
"@mikro-orm/core": "^7.0.14",
|
|
109
|
+
"@mikro-orm/decorators": "^7.0.14",
|
|
110
|
+
"@mikro-orm/migrations": "^7.0.14",
|
|
111
|
+
"@mikro-orm/postgresql": "^7.0.14",
|
|
112
|
+
"@mikro-orm/seeder": "^7.0.14",
|
|
113
|
+
"@mikro-orm/sql": "^7.0.14",
|
|
114
|
+
"@react-email/components": "^1.0.12",
|
|
115
|
+
"@react-email/render": "^2.0.8",
|
|
116
|
+
"@react-email/tailwind": "^2.0.7",
|
|
117
|
+
"@scalar/hono-api-reference": "^0.10.14",
|
|
118
|
+
"@simplewebauthn/server": "^13.3.0",
|
|
119
|
+
"croner": "^10.0.1",
|
|
120
|
+
"hono": "^4.12.18",
|
|
121
|
+
"hono-openapi": "^1.3.0",
|
|
122
|
+
"jose": "^6.2.3",
|
|
123
|
+
"kysely": "^0.28.17",
|
|
124
|
+
"kysely-d1": "^0.4.0",
|
|
125
|
+
"pino-pretty": "^13.1.3",
|
|
126
|
+
"react-email": "^6.1.1",
|
|
127
|
+
"nodemailer": "^8.0.7",
|
|
128
|
+
"otplib": "^13.4.0",
|
|
129
|
+
"pg": "^8.20.0",
|
|
130
|
+
"pino": "^10.3.1",
|
|
131
|
+
"qrcode": "^1.5.4",
|
|
132
|
+
"react": "^19.2.5",
|
|
133
|
+
"zod": "^4.4.3"
|
|
134
|
+
},
|
|
135
|
+
"mikro-orm": {
|
|
136
|
+
"configPaths": [
|
|
137
|
+
"./src/entrypoints/database/sqlite/cli.ts"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
191
140
|
"scripts": {
|
|
192
141
|
"test": "NODE_OPTIONS='--conditions=@tinyauth/source' vitest",
|
|
193
142
|
"test:coverage": "rm -rf coverage && NODE_OPTIONS='--conditions=@tinyauth/source' vitest run --coverage --maxWorkers=1",
|
|
@@ -196,61 +145,16 @@
|
|
|
196
145
|
"build:watch": "tsc -b -w tsconfig.json",
|
|
197
146
|
"email:preview": "email dev --dir src/emails/templates --port 3001",
|
|
198
147
|
"mikro-orm": "mikro-orm",
|
|
148
|
+
"mikro-orm:postgres": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/postgres/cli.ts",
|
|
149
|
+
"mikro-orm:sqlite": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/sqlite/cli.ts",
|
|
150
|
+
"mikro-orm:d1": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/d1/cli.ts",
|
|
199
151
|
"mikro-orm:compile": "pnpm run mikro-orm:compile:postgres && pnpm run mikro-orm:compile:sqlite && pnpm run mikro-orm:compile:d1",
|
|
200
152
|
"mikro-orm:compile:postgres": "mikro-orm compile --config ./src/entrypoints/database/postgres/cli.ts",
|
|
201
153
|
"mikro-orm:compile:sqlite": "mikro-orm compile --config ./src/entrypoints/database/sqlite/cli.ts",
|
|
202
154
|
"mikro-orm:compile:d1": "mikro-orm compile --config ./src/entrypoints/database/d1/cli.ts",
|
|
203
155
|
"mikro-orm:debug": "mikro-orm debug",
|
|
204
|
-
"mikro-orm:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"@biomejs/biome": "catalog:",
|
|
208
|
-
"@react-email/preview-server": "catalog:",
|
|
209
|
-
"@types/node": "catalog:",
|
|
210
|
-
"@types/nodemailer": "catalog:",
|
|
211
|
-
"@types/pg": "catalog:",
|
|
212
|
-
"@types/qrcode": "catalog:",
|
|
213
|
-
"@cloudflare/workers-types": "catalog:",
|
|
214
|
-
"@types/react": "catalog:",
|
|
215
|
-
"@vitest/coverage-v8": "catalog:",
|
|
216
|
-
"tsx": "catalog:",
|
|
217
|
-
"typescript": "catalog:",
|
|
218
|
-
"vitest": "catalog:",
|
|
219
|
-
"wrangler": "catalog:"
|
|
220
|
-
},
|
|
221
|
-
"dependencies": {
|
|
222
|
-
"@hono/standard-validator": "catalog:",
|
|
223
|
-
"@mikro-orm/cli": "catalog:",
|
|
224
|
-
"@mikro-orm/core": "catalog:",
|
|
225
|
-
"@mikro-orm/decorators": "catalog:",
|
|
226
|
-
"@mikro-orm/migrations": "catalog:",
|
|
227
|
-
"@mikro-orm/postgresql": "catalog:",
|
|
228
|
-
"@mikro-orm/seeder": "catalog:",
|
|
229
|
-
"@mikro-orm/sql": "catalog:",
|
|
230
|
-
"@react-email/components": "catalog:",
|
|
231
|
-
"@react-email/render": "catalog:",
|
|
232
|
-
"@react-email/tailwind": "catalog:",
|
|
233
|
-
"@scalar/hono-api-reference": "catalog:",
|
|
234
|
-
"@simplewebauthn/server": "catalog:",
|
|
235
|
-
"croner": "catalog:",
|
|
236
|
-
"hono": "catalog:",
|
|
237
|
-
"hono-openapi": "catalog:",
|
|
238
|
-
"jose": "catalog:",
|
|
239
|
-
"kysely": "catalog:",
|
|
240
|
-
"kysely-d1": "catalog:",
|
|
241
|
-
"pino-pretty": "catalog:",
|
|
242
|
-
"react-email": "catalog:",
|
|
243
|
-
"nodemailer": "catalog:",
|
|
244
|
-
"otplib": "catalog:",
|
|
245
|
-
"pg": "catalog:",
|
|
246
|
-
"pino": "catalog:",
|
|
247
|
-
"qrcode": "catalog:",
|
|
248
|
-
"react": "catalog:",
|
|
249
|
-
"zod": "catalog:"
|
|
250
|
-
},
|
|
251
|
-
"mikro-orm": {
|
|
252
|
-
"configPaths": [
|
|
253
|
-
"./src/entrypoints/database/sqlite/cli.ts"
|
|
254
|
-
]
|
|
156
|
+
"mikro-orm:migration:create:postgres": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/postgres/cli.ts migration:create",
|
|
157
|
+
"mikro-orm:migration:create:sqlite": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/sqlite/cli.ts migration:create",
|
|
158
|
+
"mikro-orm:migration:create:d1": "node ./scripts/mikro-orm-configured.mjs ./src/entrypoints/database/d1/cli.ts migration:create"
|
|
255
159
|
}
|
|
256
|
-
}
|
|
160
|
+
}
|