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

apple-jwt-generator

v1.1.1

Published

Generates Apple Client Secret for Sign in with Apple (SIWA) authentication.

Downloads

16

Readme

apple-jwt-generator

Yet another package to generate an Apple Client Secret for SIWA.

The apple-jwt-generator is a lightweight Node.js library designed for generating JSON Web Tokens (JWT) for server-to-server communication with Apple's services. It simplifies the process of creating JWTs using your Apple Developer account's team ID, key ID, and private key, providing an easy-to-use interface for authenticating with Apple's APIs.

Installation

Install the package via npm:

npm install apple-jwt-generator
yarn add apple-jwt-generator
pnpm install apple-jwt-generator
bun add apple-jwt-generator

Usage

import { generateAppleJWT, AppleJWTConfig } from 'apple-jwt-generator';

const config: AppleJWTConfig = {
  teamId: 'YOUR_TEAM_ID',
  keyId: 'YOUR_KEY_ID',
  clientId: 'YOUR_CLIENT_ID',
  privateKey: `-----BEGIN PRIVATE KEY-----
YOUR_PRIVATE_KEY_HERE
-----END PRIVATE KEY-----`,
};

const jwt = generateAppleJWT(config);
console.log(jwt);

API Reference

generateAppleJWT(config: AppleJWTConfig): string

Generates a JWT for server-to-server authentication with Apple's services. This function takes a configuration object as its only argument and returns a JWT string.

Parameters

| Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | config | AppleJWTConfig | Configuration object for generating the JWT. |

AppleJWTConfig Fields

| Field | Type | Required | Description | Default | | ------------ | ------ | -------- | --------------------------------------------------------------------------- | ---------- | | teamId | string | Yes | Team ID from Apple Developer Account. | N/A | | keyId | string | Yes | Key ID of the Private Key. | N/A | | clientId | string | Yes | Client ID for the JWT. | N/A | | privateKey | string | Yes | Apple Private Key in PEM format. | N/A | | expiresIn | number | No | Expiration in seconds from now for the JWT. Maximum expiration is 6 months. | 15778476 |

Returns

  • string: The generated Apple JWT.

Disclaimer

Node.js Version Requirement

This package requires a minimum Node.js version of 12.0.0 to operate correctly due to its reliance on specific features and improvements introduced in this version.

Not Suitable for Browser Environments

apple-jwt-generator is designed to be used in server-side environments and makes use of Node.js's crypto module, which is not available in browser environments. Attempting to use this package in the browser would result in errors, as browsers do not have the necessary module for cryptographic operations that this package depends on. Moreover, exposing sensitive credentials (such as private keys) in client-side code can lead to security vulnerabilities, making it critical to handle JWT generation server-side.

License

Licensed under the MIT License

See LICENSE for more information.