/// /// /// import { ApiRequest, Oauth2Driver } from '@adonisjs/ally/build/standalone'; import type { AllyUserContract, ApiRequestContract, LiteralStringUnion, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally'; import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; /** * Define the access token object properties in this type. It * must have "token" and "type" and you are free to add * more properties. * * ------------------------------------------------ * Change "YourDriver" to something more relevant * ------------------------------------------------ */ export declare type TikTokDriverAccessToken = { token: string; type: 'bearer'; accessToken: string; userId: string; }; export interface TikTokUserContract extends Omit, 'token'> { } /** * Define a union of scopes your driver accepts. Here's an example of same * https://github.com/adonisjs/ally/blob/develop/adonis-typings/ally.ts#L236-L268 * * ------------------------------------------------ * Change "YourDriver" to something more relevant * ------------------------------------------------ */ export declare type TikTokDriverScopes = 'user.info.basic' | 'video.list' | 'sound.share.create' | 'user.info.email'; /** * Define the configuration options accepted by your driver. It must have the following * properties and you are free add more. * */ export declare type TikTokDriverConfig = { driver: 'tiktok'; clientId: string; clientSecret: string; callbackUrl: string; authorizeUrl?: string; accessTokenUrl?: string; userInfoUrl?: string; scopes?: LiteralStringUnion[]; }; export declare type TikTokTokenDecoded = { open_id: string; union_id: string; avatar_url: string; avatar_url_100: string; avatar_large_url: string; display_name: string; bio_description: string; profile_deep_link: string; is_verified: boolean; follower_count: number; following_count: number; likes_count: number; email?: string; }; /** * Driver implementation. It is mostly configuration driven except the user calls * */ export declare class TikTokDriver extends Oauth2Driver { config: TikTokDriverConfig; protected authorizeUrl: string; protected accessTokenUrl: string; protected userInfoUrl: string; protected codeParamName: string; protected errorParamName: string; protected stateCookieName: string; protected stateParamName: string; protected scopeParamName: string; protected scopesSeparator: string; constructor(ctx: HttpContextContract, config: TikTokDriverConfig); protected configureRedirectRequest(request: RedirectRequestContract): void; protected processClientResponse(client: ApiRequest, response: any): any; protected configureAccessTokenRequest(request: ApiRequestContract): void; accessDenied(): boolean; protected getUserInfo(token: string): Promise; /** * Get the user details by query the provider API. This method must return * the access token and the user details both. Checkout the google * implementation for same. * * https://github.com/adonisjs/ally/blob/develop/src/Drivers/Google/index.ts#L191-L199 */ user(callback?: (request: ApiRequest) => void): Promise>; userFromToken(token: string): Promise<{ token: { token: string; type: "bearer"; }; name: string; email: string | null; id: string; nickName: string; emailVerificationState: "verified" | "unverified" | "unsupported"; avatarUrl: string | null; original: any; }>; }