mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Support nonce and acr with OIDC + other improvements and tests (#883)
* Introduces new configuration variables for OIDC: - GRIST_OIDC_IDP_ENABLED_PROTECTIONS - GRIST_OIDC_IDP_ACR_VALUES - GRIST_OIDC_IDP_EXTRA_CLIENT_METADATA * Implements all supported protections in oidc/Protections.ts * Includes a better error page for failed OIDC logins * Includes some other improvements, e.g. to logging, to OIDC * Adds a large unit test for OIDCConfig * Adds support for SERVER_NODE_OPTIONS for running tests * Adds to documentation/develop.md info about GREP_TESTS, VERBOSE, and SERVER_NODE_OPTIONS.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
export class StringUnionError extends TypeError {
|
||||
constructor(errMessage: string, public readonly actual: string, public readonly values: string[]) {
|
||||
super(errMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeScript will infer a string union type from the literal values passed to
|
||||
* this function. Without `extends string`, it would instead generalize them
|
||||
@@ -28,7 +34,7 @@ export const StringUnion = <UnionType extends string>(...values: UnionType[]) =>
|
||||
if (!guard(value)) {
|
||||
const actual = JSON.stringify(value);
|
||||
const expected = values.map(s => JSON.stringify(s)).join(' | ');
|
||||
throw new TypeError(`Value '${actual}' is not assignable to type '${expected}'.`);
|
||||
throw new StringUnionError(`Value '${actual}' is not assignable to type '${expected}'.`, actual, values);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
@@ -44,6 +50,6 @@ export const StringUnion = <UnionType extends string>(...values: UnionType[]) =>
|
||||
return value != null && guard(value) ? value : undefined;
|
||||
};
|
||||
|
||||
const unionNamespace = {guard, check, parse, values, checkAll};
|
||||
const unionNamespace = { guard, check, parse, values, checkAll };
|
||||
return Object.freeze(unionNamespace as typeof unionNamespace & {type: UnionType});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user