Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@exoshtw/apple-auth-backend

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exoshtw/apple-auth-backend

Logging with Apple

  • 0.1.0-rc2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Apple auth for backend

Library for sign in with Apple to use from server-side.

Usage

import fs from 'fs';
import path from 'path';
import {getAuthToken} from '@exoshtw/node-apple-signin';

export function loginApple(code) {
    const response = await getAuthToken(code, {
        clientId: '....',
        teamId: '....',
        keyId: '...',
        key: fs.readFileSync(path.join(__dirname, 'private_key.p8')),
    });

    console.log(response);

    // {
    //   access_token: '...',
    //   token_type: 'Bearer',
    //   expires_in: 3600,
    //   refresh_token: '...',
    //   id_token: '{encoded_jwt_reponse}',
    //   data: { // <- decoded id_token
    //     iss: 'https://appleid.apple.com',
    //     aud: '...',
    //     exp: 1582046751,
    //     iat: 1582046151,
    //     sub: '...',
    //     at_hash: '...',
    //     email: '...',
    //     email_verified: 'true',
    //     auth_time: 1582046132
    //   }
    // }
}

API

{int} getTimestamp()

Get actual timestamp in int32 format.

{string} generateSecret(options)

Generate the JWT signed token for apple auth

Parameters
NameTypeArgumentDescription
optionsobjectOptions
options.timestampintoptionalTimestamp, autogenerated by default
options.expireintoptionalExpiration time of token
options.clientIdstringApple client id
options.teamIdstringApple team id
options.keyIdstringPrivate key id

{object} getAuthToken(code, options)

Get the auth token to signing with back code

Parameters
NameTypeArgumentDescription
codestringCode returned from client app
optionsobjectOptions
options.timestampintoptionalTimestamp, autogenerated by default
options.expireintoptionalExpiration time of token
options.clientIdstringApple client id
options.teamIdstringApple team id
options.keyIdstringPrivate key id

Motivation

There are other greats libraries (listed bellow) to use with node, but are focused on generating a sign in url and to work with a callback url.

This library is focused on working from the server-side, for example, to use Apple signin from mobile applications.

Other libraries

Keywords

FAQs

Package last updated on 18 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc