Typescript Support?
Is there any plans to support Typescript?
I don’t intend to provide any myself.
Change of heart, i'll bundle definitions with 3.x
@panva: Just so that we can get an idea, when do you plan to release v3? Thx
@panva great news. do you need support or are you already about to migrate the whole project to Typescript?
@jaulz i'm not gonna migrate the project, i'll expose types only. Same note applies as in https://github.com/panva/jose/issues/9 if you could review the types there and how they're defined, I'm not a TS user myself so feedback on the types themselves would be great.
@panva great. I just had a superficial look at the declarations and they look clean and exactly how it should be 😊 did you already start with the types? Otherwise I could raise a PR with my basic types and we could go on from there.
If you could paste a gist here it'd be a good starting point. Thanks
@panva sure, here you go. I'm not sure about the fields since I am not 100% familiar with the specification but it's basically what I took from this example: https://connect2id.com/products/server/docs/api/discovery
declare module "openid-client" {
export class OpenIdConnectError extends Error {
error: string;
error_description?: string;
error_uri?: string;
state?: string;
scope?: string;
response?: any;
}
type DiscoverOptions = {
issuer: string;
authorization_endpoint: string;
token_endpoint: string;
userinfo_endpoint: string;
jwks_uri: string;
};
export class Issuer {
constructor(options: DiscoverOptions);
static discover(url: string): Promise<Issuer>;
Client: typeof Client;
useRequest(): void;
}
type ClientOptions = {
client_id: string;
client_secret: string;
};
type ClientKeyStore = any;
type ClientTokenSet = {
claims: any;
};
type SupportedScopes =
| "openid"
| "profile"
| "email"
| "address"
| "phone"
| "offline_access";
type ResponseTypesScopes =
| "code"
| "token"
| "id_token"
| "id_token token"
| "code id_token"
| "code id_token token";
type ResponseModesScopes = "query" | "fragment" | "form_post";
type GrantTypesSupported =
| "implicit"
| "authorization_code"
| "refresh_token"
| "password"
| "client_credentials"
| "urn:ietf:params:oauth:grant-type:jwt-bearer";
type CodeChallengeMethodsSupported = "S256" | "plain";
type TokenEndpointAuthMethodsSupported =
| "client_secret_basic"
| "client_secret_post"
| "client_secret_jwt"
| "private_key_jwt"
| "self_signed_tls_client_auth"
| "none";
type TokenEndpointAuthSigningAlgValuesSupported =
| "HS256"
| "HS384"
| "HS512"
| "RS256"
| "RS384"
| "RS512"
| "PS256"
| "PS384"
| "PS512"
| "ES256"
| "ES384"
| "ES512";
type RequestObjectSigningAlgValuesSupported =
| "HS256"
| "HS384"
| "HS512"
| "RS256"
| "RS384"
| "RS512"
| "PS256"
| "PS384"
| "PS512"
| "ES256"
| "ES384"
| "ES512"
| "none";
type SubjectTypesSupported = "public" | "pairwise";
type IdTokenSigningAlgValuesSupported =
| "RS256"
| "RS384"
| "RS512"
| "PS256"
| "PS384"
| "PS512"
| "ES256"
| "ES384"
| "ES512"
| "HS256"
| "HS384"
| "HS512"
| "none";
type IdTokenEncryptionAlgValuesSupported =
| "RSA1_5"
| "RSA-OAEP"
| "RSA-OAEP-256"
| "ECDH-ES"
| "ECDH-ES+A128KW"
| "ECDH-ES+A192KW"
| "ECDH-ES+A256KW"
| "dir"
| "A128KW"
| "A192KW"
| "A256KW"
| "A128GCMKW"
| "A192GCMKW"
| "A256GCMKW";
type IdTokenEncryptionEncValuesSupported =
| "A128CBC-HS256"
| "A192CBC-HS384"
| "A256CBC-HS512"
| "A128GCM"
| "A192GCM"
| "A256GCM";
type UserinfoSigningAlgValuesSupported =
| "RS256"
| "RS384"
| "RS512"
| "PS256"
| "PS384"
| "PS512"
| "ES256"
| "ES384"
| "ES512"
| "HS256"
| "HS384"
| "HS512";
type UserinfoEncryptionAlgValuesSupported =
| "RSA1_5"
| "RSA-OAEP"
| "RSA-OAEP-256"
| "ECDH-ES"
| "ECDH-ES+A128KW"
| "ECDH-ES+A192KW"
| "ECDH-ES+A256KW"
| "dir"
| "A128KW"
| "A192KW"
| "A256KW"
| "A128GCMKW"
| "A192GCMKW"
| "A256GCMKW";
type UserinfoEncryptionEncValuesSupported =
| "A128CBC-HS256"
| "A192CBC-HS384"
| "A256CBC-HS512"
| "A128GCM"
| "A192GCM"
| "A256GCM";
type DisplayValuesSupported = "page" | "popup";
type ClaimTypesSupported = "normal";
type ClaimsSupported =
| "sub"
| "iss"
| "auth_time"
| "acr"
| "name"
| "given_name"
| "family_name"
| "nickname"
| "email"
| "email_verified";
type Metadata = {
issuer: string;
jwks_uri: string;
authorization_endpoint: string;
token_endpoint: string;
registration_endpoint: string;
introspection_endpoint: string;
revocation_endpoint: string;
userinfo_endpoint: string;
scopes_supported: SupportedScopes[];
response_types_supported: ResponseTypesScopes[];
response_modes_supported: ResponseModesScopes[];
grant_types_supported: GrantTypesSupported[];
code_challenge_methods_supported: CodeChallengeMethodsSupported[];
token_endpoint_auth_methods_supported: TokenEndpointAuthMethodsSupported[];
token_endpoint_auth_signing_alg_values_supported: TokenEndpointAuthSigningAlgValuesSupported[];
request_object_signing_alg_values_supported: RequestObjectSigningAlgValuesSupported[];
ui_locales_supported: string[];
request_parameter_supported: boolean;
request_uri_parameter_supported: boolean;
require_request_uri_registration: boolean;
tls_client_certificate_bound_access_tokens: boolean;
request_uri_quota: number;
subject_types_supported: SubjectTypesSupported[];
acr_values_supported: string[];
id_token_signing_alg_values_supported: IdTokenSigningAlgValuesSupported[];
id_token_encryption_alg_values_supported: IdTokenEncryptionAlgValuesSupported[];
id_token_encryption_enc_values_supported: IdTokenEncryptionEncValuesSupported[];
userinfo_signing_alg_values_supported: UserinfoSigningAlgValuesSupported[];
userinfo_encryption_alg_values_supported: UserinfoEncryptionAlgValuesSupported[];
userinfo_encryption_enc_values_supported: UserinfoEncryptionEncValuesSupported[];
display_values_supported: DisplayValuesSupported[];
claim_types_supported: ClaimTypesSupported[];
claims_supported: ClaimsSupported[];
claims_parameter_supported: boolean;
frontchannel_logout_supported: boolean;
frontchannel_logout_session_supported: boolean;
backchannel_logout_supported: boolean;
backchannel_logout_session_supported: boolean;
};
export class Client {
constructor(options: ClientOptions, keystore?: ClientKeyStore);
static fromUri(
registrationClientUri: string,
registrationAccessToken: string,
keystore?: ClientKeyStore
): Promise<Client>;
CLOCK_TOLERANCE: number;
issuer: {
metadata: Metadata;
};
authorizationUrl(params: {
redirect_uri: string;
scope: string;
claims?: object;
[key: string]: any;
}): string;
authorizationPost(params: {
redirect_uri: string;
scope: string;
claims?: object;
[key: string]: any;
}): string;
authorizationCallback(
callbackUri: string,
query: object,
params: {
state: string;
response_type: string;
nonce?: string;
max_age?: number;
code_verifier?: any;
}
): Promise<ClientTokenSet>;
callbackParams(): { code: string };
}
}
@jaulz what would be error_uri for OpenIdConnectError.state?
@wegylexy here you can see it: https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0-01.html#rfc.section.13
"OPTIONAL. A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. Values for the "error_uri" parameter MUST conform to the URI-reference syntax and thus MUST NOT include characters outside the set %x21 / %x23-5B / %x5D-7E."
@jaulz so it should be string, or missing a type declaration
@wegylexy oh yeah, sure. sorry for the mistake!
Do we have a eta for the release of version 3, or could we bundle in the above type definition into version 2?
@joshuaanthonydeleon hmm, the above is incomplete.
@joshuaanthonydeleon
Do we have a eta for the release of version 3
Earliest with the release of node 12 end of april if all dependencies work out of the box, if not, once they get fixed.
I started with the typings I needed and added them to DT.
See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/35412
I've opened a PR that adds a comprehensive set of definitions
https://github.com/panva/node-openid-client/pull/184