n8n
Version:
n8n Workflow Automation Tool
79 lines (78 loc) • 3.25 kB
TypeScript
import { Logger } from '@n8n/backend-common';
import type { ICredentialContext } from 'n8n-workflow';
import { z } from 'zod';
import { CacheService } from '../../../../services/cache/cache.service';
import { ITokenIdentifier } from './identifier-interface';
export declare const OAuth2IntrospectionOptionsSchema: z.ZodObject<{
validation: z.ZodLiteral<"oauth2-introspection">;
clientId: z.ZodString;
clientSecret: z.ZodString;
metadataUri: z.ZodString;
subjectClaim: z.ZodDefault<z.ZodOptional<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
validation: "oauth2-introspection";
clientId: string;
clientSecret: string;
metadataUri: string;
subjectClaim: string;
}, {
validation: "oauth2-introspection";
clientId: string;
clientSecret: string;
metadataUri: string;
subjectClaim?: string | undefined;
}>;
export declare const TokenIntrospectionResponseSchema: z.ZodObject<{
active: z.ZodBoolean;
scope: z.ZodOptional<z.ZodString>;
client_id: z.ZodOptional<z.ZodString>;
username: z.ZodOptional<z.ZodString>;
token_type: z.ZodOptional<z.ZodString>;
exp: z.ZodOptional<z.ZodNumber>;
iat: z.ZodOptional<z.ZodNumber>;
nbf: z.ZodOptional<z.ZodNumber>;
sub: z.ZodOptional<z.ZodString>;
aud: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
iss: z.ZodOptional<z.ZodString>;
jti: z.ZodOptional<z.ZodString>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
active: z.ZodBoolean;
scope: z.ZodOptional<z.ZodString>;
client_id: z.ZodOptional<z.ZodString>;
username: z.ZodOptional<z.ZodString>;
token_type: z.ZodOptional<z.ZodString>;
exp: z.ZodOptional<z.ZodNumber>;
iat: z.ZodOptional<z.ZodNumber>;
nbf: z.ZodOptional<z.ZodNumber>;
sub: z.ZodOptional<z.ZodString>;
aud: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
iss: z.ZodOptional<z.ZodString>;
jti: z.ZodOptional<z.ZodString>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
active: z.ZodBoolean;
scope: z.ZodOptional<z.ZodString>;
client_id: z.ZodOptional<z.ZodString>;
username: z.ZodOptional<z.ZodString>;
token_type: z.ZodOptional<z.ZodString>;
exp: z.ZodOptional<z.ZodNumber>;
iat: z.ZodOptional<z.ZodNumber>;
nbf: z.ZodOptional<z.ZodNumber>;
sub: z.ZodOptional<z.ZodString>;
aud: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
iss: z.ZodOptional<z.ZodString>;
jti: z.ZodOptional<z.ZodString>;
}, z.ZodTypeAny, "passthrough">>;
export type TokenIntrospectionResponse = z.infer<typeof TokenIntrospectionResponseSchema>;
export declare class OAuth2TokenIntrospectionIdentifier implements ITokenIdentifier {
private readonly logger;
private readonly cache;
constructor(logger: Logger, cache: CacheService);
validateOptions(identifierOptions: Record<string, unknown>): Promise<void>;
resolve(context: ICredentialContext, identifierOptions: Record<string, unknown>): Promise<string>;
private parseOptions;
private fetchMetadata;
private buildClientBasicRequest;
private buildClientPostRequest;
private parseIntrospectionResponse;
private resolveBasedOnTokenIntrospection;
}