capacitor-auth-manager 2.2.0 → 2.3.0
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/angular.cjs.js +99 -80
- package/dist/angular.cjs.js.map +1 -1
- package/dist/core.cjs.js +99 -80
- package/dist/core.cjs.js.map +1 -1
- package/dist/esm/providers/base-provider.d.ts +11 -0
- package/dist/esm/providers/base-provider.js +30 -3
- package/dist/esm/providers/base-provider.js.map +1 -1
- package/dist/esm/providers/web/biometric-provider.d.ts +6 -7
- package/dist/esm/providers/web/biometric-provider.js +10 -7
- package/dist/esm/providers/web/biometric-provider.js.map +1 -1
- package/dist/esm/providers/web/email-code-provider.d.ts +5 -7
- package/dist/esm/providers/web/email-code-provider.js +10 -11
- package/dist/esm/providers/web/email-code-provider.js.map +1 -1
- package/dist/esm/providers/web/email-password-provider.d.ts +4 -7
- package/dist/esm/providers/web/email-password-provider.js +12 -13
- package/dist/esm/providers/web/email-password-provider.js.map +1 -1
- package/dist/esm/providers/web/magic-link-provider.d.ts +5 -7
- package/dist/esm/providers/web/magic-link-provider.js +12 -13
- package/dist/esm/providers/web/magic-link-provider.js.map +1 -1
- package/dist/esm/providers/web/phone-password-provider.d.ts +5 -8
- package/dist/esm/providers/web/phone-password-provider.js +18 -16
- package/dist/esm/providers/web/phone-password-provider.js.map +1 -1
- package/dist/esm/providers/web/sms-provider.d.ts +5 -7
- package/dist/esm/providers/web/sms-provider.js +11 -13
- package/dist/esm/providers/web/sms-provider.js.map +1 -1
- package/dist/esm/providers/web/username-password-provider.d.ts +4 -7
- package/dist/esm/providers/web/username-password-provider.js +12 -11
- package/dist/esm/providers/web/username-password-provider.js.map +1 -1
- package/dist/plugin.cjs.js +99 -80
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +99 -80
- package/dist/plugin.js.map +1 -1
- package/dist/react.cjs.js +99 -80
- package/dist/react.cjs.js.map +1 -1
- package/dist/vue.cjs.js +99 -80
- package/dist/vue.cjs.js.map +1 -1
- package/package.json +2 -2
package/dist/core.cjs.js
CHANGED
|
@@ -1834,6 +1834,31 @@ class AuthManagerCore {
|
|
|
1834
1834
|
// Create singleton instance
|
|
1835
1835
|
const auth = new AuthManagerCore();
|
|
1836
1836
|
|
|
1837
|
+
/**
|
|
1838
|
+
* Normalize a provider constructor argument into a full {@link BaseProviderConfig}.
|
|
1839
|
+
*
|
|
1840
|
+
* The standalone providers are public (exported from `capacitor-auth-manager/providers/web`) and
|
|
1841
|
+
* get constructed two ways: the factory/registry pass a full {@link BaseProviderConfig}, while
|
|
1842
|
+
* tests and direct consumers pass the provider's own bare options object. This helper accepts
|
|
1843
|
+
* either — a bare object is wrapped with an in-memory storage (`AuthPersistence.NONE`, so it never
|
|
1844
|
+
* touches `window` and stays safe under SSR / Node test environments) plus the shared
|
|
1845
|
+
* {@link defaultLogger}. Callers that pass a full config keep their injected storage/logger.
|
|
1846
|
+
*/
|
|
1847
|
+
function resolveProviderConfig(provider, input) {
|
|
1848
|
+
if (typeof input === 'object' &&
|
|
1849
|
+
input !== null &&
|
|
1850
|
+
'storage' in input &&
|
|
1851
|
+
'logger' in input &&
|
|
1852
|
+
'options' in input) {
|
|
1853
|
+
return input;
|
|
1854
|
+
}
|
|
1855
|
+
return {
|
|
1856
|
+
provider,
|
|
1857
|
+
options: (input !== null && input !== void 0 ? input : {}),
|
|
1858
|
+
storage: new WebStorage(AuthPersistence.NONE),
|
|
1859
|
+
logger: defaultLogger,
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1837
1862
|
class BaseAuthProvider {
|
|
1838
1863
|
get name() {
|
|
1839
1864
|
return this.provider;
|
|
@@ -1853,13 +1878,13 @@ class BaseAuthProvider {
|
|
|
1853
1878
|
// across every provider (see AuthProviderInterface, where they are optional). Marking them
|
|
1854
1879
|
// abstract previously forced every subclass to re-implement them just to throw.
|
|
1855
1880
|
async linkAccount(_options) {
|
|
1856
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `
|
|
1881
|
+
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `Account linking is not supported by provider ${this.provider}`, this.provider);
|
|
1857
1882
|
}
|
|
1858
1883
|
async unlinkAccount(_options) {
|
|
1859
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `
|
|
1884
|
+
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `Account unlinking is not supported by provider ${this.provider}`, this.provider);
|
|
1860
1885
|
}
|
|
1861
1886
|
async revokeAccess(_token) {
|
|
1862
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `
|
|
1887
|
+
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, `Access revocation is not supported by provider ${this.provider}`, this.provider);
|
|
1863
1888
|
}
|
|
1864
1889
|
async getCurrentUser() {
|
|
1865
1890
|
if (!this.isInitialized) {
|
|
@@ -4174,16 +4199,19 @@ class PendingVerificationStore {
|
|
|
4174
4199
|
}
|
|
4175
4200
|
}
|
|
4176
4201
|
|
|
4177
|
-
class MagicLinkProvider {
|
|
4178
|
-
|
|
4179
|
-
|
|
4202
|
+
class MagicLinkProvider extends BaseAuthProvider {
|
|
4203
|
+
get name() {
|
|
4204
|
+
return 'magic-link';
|
|
4205
|
+
}
|
|
4206
|
+
constructor(input) {
|
|
4207
|
+
super(resolveProviderConfig(AuthProvider.EMAIL_MAGIC_LINK, input));
|
|
4180
4208
|
// Persisted (SSR-guarded localStorage) so a magic link clicked from an email — which opens a
|
|
4181
4209
|
// FRESH page load with empty in-memory state — can still find its pending entry to verify
|
|
4182
4210
|
// against. Keyed by the link token (already present in the callback URL); we store only the
|
|
4183
4211
|
// email + expiry, never any additional secret (see PendingVerificationStore + F-11).
|
|
4184
4212
|
this.pendingVerification = new PendingVerificationStore('magic-link');
|
|
4185
|
-
//
|
|
4186
|
-
this.config =
|
|
4213
|
+
// Magic link uses its config as-is (no defaults to merge).
|
|
4214
|
+
this.config = this.options;
|
|
4187
4215
|
// Check for magic link callback on initialization
|
|
4188
4216
|
this.checkForMagicLinkCallback();
|
|
4189
4217
|
}
|
|
@@ -4433,14 +4461,9 @@ class MagicLinkProvider {
|
|
|
4433
4461
|
// Magic link auth is supported if we have the required config
|
|
4434
4462
|
return !!this.config.sendLinkUrl;
|
|
4435
4463
|
}
|
|
4436
|
-
|
|
4437
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for magic link authentication');
|
|
4438
|
-
}
|
|
4439
|
-
async unlinkAccount(_options) {
|
|
4440
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for magic link authentication');
|
|
4441
|
-
}
|
|
4464
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
4442
4465
|
async revokeAccess(_token) {
|
|
4443
|
-
// Magic link doesn't have persistent access to revoke
|
|
4466
|
+
// Magic link doesn't have persistent access to revoke; clear any pending verification.
|
|
4444
4467
|
this.pendingVerification.clear();
|
|
4445
4468
|
}
|
|
4446
4469
|
}
|
|
@@ -4450,16 +4473,18 @@ var magicLinkProvider = /*#__PURE__*/Object.freeze({
|
|
|
4450
4473
|
MagicLinkProvider: MagicLinkProvider
|
|
4451
4474
|
});
|
|
4452
4475
|
|
|
4453
|
-
class SMSProvider {
|
|
4454
|
-
|
|
4455
|
-
|
|
4476
|
+
class SMSProvider extends BaseAuthProvider {
|
|
4477
|
+
get name() {
|
|
4478
|
+
return 'sms';
|
|
4479
|
+
}
|
|
4480
|
+
constructor(input) {
|
|
4481
|
+
super(resolveProviderConfig(AuthProvider.SMS, input));
|
|
4456
4482
|
// Pending verifications are persisted (SSR-guarded localStorage) so they survive a reload /
|
|
4457
4483
|
// page change between sending and verifying the code. Only non-secret metadata is stored —
|
|
4458
4484
|
// never the SMS code itself (see PendingVerificationStore + F-11).
|
|
4459
4485
|
this.pendingVerifications = new PendingVerificationStore('sms');
|
|
4460
4486
|
this.MAX_ATTEMPTS = 3;
|
|
4461
|
-
|
|
4462
|
-
this.config = Object.assign({ countryCode: '+1', codeLength: 6, resendDelay: 60000 }, config);
|
|
4487
|
+
this.config = Object.assign({ countryCode: '+1', codeLength: 6, resendDelay: 60000 }, this.options);
|
|
4463
4488
|
}
|
|
4464
4489
|
async signIn(options) {
|
|
4465
4490
|
if (!(options === null || options === void 0 ? void 0 : options.phoneNumber)) {
|
|
@@ -4697,14 +4722,9 @@ class SMSProvider {
|
|
|
4697
4722
|
// SMS auth is supported if we have the required config
|
|
4698
4723
|
return !!(this.config.sendCodeUrl && this.config.verifyCodeUrl);
|
|
4699
4724
|
}
|
|
4700
|
-
|
|
4701
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for SMS authentication');
|
|
4702
|
-
}
|
|
4703
|
-
async unlinkAccount(_options) {
|
|
4704
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for SMS authentication');
|
|
4705
|
-
}
|
|
4725
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
4706
4726
|
async revokeAccess(_token) {
|
|
4707
|
-
// SMS auth doesn't have persistent access to revoke
|
|
4727
|
+
// SMS auth doesn't have persistent access to revoke; clear any pending verification.
|
|
4708
4728
|
this.pendingVerifications.clear();
|
|
4709
4729
|
}
|
|
4710
4730
|
}
|
|
@@ -4714,20 +4734,23 @@ var smsProvider = /*#__PURE__*/Object.freeze({
|
|
|
4714
4734
|
SMSProvider: SMSProvider
|
|
4715
4735
|
});
|
|
4716
4736
|
|
|
4717
|
-
class EmailPasswordProvider {
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4737
|
+
class EmailPasswordProvider extends BaseAuthProvider {
|
|
4738
|
+
get name() {
|
|
4739
|
+
return 'email-password';
|
|
4740
|
+
}
|
|
4741
|
+
constructor(input) {
|
|
4742
|
+
super(resolveProviderConfig(AuthProvider.EMAIL_PASSWORD, input));
|
|
4743
|
+
// currentUser is the inherited (in-memory) field from BaseAuthProvider; assigned directly here
|
|
4744
|
+
// so email/password sessions stay in-memory exactly as before (no new storage persistence).
|
|
4721
4745
|
this.authToken = null;
|
|
4722
4746
|
this.refreshTokenValue = null;
|
|
4723
|
-
// Initialize with config
|
|
4724
4747
|
this.config = Object.assign({ allowSignUp: true, passwordRequirements: {
|
|
4725
4748
|
minLength: 8,
|
|
4726
4749
|
requireUppercase: true,
|
|
4727
4750
|
requireLowercase: true,
|
|
4728
4751
|
requireNumbers: true,
|
|
4729
4752
|
requireSpecialChars: false,
|
|
4730
|
-
} },
|
|
4753
|
+
} }, this.options);
|
|
4731
4754
|
}
|
|
4732
4755
|
async signIn(options) {
|
|
4733
4756
|
if (!(options === null || options === void 0 ? void 0 : options.email) || !(options === null || options === void 0 ? void 0 : options.password)) {
|
|
@@ -5073,12 +5096,7 @@ class EmailPasswordProvider {
|
|
|
5073
5096
|
// Email/Password auth is supported if we have the required config
|
|
5074
5097
|
return !!this.config.apiUrl;
|
|
5075
5098
|
}
|
|
5076
|
-
|
|
5077
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for email/password authentication');
|
|
5078
|
-
}
|
|
5079
|
-
async unlinkAccount(_options) {
|
|
5080
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for email/password authentication');
|
|
5081
|
-
}
|
|
5099
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
5082
5100
|
async revokeAccess(_token) {
|
|
5083
5101
|
// For email/password auth, revoking access means signing out
|
|
5084
5102
|
await this.signOut();
|
|
@@ -5090,11 +5108,15 @@ var emailPasswordProvider = /*#__PURE__*/Object.freeze({
|
|
|
5090
5108
|
EmailPasswordProvider: EmailPasswordProvider
|
|
5091
5109
|
});
|
|
5092
5110
|
|
|
5093
|
-
class BiometricProvider {
|
|
5094
|
-
|
|
5095
|
-
|
|
5111
|
+
class BiometricProvider extends BaseAuthProvider {
|
|
5112
|
+
get name() {
|
|
5113
|
+
return 'biometric';
|
|
5114
|
+
}
|
|
5115
|
+
constructor(input = {}) {
|
|
5116
|
+
super(resolveProviderConfig(AuthProvider.BIOMETRIC, input));
|
|
5096
5117
|
this.biometricAuth = null;
|
|
5097
5118
|
this.cryptoKeyPromise = null;
|
|
5119
|
+
const config = this.options;
|
|
5098
5120
|
this.config = Object.assign({ reason: 'Authenticate to access your account', title: 'Authentication Required', subtitle: 'Access your account securely', fallbackTitle: 'Use Passcode', requireRecentAuth: true, recentAuthTimeout: 5 * 60 * 1000 }, config);
|
|
5099
5121
|
this.storageKey =
|
|
5100
5122
|
config.storageKey || 'capacitor-auth-biometric-credentials';
|
|
@@ -5378,9 +5400,7 @@ class BiometricProvider {
|
|
|
5378
5400
|
const result = await this.isAvailable();
|
|
5379
5401
|
return result.available;
|
|
5380
5402
|
}
|
|
5381
|
-
|
|
5382
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for biometric authentication');
|
|
5383
|
-
}
|
|
5403
|
+
// linkAccount inherits BaseAuthProvider's OPERATION_NOT_ALLOWED default (F-44).
|
|
5384
5404
|
async unlinkAccount(_options) {
|
|
5385
5405
|
// Unlinking biometric auth means clearing stored credentials
|
|
5386
5406
|
await this.clearStoredCredentials();
|
|
@@ -5657,12 +5677,17 @@ var linkedinProvider = /*#__PURE__*/Object.freeze({
|
|
|
5657
5677
|
LinkedInProvider: LinkedInProvider
|
|
5658
5678
|
});
|
|
5659
5679
|
|
|
5660
|
-
class UsernamePasswordProvider {
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5680
|
+
class UsernamePasswordProvider extends BaseAuthProvider {
|
|
5681
|
+
get name() {
|
|
5682
|
+
return 'username-password';
|
|
5683
|
+
}
|
|
5684
|
+
constructor(input) {
|
|
5685
|
+
super(resolveProviderConfig(AuthProvider.USERNAME_PASSWORD, input));
|
|
5686
|
+
// currentUser is the inherited (in-memory) field from BaseAuthProvider; assigned directly here
|
|
5687
|
+
// so username/password sessions stay in-memory exactly as before (no new storage persistence).
|
|
5664
5688
|
this.authToken = null;
|
|
5665
5689
|
this.refreshTokenValue = null;
|
|
5690
|
+
const config = this.options;
|
|
5666
5691
|
this.config = Object.assign({ allowSignUp: true, usernameRequirements: Object.assign({ minLength: 3, maxLength: 20, allowedCharacters: /^[a-zA-Z0-9_-]+$/, reservedUsernames: ['admin', 'root', 'system', 'user'] }, config.usernameRequirements), passwordRequirements: Object.assign({ minLength: 8, requireUppercase: true, requireLowercase: true, requireNumbers: true, requireSpecialChars: false }, config.passwordRequirements) }, config);
|
|
5667
5692
|
}
|
|
5668
5693
|
async signIn(options) {
|
|
@@ -6007,12 +6032,7 @@ class UsernamePasswordProvider {
|
|
|
6007
6032
|
// Username/Password auth is supported if we have the required config
|
|
6008
6033
|
return !!this.config.apiUrl;
|
|
6009
6034
|
}
|
|
6010
|
-
|
|
6011
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for username/password authentication');
|
|
6012
|
-
}
|
|
6013
|
-
async unlinkAccount(_options) {
|
|
6014
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for username/password authentication');
|
|
6015
|
-
}
|
|
6035
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
6016
6036
|
async revokeAccess(_token) {
|
|
6017
6037
|
// For username/password auth, revoking access means signing out
|
|
6018
6038
|
await this.signOut();
|
|
@@ -6024,15 +6044,18 @@ var usernamePasswordProvider = /*#__PURE__*/Object.freeze({
|
|
|
6024
6044
|
UsernamePasswordProvider: UsernamePasswordProvider
|
|
6025
6045
|
});
|
|
6026
6046
|
|
|
6027
|
-
class EmailCodeProvider {
|
|
6028
|
-
|
|
6029
|
-
|
|
6047
|
+
class EmailCodeProvider extends BaseAuthProvider {
|
|
6048
|
+
get name() {
|
|
6049
|
+
return 'email-code';
|
|
6050
|
+
}
|
|
6051
|
+
constructor(input) {
|
|
6052
|
+
super(resolveProviderConfig(AuthProvider.EMAIL_CODE, input));
|
|
6030
6053
|
// Pending verifications are persisted (SSR-guarded localStorage) so they survive a reload /
|
|
6031
6054
|
// page change between sending and verifying the code. Only non-secret metadata is stored —
|
|
6032
6055
|
// never the verification code itself (see PendingVerificationStore + F-11).
|
|
6033
6056
|
this.pendingVerifications = new PendingVerificationStore('email-code');
|
|
6034
6057
|
this.MAX_ATTEMPTS = 3;
|
|
6035
|
-
this.config = Object.assign({ codeLength: 6, resendDelay: 60000, codeExpiration: 10 * 60 * 1000 },
|
|
6058
|
+
this.config = Object.assign({ codeLength: 6, resendDelay: 60000, codeExpiration: 10 * 60 * 1000 }, this.options);
|
|
6036
6059
|
}
|
|
6037
6060
|
async signIn(options) {
|
|
6038
6061
|
if (!(options === null || options === void 0 ? void 0 : options.email)) {
|
|
@@ -6227,12 +6250,7 @@ class EmailCodeProvider {
|
|
|
6227
6250
|
async isSupported() {
|
|
6228
6251
|
return !!(this.config.sendCodeUrl && this.config.verifyCodeUrl);
|
|
6229
6252
|
}
|
|
6230
|
-
|
|
6231
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for email code authentication');
|
|
6232
|
-
}
|
|
6233
|
-
async unlinkAccount(_options) {
|
|
6234
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for email code authentication');
|
|
6235
|
-
}
|
|
6253
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
6236
6254
|
async revokeAccess(_token) {
|
|
6237
6255
|
this.pendingVerifications.clear();
|
|
6238
6256
|
}
|
|
@@ -6277,11 +6295,15 @@ var emailCodeProvider = /*#__PURE__*/Object.freeze({
|
|
|
6277
6295
|
EmailCodeProvider: EmailCodeProvider
|
|
6278
6296
|
});
|
|
6279
6297
|
|
|
6280
|
-
class PhonePasswordProvider {
|
|
6281
|
-
|
|
6282
|
-
|
|
6298
|
+
class PhonePasswordProvider extends BaseAuthProvider {
|
|
6299
|
+
get name() {
|
|
6300
|
+
return 'phone-password';
|
|
6301
|
+
}
|
|
6302
|
+
constructor(input) {
|
|
6303
|
+
super(resolveProviderConfig(AuthProvider.PHONE_PASSWORD, input));
|
|
6283
6304
|
this.pendingVerifications = new Map();
|
|
6284
|
-
|
|
6305
|
+
// currentUser is the inherited (in-memory) field from BaseAuthProvider; assigned directly here
|
|
6306
|
+
// so phone/password sessions stay in-memory exactly as before (no new storage persistence).
|
|
6285
6307
|
this.storedAccessToken = null;
|
|
6286
6308
|
this.storedRefreshToken = null;
|
|
6287
6309
|
this.config = Object.assign({ countryCode: '+1', requirePhoneVerification: false, passwordStrength: {
|
|
@@ -6290,7 +6312,7 @@ class PhonePasswordProvider {
|
|
|
6290
6312
|
requireLowercase: true,
|
|
6291
6313
|
requireNumbers: true,
|
|
6292
6314
|
requireSpecialChars: false,
|
|
6293
|
-
} },
|
|
6315
|
+
} }, this.options);
|
|
6294
6316
|
}
|
|
6295
6317
|
async signIn(options) {
|
|
6296
6318
|
const credentials = options === null || options === void 0 ? void 0 : options.credentials;
|
|
@@ -6333,7 +6355,7 @@ class PhonePasswordProvider {
|
|
|
6333
6355
|
throw new AuthError(AuthErrorCode.SIGN_IN_FAILED, error.message || 'Sign in failed');
|
|
6334
6356
|
}
|
|
6335
6357
|
const data = await response.json();
|
|
6336
|
-
return this.
|
|
6358
|
+
return this.buildAuthResult(data, phoneNumber);
|
|
6337
6359
|
}
|
|
6338
6360
|
catch (error) {
|
|
6339
6361
|
if (error instanceof AuthError)
|
|
@@ -6397,7 +6419,7 @@ class PhonePasswordProvider {
|
|
|
6397
6419
|
},
|
|
6398
6420
|
};
|
|
6399
6421
|
}
|
|
6400
|
-
return this.
|
|
6422
|
+
return this.buildAuthResult(data, phoneNumber, true);
|
|
6401
6423
|
}
|
|
6402
6424
|
catch (error) {
|
|
6403
6425
|
if (error instanceof AuthError)
|
|
@@ -6465,7 +6487,7 @@ class PhonePasswordProvider {
|
|
|
6465
6487
|
}
|
|
6466
6488
|
const data = await response.json();
|
|
6467
6489
|
this.pendingVerifications.delete(phoneNumber);
|
|
6468
|
-
return this.
|
|
6490
|
+
return this.buildAuthResult(data, phoneNumber);
|
|
6469
6491
|
}
|
|
6470
6492
|
catch (error) {
|
|
6471
6493
|
if (error instanceof AuthError)
|
|
@@ -6535,12 +6557,7 @@ class PhonePasswordProvider {
|
|
|
6535
6557
|
async isSupported() {
|
|
6536
6558
|
return !!(this.config.signInUrl && this.config.signUpUrl);
|
|
6537
6559
|
}
|
|
6538
|
-
|
|
6539
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account linking is not supported for phone/password authentication');
|
|
6540
|
-
}
|
|
6541
|
-
async unlinkAccount(_options) {
|
|
6542
|
-
throw new AuthError(AuthErrorCode.OPERATION_NOT_ALLOWED, 'Account unlinking is not supported for phone/password authentication');
|
|
6543
|
-
}
|
|
6560
|
+
// linkAccount + unlinkAccount inherit BaseAuthProvider's OPERATION_NOT_ALLOWED defaults (F-44).
|
|
6544
6561
|
async revokeAccess(_token) {
|
|
6545
6562
|
await this.signOut();
|
|
6546
6563
|
}
|
|
@@ -6567,7 +6584,9 @@ class PhonePasswordProvider {
|
|
|
6567
6584
|
throw new AuthError(AuthErrorCode.SERVER_ERROR, error.message || 'Failed to send password reset');
|
|
6568
6585
|
}
|
|
6569
6586
|
}
|
|
6570
|
-
createAuthResult
|
|
6587
|
+
// Renamed from createAuthResult to avoid colliding with BaseAuthProvider.createAuthResult,
|
|
6588
|
+
// which has a different signature (this builds a phone-specific result from a backend payload).
|
|
6589
|
+
buildAuthResult(data, phoneNumber, isNewUser = false) {
|
|
6571
6590
|
const user = {
|
|
6572
6591
|
uid: data.uid || this.generateUid(phoneNumber),
|
|
6573
6592
|
email: data.email || null,
|