.eslintrc.js
.github
    ISSUE_TEMPLATE
        bug-defect-problem.md
        epic-template.md
        feature_request.md
        issue-template.md
    workflows
        bundle-and-deploy.yml
        deploy-main.yml
        playwright.yml
        pull-request.yml
        push-to-artifact-registry.yml
        push-to-docker-hub.yml
.idea
    codeStyles
        codeStyleConfig.xml
    inspectionProfiles
        Project_Default.xml
    jsLibraryMappings.xml
    jsLinters
        eslint.xml
    modules.xml
    prettier.xml
    vcs.xml
.vscode
    launch.json
README.md
lerna.json
package.json
packages
    near-fast-auth-signer-e2e-tests
        .eslintrc.js
        README.md
        package.json
        playwright.config.ts
        public
            index.html
        test-app
            index.html
        tests
            example.spec.ts
        tsconfig.json
        webpack.config.js
    near-fast-auth-signer
        .eslintrc.js
        README.md
        package.json
        public
            index.html
        src
            api
                index.ts
            components
                Layout
                    index.ts
                Login
                    Login.style.ts
                Sign
                    Sign.styles.ts
                    Values
                        fiatValueManager.ts
                        formatNearAmount.ts
                        store.ts
                        tmp_fetch_send_json.ts
                SignMultichain
                    bitcoin
                        schema.ts
                    evm
                        schema.ts
                    schema.ts
                    types.ts
                    utils.ts
                TableContent
                    TableContent.styles.ts
            hooks
                useAuthState.ts
                useFirebaseUser.ts
                useIframeDialogConfig.ts
                useInvalidContractId.ts
                usePageChangeEffect.ts
            index.html
            lib
                Spinner
                    index.ts
                Toast
                    README.md
                    api.ts
                    index.ts
                    store.ts
                    styles.ts
                Tooltip
                    index.ts
                controller.ts
                firestoreController.ts
                networkParams.ts
            styles
                globals.css
                theme.css
            translations
                de.json
                en.json
            types
                global.d.ts
            utils
                analytics.ts
                config.ts
                cookie.ts
                environment.ts
                firebase.ts
                form-validation.ts
                index.ts
                keypom-options.ts
                mpc-service.ts
                types.ts
        tsconfig.json
        vercel.json
        webpack.config.js

# `fast-auth-signer-e2e-tests`

> TODO: description

## Usage

```
const fastAuthSignerE2eTests = require('fast-auth-signer-e2e-tests');

// TODO: DEMONSTRATE API
```
# fast-auth-signer ![Docker Pulls](https://img.shields.io/docker/pulls/nearprotocol/fast-auth-sdk-frontend?link=https%3A%2F%2Fhub.docker.com%2Fr%2Fnearprotocol%2Ffast-auth-sdk-frontend)
Monorepo for fast-auth-signer functionality - contains frontend app, and associated E2E test suites defined using Playwright

## Packages
#### [near-fast-auth-signer](./packages/near-fast-auth-signer/README.md)
Web application designed primarily for usage via embedding into parent site using an iframe 
#### [near-fast-auth-signer-e2e-tests](./packages/near-fast-auth-signer-e2e-tests/README.md)
E2E test suites for `near-fast-auth-signer` using Playwright tests.

## Usage
This repository leverages Yarn workspaces.  

