bwh-auth 0.4.0 → 0.6.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 +34 -0
- package/dist/index.cjs +482 -140
- package/dist/index.d.cts +120 -2
- package/dist/index.d.ts +120 -2
- package/dist/index.js +473 -139
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -61,6 +61,26 @@ type AuthButtonComponentProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
|
61
61
|
type AuthInputComponentProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
62
62
|
type AuthLabelComponentProps = React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
63
63
|
type AuthContainerComponentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
64
|
+
type AuthTextareaComponentProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
65
|
+
/** A controlled checkbox: the app's own, e.g. a design-system `Checkbox` with `onCheckedChange`. */
|
|
66
|
+
interface AuthCheckboxComponentProps {
|
|
67
|
+
id: string;
|
|
68
|
+
checked: boolean;
|
|
69
|
+
onCheckedChange: (checked: boolean) => void;
|
|
70
|
+
}
|
|
71
|
+
/** A small inline label, e.g. a design-system `Badge`. */
|
|
72
|
+
type AuthBadgeComponentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
73
|
+
interface AuthRadioGroupOption {
|
|
74
|
+
value: string;
|
|
75
|
+
label: React.ReactNode;
|
|
76
|
+
}
|
|
77
|
+
/** A controlled set of radio options, rendered however the app renders radio groups. */
|
|
78
|
+
interface AuthRadioGroupComponentProps {
|
|
79
|
+
name: string;
|
|
80
|
+
value: string;
|
|
81
|
+
onValueChange: (value: string) => void;
|
|
82
|
+
options: AuthRadioGroupOption[];
|
|
83
|
+
}
|
|
64
84
|
interface AuthComponentSet {
|
|
65
85
|
Button: React.ComponentType<AuthButtonComponentProps>;
|
|
66
86
|
Card: React.ComponentType<AuthContainerComponentProps>;
|
|
@@ -70,6 +90,14 @@ interface AuthComponentSet {
|
|
|
70
90
|
CardTitle: React.ComponentType<AuthContainerComponentProps>;
|
|
71
91
|
Input: React.ComponentType<AuthInputComponentProps>;
|
|
72
92
|
Label: React.ComponentType<AuthLabelComponentProps>;
|
|
93
|
+
/** Optional; native elements are rendered when omitted. */
|
|
94
|
+
Textarea?: React.ComponentType<AuthTextareaComponentProps>;
|
|
95
|
+
Checkbox?: React.ComponentType<AuthCheckboxComponentProps>;
|
|
96
|
+
RadioGroup?: React.ComponentType<AuthRadioGroupComponentProps>;
|
|
97
|
+
/** Optional: the "Sensitive" badge in the scope picker. A `<span>` is rendered when omitted. */
|
|
98
|
+
Badge?: React.ComponentType<AuthBadgeComponentProps>;
|
|
99
|
+
/** Optional: the warning shown for a sensitive scope group. A styled `<p>` is rendered when omitted. */
|
|
100
|
+
Alert?: React.ComponentType<AuthContainerComponentProps>;
|
|
73
101
|
}
|
|
74
102
|
type AuthComponents = AuthComponentSet;
|
|
75
103
|
type AuthComponentOverrides = Partial<AuthComponentSet>;
|
|
@@ -214,6 +242,56 @@ declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
|
214
242
|
declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
215
243
|
declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
|
|
216
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Pure selection logic for the scope picker. Implications are a picker-only
|
|
247
|
+
* cascade: the credential still stores exactly the ids that end up selected,
|
|
248
|
+
* and the server never infers one scope from another.
|
|
249
|
+
*/
|
|
250
|
+
/** scope id => scope ids it needs, e.g. `{ 'billing:write': ['billing:read'] }`. */
|
|
251
|
+
type ScopeImplications = Record<string, string[]>;
|
|
252
|
+
/** Transitive closure of `implications`, with self-references and cycles dropped. */
|
|
253
|
+
declare function closeImplications(implications: ScopeImplications): ScopeImplications;
|
|
254
|
+
/** Keeps only entries whose key and every requirement are offered; drops entries left empty. */
|
|
255
|
+
declare function restrictImplications(implications: ScopeImplications | undefined, offered: Set<string>): ScopeImplications;
|
|
256
|
+
/** Orders `ids` by `catalog`, removing duplicates and ids not in it. */
|
|
257
|
+
declare function inCatalogOrder(ids: Iterable<string>, catalog: string[]): string[];
|
|
258
|
+
/** Ticking: adds the ids and everything they need. */
|
|
259
|
+
declare function withScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
260
|
+
/** Unticking: removes the ids and every selected scope that needs one of them. */
|
|
261
|
+
declare function withoutScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
262
|
+
/** Selected scopes that need `id`, in catalog order: why `id` is ticked beyond the person's own choice. */
|
|
263
|
+
declare function neededBy(id: string, selected: string[], closed: ScopeImplications): string[];
|
|
264
|
+
declare function sameSelection(a: string[], b: string[]): boolean;
|
|
265
|
+
|
|
266
|
+
/** A named set of related scopes (`scopes` are ids from the sibling scope list). */
|
|
267
|
+
interface ApiCredentialScopeGroup {
|
|
268
|
+
id: string;
|
|
269
|
+
label: string;
|
|
270
|
+
description: string | null;
|
|
271
|
+
/** A sensitive group is one parent checkbox, with its scopes behind a disclosure. */
|
|
272
|
+
sensitive: boolean;
|
|
273
|
+
scopes: string[];
|
|
274
|
+
}
|
|
275
|
+
/** A one-click selection: choosing it replaces the selection with exactly `scopes`. */
|
|
276
|
+
interface ApiCredentialScopePreset {
|
|
277
|
+
id: string;
|
|
278
|
+
label: string;
|
|
279
|
+
description: string;
|
|
280
|
+
scopes: string[];
|
|
281
|
+
}
|
|
282
|
+
interface ScopePickerProps {
|
|
283
|
+
idPrefix: string;
|
|
284
|
+
scopes: ApiCredentialScope[];
|
|
285
|
+
/** Absent or empty: a flat list, as before groups existed. */
|
|
286
|
+
groups?: ApiCredentialScopeGroup[];
|
|
287
|
+
presets?: ApiCredentialScopePreset[];
|
|
288
|
+
implications?: ScopeImplications;
|
|
289
|
+
selected: string[];
|
|
290
|
+
onChange: (next: string[]) => void;
|
|
291
|
+
components: AuthComponentInput;
|
|
292
|
+
}
|
|
293
|
+
declare function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }: ScopePickerProps): React.JSX.Element;
|
|
294
|
+
|
|
217
295
|
interface ApiCredentialScope {
|
|
218
296
|
id: string;
|
|
219
297
|
description: string;
|
|
@@ -225,6 +303,8 @@ interface ApiCredentialToken {
|
|
|
225
303
|
created_at: string | null;
|
|
226
304
|
expires_at: string | null;
|
|
227
305
|
revoke_href: string;
|
|
306
|
+
/** True for a token that carries an MCP connection scope. */
|
|
307
|
+
connection?: boolean;
|
|
228
308
|
}
|
|
229
309
|
interface ApiCredentialApp {
|
|
230
310
|
id: string;
|
|
@@ -244,6 +324,24 @@ interface ApiCredentialIndex {
|
|
|
244
324
|
register_app_href: string | null;
|
|
245
325
|
tokens: ApiCredentialToken[];
|
|
246
326
|
apps: ApiCredentialApp[];
|
|
327
|
+
/**
|
|
328
|
+
* Grouped picker data, all optional and presentation only: the credential still
|
|
329
|
+
* stores explicit scope ids. `scope_*` serves the OAuth-app form and, unless the
|
|
330
|
+
* matching `token_*` key is present, the token form. Without groups the picker is a flat list.
|
|
331
|
+
*/
|
|
332
|
+
scope_groups?: ApiCredentialScopeGroup[];
|
|
333
|
+
scope_presets?: ApiCredentialScopePreset[];
|
|
334
|
+
/** scope id => scope ids it needs: ticking a scope ticks them, unticking one unticks what needs it. */
|
|
335
|
+
scope_implications?: ScopeImplications;
|
|
336
|
+
/** A narrower scope list for personal tokens, when the server offers one. */
|
|
337
|
+
token_scopes?: ApiCredentialScope[];
|
|
338
|
+
token_scope_groups?: ApiCredentialScopeGroup[];
|
|
339
|
+
token_scope_presets?: ApiCredentialScopePreset[];
|
|
340
|
+
token_scope_implications?: ScopeImplications;
|
|
341
|
+
/** Offered to personal tokens only: MCP connection scopes, listed after the token scopes. */
|
|
342
|
+
token_connection_scopes?: ApiCredentialScope[];
|
|
343
|
+
/** The lifetimes a token carrying a connection scope may have; replaces `token_lifetimes` for it. */
|
|
344
|
+
connection_token_lifetimes?: string[];
|
|
247
345
|
}
|
|
248
346
|
type IssuedApiCredential = {
|
|
249
347
|
kind: 'token';
|
|
@@ -260,6 +358,24 @@ interface ApiCredentialEndpointLink {
|
|
|
260
358
|
label: string;
|
|
261
359
|
url: string;
|
|
262
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The outcome of one credential request: on success the parsed JSON body
|
|
363
|
+
* (the component reads its `data` when present), on failure the message to show.
|
|
364
|
+
*/
|
|
365
|
+
type ApiCredentialRequestResult = {
|
|
366
|
+
ok: true;
|
|
367
|
+
status: number;
|
|
368
|
+
payload: unknown;
|
|
369
|
+
} | {
|
|
370
|
+
ok: false;
|
|
371
|
+
status: number;
|
|
372
|
+
message: string;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Performs one credential request in place of the built-in `fetch`, so an app
|
|
376
|
+
* can route it through its own client (session-expiry redirect, CSRF, retries).
|
|
377
|
+
*/
|
|
378
|
+
type ApiCredentialRequest = (method: 'GET' | 'POST' | 'DELETE', url: string, body?: object) => Promise<ApiCredentialRequestResult>;
|
|
263
379
|
interface ApiCredentialsSectionProps {
|
|
264
380
|
/** The credential service's index URL (GET). */
|
|
265
381
|
indexUrl: string;
|
|
@@ -267,6 +383,8 @@ interface ApiCredentialsSectionProps {
|
|
|
267
383
|
/** Values a connector needs: the OpenAPI document, API base, OAuth authorize/token URLs, MCP URL. */
|
|
268
384
|
links?: ApiCredentialEndpointLink[];
|
|
269
385
|
csrfToken?: string;
|
|
386
|
+
/** Replaces the built-in `fetch` for every credential request; `csrfToken` is then the app's to send. */
|
|
387
|
+
request?: ApiCredentialRequest;
|
|
270
388
|
onSuccess?: (message: string) => void;
|
|
271
389
|
onError?: (field: string, message: string) => void;
|
|
272
390
|
}
|
|
@@ -279,8 +397,8 @@ interface ApiCredentialsSectionProps {
|
|
|
279
397
|
* in this component's memory; afterwards only the lists are reloaded, so it is
|
|
280
398
|
* never part of page props or browser history.
|
|
281
399
|
*/
|
|
282
|
-
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
400
|
+
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
283
401
|
/** PT4H → "4 hours", P30D → "30 days", P1Y → "1 year". Unknown shapes are shown as given. */
|
|
284
402
|
declare function describeDuration(spec: string): string;
|
|
285
403
|
|
|
286
|
-
export { type ApiCredentialApp, type ApiCredentialEndpointLink, type ApiCredentialIndex, type ApiCredentialScope, type ApiCredentialToken, ApiCredentialsSection, type ApiCredentialsSectionProps, type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, type IssuedApiCredential, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, describeDuration, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
|
|
404
|
+
export { type ApiCredentialApp, type ApiCredentialEndpointLink, type ApiCredentialIndex, type ApiCredentialRequest, type ApiCredentialRequestResult, type ApiCredentialScope, type ApiCredentialScopeGroup, type ApiCredentialScopePreset, type ApiCredentialToken, ApiCredentialsSection, type ApiCredentialsSectionProps, type AuthBadgeComponentProps, type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthCheckboxComponentProps, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthRadioGroupComponentProps, type AuthRadioGroupOption, type AuthSignupField, type AuthSignupValues, type AuthTextareaComponentProps, type AuthValidationErrors, ChangePasswordForm, type IssuedApiCredential, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, type ScopeImplications, ScopePicker, type ScopePickerProps, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, closeImplications, describeDuration, getCsrfToken, getDefaultPasskeyName, inCatalogOrder, isAbortError, isConditionalMediationAvailable, neededBy, registerPasskey, relyingApplicationsFrom, restrictImplications, safeApplicationHref, sameSelection, withScopes, withoutScopes };
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,26 @@ type AuthButtonComponentProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
|
61
61
|
type AuthInputComponentProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
62
62
|
type AuthLabelComponentProps = React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
63
63
|
type AuthContainerComponentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
64
|
+
type AuthTextareaComponentProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
65
|
+
/** A controlled checkbox: the app's own, e.g. a design-system `Checkbox` with `onCheckedChange`. */
|
|
66
|
+
interface AuthCheckboxComponentProps {
|
|
67
|
+
id: string;
|
|
68
|
+
checked: boolean;
|
|
69
|
+
onCheckedChange: (checked: boolean) => void;
|
|
70
|
+
}
|
|
71
|
+
/** A small inline label, e.g. a design-system `Badge`. */
|
|
72
|
+
type AuthBadgeComponentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
73
|
+
interface AuthRadioGroupOption {
|
|
74
|
+
value: string;
|
|
75
|
+
label: React.ReactNode;
|
|
76
|
+
}
|
|
77
|
+
/** A controlled set of radio options, rendered however the app renders radio groups. */
|
|
78
|
+
interface AuthRadioGroupComponentProps {
|
|
79
|
+
name: string;
|
|
80
|
+
value: string;
|
|
81
|
+
onValueChange: (value: string) => void;
|
|
82
|
+
options: AuthRadioGroupOption[];
|
|
83
|
+
}
|
|
64
84
|
interface AuthComponentSet {
|
|
65
85
|
Button: React.ComponentType<AuthButtonComponentProps>;
|
|
66
86
|
Card: React.ComponentType<AuthContainerComponentProps>;
|
|
@@ -70,6 +90,14 @@ interface AuthComponentSet {
|
|
|
70
90
|
CardTitle: React.ComponentType<AuthContainerComponentProps>;
|
|
71
91
|
Input: React.ComponentType<AuthInputComponentProps>;
|
|
72
92
|
Label: React.ComponentType<AuthLabelComponentProps>;
|
|
93
|
+
/** Optional; native elements are rendered when omitted. */
|
|
94
|
+
Textarea?: React.ComponentType<AuthTextareaComponentProps>;
|
|
95
|
+
Checkbox?: React.ComponentType<AuthCheckboxComponentProps>;
|
|
96
|
+
RadioGroup?: React.ComponentType<AuthRadioGroupComponentProps>;
|
|
97
|
+
/** Optional: the "Sensitive" badge in the scope picker. A `<span>` is rendered when omitted. */
|
|
98
|
+
Badge?: React.ComponentType<AuthBadgeComponentProps>;
|
|
99
|
+
/** Optional: the warning shown for a sensitive scope group. A styled `<p>` is rendered when omitted. */
|
|
100
|
+
Alert?: React.ComponentType<AuthContainerComponentProps>;
|
|
73
101
|
}
|
|
74
102
|
type AuthComponents = AuthComponentSet;
|
|
75
103
|
type AuthComponentOverrides = Partial<AuthComponentSet>;
|
|
@@ -214,6 +242,56 @@ declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
|
214
242
|
declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
215
243
|
declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
|
|
216
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Pure selection logic for the scope picker. Implications are a picker-only
|
|
247
|
+
* cascade: the credential still stores exactly the ids that end up selected,
|
|
248
|
+
* and the server never infers one scope from another.
|
|
249
|
+
*/
|
|
250
|
+
/** scope id => scope ids it needs, e.g. `{ 'billing:write': ['billing:read'] }`. */
|
|
251
|
+
type ScopeImplications = Record<string, string[]>;
|
|
252
|
+
/** Transitive closure of `implications`, with self-references and cycles dropped. */
|
|
253
|
+
declare function closeImplications(implications: ScopeImplications): ScopeImplications;
|
|
254
|
+
/** Keeps only entries whose key and every requirement are offered; drops entries left empty. */
|
|
255
|
+
declare function restrictImplications(implications: ScopeImplications | undefined, offered: Set<string>): ScopeImplications;
|
|
256
|
+
/** Orders `ids` by `catalog`, removing duplicates and ids not in it. */
|
|
257
|
+
declare function inCatalogOrder(ids: Iterable<string>, catalog: string[]): string[];
|
|
258
|
+
/** Ticking: adds the ids and everything they need. */
|
|
259
|
+
declare function withScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
260
|
+
/** Unticking: removes the ids and every selected scope that needs one of them. */
|
|
261
|
+
declare function withoutScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
262
|
+
/** Selected scopes that need `id`, in catalog order: why `id` is ticked beyond the person's own choice. */
|
|
263
|
+
declare function neededBy(id: string, selected: string[], closed: ScopeImplications): string[];
|
|
264
|
+
declare function sameSelection(a: string[], b: string[]): boolean;
|
|
265
|
+
|
|
266
|
+
/** A named set of related scopes (`scopes` are ids from the sibling scope list). */
|
|
267
|
+
interface ApiCredentialScopeGroup {
|
|
268
|
+
id: string;
|
|
269
|
+
label: string;
|
|
270
|
+
description: string | null;
|
|
271
|
+
/** A sensitive group is one parent checkbox, with its scopes behind a disclosure. */
|
|
272
|
+
sensitive: boolean;
|
|
273
|
+
scopes: string[];
|
|
274
|
+
}
|
|
275
|
+
/** A one-click selection: choosing it replaces the selection with exactly `scopes`. */
|
|
276
|
+
interface ApiCredentialScopePreset {
|
|
277
|
+
id: string;
|
|
278
|
+
label: string;
|
|
279
|
+
description: string;
|
|
280
|
+
scopes: string[];
|
|
281
|
+
}
|
|
282
|
+
interface ScopePickerProps {
|
|
283
|
+
idPrefix: string;
|
|
284
|
+
scopes: ApiCredentialScope[];
|
|
285
|
+
/** Absent or empty: a flat list, as before groups existed. */
|
|
286
|
+
groups?: ApiCredentialScopeGroup[];
|
|
287
|
+
presets?: ApiCredentialScopePreset[];
|
|
288
|
+
implications?: ScopeImplications;
|
|
289
|
+
selected: string[];
|
|
290
|
+
onChange: (next: string[]) => void;
|
|
291
|
+
components: AuthComponentInput;
|
|
292
|
+
}
|
|
293
|
+
declare function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }: ScopePickerProps): React.JSX.Element;
|
|
294
|
+
|
|
217
295
|
interface ApiCredentialScope {
|
|
218
296
|
id: string;
|
|
219
297
|
description: string;
|
|
@@ -225,6 +303,8 @@ interface ApiCredentialToken {
|
|
|
225
303
|
created_at: string | null;
|
|
226
304
|
expires_at: string | null;
|
|
227
305
|
revoke_href: string;
|
|
306
|
+
/** True for a token that carries an MCP connection scope. */
|
|
307
|
+
connection?: boolean;
|
|
228
308
|
}
|
|
229
309
|
interface ApiCredentialApp {
|
|
230
310
|
id: string;
|
|
@@ -244,6 +324,24 @@ interface ApiCredentialIndex {
|
|
|
244
324
|
register_app_href: string | null;
|
|
245
325
|
tokens: ApiCredentialToken[];
|
|
246
326
|
apps: ApiCredentialApp[];
|
|
327
|
+
/**
|
|
328
|
+
* Grouped picker data, all optional and presentation only: the credential still
|
|
329
|
+
* stores explicit scope ids. `scope_*` serves the OAuth-app form and, unless the
|
|
330
|
+
* matching `token_*` key is present, the token form. Without groups the picker is a flat list.
|
|
331
|
+
*/
|
|
332
|
+
scope_groups?: ApiCredentialScopeGroup[];
|
|
333
|
+
scope_presets?: ApiCredentialScopePreset[];
|
|
334
|
+
/** scope id => scope ids it needs: ticking a scope ticks them, unticking one unticks what needs it. */
|
|
335
|
+
scope_implications?: ScopeImplications;
|
|
336
|
+
/** A narrower scope list for personal tokens, when the server offers one. */
|
|
337
|
+
token_scopes?: ApiCredentialScope[];
|
|
338
|
+
token_scope_groups?: ApiCredentialScopeGroup[];
|
|
339
|
+
token_scope_presets?: ApiCredentialScopePreset[];
|
|
340
|
+
token_scope_implications?: ScopeImplications;
|
|
341
|
+
/** Offered to personal tokens only: MCP connection scopes, listed after the token scopes. */
|
|
342
|
+
token_connection_scopes?: ApiCredentialScope[];
|
|
343
|
+
/** The lifetimes a token carrying a connection scope may have; replaces `token_lifetimes` for it. */
|
|
344
|
+
connection_token_lifetimes?: string[];
|
|
247
345
|
}
|
|
248
346
|
type IssuedApiCredential = {
|
|
249
347
|
kind: 'token';
|
|
@@ -260,6 +358,24 @@ interface ApiCredentialEndpointLink {
|
|
|
260
358
|
label: string;
|
|
261
359
|
url: string;
|
|
262
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The outcome of one credential request: on success the parsed JSON body
|
|
363
|
+
* (the component reads its `data` when present), on failure the message to show.
|
|
364
|
+
*/
|
|
365
|
+
type ApiCredentialRequestResult = {
|
|
366
|
+
ok: true;
|
|
367
|
+
status: number;
|
|
368
|
+
payload: unknown;
|
|
369
|
+
} | {
|
|
370
|
+
ok: false;
|
|
371
|
+
status: number;
|
|
372
|
+
message: string;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Performs one credential request in place of the built-in `fetch`, so an app
|
|
376
|
+
* can route it through its own client (session-expiry redirect, CSRF, retries).
|
|
377
|
+
*/
|
|
378
|
+
type ApiCredentialRequest = (method: 'GET' | 'POST' | 'DELETE', url: string, body?: object) => Promise<ApiCredentialRequestResult>;
|
|
263
379
|
interface ApiCredentialsSectionProps {
|
|
264
380
|
/** The credential service's index URL (GET). */
|
|
265
381
|
indexUrl: string;
|
|
@@ -267,6 +383,8 @@ interface ApiCredentialsSectionProps {
|
|
|
267
383
|
/** Values a connector needs: the OpenAPI document, API base, OAuth authorize/token URLs, MCP URL. */
|
|
268
384
|
links?: ApiCredentialEndpointLink[];
|
|
269
385
|
csrfToken?: string;
|
|
386
|
+
/** Replaces the built-in `fetch` for every credential request; `csrfToken` is then the app's to send. */
|
|
387
|
+
request?: ApiCredentialRequest;
|
|
270
388
|
onSuccess?: (message: string) => void;
|
|
271
389
|
onError?: (field: string, message: string) => void;
|
|
272
390
|
}
|
|
@@ -279,8 +397,8 @@ interface ApiCredentialsSectionProps {
|
|
|
279
397
|
* in this component's memory; afterwards only the lists are reloaded, so it is
|
|
280
398
|
* never part of page props or browser history.
|
|
281
399
|
*/
|
|
282
|
-
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
400
|
+
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
283
401
|
/** PT4H → "4 hours", P30D → "30 days", P1Y → "1 year". Unknown shapes are shown as given. */
|
|
284
402
|
declare function describeDuration(spec: string): string;
|
|
285
403
|
|
|
286
|
-
export { type ApiCredentialApp, type ApiCredentialEndpointLink, type ApiCredentialIndex, type ApiCredentialScope, type ApiCredentialToken, ApiCredentialsSection, type ApiCredentialsSectionProps, type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, type IssuedApiCredential, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, describeDuration, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
|
|
404
|
+
export { type ApiCredentialApp, type ApiCredentialEndpointLink, type ApiCredentialIndex, type ApiCredentialRequest, type ApiCredentialRequestResult, type ApiCredentialScope, type ApiCredentialScopeGroup, type ApiCredentialScopePreset, type ApiCredentialToken, ApiCredentialsSection, type ApiCredentialsSectionProps, type AuthBadgeComponentProps, type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthCheckboxComponentProps, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthRadioGroupComponentProps, type AuthRadioGroupOption, type AuthSignupField, type AuthSignupValues, type AuthTextareaComponentProps, type AuthValidationErrors, ChangePasswordForm, type IssuedApiCredential, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, type ScopeImplications, ScopePicker, type ScopePickerProps, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, closeImplications, describeDuration, getCsrfToken, getDefaultPasskeyName, inCatalogOrder, isAbortError, isConditionalMediationAvailable, neededBy, registerPasskey, relyingApplicationsFrom, restrictImplications, safeApplicationHref, sameSelection, withScopes, withoutScopes };
|