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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sparkrewards/sra-client

v0.0.4

Published

@sparkrewards/sra-client client

Readme

@sparkrewards/sra-client

TypeScript / JavaScript client SDK for the Spark Rewards App API, generated from the Smithy service model.

Installation

npm install @sparkrewards/sra-client
# or
yarn add @sparkrewards/sra-client

Authentication

The App API uses Cognito User Pools authentication. You must configure the client with the aws.auth#cognitoUserPools auth scheme.

Important: The generated client does not automatically provide auth scheme implementations. You must configure httpAuthSchemes when creating the client.

Basic Usage with AWS Amplify

import { AppAPIClient } from '@sparkrewards/sra-client';
import { fetchAuthSession } from 'aws-amplify/auth';
import { 
  HttpAuthScheme, 
  Identity, 
  IdentityProvider, 
  IdentityProviderConfig 
} from "@smithy/types";

interface CognitoIdentity extends Identity {
  token: string;
}

function createCognitoAuthScheme(token?: string): HttpAuthScheme {
  return {
    schemeId: "aws.auth#cognitoUserPools",
    identityProvider: (config: IdentityProviderConfig): IdentityProvider<CognitoIdentity> => {
      return async (): Promise<CognitoIdentity> => {
        return { token: token || '' } as CognitoIdentity;
      };
    },
    signer: {
      sign: async (httpRequest: any, identity: any) => {
        const cognitoIdentity = identity as CognitoIdentity;
        httpRequest.headers["Authorization"] = `Bearer ${cognitoIdentity.token}`;
        return httpRequest;
      },
    },
  };
}

async function getClient(): Promise<AppAPIClient> {
  const session = await fetchAuthSession();
  const idToken = session.tokens?.idToken?.toString();

  const client = new AppAPIClient({
    endpoint: 'https://beta-api.sparkrewards.co/sra',
    httpAuthSchemes: [createCognitoAuthScheme(idToken)],
  });
  
  return client;
}

// Usage
const client = await getClient();
const result = await client.send(new GetUserCommand({}));

Using with Public Endpoints

For public endpoints (those with @auth([]) in the model), you don't need authentication:

import { AppAPIClient, NearbyShopsPublicCommand } from '@sparkrewards/sra-client';

const client = new AppAPIClient({
  endpoint: 'https://beta-api.sparkrewards.co/sra',
  httpAuthSchemes: [], // Empty array for public-only usage
});

const shops = await client.send(new NearbyShopsPublicCommand({
  lat: 40.7128,
  lon: -74.0060,
}));

API Operations

The client supports both authenticated and public operations:

Authenticated operations (require Cognito token):

  • GetUser, UpdateUser, DeleteUser, OnboardUser
  • NearbyShops, FavoriteShops, GetShop, PinnedShop, PopularShops
  • Plan, Plans, FavoritePlans
  • RedeemFirstTimeReward, RedeemVisitReward, RedeemPointReward
  • RecordVisit, LikeOrg

Public operations (no authentication required):

  • NearbyShopsPublic, PopularShopsPublic, GetShopPublic
  • PlanPublic, PinnedShopPublic, SearchShopsPublic
  • RadiusShops, SearchSuggestion

Regenerating from the Smithy model

This package is generated by the typescript-client-codegen Smithy plugin. To regenerate it:

./gradlew :smithy:smithyBuild

The generated package lives under:

  • smithy/build/smithyprojections/smithy/source/typescript-client-codegen