@nauth-toolkit/social-apple 0.1.13 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nestjs/apple-social-auth.module.d.ts +37 -0
- package/dist/nestjs/apple-social-auth.module.d.ts.map +1 -1
- package/dist/nestjs/apple-social-auth.module.js +48 -4
- package/dist/nestjs/apple-social-auth.module.js.map +1 -1
- package/dist/nestjs/index.d.ts +5 -0
- package/dist/nestjs/index.d.ts.map +1 -1
- package/dist/nestjs/index.js +6 -0
- package/dist/nestjs/index.js.map +1 -1
- package/dist/src/apple-oauth.client.d.ts +59 -0
- package/dist/src/apple-oauth.client.d.ts.map +1 -1
- package/dist/src/apple-oauth.client.js +63 -2
- package/dist/src/apple-oauth.client.js.map +1 -1
- package/dist/src/apple-social-auth.service.d.ts +57 -1
- package/dist/src/apple-social-auth.service.d.ts.map +1 -1
- package/dist/src/apple-social-auth.service.js +80 -3
- package/dist/src/apple-social-auth.service.js.map +1 -1
- package/dist/src/dto/social-login.dto.d.ts +219 -0
- package/dist/src/dto/social-login.dto.d.ts.map +1 -1
- package/dist/src/dto/social-login.dto.js +219 -0
- package/dist/src/dto/social-login.dto.js.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/token-verifier.service.d.ts +45 -0
- package/dist/src/token-verifier.service.d.ts.map +1 -1
- package/dist/src/token-verifier.service.js +41 -1
- package/dist/src/token-verifier.service.js.map +1 -1
- package/dist/src/verified-token-profile.interface.d.ts +19 -0
- package/dist/src/verified-token-profile.interface.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -35,6 +35,24 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.TokenVerifierService = void 0;
|
|
37
37
|
const core_1 = require("@nauth-toolkit/core");
|
|
38
|
+
/**
|
|
39
|
+
* Token Verifier Service for Apple OAuth (Platform-Agnostic)
|
|
40
|
+
*
|
|
41
|
+
* Handles secure verification of Apple ID tokens using JWKS public keys.
|
|
42
|
+
* Uses cryptographic signature verification to ensure tokens are authentic.
|
|
43
|
+
*
|
|
44
|
+
* Security Features:
|
|
45
|
+
* - Apple: Verifies JWT signature with Apple's JWKS public keys
|
|
46
|
+
*
|
|
47
|
+
* This is a plain TypeScript class with no framework dependencies.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const verifier = new TokenVerifierService(config);
|
|
52
|
+
* const profile = await verifier.verifyAppleToken(idToken, clientId);
|
|
53
|
+
* console.log(profile.email); // Verified email from Apple
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
38
56
|
class TokenVerifierService {
|
|
39
57
|
appleJWKS = null;
|
|
40
58
|
logger;
|
|
@@ -54,9 +72,31 @@ class TokenVerifierService {
|
|
|
54
72
|
if (this.appleJWKS)
|
|
55
73
|
return this.appleJWKS;
|
|
56
74
|
const jose = await this.getJose();
|
|
75
|
+
// Initialize Apple Remote JWKS (fetched and cached by jose)
|
|
57
76
|
this.appleJWKS = jose.createRemoteJWKSet(new URL('https://appleid.apple.com/auth/keys'));
|
|
58
77
|
return this.appleJWKS;
|
|
59
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Verify Apple ID token with JWT signature validation
|
|
81
|
+
*
|
|
82
|
+
* Fetches Apple's public keys from their JWKS endpoint and verifies the
|
|
83
|
+
* JWT signature to ensure authenticity.
|
|
84
|
+
*
|
|
85
|
+
* @param idToken - ID token from Apple Sign In
|
|
86
|
+
* @param clientId - Apple Services ID (client ID) for audience validation
|
|
87
|
+
* @returns Verified user profile data
|
|
88
|
+
* @throws {BadRequestException} When token is invalid, expired, or signature fails
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* try {
|
|
93
|
+
* const profile = await verifier.verifyAppleToken(idToken, 'com.yourapp.service');
|
|
94
|
+
* console.log(`Verified email: ${profile.email}`);
|
|
95
|
+
* } catch (error) {
|
|
96
|
+
* console.error('Token verification failed:', error.message);
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
60
100
|
async verifyAppleToken(idToken, clientId) {
|
|
61
101
|
try {
|
|
62
102
|
this.logger?.debug?.(`[TokenVerifier] Verifying Apple token`);
|
|
@@ -65,7 +105,7 @@ class TokenVerifierService {
|
|
|
65
105
|
const { payload } = await jose.jwtVerify(idToken, appleJWKS, {
|
|
66
106
|
issuer: 'https://appleid.apple.com',
|
|
67
107
|
audience: clientId,
|
|
68
|
-
clockTolerance: 300,
|
|
108
|
+
clockTolerance: 300, // 5 minutes leeway
|
|
69
109
|
});
|
|
70
110
|
const p = payload;
|
|
71
111
|
this.logger?.log?.(`[TokenVerifier] Apple token verified (secure): ${p.email}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-verifier.service.js","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAqH;
|
|
1
|
+
{"version":3,"file":"token-verifier.service.js","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAqH;AAWrH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,oBAAoB;IACvB,SAAS,GAAwD,IAAI,CAAC;IAC7D,MAAM,CAAc;IACpB,QAAQ,CAA4B;IAC7C,iBAAiB,GAA+B,IAAI,CAAC;IAE7D,YAAY,MAAmB,EAAE,QAAoC;QACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAqB,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,kDAAO,M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GAAa;gBACpB,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;gBACpB,cAAc,EAAE,CAAC,CAAC,cAAc,KAAK,MAAM,IAAI,CAAC,CAAC,cAAc,KAAK,IAAI;gBACxE,gBAAgB,EAAE,CAAC,CAAC,gBAAgB;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,oDAAoD,YAAY,EAAE,CAAC,CAAC;YACzF,MAAM,IAAI,qBAAc,CAAC,oBAAa,CAAC,oBAAoB,EAAE,oCAAoC,YAAY,EAAE,CAAC,CAAC;QACnH,CAAC;IACH,CAAC;CACF;AAhFD,oDAgFC"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verified Token Profile - Apple OAuth
|
|
3
|
+
*
|
|
4
|
+
* Standardized return type for Apple token verification.
|
|
5
|
+
* This is provider-specific and should not be in core.
|
|
6
|
+
*/
|
|
1
7
|
export interface VerifiedAppleTokenProfile {
|
|
8
|
+
/**
|
|
9
|
+
* Apple user ID (sub claim)
|
|
10
|
+
*/
|
|
2
11
|
sub: string;
|
|
12
|
+
/**
|
|
13
|
+
* User's email address
|
|
14
|
+
* May be empty string if not provided or using private relay
|
|
15
|
+
*/
|
|
3
16
|
email: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the email is verified by Apple
|
|
19
|
+
*/
|
|
4
20
|
email_verified: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the email is a private relay email (iCloud Private Relay)
|
|
23
|
+
*/
|
|
5
24
|
is_private_email?: boolean;
|
|
6
25
|
}
|
|
7
26
|
//# sourceMappingURL=verified-token-profile.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verified-token-profile.interface.d.ts","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verified-token-profile.interface.d.ts","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|