capacitor-auth-manager 2.4.0 → 2.4.2
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/CHANGELOG.md +180 -0
- package/CapacitorAuthManager.podspec +10 -18
- package/LICENSE +1 -1
- package/Readme.md +136 -595
- package/android/build.gradle +14 -18
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManager.java +44 -16
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManagerPlugin.java +24 -3
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/GoogleAuthProvider.java +424 -226
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/ProviderFactory.java +27 -99
- package/dist/angular.cjs.js +942 -4545
- package/dist/core.cjs.js +913 -4515
- package/dist/esm/angular/auth.guard.js +0 -1
- package/dist/esm/angular/auth.module.js +0 -1
- package/dist/esm/angular/auth.service.js +0 -1
- package/dist/esm/angular/index.d.ts +1 -0
- package/dist/esm/angular/index.js +4 -1
- package/dist/esm/capacitor-plugin.js +0 -1
- package/dist/esm/core/auth-manager.d.ts +6 -0
- package/dist/esm/core/auth-manager.js +25 -4
- package/dist/esm/core/index.js +0 -1
- package/dist/esm/core/platform.js +0 -1
- package/dist/esm/core/provider-manifests.js +0 -1
- package/dist/esm/core/provider-registry.d.ts +7 -0
- package/dist/esm/core/provider-registry.js +55 -53
- package/dist/esm/core/types.js +0 -1
- package/dist/esm/definitions.d.ts +30 -1
- package/dist/esm/definitions.js +8 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/providers/base-provider.js +0 -1
- package/dist/esm/providers/native/google-native-provider.d.ts +26 -0
- package/dist/esm/providers/native/google-native-provider.js +114 -0
- package/dist/esm/providers/oauth-provider.js +0 -1
- package/dist/esm/providers/provider-factory.d.ts +9 -0
- package/dist/esm/providers/provider-factory.js +20 -57
- package/dist/esm/providers/web/google-provider.d.ts +70 -92
- package/dist/esm/providers/web/google-provider.js +262 -205
- package/dist/esm/providers/web/index.d.ts +0 -14
- package/dist/esm/providers/web/index.js +7 -16
- package/dist/esm/react/hooks.js +0 -1
- package/dist/esm/react/index.d.ts +1 -0
- package/dist/esm/react/index.js +4 -1
- package/dist/esm/react/types.js +0 -1
- package/dist/esm/utils/auth-error.js +0 -1
- package/dist/esm/utils/error-message.js +0 -1
- package/dist/esm/utils/event-emitter.js +0 -1
- package/dist/esm/utils/logger.js +0 -1
- package/dist/esm/utils/pending-verification-store.js +0 -1
- package/dist/esm/utils/storage.js +0 -1
- package/dist/esm/vue/composables.js +0 -1
- package/dist/esm/vue/index.d.ts +1 -0
- package/dist/esm/vue/index.js +4 -1
- package/dist/esm/web.js +0 -1
- package/dist/plugin.cjs.js +435 -4664
- package/dist/plugin.js +435 -4664
- package/dist/react.cjs.js +942 -4545
- package/dist/vue.cjs.js +942 -4545
- package/ios/Plugin/CapacitorAuthManager.swift +12 -21
- package/ios/Plugin/GoogleAuthProvider.swift +213 -105
- package/ios/Plugin/Models.swift +35 -4
- package/ios/Plugin/Plugin.swift +4 -2
- package/package.json +31 -30
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/FacebookAuthProvider.java +0 -389
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/MicrosoftAuthProvider.java +0 -455
- package/dist/angular.cjs.js.map +0 -1
- package/dist/core.cjs.js.map +0 -1
- package/dist/esm/angular/auth.guard.js.map +0 -1
- package/dist/esm/angular/auth.module.js.map +0 -1
- package/dist/esm/angular/auth.service.js.map +0 -1
- package/dist/esm/angular/index.js.map +0 -1
- package/dist/esm/capacitor-plugin.js.map +0 -1
- package/dist/esm/core/auth-manager.js.map +0 -1
- package/dist/esm/core/index.js.map +0 -1
- package/dist/esm/core/platform.js.map +0 -1
- package/dist/esm/core/provider-manifests.js.map +0 -1
- package/dist/esm/core/provider-registry.js.map +0 -1
- package/dist/esm/core/types.js.map +0 -1
- package/dist/esm/definitions.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/providers/base-provider.js.map +0 -1
- package/dist/esm/providers/oauth-provider.js.map +0 -1
- package/dist/esm/providers/provider-factory.js.map +0 -1
- package/dist/esm/providers/web/apple-provider.d.ts +0 -61
- package/dist/esm/providers/web/apple-provider.js +0 -293
- package/dist/esm/providers/web/apple-provider.js.map +0 -1
- package/dist/esm/providers/web/biometric-provider.d.ts +0 -60
- package/dist/esm/providers/web/biometric-provider.js +0 -374
- package/dist/esm/providers/web/biometric-provider.js.map +0 -1
- package/dist/esm/providers/web/email-code-provider.d.ts +0 -46
- package/dist/esm/providers/web/email-code-provider.js +0 -294
- package/dist/esm/providers/web/email-code-provider.js.map +0 -1
- package/dist/esm/providers/web/email-password-provider.d.ts +0 -52
- package/dist/esm/providers/web/email-password-provider.js +0 -430
- package/dist/esm/providers/web/email-password-provider.js.map +0 -1
- package/dist/esm/providers/web/facebook-provider.d.ts +0 -80
- package/dist/esm/providers/web/facebook-provider.js +0 -249
- package/dist/esm/providers/web/facebook-provider.js.map +0 -1
- package/dist/esm/providers/web/firebase-provider.d.ts +0 -22
- package/dist/esm/providers/web/firebase-provider.js +0 -338
- package/dist/esm/providers/web/firebase-provider.js.map +0 -1
- package/dist/esm/providers/web/github-provider.d.ts +0 -34
- package/dist/esm/providers/web/github-provider.js +0 -325
- package/dist/esm/providers/web/github-provider.js.map +0 -1
- package/dist/esm/providers/web/google-provider.js.map +0 -1
- package/dist/esm/providers/web/index.js.map +0 -1
- package/dist/esm/providers/web/linkedin-provider.d.ts +0 -37
- package/dist/esm/providers/web/linkedin-provider.js +0 -178
- package/dist/esm/providers/web/linkedin-provider.js.map +0 -1
- package/dist/esm/providers/web/magic-link-provider.d.ts +0 -44
- package/dist/esm/providers/web/magic-link-provider.js +0 -311
- package/dist/esm/providers/web/magic-link-provider.js.map +0 -1
- package/dist/esm/providers/web/microsoft-provider.d.ts +0 -23
- package/dist/esm/providers/web/microsoft-provider.js +0 -236
- package/dist/esm/providers/web/microsoft-provider.js.map +0 -1
- package/dist/esm/providers/web/phone-password-provider.d.ts +0 -63
- package/dist/esm/providers/web/phone-password-provider.js +0 -442
- package/dist/esm/providers/web/phone-password-provider.js.map +0 -1
- package/dist/esm/providers/web/slack-provider.d.ts +0 -39
- package/dist/esm/providers/web/slack-provider.js +0 -175
- package/dist/esm/providers/web/slack-provider.js.map +0 -1
- package/dist/esm/providers/web/sms-provider.d.ts +0 -46
- package/dist/esm/providers/web/sms-provider.js +0 -306
- package/dist/esm/providers/web/sms-provider.js.map +0 -1
- package/dist/esm/providers/web/username-password-provider.d.ts +0 -59
- package/dist/esm/providers/web/username-password-provider.js +0 -435
- package/dist/esm/providers/web/username-password-provider.js.map +0 -1
- package/dist/esm/react/hooks.js.map +0 -1
- package/dist/esm/react/index.js.map +0 -1
- package/dist/esm/react/types.js.map +0 -1
- package/dist/esm/utils/auth-error.js.map +0 -1
- package/dist/esm/utils/error-message.js.map +0 -1
- package/dist/esm/utils/event-emitter.js.map +0 -1
- package/dist/esm/utils/logger.js.map +0 -1
- package/dist/esm/utils/pending-verification-store.js.map +0 -1
- package/dist/esm/utils/storage.js.map +0 -1
- package/dist/esm/vue/composables.js.map +0 -1
- package/dist/esm/vue/index.js.map +0 -1
- package/dist/esm/web.js.map +0 -1
- package/dist/plugin.cjs.js.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/react.cjs.js.map +0 -1
- package/dist/vue.cjs.js.map +0 -1
- package/ios/Plugin/AppleAuthProvider.swift +0 -288
- package/ios/Plugin/FacebookAuthProvider.swift +0 -297
- package/ios/Plugin/GitHubAuthProvider.swift +0 -54
- package/ios/Plugin/LinkedInAuthProvider.swift +0 -63
- package/ios/Plugin/MicrosoftAuthProvider.swift +0 -315
- package/ios/Plugin/OAuthWebProvider.swift +0 -415
- package/ios/Plugin/SlackAuthProvider.swift +0 -108
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { AuthProvider, AuthErrorCode, } from '../../definitions';
|
|
2
|
-
import { OAuthProvider, } from '../oauth-provider';
|
|
3
|
-
import { AuthError } from '../../utils/auth-error';
|
|
4
|
-
export class SlackProvider extends OAuthProvider {
|
|
5
|
-
constructor(config) {
|
|
6
|
-
super(config);
|
|
7
|
-
this.provider = AuthProvider.SLACK;
|
|
8
|
-
this.clientId = '';
|
|
9
|
-
this.redirectUri = '';
|
|
10
|
-
this.scopes = [];
|
|
11
|
-
this.authWindow = null;
|
|
12
|
-
const options = config.options;
|
|
13
|
-
this.clientId = options.clientId || '';
|
|
14
|
-
this.redirectUri = options.redirectUri || '';
|
|
15
|
-
this.scopes = options.scopes || ['openid', 'profile', 'email'];
|
|
16
|
-
this.teamId = options.teamId;
|
|
17
|
-
}
|
|
18
|
-
async initialize() {
|
|
19
|
-
this.isInitialized = true;
|
|
20
|
-
}
|
|
21
|
-
async signIn(options) {
|
|
22
|
-
return this.performOAuthFlow(options);
|
|
23
|
-
}
|
|
24
|
-
// Uses base OAuthProvider.refreshToken() which handles refresh tokens if available.
|
|
25
|
-
// Note: Slack's OAuth 2.0 for public web apps typically doesn't issue refresh tokens.
|
|
26
|
-
// If no refresh token is available, the base class will throw "No refresh token available".
|
|
27
|
-
getOAuthConfig() {
|
|
28
|
-
return {
|
|
29
|
-
clientId: this.clientId,
|
|
30
|
-
redirectUri: this.redirectUri,
|
|
31
|
-
authorizationEndpoint: 'https://slack.com/oauth/v2/authorize',
|
|
32
|
-
tokenEndpoint: 'https://slack.com/api/oauth.v2.access',
|
|
33
|
-
scopes: this.scopes,
|
|
34
|
-
additionalParams: this.teamId ? { team: this.teamId } : {},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async parseUserFromTokenResponse(response) {
|
|
38
|
-
var _a;
|
|
39
|
-
const accessToken = response.access_token;
|
|
40
|
-
if (!accessToken) {
|
|
41
|
-
throw new AuthError(AuthErrorCode.INVALID_CREDENTIALS, 'Slack token response did not include an access token; cannot fetch the user profile.', this.provider);
|
|
42
|
-
}
|
|
43
|
-
// Fetch the real profile via Slack's OpenID Connect userInfo endpoint.
|
|
44
|
-
// https://api.slack.com/methods/openid.connect.userInfo
|
|
45
|
-
let res;
|
|
46
|
-
try {
|
|
47
|
-
res = await fetch('https://slack.com/api/openid.connect.userInfo', {
|
|
48
|
-
method: 'GET',
|
|
49
|
-
headers: {
|
|
50
|
-
Authorization: `Bearer ${accessToken}`,
|
|
51
|
-
Accept: 'application/json',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
throw new AuthError(AuthErrorCode.NETWORK_ERROR, 'Failed to reach Slack userInfo endpoint', this.provider, error);
|
|
57
|
-
}
|
|
58
|
-
// Slack returns HTTP 200 with `{ ok: false, error }` on API-level failures.
|
|
59
|
-
const data = (await res.json().catch(() => null));
|
|
60
|
-
if (!res.ok || !data || data.ok === false || !data.sub) {
|
|
61
|
-
throw new AuthError(AuthErrorCode.INVALID_CREDENTIALS, `Failed to fetch Slack user profile${(data === null || data === void 0 ? void 0 : data.error) ? `: ${data.error}` : ''}`, this.provider);
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
id: data.sub,
|
|
65
|
-
sub: data.sub,
|
|
66
|
-
email: data.email,
|
|
67
|
-
email_verified: (_a = data.email_verified) !== null && _a !== void 0 ? _a : false,
|
|
68
|
-
name: data.name,
|
|
69
|
-
picture: data.picture,
|
|
70
|
-
isNewUser: false,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async openAuthorizationUrl(url) {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
// Open OAuth window
|
|
76
|
-
this.authWindow = window.open(url, 'SlackAuth', 'width=500,height=600');
|
|
77
|
-
if (!this.authWindow) {
|
|
78
|
-
reject(new Error('Failed to open authentication window'));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Listen for OAuth callback
|
|
82
|
-
const checkInterval = setInterval(() => {
|
|
83
|
-
var _a, _b;
|
|
84
|
-
try {
|
|
85
|
-
if ((_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.closed) {
|
|
86
|
-
clearInterval(checkInterval);
|
|
87
|
-
reject(new Error('Authentication cancelled'));
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if ((_b = this.authWindow) === null || _b === void 0 ? void 0 : _b.location.href.startsWith(this.redirectUri)) {
|
|
91
|
-
clearInterval(checkInterval);
|
|
92
|
-
const url = new URL(this.authWindow.location.href);
|
|
93
|
-
const code = url.searchParams.get('code');
|
|
94
|
-
const state = url.searchParams.get('state');
|
|
95
|
-
const error = url.searchParams.get('error');
|
|
96
|
-
this.authWindow.close();
|
|
97
|
-
this.authWindow = null;
|
|
98
|
-
resolve({
|
|
99
|
-
code: code || undefined,
|
|
100
|
-
state: state || undefined,
|
|
101
|
-
error: error || undefined,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (_c) {
|
|
106
|
-
// Cross-origin error, ignore
|
|
107
|
-
}
|
|
108
|
-
}, 1000);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
async isSupported() {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
async linkAccount(_options) {
|
|
115
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for Slack provider');
|
|
116
|
-
}
|
|
117
|
-
async unlinkAccount(_options) {
|
|
118
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for Slack provider');
|
|
119
|
-
}
|
|
120
|
-
async revokeAccess(token) {
|
|
121
|
-
await super.revokeAccess(token);
|
|
122
|
-
}
|
|
123
|
-
async signOut(_options) {
|
|
124
|
-
await this.clearStoredData();
|
|
125
|
-
await this.setCurrentUser(null);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Provider manifest for dynamic loading
|
|
129
|
-
export const SlackProviderManifest = {
|
|
130
|
-
name: 'slack',
|
|
131
|
-
displayName: 'Slack',
|
|
132
|
-
iconUrl: 'https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/slack.svg',
|
|
133
|
-
description: 'Sign in with Slack workspace',
|
|
134
|
-
setupInstructions: `
|
|
135
|
-
To use Slack authentication:
|
|
136
|
-
|
|
137
|
-
1. Create a Slack App:
|
|
138
|
-
- Go to https://api.slack.com/apps
|
|
139
|
-
- Click "Create New App" > "From scratch"
|
|
140
|
-
- Name your app and select workspace
|
|
141
|
-
|
|
142
|
-
2. Configure OAuth & Permissions:
|
|
143
|
-
- Add redirect URL: https://your-app.com/auth/slack/callback
|
|
144
|
-
- Add required scopes:
|
|
145
|
-
- openid
|
|
146
|
-
- profile
|
|
147
|
-
- email
|
|
148
|
-
|
|
149
|
-
3. Get your credentials:
|
|
150
|
-
- Go to "Basic Information"
|
|
151
|
-
- Copy Client ID and Client Secret
|
|
152
|
-
|
|
153
|
-
4. Configure the provider:
|
|
154
|
-
\`\`\`javascript
|
|
155
|
-
auth.configure({
|
|
156
|
-
providers: {
|
|
157
|
-
slack: {
|
|
158
|
-
clientId: 'YOUR_CLIENT_ID',
|
|
159
|
-
redirectUri: 'https://your-app.com/auth/slack/callback',
|
|
160
|
-
scopes: ['openid', 'profile', 'email'],
|
|
161
|
-
teamId: 'OPTIONAL_TEAM_ID' // Restrict to specific workspace
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
\`\`\`
|
|
166
|
-
|
|
167
|
-
5. Use the provider:
|
|
168
|
-
\`\`\`javascript
|
|
169
|
-
await auth.signIn('slack');
|
|
170
|
-
\`\`\`
|
|
171
|
-
|
|
172
|
-
Note: Slack OAuth requires a backend service to exchange the authorization code for access tokens.
|
|
173
|
-
`,
|
|
174
|
-
};
|
|
175
|
-
//# sourceMappingURL=slack-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slack-provider.js","sourceRoot":"","sources":["../../../../src/providers/web/slack-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ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AAW,EAAE,OAAO;IACpB,OAAO,EAAE,8DAA8D;IACvE,WAAW,EAAE,8BAA8B;IAC3C,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCpB;CACA,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { AuthResult, AuthUser, SignInOptions, RefreshTokenOptions } from '../../definitions';
|
|
2
|
-
import { BaseAuthProvider, BaseProviderConfig } from '../base-provider';
|
|
3
|
-
export interface SMSConfig {
|
|
4
|
-
sendCodeUrl: string;
|
|
5
|
-
verifyCodeUrl: string;
|
|
6
|
-
clientId?: string;
|
|
7
|
-
countryCode?: string;
|
|
8
|
-
codeLength?: number;
|
|
9
|
-
resendDelay?: number;
|
|
10
|
-
}
|
|
11
|
-
interface SMSOptions extends SignInOptions {
|
|
12
|
-
phoneNumber: string;
|
|
13
|
-
code?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare class SMSProvider extends BaseAuthProvider {
|
|
16
|
-
get name(): string;
|
|
17
|
-
private config;
|
|
18
|
-
private pendingVerifications;
|
|
19
|
-
private readonly MAX_ATTEMPTS;
|
|
20
|
-
constructor(input: BaseProviderConfig | SMSConfig);
|
|
21
|
-
signIn(options?: SMSOptions): Promise<AuthResult>;
|
|
22
|
-
private sendCode;
|
|
23
|
-
private verifyCode;
|
|
24
|
-
signOut(): Promise<void>;
|
|
25
|
-
getCurrentUser(): Promise<AuthUser | null>;
|
|
26
|
-
refreshToken(_options?: RefreshTokenOptions): Promise<AuthResult>;
|
|
27
|
-
private formatPhoneNumber;
|
|
28
|
-
private maskPhoneNumber;
|
|
29
|
-
private generateUid;
|
|
30
|
-
resendCode(phoneNumber: string): Promise<AuthResult>;
|
|
31
|
-
canResendCode(phoneNumber: string): {
|
|
32
|
-
canResend: boolean;
|
|
33
|
-
waitTime?: number;
|
|
34
|
-
};
|
|
35
|
-
initialize(): Promise<void>;
|
|
36
|
-
isSupported(): Promise<boolean>;
|
|
37
|
-
revokeAccess(_token?: string): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
export declare const SMSProviderManifest: {
|
|
40
|
-
name: string;
|
|
41
|
-
displayName: string;
|
|
42
|
-
iconUrl: string;
|
|
43
|
-
description: string;
|
|
44
|
-
setupInstructions: string;
|
|
45
|
-
};
|
|
46
|
-
export {};
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { AuthErrorCode, AuthProvider, } from '../../definitions';
|
|
2
|
-
import { AuthError } from '../../utils/auth-error';
|
|
3
|
-
import { BaseAuthProvider, resolveProviderConfig, } from '../base-provider';
|
|
4
|
-
import { PendingVerificationStore } from '../../utils/pending-verification-store';
|
|
5
|
-
export class SMSProvider extends BaseAuthProvider {
|
|
6
|
-
get name() {
|
|
7
|
-
return 'sms';
|
|
8
|
-
}
|
|
9
|
-
constructor(input) {
|
|
10
|
-
super(resolveProviderConfig(AuthProvider.SMS, input));
|
|
11
|
-
// Pending verifications are persisted (SSR-guarded localStorage) so they survive a reload /
|
|
12
|
-
// page change between sending and verifying the code. Only non-secret metadata is stored —
|
|
13
|
-
// never the SMS code itself (see PendingVerificationStore + F-11).
|
|
14
|
-
this.pendingVerifications = new PendingVerificationStore('sms');
|
|
15
|
-
this.MAX_ATTEMPTS = 3;
|
|
16
|
-
this.config = Object.assign({ countryCode: '+1', codeLength: 6, resendDelay: 60000 }, this.options);
|
|
17
|
-
}
|
|
18
|
-
async signIn(options) {
|
|
19
|
-
if (!(options === null || options === void 0 ? void 0 : options.phoneNumber)) {
|
|
20
|
-
throw new AuthError(AuthErrorCode.PHONE_REQUIRED, 'Phone number is required for SMS authentication');
|
|
21
|
-
}
|
|
22
|
-
// If code is provided, verify it
|
|
23
|
-
if (options.code) {
|
|
24
|
-
return this.verifyCode(options.phoneNumber, options.code);
|
|
25
|
-
}
|
|
26
|
-
// Otherwise, send code
|
|
27
|
-
return this.sendCode(options.phoneNumber);
|
|
28
|
-
}
|
|
29
|
-
async sendCode(phoneNumber) {
|
|
30
|
-
try {
|
|
31
|
-
// Format phone number
|
|
32
|
-
const formattedPhone = this.formatPhoneNumber(phoneNumber);
|
|
33
|
-
// Check if we can resend
|
|
34
|
-
const existing = this.pendingVerifications.get(formattedPhone);
|
|
35
|
-
if (existing && existing.lastResent) {
|
|
36
|
-
const timeSinceLastResend = Date.now() - existing.lastResent;
|
|
37
|
-
if (timeSinceLastResend < this.config.resendDelay) {
|
|
38
|
-
const waitTime = Math.ceil((this.config.resendDelay - timeSinceLastResend) / 1000);
|
|
39
|
-
throw new AuthError(AuthErrorCode.RESEND_DELAY, `Please wait ${waitTime} seconds before requesting a new code`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Send SMS code via backend
|
|
43
|
-
const response = await fetch(this.config.sendCodeUrl, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
},
|
|
48
|
-
body: JSON.stringify({
|
|
49
|
-
phoneNumber: formattedPhone,
|
|
50
|
-
clientId: this.config.clientId,
|
|
51
|
-
codeLength: this.config.codeLength,
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
if (!response.ok) {
|
|
55
|
-
const error = await response.json().catch(() => ({}));
|
|
56
|
-
throw new AuthError(AuthErrorCode.SEND_CODE_FAILED, error.message || 'Failed to send SMS code');
|
|
57
|
-
}
|
|
58
|
-
const data = await response.json();
|
|
59
|
-
// Store pending verification (persisted; metadata only, never the code).
|
|
60
|
-
this.pendingVerifications.set(formattedPhone, {
|
|
61
|
-
identifier: formattedPhone,
|
|
62
|
-
sessionId: data.sessionId,
|
|
63
|
-
expires: Date.now() + 10 * 60 * 1000, // 10 minutes
|
|
64
|
-
attempts: 0,
|
|
65
|
-
lastResent: Date.now(),
|
|
66
|
-
});
|
|
67
|
-
// Return partial auth result for pending state
|
|
68
|
-
// SMS requires two-step process, so we return a temporary user
|
|
69
|
-
const tempUser = {
|
|
70
|
-
uid: `sms-pending:${data.sessionId}`,
|
|
71
|
-
email: null,
|
|
72
|
-
displayName: this.maskPhoneNumber(formattedPhone),
|
|
73
|
-
photoURL: null,
|
|
74
|
-
phoneNumber: formattedPhone,
|
|
75
|
-
emailVerified: false,
|
|
76
|
-
providerData: [],
|
|
77
|
-
metadata: {
|
|
78
|
-
creationTime: new Date().toISOString(),
|
|
79
|
-
lastSignInTime: new Date().toISOString(),
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
return {
|
|
83
|
-
user: tempUser,
|
|
84
|
-
credential: {
|
|
85
|
-
providerId: this.name,
|
|
86
|
-
signInMethod: 'sms',
|
|
87
|
-
accessToken: data.sessionId,
|
|
88
|
-
},
|
|
89
|
-
additionalUserInfo: {
|
|
90
|
-
isNewUser: false,
|
|
91
|
-
providerId: this.name,
|
|
92
|
-
profile: {
|
|
93
|
-
phoneNumber: formattedPhone,
|
|
94
|
-
sessionId: data.sessionId,
|
|
95
|
-
message: `SMS code sent to ${this.maskPhoneNumber(formattedPhone)}`,
|
|
96
|
-
pending: true,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
if (error instanceof AuthError)
|
|
103
|
-
throw error;
|
|
104
|
-
throw new AuthError(AuthErrorCode.SEND_CODE_FAILED, error.message || 'Failed to send SMS code');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async verifyCode(phoneNumber, code) {
|
|
108
|
-
const formattedPhone = this.formatPhoneNumber(phoneNumber);
|
|
109
|
-
const pending = this.pendingVerifications.get(formattedPhone);
|
|
110
|
-
if (!pending) {
|
|
111
|
-
throw new AuthError(AuthErrorCode.NO_PENDING_VERIFICATION, 'No pending SMS verification found');
|
|
112
|
-
}
|
|
113
|
-
if (Date.now() > pending.expires) {
|
|
114
|
-
this.pendingVerifications.delete(formattedPhone);
|
|
115
|
-
throw new AuthError(AuthErrorCode.CODE_EXPIRED, 'SMS code has expired');
|
|
116
|
-
}
|
|
117
|
-
if (pending.attempts >= this.MAX_ATTEMPTS) {
|
|
118
|
-
this.pendingVerifications.delete(formattedPhone);
|
|
119
|
-
throw new AuthError(AuthErrorCode.TOO_MANY_ATTEMPTS, 'Too many failed attempts');
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
// Increment attempts and persist the bump (so the count survives a reload mid-flow).
|
|
123
|
-
pending.attempts++;
|
|
124
|
-
this.pendingVerifications.set(formattedPhone, pending);
|
|
125
|
-
// Verify code with backend
|
|
126
|
-
const response = await fetch(this.config.verifyCodeUrl, {
|
|
127
|
-
method: 'POST',
|
|
128
|
-
headers: {
|
|
129
|
-
'Content-Type': 'application/json',
|
|
130
|
-
},
|
|
131
|
-
body: JSON.stringify({
|
|
132
|
-
phoneNumber: formattedPhone,
|
|
133
|
-
code,
|
|
134
|
-
sessionId: pending.sessionId,
|
|
135
|
-
clientId: this.config.clientId,
|
|
136
|
-
}),
|
|
137
|
-
});
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
const error = await response.json().catch(() => ({}));
|
|
140
|
-
if (response.status === 401) {
|
|
141
|
-
throw new AuthError(AuthErrorCode.INVALID_CODE, 'Invalid SMS code');
|
|
142
|
-
}
|
|
143
|
-
throw new AuthError(AuthErrorCode.VERIFICATION_FAILED, error.message || 'Failed to verify SMS code');
|
|
144
|
-
}
|
|
145
|
-
const data = await response.json();
|
|
146
|
-
// Create user from verified data
|
|
147
|
-
const user = {
|
|
148
|
-
uid: data.uid || this.generateUid(formattedPhone),
|
|
149
|
-
email: data.email || null,
|
|
150
|
-
displayName: data.displayName || formattedPhone,
|
|
151
|
-
photoURL: data.photoURL || null,
|
|
152
|
-
phoneNumber: formattedPhone,
|
|
153
|
-
emailVerified: false,
|
|
154
|
-
providerData: [
|
|
155
|
-
{
|
|
156
|
-
providerId: this.name,
|
|
157
|
-
uid: data.uid || phoneNumber,
|
|
158
|
-
displayName: phoneNumber,
|
|
159
|
-
email: null,
|
|
160
|
-
phoneNumber: phoneNumber,
|
|
161
|
-
photoURL: null,
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
metadata: {
|
|
165
|
-
creationTime: data.createdAt || new Date().toISOString(),
|
|
166
|
-
lastSignInTime: new Date().toISOString(),
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
// Clean up pending verification
|
|
170
|
-
this.pendingVerifications.delete(formattedPhone);
|
|
171
|
-
return {
|
|
172
|
-
user,
|
|
173
|
-
credential: {
|
|
174
|
-
providerId: this.name,
|
|
175
|
-
signInMethod: 'sms',
|
|
176
|
-
accessToken: data.accessToken,
|
|
177
|
-
refreshToken: data.refreshToken,
|
|
178
|
-
expiresAt: data.expiresAt,
|
|
179
|
-
},
|
|
180
|
-
additionalUserInfo: {
|
|
181
|
-
isNewUser: data.isNewUser || false,
|
|
182
|
-
providerId: this.name,
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
if (error instanceof AuthError)
|
|
188
|
-
throw error;
|
|
189
|
-
throw new AuthError(AuthErrorCode.VERIFICATION_FAILED, error.message || 'Failed to verify SMS code');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
async signOut() {
|
|
193
|
-
// Clear any pending verifications
|
|
194
|
-
this.pendingVerifications.clear();
|
|
195
|
-
}
|
|
196
|
-
async getCurrentUser() {
|
|
197
|
-
// SMS auth doesn't persist sessions by default
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
async refreshToken(_options) {
|
|
201
|
-
// SMS code authentication is single-use and has no refresh flow; the user must request
|
|
202
|
-
// a new verification code rather than refresh a token.
|
|
203
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'SMS authentication does not support token refresh; request a new code instead.');
|
|
204
|
-
}
|
|
205
|
-
formatPhoneNumber(phoneNumber) {
|
|
206
|
-
// Remove all non-numeric characters
|
|
207
|
-
let cleaned = phoneNumber.replace(/\D/g, '');
|
|
208
|
-
// Add country code if not present
|
|
209
|
-
if (!phoneNumber.startsWith('+')) {
|
|
210
|
-
if (cleaned.length === 10) {
|
|
211
|
-
// Assume US number without country code
|
|
212
|
-
cleaned = '1' + cleaned;
|
|
213
|
-
}
|
|
214
|
-
cleaned = this.config.countryCode.replace('+', '') + cleaned;
|
|
215
|
-
}
|
|
216
|
-
return '+' + cleaned;
|
|
217
|
-
}
|
|
218
|
-
maskPhoneNumber(phoneNumber) {
|
|
219
|
-
// Show only last 4 digits
|
|
220
|
-
const digits = phoneNumber.replace(/\D/g, '');
|
|
221
|
-
const lastFour = digits.slice(-4);
|
|
222
|
-
return `***-***-${lastFour}`;
|
|
223
|
-
}
|
|
224
|
-
generateUid(phoneNumber) {
|
|
225
|
-
return `sms:${phoneNumber.replace(/\D/g, '')}`;
|
|
226
|
-
}
|
|
227
|
-
// Public method to resend code
|
|
228
|
-
async resendCode(phoneNumber) {
|
|
229
|
-
return this.sendCode(phoneNumber);
|
|
230
|
-
}
|
|
231
|
-
// Public method to check if can resend
|
|
232
|
-
canResendCode(phoneNumber) {
|
|
233
|
-
const formattedPhone = this.formatPhoneNumber(phoneNumber);
|
|
234
|
-
const pending = this.pendingVerifications.get(formattedPhone);
|
|
235
|
-
if (!pending || !pending.lastResent) {
|
|
236
|
-
return { canResend: true };
|
|
237
|
-
}
|
|
238
|
-
const timeSinceLastResend = Date.now() - pending.lastResent;
|
|
239
|
-
if (timeSinceLastResend < this.config.resendDelay) {
|
|
240
|
-
return {
|
|
241
|
-
canResend: false,
|
|
242
|
-
waitTime: Math.ceil((this.config.resendDelay - timeSinceLastResend) / 1000),
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
return { canResend: true };
|
|
246
|
-
}
|
|
247
|
-
async initialize() {
|
|
248
|
-
// SMS provider doesn't require initialization
|
|
249
|
-
}
|
|
250
|
-
async isSupported() {
|
|
251
|
-
// SMS auth is supported if we have the required config
|
|
252
|
-
return !!(this.config.sendCodeUrl && this.config.verifyCodeUrl);
|
|
253
|
-
}
|
|
254
|
-
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
255
|
-
async revokeAccess(_token) {
|
|
256
|
-
// SMS auth doesn't have persistent access to revoke; clear any pending verification.
|
|
257
|
-
this.pendingVerifications.clear();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
// Provider manifest for dynamic loading
|
|
261
|
-
export const SMSProviderManifest = {
|
|
262
|
-
name: 'sms',
|
|
263
|
-
displayName: 'SMS Authentication',
|
|
264
|
-
iconUrl: 'https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/sms.svg',
|
|
265
|
-
description: 'Phone number authentication via SMS',
|
|
266
|
-
setupInstructions: `
|
|
267
|
-
To use SMS authentication:
|
|
268
|
-
|
|
269
|
-
1. Set up backend endpoints:
|
|
270
|
-
- Send code endpoint: POST request to send SMS
|
|
271
|
-
- Verify code endpoint: POST request to verify SMS code
|
|
272
|
-
|
|
273
|
-
2. Configure the provider:
|
|
274
|
-
\`\`\`javascript
|
|
275
|
-
auth.configure({
|
|
276
|
-
providers: {
|
|
277
|
-
sms: {
|
|
278
|
-
sendCodeUrl: 'https://your-api.com/sms/send',
|
|
279
|
-
verifyCodeUrl: 'https://your-api.com/sms/verify',
|
|
280
|
-
countryCode: '+1', // Default country code
|
|
281
|
-
codeLength: 6, // SMS code length
|
|
282
|
-
resendDelay: 60000 // Minimum time between resends (ms)
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
\`\`\`
|
|
287
|
-
|
|
288
|
-
3. Send SMS code:
|
|
289
|
-
\`\`\`javascript
|
|
290
|
-
const result = await auth.signIn('sms', { phoneNumber: '+1234567890' });
|
|
291
|
-
// Returns pending state with sessionId
|
|
292
|
-
\`\`\`
|
|
293
|
-
|
|
294
|
-
4. Verify SMS code:
|
|
295
|
-
\`\`\`javascript
|
|
296
|
-
const result = await auth.signIn('sms', {
|
|
297
|
-
phoneNumber: '+1234567890',
|
|
298
|
-
code: '123456'
|
|
299
|
-
});
|
|
300
|
-
\`\`\`
|
|
301
|
-
|
|
302
|
-
Note: This provider requires a backend service to send SMS messages.
|
|
303
|
-
You'll need to integrate with an SMS service like Twilio, AWS SNS, etc.
|
|
304
|
-
`,
|
|
305
|
-
};
|
|
306
|
-
//# sourceMappingURL=sms-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sms-provider.js","sourceRoot":"","sources":["../../../../src/providers/web/sms-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,gBAAgB,EAEhB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAqBlF,MAAM,OAAO,WAAY,SAAQ,gBAAgB;IAC/C,IAAI,IAAI;QACN,OAAO,KAAK,CAAC;IACf,CAAC;IAQD,YAAY,KAAqC;QAC/C,KAAK,CAAC,qBAAqB,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAPxD,4FAA4F;QAC5F,2FAA2F;QAC3F,mEAAmE;QAC3D,yBAAoB,GAAG,IAAI,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAClD,iBAAY,GAAG,CAAC,CAAC;QAIhC,IAAI,CAAC,MAAM,mBACT,WAAW,EAAE,IAAI,EACjB,UAAU,EAAE,CAAC,EACb,WAAW,EAAE,KAAK,IACd,IAAI,CAAC,OAAqB,CAC/B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAoB;QAC/B,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,cAAc,EAC5B,iDAAiD,CAClD,CAA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AAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,4DAA4D;IACrE,WAAW,EAAE,qCAAqC;IAClD,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCpB;CACA,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { AuthResult, AuthUser, SignInOptions, SignUpOptions, RefreshTokenOptions } from '../../definitions';
|
|
2
|
-
import { BaseAuthProvider, BaseProviderConfig } from '../base-provider';
|
|
3
|
-
export interface UsernamePasswordConfig {
|
|
4
|
-
apiUrl: string;
|
|
5
|
-
clientId?: string;
|
|
6
|
-
usernameRequirements?: {
|
|
7
|
-
minLength?: number;
|
|
8
|
-
maxLength?: number;
|
|
9
|
-
allowedCharacters?: RegExp;
|
|
10
|
-
reservedUsernames?: string[];
|
|
11
|
-
};
|
|
12
|
-
passwordRequirements?: {
|
|
13
|
-
minLength?: number;
|
|
14
|
-
requireUppercase?: boolean;
|
|
15
|
-
requireLowercase?: boolean;
|
|
16
|
-
requireNumbers?: boolean;
|
|
17
|
-
requireSpecialChars?: boolean;
|
|
18
|
-
};
|
|
19
|
-
allowSignUp?: boolean;
|
|
20
|
-
}
|
|
21
|
-
interface UsernamePasswordSignInOptions extends SignInOptions {
|
|
22
|
-
username: string;
|
|
23
|
-
password: string;
|
|
24
|
-
}
|
|
25
|
-
interface UsernamePasswordSignUpOptions extends SignUpOptions {
|
|
26
|
-
username: string;
|
|
27
|
-
password: string;
|
|
28
|
-
email?: string;
|
|
29
|
-
displayName?: string;
|
|
30
|
-
photoURL?: string;
|
|
31
|
-
}
|
|
32
|
-
export declare class UsernamePasswordProvider extends BaseAuthProvider {
|
|
33
|
-
get name(): string;
|
|
34
|
-
private config;
|
|
35
|
-
private authToken;
|
|
36
|
-
private refreshTokenValue;
|
|
37
|
-
constructor(input: BaseProviderConfig | UsernamePasswordConfig);
|
|
38
|
-
signIn(options?: UsernamePasswordSignInOptions): Promise<AuthResult>;
|
|
39
|
-
signUp(options?: UsernamePasswordSignUpOptions): Promise<AuthResult>;
|
|
40
|
-
signOut(): Promise<void>;
|
|
41
|
-
getCurrentUser(): Promise<AuthUser | null>;
|
|
42
|
-
refreshToken(_options?: RefreshTokenOptions): Promise<AuthResult>;
|
|
43
|
-
updatePassword(currentPassword: string, newPassword: string): Promise<void>;
|
|
44
|
-
checkUsernameAvailability(username: string): Promise<boolean>;
|
|
45
|
-
private isValidEmail;
|
|
46
|
-
private validateUsername;
|
|
47
|
-
private validatePassword;
|
|
48
|
-
initialize(): Promise<void>;
|
|
49
|
-
isSupported(): Promise<boolean>;
|
|
50
|
-
revokeAccess(_token?: string): Promise<void>;
|
|
51
|
-
}
|
|
52
|
-
export declare const UsernamePasswordProviderManifest: {
|
|
53
|
-
name: string;
|
|
54
|
-
displayName: string;
|
|
55
|
-
iconUrl: string;
|
|
56
|
-
description: string;
|
|
57
|
-
setupInstructions: string;
|
|
58
|
-
};
|
|
59
|
-
export {};
|