TypeScript Types

Othent exported TypeScript types.

Events

See Events.

type OthentEventType = "auth" | "error"
type AuthListener = (
    userDetails: UserDetails | null,
    isAuthenticated: boolean,
) => void;
type ErrorListener = (err: Error | OthentError) => void;

Dispatch

See dispatch();

interface DispatchOptions {
  arweave?: Arweave;
  node?: UrlString;
}
interface ArDriveBundledTransactionResponseData {
  id: string;
  timestamp: number;
  winc: string;
  version: string;
  deadlineHeight: number;
  dataCaches: string[];
  fastFinalityIndexes: string[];
  public: string;
  signature: string;
  owner: string;
}
interface ArDriveBundledTransactionData
  extends ArDriveBundledTransactionResponseData {
  type: "BUNDLED";
}
interface UploadedTransactionData {
  type: "BASE";
  id: string;
  signature: string;
  owner: string;
}

DataItem

See signDataItem();

type OthentEventType = "auth" | "error";
interface TagData {
  name: string;
  value: string;
}
interface DataItem {
  data: string | Uint8Array;
  target?: string;
  anchor?: string;
  tags?: TagData[];
}

See constructor() and config.

type OthentStorageKey = `othent${string}`;
type Auth0Strategy = "cross-site-cookies" | "refresh-tokens";
type Auth0Cache = "memory" | "localstorage" | ICache;
type Auth0CacheType = "memory" | "localstorage" | "custom";
type Auth0RedirectUri =
  | UrlString
  | `${string}.auth0://${string}/ios/${string}/callback`
  | `${string}.auth0://${string}/android/${string}/callback`;
type Auth0RedirectUriWithParams = `${Auth0RedirectUri}?${string}`;
type Auth0LogInMethod = "popup" | "redirect";
type AutoConnect = "eager" | "lazy" | "off";
interface AppInfo {
  name: string;
  version: string;
  env: string;
  logo?: UrlString;
}
interface OthentConfig { ... } // Listed in constructor()'s docs page.
interface OthentOptions { ... } // Listed in constructor()'s docs page.

See getUserDetails().

type Auth0Provider =
  | `apple`
  | `auth0`
  | `google-oauth2`
  | `<LinkedIn>`
  | `<X>`
  | `<Meta>`
  | `<Twitch>`
  | `github`;
type Auth0Sub = `${Auth0Provider}|(${string})`;
type Auth0ProviderLabel =
  | `Apple`
  | `E-Mail`
  | `Google`
  | `LinkedIn`
  | `X`
  | `Meta`
  | `Twitch`
  | `GitHub`
  | `Unknown Provider`;
type Auth0WalletAddressLabel = `${Auth0ProviderLabel} (${string})`;
type ANSDomain = `${string}.ar`;
type OthentWalletAddressLabel = Auth0WalletAddressLabel | ANSDomain;
export interface UserDetails {
  // Default from Auth0's User:
  sub: Auth0Sub;
  name: string;
  givenName: string;
  middleName: string;
  familyName: string;
  nickname: string;
  preferredUsername: string;
  profile: string;
  picture: string;
  website: string;
  locale: string;
  updatedAt: string;
  email: string;
  emailVerified: boolean;

  // Custom from Auth0's Add User Metadata action:
  owner: B64UrlString;
  walletAddress: B64UrlString;
  walletAddressLabel: OthentWalletAddressLabel;
  authSystem: "KMS";
  authProvider: Auth0Provider;
}

These types are only exported for backwards compatibility with @othent/kms version 1.X.X and to facilitate the migration to version 2 for those that might have stored this BufferObject entity.

interface BufferObject {
  type: "Buffer";
  data: number[];
}
function isBufferObject(obj: any): obj is BufferObject {
  return (
    obj.type === "Buffer" &&
    Array.isArray(obj.data) &&
    typeof obj[0] === "number"
  );
}

Note that the DispatchResult, AppInfo and DateItem types defined in arconnect / arconnectio/types are not exported as Othent overrides and extends them.

type PermissionType =
  | "ACCESS_ADDRESS"
  | "ACCESS_PUBLIC_KEY"
  | "ACCESS_ALL_ADDRESSES"
  | "SIGN_TRANSACTION"
  | "ENCRYPT"
  | "DECRYPT"
  | "SIGNATURE"
  | "ACCESS_ARWEAVE_CONFIG"
  | "DISPATCH";
interface GatewayConfig {
  host: string;
  port: number;
  protocol: "http" | "https";
}
interface SignMessageOptions {
  hashAlgorithm?: "SHA-256" | "SHA-384" | "SHA-512";
}

An enum OthentErrorID and class OthentError (extends Error) are exported from error.ts.

See Error Handling.

type UrlString = `http://${string}` | `https://${string}`;

Last updated