Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 13, 2025

This PR adds a new sign-in-with-apple template for Node.js/TypeScript, providing the same Apple authentication functionality that was previously only available in Dart.

Features

The template implements a complete Apple Sign-In flow that:

  • Exchanges authorization codes with Apple's API to obtain user ID tokens
  • Creates JWT client secrets using ES256 algorithm for Apple API authentication
  • Manages user accounts by creating new users or finding existing ones by ID/email
  • Handles email verification automatically for Apple-authenticated users
  • Generates session tokens for seamless Appwrite session creation

Implementation Details

The Node.js implementation mirrors the existing Dart version with appropriate ecosystem adaptations:

  • Uses jsonwebtoken for ES256 JWT creation with Apple credentials
  • Uses undici for modern HTTP requests to Apple's token endpoint
  • Uses Node.js crypto module for MD5 hashing of Apple's sub claim
  • Includes full TypeScript interfaces for type safety
  • Follows the same user creation and verification logic as the Dart version

API Usage

Request:

{
  "code": "c361a519253b3486ea3c7ecd4e9b6903f.0.suut.3LCHm9ytku1B2v4r5IayPQ",
  "firstName": "Walter",
  "lastName": "O'Brien"
}

Response:

{
  "secret": "0cbdd4fd7638e0f3f55871adf2256f8f42f6faa01c9300e482c9a585b76611343dee8562ce4421b1cf9e9de6f8341fb2286499cb7992d02accd2dc699211008c",
  "userId": "90a5450f396c242637c39b4c39e07af4",
  "expire": "2025-07-15T00:10:21.345+00:00"
}

This enables Node.js developers to integrate Apple Sign-In authentication into their Appwrite functions with the same capabilities previously available only to Dart developers.

Fixes #333.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Author

Copilot AI commented Aug 13, 2025

@stnguyen90 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@stnguyen90 stnguyen90 self-requested a review August 13, 2025 00:05
@stnguyen90 stnguyen90 marked this pull request as ready for review August 13, 2025 00:05
@Copilot Copilot AI changed the title [WIP] Implement sign-in-with-apple in node-typescript Implement sign-in-with-apple template for node-typescript Aug 13, 2025
Copilot finished work on behalf of stnguyen90 August 13, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement sign-in-with-apple in node-typescript

2 participants