@adonis-agora/config 0.0.0-bootstrap.0 → 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.
- package/CHANGELOG.md +42 -0
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/assets/spa/assets/index-CAHRPNZj.js +50 -0
- package/dist/assets/spa/assets/index-CAHRPNZj.js.map +1 -0
- package/dist/assets/spa/assets/index-Cvjcgc6i.css +1 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-CRt88UEn.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-OW7qkl5a.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-01eiPEn0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-w58xtEt9.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-1_7fyUAY.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-Cdg4DaK0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-9waGdLWo.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-BKPfQAnC.woff +0 -0
- package/dist/assets/spa/index.html +20 -0
- package/dist/commands/agora_doctor.d.ts +23 -0
- package/dist/commands/agora_doctor.d.ts.map +1 -0
- package/dist/commands/agora_doctor.js +120 -0
- package/dist/commands/agora_doctor.js.map +1 -0
- package/dist/commands/config.d.ts +100 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +447 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/crypto.d.ts +17 -0
- package/dist/commands/crypto.d.ts.map +1 -0
- package/dist/commands/crypto.js +89 -0
- package/dist/commands/crypto.js.map +1 -0
- package/dist/commands/main.d.ts +16 -0
- package/dist/commands/main.d.ts.map +1 -0
- package/dist/commands/main.js +31 -0
- package/dist/commands/main.js.map +1 -0
- package/dist/commands/pull.d.ts +36 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +262 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/shared.d.ts +33 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +134 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/tenant_key.d.ts +22 -0
- package/dist/commands/tenant_key.d.ts.map +1 -0
- package/dist/commands/tenant_key.js +141 -0
- package/dist/commands/tenant_key.js.map +1 -0
- package/dist/configure.d.ts +13 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +33 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/config_provider.d.ts +31 -0
- package/dist/providers/config_provider.d.ts.map +1 -0
- package/dist/providers/config_provider.js +458 -0
- package/dist/providers/config_provider.js.map +1 -0
- package/dist/services/main.d.ts +39 -0
- package/dist/services/main.d.ts.map +1 -0
- package/dist/services/main.js +67 -0
- package/dist/services/main.js.map +1 -0
- package/dist/src/admin.d.ts +110 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/admin.js +326 -0
- package/dist/src/admin.js.map +1 -0
- package/dist/src/bootstrap.d.ts +35 -0
- package/dist/src/bootstrap.d.ts.map +1 -0
- package/dist/src/bootstrap.js +35 -0
- package/dist/src/bootstrap.js.map +1 -0
- package/dist/src/crypto/secrets.d.ts +67 -0
- package/dist/src/crypto/secrets.d.ts.map +1 -0
- package/dist/src/crypto/secrets.js +100 -0
- package/dist/src/crypto/secrets.js.map +1 -0
- package/dist/src/crypto/tenant_keys.d.ts +49 -0
- package/dist/src/crypto/tenant_keys.d.ts.map +1 -0
- package/dist/src/crypto/tenant_keys.js +134 -0
- package/dist/src/crypto/tenant_keys.js.map +1 -0
- package/dist/src/crypto-kit/asymmetric.d.ts +61 -0
- package/dist/src/crypto-kit/asymmetric.d.ts.map +1 -0
- package/dist/src/crypto-kit/asymmetric.js +201 -0
- package/dist/src/crypto-kit/asymmetric.js.map +1 -0
- package/dist/src/crypto-kit/index.d.ts +5 -0
- package/dist/src/crypto-kit/index.d.ts.map +1 -0
- package/dist/src/crypto-kit/index.js +6 -0
- package/dist/src/crypto-kit/index.js.map +1 -0
- package/dist/src/crypto-kit/keyring.d.ts +52 -0
- package/dist/src/crypto-kit/keyring.d.ts.map +1 -0
- package/dist/src/crypto-kit/keyring.js +36 -0
- package/dist/src/crypto-kit/keyring.js.map +1 -0
- package/dist/src/crypto-kit/kms.d.ts +18 -0
- package/dist/src/crypto-kit/kms.d.ts.map +1 -0
- package/dist/src/crypto-kit/kms.js +29 -0
- package/dist/src/crypto-kit/kms.js.map +1 -0
- package/dist/src/crypto-kit/seal.d.ts +39 -0
- package/dist/src/crypto-kit/seal.d.ts.map +1 -0
- package/dist/src/crypto-kit/seal.js +159 -0
- package/dist/src/crypto-kit/seal.js.map +1 -0
- package/dist/src/dashboard/access_denied_page.d.ts +100 -0
- package/dist/src/dashboard/access_denied_page.d.ts.map +1 -0
- package/dist/src/dashboard/access_denied_page.js +262 -0
- package/dist/src/dashboard/access_denied_page.js.map +1 -0
- package/dist/src/dashboard/actor.d.ts +14 -0
- package/dist/src/dashboard/actor.d.ts.map +1 -0
- package/dist/src/dashboard/actor.js +60 -0
- package/dist/src/dashboard/actor.js.map +1 -0
- package/dist/src/dashboard/console.d.ts +71 -0
- package/dist/src/dashboard/console.d.ts.map +1 -0
- package/dist/src/dashboard/console.js +456 -0
- package/dist/src/dashboard/console.js.map +1 -0
- package/dist/src/dashboard/console_authorize.d.ts +91 -0
- package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
- package/dist/src/dashboard/console_authorize.js +154 -0
- package/dist/src/dashboard/console_authorize.js.map +1 -0
- package/dist/src/dashboard/console_shell.d.ts +49 -0
- package/dist/src/dashboard/console_shell.d.ts.map +1 -0
- package/dist/src/dashboard/console_shell.js +183 -0
- package/dist/src/dashboard/console_shell.js.map +1 -0
- package/dist/src/dashboard/console_switcher.d.ts +92 -0
- package/dist/src/dashboard/console_switcher.d.ts.map +1 -0
- package/dist/src/dashboard/console_switcher.js +188 -0
- package/dist/src/dashboard/console_switcher.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +54 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -0
- package/dist/src/dashboard/define_config.js +29 -0
- package/dist/src/dashboard/define_config.js.map +1 -0
- package/dist/src/dashboard/spa.d.ts +42 -0
- package/dist/src/dashboard/spa.d.ts.map +1 -0
- package/dist/src/dashboard/spa.js +51 -0
- package/dist/src/dashboard/spa.js.map +1 -0
- package/dist/src/define_config.d.ts +162 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +53 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/dev_tools.d.ts +74 -0
- package/dist/src/dev_tools.d.ts.map +1 -0
- package/dist/src/dev_tools.js +414 -0
- package/dist/src/dev_tools.js.map +1 -0
- package/dist/src/diagnostics.d.ts +87 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +35 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/doctor/agora_doctor.d.ts +116 -0
- package/dist/src/doctor/agora_doctor.d.ts.map +1 -0
- package/dist/src/doctor/agora_doctor.js +685 -0
- package/dist/src/doctor/agora_doctor.js.map +1 -0
- package/dist/src/doctor/checks.d.ts +8 -0
- package/dist/src/doctor/checks.d.ts.map +1 -0
- package/dist/src/doctor/checks.js +352 -0
- package/dist/src/doctor/checks.js.map +1 -0
- package/dist/src/doctor/index.d.ts +3 -0
- package/dist/src/doctor/index.d.ts.map +1 -0
- package/dist/src/doctor/index.js +3 -0
- package/dist/src/doctor/index.js.map +1 -0
- package/dist/src/env_file.d.ts +24 -0
- package/dist/src/env_file.d.ts.map +1 -0
- package/dist/src/env_file.js +74 -0
- package/dist/src/env_file.js.map +1 -0
- package/dist/src/http/control_plane.d.ts +93 -0
- package/dist/src/http/control_plane.d.ts.map +1 -0
- package/dist/src/http/control_plane.js +406 -0
- package/dist/src/http/control_plane.js.map +1 -0
- package/dist/src/http/list.d.ts +27 -0
- package/dist/src/http/list.d.ts.map +1 -0
- package/dist/src/http/list.js +75 -0
- package/dist/src/http/list.js.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/runtime.d.ts +31 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +2 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/services/accessor.d.ts +6 -0
- package/dist/src/services/accessor.d.ts.map +1 -0
- package/dist/src/services/accessor.js +15 -0
- package/dist/src/services/accessor.js.map +1 -0
- package/dist/src/sql.d.ts +40 -0
- package/dist/src/sql.d.ts.map +1 -0
- package/dist/src/sql.js +97 -0
- package/dist/src/sql.js.map +1 -0
- package/dist/src/store/lucid_store.d.ts +62 -0
- package/dist/src/store/lucid_store.d.ts.map +1 -0
- package/dist/src/store/lucid_store.js +393 -0
- package/dist/src/store/lucid_store.js.map +1 -0
- package/dist/src/store/memory_store.d.ts +47 -0
- package/dist/src/store/memory_store.d.ts.map +1 -0
- package/dist/src/store/memory_store.js +184 -0
- package/dist/src/store/memory_store.js.map +1 -0
- package/dist/src/store/schema.d.ts +18 -0
- package/dist/src/store/schema.d.ts.map +1 -0
- package/dist/src/store/schema.js +74 -0
- package/dist/src/store/schema.js.map +1 -0
- package/dist/src/store/store.d.ts +160 -0
- package/dist/src/store/store.d.ts.map +1 -0
- package/dist/src/store/store.js +254 -0
- package/dist/src/store/store.js.map +1 -0
- package/dist/src/telescope/dashboard.d.ts +16 -0
- package/dist/src/telescope/dashboard.d.ts.map +1 -0
- package/dist/src/telescope/dashboard.js +129 -0
- package/dist/src/telescope/dashboard.js.map +1 -0
- package/dist/src/telescope/data-providers.d.ts +19 -0
- package/dist/src/telescope/data-providers.d.ts.map +1 -0
- package/dist/src/telescope/data-providers.js +266 -0
- package/dist/src/telescope/data-providers.js.map +1 -0
- package/dist/src/telescope/extension.d.ts +23 -0
- package/dist/src/telescope/extension.d.ts.map +1 -0
- package/dist/src/telescope/extension.js +36 -0
- package/dist/src/telescope/extension.js.map +1 -0
- package/dist/src/telescope/index.d.ts +6 -0
- package/dist/src/telescope/index.d.ts.map +1 -0
- package/dist/src/telescope/index.js +5 -0
- package/dist/src/telescope/index.js.map +1 -0
- package/dist/src/telescope/register.d.ts +17 -0
- package/dist/src/telescope/register.d.ts.map +1 -0
- package/dist/src/telescope/register.js +28 -0
- package/dist/src/telescope/register.js.map +1 -0
- package/dist/src/telescope/telescope-sdk.d.ts +116 -0
- package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
- package/dist/src/telescope/telescope-sdk.js +8 -0
- package/dist/src/telescope/telescope-sdk.js.map +1 -0
- package/dist/src/testing/index.d.ts +22 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +35 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/topology/tenant_client.d.ts +178 -0
- package/dist/src/topology/tenant_client.d.ts.map +1 -0
- package/dist/src/topology/tenant_client.js +642 -0
- package/dist/src/topology/tenant_client.js.map +1 -0
- package/dist/src/topology/tenant_keyring.d.ts +65 -0
- package/dist/src/topology/tenant_keyring.d.ts.map +1 -0
- package/dist/src/topology/tenant_keyring.js +150 -0
- package/dist/src/topology/tenant_keyring.js.map +1 -0
- package/dist/src/topology/token.d.ts +9 -0
- package/dist/src/topology/token.d.ts.map +1 -0
- package/dist/src/topology/token.js +10 -0
- package/dist/src/topology/token.js.map +1 -0
- package/dist/src/topology/verify.d.ts +79 -0
- package/dist/src/topology/verify.d.ts.map +1 -0
- package/dist/src/topology/verify.js +131 -0
- package/dist/src/topology/verify.js.map +1 -0
- package/dist/stubs/config/config.stub +23 -0
- package/dist/stubs/database/migrations/create_config_tables.stub +31 -0
- package/dist/stubs/main.ts +6 -0
- package/package.json +126 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Encryption } from '@adonisjs/core/encryption';
|
|
2
|
+
import type { KmsAdapter } from './kms.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the kit needs from Adonis' encryption: an `Encryption` or the app's `EncryptionManager`
|
|
5
|
+
* (`@adonisjs/core/services/encryption`) both fit.
|
|
6
|
+
*/
|
|
7
|
+
export interface EncrypterLike {
|
|
8
|
+
encrypt(payload: unknown, options?: {
|
|
9
|
+
purpose?: string;
|
|
10
|
+
}): string;
|
|
11
|
+
decrypt<T = unknown>(value: string, purpose?: string): T | null;
|
|
12
|
+
}
|
|
13
|
+
/** A key: a string, or an Adonis `Secret` (`env.get('APP_KEY')`). At least 16 characters. */
|
|
14
|
+
export type SecretLike = string | {
|
|
15
|
+
release(): string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Opens a value written before the kit (a lib's old format). Returns the plaintext, or `undefined`
|
|
19
|
+
* when the value is not one it knows. A throw counts as `undefined`.
|
|
20
|
+
*/
|
|
21
|
+
export type LegacyReader = (sealed: string) => string | undefined | Promise<string | undefined>;
|
|
22
|
+
export interface KeyringOptions {
|
|
23
|
+
/** Domain separation, e.g. `authkit:keystore`: bound into every value as Adonis' `purpose`. */
|
|
24
|
+
purpose: string;
|
|
25
|
+
/**
|
|
26
|
+
* Keys, newest first: the first encrypts, every one decrypts (Adonis' AES-256-GCM driver). The
|
|
27
|
+
* kit can then tell values sealed with an older key apart (`retired`).
|
|
28
|
+
*/
|
|
29
|
+
keys?: SecretLike[];
|
|
30
|
+
/**
|
|
31
|
+
* Or an Adonis encryption instance (the app's `encryption` service by default in the libs). Its
|
|
32
|
+
* own keys rotate in `config/encryption.ts`; the kit can't tell which of them sealed a value.
|
|
33
|
+
*/
|
|
34
|
+
encryption?: EncrypterLike;
|
|
35
|
+
/** Envelope encryption: a fresh data key per value, wrapped by the KMS and stored inline. */
|
|
36
|
+
kms?: KmsAdapter;
|
|
37
|
+
/** Readers for values written before the kit, tried in order. Never used to write. */
|
|
38
|
+
legacy?: LegacyReader[];
|
|
39
|
+
}
|
|
40
|
+
export interface Keyring {
|
|
41
|
+
readonly purpose: string;
|
|
42
|
+
/** Opens with every key. */
|
|
43
|
+
readonly all: EncrypterLike;
|
|
44
|
+
/** Opens with the encrypting key only; `undefined` when the kit can't tell keys apart. */
|
|
45
|
+
readonly active: EncrypterLike | undefined;
|
|
46
|
+
readonly kms: KmsAdapter | undefined;
|
|
47
|
+
readonly legacy: readonly LegacyReader[];
|
|
48
|
+
}
|
|
49
|
+
/** Adonis `Encryption` over AES-256-GCM with these keys (first encrypts). */
|
|
50
|
+
export declare function gcmEncryption(keys: SecretLike[], id?: string): Encryption;
|
|
51
|
+
export declare function createKeyring(options: KeyringOptions): Keyring;
|
|
52
|
+
//# sourceMappingURL=keyring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring.d.ts","sourceRoot":"","sources":["../../../src/crypto-kit/keyring.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IAClE,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;CACjE;AAED,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAAE,OAAO,IAAI,MAAM,CAAA;CAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEhG,MAAM,WAAW,cAAc;IAC7B,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,6FAA6F;IAC7F,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,sFAAsF;IACtF,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,SAAU,GAAG,UAAU,CAK1E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CA0B9D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// agora crypto-kit v1 — copied verbatim from _1x/shared/crypto-kit; never edit in one lib only.
|
|
2
|
+
import { Encryption } from '@adonisjs/core/encryption';
|
|
3
|
+
import { AES256GCM } from '@adonisjs/core/encryption/drivers/aes_256_gcm';
|
|
4
|
+
/** Adonis `Encryption` over AES-256-GCM with these keys (first encrypts). */
|
|
5
|
+
export function gcmEncryption(keys, id = 'agora') {
|
|
6
|
+
return new Encryption({
|
|
7
|
+
driver: (key) => new AES256GCM({ id, key }),
|
|
8
|
+
keys: keys.map((key) => (typeof key === 'string' ? key : key.release())),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function createKeyring(options) {
|
|
12
|
+
const { purpose, keys, encryption } = options;
|
|
13
|
+
if (typeof purpose !== 'string' || purpose.length === 0) {
|
|
14
|
+
throw new Error('crypto-kit: a keyring needs a `purpose`');
|
|
15
|
+
}
|
|
16
|
+
if ((keys === undefined) === (encryption === undefined)) {
|
|
17
|
+
throw new Error('crypto-kit: give a keyring either `keys` or `encryption`');
|
|
18
|
+
}
|
|
19
|
+
if (keys !== undefined && keys.length === 0) {
|
|
20
|
+
throw new Error('crypto-kit: `keys` needs at least one key');
|
|
21
|
+
}
|
|
22
|
+
if (options.kms &&
|
|
23
|
+
(typeof options.kms.wrap !== 'function' || typeof options.kms.unwrap !== 'function')) {
|
|
24
|
+
throw new Error('crypto-kit: `kms` needs wrap() and unwrap()');
|
|
25
|
+
}
|
|
26
|
+
const all = keys ? gcmEncryption(keys) : encryption;
|
|
27
|
+
const active = keys ? (keys.length === 1 ? all : gcmEncryption(keys.slice(0, 1))) : undefined;
|
|
28
|
+
return {
|
|
29
|
+
purpose,
|
|
30
|
+
all,
|
|
31
|
+
active,
|
|
32
|
+
kms: options.kms,
|
|
33
|
+
legacy: [...(options.legacy ?? [])],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=keyring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../../../src/crypto-kit/keyring.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CA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C,CAAC;IACjE,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,UAA4B,CAAC;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9F,OAAO;QACL,OAAO;QACP,GAAG;QACH,MAAM;QACN,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** What a data key is wrapped for: a KMS can bind it (AWS/GCP "encryption context"). */
|
|
2
|
+
export interface KmsContext {
|
|
3
|
+
purpose: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Envelope encryption: every sealed value gets a fresh data key, the KMS wraps it, and the wrapped
|
|
7
|
+
* key is stored inside the sealed value. Only the KMS can unwrap it.
|
|
8
|
+
*/
|
|
9
|
+
export interface KmsAdapter {
|
|
10
|
+
wrap(dataKey: Uint8Array, context: KmsContext): Uint8Array | Promise<Uint8Array>;
|
|
11
|
+
unwrap(wrapped: Uint8Array, context: KmsContext): Uint8Array | Promise<Uint8Array>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A KMS that lives in memory, for tests and local development: Adonis' AES-256-GCM under a master
|
|
15
|
+
* key that never leaves the process (pass the same `masterKey` to read values back later).
|
|
16
|
+
*/
|
|
17
|
+
export declare function createInMemoryKms(masterKey?: string): KmsAdapter;
|
|
18
|
+
//# sourceMappingURL=kms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.d.ts","sourceRoot":"","sources":["../../../src/crypto-kit/kms.ts"],"names":[],"mappings":"AAKA,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACjF,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,GAAE,MAA8C,GACxD,UAAU,CAsBZ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// agora crypto-kit v1 — copied verbatim from _1x/shared/crypto-kit; never edit in one lib only.
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { Encryption } from '@adonisjs/core/encryption';
|
|
4
|
+
import { AES256GCM } from '@adonisjs/core/encryption/drivers/aes_256_gcm';
|
|
5
|
+
/**
|
|
6
|
+
* A KMS that lives in memory, for tests and local development: Adonis' AES-256-GCM under a master
|
|
7
|
+
* key that never leaves the process (pass the same `masterKey` to read values back later).
|
|
8
|
+
*/
|
|
9
|
+
export function createInMemoryKms(masterKey = randomBytes(32).toString('base64url')) {
|
|
10
|
+
const encryption = new Encryption({
|
|
11
|
+
driver: (key) => new AES256GCM({ id: 'kms', key }),
|
|
12
|
+
keys: [masterKey],
|
|
13
|
+
});
|
|
14
|
+
const purposeOf = (context) => `kms:${context.purpose}`;
|
|
15
|
+
return {
|
|
16
|
+
wrap(dataKey, context) {
|
|
17
|
+
const payload = Buffer.from(dataKey).toString('base64url');
|
|
18
|
+
return Buffer.from(encryption.encrypt(payload, { purpose: purposeOf(context) }), 'utf8');
|
|
19
|
+
},
|
|
20
|
+
unwrap(wrapped, context) {
|
|
21
|
+
const payload = encryption.decrypt(Buffer.from(wrapped).toString('utf8'), purposeOf(context));
|
|
22
|
+
if (typeof payload !== 'string') {
|
|
23
|
+
throw new Error('crypto-kit: in-memory KMS could not unwrap');
|
|
24
|
+
}
|
|
25
|
+
return Buffer.from(payload, 'base64url');
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=kms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.js","sourceRoot":"","sources":["../../../src/crypto-kit/kms.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAgB1E;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAS,GAAW,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IAEzD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;QAChC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAClD,IAAI,EAAE,CAAC,SAAS,CAAC;KAClB,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,CAAC,OAAmB,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IACpE,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,OAAO;YACnB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC3F,CAAC;QACD,MAAM,CAAC,OAAO,EAAE,OAAO;YACrB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAChC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EACrC,SAAS,CAAC,OAAO,CAAC,CACnB,CAAC;YACF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Keyring } from './keyring.js';
|
|
2
|
+
/** Every value the kit writes starts with this; the rest is Adonis' own ciphertext. */
|
|
3
|
+
export declare const SEALED_PREFIX = "agora:v1:";
|
|
4
|
+
export interface SealOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Context bound into the value with the lib's purpose (e.g. `auth_mfa.totp_secret:<account id>`):
|
|
7
|
+
* not stored, and the same string must be passed to `open`, so a value can't move to another row.
|
|
8
|
+
*/
|
|
9
|
+
aad?: string;
|
|
10
|
+
}
|
|
11
|
+
export type SealedValueErrorCode = 'format' | 'unreadable' | 'kms' | 'legacy';
|
|
12
|
+
/** A value that can't be opened. The message never contains the value or a key. */
|
|
13
|
+
export declare class SealedValueError extends Error {
|
|
14
|
+
readonly code: SealedValueErrorCode;
|
|
15
|
+
constructor(code: SealedValueErrorCode, message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* - `active`: opens with the encrypting key (or, with an opaque `encryption`, opens at all).
|
|
19
|
+
* - `retired`: opens only with an older key, or is not in the KMS envelope the keyring now uses.
|
|
20
|
+
* - `legacy`: a lib's pre-kit format that one of its legacy readers opens.
|
|
21
|
+
* - `unreadable`: nothing configured opens it (key gone, tampered, wrong aad).
|
|
22
|
+
*/
|
|
23
|
+
export type SealedStatus = 'active' | 'retired' | 'legacy' | 'unreadable';
|
|
24
|
+
/** Seals `value` with the keyring's encrypting key (or a fresh KMS-wrapped data key). */
|
|
25
|
+
export declare function seal(keyring: Keyring, value: string, options?: SealOptions): Promise<string>;
|
|
26
|
+
/** Opens a value from {@link seal} (or, through the keyring's legacy readers, an older format). */
|
|
27
|
+
export declare function open(keyring: Keyring, sealed: string, options?: SealOptions): Promise<string>;
|
|
28
|
+
/** Where a sealed value stands against the keyring (tries to open it; never returns the value). */
|
|
29
|
+
export declare function sealedStatus(keyring: Keyring, sealed: string, options?: SealOptions): Promise<SealedStatus>;
|
|
30
|
+
/** True when the value opens but not with the encrypting key (an older key, a legacy format). */
|
|
31
|
+
export declare function needsReseal(keyring: Keyring, sealed: string, options?: SealOptions): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Opens and seals again with the encrypting key. Returns `sealed` unchanged when nothing is to do,
|
|
34
|
+
* unless `force` (rewrite anyway: rotating keys the kit can't tell apart, e.g. the app's own).
|
|
35
|
+
*/
|
|
36
|
+
export declare function reseal(keyring: Keyring, sealed: string, options?: SealOptions & {
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/crypto-kit/seal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/E,uFAAuF;AACvF,eAAO,MAAM,aAAa,cAAc,CAAC;AAIzC,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE9E,mFAAmF;AACnF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,YAAY,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAItD;CACF;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;AAkC1E,yFAAyF;AACzF,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CASjB;AAsCD,mGAAmG;AACnG,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAKD,mGAAmG;AACnG,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,YAAY,CAAC,CAmBvB;AAED,iGAAiG;AACjG,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9C,OAAO,CAAC,MAAM,CAAC,CAIjB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// agora crypto-kit v1 — copied verbatim from _1x/shared/crypto-kit; never edit in one lib only.
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { gcmEncryption } from './keyring.js';
|
|
4
|
+
/** Every value the kit writes starts with this; the rest is Adonis' own ciphertext. */
|
|
5
|
+
export const SEALED_PREFIX = 'agora:v1:';
|
|
6
|
+
/** `agora:v1:kms:<wrapped data key>:<ciphertext under the data key>` */
|
|
7
|
+
const KMS_MARK = 'kms:';
|
|
8
|
+
/** A value that can't be opened. The message never contains the value or a key. */
|
|
9
|
+
export class SealedValueError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(`crypto-kit: ${message}`);
|
|
13
|
+
this.name = 'SealedValueError';
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const purposeOf = (keyring, aad) => JSON.stringify([keyring.purpose, aad ?? null]);
|
|
18
|
+
const b64 = (bytes) => Buffer.from(bytes).toString('base64url');
|
|
19
|
+
/** Strict base64url: only the canonical spelling of its bytes. */
|
|
20
|
+
function decode(part) {
|
|
21
|
+
if (!/^[A-Za-z0-9_-]+$/.test(part))
|
|
22
|
+
return undefined;
|
|
23
|
+
const bytes = Buffer.from(part, 'base64url');
|
|
24
|
+
return b64(bytes) === part ? bytes : undefined;
|
|
25
|
+
}
|
|
26
|
+
/** `undefined`: not a kit value. `null`: a kit value that is malformed. */
|
|
27
|
+
function parse(sealed) {
|
|
28
|
+
if (!sealed.startsWith(SEALED_PREFIX))
|
|
29
|
+
return undefined;
|
|
30
|
+
const rest = sealed.slice(SEALED_PREFIX.length);
|
|
31
|
+
if (!rest.startsWith(KMS_MARK))
|
|
32
|
+
return rest.length > 0 ? { kind: 'plain', body: rest } : null;
|
|
33
|
+
const end = rest.indexOf(':', KMS_MARK.length);
|
|
34
|
+
if (end === -1)
|
|
35
|
+
return null;
|
|
36
|
+
const wrapped = decode(rest.slice(KMS_MARK.length, end));
|
|
37
|
+
const body = rest.slice(end + 1);
|
|
38
|
+
return wrapped && body.length > 0 ? { kind: 'kms', wrapped, body } : null;
|
|
39
|
+
}
|
|
40
|
+
/** Adonis' payload is `{ v: value }`: its message format drops an empty string. */
|
|
41
|
+
const opened = (payload) => {
|
|
42
|
+
const value = payload?.v;
|
|
43
|
+
return typeof value === 'string' ? value : undefined;
|
|
44
|
+
};
|
|
45
|
+
/** Seals `value` with the keyring's encrypting key (or a fresh KMS-wrapped data key). */
|
|
46
|
+
export async function seal(keyring, value, options = {}) {
|
|
47
|
+
if (typeof value !== 'string')
|
|
48
|
+
throw new TypeError('crypto-kit: seal() takes a string');
|
|
49
|
+
const purpose = purposeOf(keyring, options.aad);
|
|
50
|
+
if (!keyring.kms)
|
|
51
|
+
return `${SEALED_PREFIX}${keyring.all.encrypt({ v: value }, { purpose })}`;
|
|
52
|
+
const dataKey = randomBytes(32);
|
|
53
|
+
const wrapped = await keyring.kms.wrap(dataKey, { purpose: keyring.purpose });
|
|
54
|
+
const body = gcmEncryption([dataKey.toString('base64url')]).encrypt({ v: value }, { purpose });
|
|
55
|
+
dataKey.fill(0);
|
|
56
|
+
return `${SEALED_PREFIX}${KMS_MARK}${b64(wrapped)}:${body}`;
|
|
57
|
+
}
|
|
58
|
+
async function openKms(keyring, parsed, purpose) {
|
|
59
|
+
if (!keyring.kms) {
|
|
60
|
+
throw new SealedValueError('kms', 'value is KMS-sealed but no `kms` is configured');
|
|
61
|
+
}
|
|
62
|
+
let dataKey;
|
|
63
|
+
try {
|
|
64
|
+
dataKey = Buffer.from(await keyring.kms.unwrap(parsed.wrapped, { purpose: keyring.purpose }));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new SealedValueError('kms', 'the KMS could not unwrap the data key');
|
|
68
|
+
}
|
|
69
|
+
if (dataKey.length !== 32) {
|
|
70
|
+
throw new SealedValueError('kms', 'unwrapped data key is not 32 bytes');
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return opened(gcmEncryption([dataKey.toString('base64url')]).decrypt(parsed.body, purpose));
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
dataKey.fill(0);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function openLegacy(keyring, sealed) {
|
|
80
|
+
for (const reader of keyring.legacy) {
|
|
81
|
+
try {
|
|
82
|
+
const value = await reader(sealed);
|
|
83
|
+
if (typeof value === 'string')
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// not this reader's format
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
/** Opens a value from {@link seal} (or, through the keyring's legacy readers, an older format). */
|
|
93
|
+
export async function open(keyring, sealed, options = {}) {
|
|
94
|
+
if (typeof sealed !== 'string') {
|
|
95
|
+
throw new SealedValueError('format', 'sealed value must be a string');
|
|
96
|
+
}
|
|
97
|
+
const parsed = parse(sealed);
|
|
98
|
+
if (parsed === undefined) {
|
|
99
|
+
const value = await openLegacy(keyring, sealed);
|
|
100
|
+
if (value === undefined) {
|
|
101
|
+
throw new SealedValueError('legacy', 'not an agora:v1 value and no legacy reader opened it');
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
if (parsed === null)
|
|
106
|
+
throw new SealedValueError('format', 'malformed sealed value');
|
|
107
|
+
const purpose = purposeOf(keyring, options.aad);
|
|
108
|
+
const value = parsed.kind === 'kms'
|
|
109
|
+
? await openKms(keyring, parsed, purpose)
|
|
110
|
+
: opened(keyring.all.decrypt(parsed.body, purpose));
|
|
111
|
+
if (value === undefined) {
|
|
112
|
+
throw new SealedValueError('unreadable', 'sealed value did not open (tampered, wrong aad, or its key is not configured)');
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
const opensWith = (encryption, body, purpose) => opened(encryption.decrypt(body, purpose)) !== undefined;
|
|
117
|
+
/** Where a sealed value stands against the keyring (tries to open it; never returns the value). */
|
|
118
|
+
export async function sealedStatus(keyring, sealed, options = {}) {
|
|
119
|
+
const parsed = typeof sealed === 'string' ? parse(sealed) : null;
|
|
120
|
+
if (parsed === undefined) {
|
|
121
|
+
return (await openLegacy(keyring, sealed)) === undefined ? 'unreadable' : 'legacy';
|
|
122
|
+
}
|
|
123
|
+
if (parsed === null)
|
|
124
|
+
return 'unreadable';
|
|
125
|
+
const purpose = purposeOf(keyring, options.aad);
|
|
126
|
+
if (parsed.kind === 'kms') {
|
|
127
|
+
if (!keyring.kms)
|
|
128
|
+
return 'unreadable';
|
|
129
|
+
try {
|
|
130
|
+
return (await openKms(keyring, parsed, purpose)) === undefined ? 'unreadable' : 'active';
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return 'unreadable';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (keyring.kms)
|
|
137
|
+
return opensWith(keyring.all, parsed.body, purpose) ? 'retired' : 'unreadable';
|
|
138
|
+
if (keyring.active && opensWith(keyring.active, parsed.body, purpose))
|
|
139
|
+
return 'active';
|
|
140
|
+
if (!opensWith(keyring.all, parsed.body, purpose))
|
|
141
|
+
return 'unreadable';
|
|
142
|
+
return keyring.active ? 'retired' : 'active';
|
|
143
|
+
}
|
|
144
|
+
/** True when the value opens but not with the encrypting key (an older key, a legacy format). */
|
|
145
|
+
export async function needsReseal(keyring, sealed, options = {}) {
|
|
146
|
+
const status = await sealedStatus(keyring, sealed, options);
|
|
147
|
+
return status === 'retired' || status === 'legacy';
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Opens and seals again with the encrypting key. Returns `sealed` unchanged when nothing is to do,
|
|
151
|
+
* unless `force` (rewrite anyway: rotating keys the kit can't tell apart, e.g. the app's own).
|
|
152
|
+
*/
|
|
153
|
+
export async function reseal(keyring, sealed, options = {}) {
|
|
154
|
+
const aad = options.aad === undefined ? {} : { aad: options.aad };
|
|
155
|
+
if (options.force !== true && !(await needsReseal(keyring, sealed, aad)))
|
|
156
|
+
return sealed;
|
|
157
|
+
return seal(keyring, await open(keyring, sealed, aad), aad);
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=seal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.js","sourceR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M,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgB,EAChB,MAAc,EACd,OAAO,GAAsC,EAAE;IAE/C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAClE,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IACxF,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in "access denied" page a BROWSER sees when the dashboard guard refuses a page
|
|
3
|
+
* navigation — the SPA shell or its assets. Before this page
|
|
4
|
+
* existed the guard answered every denial with the JSON it answers the API with
|
|
5
|
+
* (`{ "error": "forbidden" }`), which is the right thing for the SPA's `fetch` calls and the wrong
|
|
6
|
+
* thing for a human staring at a browser tab.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately a small, dependency-free, hand-authored HTML page — NOT part
|
|
9
|
+
* of the bundled SPA, so a denial never needs the SPA to load first. It carries NO `<script>` at all,
|
|
10
|
+
* so a host running a nonce'd `script-src` CSP (the `@adonisjs/shield` default) cannot break it; the
|
|
11
|
+
* one inline `<style>` takes the request's CSP nonce when the provider hands one over.
|
|
12
|
+
*
|
|
13
|
+
* Every string the host can supply ({@link AccessDeniedPageOptions}) is HTML-escaped on the way in.
|
|
14
|
+
* They are developer-controlled config values, not user input — but escaping them costs nothing and
|
|
15
|
+
* removes the one class of bug a "just interpolate it" template would invite.
|
|
16
|
+
*
|
|
17
|
+
* The visual language (Aviary neutrals, the console's own accent, mono eyebrow over a sans body)
|
|
18
|
+
* mirrors the flags SPA so the refusal reads as part of the same product, not a server default.
|
|
19
|
+
*
|
|
20
|
+
* Ported from `@adonis-agora/payments` (as durable, media, agent and telescope were) with only
|
|
21
|
+
* {@link CONSOLE} changed, so the Agora consoles share ONE
|
|
22
|
+
* refusal story rather than each inventing its own.
|
|
23
|
+
*/
|
|
24
|
+
/** Why the guard refused. Drives the default title/message and which buttons make sense. */
|
|
25
|
+
export type AccessDeniedReason =
|
|
26
|
+
/** Nobody is signed in (a `401`): offer the login page when one exists. */
|
|
27
|
+
'unauthenticated'
|
|
28
|
+
/** Somebody is signed in but `authorize` said no (a `403`). */
|
|
29
|
+
| 'forbidden';
|
|
30
|
+
/** What the provider knows about the refusal — handed to a custom renderer and to the default page. */
|
|
31
|
+
export interface AccessDeniedInfo {
|
|
32
|
+
/** The HTTP status the page is served with. */
|
|
33
|
+
status: 401 | 403;
|
|
34
|
+
reason: AccessDeniedReason;
|
|
35
|
+
/** The console's mount path (`/flags`; `''` when mounted at the root). */
|
|
36
|
+
basePath: string;
|
|
37
|
+
/** The app's login page, when the console knows one (`accessDenied.loginHref`). */
|
|
38
|
+
loginHref?: string;
|
|
39
|
+
/** A developer-facing detail (e.g. a thrown hook's message). Providers set it OUTSIDE production only. */
|
|
40
|
+
detail?: string;
|
|
41
|
+
/** The request's CSP nonce, applied to the inline `<style>` so a nonce'd `style-src` keeps the page styled. */
|
|
42
|
+
nonce?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Knobs for the built-in page — the `accessDenied` config option in its OBJECT form. Every field is
|
|
46
|
+
* optional; omit the option entirely for the defaults.
|
|
47
|
+
*/
|
|
48
|
+
export interface AccessDeniedPageOptions {
|
|
49
|
+
/** Console name in the eyebrow and `<title>`. Default: the console's own name (`Flags`). */
|
|
50
|
+
brand?: string;
|
|
51
|
+
/** Heading. Default depends on {@link AccessDeniedInfo.reason}. */
|
|
52
|
+
title?: string;
|
|
53
|
+
/** The sentence under the heading. Default depends on the reason. */
|
|
54
|
+
message?: string;
|
|
55
|
+
/** Where "Back to app" points. Default `/`; `false` hides the button. */
|
|
56
|
+
homeHref?: string | false;
|
|
57
|
+
/** Label of the "Back to app" button. */
|
|
58
|
+
homeLabel?: string;
|
|
59
|
+
/** Where "Sign in" points (your app's login page). Default: none; `false` hides it. */
|
|
60
|
+
loginHref?: string | false;
|
|
61
|
+
/** Label of the "Sign in" button. */
|
|
62
|
+
loginLabel?: string;
|
|
63
|
+
/** Accent colour (any CSS colour). Default: the console's own accent. */
|
|
64
|
+
accent?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The `accessDenied` config option in its FUNCTION form: render the page yourself. Return an HTML
|
|
68
|
+
* string and the provider serves it (with the refusal's status, `text/html`, `no-store`). Return
|
|
69
|
+
* nothing after answering the request yourself — a redirect to your own login page, most commonly —
|
|
70
|
+
* and the provider stands down. Return nothing WITHOUT answering and the default page is served, so
|
|
71
|
+
* the hook is safe to use for side effects (logging) alone.
|
|
72
|
+
*
|
|
73
|
+
* `Ctx` is the host framework's HTTP context — the provider passes AdonisJS's `HttpContext` through
|
|
74
|
+
* untouched; it is generic here so this module stays framework-light and unit-testable.
|
|
75
|
+
*/
|
|
76
|
+
export type AccessDeniedRenderer<Ctx = unknown> = (info: AccessDeniedInfo, ctx: Ctx) => string | undefined | null | void | Promise<string | undefined | null | void>;
|
|
77
|
+
/** The `accessDenied` config option: tweak the built-in page, or replace it. */
|
|
78
|
+
export type AccessDeniedOption<Ctx = unknown> = AccessDeniedPageOptions | AccessDeniedRenderer<Ctx>;
|
|
79
|
+
/** This console's identity — the ONLY thing that differs between the Agora ports of this file. */
|
|
80
|
+
export declare const CONSOLE: {
|
|
81
|
+
readonly brand: 'Config';
|
|
82
|
+
readonly accent: '#a78bfa';
|
|
83
|
+
readonly packageName: '@adonis-agora/config';
|
|
84
|
+
};
|
|
85
|
+
/** Escape the five characters that matter inside HTML text and double-quoted attributes. */
|
|
86
|
+
export declare function escapeHtml(value: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Render the built-in page. Pure: same `info` + `options` in, same HTML out — so it is trivially
|
|
89
|
+
* snapshot/regex testable and safe to call from anywhere (the provider, a test, a host that wants
|
|
90
|
+
* to embed the default page inside its own layout).
|
|
91
|
+
*/
|
|
92
|
+
export declare function renderAccessDeniedPage(info: AccessDeniedInfo, options?: AccessDeniedPageOptions): string;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve WHAT to serve for a refusal, honouring the host's `accessDenied` option in either form.
|
|
95
|
+
* Returns the HTML to send, or `null` when a custom renderer already answered the request itself
|
|
96
|
+
* (`answered()` reports whether it did — the provider wires that to "a `location` header or a body
|
|
97
|
+
* is already set"). Framework-light: knows nothing about the HTTP context beyond passing it through.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolveAccessDeniedPage<Ctx>(info: AccessDeniedInfo, option: AccessDeniedOption<Ctx> | null | undefined, ctx: Ctx, answered: () => boolean): Promise<string | null>;
|
|
100
|
+
//# sourceMappingURL=access_denied_page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access_denied_page.d.ts","sourceRoot":"","sources":["../../../src/dashboard/access_denied_page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,4FAA4F;AAC5F,MAAM,MAAM,kBAAkB;AAC5B,2EAA2E;AACzE,iBAAiB;AACnB,+DAA+D;GAC7D,WAAW,CAAC;AAEhB,uGAAuG;AACvG,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0GAA0G;IAC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