@adonis-agora/authkit-server 0.81.2 → 0.82.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 +1 -1
- package/build/database/migrations/make_authkit_oidc_table.js +3 -0
- package/build/src/adapters/adapter_contract.d.ts +12 -0
- package/build/src/adapters/database_adapter.d.ts +10 -0
- package/build/src/adapters/database_adapter.js +172 -7
- package/build/src/adapters/redis_adapter.d.ts +1 -1
- package/build/src/adapters/redis_adapter.js +9 -6
- package/build/src/host/admin_sessions_service.js +46 -34
- package/build/src/host/durable/account_deletion_workflow.d.ts +5 -1
- package/build/src/host/durable/account_deletion_workflow.js +3 -2
- package/build/src/host/durable/account_export_workflow.d.ts +4 -0
- package/build/src/host/durable/account_export_workflow.js +2 -1
- package/build/src/host/durable/index.d.ts +2 -2
- package/build/src/host/durable/index.js +5 -4
- package/build/src/host/durable/package_origin.d.ts +7 -0
- package/build/src/host/durable/package_origin.js +7 -0
- package/build/src/host/runtime_settings.d.ts +5 -3
- package/build/src/host/runtime_settings.js +34 -7
- package/build/src/host/ui-dist/assets/index-d00IbXWz.js +155 -0
- package/build/src/host/ui-dist/index.html +1 -1
- package/build/src/pat/lucid_pat_store.js +9 -3
- package/build/src/pat/pat_store.d.ts +1 -0
- package/build/src/schema/ensure.d.ts +5 -0
- package/build/src/schema/ensure.js +130 -4
- package/package.json +13 -10
- package/skills/authkit-idp-setup/SKILL.md +6 -2
- package/build/src/host/ui-dist/assets/index-CIv26Mfg.js +0 -155
|
@@ -57,6 +57,24 @@ import { isSettingLocked, SettingLockedError } from './config_locks.js';
|
|
|
57
57
|
export function supportsSettings(obj) {
|
|
58
58
|
return !!obj && typeof obj.getSetting === 'function';
|
|
59
59
|
}
|
|
60
|
+
const sharedStates = new WeakMap();
|
|
61
|
+
function sharedStateFor(db, connection) {
|
|
62
|
+
const fresh = () => ({ cache: new Map(), tablePresent: null, tableAbsentUntil: 0 });
|
|
63
|
+
if (!db || (typeof db !== 'object' && typeof db !== 'function'))
|
|
64
|
+
return fresh();
|
|
65
|
+
let byConnection = sharedStates.get(db);
|
|
66
|
+
if (!byConnection) {
|
|
67
|
+
byConnection = new Map();
|
|
68
|
+
sharedStates.set(db, byConnection);
|
|
69
|
+
}
|
|
70
|
+
const name = connection ?? '';
|
|
71
|
+
let state = byConnection.get(name);
|
|
72
|
+
if (!state) {
|
|
73
|
+
state = fresh();
|
|
74
|
+
byConnection.set(name, state);
|
|
75
|
+
}
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
60
78
|
/** Chave de cache: combina key + escopo de org (null = global). */
|
|
61
79
|
function cacheKey(key, orgId) {
|
|
62
80
|
return orgId ? `${key}\x00${orgId}` : key;
|
|
@@ -70,13 +88,15 @@ export class RuntimeSettings {
|
|
|
70
88
|
db;
|
|
71
89
|
ttlMs;
|
|
72
90
|
connectionName;
|
|
73
|
-
|
|
74
|
-
/** null = não foi verificado ainda; false = tabela ausente; true = presente */
|
|
75
|
-
tablePresent = null;
|
|
91
|
+
shared;
|
|
76
92
|
constructor(db, opts = {}) {
|
|
77
93
|
this.db = db;
|
|
78
94
|
this.ttlMs = opts.ttlMs ?? 15_000;
|
|
79
95
|
this.connectionName = opts.connection;
|
|
96
|
+
this.shared = sharedStateFor(db, opts.connection);
|
|
97
|
+
}
|
|
98
|
+
get cache() {
|
|
99
|
+
return this.shared.cache;
|
|
80
100
|
}
|
|
81
101
|
/**
|
|
82
102
|
* Retorna o objeto de conexão Lucid correto.
|
|
@@ -96,17 +116,24 @@ export class RuntimeSettings {
|
|
|
96
116
|
* detecta a tabela corretamente independente do schema.
|
|
97
117
|
*
|
|
98
118
|
* Fail-safe: qualquer erro → false (tabela considerada ausente, sem lançar).
|
|
119
|
+
* "Presente" vale pela vida do processo; "ausente" é re-verificado após o TTL,
|
|
120
|
+
* para que uma migração rodada com o app no ar (ou um erro transitório) não
|
|
121
|
+
* desligue as settings até o restart.
|
|
99
122
|
*/
|
|
100
123
|
async hasTable() {
|
|
101
|
-
|
|
102
|
-
|
|
124
|
+
const shared = this.shared;
|
|
125
|
+
if (shared.tablePresent === true)
|
|
126
|
+
return true;
|
|
127
|
+
if (shared.tablePresent === false && shared.tableAbsentUntil > Date.now())
|
|
128
|
+
return false;
|
|
103
129
|
try {
|
|
104
130
|
await this.conn().from('auth_settings').select('key').limit(1);
|
|
105
|
-
|
|
131
|
+
shared.tablePresent = true;
|
|
106
132
|
return true;
|
|
107
133
|
}
|
|
108
134
|
catch {
|
|
109
|
-
|
|
135
|
+
shared.tablePresent = false;
|
|
136
|
+
shared.tableAbsentUntil = Date.now() + this.ttlMs;
|
|
110
137
|
return false;
|
|
111
138
|
}
|
|
112
139
|
}
|