@nauth-toolkit/social-apple 0.1.3
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/LICENSE +90 -0
- package/README.md +30 -0
- package/dist/nestjs/apple-social-auth.module.d.ts +10 -0
- package/dist/nestjs/apple-social-auth.module.d.ts.map +1 -0
- package/dist/nestjs/apple-social-auth.module.js +72 -0
- package/dist/nestjs/apple-social-auth.module.js.map +1 -0
- package/dist/nestjs/index.d.ts +7 -0
- package/dist/nestjs/index.d.ts.map +1 -0
- package/dist/nestjs/index.js +25 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/src/apple-oauth.client.d.ts +15 -0
- package/dist/src/apple-oauth.client.d.ts.map +1 -0
- package/dist/src/apple-oauth.client.js +97 -0
- package/dist/src/apple-oauth.client.js.map +1 -0
- package/dist/src/apple-social-auth.service.d.ts +16 -0
- package/dist/src/apple-social-auth.service.d.ts.map +1 -0
- package/dist/src/apple-social-auth.service.js +91 -0
- package/dist/src/apple-social-auth.service.js.map +1 -0
- package/dist/src/dto/social-login.dto.d.ts +47 -0
- package/dist/src/dto/social-login.dto.d.ts.map +1 -0
- package/dist/src/dto/social-login.dto.js +131 -0
- package/dist/src/dto/social-login.dto.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/token-verifier.service.d.ts +9 -0
- package/dist/src/token-verifier.service.d.ts.map +1 -0
- package/dist/src/token-verifier.service.js +38 -0
- package/dist/src/token-verifier.service.js.map +1 -0
- package/dist/src/verified-token-profile.interface.d.ts +7 -0
- package/dist/src/verified-token-profile.interface.d.ts.map +1 -0
- package/dist/src/verified-token-profile.interface.js +3 -0
- package/dist/src/verified-token-profile.interface.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SocialAccountsResponseDTO = exports.SocialLoginResponseDTO = exports.UnlinkSocialAccountDTO = exports.LinkSocialAccountDTO = exports.SocialCallbackDTO = exports.SocialLoginDTO = exports.SocialProvider = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
var SocialProvider;
|
|
15
|
+
(function (SocialProvider) {
|
|
16
|
+
SocialProvider["GOOGLE"] = "google";
|
|
17
|
+
SocialProvider["APPLE"] = "apple";
|
|
18
|
+
SocialProvider["FACEBOOK"] = "facebook";
|
|
19
|
+
})(SocialProvider || (exports.SocialProvider = SocialProvider = {}));
|
|
20
|
+
class SocialLoginDTO {
|
|
21
|
+
provider;
|
|
22
|
+
state;
|
|
23
|
+
}
|
|
24
|
+
exports.SocialLoginDTO = SocialLoginDTO;
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, class_validator_1.IsEnum)(SocialProvider, { message: 'Provider must be one of: google, apple, facebook' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], SocialLoginDTO.prototype, "provider", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, class_validator_1.IsOptional)(),
|
|
31
|
+
(0, class_validator_1.IsString)({ message: 'State must be a string' }),
|
|
32
|
+
(0, class_validator_1.MaxLength)(500, { message: 'State must not exceed 500 characters' }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], SocialLoginDTO.prototype, "state", void 0);
|
|
35
|
+
class SocialCallbackDTO {
|
|
36
|
+
provider;
|
|
37
|
+
code;
|
|
38
|
+
state;
|
|
39
|
+
error;
|
|
40
|
+
error_description;
|
|
41
|
+
}
|
|
42
|
+
exports.SocialCallbackDTO = SocialCallbackDTO;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, class_validator_1.IsEnum)(SocialProvider, { message: 'Provider must be one of: google, apple, facebook' }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], SocialCallbackDTO.prototype, "provider", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, class_validator_1.IsString)({ message: 'Authorization code must be a string' }),
|
|
49
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'Authorization code is required' }),
|
|
50
|
+
(0, class_validator_1.MaxLength)(1000, { message: 'Authorization code must not exceed 1000 characters' }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], SocialCallbackDTO.prototype, "code", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, class_validator_1.IsString)({ message: 'State must be a string' }),
|
|
55
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'State is required' }),
|
|
56
|
+
(0, class_validator_1.MaxLength)(500, { message: 'State must not exceed 500 characters' }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], SocialCallbackDTO.prototype, "state", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, class_validator_1.IsOptional)(),
|
|
61
|
+
(0, class_validator_1.IsString)({ message: 'Error must be a string' }),
|
|
62
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Error must not exceed 100 characters' }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], SocialCallbackDTO.prototype, "error", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, class_validator_1.IsOptional)(),
|
|
67
|
+
(0, class_validator_1.IsString)({ message: 'Error description must be a string' }),
|
|
68
|
+
(0, class_validator_1.MaxLength)(500, { message: 'Error description must not exceed 500 characters' }),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], SocialCallbackDTO.prototype, "error_description", void 0);
|
|
71
|
+
class LinkSocialAccountDTO {
|
|
72
|
+
provider;
|
|
73
|
+
code;
|
|
74
|
+
state;
|
|
75
|
+
}
|
|
76
|
+
exports.LinkSocialAccountDTO = LinkSocialAccountDTO;
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, class_validator_1.IsEnum)(SocialProvider, { message: 'Provider must be one of: google, apple, facebook' }),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], LinkSocialAccountDTO.prototype, "provider", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, class_validator_1.IsString)({ message: 'Authorization code must be a string' }),
|
|
83
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'Authorization code is required' }),
|
|
84
|
+
(0, class_validator_1.MaxLength)(1000, { message: 'Authorization code must not exceed 1000 characters' }),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], LinkSocialAccountDTO.prototype, "code", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, class_validator_1.IsString)({ message: 'State must be a string' }),
|
|
89
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'State is required' }),
|
|
90
|
+
(0, class_validator_1.MaxLength)(500, { message: 'State must not exceed 500 characters' }),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], LinkSocialAccountDTO.prototype, "state", void 0);
|
|
93
|
+
class UnlinkSocialAccountDTO {
|
|
94
|
+
provider;
|
|
95
|
+
}
|
|
96
|
+
exports.UnlinkSocialAccountDTO = UnlinkSocialAccountDTO;
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, class_validator_1.IsEnum)(SocialProvider, { message: 'Provider must be one of: google, apple, facebook' }),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], UnlinkSocialAccountDTO.prototype, "provider", void 0);
|
|
101
|
+
class SocialLoginResponseDTO {
|
|
102
|
+
accessToken;
|
|
103
|
+
refreshToken;
|
|
104
|
+
accessTokenExpiresAt;
|
|
105
|
+
refreshTokenExpiresAt;
|
|
106
|
+
user;
|
|
107
|
+
}
|
|
108
|
+
exports.SocialLoginResponseDTO = SocialLoginResponseDTO;
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, class_validator_1.IsString)({ message: 'Access token must be a string' }),
|
|
111
|
+
(0, class_validator_1.MaxLength)(2048, { message: 'Access token must not exceed 2048 characters' }),
|
|
112
|
+
__metadata("design:type", String)
|
|
113
|
+
], SocialLoginResponseDTO.prototype, "accessToken", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, class_validator_1.IsString)({ message: 'Refresh token must be a string' }),
|
|
116
|
+
(0, class_validator_1.MaxLength)(2048, { message: 'Refresh token must not exceed 2048 characters' }),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], SocialLoginResponseDTO.prototype, "refreshToken", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Access token expiration must be a number' }),
|
|
121
|
+
__metadata("design:type", Number)
|
|
122
|
+
], SocialLoginResponseDTO.prototype, "accessTokenExpiresAt", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Refresh token expiration must be a number' }),
|
|
125
|
+
__metadata("design:type", Number)
|
|
126
|
+
], SocialLoginResponseDTO.prototype, "refreshTokenExpiresAt", void 0);
|
|
127
|
+
class SocialAccountsResponseDTO {
|
|
128
|
+
accounts;
|
|
129
|
+
}
|
|
130
|
+
exports.SocialAccountsResponseDTO = SocialAccountsResponseDTO;
|
|
131
|
+
//# sourceMappingURL=social-login.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AWrB,YAAY,CAAU;IAStB,oBAAoB,CAAU;IAS9B,qBAAqB,CAAU;IAc/B,IAAI,CAOF;CACH;AA7DD,wDA6DC;AAnDC;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;IACtD,IAAA,2BAAS,EAAC,IAAI,EAAE,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;;2DACxD;AAWrB;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;IACvD,IAAA,2BAAS,EAAC,IAAI,EAAE,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAAC;;4DACxD;AAStB;IADC,IAAA,0BAAQ,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,0CAA0C,EAAE,CAAC;;oEACxC;AAS9B;IADC,IAAA,0BAAQ,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,2CAA2C,EAAE,CAAC;;qEACxC;AA2CjC,MAAa,yBAAyB;IAIpC,QAAQ,CAKL;CACJ;AAVD,8DAUC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AppleOAuthClient } from './apple-oauth.client';
|
|
2
|
+
export { TokenVerifierService } from './token-verifier.service';
|
|
3
|
+
export { AppleSocialAuthService } from './apple-social-auth.service';
|
|
4
|
+
export { VerifiedAppleTokenProfile } from './verified-token-profile.interface';
|
|
5
|
+
export * from './dto/social-login.dto';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AppleSocialAuthService = exports.TokenVerifierService = exports.AppleOAuthClient = void 0;
|
|
18
|
+
var apple_oauth_client_1 = require("./apple-oauth.client");
|
|
19
|
+
Object.defineProperty(exports, "AppleOAuthClient", { enumerable: true, get: function () { return apple_oauth_client_1.AppleOAuthClient; } });
|
|
20
|
+
var token_verifier_service_1 = require("./token-verifier.service");
|
|
21
|
+
Object.defineProperty(exports, "TokenVerifierService", { enumerable: true, get: function () { return token_verifier_service_1.TokenVerifierService; } });
|
|
22
|
+
var apple_social_auth_service_1 = require("./apple-social-auth.service");
|
|
23
|
+
Object.defineProperty(exports, "AppleSocialAuthService", { enumerable: true, get: function () { return apple_social_auth_service_1.AppleSocialAuthService; } });
|
|
24
|
+
__exportStar(require("./dto/social-login.dto"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOA,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAE/B,yDAAuC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NAuthConfig, ITokenVerifierService } from '@nauth-toolkit/core';
|
|
2
|
+
import { VerifiedAppleTokenProfile } from './verified-token-profile.interface';
|
|
3
|
+
export declare class TokenVerifierService implements ITokenVerifierService {
|
|
4
|
+
private appleJWKS;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(config: NAuthConfig);
|
|
7
|
+
verifyAppleToken(idToken: string, clientId: string): Promise<VerifiedAppleTokenProfile>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=token-verifier.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-verifier.service.d.ts","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA8C,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAoB/E,qBAAa,oBAAqB,YAAW,qBAAqB;IAChE,OAAO,CAAC,SAAS,CAAwC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IA2BzB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;CA8B9F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenVerifierService = void 0;
|
|
4
|
+
const jose_1 = require("jose");
|
|
5
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
6
|
+
class TokenVerifierService {
|
|
7
|
+
appleJWKS;
|
|
8
|
+
logger;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.logger = config.logger;
|
|
11
|
+
this.appleJWKS = (0, jose_1.createRemoteJWKSet)(new URL('https://appleid.apple.com/auth/keys'));
|
|
12
|
+
}
|
|
13
|
+
async verifyAppleToken(idToken, clientId) {
|
|
14
|
+
try {
|
|
15
|
+
this.logger?.debug?.(`[TokenVerifier] Verifying Apple token`);
|
|
16
|
+
const { payload } = await (0, jose_1.jwtVerify)(idToken, this.appleJWKS, {
|
|
17
|
+
issuer: 'https://appleid.apple.com',
|
|
18
|
+
audience: clientId,
|
|
19
|
+
clockTolerance: 300,
|
|
20
|
+
});
|
|
21
|
+
const p = payload;
|
|
22
|
+
this.logger?.log?.(`[TokenVerifier] Apple token verified (secure): ${p.email}`);
|
|
23
|
+
return {
|
|
24
|
+
sub: p.sub,
|
|
25
|
+
email: p.email || '',
|
|
26
|
+
email_verified: p.email_verified === 'true' || p.email_verified === true,
|
|
27
|
+
is_private_email: p.is_private_email,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
32
|
+
this.logger?.error?.(`[TokenVerifier] Apple token verification FAILED: ${errorMessage}`);
|
|
33
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_TOKEN_INVALID, `Apple token verification failed: ${errorMessage}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.TokenVerifierService = TokenVerifierService;
|
|
38
|
+
//# sourceMappingURL=token-verifier.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-verifier.service.js","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":";;;AAAA,+BAAiE;AACjE,8CAAqH;AAqBrH,MAAa,oBAAoB;IACvB,SAAS,CAAwC;IACxC,MAA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ACH,CAAC;CACF;AA7DD,oDA6DC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verified-token-profile.interface.d.ts","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,yBAAyB;IAIxC,GAAG,EAAE,MAAM,CAAC;IAMZ,KAAK,EAAE,MAAM,CAAC;IAKd,cAAc,EAAE,OAAO,CAAC;IAKxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verified-token-profile.interface.js","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":""}
|