#### Local Development
Run `yarn` from the repository root. This will install dependencies for all packages by way of Yarn workspaces functionality.
#### Run your own instance
Instructions to run your own instance of the signer app can be found [here](https://docs.near.org/tools/fastauth-sdk#setting-up-the-frontend).
#### End-to-End tests
Run `yarn test` from the repository root.
# Toast

Implemented via Radix primitives: https://www.radix-ui.com/docs/primitives/components/toast

_If the current props and Stitches style overrides aren't enough to cover your use case, feel free to implement your own component using the Radix primitives directly._

## Example

Using the `openToast` API allows you to easily open a toast from any context:

```tsx
import { openToast } from '@/components/lib/Toast';

...

<Button
  onClick={() =>
    openToast({
      type: 'ERROR',
      title: 'Toast Title',
      description: 'This is a great toast description.',
    })
  }
>
  Open a Toast
</Button>
```

You can pass other options too:

```tsx
<Button
  onClick={() =>
    openToast({
      type: 'SUCCESS', // SUCCESS | INFO | ERROR
      title: 'Toast Title',
      description: 'This is a great toast description.',
      icon: 'ph-bold ph-pizza', // https://phosphoricons.com/
      duration: 20000, // milliseconds (pass Infinity to disable auto close)
    })
  }
>
  Open a Toast
</Button>
```

## Deduplicate

If you need to ensure only a single instance of a toast is ever displayed at once, you can deduplicate by passing a unique `id` key. If a toast with the passed `id` is currently open, a new toast will not be opened:

```tsx
<Button
  onClick={() =>
    openToast({
      id: 'my-unique-toast',
      title: 'Toast Title',
      description: 'This is a great toast description.',
    })
  }
>
  Deduplicated Toast
</Button>
```

## Custom Toast

If you need something more custom, you can render a custom toast using `lib/Toast/Toaster.tsx` as an example like so:

```tsx
import * as Toast from '@/components/lib/Toast';

...

<Toast.Provider duration={5000}>
  <Toast.Root open={isOpen} onOpenChange={setIsOpen}>
    <Toast.Title>My Title</Toast.Title>
    <Toast.Description>My Description</Toast.Description>
    <Toast.CloseButton />
  </Toast.Root>

  <Toast.Viewport />
</Toast.Provider>
```
# Fast-Auth-Signer

This application facilitates generation of ED25519 keys using WebAuthN APIs (typically using biometrics), signing of transactions using those keys, and an implementation of 'sign in' functionality using the same paradigm as wallet apps in the ecosystem support.
It is designed to be integrated into [near-discovery](https://github.com/near/near-discovery) by way of inter-iframe RPC calls leveraging [iframe-rpc](https://github.com/near/near-api-js/tree/master/packages/iframe-rpc).

## How to run

This repository uses Yarn for package management. You'll need to install the dependencies first before you start the dev server.

```bash
yarn install
yarn start
```

## UI Routes
#### `/create-account`
- Displays a UI to create a new account
- Account creation is handled via the recovery service, using an e-mail link to get a valid OAuth assertion for that service
- FAK is generated via WebAuthN prompt (typically biometrics)
#### `/add-device`
- Displays a UI to authorize the current machine to control a recovery-service enabled account (adds a new biometric-based FAK to the account)
- FAK is generated via WebAuthN prompt (typically biometrics)
#### `/sign`
- Displays a UI to display transaction details, allowing the user to review the transaction and approve signing it.
#### `/login`
- Displays a UI to display a detailed overview of access key permissions that are being requested to be added to the user's account.

## RPC API
#### `createAccount(limitedAccessPublicKeys[]) -> { accountId: string, fullAccessPublicKey:string }`
- Returns the account ID of the account that the user created, along with the publicKey of the FAK that was used to secure the account (generated via WebAuthN prompt)
#### `getPublicKey() -> <PublicKey in Hex format`
- Returns the user's public key in hex format, which is derived from a WebAuthN (typically biometric) interaction
- Throws error if user has not yet authenticated
#### `getAccount() -> accountId: string`
- Returns the account ID of the account that the user is currently authenticated to use.  
- Throws error if user has not yet authenticated
#### `signTransactions(transactions[]) -> signedTransactions[]`
- Navigates to the appropate UI route (/sign)
- Returns signed transactions that can be submitted by the requester if approved
- Throws error if failed or cancelled by user
#### `signDelegateAction(actions) -> signedDelegateAction`
- Navigates to the appropate UI route (/sign)
- Returns a signed DelegateAction composed of the requested actions so that the requester can submit them for execution by a relayer if approved
- Throws error if failed or cancelled by user
#### `login(accessKey) -> boolean`
- Navigates to the appropate UI route (/login)
- Returns true if login was successful
- Throws error if failed or cancelled by user
