tharos-web-sdk 0.2.0 → 0.3.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/dist/index.cjs CHANGED
@@ -97,8 +97,12 @@ var JourneyResponse = class extends BasicTharosContext {
97
97
  };
98
98
  var JourneyRequestProcess = class extends BasicTharosContext {
99
99
  async start(payload, executor, options) {
100
+ let uri = `/realms/${this.ctx.config.realm}/journeys/auth`;
101
+ if (options == null ? void 0 : options.params) {
102
+ uri += "?" + Object.entries(options.params).map((val) => val.join("=")).join("&");
103
+ }
100
104
  let journeyResponse = await this.ctx.api.post(
101
- `/realms/${this.ctx.config.realm}/journeys/auth`,
105
+ uri,
102
106
  payload,
103
107
  {
104
108
  headers: options == null ? void 0 : options.headers
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/tharos.ts","../src/client-inputs/client-input.ts","../src/auth/journey.ts","../src/auth/user.ts","../src/http.ts","../src/config.ts","../src/types/journey.ts","../src/client-inputs/user-name.ts","../src/client-inputs/password.ts","../src/client-inputs/metadata.ts","../src/client-inputs/choice.ts","../src/auth/tokens.ts","../src/error.ts"],"sourcesContent":["import { JourneyRequestProcess, type JourneyExecutor } from './auth/journey.js';\nimport { User } from './auth/user.js';\nimport { TharosConfig } from './config.js';\nimport { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\nexport * from './client-inputs/index';\nexport * from './types/index';\nexport * from './auth/index';\nexport * from './config';\nexport * from './error';\nexport * from './http';\nexport * from './tharos';\n\nexport class Tharos {\n public readonly config: TharosConfig;\n public readonly api: ApiClient;\n public readonly journey: JourneyRequestProcess;\n private defaultJourneyExecutor: JourneyExecutor | undefined;\n private user: User | null = null;\n\n constructor({ config, defaultJourneyExecutor }: { config: TharosConfig; defaultJourneyExecutor?: JourneyExecutor }) {\n this.config = config;\n this.api = new ApiClient(this.config.tharosAuthUrl);\n this.journey = new JourneyRequestProcess(this);\n this.defaultJourneyExecutor = defaultJourneyExecutor;\n\n const currentURL = new URL(window.location.href).origin + new URL(window.location.href).pathname;\n\n if (currentURL === this.config.oauth?.redirectUri) {\n }\n }\n\n public getDefaultJourneyExecutor() {\n return this.defaultJourneyExecutor;\n }\n\n public getCurrentUser() {\n return this.user;\n }\n\n public async setAuthenticatedUser() {\n const user = new User(this);\n\n await user.sessionInfo();\n this.user = user;\n }\n\n public getAuthorizeUrl(config?: OAuth): string {\n if (!config) {\n if (!this.config.oauth) {\n throw new Error('oauth not configured');\n }\n\n config = this.config.oauth;\n }\n\n return `${this.config.tharosAuthUrl}/realms/${this.config.realm}/oauth2/auth?client_id=${config.clientId}&scope=${config.scope}&response_type=code&redirect_uri=${config.redirectUri}&acr_values=all1`;\n }\n\n public async exchangeTokens() {\n const url = new URL(window.location.href);\n this.api.post(\n `/realms/${this.config.realm}/oauth2/token`,\n {\n grant_type: 'authorization_code',\n code: url.searchParams.get('code'),\n client_id: this.config.oauth?.clientId,\n scope: this.config.oauth?.scope,\n },\n { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }\n );\n }\n\n public static async newInstance(baseConfig: Config) {\n return new Tharos({ config: await TharosConfig.newInstance(baseConfig) });\n }\n}\n","import type { JourneyRequestProcess } from './auth/journey.js';\nimport type { User } from './auth/user.js';\nimport type { TharosConfig } from './config.js';\nimport type { ApiClient } from './http.js';\n\nexport interface TharosImpl {\n config: TharosConfig;\n api: ApiClient;\n journey: JourneyRequestProcess;\n getCurrentUser(): User | null;\n setAuthenticatedUser(): Promise<void>;\n}\n\nexport class BasicTharosContext {\n protected ctx: TharosImpl;\n\n constructor(tharosCtx: TharosImpl) {\n this.ctx = tharosCtx;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { ClientInput } from '../types/journey.js';\n\nexport class JourneyStepType extends BasicTharosContext {\n private clientInput: ClientInput;\n public static readonly stepsMap: Map<string, typeof JourneyStepType> = new Map();\n\n constructor(clientInput: ClientInput, ctx: TharosImpl) {\n super(ctx);\n\n this.clientInput = clientInput;\n }\n\n public getID() {\n return this.clientInput.id;\n }\n\n public getStepType() {\n return this.clientInput.step_type;\n }\n\n public getType() {\n return this.clientInput.type;\n }\n\n public setInput(data: any) {\n this.clientInput.input = data;\n }\n\n public getOutput() {\n return this.clientInput.output;\n }\n\n public getPayload() {\n return this.clientInput;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type {\n ClientInput,\n JourneyFailure,\n JourneyRequest,\n JourneyResponsePayload,\n JourneySuccess,\n StepType,\n} from '../types/journey.js';\nimport { JourneyStepType } from '../client-inputs/client-input.js';\n\nexport class JourneyResponse extends BasicTharosContext {\n private journeyResponsePayload: JourneyResponsePayload;\n private clientInputs: JourneyStepType[];\n\n constructor(journeyResponsePayload: JourneyResponsePayload, ctx: TharosImpl) {\n super(ctx);\n\n this.journeyResponsePayload = journeyResponsePayload;\n this.clientInputs = this.journeyResponsePayload.client_inputs.map(\n (el) => new (JourneyStepType.stepsMap.get(el.step_type.toString())!)(el, ctx)\n );\n }\n\n public getJourneyToken() {\n return this.journeyResponsePayload.journey_token;\n }\n\n public getClientInputs<T extends JourneyStepType>(stepType: StepType): T[] {\n return this.clientInputs.filter((el) => el.getStepType() == stepType) as T[];\n }\n\n public getAllClientInputs() {\n return this.clientInputs;\n }\n}\n\nexport class JourneyRequestProcess extends BasicTharosContext {\n public async start(\n payload: { journey_id: string } | { resume_id: string },\n executor: JourneyExecutor,\n options?: { headers: Map<string, string> }\n ) {\n let journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n payload,\n {\n headers: options?.headers as any,\n }\n );\n\n while (journeyResponse.hasOwnProperty('journey_token')) {\n journeyResponse = journeyResponse as JourneyResponsePayload;\n let process = new JourneyResponse(journeyResponse, this.ctx);\n await executor.onNewStep(process);\n\n journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n {\n journey_token: journeyResponse.journey_token,\n client_inputs: process.getAllClientInputs().map((el) => el.getPayload()),\n }\n );\n }\n\n if (journeyResponse.hasOwnProperty('session_id')) {\n await this.ctx.setAuthenticatedUser();\n executor.onSuccess(journeyResponse as JourneySuccess);\n } else {\n executor.onFailure(journeyResponse as JourneyFailure);\n }\n }\n}\n\nexport interface JourneyExecutor {\n onSuccess: (journeySuccess: JourneySuccess) => Promise<void>;\n onFailure: (journeyFailure: JourneyFailure) => Promise<void>;\n onNewStep: (journeyResponse: JourneyResponse) => Promise<void>;\n}\n","import { BasicTharosContext } from '../tharos.js';\nimport type { UserTokens } from './tokens.js';\n\nexport class User extends BasicTharosContext {\n private tokens: UserTokens | null = null;\n\n public getUserTokens() {\n return this.tokens;\n }\n\n public async sessionInfo() {\n return await this.ctx.api.post<Record<string, string>>(`/realms/${this.ctx.config.realm}/session/info`);\n }\n\n public async validateSession(refresh: boolean = false) {\n return await this.ctx.api.post<Record<string, string>>(\n `/realms/${this.ctx.config.realm}/session/validate?refresh=${refresh}`\n );\n }\n}\n","type RequestInterceptor = (url: string, request: RequestInit) => Promise<[string, RequestInit]> | [string, RequestInit];\n\ntype ResponseInterceptor = (response: Response) => Promise<Response> | Response;\n\nexport class HttpError extends Error {\n code: number;\n details: any;\n\n constructor({ code, message, details }: { code: number; message: string; details: any }) {\n super(message);\n\n this.code = code;\n this.details = details;\n }\n}\n\nexport class ApiClient {\n private baseUrl: string;\n private defaultHeaders: Record<string, string>;\n private requestInterceptors: RequestInterceptor[];\n private responseInterceptors: ResponseInterceptor[];\n\n constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n this.baseUrl = baseUrl;\n this.defaultHeaders = { ...defaultHeaders };\n this.requestInterceptors = [];\n this.responseInterceptors = [];\n }\n\n withPath(subPath: string): ApiClient {\n const child = new ApiClient(this.baseUrl + subPath, this.defaultHeaders);\n\n child.requestInterceptors = [...this.requestInterceptors];\n child.responseInterceptors = [...this.responseInterceptors];\n\n return child;\n }\n\n setDefaultHeader(key: string, value: string) {\n this.defaultHeaders[key] = value;\n }\n\n addRequestInterceptor(interceptor: RequestInterceptor) {\n this.requestInterceptors.push(interceptor);\n }\n\n addResponseInterceptor(interceptor: ResponseInterceptor) {\n this.responseInterceptors.push(interceptor);\n }\n\n async fetch<T>(path: string, options: RequestInit & { overrideUrl?: boolean } = {}): Promise<T> {\n if (path == '/') {\n path = '';\n }\n\n let url = options.overrideUrl ? path : `${this.baseUrl}${path}`;\n let init: RequestInit = {\n headers: { ...this.defaultHeaders, ...(options.headers || {}) },\n ...options,\n credentials: 'include',\n };\n\n // Interceptores de request\n for (const interceptor of this.requestInterceptors) {\n [url, init] = await interceptor(url, init);\n }\n\n // Ejecutar fetch\n let response = await fetch(url, init);\n\n // Interceptores de response\n for (const interceptor of this.responseInterceptors) {\n response = await interceptor(response);\n }\n\n if (!response.ok) {\n if (response.headers.get('content-type')?.includes('application/json')) {\n throw new HttpError(await response.json());\n } else {\n throw new Error(`Error ${response.status}: ${response.statusText}`);\n }\n }\n\n return response.json() as Promise<T>;\n }\n\n get<T>(path: string, options?: RequestInit & { overrideUrl?: boolean }) {\n return this.fetch<T>(path, { ...options, method: 'GET' });\n }\n post<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'POST',\n body: JSON.stringify(body),\n });\n }\n put<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'PUT',\n body: JSON.stringify(body),\n });\n }\n delete<T>(path: string, options?: RequestInit) {\n return this.fetch<T>(path, { ...options, method: 'DELETE' });\n }\n}\n","import { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\n\nexport interface OpenIdConfiguration {\n issuer: string;\n\n authorization_endpoint: string;\n token_endpoint: string;\n userinfo_endpoint: string;\n jwks_uri: string;\n registration_endpoint?: string;\n revocation_endpoint?: string;\n introspection_endpoint?: string;\n device_authorization_endpoint?: string;\n pushed_authorization_request_endpoint?: string;\n\n scopes_supported?: string[];\n response_types_supported: string[];\n response_modes_supported?: string[];\n grant_types_supported?: string[];\n\n subject_types_supported: ('public' | 'pairwise')[];\n id_token_signing_alg_values_supported: string[];\n id_token_encryption_alg_values_supported?: string[];\n id_token_encryption_enc_values_supported?: string[];\n\n userinfo_signing_alg_values_supported?: string[];\n userinfo_encryption_alg_values_supported?: string[];\n userinfo_encryption_enc_values_supported?: string[];\n\n request_object_signing_alg_values_supported?: string[];\n request_object_encryption_alg_values_supported?: string[];\n request_object_encryption_enc_values_supported?: string[];\n\n token_endpoint_auth_methods_supported?: string[];\n token_endpoint_auth_signing_alg_values_supported?: string[];\n\n introspection_endpoint_auth_methods_supported?: string[];\n introspection_endpoint_auth_signing_alg_values_supported?: string[];\n\n revocation_endpoint_auth_methods_supported?: string[];\n revocation_endpoint_auth_signing_alg_values_supported?: string[];\n\n claims_supported?: string[];\n claims_locales_supported?: string[];\n ui_locales_supported?: string[];\n\n claims_parameter_supported?: boolean;\n request_parameter_supported?: boolean;\n request_uri_parameter_supported?: boolean;\n require_request_uri_registration?: boolean;\n\n frontchannel_logout_supported?: boolean;\n frontchannel_logout_session_supported?: boolean;\n backchannel_logout_supported?: boolean;\n backchannel_logout_session_supported?: boolean;\n\n code_challenge_methods_supported?: ('plain' | 'S256')[];\n\n tls_client_certificate_bound_access_tokens?: boolean;\n authorization_response_iss_parameter_supported?: boolean;\n\n [key: string]: unknown;\n}\n\nexport class TharosConfig {\n public readonly tharosAuthUrl: string;\n public readonly realm: string;\n public readonly oidc: OpenIdConfiguration;\n public readonly oauth: OAuth | undefined;\n\n constructor({ tharosAuthUrl, realm, oidc, oauth }: Config & { oidc: OpenIdConfiguration }) {\n this.tharosAuthUrl = tharosAuthUrl;\n this.realm = realm;\n this.oidc = oidc;\n this.oauth = oauth;\n }\n\n public static async newInstance(config: Config) {\n const api = new ApiClient('');\n\n const oidc = null as any;\n\n return new TharosConfig({ ...config, oidc });\n }\n}\n","export enum StepType {\n USER_NAME = 'UserName',\n PASSWORD = 'Password',\n METADATA = 'Metadata',\n CHOICE = 'Choice',\n}\n\nexport interface ClientInput {\n id: string;\n step_type: StepType;\n type: string;\n send_back: boolean;\n output: Record<string, any>;\n input: any;\n}\n\nexport interface JourneyRequest {\n journey_id?: string;\n journey_token?: string;\n client_inputs?: ClientInput[];\n}\n\nexport interface JourneyResponsePayload {\n journey_token: string;\n client_inputs: ClientInput[];\n client_error?: {\n error: string;\n details?: Record<string, any>;\n };\n}\n\nexport interface JourneySuccess {\n session_id?: string;\n success_url?: string;\n}\n\nexport interface JourneyFailure {\n error: string;\n failure_url?: string;\n}\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class UserNameInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(userName: string) {\n super.setInput(userName);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.USER_NAME, UserNameInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class PasswordInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(password: string) {\n super.setInput(password);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.PASSWORD, PasswordInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class MeatadataInput extends JourneyStepType {\n public setInput() {}\n}\n\nJourneyStepType.stepsMap.set(StepType.METADATA, MeatadataInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class ChoiceInput extends JourneyStepType {\n public getDefaultChoice(): string | undefined {\n return this.getOutput().default_value || undefined;\n }\n\n public getChoices(): string[] {\n return this.getOutput().value as string[];\n }\n\n public setInput(choice: string) {\n super.setInput(choice);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.CHOICE, ChoiceInput);\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { Tokens } from '../types/tokens.js';\n\nexport class UserTokens extends BasicTharosContext {\n private tokens: Tokens;\n\n constructor(tokens: Tokens, tharosCtx: TharosImpl) {\n super(tharosCtx);\n\n this.tokens = tokens;\n }\n\n public getSessionID() {\n return this.tokens.session_id;\n }\n\n public async userInfo(): Promise<Map<string, any>> {\n const claims = await this.ctx.api.get<Map<string, any>>(this.ctx.config.oidc.userinfo_endpoint, {\n overrideUrl: true,\n });\n return claims;\n }\n\n public getAccessToken() {\n return this.tokens.access_token;\n }\n\n /**\n * Get claims for the current access token, if its a JWT extracts claims from encoded payload, otherwhise makes a call to /userinfo endpoint.\n */\n public async getAccessTokenClaims(): Promise<Map<string, any>> {\n return this.getAccessToken()?.split('.').length === 3 ? this.getClaimsFromJWT() : this.userInfo();\n }\n\n private getClaimsFromJWT(): Map<string, any> {\n const payload = this.getAccessToken()?.split('.')[1]!;\n const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');\n const bin = atob(base64);\n const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n }\n\n public getIDToken() {\n return this.tokens.id_token;\n }\n\n public getRefreshToken() {\n return this.tokens.refresh_token;\n }\n\n public async refreshTokens(): Promise<boolean> {\n if (!this.tokens.refresh_token) {\n return false;\n }\n\n return true;\n }\n}\n","export enum ErrorCode {\n INVALID_REQUEST = 'invalid_request',\n INVALID_CLIENT = 'invalid_client',\n INVALID_GRANT = 'invalid_grant',\n UNAUTHORIZED_CLIENT = 'unauthorized_client',\n ACCESS_DENIED = 'access_denied',\n INVALID_TOKEN = 'invalid_token',\n INVALID_TOKEN_FORMAT = 'invalid_token_format',\n CONSENT_REQUIRED = 'consent_required',\n POLICY_REQUIRED = 'policy_required',\n SERVER_ERROR = 'server_error',\n TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable',\n NETWORK = 'network',\n}\n\nexport class TharosError extends Error {\n private code: ErrorCode;\n private details: Map<string, any> | undefined;\n\n constructor(code: ErrorCode, message: string, details?: Map<string, any>, options?: ErrorOptions) {\n super(message, options);\n\n this.code = code;\n this.details = details;\n }\n\n getDetails() {\n return this.details;\n }\n\n getMessage() {\n return this.message;\n }\n\n getCode() {\n return this.code;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAM,qBAAN,MAAyB;AAAA,EACpB;AAAA,EAEV,YAAY,WAAuB;AACjC,SAAK,MAAM;AAAA,EACb;AACF;;;AChBO,IAAM,kBAAN,cAA8B,mBAAmB;AAAA,EAC9C;AAAA,EACR,OAAuB,WAAgD,oBAAI,IAAI;AAAA,EAE/E,YAAY,aAA0B,KAAiB;AACrD,UAAM,GAAG;AAET,SAAK,cAAc;AAAA,EACrB;AAAA,EAEO,QAAQ;AACb,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,UAAU;AACf,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,SAAS,MAAW;AACzB,SAAK,YAAY,QAAQ;AAAA,EAC3B;AAAA,EAEO,YAAY;AACjB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,aAAa;AAClB,WAAO,KAAK;AAAA,EACd;AACF;;;ACzBO,IAAM,kBAAN,cAA8B,mBAAmB;AAAA,EAC9C;AAAA,EACA;AAAA,EAER,YAAY,wBAAgD,KAAiB;AAC3E,UAAM,GAAG;AAET,SAAK,yBAAyB;AAC9B,SAAK,eAAe,KAAK,uBAAuB,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EAAE,CAAC;AAAA,EAC1E;AACF;","names":["StepType","ErrorCode"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/tharos.ts","../src/client-inputs/client-input.ts","../src/auth/journey.ts","../src/auth/user.ts","../src/http.ts","../src/config.ts","../src/types/journey.ts","../src/client-inputs/user-name.ts","../src/client-inputs/password.ts","../src/client-inputs/metadata.ts","../src/client-inputs/choice.ts","../src/auth/tokens.ts","../src/error.ts"],"sourcesContent":["import { JourneyRequestProcess, type JourneyExecutor } from './auth/journey.js';\nimport { User } from './auth/user.js';\nimport { TharosConfig } from './config.js';\nimport { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\nexport * from './client-inputs/index';\nexport * from './types/index';\nexport * from './auth/index';\nexport * from './config';\nexport * from './error';\nexport * from './http';\nexport * from './tharos';\n\nexport class Tharos {\n public readonly config: TharosConfig;\n public readonly api: ApiClient;\n public readonly journey: JourneyRequestProcess;\n private defaultJourneyExecutor: JourneyExecutor | undefined;\n private user: User | null = null;\n\n constructor({ config, defaultJourneyExecutor }: { config: TharosConfig; defaultJourneyExecutor?: JourneyExecutor }) {\n this.config = config;\n this.api = new ApiClient(this.config.tharosAuthUrl);\n this.journey = new JourneyRequestProcess(this);\n this.defaultJourneyExecutor = defaultJourneyExecutor;\n\n const currentURL = new URL(window.location.href).origin + new URL(window.location.href).pathname;\n\n if (currentURL === this.config.oauth?.redirectUri) {\n }\n }\n\n public getDefaultJourneyExecutor() {\n return this.defaultJourneyExecutor;\n }\n\n public getCurrentUser() {\n return this.user;\n }\n\n public async setAuthenticatedUser() {\n const user = new User(this);\n\n await user.sessionInfo();\n this.user = user;\n }\n\n public getAuthorizeUrl(config?: OAuth): string {\n if (!config) {\n if (!this.config.oauth) {\n throw new Error('oauth not configured');\n }\n\n config = this.config.oauth;\n }\n\n return `${this.config.tharosAuthUrl}/realms/${this.config.realm}/oauth2/auth?client_id=${config.clientId}&scope=${config.scope}&response_type=code&redirect_uri=${config.redirectUri}&acr_values=all1`;\n }\n\n public async exchangeTokens() {\n const url = new URL(window.location.href);\n this.api.post(\n `/realms/${this.config.realm}/oauth2/token`,\n {\n grant_type: 'authorization_code',\n code: url.searchParams.get('code'),\n client_id: this.config.oauth?.clientId,\n scope: this.config.oauth?.scope,\n },\n { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }\n );\n }\n\n public static async newInstance(baseConfig: Config) {\n return new Tharos({ config: await TharosConfig.newInstance(baseConfig) });\n }\n}\n","import type { JourneyRequestProcess } from './auth/journey.js';\nimport type { User } from './auth/user.js';\nimport type { TharosConfig } from './config.js';\nimport type { ApiClient } from './http.js';\n\nexport interface TharosImpl {\n config: TharosConfig;\n api: ApiClient;\n journey: JourneyRequestProcess;\n getCurrentUser(): User | null;\n setAuthenticatedUser(): Promise<void>;\n}\n\nexport class BasicTharosContext {\n protected ctx: TharosImpl;\n\n constructor(tharosCtx: TharosImpl) {\n this.ctx = tharosCtx;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { ClientInput } from '../types/journey.js';\n\nexport class JourneyStepType extends BasicTharosContext {\n private clientInput: ClientInput;\n public static readonly stepsMap: Map<string, typeof JourneyStepType> = new Map();\n\n constructor(clientInput: ClientInput, ctx: TharosImpl) {\n super(ctx);\n\n this.clientInput = clientInput;\n }\n\n public getID() {\n return this.clientInput.id;\n }\n\n public getStepType() {\n return this.clientInput.step_type;\n }\n\n public getType() {\n return this.clientInput.type;\n }\n\n public setInput(data: any) {\n this.clientInput.input = data;\n }\n\n public getOutput() {\n return this.clientInput.output;\n }\n\n public getPayload() {\n return this.clientInput;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type {\n ClientInput,\n JourneyFailure,\n JourneyRequest,\n JourneyResponsePayload,\n JourneySuccess,\n StepType,\n} from '../types/journey.js';\nimport { JourneyStepType } from '../client-inputs/client-input.js';\n\nexport class JourneyResponse extends BasicTharosContext {\n private journeyResponsePayload: JourneyResponsePayload;\n private clientInputs: JourneyStepType[];\n\n constructor(journeyResponsePayload: JourneyResponsePayload, ctx: TharosImpl) {\n super(ctx);\n\n this.journeyResponsePayload = journeyResponsePayload;\n this.clientInputs = this.journeyResponsePayload.client_inputs.map(\n (el) => new (JourneyStepType.stepsMap.get(el.step_type.toString())!)(el, ctx)\n );\n }\n\n public getJourneyToken() {\n return this.journeyResponsePayload.journey_token;\n }\n\n public getClientInputs<T extends JourneyStepType>(stepType: StepType): T[] {\n return this.clientInputs.filter((el) => el.getStepType() == stepType) as T[];\n }\n\n public getAllClientInputs() {\n return this.clientInputs;\n }\n}\n\nexport class JourneyRequestProcess extends BasicTharosContext {\n public async start(\n payload: { journey_id: string } | { resume_id: string },\n executor: JourneyExecutor,\n options?: { headers?: Record<string, string>; params?: Record<string, string> }\n ) {\n let uri = `/realms/${this.ctx.config.realm}/journeys/auth`;\n if (options?.params) {\n uri +=\n '?' +\n Object.entries(options.params)\n .map((val) => val.join('='))\n .join('&');\n }\n\n let journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n uri,\n payload,\n {\n headers: options?.headers as any,\n }\n );\n\n while (journeyResponse.hasOwnProperty('journey_token')) {\n journeyResponse = journeyResponse as JourneyResponsePayload;\n let process = new JourneyResponse(journeyResponse, this.ctx);\n await executor.onNewStep(process);\n\n journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n {\n journey_token: journeyResponse.journey_token,\n client_inputs: process.getAllClientInputs().map((el) => el.getPayload()),\n }\n );\n }\n\n if (journeyResponse.hasOwnProperty('session_id')) {\n await this.ctx.setAuthenticatedUser();\n executor.onSuccess(journeyResponse as JourneySuccess);\n } else {\n executor.onFailure(journeyResponse as JourneyFailure);\n }\n }\n}\n\nexport interface JourneyExecutor {\n onSuccess: (journeySuccess: JourneySuccess) => Promise<void>;\n onFailure: (journeyFailure: JourneyFailure) => Promise<void>;\n onNewStep: (journeyResponse: JourneyResponse) => Promise<void>;\n}\n","import { BasicTharosContext } from '../tharos.js';\nimport type { UserTokens } from './tokens.js';\n\nexport class User extends BasicTharosContext {\n private tokens: UserTokens | null = null;\n\n public getUserTokens() {\n return this.tokens;\n }\n\n public async sessionInfo() {\n return await this.ctx.api.post<Record<string, string>>(`/realms/${this.ctx.config.realm}/session/info`);\n }\n\n public async validateSession(refresh: boolean = false) {\n return await this.ctx.api.post<Record<string, string>>(\n `/realms/${this.ctx.config.realm}/session/validate?refresh=${refresh}`\n );\n }\n}\n","type RequestInterceptor = (url: string, request: RequestInit) => Promise<[string, RequestInit]> | [string, RequestInit];\n\ntype ResponseInterceptor = (response: Response) => Promise<Response> | Response;\n\nexport class HttpError extends Error {\n code: number;\n details: any;\n\n constructor({ code, message, details }: { code: number; message: string; details: any }) {\n super(message);\n\n this.code = code;\n this.details = details;\n }\n}\n\nexport class ApiClient {\n private baseUrl: string;\n private defaultHeaders: Record<string, string>;\n private requestInterceptors: RequestInterceptor[];\n private responseInterceptors: ResponseInterceptor[];\n\n constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n this.baseUrl = baseUrl;\n this.defaultHeaders = { ...defaultHeaders };\n this.requestInterceptors = [];\n this.responseInterceptors = [];\n }\n\n withPath(subPath: string): ApiClient {\n const child = new ApiClient(this.baseUrl + subPath, this.defaultHeaders);\n\n child.requestInterceptors = [...this.requestInterceptors];\n child.responseInterceptors = [...this.responseInterceptors];\n\n return child;\n }\n\n setDefaultHeader(key: string, value: string) {\n this.defaultHeaders[key] = value;\n }\n\n addRequestInterceptor(interceptor: RequestInterceptor) {\n this.requestInterceptors.push(interceptor);\n }\n\n addResponseInterceptor(interceptor: ResponseInterceptor) {\n this.responseInterceptors.push(interceptor);\n }\n\n async fetch<T>(path: string, options: RequestInit & { overrideUrl?: boolean } = {}): Promise<T> {\n if (path == '/') {\n path = '';\n }\n\n let url = options.overrideUrl ? path : `${this.baseUrl}${path}`;\n let init: RequestInit = {\n headers: { ...this.defaultHeaders, ...(options.headers || {}) },\n ...options,\n credentials: 'include',\n };\n\n // Interceptores de request\n for (const interceptor of this.requestInterceptors) {\n [url, init] = await interceptor(url, init);\n }\n\n // Ejecutar fetch\n let response = await fetch(url, init);\n\n // Interceptores de response\n for (const interceptor of this.responseInterceptors) {\n response = await interceptor(response);\n }\n\n if (!response.ok) {\n if (response.headers.get('content-type')?.includes('application/json')) {\n throw new HttpError(await response.json());\n } else {\n throw new Error(`Error ${response.status}: ${response.statusText}`);\n }\n }\n\n return response.json() as Promise<T>;\n }\n\n get<T>(path: string, options?: RequestInit & { overrideUrl?: boolean }) {\n return this.fetch<T>(path, { ...options, method: 'GET' });\n }\n post<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'POST',\n body: JSON.stringify(body),\n });\n }\n put<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'PUT',\n body: JSON.stringify(body),\n });\n }\n delete<T>(path: string, options?: RequestInit) {\n return this.fetch<T>(path, { ...options, method: 'DELETE' });\n }\n}\n","import { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\n\nexport interface OpenIdConfiguration {\n issuer: string;\n\n authorization_endpoint: string;\n token_endpoint: string;\n userinfo_endpoint: string;\n jwks_uri: string;\n registration_endpoint?: string;\n revocation_endpoint?: string;\n introspection_endpoint?: string;\n device_authorization_endpoint?: string;\n pushed_authorization_request_endpoint?: string;\n\n scopes_supported?: string[];\n response_types_supported: string[];\n response_modes_supported?: string[];\n grant_types_supported?: string[];\n\n subject_types_supported: ('public' | 'pairwise')[];\n id_token_signing_alg_values_supported: string[];\n id_token_encryption_alg_values_supported?: string[];\n id_token_encryption_enc_values_supported?: string[];\n\n userinfo_signing_alg_values_supported?: string[];\n userinfo_encryption_alg_values_supported?: string[];\n userinfo_encryption_enc_values_supported?: string[];\n\n request_object_signing_alg_values_supported?: string[];\n request_object_encryption_alg_values_supported?: string[];\n request_object_encryption_enc_values_supported?: string[];\n\n token_endpoint_auth_methods_supported?: string[];\n token_endpoint_auth_signing_alg_values_supported?: string[];\n\n introspection_endpoint_auth_methods_supported?: string[];\n introspection_endpoint_auth_signing_alg_values_supported?: string[];\n\n revocation_endpoint_auth_methods_supported?: string[];\n revocation_endpoint_auth_signing_alg_values_supported?: string[];\n\n claims_supported?: string[];\n claims_locales_supported?: string[];\n ui_locales_supported?: string[];\n\n claims_parameter_supported?: boolean;\n request_parameter_supported?: boolean;\n request_uri_parameter_supported?: boolean;\n require_request_uri_registration?: boolean;\n\n frontchannel_logout_supported?: boolean;\n frontchannel_logout_session_supported?: boolean;\n backchannel_logout_supported?: boolean;\n backchannel_logout_session_supported?: boolean;\n\n code_challenge_methods_supported?: ('plain' | 'S256')[];\n\n tls_client_certificate_bound_access_tokens?: boolean;\n authorization_response_iss_parameter_supported?: boolean;\n\n [key: string]: unknown;\n}\n\nexport class TharosConfig {\n public readonly tharosAuthUrl: string;\n public readonly realm: string;\n public readonly oidc: OpenIdConfiguration;\n public readonly oauth: OAuth | undefined;\n\n constructor({ tharosAuthUrl, realm, oidc, oauth }: Config & { oidc: OpenIdConfiguration }) {\n this.tharosAuthUrl = tharosAuthUrl;\n this.realm = realm;\n this.oidc = oidc;\n this.oauth = oauth;\n }\n\n public static async newInstance(config: Config) {\n const api = new ApiClient('');\n\n const oidc = null as any;\n\n return new TharosConfig({ ...config, oidc });\n }\n}\n","export enum StepType {\n USER_NAME = 'UserName',\n PASSWORD = 'Password',\n METADATA = 'Metadata',\n CHOICE = 'Choice',\n}\n\nexport interface ClientInput {\n id: string;\n step_type: StepType;\n type: string;\n send_back: boolean;\n output: Record<string, any>;\n input: any;\n}\n\nexport interface JourneyRequest {\n journey_id?: string;\n journey_token?: string;\n client_inputs?: ClientInput[];\n}\n\nexport interface JourneyResponsePayload {\n journey_token: string;\n client_inputs: ClientInput[];\n client_error?: {\n error: string;\n details?: Record<string, any>;\n };\n}\n\nexport interface JourneySuccess {\n session_id?: string;\n success_url?: string;\n}\n\nexport interface JourneyFailure {\n error: string;\n failure_url?: string;\n}\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class UserNameInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(userName: string) {\n super.setInput(userName);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.USER_NAME, UserNameInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class PasswordInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(password: string) {\n super.setInput(password);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.PASSWORD, PasswordInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class MeatadataInput extends JourneyStepType {\n public setInput() {}\n}\n\nJourneyStepType.stepsMap.set(StepType.METADATA, MeatadataInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class ChoiceInput extends JourneyStepType {\n public getDefaultChoice(): string | undefined {\n return this.getOutput().default_value || undefined;\n }\n\n public getChoices(): string[] {\n return this.getOutput().value as string[];\n }\n\n public setInput(choice: string) {\n super.setInput(choice);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.CHOICE, ChoiceInput);\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { Tokens } from '../types/tokens.js';\n\nexport class UserTokens extends BasicTharosContext {\n private tokens: Tokens;\n\n constructor(tokens: Tokens, tharosCtx: TharosImpl) {\n super(tharosCtx);\n\n this.tokens = tokens;\n }\n\n public getSessionID() {\n return this.tokens.session_id;\n }\n\n public async userInfo(): Promise<Map<string, any>> {\n const claims = await this.ctx.api.get<Map<string, any>>(this.ctx.config.oidc.userinfo_endpoint, {\n overrideUrl: true,\n });\n return claims;\n }\n\n public getAccessToken() {\n return this.tokens.access_token;\n }\n\n /**\n * Get claims for the current access token, if its a JWT extracts claims from encoded payload, otherwhise makes a call to /userinfo endpoint.\n */\n public async getAccessTokenClaims(): Promise<Map<string, any>> {\n return this.getAccessToken()?.split('.').length === 3 ? this.getClaimsFromJWT() : this.userInfo();\n }\n\n private getClaimsFromJWT(): Map<string, any> {\n const payload = this.getAccessToken()?.split('.')[1]!;\n const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');\n const bin = atob(base64);\n const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n }\n\n public getIDToken() {\n return this.tokens.id_token;\n }\n\n public getRefreshToken() {\n return this.tokens.refresh_token;\n }\n\n public async refreshTokens(): Promise<boolean> {\n if (!this.tokens.refresh_token) {\n return false;\n }\n\n return true;\n }\n}\n","export enum ErrorCode {\n INVALID_REQUEST = 'invalid_request',\n INVALID_CLIENT = 'invalid_client',\n INVALID_GRANT = 'invalid_grant',\n UNAUTHORIZED_CLIENT = 'unauthorized_client',\n ACCESS_DENIED = 'access_denied',\n INVALID_TOKEN = 'invalid_token',\n INVALID_TOKEN_FORMAT = 'invalid_token_format',\n CONSENT_REQUIRED = 'consent_required',\n POLICY_REQUIRED = 'policy_required',\n SERVER_ERROR = 'server_error',\n TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable',\n NETWORK = 'network',\n}\n\nexport class TharosError extends Error {\n private code: ErrorCode;\n private details: Map<string, any> | undefined;\n\n constructor(code: ErrorCode, message: string, details?: Map<string, any>, options?: ErrorOptions) {\n super(message, options);\n\n this.code = code;\n this.details = details;\n }\n\n getDetails() {\n return this.details;\n }\n\n getMessage() {\n return this.message;\n }\n\n getCode() {\n return this.code;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA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O,UAAZ,mBAAmB,cAAa;AAAA,IACnD;AAAA,EACF;AAAA,EAEO,4BAA4B;AACjC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,iBAAiB;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,uBAAuB;AAClC,UAAM,OAAO,IAAI,KAAK,IAAI;AAE1B,UAAM,KAAK,YAAY;AACvB,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,gBAAgB,QAAwB;AAC7C,QAAI,CAAC,QAAQ;AACX,UAAI,CAAC,KAAK,OAAO,OAAO;AACtB,cAAM,IAAI,MAAM,sBAAsB;AAAA,MACxC;AAEA,eAAS,KAAK,OAAO;AAAA,IACvB;AAEA,WAAO,GAAG,KAAK,OAAO,aAAa,WAAW,KAAK,OAAO,KAAK,0BAA0B,OAAO,QAAQ,UAAU,OAAO,KAAK,oCAAoC,OAAO,WAAW;AAAA,EACtL;AAAA,EAEA,MAAa,iBAAiB;AA3DhC;AA4DI,UAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;AACxC,SAAK,IAAI;AAAA,MACP,WAAW,KAAK,OAAO,KAAK;AAAA,MAC5B;AAAA,QACE,YAAY;AAAA,QACZ,MAAM,IAAI,aAAa,IAAI,MAAM;AAAA,QACjC,YAAW,UAAK,OAAO,UAAZ,mBAAmB;AAAA,QAC9B,QAAO,UAAK,OAAO,UAAZ,mBAAmB;AAAA,MAC5B;AAAA,MACA,EAAE,SAAS,EAAE,gBAAgB,oCAAoC,EAAE;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,aAAoB,YAAY,YAAoB;AAClD,WAAO,IAAI,QAAO,EAAE,QAAQ,MAAM,aAAa,YAAY,UAAU,EAAE,CAAC;AAAA,EAC1E;AACF;","names":["StepType","ErrorCode"]}
package/dist/index.d.cts CHANGED
@@ -204,7 +204,8 @@ declare class JourneyRequestProcess extends BasicTharosContext {
204
204
  } | {
205
205
  resume_id: string;
206
206
  }, executor: JourneyExecutor, options?: {
207
- headers: Map<string, string>;
207
+ headers?: Record<string, string>;
208
+ params?: Record<string, string>;
208
209
  }): Promise<void>;
209
210
  }
210
211
  interface JourneyExecutor {
package/dist/index.d.ts CHANGED
@@ -204,7 +204,8 @@ declare class JourneyRequestProcess extends BasicTharosContext {
204
204
  } | {
205
205
  resume_id: string;
206
206
  }, executor: JourneyExecutor, options?: {
207
- headers: Map<string, string>;
207
+ headers?: Record<string, string>;
208
+ params?: Record<string, string>;
208
209
  }): Promise<void>;
209
210
  }
210
211
  interface JourneyExecutor {
package/dist/index.js CHANGED
@@ -57,8 +57,12 @@ var JourneyResponse = class extends BasicTharosContext {
57
57
  };
58
58
  var JourneyRequestProcess = class extends BasicTharosContext {
59
59
  async start(payload, executor, options) {
60
+ let uri = `/realms/${this.ctx.config.realm}/journeys/auth`;
61
+ if (options == null ? void 0 : options.params) {
62
+ uri += "?" + Object.entries(options.params).map((val) => val.join("=")).join("&");
63
+ }
60
64
  let journeyResponse = await this.ctx.api.post(
61
- `/realms/${this.ctx.config.realm}/journeys/auth`,
65
+ uri,
62
66
  payload,
63
67
  {
64
68
  headers: options == null ? void 0 : options.headers
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tharos.ts","../src/client-inputs/client-input.ts","../src/auth/journey.ts","../src/auth/user.ts","../src/http.ts","../src/config.ts","../src/types/journey.ts","../src/client-inputs/user-name.ts","../src/client-inputs/password.ts","../src/client-inputs/metadata.ts","../src/client-inputs/choice.ts","../src/auth/tokens.ts","../src/error.ts","../src/index.ts"],"sourcesContent":["import type { JourneyRequestProcess } from './auth/journey.js';\nimport type { User } from './auth/user.js';\nimport type { TharosConfig } from './config.js';\nimport type { ApiClient } from './http.js';\n\nexport interface TharosImpl {\n config: TharosConfig;\n api: ApiClient;\n journey: JourneyRequestProcess;\n getCurrentUser(): User | null;\n setAuthenticatedUser(): Promise<void>;\n}\n\nexport class BasicTharosContext {\n protected ctx: TharosImpl;\n\n constructor(tharosCtx: TharosImpl) {\n this.ctx = tharosCtx;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { ClientInput } from '../types/journey.js';\n\nexport class JourneyStepType extends BasicTharosContext {\n private clientInput: ClientInput;\n public static readonly stepsMap: Map<string, typeof JourneyStepType> = new Map();\n\n constructor(clientInput: ClientInput, ctx: TharosImpl) {\n super(ctx);\n\n this.clientInput = clientInput;\n }\n\n public getID() {\n return this.clientInput.id;\n }\n\n public getStepType() {\n return this.clientInput.step_type;\n }\n\n public getType() {\n return this.clientInput.type;\n }\n\n public setInput(data: any) {\n this.clientInput.input = data;\n }\n\n public getOutput() {\n return this.clientInput.output;\n }\n\n public getPayload() {\n return this.clientInput;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type {\n ClientInput,\n JourneyFailure,\n JourneyRequest,\n JourneyResponsePayload,\n JourneySuccess,\n StepType,\n} from '../types/journey.js';\nimport { JourneyStepType } from '../client-inputs/client-input.js';\n\nexport class JourneyResponse extends BasicTharosContext {\n private journeyResponsePayload: JourneyResponsePayload;\n private clientInputs: JourneyStepType[];\n\n constructor(journeyResponsePayload: JourneyResponsePayload, ctx: TharosImpl) {\n super(ctx);\n\n this.journeyResponsePayload = journeyResponsePayload;\n this.clientInputs = this.journeyResponsePayload.client_inputs.map(\n (el) => new (JourneyStepType.stepsMap.get(el.step_type.toString())!)(el, ctx)\n );\n }\n\n public getJourneyToken() {\n return this.journeyResponsePayload.journey_token;\n }\n\n public getClientInputs<T extends JourneyStepType>(stepType: StepType): T[] {\n return this.clientInputs.filter((el) => el.getStepType() == stepType) as T[];\n }\n\n public getAllClientInputs() {\n return this.clientInputs;\n }\n}\n\nexport class JourneyRequestProcess extends BasicTharosContext {\n public async start(\n payload: { journey_id: string } | { resume_id: string },\n executor: JourneyExecutor,\n options?: { headers: Map<string, string> }\n ) {\n let journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n payload,\n {\n headers: options?.headers as any,\n }\n );\n\n while (journeyResponse.hasOwnProperty('journey_token')) {\n journeyResponse = journeyResponse as JourneyResponsePayload;\n let process = new JourneyResponse(journeyResponse, this.ctx);\n await executor.onNewStep(process);\n\n journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n {\n journey_token: journeyResponse.journey_token,\n client_inputs: process.getAllClientInputs().map((el) => el.getPayload()),\n }\n );\n }\n\n if (journeyResponse.hasOwnProperty('session_id')) {\n await this.ctx.setAuthenticatedUser();\n executor.onSuccess(journeyResponse as JourneySuccess);\n } else {\n executor.onFailure(journeyResponse as JourneyFailure);\n }\n }\n}\n\nexport interface JourneyExecutor {\n onSuccess: (journeySuccess: JourneySuccess) => Promise<void>;\n onFailure: (journeyFailure: JourneyFailure) => Promise<void>;\n onNewStep: (journeyResponse: JourneyResponse) => Promise<void>;\n}\n","import { BasicTharosContext } from '../tharos.js';\nimport type { UserTokens } from './tokens.js';\n\nexport class User extends BasicTharosContext {\n private tokens: UserTokens | null = null;\n\n public getUserTokens() {\n return this.tokens;\n }\n\n public async sessionInfo() {\n return await this.ctx.api.post<Record<string, string>>(`/realms/${this.ctx.config.realm}/session/info`);\n }\n\n public async validateSession(refresh: boolean = false) {\n return await this.ctx.api.post<Record<string, string>>(\n `/realms/${this.ctx.config.realm}/session/validate?refresh=${refresh}`\n );\n }\n}\n","type RequestInterceptor = (url: string, request: RequestInit) => Promise<[string, RequestInit]> | [string, RequestInit];\n\ntype ResponseInterceptor = (response: Response) => Promise<Response> | Response;\n\nexport class HttpError extends Error {\n code: number;\n details: any;\n\n constructor({ code, message, details }: { code: number; message: string; details: any }) {\n super(message);\n\n this.code = code;\n this.details = details;\n }\n}\n\nexport class ApiClient {\n private baseUrl: string;\n private defaultHeaders: Record<string, string>;\n private requestInterceptors: RequestInterceptor[];\n private responseInterceptors: ResponseInterceptor[];\n\n constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n this.baseUrl = baseUrl;\n this.defaultHeaders = { ...defaultHeaders };\n this.requestInterceptors = [];\n this.responseInterceptors = [];\n }\n\n withPath(subPath: string): ApiClient {\n const child = new ApiClient(this.baseUrl + subPath, this.defaultHeaders);\n\n child.requestInterceptors = [...this.requestInterceptors];\n child.responseInterceptors = [...this.responseInterceptors];\n\n return child;\n }\n\n setDefaultHeader(key: string, value: string) {\n this.defaultHeaders[key] = value;\n }\n\n addRequestInterceptor(interceptor: RequestInterceptor) {\n this.requestInterceptors.push(interceptor);\n }\n\n addResponseInterceptor(interceptor: ResponseInterceptor) {\n this.responseInterceptors.push(interceptor);\n }\n\n async fetch<T>(path: string, options: RequestInit & { overrideUrl?: boolean } = {}): Promise<T> {\n if (path == '/') {\n path = '';\n }\n\n let url = options.overrideUrl ? path : `${this.baseUrl}${path}`;\n let init: RequestInit = {\n headers: { ...this.defaultHeaders, ...(options.headers || {}) },\n ...options,\n credentials: 'include',\n };\n\n // Interceptores de request\n for (const interceptor of this.requestInterceptors) {\n [url, init] = await interceptor(url, init);\n }\n\n // Ejecutar fetch\n let response = await fetch(url, init);\n\n // Interceptores de response\n for (const interceptor of this.responseInterceptors) {\n response = await interceptor(response);\n }\n\n if (!response.ok) {\n if (response.headers.get('content-type')?.includes('application/json')) {\n throw new HttpError(await response.json());\n } else {\n throw new Error(`Error ${response.status}: ${response.statusText}`);\n }\n }\n\n return response.json() as Promise<T>;\n }\n\n get<T>(path: string, options?: RequestInit & { overrideUrl?: boolean }) {\n return this.fetch<T>(path, { ...options, method: 'GET' });\n }\n post<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'POST',\n body: JSON.stringify(body),\n });\n }\n put<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'PUT',\n body: JSON.stringify(body),\n });\n }\n delete<T>(path: string, options?: RequestInit) {\n return this.fetch<T>(path, { ...options, method: 'DELETE' });\n }\n}\n","import { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\n\nexport interface OpenIdConfiguration {\n issuer: string;\n\n authorization_endpoint: string;\n token_endpoint: string;\n userinfo_endpoint: string;\n jwks_uri: string;\n registration_endpoint?: string;\n revocation_endpoint?: string;\n introspection_endpoint?: string;\n device_authorization_endpoint?: string;\n pushed_authorization_request_endpoint?: string;\n\n scopes_supported?: string[];\n response_types_supported: string[];\n response_modes_supported?: string[];\n grant_types_supported?: string[];\n\n subject_types_supported: ('public' | 'pairwise')[];\n id_token_signing_alg_values_supported: string[];\n id_token_encryption_alg_values_supported?: string[];\n id_token_encryption_enc_values_supported?: string[];\n\n userinfo_signing_alg_values_supported?: string[];\n userinfo_encryption_alg_values_supported?: string[];\n userinfo_encryption_enc_values_supported?: string[];\n\n request_object_signing_alg_values_supported?: string[];\n request_object_encryption_alg_values_supported?: string[];\n request_object_encryption_enc_values_supported?: string[];\n\n token_endpoint_auth_methods_supported?: string[];\n token_endpoint_auth_signing_alg_values_supported?: string[];\n\n introspection_endpoint_auth_methods_supported?: string[];\n introspection_endpoint_auth_signing_alg_values_supported?: string[];\n\n revocation_endpoint_auth_methods_supported?: string[];\n revocation_endpoint_auth_signing_alg_values_supported?: string[];\n\n claims_supported?: string[];\n claims_locales_supported?: string[];\n ui_locales_supported?: string[];\n\n claims_parameter_supported?: boolean;\n request_parameter_supported?: boolean;\n request_uri_parameter_supported?: boolean;\n require_request_uri_registration?: boolean;\n\n frontchannel_logout_supported?: boolean;\n frontchannel_logout_session_supported?: boolean;\n backchannel_logout_supported?: boolean;\n backchannel_logout_session_supported?: boolean;\n\n code_challenge_methods_supported?: ('plain' | 'S256')[];\n\n tls_client_certificate_bound_access_tokens?: boolean;\n authorization_response_iss_parameter_supported?: boolean;\n\n [key: string]: unknown;\n}\n\nexport class TharosConfig {\n public readonly tharosAuthUrl: string;\n public readonly realm: string;\n public readonly oidc: OpenIdConfiguration;\n public readonly oauth: OAuth | undefined;\n\n constructor({ tharosAuthUrl, realm, oidc, oauth }: Config & { oidc: OpenIdConfiguration }) {\n this.tharosAuthUrl = tharosAuthUrl;\n this.realm = realm;\n this.oidc = oidc;\n this.oauth = oauth;\n }\n\n public static async newInstance(config: Config) {\n const api = new ApiClient('');\n\n const oidc = null as any;\n\n return new TharosConfig({ ...config, oidc });\n }\n}\n","export enum StepType {\n USER_NAME = 'UserName',\n PASSWORD = 'Password',\n METADATA = 'Metadata',\n CHOICE = 'Choice',\n}\n\nexport interface ClientInput {\n id: string;\n step_type: StepType;\n type: string;\n send_back: boolean;\n output: Record<string, any>;\n input: any;\n}\n\nexport interface JourneyRequest {\n journey_id?: string;\n journey_token?: string;\n client_inputs?: ClientInput[];\n}\n\nexport interface JourneyResponsePayload {\n journey_token: string;\n client_inputs: ClientInput[];\n client_error?: {\n error: string;\n details?: Record<string, any>;\n };\n}\n\nexport interface JourneySuccess {\n session_id?: string;\n success_url?: string;\n}\n\nexport interface JourneyFailure {\n error: string;\n failure_url?: string;\n}\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class UserNameInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(userName: string) {\n super.setInput(userName);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.USER_NAME, UserNameInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class PasswordInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(password: string) {\n super.setInput(password);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.PASSWORD, PasswordInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class MeatadataInput extends JourneyStepType {\n public setInput() {}\n}\n\nJourneyStepType.stepsMap.set(StepType.METADATA, MeatadataInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class ChoiceInput extends JourneyStepType {\n public getDefaultChoice(): string | undefined {\n return this.getOutput().default_value || undefined;\n }\n\n public getChoices(): string[] {\n return this.getOutput().value as string[];\n }\n\n public setInput(choice: string) {\n super.setInput(choice);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.CHOICE, ChoiceInput);\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { Tokens } from '../types/tokens.js';\n\nexport class UserTokens extends BasicTharosContext {\n private tokens: Tokens;\n\n constructor(tokens: Tokens, tharosCtx: TharosImpl) {\n super(tharosCtx);\n\n this.tokens = tokens;\n }\n\n public getSessionID() {\n return this.tokens.session_id;\n }\n\n public async userInfo(): Promise<Map<string, any>> {\n const claims = await this.ctx.api.get<Map<string, any>>(this.ctx.config.oidc.userinfo_endpoint, {\n overrideUrl: true,\n });\n return claims;\n }\n\n public getAccessToken() {\n return this.tokens.access_token;\n }\n\n /**\n * Get claims for the current access token, if its a JWT extracts claims from encoded payload, otherwhise makes a call to /userinfo endpoint.\n */\n public async getAccessTokenClaims(): Promise<Map<string, any>> {\n return this.getAccessToken()?.split('.').length === 3 ? this.getClaimsFromJWT() : this.userInfo();\n }\n\n private getClaimsFromJWT(): Map<string, any> {\n const payload = this.getAccessToken()?.split('.')[1]!;\n const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');\n const bin = atob(base64);\n const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n }\n\n public getIDToken() {\n return this.tokens.id_token;\n }\n\n public getRefreshToken() {\n return this.tokens.refresh_token;\n }\n\n public async refreshTokens(): Promise<boolean> {\n if (!this.tokens.refresh_token) {\n return false;\n }\n\n return true;\n }\n}\n","export enum ErrorCode {\n INVALID_REQUEST = 'invalid_request',\n INVALID_CLIENT = 'invalid_client',\n INVALID_GRANT = 'invalid_grant',\n UNAUTHORIZED_CLIENT = 'unauthorized_client',\n ACCESS_DENIED = 'access_denied',\n INVALID_TOKEN = 'invalid_token',\n INVALID_TOKEN_FORMAT = 'invalid_token_format',\n CONSENT_REQUIRED = 'consent_required',\n POLICY_REQUIRED = 'policy_required',\n SERVER_ERROR = 'server_error',\n TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable',\n NETWORK = 'network',\n}\n\nexport class TharosError extends Error {\n private code: ErrorCode;\n private details: Map<string, any> | undefined;\n\n constructor(code: ErrorCode, message: string, details?: Map<string, any>, options?: ErrorOptions) {\n super(message, options);\n\n this.code = code;\n this.details = details;\n }\n\n getDetails() {\n return this.details;\n }\n\n getMessage() {\n return this.message;\n }\n\n getCode() {\n return this.code;\n }\n}\n","import { JourneyRequestProcess, type JourneyExecutor } from './auth/journey.js';\nimport { User } from './auth/user.js';\nimport { TharosConfig } from './config.js';\nimport { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\nexport * from './client-inputs/index';\nexport * from './types/index';\nexport * from './auth/index';\nexport * from './config';\nexport * from './error';\nexport * from './http';\nexport * from './tharos';\n\nexport class Tharos {\n public readonly config: TharosConfig;\n public readonly api: ApiClient;\n public readonly journey: JourneyRequestProcess;\n private defaultJourneyExecutor: JourneyExecutor | undefined;\n private user: User | null = null;\n\n constructor({ config, defaultJourneyExecutor }: { config: TharosConfig; defaultJourneyExecutor?: JourneyExecutor }) {\n this.config = config;\n this.api = new ApiClient(this.config.tharosAuthUrl);\n this.journey = new JourneyRequestProcess(this);\n this.defaultJourneyExecutor = defaultJourneyExecutor;\n\n const currentURL = new URL(window.location.href).origin + new URL(window.location.href).pathname;\n\n if (currentURL === this.config.oauth?.redirectUri) {\n }\n }\n\n public getDefaultJourneyExecutor() {\n return this.defaultJourneyExecutor;\n }\n\n public getCurrentUser() {\n return this.user;\n }\n\n public async setAuthenticatedUser() {\n const user = new User(this);\n\n await user.sessionInfo();\n this.user = user;\n }\n\n public getAuthorizeUrl(config?: OAuth): string {\n if (!config) {\n if (!this.config.oauth) {\n throw new Error('oauth not configured');\n }\n\n config = this.config.oauth;\n }\n\n return `${this.config.tharosAuthUrl}/realms/${this.config.realm}/oauth2/auth?client_id=${config.clientId}&scope=${config.scope}&response_type=code&redirect_uri=${config.redirectUri}&acr_values=all1`;\n }\n\n public async exchangeTokens() {\n const url = new URL(window.location.href);\n this.api.post(\n `/realms/${this.config.realm}/oauth2/token`,\n {\n grant_type: 'authorization_code',\n code: url.searchParams.get('code'),\n client_id: this.config.oauth?.clientId,\n scope: this.config.oauth?.scope,\n },\n { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }\n );\n }\n\n public static async newInstance(baseConfig: Config) {\n return new Tharos({ config: await TharosConfig.newInstance(baseConfig) });\n }\n}\n"],"mappings":";AAaO,IAAM,qBAAN,MAAyB;AAAA,EACpB;AAAA,EAEV,YAAY,WAAuB;AACjC,SAAK,MAAM;AAAA,EACb;AACF;;;AChBO,IAAM,kBAAN,cAA8B,mBAAmB;AAAA,EAC9C;AAAA,EACR,OAAuB,WAAgD,oBAAI,IAAI;AAAA,EAE/E,YAAY,aAA0B,KAAiB;AACrD,UAAM,GAAG;AAET,SAAK,cAAc;AAAA,EACrB;AAAA,EAEO,QAAQ;AACb,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,UAAU;AACf,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,SAAS,MAAW;AACzB,SAAK,YAAY,QAAQ;AAAA,EAC3B;AAAA,EAEO,YAAY;AACjB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEO,aAAa;AAClB,WAAO,KAAK;AAAA,EACd;AACF;;;ACzBO,IAAM,kBAAN,cAA8B,mBAAmB;AAAA,EAC9C;AAAA,EACA;AAAA,EAER,YAAY,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EAEA,aAAoB,YAAY,YAAoB;AAClD,WAAO,IAAI,QAAO,EAAE,QAAQ,MAAM,aAAa,YAAY,UAAU,EAAE,CAAC;AAAA,EAC1E;AACF;","names":["StepType","ErrorCode"]}
1
+ {"version":3,"sources":["../src/tharos.ts","../src/client-inputs/client-input.ts","../src/auth/journey.ts","../src/auth/user.ts","../src/http.ts","../src/config.ts","../src/types/journey.ts","../src/client-inputs/user-name.ts","../src/client-inputs/password.ts","../src/client-inputs/metadata.ts","../src/client-inputs/choice.ts","../src/auth/tokens.ts","../src/error.ts","../src/index.ts"],"sourcesContent":["import type { JourneyRequestProcess } from './auth/journey.js';\nimport type { User } from './auth/user.js';\nimport type { TharosConfig } from './config.js';\nimport type { ApiClient } from './http.js';\n\nexport interface TharosImpl {\n config: TharosConfig;\n api: ApiClient;\n journey: JourneyRequestProcess;\n getCurrentUser(): User | null;\n setAuthenticatedUser(): Promise<void>;\n}\n\nexport class BasicTharosContext {\n protected ctx: TharosImpl;\n\n constructor(tharosCtx: TharosImpl) {\n this.ctx = tharosCtx;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { ClientInput } from '../types/journey.js';\n\nexport class JourneyStepType extends BasicTharosContext {\n private clientInput: ClientInput;\n public static readonly stepsMap: Map<string, typeof JourneyStepType> = new Map();\n\n constructor(clientInput: ClientInput, ctx: TharosImpl) {\n super(ctx);\n\n this.clientInput = clientInput;\n }\n\n public getID() {\n return this.clientInput.id;\n }\n\n public getStepType() {\n return this.clientInput.step_type;\n }\n\n public getType() {\n return this.clientInput.type;\n }\n\n public setInput(data: any) {\n this.clientInput.input = data;\n }\n\n public getOutput() {\n return this.clientInput.output;\n }\n\n public getPayload() {\n return this.clientInput;\n }\n}\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type {\n ClientInput,\n JourneyFailure,\n JourneyRequest,\n JourneyResponsePayload,\n JourneySuccess,\n StepType,\n} from '../types/journey.js';\nimport { JourneyStepType } from '../client-inputs/client-input.js';\n\nexport class JourneyResponse extends BasicTharosContext {\n private journeyResponsePayload: JourneyResponsePayload;\n private clientInputs: JourneyStepType[];\n\n constructor(journeyResponsePayload: JourneyResponsePayload, ctx: TharosImpl) {\n super(ctx);\n\n this.journeyResponsePayload = journeyResponsePayload;\n this.clientInputs = this.journeyResponsePayload.client_inputs.map(\n (el) => new (JourneyStepType.stepsMap.get(el.step_type.toString())!)(el, ctx)\n );\n }\n\n public getJourneyToken() {\n return this.journeyResponsePayload.journey_token;\n }\n\n public getClientInputs<T extends JourneyStepType>(stepType: StepType): T[] {\n return this.clientInputs.filter((el) => el.getStepType() == stepType) as T[];\n }\n\n public getAllClientInputs() {\n return this.clientInputs;\n }\n}\n\nexport class JourneyRequestProcess extends BasicTharosContext {\n public async start(\n payload: { journey_id: string } | { resume_id: string },\n executor: JourneyExecutor,\n options?: { headers?: Record<string, string>; params?: Record<string, string> }\n ) {\n let uri = `/realms/${this.ctx.config.realm}/journeys/auth`;\n if (options?.params) {\n uri +=\n '?' +\n Object.entries(options.params)\n .map((val) => val.join('='))\n .join('&');\n }\n\n let journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n uri,\n payload,\n {\n headers: options?.headers as any,\n }\n );\n\n while (journeyResponse.hasOwnProperty('journey_token')) {\n journeyResponse = journeyResponse as JourneyResponsePayload;\n let process = new JourneyResponse(journeyResponse, this.ctx);\n await executor.onNewStep(process);\n\n journeyResponse = await this.ctx.api.post<JourneyResponsePayload | JourneyFailure | JourneySuccess>(\n `/realms/${this.ctx.config.realm}/journeys/auth`,\n {\n journey_token: journeyResponse.journey_token,\n client_inputs: process.getAllClientInputs().map((el) => el.getPayload()),\n }\n );\n }\n\n if (journeyResponse.hasOwnProperty('session_id')) {\n await this.ctx.setAuthenticatedUser();\n executor.onSuccess(journeyResponse as JourneySuccess);\n } else {\n executor.onFailure(journeyResponse as JourneyFailure);\n }\n }\n}\n\nexport interface JourneyExecutor {\n onSuccess: (journeySuccess: JourneySuccess) => Promise<void>;\n onFailure: (journeyFailure: JourneyFailure) => Promise<void>;\n onNewStep: (journeyResponse: JourneyResponse) => Promise<void>;\n}\n","import { BasicTharosContext } from '../tharos.js';\nimport type { UserTokens } from './tokens.js';\n\nexport class User extends BasicTharosContext {\n private tokens: UserTokens | null = null;\n\n public getUserTokens() {\n return this.tokens;\n }\n\n public async sessionInfo() {\n return await this.ctx.api.post<Record<string, string>>(`/realms/${this.ctx.config.realm}/session/info`);\n }\n\n public async validateSession(refresh: boolean = false) {\n return await this.ctx.api.post<Record<string, string>>(\n `/realms/${this.ctx.config.realm}/session/validate?refresh=${refresh}`\n );\n }\n}\n","type RequestInterceptor = (url: string, request: RequestInit) => Promise<[string, RequestInit]> | [string, RequestInit];\n\ntype ResponseInterceptor = (response: Response) => Promise<Response> | Response;\n\nexport class HttpError extends Error {\n code: number;\n details: any;\n\n constructor({ code, message, details }: { code: number; message: string; details: any }) {\n super(message);\n\n this.code = code;\n this.details = details;\n }\n}\n\nexport class ApiClient {\n private baseUrl: string;\n private defaultHeaders: Record<string, string>;\n private requestInterceptors: RequestInterceptor[];\n private responseInterceptors: ResponseInterceptor[];\n\n constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n this.baseUrl = baseUrl;\n this.defaultHeaders = { ...defaultHeaders };\n this.requestInterceptors = [];\n this.responseInterceptors = [];\n }\n\n withPath(subPath: string): ApiClient {\n const child = new ApiClient(this.baseUrl + subPath, this.defaultHeaders);\n\n child.requestInterceptors = [...this.requestInterceptors];\n child.responseInterceptors = [...this.responseInterceptors];\n\n return child;\n }\n\n setDefaultHeader(key: string, value: string) {\n this.defaultHeaders[key] = value;\n }\n\n addRequestInterceptor(interceptor: RequestInterceptor) {\n this.requestInterceptors.push(interceptor);\n }\n\n addResponseInterceptor(interceptor: ResponseInterceptor) {\n this.responseInterceptors.push(interceptor);\n }\n\n async fetch<T>(path: string, options: RequestInit & { overrideUrl?: boolean } = {}): Promise<T> {\n if (path == '/') {\n path = '';\n }\n\n let url = options.overrideUrl ? path : `${this.baseUrl}${path}`;\n let init: RequestInit = {\n headers: { ...this.defaultHeaders, ...(options.headers || {}) },\n ...options,\n credentials: 'include',\n };\n\n // Interceptores de request\n for (const interceptor of this.requestInterceptors) {\n [url, init] = await interceptor(url, init);\n }\n\n // Ejecutar fetch\n let response = await fetch(url, init);\n\n // Interceptores de response\n for (const interceptor of this.responseInterceptors) {\n response = await interceptor(response);\n }\n\n if (!response.ok) {\n if (response.headers.get('content-type')?.includes('application/json')) {\n throw new HttpError(await response.json());\n } else {\n throw new Error(`Error ${response.status}: ${response.statusText}`);\n }\n }\n\n return response.json() as Promise<T>;\n }\n\n get<T>(path: string, options?: RequestInit & { overrideUrl?: boolean }) {\n return this.fetch<T>(path, { ...options, method: 'GET' });\n }\n post<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'POST',\n body: JSON.stringify(body),\n });\n }\n put<T>(path: string, body?: any, options?: RequestInit) {\n return this.fetch<T>(path, {\n ...options,\n method: 'PUT',\n body: JSON.stringify(body),\n });\n }\n delete<T>(path: string, options?: RequestInit) {\n return this.fetch<T>(path, { ...options, method: 'DELETE' });\n }\n}\n","import { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\n\nexport interface OpenIdConfiguration {\n issuer: string;\n\n authorization_endpoint: string;\n token_endpoint: string;\n userinfo_endpoint: string;\n jwks_uri: string;\n registration_endpoint?: string;\n revocation_endpoint?: string;\n introspection_endpoint?: string;\n device_authorization_endpoint?: string;\n pushed_authorization_request_endpoint?: string;\n\n scopes_supported?: string[];\n response_types_supported: string[];\n response_modes_supported?: string[];\n grant_types_supported?: string[];\n\n subject_types_supported: ('public' | 'pairwise')[];\n id_token_signing_alg_values_supported: string[];\n id_token_encryption_alg_values_supported?: string[];\n id_token_encryption_enc_values_supported?: string[];\n\n userinfo_signing_alg_values_supported?: string[];\n userinfo_encryption_alg_values_supported?: string[];\n userinfo_encryption_enc_values_supported?: string[];\n\n request_object_signing_alg_values_supported?: string[];\n request_object_encryption_alg_values_supported?: string[];\n request_object_encryption_enc_values_supported?: string[];\n\n token_endpoint_auth_methods_supported?: string[];\n token_endpoint_auth_signing_alg_values_supported?: string[];\n\n introspection_endpoint_auth_methods_supported?: string[];\n introspection_endpoint_auth_signing_alg_values_supported?: string[];\n\n revocation_endpoint_auth_methods_supported?: string[];\n revocation_endpoint_auth_signing_alg_values_supported?: string[];\n\n claims_supported?: string[];\n claims_locales_supported?: string[];\n ui_locales_supported?: string[];\n\n claims_parameter_supported?: boolean;\n request_parameter_supported?: boolean;\n request_uri_parameter_supported?: boolean;\n require_request_uri_registration?: boolean;\n\n frontchannel_logout_supported?: boolean;\n frontchannel_logout_session_supported?: boolean;\n backchannel_logout_supported?: boolean;\n backchannel_logout_session_supported?: boolean;\n\n code_challenge_methods_supported?: ('plain' | 'S256')[];\n\n tls_client_certificate_bound_access_tokens?: boolean;\n authorization_response_iss_parameter_supported?: boolean;\n\n [key: string]: unknown;\n}\n\nexport class TharosConfig {\n public readonly tharosAuthUrl: string;\n public readonly realm: string;\n public readonly oidc: OpenIdConfiguration;\n public readonly oauth: OAuth | undefined;\n\n constructor({ tharosAuthUrl, realm, oidc, oauth }: Config & { oidc: OpenIdConfiguration }) {\n this.tharosAuthUrl = tharosAuthUrl;\n this.realm = realm;\n this.oidc = oidc;\n this.oauth = oauth;\n }\n\n public static async newInstance(config: Config) {\n const api = new ApiClient('');\n\n const oidc = null as any;\n\n return new TharosConfig({ ...config, oidc });\n }\n}\n","export enum StepType {\n USER_NAME = 'UserName',\n PASSWORD = 'Password',\n METADATA = 'Metadata',\n CHOICE = 'Choice',\n}\n\nexport interface ClientInput {\n id: string;\n step_type: StepType;\n type: string;\n send_back: boolean;\n output: Record<string, any>;\n input: any;\n}\n\nexport interface JourneyRequest {\n journey_id?: string;\n journey_token?: string;\n client_inputs?: ClientInput[];\n}\n\nexport interface JourneyResponsePayload {\n journey_token: string;\n client_inputs: ClientInput[];\n client_error?: {\n error: string;\n details?: Record<string, any>;\n };\n}\n\nexport interface JourneySuccess {\n session_id?: string;\n success_url?: string;\n}\n\nexport interface JourneyFailure {\n error: string;\n failure_url?: string;\n}\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class UserNameInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(userName: string) {\n super.setInput(userName);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.USER_NAME, UserNameInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class PasswordInput extends JourneyStepType {\n public getPattern(): string | undefined {\n return this.getOutput().pattern;\n }\n\n public getPrompt(): string | undefined {\n return this.getOutput().prompt;\n }\n\n public getRequired(): boolean {\n return !!this.getOutput().required;\n }\n\n public setInput(password: string) {\n super.setInput(password);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.PASSWORD, PasswordInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class MeatadataInput extends JourneyStepType {\n public setInput() {}\n}\n\nJourneyStepType.stepsMap.set(StepType.METADATA, MeatadataInput);\n","import { StepType } from '../types/journey.js';\nimport { JourneyStepType } from './client-input.js';\n\nexport class ChoiceInput extends JourneyStepType {\n public getDefaultChoice(): string | undefined {\n return this.getOutput().default_value || undefined;\n }\n\n public getChoices(): string[] {\n return this.getOutput().value as string[];\n }\n\n public setInput(choice: string) {\n super.setInput(choice);\n }\n}\n\nJourneyStepType.stepsMap.set(StepType.CHOICE, ChoiceInput);\n","import { BasicTharosContext, type TharosImpl } from '../tharos.js';\nimport type { Tokens } from '../types/tokens.js';\n\nexport class UserTokens extends BasicTharosContext {\n private tokens: Tokens;\n\n constructor(tokens: Tokens, tharosCtx: TharosImpl) {\n super(tharosCtx);\n\n this.tokens = tokens;\n }\n\n public getSessionID() {\n return this.tokens.session_id;\n }\n\n public async userInfo(): Promise<Map<string, any>> {\n const claims = await this.ctx.api.get<Map<string, any>>(this.ctx.config.oidc.userinfo_endpoint, {\n overrideUrl: true,\n });\n return claims;\n }\n\n public getAccessToken() {\n return this.tokens.access_token;\n }\n\n /**\n * Get claims for the current access token, if its a JWT extracts claims from encoded payload, otherwhise makes a call to /userinfo endpoint.\n */\n public async getAccessTokenClaims(): Promise<Map<string, any>> {\n return this.getAccessToken()?.split('.').length === 3 ? this.getClaimsFromJWT() : this.userInfo();\n }\n\n private getClaimsFromJWT(): Map<string, any> {\n const payload = this.getAccessToken()?.split('.')[1]!;\n const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');\n const bin = atob(base64);\n const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n }\n\n public getIDToken() {\n return this.tokens.id_token;\n }\n\n public getRefreshToken() {\n return this.tokens.refresh_token;\n }\n\n public async refreshTokens(): Promise<boolean> {\n if (!this.tokens.refresh_token) {\n return false;\n }\n\n return true;\n }\n}\n","export enum ErrorCode {\n INVALID_REQUEST = 'invalid_request',\n INVALID_CLIENT = 'invalid_client',\n INVALID_GRANT = 'invalid_grant',\n UNAUTHORIZED_CLIENT = 'unauthorized_client',\n ACCESS_DENIED = 'access_denied',\n INVALID_TOKEN = 'invalid_token',\n INVALID_TOKEN_FORMAT = 'invalid_token_format',\n CONSENT_REQUIRED = 'consent_required',\n POLICY_REQUIRED = 'policy_required',\n SERVER_ERROR = 'server_error',\n TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable',\n NETWORK = 'network',\n}\n\nexport class TharosError extends Error {\n private code: ErrorCode;\n private details: Map<string, any> | undefined;\n\n constructor(code: ErrorCode, message: string, details?: Map<string, any>, options?: ErrorOptions) {\n super(message, options);\n\n this.code = code;\n this.details = details;\n }\n\n getDetails() {\n return this.details;\n }\n\n getMessage() {\n return this.message;\n }\n\n getCode() {\n return this.code;\n }\n}\n","import { JourneyRequestProcess, type JourneyExecutor } from './auth/journey.js';\nimport { User } from './auth/user.js';\nimport { TharosConfig } from './config.js';\nimport { ApiClient } from './http.js';\nimport type { Config, OAuth } from './types/config.js';\nexport * from './client-inputs/index';\nexport * from './types/index';\nexport * from './auth/index';\nexport * from './config';\nexport * from './error';\nexport * from './http';\nexport * from './tharos';\n\nexport class Tharos {\n public readonly config: TharosConfig;\n public readonly api: ApiClient;\n public readonly journey: JourneyRequestProcess;\n private defaultJourneyExecutor: JourneyExecutor | undefined;\n private user: User | null = null;\n\n constructor({ config, defaultJourneyExecutor }: { config: TharosConfig; defaultJourneyExecutor?: JourneyExecutor }) {\n this.config = config;\n this.api = new ApiClient(this.config.tharosAuthUrl);\n this.journey = new JourneyRequestProcess(this);\n this.defaultJourneyExecutor = defaultJourneyExecutor;\n\n const currentURL = new URL(window.location.href).origin + new URL(window.location.href).pathname;\n\n if (currentURL === this.config.oauth?.redirectUri) {\n }\n }\n\n public getDefaultJourneyExecutor() {\n return this.defaultJourneyExecutor;\n }\n\n public getCurrentUser() {\n return this.user;\n }\n\n public async setAuthenticatedUser() {\n const user = new User(this);\n\n await user.sessionInfo();\n this.user = user;\n }\n\n public getAuthorizeUrl(config?: OAuth): string {\n if (!config) {\n if (!this.config.oauth) {\n throw new Error('oauth not configured');\n }\n\n config = this.config.oauth;\n }\n\n return `${this.config.tharosAuthUrl}/realms/${this.config.realm}/oauth2/auth?client_id=${config.clientId}&scope=${config.scope}&response_type=code&redirect_uri=${config.redirectUri}&acr_values=all1`;\n }\n\n public async exchangeTokens() {\n const url = new URL(window.location.href);\n this.api.post(\n `/realms/${this.config.realm}/oauth2/token`,\n {\n grant_type: 'authorization_code',\n code: url.searchParams.get('code'),\n client_id: this.config.oauth?.clientId,\n scope: this.config.oauth?.scope,\n },\n { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }\n );\n }\n\n public static async newInstance(baseConfig: Config) {\n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O,4BAA4B;AACjC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,iBAAiB;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,uBAAuB;AAClC,UAAM,OAAO,IAAI,KAAK,IAAI;AAE1B,UAAM,KAAK,YAAY;AACvB,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,gBAAgB,QAAwB;AAC7C,QAAI,CAAC,QAAQ;AACX,UAAI,CAAC,KAAK,OAAO,OAAO;AACtB,cAAM,IAAI,MAAM,sBAAsB;AAAA,MACxC;AAEA,eAAS,KAAK,OAAO;AAAA,IACvB;AAEA,WAAO,GAAG,KAAK,OAAO,aAAa,WAAW,KAAK,OAAO,KAAK,0BAA0B,OAAO,QAAQ,UAAU,OAAO,KAAK,oCAAoC,OAAO,WAAW;AAAA,EACtL;AAAA,EAEA,MAAa,iBAAiB;AA3DhC;AA4DI,UAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;AACxC,SAAK,IAAI;AAAA,MACP,WAAW,KAAK,OAAO,KAAK;AAAA,MAC5B;AAAA,QACE,YAAY;AAAA,QACZ,MAAM,IAAI,aAAa,IAAI,MAAM;AAAA,QACjC,YAAW,UAAK,OAAO,UAAZ,mBAAmB;AAAA,QAC9B,QAAO,UAAK,OAAO,UAAZ,mBAAmB;AAAA,MAC5B;AAAA,MACA,EAAE,SAAS,EAAE,gBAAgB,oCAAoC,EAAE;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,aAAoB,YAAY,YAAoB;AAClD,WAAO,IAAI,QAAO,EAAE,QAAQ,MAAM,aAAa,YAAY,UAAU,EAAE,CAAC;AAAA,EAC1E;AACF;","names":["StepType","ErrorCode"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tharos-web-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"