@dokebi/oauth 0.0.0-stage → 0.1.1
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/AI.md +469 -0
- package/LICENSE +21 -0
- package/README.md +41 -2
- package/dist/bounded.d.ts +9 -0
- package/dist/bounded.js +36 -0
- package/dist/cimd.d.ts +97 -0
- package/dist/cimd.js +384 -0
- package/dist/clients.d.ts +85 -0
- package/dist/clients.js +303 -0
- package/dist/dependency.d.ts +4 -0
- package/dist/dependency.js +14 -0
- package/dist/errors.d.ts +87 -0
- package/dist/errors.js +34 -0
- package/dist/extension.d.ts +161 -0
- package/dist/extension.js +108 -0
- package/dist/grants.d.ts +126 -0
- package/dist/grants.js +280 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +28 -0
- package/dist/install.d.ts +33 -0
- package/dist/install.js +112 -0
- package/dist/live.d.ts +47 -0
- package/dist/live.js +105 -0
- package/dist/options.d.ts +173 -0
- package/dist/options.js +521 -0
- package/dist/plugin.d.ts +113 -0
- package/dist/plugin.js +766 -0
- package/dist/protocol.d.ts +81 -0
- package/dist/protocol.js +249 -0
- package/dist/server.d.ts +148 -0
- package/dist/server.js +1516 -0
- package/dist/signin.d.ts +40 -0
- package/dist/signin.js +86 -0
- package/dist/store-redis.d.ts +38 -0
- package/dist/store-redis.js +173 -0
- package/dist/store-sql.d.ts +46 -0
- package/dist/store-sql.js +363 -0
- package/dist/store.d.ts +126 -0
- package/dist/store.js +266 -0
- package/options.schema.json +633 -0
- package/package.json +143 -4
- package/templates/extension.ts +45 -0
- package/templates/migrations/dokebi_oauth.ts +117 -0
package/dist/install.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Install lifecycle module (`dokebi.installModule`). It runs isolated in the CLI, so it imports
|
|
2
|
+
// nothing and only reads the plain options it is given. Invalid options are left to the schema.
|
|
3
|
+
const REDIS_PROVIDER = 'dokebi-redis';
|
|
4
|
+
const DB_PROVIDER = 'dokebi-db';
|
|
5
|
+
const RATE_LIMIT_PROVIDER = 'dokebi-rate-limit';
|
|
6
|
+
const DEFAULT_PREFIX = 'dokebi_oauth';
|
|
7
|
+
/** dokebi-db connection names (the same rule as its options). */
|
|
8
|
+
const CONNECTION = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
9
|
+
/** The three tables (store.driver: sql), for @dokebi/migrate. */
|
|
10
|
+
const MIGRATION_SOURCE = 'templates/migrations/dokebi_oauth.ts';
|
|
11
|
+
/** The user-owned extension entry (D-0064): the class that renders the consent page. */
|
|
12
|
+
const ENTRY = Object.freeze({
|
|
13
|
+
source: 'templates/extension.ts',
|
|
14
|
+
target: 'src/infra/oauth/extension.ts',
|
|
15
|
+
});
|
|
16
|
+
/** http is accepted on these hosts only (the start's own rule, src/plugin.ts). */
|
|
17
|
+
function localIssuer(issuer) {
|
|
18
|
+
if (!URL.canParse(issuer))
|
|
19
|
+
return false;
|
|
20
|
+
const host = new URL(issuer).hostname;
|
|
21
|
+
return (host === 'localhost' || host.endsWith('.localhost') || host === '127.0.0.1' || host === '[::1]');
|
|
22
|
+
}
|
|
23
|
+
function plain(value) {
|
|
24
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
function store(options) {
|
|
27
|
+
return plain(options) && plain(options.store) ? options.store : undefined;
|
|
28
|
+
}
|
|
29
|
+
function requires(context) {
|
|
30
|
+
const list = [];
|
|
31
|
+
const driver = store(context.options)?.driver;
|
|
32
|
+
if (driver === 'redis')
|
|
33
|
+
list.push(REDIS_PROVIDER);
|
|
34
|
+
if (driver === 'sql')
|
|
35
|
+
list.push(DB_PROVIDER);
|
|
36
|
+
if (plain(context.options.rateLimit))
|
|
37
|
+
list.push(RATE_LIMIT_PROVIDER);
|
|
38
|
+
return list;
|
|
39
|
+
}
|
|
40
|
+
/** UTC yyyyMMddHHmmss, the @dokebi/migrate file name prefix. */
|
|
41
|
+
function stamp(now) {
|
|
42
|
+
return now.toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* store.driver: sql with the default prefix: the migration that creates the tables, in the
|
|
46
|
+
* @dokebi/migrate layout of the connection. A custom prefix gets no file (the SQL is in AI.md).
|
|
47
|
+
*/
|
|
48
|
+
function migrationFiles(context) {
|
|
49
|
+
const settings = store(context.options);
|
|
50
|
+
if (settings?.driver !== 'sql')
|
|
51
|
+
return [];
|
|
52
|
+
const connection = settings.connection;
|
|
53
|
+
if (typeof connection !== 'string' || !CONNECTION.test(connection))
|
|
54
|
+
return [];
|
|
55
|
+
if (settings.tablePrefix !== undefined && settings.tablePrefix !== DEFAULT_PREFIX)
|
|
56
|
+
return [];
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
source: MIGRATION_SOURCE,
|
|
60
|
+
target: `src/infra/db/migrations/${connection}/${stamp(new Date())}_dokebi_oauth.ts`,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
export function planInstall(context) {
|
|
65
|
+
const files = migrationFiles(context);
|
|
66
|
+
return { requires: requires(context), entry: ENTRY, ...(files.length ? { files } : {}) };
|
|
67
|
+
}
|
|
68
|
+
/** An existing entry file is never replaced. */
|
|
69
|
+
export function planUpgrade(context) {
|
|
70
|
+
return { requires: requires(context), entry: ENTRY };
|
|
71
|
+
}
|
|
72
|
+
/** The defaults of `registrationLimit` and `registrationWindowMs` (src/options.ts, not imported here). */
|
|
73
|
+
const REGISTRATION_LIMIT = 20;
|
|
74
|
+
const REGISTRATION_WINDOW_MS = 3_600_000;
|
|
75
|
+
/** `<limit> per address and <window>` of the configured options (or their defaults). */
|
|
76
|
+
function registrationBound(options) {
|
|
77
|
+
const limit = Number.isSafeInteger(options.registrationLimit)
|
|
78
|
+
? options.registrationLimit
|
|
79
|
+
: REGISTRATION_LIMIT;
|
|
80
|
+
const windowMs = Number.isSafeInteger(options.registrationWindowMs)
|
|
81
|
+
? options.registrationWindowMs
|
|
82
|
+
: REGISTRATION_WINDOW_MS;
|
|
83
|
+
const unit = (count, name) => `${count} ${name}${count === 1 ? '' : 's'}`;
|
|
84
|
+
const window = windowMs % 3_600_000 === 0
|
|
85
|
+
? unit(windowMs / 3_600_000, 'hour')
|
|
86
|
+
: windowMs % 60_000 === 0
|
|
87
|
+
? unit(windowMs / 60_000, 'minute')
|
|
88
|
+
: unit(Math.ceil(windowMs / 1_000), 'second');
|
|
89
|
+
return `${limit} per address and ${window}`;
|
|
90
|
+
}
|
|
91
|
+
export function check(context) {
|
|
92
|
+
const diagnostics = [];
|
|
93
|
+
const issuer = plain(context.options) ? context.options.issuer : undefined;
|
|
94
|
+
// R6 Codex T3 review: an http issuer on localhost or *.localhost (which the start accepts) got
|
|
95
|
+
// this warning on every doctor run, with nothing a local project could change. Only an http
|
|
96
|
+
// issuer the start refuses is reported, as the error it is.
|
|
97
|
+
if (typeof issuer === 'string' && issuer.startsWith('http://') && !localIssuer(issuer))
|
|
98
|
+
diagnostics.push({
|
|
99
|
+
code: 'OAUTH_ISSUER_HTTP',
|
|
100
|
+
severity: 'error',
|
|
101
|
+
optionPath: ['issuer'],
|
|
102
|
+
hint: 'issuer uses http on a host other than localhost, *.localhost, 127.0.0.1 or [::1]: the start refuses it; set the public https origin of the app',
|
|
103
|
+
});
|
|
104
|
+
if (plain(context.options) && context.options.registration === 'open')
|
|
105
|
+
diagnostics.push({
|
|
106
|
+
code: 'OAUTH_REGISTRATION_OPEN',
|
|
107
|
+
severity: 'warning',
|
|
108
|
+
optionPath: ['registration'],
|
|
109
|
+
hint: `dynamic client registration is open: anyone may register a public client (${registrationBound(context.options)})`,
|
|
110
|
+
});
|
|
111
|
+
return { requires: requires(context), diagnostics };
|
|
112
|
+
}
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Logger } from '@dokebi/core';
|
|
2
|
+
/** `api.live(request)`: the structural contract of the SSE and WebSocket transports. */
|
|
3
|
+
export interface OAuthLiveAuthorization {
|
|
4
|
+
/** False once the token expired, was revoked, or a check did not confirm it in time. */
|
|
5
|
+
valid(): boolean;
|
|
6
|
+
/** Starts the checks; `invalidated` runs once when the lease ends. Returns the unsubscribe. */
|
|
7
|
+
subscribe(invalidated: () => void): () => void;
|
|
8
|
+
/** When the lease ends at the latest: the token's expiry or the grant's end, whichever is first. */
|
|
9
|
+
readonly expiresAt: Date;
|
|
10
|
+
}
|
|
11
|
+
/** How a lease is timed (dokebi-oauth `live`). */
|
|
12
|
+
export interface LiveTiming {
|
|
13
|
+
readonly maxAgeMs: number;
|
|
14
|
+
readonly renewBeforeMs: number;
|
|
15
|
+
}
|
|
16
|
+
/** The lease dokebi-auth gives (`request.auth.live()`), by shape. */
|
|
17
|
+
export interface InnerLease {
|
|
18
|
+
valid(): boolean;
|
|
19
|
+
subscribe(invalidated: () => void): () => void;
|
|
20
|
+
}
|
|
21
|
+
/** The open leases of this process by grant, for the revocations this process makes. */
|
|
22
|
+
export declare class LiveGrants {
|
|
23
|
+
#private;
|
|
24
|
+
get size(): number;
|
|
25
|
+
add(grant: string, lease: GrantLease): void;
|
|
26
|
+
delete(grant: string, lease: GrantLease): void;
|
|
27
|
+
/** Ends every lease of a grant now (it was revoked here); the number ended. */
|
|
28
|
+
end(grant: string): number;
|
|
29
|
+
}
|
|
30
|
+
/** One Bearer connection's lease: dokebi-auth's lease, ended at once by a revocation here. */
|
|
31
|
+
export declare class GrantLease implements OAuthLiveAuthorization {
|
|
32
|
+
#private;
|
|
33
|
+
readonly expiresAt: Date;
|
|
34
|
+
constructor(settings: {
|
|
35
|
+
readonly grant: string;
|
|
36
|
+
/** dokebi-auth's lease of the Bearer request (its check includes the grant). */
|
|
37
|
+
readonly inner: InnerLease;
|
|
38
|
+
/** The token's expiry or the grant's end, whichever is first (epoch ms). */
|
|
39
|
+
readonly endsAt: number;
|
|
40
|
+
readonly logger: Logger;
|
|
41
|
+
readonly registry: LiveGrants;
|
|
42
|
+
});
|
|
43
|
+
valid(): boolean;
|
|
44
|
+
subscribe(invalidated: () => void): () => void;
|
|
45
|
+
/** Ends the lease (once) and tells every listener. */
|
|
46
|
+
end(reason: string): void;
|
|
47
|
+
}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { diagnostics } from '@dokebi/core/libraries';
|
|
2
|
+
/** The open leases of this process by grant, for the revocations this process makes. */
|
|
3
|
+
export class LiveGrants {
|
|
4
|
+
#byGrant = new Map();
|
|
5
|
+
get size() {
|
|
6
|
+
let count = 0;
|
|
7
|
+
for (const leases of this.#byGrant.values())
|
|
8
|
+
count += leases.size;
|
|
9
|
+
return count;
|
|
10
|
+
}
|
|
11
|
+
add(grant, lease) {
|
|
12
|
+
let leases = this.#byGrant.get(grant);
|
|
13
|
+
if (!leases) {
|
|
14
|
+
leases = new Set();
|
|
15
|
+
this.#byGrant.set(grant, leases);
|
|
16
|
+
}
|
|
17
|
+
leases.add(lease);
|
|
18
|
+
}
|
|
19
|
+
delete(grant, lease) {
|
|
20
|
+
const leases = this.#byGrant.get(grant);
|
|
21
|
+
if (!leases)
|
|
22
|
+
return;
|
|
23
|
+
leases.delete(lease);
|
|
24
|
+
if (!leases.size)
|
|
25
|
+
this.#byGrant.delete(grant);
|
|
26
|
+
}
|
|
27
|
+
/** Ends every lease of a grant now (it was revoked here); the number ended. */
|
|
28
|
+
end(grant) {
|
|
29
|
+
const leases = this.#byGrant.get(grant);
|
|
30
|
+
if (!leases)
|
|
31
|
+
return 0;
|
|
32
|
+
const all = [...leases];
|
|
33
|
+
for (const lease of all)
|
|
34
|
+
lease.end('revoked');
|
|
35
|
+
return all.length;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** One Bearer connection's lease: dokebi-auth's lease, ended at once by a revocation here. */
|
|
39
|
+
export class GrantLease {
|
|
40
|
+
expiresAt;
|
|
41
|
+
#grant;
|
|
42
|
+
#inner;
|
|
43
|
+
#logger;
|
|
44
|
+
#registry;
|
|
45
|
+
#listeners = new Set();
|
|
46
|
+
#release;
|
|
47
|
+
#ended = false;
|
|
48
|
+
constructor(settings) {
|
|
49
|
+
this.#grant = settings.grant;
|
|
50
|
+
this.#inner = settings.inner;
|
|
51
|
+
this.#logger = settings.logger;
|
|
52
|
+
this.#registry = settings.registry;
|
|
53
|
+
this.expiresAt = new Date(settings.endsAt);
|
|
54
|
+
}
|
|
55
|
+
valid() {
|
|
56
|
+
return !this.#ended && this.#inner.valid();
|
|
57
|
+
}
|
|
58
|
+
subscribe(invalidated) {
|
|
59
|
+
if (typeof invalidated !== 'function')
|
|
60
|
+
throw new TypeError('subscribe needs a function');
|
|
61
|
+
if (!this.valid()) {
|
|
62
|
+
this.end(this.#ended ? 'ended' : 'expired');
|
|
63
|
+
queueMicrotask(invalidated);
|
|
64
|
+
return () => undefined;
|
|
65
|
+
}
|
|
66
|
+
const listener = () => invalidated();
|
|
67
|
+
this.#listeners.add(listener);
|
|
68
|
+
if (this.#listeners.size === 1) {
|
|
69
|
+
this.#registry.add(this.#grant, this);
|
|
70
|
+
// The inner lease runs the checks while something listens here.
|
|
71
|
+
const release = this.#inner.subscribe(() => this.end('unconfirmed'));
|
|
72
|
+
if (this.#ended)
|
|
73
|
+
release();
|
|
74
|
+
else
|
|
75
|
+
this.#release = release;
|
|
76
|
+
}
|
|
77
|
+
return () => {
|
|
78
|
+
if (!this.#listeners.delete(listener) || this.#listeners.size)
|
|
79
|
+
return;
|
|
80
|
+
this.#stop();
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Ends the lease (once) and tells every listener. */
|
|
84
|
+
end(reason) {
|
|
85
|
+
if (this.#ended)
|
|
86
|
+
return;
|
|
87
|
+
this.#ended = true;
|
|
88
|
+
this.#stop();
|
|
89
|
+
diagnostics.logDebug(this.#logger, 'OAuth live authorization ended', () => ({
|
|
90
|
+
grant: this.#grant,
|
|
91
|
+
reason,
|
|
92
|
+
listeners: this.#listeners.size,
|
|
93
|
+
}));
|
|
94
|
+
const listeners = [...this.#listeners];
|
|
95
|
+
this.#listeners.clear();
|
|
96
|
+
for (const listener of listeners)
|
|
97
|
+
listener();
|
|
98
|
+
}
|
|
99
|
+
#stop() {
|
|
100
|
+
const release = this.#release;
|
|
101
|
+
this.#release = undefined;
|
|
102
|
+
release?.();
|
|
103
|
+
this.#registry.delete(this.#grant, this);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type OptionsDeclaration } from '@dokebi/core';
|
|
2
|
+
/** Default of `grant.clientMaxDays`: the ceiling of a client's own `grant.maxDays` (D-0122). */
|
|
3
|
+
export declare const GRANT_CLIENT_MAX_DAYS = 365;
|
|
4
|
+
/** Defaults of `live` (D-0122), the same bound as dokebi-auth's `live` for sessions. */
|
|
5
|
+
export declare const LIVE_DEFAULT: Readonly<{
|
|
6
|
+
maxAgeMs: 5000;
|
|
7
|
+
renewBeforeMs: 1000;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Defaults of the D-0113 §5 limits (dokebi.yaml options); constructors used directly (tests) fall
|
|
11
|
+
* back to them.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LIMITS_DEFAULT: Readonly<{
|
|
14
|
+
logRepeatWindowMs: 10000;
|
|
15
|
+
storeRetryAfterMs: 1000;
|
|
16
|
+
storeFullRetryAfterMs: 5000;
|
|
17
|
+
grantTouchMs: 60000;
|
|
18
|
+
maxCachedGrants: 10000;
|
|
19
|
+
codeGraceMs: 600000;
|
|
20
|
+
clientUnusedMs: number;
|
|
21
|
+
refreshMs: number;
|
|
22
|
+
registrationLimit: 20;
|
|
23
|
+
registrationWindowMs: 3600000;
|
|
24
|
+
maxTrackedAddresses: 10000;
|
|
25
|
+
pendingMs: 600000;
|
|
26
|
+
maxPending: 5;
|
|
27
|
+
maxBodyBytes: 65536;
|
|
28
|
+
maxCodes: 100000;
|
|
29
|
+
maxClients: 100000;
|
|
30
|
+
maxPerClient: 20;
|
|
31
|
+
}>;
|
|
32
|
+
/** Defaults of the `cimd` limits (D-0113 §5). */
|
|
33
|
+
export declare const CIMD_LIMITS_DEFAULT: Readonly<{
|
|
34
|
+
maxFetches: 16;
|
|
35
|
+
maxFetchesPerAddress: 2;
|
|
36
|
+
refusalCacheMs: 300000;
|
|
37
|
+
maxRefused: 1000;
|
|
38
|
+
maxBytes: number;
|
|
39
|
+
maxHeaderBytes: number;
|
|
40
|
+
minCacheMs: 300000;
|
|
41
|
+
maxCacheMs: 86400000;
|
|
42
|
+
defaultCacheMs: 3600000;
|
|
43
|
+
maxCached: 1000;
|
|
44
|
+
}>;
|
|
45
|
+
/** An origin without a path: `https://example.com`, `http://localhost:3000`. */
|
|
46
|
+
export declare const ISSUER: RegExp;
|
|
47
|
+
/** A realm of dokebi-auth. */
|
|
48
|
+
export declare const REALM_NAME: RegExp;
|
|
49
|
+
/** A resource id: also the audience of its tokens (dokebi-auth `aud:<id>`). */
|
|
50
|
+
export declare const RESOURCE_ID: RegExp;
|
|
51
|
+
/**
|
|
52
|
+
* A scope name: an RFC 6749 §3.3 scope-token that is also a dokebi-auth token ability (the
|
|
53
|
+
* tokens carry their scopes as abilities): letters, digits, `_`, `:`, `-`, dot-separated parts.
|
|
54
|
+
*/
|
|
55
|
+
export declare const SCOPE_TOKEN: RegExp;
|
|
56
|
+
/** A pre-registered client id: no URL (those are client ID metadata documents). */
|
|
57
|
+
export declare const CLIENT_ID: RegExp;
|
|
58
|
+
export interface OAuthResourceOptions {
|
|
59
|
+
readonly uri: string;
|
|
60
|
+
readonly name?: string;
|
|
61
|
+
readonly scopes: Readonly<Record<string, string>>;
|
|
62
|
+
readonly defaultScopes: readonly string[];
|
|
63
|
+
/** The apps whose hosts serve its metadata (D-0132); absent: `app` of the plugin. */
|
|
64
|
+
readonly app?: string | readonly string[];
|
|
65
|
+
}
|
|
66
|
+
export interface OAuthClientOptions {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly redirectUris: readonly string[];
|
|
69
|
+
readonly secretSha256?: string;
|
|
70
|
+
/** Absent: `grant.maxDays`. */
|
|
71
|
+
readonly grant?: {
|
|
72
|
+
readonly maxDays: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface OAuthCimdOptions {
|
|
76
|
+
readonly enabled: boolean;
|
|
77
|
+
readonly allowHosts: readonly string[];
|
|
78
|
+
readonly timeoutMs: number;
|
|
79
|
+
readonly maxFetches: number;
|
|
80
|
+
readonly maxFetchesPerAddress: number;
|
|
81
|
+
readonly refusalCacheMs: number;
|
|
82
|
+
readonly maxRefused: number;
|
|
83
|
+
readonly maxBytes: number;
|
|
84
|
+
readonly maxHeaderBytes: number;
|
|
85
|
+
readonly minCacheMs: number;
|
|
86
|
+
readonly maxCacheMs: number;
|
|
87
|
+
readonly defaultCacheMs: number;
|
|
88
|
+
readonly maxCached: number;
|
|
89
|
+
}
|
|
90
|
+
export interface MemoryOAuthStoreOptions {
|
|
91
|
+
readonly driver: 'memory';
|
|
92
|
+
readonly maxGrants: number;
|
|
93
|
+
readonly maxGrantsPerUser: number;
|
|
94
|
+
readonly maxCodes: number;
|
|
95
|
+
readonly maxClients: number;
|
|
96
|
+
}
|
|
97
|
+
export interface SqlOAuthStoreOptions {
|
|
98
|
+
readonly driver: 'sql';
|
|
99
|
+
readonly connection: string;
|
|
100
|
+
readonly tablePrefix: string;
|
|
101
|
+
}
|
|
102
|
+
export interface RedisOAuthStoreOptions {
|
|
103
|
+
readonly driver: 'redis';
|
|
104
|
+
readonly connection: string;
|
|
105
|
+
readonly namespace: string;
|
|
106
|
+
}
|
|
107
|
+
export type OAuthStoreOptions = MemoryOAuthStoreOptions | SqlOAuthStoreOptions | RedisOAuthStoreOptions;
|
|
108
|
+
export interface OAuthPaths {
|
|
109
|
+
readonly authorize: string;
|
|
110
|
+
readonly token: string;
|
|
111
|
+
readonly revoke: string;
|
|
112
|
+
readonly register: string;
|
|
113
|
+
}
|
|
114
|
+
export interface OAuthOptions {
|
|
115
|
+
readonly issuer: string;
|
|
116
|
+
readonly realm: string;
|
|
117
|
+
/** The apps whose hosts answer the authorization server (D-0132); absent: every host. */
|
|
118
|
+
readonly app?: string | readonly string[];
|
|
119
|
+
readonly resources: Readonly<Record<string, OAuthResourceOptions>>;
|
|
120
|
+
readonly clients: Readonly<Record<string, OAuthClientOptions>>;
|
|
121
|
+
/** Absent: on, every public https host, 3 seconds. */
|
|
122
|
+
readonly cimd?: OAuthCimdOptions;
|
|
123
|
+
readonly registration: 'closed' | 'open';
|
|
124
|
+
readonly registrationLimit: number;
|
|
125
|
+
readonly registrationWindowMs: number;
|
|
126
|
+
readonly clientUnusedMs: number;
|
|
127
|
+
readonly maxTrackedAddresses: number;
|
|
128
|
+
readonly accessMs: number;
|
|
129
|
+
readonly refreshMs: number;
|
|
130
|
+
/** Absent: 90 days; clients may set up to 365; 20 live grants per user and client. */
|
|
131
|
+
readonly grant?: {
|
|
132
|
+
readonly maxDays: number;
|
|
133
|
+
readonly clientMaxDays: number;
|
|
134
|
+
readonly maxPerClient: number;
|
|
135
|
+
};
|
|
136
|
+
/** Absent: 5000 ms and 1000 ms. */
|
|
137
|
+
readonly live?: {
|
|
138
|
+
readonly maxAgeMs: number;
|
|
139
|
+
readonly renewBeforeMs: number;
|
|
140
|
+
};
|
|
141
|
+
readonly codeMs: number;
|
|
142
|
+
readonly grantCacheMs: number;
|
|
143
|
+
readonly maxCachedGrants: number;
|
|
144
|
+
readonly grantTouchMs: number;
|
|
145
|
+
readonly codeGraceMs: number;
|
|
146
|
+
readonly pendingMs: number;
|
|
147
|
+
readonly maxPending: number;
|
|
148
|
+
readonly maxBodyBytes: number;
|
|
149
|
+
readonly storeRetryAfterMs: number;
|
|
150
|
+
readonly storeFullRetryAfterMs: number;
|
|
151
|
+
readonly logRepeatWindowMs: number;
|
|
152
|
+
/** Absent: the memory store. */
|
|
153
|
+
readonly store?: OAuthStoreOptions;
|
|
154
|
+
/** Absent: the default paths. */
|
|
155
|
+
readonly paths?: OAuthPaths;
|
|
156
|
+
/** Route id overrides by route key (D-0142); absent: `oauth.<key>`. */
|
|
157
|
+
readonly routeIds?: {
|
|
158
|
+
readonly [K in OAuthRouteKey]?: string;
|
|
159
|
+
};
|
|
160
|
+
/** Absent: the token endpoint is not limited. */
|
|
161
|
+
readonly rateLimit?: {
|
|
162
|
+
readonly policy: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** The routes dokebi-oauth adds, by the key of `routeIds` (D-0142). */
|
|
166
|
+
export declare const OAUTH_ROUTE_KEYS: readonly ['serverMetadata', 'resourceMetadata', 'authorize', 'token', 'revoke', 'register'];
|
|
167
|
+
export type OAuthRouteKey = (typeof OAUTH_ROUTE_KEYS)[number];
|
|
168
|
+
/** The `dokebi-oauth` options declaration (parser and options.schema.json). */
|
|
169
|
+
export declare const options: OptionsDeclaration<OAuthOptions>;
|
|
170
|
+
export declare const CIMD_DEFAULT: OAuthCimdOptions;
|
|
171
|
+
export declare const PATHS_DEFAULT: OAuthPaths;
|
|
172
|
+
export declare const STORE_DEFAULT: MemoryOAuthStoreOptions;
|
|
173
|
+
export declare const GRANT_MAX_DAYS = 90;
|