@treasure-dev/launcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Treasure Launcher

Treasure Launcher utilities for the Treasure ecosystem

Prerequisites

Installation

pnpm add @treasure-dev/launcher

Usage

Using vanilla JavaScript

Get auth token

import { getTreasureLauncherAuthToken } from "@treasure-dev/launcher";

const authToken = getTreasureLauncherAuthToken();

Check if using Treasure Launcher

import { isUsingTreasureLauncher } from "@treasure-dev/launcher";

const usingLauncher = isUsingTreasureLauncher();

Start user session

import { startUserSessionViaLauncher } from "@treasure-dev/launcher";

await startUserSessionViaLauncher({
    backendWallet: "0x...",
    approvedTargets: ["0x..."],
    nativeTokenLimitPerTransaction: 100,
    sessionDurationSec: 60 * 60 * 24 * 7,
    sessionMinDurationLeftSec: 60 * 60 * 24 * 3,
});

Using React

Check if using Treasure Launcher

import { useTreasure } from "@treasure-dev/react";

const { isUsingTreasureLauncher } = useTreasure();

Start user session via Treasure Launcher

Use startUserSession as usual:

import { useTreasure } from "@treasure-dev/react";

const { startUserSession } = useTreasure();

Using Electron + React

import { getTreasureLauncherAuthToken } from "@treasure-dev/launcher";

ipcMain.on("get-auth-token", (event, _arg) => {
    event.returnValue = getTreasureLauncherAuthToken();
});
const getAuthToken = () =>
  window.electron.ipcRenderer.sendSync("get-auth-token");

<TreasureProvider
 ...
    launcherOptions={{
        getAuthTokenOverride: getAuthToken,
    }}
>

Deployment

Merge changeset-bot's versioning PR to the main branch to push a new package version to npm.

Readme

Keywords

Package Sidebar

Install

npm i @treasure-dev/launcher

Weekly Downloads

113

Version

1.0.1

License

none

Unpacked Size

7.75 kB

Total Files

6

Last publish

Collaborators

  • vujevits
  • karelvuong
  • aphexyuri
  • rappzula