npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@standardnotes/snjs

v2.209.5

Published

SNJS is a client-side JavaScript library for [Standard Notes](https://standardnotes.com) that contains shared logic for all Standard Notes clients.

Downloads

538

Readme

SNJS

SNJS is a client-side JavaScript library for Standard Notes that contains shared logic for all Standard Notes clients.

Introduction

SNJS is a shared library for use in all Standard Notes clients (desktop, web, and mobile). Its role is to extract any business or data logic from client code, so that clients are mostly responsible for UI-level code, and don’t have to think about encryption and key management, or even authentication or storage specifics. Extracting the code into a shared library also prevents us from having to write the same critical code on multiple platforms.

The entry point of SNJS is the SNApplication class. The application class is a complete unit of application functionality. Theoretically, many instances of an application can be created, each with its own storage namespace and memory state. This can allow clients to support multiple user accounts.

An application must be supplied a custom subclass of DeviceInterface. This allows the library to generalize all behavior a client will need to perform throughout normal client operation, such as saving data to a local database store, saving key/values, and accessing the keychain.

On Web platforms SNJS interacts with sncrypto to perform operations as mentioned in the specification document. This includes operations like key generation and data encryption.

SNJS also interacts with a Standard Notes syncing server, which is a zero-knowledge data and sync store that deals with encrypted data, and never learns of client secrets or sensitive information.

Installation

yarn add snjs

Integrating in module environment

import { SNApplication } from 'snjs';

Integrating in non-module web environment

<script src="snjs.js"></script>
Object.assign(window, SNLibrary);

Building

  1. yarn install --pure-lockfile
  2. yarn start to start Webpack in development mode (watches changes), or yarn build to create dist files.

Tests

E2E Tests

Prerequisites

To run a stable server environment for E2E tests that is up to date with production, setup a local self-hosted server.

Make sure you have the following value in the env vars mentioned below. It's important to have low token TTLs for the purpose of the suite.

# .env
...
AUTH_SERVER_ACCESS_TOKEN_AGE=4
AUTH_SERVER_REFRESH_TOKEN_AGE=10
AUTH_SERVER_EPHEMERAL_SESSION_AGE=300
SYNCING_SERVER_REVISIONS_FREQUENCY=5

Edit docker-compose.yml ports and change keypath services.server.ports[0] from port 3000 to 3123.

If running server without docker and as individual node processes, and you need a valid subscription for a test (such as uploading files), you'll need to clone the mock-event-publisher and run it locally on port 3124. In the Container.ts file, comment out any SNS_ENDPOINT related lines for running locally.

Start Server For Tests

In the self-hosted folder run:

docker compose pull && docker compose up

Wait for the services to be up.

Run Test Suite (APP)

Once the server infrastructure is ready, and you've built all packages, you can run the test suite in the browser.

In the app folder run:

yarn e2e

Troubleshooting

Before running the E2E test suite you might want to run in the app folder yarn build:snjs to make sure you are running the test suite against the most recent changes you have locally.

Unit Tests

From the root of the repository, run:

yarn run test