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

@wekanteam/accounts-sandstorm

v0.8.0

Published

Forked Package meteor-accounts-sandstorm

Downloads

4

Readme

Current status

  • Originally from https://github.com/sandstorm-io/meteor-accounts-sandstorm
  • xet7 added upgrade to newest Meteor 2.11 https://github.com/sandstorm-io/meteor-accounts-sandstorm/pull/36

Sandstorm.io login integration for Meteor.js

Sandstorm is a platform for personal clouds that makes installing apps to your personal server as easy as installing apps to your phone.

Meteor is a revolutionary web app framework. Sandstorm's own UI is built using Meteor, and Meteor is also a great way to build Sandstorm apps.

This package is meant to be used by Meteor apps built to run on Sandstorm. It integrates with Sandstorm's built-in login system to log the user in automatically when they open the app. The user's profile.name will be populated from Sandstorm. When using this package, you should not use accounts-ui at all; just let login happen automatically.

Including in your app

To use this package in your Meteor project, simply install it from the Meteor package repository:

npm install @wekanteam/accounts-sandstorm

To package a Meteor app for Sandstorm, see the Meteor app packaging guide.

Note that this package does nothing if the SANDSTORM environment variable is not set. Therefore, it is safe to include the package even in non-Sandstorm builds of your app. Note that sandstorm-pkgdef.capnp files generated by spk init automatically have a line like (key = "SANDSTORM", value = "1"), which sets the environment variable, so you shouldn't have to do anything special to enable it.

Conversely, when SANDSTORM is set, this package will enter Highlander Mode in which it will disable all other accounts packages. This makes it safe to include those other accounts packages in the Sandstorm build, which is often convenient, although they will add bloat to your spk.

Usage

  • On the client, call Meteor.sandstormUser(). (This is a reactive data source.)
  • In a method or publish (on the server), call this.connection.sandstormUser().

Either of these will return an object containing the following fields:

  • id: From X-Sandstorm-User-Id; globally unique and stable identifier for this user. null if the user is not logged in.
  • name: From "X-Sandstorm-Username, the user's display name (e.g. "Kenton Varda"`).
  • picture: From X-Sandstorm-User-Picture, URL of the user's preferred avatar, or null if they don't have one.
  • permissions: From X-Sandstorm-Permissions (but parsed to a list), the list of permissions the user has as determined by the Sandstorm sharing model. Apps can define their own permissions.
  • preferredHandle: From X-Sandstorm-Preferred-Handle, the user's preferred handle ("username", in the unix sense). This is NOT guaranteed to be unique; it's just a different form of display name.
  • pronouns: From X-Sandstorm-User-Pronouns, indicates the pronouns by which the user prefers to be referred.

See the Sandstorm docs for more information about these fields.

Note that sandstormUser() may return null on the client side if the login handshake has not completed yet (Meteor.loggingIn() returns true during this time). It never returns null on the server, but it may throw an exception if the client skipped the authentication handshake (which indicates the client is not running accounts-sandstorm, which is rather suspicious!).

Synchronization with Meteor Accounts

accounts-sandstorm does NOT require accounts-base. However, if you do include accounts-base in your dependencies, then accounts-sandstorm will integrate with it in order to store information about users seen previously. In particular:

  • A Meteor account will be automatically created for each logged-in Sandstorm user, the first time they visit the grain.
  • In the Meteor.users table, services.sandstorm will contain the same data returned by Meteor.sandstormUser().
  • Meteor.loggingIn() will return true during the initial handshake (when sandstormUser() would return null).

Please note, however, that you should prefer sandstormUser() over Meteor.user().services.sandstorm whenever possible, especially for enforcing permissions, for a few reasons:

  • Anonymous users do NOT get a table entry, therefore Meteor.user() will be null for them. However, anonymous users of a sharing link may have permissions!
  • Moreover, in the future, anonymous users may additionally be able to assign themselves names, handles, avatars, etc. The only thing that makes them "anonymous" is that they have not provided the app with a unique identifier that could be used to recognize the same user when they visit again later.
  • services.sandstorm is only updated when the user is online; it may be stale when they are not present. This implies that when a user's access is revoked, their user table entry will never be updated again, and will continue to indicate that they have permissions when they in fact no longer do.

Development aids

accounts-sandstorm normally works its magic when running inside Sandstorm. However, it's often a lot more convenient to develop Meteor apps using Meteor's normal dev tools which currently cannot run inside Sandstorm.

Therefore, when not running inside Sansdtorm, you may use the following console function to fake your user information:

SandstormAccounts.setTestUserInfo({
  id: "12345",
  name: "Alice",
  // ... other parameters, as listed above ...
});

This will cause accounts-sandstorm to spoof the X-Sandstorm-* headers with the parameters you provided when it attempts to log in. When actually running inside Sandstorm, such spoofing is blocked by Sandstorm, but when running outside it will work and now you can test your app.

Note that this functionality, like all of the package, is only enabled if you set the SANDSTORM environment variable. So, run meteor like so:

SANDSTORM=1 meteor

Migrating from 0.1

In version 0.1.x of this puackage, there was no sandstormUser() function; the only mode of operation was through Meteor accounts. This had problems with permissions and anonymous users as described adove. Introducing sandstormUser() is a huge update.

For almost all users, 0.2 should be a drop-in replacement for 0.1, only adding new features. Please note, though, two possible issues:

  • If you did not explicitly depend on accounts-base before, you must add this dependency, since it is no longer implied by accounts-sandstorm.
  • The /.sandstorm-credentials endpoint no longer exists. If you were directly fetching this undocumented endpoint before, you will need to switch your code to use Meteor.sandstormUser().