import { AuthonConfig, Authon } from '@authon/js'; import { AuthonUser, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential, OAuthProviderType } from '@authon/shared'; export { PasskeyCredential, Web3Chain, Web3NonceResponse, Web3Wallet, Web3WalletType } from '@authon/shared'; /** * Injection token key for Authon configuration. * Used with Angular's InjectionToken. */ declare const AUTHON_CONFIG = "AUTHON_CONFIG"; interface AuthonServiceConfig { publishableKey: string; config?: Omit; } /** * Plain class wrapping @authon/js for Angular dependency injection. * * Since tsup cannot compile Angular decorators, this is a plain class. * Users should wrap it in their own injectable service: * * ```ts * import { Injectable } from '@angular/core'; * import { AuthonService as BaseAuthonService } from '@authon/angular'; * * @Injectable({ providedIn: 'root' }) * export class AuthonService extends BaseAuthonService { * constructor() { * super({ publishableKey: 'pk_live_...' }); * } * } * ``` * * Or use the `provideAuthon()` helper for standalone components. */ declare class AuthonService { private client; private _user; private _isSignedIn; private _isLoading; private _listeners; constructor(config: AuthonServiceConfig); get user(): AuthonUser | null; get isSignedIn(): boolean; get isLoading(): boolean; openSignIn(): Promise; openSignUp(): Promise; signOut(): Promise; getToken(): string | null; getClient(): Authon; web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise; web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise; web3LinkWallet(params: { address: string; chain: Web3Chain; walletType: Web3WalletType; chainId?: number; message: string; signature: string; }): Promise; web3UnlinkWallet(walletId: string): Promise; web3GetWallets(): Promise; passwordlessSendCode(email: string, type?: 'magic-link' | 'otp'): Promise; passwordlessVerifyCode(email: string, code: string): Promise; passkeyRegister(name?: string): Promise; passkeyAuthenticate(email?: string): Promise; passkeyList(): Promise; passkeyDelete(credentialId: string): Promise; /** * Subscribe to auth state changes. * Returns an unsubscribe function. */ onStateChange(callback: () => void): () => void; destroy(): void; private notifyListeners; } /** * Route guard factory for Angular Router (CanActivateFn style). * * Since tsup can't compile Angular decorators, this returns a plain function. * Users wire it up in their route config: * * ```ts * import { inject } from '@angular/core'; * import { authGuard } from '@authon/angular'; * import { AuthonService } from './authon.service'; // your injectable wrapper * * const routes = [ * { * path: 'dashboard', * component: DashboardComponent, * canActivate: [() => { * const authon = inject(AuthonService); * return authGuard(authon, '/login'); * }], * }, * ]; * ``` */ declare function authGuard(authonService: AuthonService, redirectTo?: string): boolean | { path: string; }; /** * Provider factory for Angular standalone components. * * Usage in app.config.ts: * ```ts * import { provideAuthon } from '@authon/angular'; * * export const appConfig = { * providers: [ * ...provideAuthon({ publishableKey: 'pk_live_...' }), * ], * }; * ``` * * Then inject in your components: * ```ts * import { Inject } from '@angular/core'; * import { AUTHON_CONFIG, AuthonService } from '@authon/angular'; * * constructor(@Inject('AuthonService') private authon: AuthonService) {} * ``` */ declare function provideAuthon(config: AuthonServiceConfig): ({ provide: string; useValue: AuthonServiceConfig; } | { provide: string; useValue: AuthonService; })[]; interface SocialButtonsConfig { /** Compact mode — icon-only square buttons in a row (default: false) */ compact?: boolean; /** Gap between buttons in px (default: 10, compact default: 12) */ gap?: number; /** Custom labels per provider */ labels?: Partial>; /** Icon size (default: 20, compact default: 24) */ iconSize?: number; /** Border radius in px (default: 10) */ borderRadius?: number; /** Button height in px (default: 48) */ height?: number; /** Button size for compact mode in px (default: 48) */ size?: number; } /** * Renders social login buttons into a container element. * * Usage with Angular: * ```ts * import { AuthonService } from '@authon/angular'; * import { renderSocialButtons } from '@authon/angular'; * * @Component({ ... }) * export class LoginComponent implements AfterViewInit, OnDestroy { * @ViewChild('socialContainer') container!: ElementRef; * private cleanup?: () => void; * * constructor(private authon: AuthonService) {} * * ngAfterViewInit() { * this.cleanup = renderSocialButtons({ * client: this.authon.getClient(), * container: this.container.nativeElement, * compact: true, * onError: (err) => console.error(err), * }); * } * * ngOnDestroy() { * this.cleanup?.(); * } * } * ``` */ declare function renderSocialButtons(options: { client: Authon; container: HTMLElement; onSuccess?: () => void; onError?: (error: Error) => void; } & SocialButtonsConfig): () => void; /** * Embedded sign-in component for Angular 17+ standalone projects. * * Since tsup cannot compile Angular decorators, use this class directly * and annotate it in your application layer: * * ```ts * import { Component, Input, Output, EventEmitter, OnInit, OnDestroy, ElementRef, ViewChild } from '@angular/core'; * import { AuthonSignInComponent } from '@authon/angular'; * * @Component({ * selector: 'authon-sign-in', * standalone: true, * template: `
`, * }) * export class SignInComponent extends AuthonSignInComponent implements OnInit, OnDestroy { * @Input() override publishableKey!: string; * @Input() override apiUrl = 'https://api.authon.dev'; * @Input() override theme: 'light' | 'dark' | 'auto' = 'auto'; * @Input() override locale?: string; * @Output() override signIn = new EventEmitter(); * @ViewChild('container', { static: true }) override containerRef!: ElementRef; * * ngOnInit() { this.onInit(); } * ngOnDestroy() { this.onDestroy(); } * } * ``` * * Or, for a fully self-contained approach (Angular 17+): * * ```ts * import { Component, Input, Output, EventEmitter, OnInit, OnDestroy, ElementRef, ViewChild } from '@angular/core'; * import { Authon } from '@authon/js'; * * @Component({ * selector: 'authon-sign-in', * standalone: true, * template: `
`, * }) * export class AuthonSignInComponent implements OnInit, OnDestroy { * @Input() publishableKey!: string; * @Input() apiUrl = 'https://api.authon.dev'; * @Input() theme: 'light' | 'dark' | 'auto' = 'auto'; * @Input() locale?: string; * @Output() signIn = new EventEmitter(); * @ViewChild('container', { static: true }) containerRef!: ElementRef; * * private _authon: Authon | null = null; * private _containerId = `authon-signin-${Math.random().toString(36).slice(2, 8)}`; * * ngOnInit() { * this.containerRef.nativeElement.id = this._containerId; * this._authon = new Authon(this.publishableKey, { * mode: 'embedded', * containerId: this._containerId, * apiUrl: this.apiUrl, * theme: this.theme, * locale: this.locale, * }); * this._authon.on('signedIn', (user) => this.signIn.emit(user)); * this._authon.openSignIn(); * } * * ngOnDestroy() { * this._authon?.destroy(); * } * } * ``` */ declare class AuthonSignInComponent { publishableKey: string; apiUrl: string; theme: 'light' | 'dark' | 'auto'; locale?: string; signIn: { emit: (user: unknown) => void; }; containerRef: { nativeElement: HTMLDivElement; }; private _authon; private _containerId; /** * Call from ngOnInit(). */ onInit(): void; /** * Call from ngOnDestroy(). */ onDestroy(): void; } /** * Embedded sign-up component for Angular 17+ standalone projects. * * Since tsup cannot compile Angular decorators, use this class directly * and annotate it in your application layer: * * ```ts * import { Component, Input, Output, EventEmitter, OnInit, OnDestroy, ElementRef, ViewChild } from '@angular/core'; * import { AuthonSignUpComponent } from '@authon/angular'; * * @Component({ * selector: 'authon-sign-up', * standalone: true, * template: `
`, * }) * export class SignUpComponent extends AuthonSignUpComponent implements OnInit, OnDestroy { * @Input() override publishableKey!: string; * @Input() override apiUrl = 'https://api.authon.dev'; * @Input() override theme: 'light' | 'dark' | 'auto' = 'auto'; * @Input() override locale?: string; * @Output() override signUp = new EventEmitter(); * @ViewChild('container', { static: true }) override containerRef!: ElementRef; * * ngOnInit() { this.onInit(); } * ngOnDestroy() { this.onDestroy(); } * } * ``` * * Or, for a fully self-contained approach (Angular 17+): * * ```ts * import { Component, Input, Output, EventEmitter, OnInit, OnDestroy, ElementRef, ViewChild } from '@angular/core'; * import { Authon } from '@authon/js'; * * @Component({ * selector: 'authon-sign-up', * standalone: true, * template: `
`, * }) * export class AuthonSignUpComponent implements OnInit, OnDestroy { * @Input() publishableKey!: string; * @Input() apiUrl = 'https://api.authon.dev'; * @Input() theme: 'light' | 'dark' | 'auto' = 'auto'; * @Input() locale?: string; * @Output() signUp = new EventEmitter(); * @ViewChild('container', { static: true }) containerRef!: ElementRef; * * private _authon: Authon | null = null; * private _containerId = `authon-signup-${Math.random().toString(36).slice(2, 8)}`; * * ngOnInit() { * this.containerRef.nativeElement.id = this._containerId; * this._authon = new Authon(this.publishableKey, { * mode: 'embedded', * containerId: this._containerId, * apiUrl: this.apiUrl, * theme: this.theme, * locale: this.locale, * }); * this._authon.on('signedIn', (user) => this.signUp.emit(user)); * this._authon.openSignUp(); * } * * ngOnDestroy() { * this._authon?.destroy(); * } * } * ``` */ declare class AuthonSignUpComponent { publishableKey: string; apiUrl: string; theme: 'light' | 'dark' | 'auto'; locale?: string; signUp: { emit: (user: unknown) => void; }; containerRef: { nativeElement: HTMLDivElement; }; private _authon; private _containerId; /** * Call from ngOnInit(). */ onInit(): void; /** * Call from ngOnDestroy(). */ onDestroy(): void; } export { AUTHON_CONFIG, AuthonService, type AuthonServiceConfig, AuthonSignInComponent, AuthonSignUpComponent, type SocialButtonsConfig, authGuard, provideAuthon, renderSocialButtons };