@misiki/gocommerce-connector 0.4.6 → 0.4.8
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/{index-B0Gf_Bvg.d.cts → index-Bjx8kR8G.d.cts} +80 -5
- package/dist/{index-B0Gf_Bvg.d.ts → index-Bjx8kR8G.d.ts} +80 -5
- package/dist/index.cjs +62 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -9
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +62 -9
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +62 -9
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -374,6 +374,8 @@ type Customer = {
|
|
|
374
374
|
id: number;
|
|
375
375
|
email: string;
|
|
376
376
|
email_verified: boolean;
|
|
377
|
+
/** The phone was proved with a code and signs in to this account (D118). */
|
|
378
|
+
phone_verified?: boolean;
|
|
377
379
|
name: string;
|
|
378
380
|
phone: string;
|
|
379
381
|
created_at: string;
|
|
@@ -1126,6 +1128,7 @@ declare function toUser(c: Customer): {
|
|
|
1126
1128
|
email: string;
|
|
1127
1129
|
emailVerified: boolean;
|
|
1128
1130
|
phone: string | null;
|
|
1131
|
+
phoneVerified: boolean;
|
|
1129
1132
|
firstName: string;
|
|
1130
1133
|
lastName: string;
|
|
1131
1134
|
name: string;
|
|
@@ -4669,10 +4672,16 @@ declare const orderService: OrderService;
|
|
|
4669
4672
|
* as "Accounts are not available on this store" rather than as a route error.
|
|
4670
4673
|
*/
|
|
4671
4674
|
declare class UserService extends BaseService {
|
|
4672
|
-
/**
|
|
4673
|
-
|
|
4675
|
+
/**
|
|
4676
|
+
* Email and password. The answer is the user object the storefront keeps in its `me` cookie.
|
|
4677
|
+
* With `phone` and `phoneToken` from `verifyOtp({ askIfNew: true })`, the phone is added to
|
|
4678
|
+
* the account as it signs in (D123).
|
|
4679
|
+
*/
|
|
4680
|
+
login({ email, password, phone, phoneToken, }: {
|
|
4674
4681
|
email: string;
|
|
4675
4682
|
password: string;
|
|
4683
|
+
phone?: string;
|
|
4684
|
+
phoneToken?: string;
|
|
4676
4685
|
cartId?: string | null;
|
|
4677
4686
|
}): Promise<{
|
|
4678
4687
|
id: string;
|
|
@@ -4686,6 +4695,7 @@ declare class UserService extends BaseService {
|
|
|
4686
4695
|
avatar: null;
|
|
4687
4696
|
role: string;
|
|
4688
4697
|
emailVerified: boolean;
|
|
4698
|
+
phoneVerified: boolean;
|
|
4689
4699
|
storeId: null;
|
|
4690
4700
|
}>;
|
|
4691
4701
|
signup({ email, password, firstName, lastName, phone, }: {
|
|
@@ -4708,6 +4718,7 @@ declare class UserService extends BaseService {
|
|
|
4708
4718
|
avatar: null;
|
|
4709
4719
|
role: string;
|
|
4710
4720
|
emailVerified: boolean;
|
|
4721
|
+
phoneVerified: boolean;
|
|
4711
4722
|
storeId: null;
|
|
4712
4723
|
}>;
|
|
4713
4724
|
/** Signs out here and on the engine. The storefront assigns the answer to its user: `null`. */
|
|
@@ -4718,6 +4729,7 @@ declare class UserService extends BaseService {
|
|
|
4718
4729
|
email: string;
|
|
4719
4730
|
emailVerified: boolean;
|
|
4720
4731
|
phone: string | null;
|
|
4732
|
+
phoneVerified: boolean;
|
|
4721
4733
|
firstName: string;
|
|
4722
4734
|
lastName: string;
|
|
4723
4735
|
name: string;
|
|
@@ -4739,6 +4751,7 @@ declare class UserService extends BaseService {
|
|
|
4739
4751
|
email: string;
|
|
4740
4752
|
emailVerified: boolean;
|
|
4741
4753
|
phone: string | null;
|
|
4754
|
+
phoneVerified: boolean;
|
|
4742
4755
|
firstName: string;
|
|
4743
4756
|
lastName: string;
|
|
4744
4757
|
name: string;
|
|
@@ -4763,6 +4776,7 @@ declare class UserService extends BaseService {
|
|
|
4763
4776
|
email: string;
|
|
4764
4777
|
emailVerified: boolean;
|
|
4765
4778
|
phone: string | null;
|
|
4779
|
+
phoneVerified: boolean;
|
|
4766
4780
|
firstName: string;
|
|
4767
4781
|
lastName: string;
|
|
4768
4782
|
name: string;
|
|
@@ -4793,6 +4807,7 @@ declare class UserService extends BaseService {
|
|
|
4793
4807
|
avatar: null;
|
|
4794
4808
|
role: string;
|
|
4795
4809
|
emailVerified: boolean;
|
|
4810
|
+
phoneVerified: boolean;
|
|
4796
4811
|
storeId: null;
|
|
4797
4812
|
}>;
|
|
4798
4813
|
/**
|
|
@@ -4918,6 +4933,7 @@ declare class UserService extends BaseService {
|
|
|
4918
4933
|
avatar: null;
|
|
4919
4934
|
role: string;
|
|
4920
4935
|
emailVerified: boolean;
|
|
4936
|
+
phoneVerified: boolean;
|
|
4921
4937
|
storeId: null;
|
|
4922
4938
|
}>;
|
|
4923
4939
|
/** An identity call, with a 404 from a build without the module said in words. */
|
|
@@ -4934,7 +4950,7 @@ declare class AuthService extends UserService {
|
|
|
4934
4950
|
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
4935
4951
|
* A store whose accounts module says nothing signs in by email.
|
|
4936
4952
|
*/
|
|
4937
|
-
loginMethod(): Promise<'email_password' | 'phone_otp'>;
|
|
4953
|
+
loginMethod(): Promise<'email_password' | 'phone_otp' | 'email_or_phone'>;
|
|
4938
4954
|
forgotPassword({ email }: {
|
|
4939
4955
|
email: string;
|
|
4940
4956
|
referrer?: string;
|
|
@@ -4958,6 +4974,7 @@ declare class AuthService extends UserService {
|
|
|
4958
4974
|
avatar: null;
|
|
4959
4975
|
role: string;
|
|
4960
4976
|
emailVerified: boolean;
|
|
4977
|
+
phoneVerified: boolean;
|
|
4961
4978
|
storeId: null;
|
|
4962
4979
|
}>;
|
|
4963
4980
|
/** Answers `{ errorCode, message }` on failure rather than throwing: that is how the page reads it. */
|
|
@@ -4968,6 +4985,7 @@ declare class AuthService extends UserService {
|
|
|
4968
4985
|
email: string;
|
|
4969
4986
|
emailVerified: boolean;
|
|
4970
4987
|
phone: string | null;
|
|
4988
|
+
phoneVerified: boolean;
|
|
4971
4989
|
firstName: string;
|
|
4972
4990
|
lastName: string;
|
|
4973
4991
|
name: string;
|
|
@@ -4987,10 +5005,38 @@ declare class AuthService extends UserService {
|
|
|
4987
5005
|
}): Promise<{
|
|
4988
5006
|
expiresInMinutes: number;
|
|
4989
5007
|
}>;
|
|
4990
|
-
/**
|
|
4991
|
-
|
|
5008
|
+
/**
|
|
5009
|
+
* Signs in the account on `phone` with the code it was sent, opening one the first time.
|
|
5010
|
+
* With `askIfNew`, on a store that signs in either way, a phone with no account opens none:
|
|
5011
|
+
* the answer is `{ newPhone: true, phoneToken }`, and the storefront asks "Already have an
|
|
5012
|
+
* account?" — `login` with the token adds the phone to it, `openPhoneAccount` opens a new one (D123).
|
|
5013
|
+
*/
|
|
5014
|
+
verifyOtp({ phone, otp, askIfNew }: {
|
|
4992
5015
|
phone: string;
|
|
4993
5016
|
otp: string;
|
|
5017
|
+
askIfNew?: boolean;
|
|
5018
|
+
}): Promise<{
|
|
5019
|
+
id: string;
|
|
5020
|
+
userId: string;
|
|
5021
|
+
email: string;
|
|
5022
|
+
phone: string | null;
|
|
5023
|
+
firstName: string;
|
|
5024
|
+
lastName: string;
|
|
5025
|
+
name: string;
|
|
5026
|
+
fullName: string;
|
|
5027
|
+
avatar: null;
|
|
5028
|
+
role: string;
|
|
5029
|
+
emailVerified: boolean;
|
|
5030
|
+
phoneVerified: boolean;
|
|
5031
|
+
storeId: null;
|
|
5032
|
+
} | {
|
|
5033
|
+
newPhone: true;
|
|
5034
|
+
phoneToken: string;
|
|
5035
|
+
}>;
|
|
5036
|
+
/** Opens a new account on a phone `verifyOtp({ askIfNew: true })` proved, and signs it in (D123). */
|
|
5037
|
+
openPhoneAccount({ phone, phoneToken }: {
|
|
5038
|
+
phone: string;
|
|
5039
|
+
phoneToken: string;
|
|
4994
5040
|
}): Promise<{
|
|
4995
5041
|
id: string;
|
|
4996
5042
|
userId: string;
|
|
@@ -5003,6 +5049,7 @@ declare class AuthService extends UserService {
|
|
|
5003
5049
|
avatar: null;
|
|
5004
5050
|
role: string;
|
|
5005
5051
|
emailVerified: boolean;
|
|
5052
|
+
phoneVerified: boolean;
|
|
5006
5053
|
storeId: null;
|
|
5007
5054
|
}>;
|
|
5008
5055
|
joinAsAdmin(): Promise<never>;
|
|
@@ -5015,6 +5062,7 @@ declare class ProfileService extends UserService {
|
|
|
5015
5062
|
email: string;
|
|
5016
5063
|
emailVerified: boolean;
|
|
5017
5064
|
phone: string | null;
|
|
5065
|
+
phoneVerified: boolean;
|
|
5018
5066
|
firstName: string;
|
|
5019
5067
|
lastName: string;
|
|
5020
5068
|
name: string;
|
|
@@ -5035,6 +5083,33 @@ declare class ProfileService extends UserService {
|
|
|
5035
5083
|
email: string;
|
|
5036
5084
|
emailVerified: boolean;
|
|
5037
5085
|
phone: string | null;
|
|
5086
|
+
phoneVerified: boolean;
|
|
5087
|
+
firstName: string;
|
|
5088
|
+
lastName: string;
|
|
5089
|
+
name: string;
|
|
5090
|
+
fullName: string;
|
|
5091
|
+
avatar: null;
|
|
5092
|
+
role: string;
|
|
5093
|
+
createdAt: string;
|
|
5094
|
+
updatedAt: string;
|
|
5095
|
+
}>;
|
|
5096
|
+
/** Texts a code to a phone the signed-in shopper wants to add (D118). */
|
|
5097
|
+
requestPhoneLink({ phone }: {
|
|
5098
|
+
phone: string;
|
|
5099
|
+
}): Promise<{
|
|
5100
|
+
expiresInMinutes: number;
|
|
5101
|
+
}>;
|
|
5102
|
+
/** Adds the phone with its code; from then on it signs in to this account too. */
|
|
5103
|
+
verifyPhoneLink({ phone, otp }: {
|
|
5104
|
+
phone: string;
|
|
5105
|
+
otp: string;
|
|
5106
|
+
}): Promise<{
|
|
5107
|
+
id: string;
|
|
5108
|
+
userId: string;
|
|
5109
|
+
email: string;
|
|
5110
|
+
emailVerified: boolean;
|
|
5111
|
+
phone: string | null;
|
|
5112
|
+
phoneVerified: boolean;
|
|
5038
5113
|
firstName: string;
|
|
5039
5114
|
lastName: string;
|
|
5040
5115
|
name: string;
|
|
@@ -374,6 +374,8 @@ type Customer = {
|
|
|
374
374
|
id: number;
|
|
375
375
|
email: string;
|
|
376
376
|
email_verified: boolean;
|
|
377
|
+
/** The phone was proved with a code and signs in to this account (D118). */
|
|
378
|
+
phone_verified?: boolean;
|
|
377
379
|
name: string;
|
|
378
380
|
phone: string;
|
|
379
381
|
created_at: string;
|
|
@@ -1126,6 +1128,7 @@ declare function toUser(c: Customer): {
|
|
|
1126
1128
|
email: string;
|
|
1127
1129
|
emailVerified: boolean;
|
|
1128
1130
|
phone: string | null;
|
|
1131
|
+
phoneVerified: boolean;
|
|
1129
1132
|
firstName: string;
|
|
1130
1133
|
lastName: string;
|
|
1131
1134
|
name: string;
|
|
@@ -4669,10 +4672,16 @@ declare const orderService: OrderService;
|
|
|
4669
4672
|
* as "Accounts are not available on this store" rather than as a route error.
|
|
4670
4673
|
*/
|
|
4671
4674
|
declare class UserService extends BaseService {
|
|
4672
|
-
/**
|
|
4673
|
-
|
|
4675
|
+
/**
|
|
4676
|
+
* Email and password. The answer is the user object the storefront keeps in its `me` cookie.
|
|
4677
|
+
* With `phone` and `phoneToken` from `verifyOtp({ askIfNew: true })`, the phone is added to
|
|
4678
|
+
* the account as it signs in (D123).
|
|
4679
|
+
*/
|
|
4680
|
+
login({ email, password, phone, phoneToken, }: {
|
|
4674
4681
|
email: string;
|
|
4675
4682
|
password: string;
|
|
4683
|
+
phone?: string;
|
|
4684
|
+
phoneToken?: string;
|
|
4676
4685
|
cartId?: string | null;
|
|
4677
4686
|
}): Promise<{
|
|
4678
4687
|
id: string;
|
|
@@ -4686,6 +4695,7 @@ declare class UserService extends BaseService {
|
|
|
4686
4695
|
avatar: null;
|
|
4687
4696
|
role: string;
|
|
4688
4697
|
emailVerified: boolean;
|
|
4698
|
+
phoneVerified: boolean;
|
|
4689
4699
|
storeId: null;
|
|
4690
4700
|
}>;
|
|
4691
4701
|
signup({ email, password, firstName, lastName, phone, }: {
|
|
@@ -4708,6 +4718,7 @@ declare class UserService extends BaseService {
|
|
|
4708
4718
|
avatar: null;
|
|
4709
4719
|
role: string;
|
|
4710
4720
|
emailVerified: boolean;
|
|
4721
|
+
phoneVerified: boolean;
|
|
4711
4722
|
storeId: null;
|
|
4712
4723
|
}>;
|
|
4713
4724
|
/** Signs out here and on the engine. The storefront assigns the answer to its user: `null`. */
|
|
@@ -4718,6 +4729,7 @@ declare class UserService extends BaseService {
|
|
|
4718
4729
|
email: string;
|
|
4719
4730
|
emailVerified: boolean;
|
|
4720
4731
|
phone: string | null;
|
|
4732
|
+
phoneVerified: boolean;
|
|
4721
4733
|
firstName: string;
|
|
4722
4734
|
lastName: string;
|
|
4723
4735
|
name: string;
|
|
@@ -4739,6 +4751,7 @@ declare class UserService extends BaseService {
|
|
|
4739
4751
|
email: string;
|
|
4740
4752
|
emailVerified: boolean;
|
|
4741
4753
|
phone: string | null;
|
|
4754
|
+
phoneVerified: boolean;
|
|
4742
4755
|
firstName: string;
|
|
4743
4756
|
lastName: string;
|
|
4744
4757
|
name: string;
|
|
@@ -4763,6 +4776,7 @@ declare class UserService extends BaseService {
|
|
|
4763
4776
|
email: string;
|
|
4764
4777
|
emailVerified: boolean;
|
|
4765
4778
|
phone: string | null;
|
|
4779
|
+
phoneVerified: boolean;
|
|
4766
4780
|
firstName: string;
|
|
4767
4781
|
lastName: string;
|
|
4768
4782
|
name: string;
|
|
@@ -4793,6 +4807,7 @@ declare class UserService extends BaseService {
|
|
|
4793
4807
|
avatar: null;
|
|
4794
4808
|
role: string;
|
|
4795
4809
|
emailVerified: boolean;
|
|
4810
|
+
phoneVerified: boolean;
|
|
4796
4811
|
storeId: null;
|
|
4797
4812
|
}>;
|
|
4798
4813
|
/**
|
|
@@ -4918,6 +4933,7 @@ declare class UserService extends BaseService {
|
|
|
4918
4933
|
avatar: null;
|
|
4919
4934
|
role: string;
|
|
4920
4935
|
emailVerified: boolean;
|
|
4936
|
+
phoneVerified: boolean;
|
|
4921
4937
|
storeId: null;
|
|
4922
4938
|
}>;
|
|
4923
4939
|
/** An identity call, with a 404 from a build without the module said in words. */
|
|
@@ -4934,7 +4950,7 @@ declare class AuthService extends UserService {
|
|
|
4934
4950
|
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
4935
4951
|
* A store whose accounts module says nothing signs in by email.
|
|
4936
4952
|
*/
|
|
4937
|
-
loginMethod(): Promise<'email_password' | 'phone_otp'>;
|
|
4953
|
+
loginMethod(): Promise<'email_password' | 'phone_otp' | 'email_or_phone'>;
|
|
4938
4954
|
forgotPassword({ email }: {
|
|
4939
4955
|
email: string;
|
|
4940
4956
|
referrer?: string;
|
|
@@ -4958,6 +4974,7 @@ declare class AuthService extends UserService {
|
|
|
4958
4974
|
avatar: null;
|
|
4959
4975
|
role: string;
|
|
4960
4976
|
emailVerified: boolean;
|
|
4977
|
+
phoneVerified: boolean;
|
|
4961
4978
|
storeId: null;
|
|
4962
4979
|
}>;
|
|
4963
4980
|
/** Answers `{ errorCode, message }` on failure rather than throwing: that is how the page reads it. */
|
|
@@ -4968,6 +4985,7 @@ declare class AuthService extends UserService {
|
|
|
4968
4985
|
email: string;
|
|
4969
4986
|
emailVerified: boolean;
|
|
4970
4987
|
phone: string | null;
|
|
4988
|
+
phoneVerified: boolean;
|
|
4971
4989
|
firstName: string;
|
|
4972
4990
|
lastName: string;
|
|
4973
4991
|
name: string;
|
|
@@ -4987,10 +5005,38 @@ declare class AuthService extends UserService {
|
|
|
4987
5005
|
}): Promise<{
|
|
4988
5006
|
expiresInMinutes: number;
|
|
4989
5007
|
}>;
|
|
4990
|
-
/**
|
|
4991
|
-
|
|
5008
|
+
/**
|
|
5009
|
+
* Signs in the account on `phone` with the code it was sent, opening one the first time.
|
|
5010
|
+
* With `askIfNew`, on a store that signs in either way, a phone with no account opens none:
|
|
5011
|
+
* the answer is `{ newPhone: true, phoneToken }`, and the storefront asks "Already have an
|
|
5012
|
+
* account?" — `login` with the token adds the phone to it, `openPhoneAccount` opens a new one (D123).
|
|
5013
|
+
*/
|
|
5014
|
+
verifyOtp({ phone, otp, askIfNew }: {
|
|
4992
5015
|
phone: string;
|
|
4993
5016
|
otp: string;
|
|
5017
|
+
askIfNew?: boolean;
|
|
5018
|
+
}): Promise<{
|
|
5019
|
+
id: string;
|
|
5020
|
+
userId: string;
|
|
5021
|
+
email: string;
|
|
5022
|
+
phone: string | null;
|
|
5023
|
+
firstName: string;
|
|
5024
|
+
lastName: string;
|
|
5025
|
+
name: string;
|
|
5026
|
+
fullName: string;
|
|
5027
|
+
avatar: null;
|
|
5028
|
+
role: string;
|
|
5029
|
+
emailVerified: boolean;
|
|
5030
|
+
phoneVerified: boolean;
|
|
5031
|
+
storeId: null;
|
|
5032
|
+
} | {
|
|
5033
|
+
newPhone: true;
|
|
5034
|
+
phoneToken: string;
|
|
5035
|
+
}>;
|
|
5036
|
+
/** Opens a new account on a phone `verifyOtp({ askIfNew: true })` proved, and signs it in (D123). */
|
|
5037
|
+
openPhoneAccount({ phone, phoneToken }: {
|
|
5038
|
+
phone: string;
|
|
5039
|
+
phoneToken: string;
|
|
4994
5040
|
}): Promise<{
|
|
4995
5041
|
id: string;
|
|
4996
5042
|
userId: string;
|
|
@@ -5003,6 +5049,7 @@ declare class AuthService extends UserService {
|
|
|
5003
5049
|
avatar: null;
|
|
5004
5050
|
role: string;
|
|
5005
5051
|
emailVerified: boolean;
|
|
5052
|
+
phoneVerified: boolean;
|
|
5006
5053
|
storeId: null;
|
|
5007
5054
|
}>;
|
|
5008
5055
|
joinAsAdmin(): Promise<never>;
|
|
@@ -5015,6 +5062,7 @@ declare class ProfileService extends UserService {
|
|
|
5015
5062
|
email: string;
|
|
5016
5063
|
emailVerified: boolean;
|
|
5017
5064
|
phone: string | null;
|
|
5065
|
+
phoneVerified: boolean;
|
|
5018
5066
|
firstName: string;
|
|
5019
5067
|
lastName: string;
|
|
5020
5068
|
name: string;
|
|
@@ -5035,6 +5083,33 @@ declare class ProfileService extends UserService {
|
|
|
5035
5083
|
email: string;
|
|
5036
5084
|
emailVerified: boolean;
|
|
5037
5085
|
phone: string | null;
|
|
5086
|
+
phoneVerified: boolean;
|
|
5087
|
+
firstName: string;
|
|
5088
|
+
lastName: string;
|
|
5089
|
+
name: string;
|
|
5090
|
+
fullName: string;
|
|
5091
|
+
avatar: null;
|
|
5092
|
+
role: string;
|
|
5093
|
+
createdAt: string;
|
|
5094
|
+
updatedAt: string;
|
|
5095
|
+
}>;
|
|
5096
|
+
/** Texts a code to a phone the signed-in shopper wants to add (D118). */
|
|
5097
|
+
requestPhoneLink({ phone }: {
|
|
5098
|
+
phone: string;
|
|
5099
|
+
}): Promise<{
|
|
5100
|
+
expiresInMinutes: number;
|
|
5101
|
+
}>;
|
|
5102
|
+
/** Adds the phone with its code; from then on it signs in to this account too. */
|
|
5103
|
+
verifyPhoneLink({ phone, otp }: {
|
|
5104
|
+
phone: string;
|
|
5105
|
+
otp: string;
|
|
5106
|
+
}): Promise<{
|
|
5107
|
+
id: string;
|
|
5108
|
+
userId: string;
|
|
5109
|
+
email: string;
|
|
5110
|
+
emailVerified: boolean;
|
|
5111
|
+
phone: string | null;
|
|
5112
|
+
phoneVerified: boolean;
|
|
5038
5113
|
firstName: string;
|
|
5039
5114
|
lastName: string;
|
|
5040
5115
|
name: string;
|
package/dist/index.cjs
CHANGED
|
@@ -205,6 +205,7 @@ function toMe(c) {
|
|
|
205
205
|
avatar: null,
|
|
206
206
|
role: "USER",
|
|
207
207
|
emailVerified: c.email_verified,
|
|
208
|
+
phoneVerified: !!c.phone_verified,
|
|
208
209
|
storeId: null
|
|
209
210
|
};
|
|
210
211
|
}
|
|
@@ -986,6 +987,7 @@ function toUser(c) {
|
|
|
986
987
|
email: c.email,
|
|
987
988
|
emailVerified: c.email_verified,
|
|
988
989
|
phone: c.phone || null,
|
|
990
|
+
phoneVerified: !!c.phone_verified,
|
|
989
991
|
firstName: firstName || "",
|
|
990
992
|
lastName: rest.join(" "),
|
|
991
993
|
name: c.name,
|
|
@@ -2083,11 +2085,24 @@ var orderService = new OrderService();
|
|
|
2083
2085
|
|
|
2084
2086
|
// src/services/user-service.ts
|
|
2085
2087
|
var UserService = class extends BaseService {
|
|
2086
|
-
/**
|
|
2087
|
-
|
|
2088
|
+
/**
|
|
2089
|
+
* Email and password. The answer is the user object the storefront keeps in its `me` cookie.
|
|
2090
|
+
* With `phone` and `phoneToken` from `verifyOtp({ askIfNew: true })`, the phone is added to
|
|
2091
|
+
* the account as it signs in (D123).
|
|
2092
|
+
*/
|
|
2093
|
+
async login({
|
|
2094
|
+
email,
|
|
2095
|
+
password,
|
|
2096
|
+
phone,
|
|
2097
|
+
phoneToken
|
|
2098
|
+
}) {
|
|
2088
2099
|
const auth = await this.account("/x/identity/login", {
|
|
2089
2100
|
method: "POST",
|
|
2090
|
-
body: {
|
|
2101
|
+
body: {
|
|
2102
|
+
email: String(email ?? "").trim(),
|
|
2103
|
+
password: String(password ?? ""),
|
|
2104
|
+
...phoneToken ? { phone: String(phone ?? "").trim(), phone_token: phoneToken } : {}
|
|
2105
|
+
}
|
|
2091
2106
|
});
|
|
2092
2107
|
return this.signedIn(auth);
|
|
2093
2108
|
}
|
|
@@ -2220,7 +2235,7 @@ var AuthService = class extends UserService {
|
|
|
2220
2235
|
async loginMethod() {
|
|
2221
2236
|
try {
|
|
2222
2237
|
const method = (await this.facts.plugins()).get("identity")?.settings?.login_method;
|
|
2223
|
-
return method === "phone_otp"
|
|
2238
|
+
return method === "phone_otp" || method === "email_or_phone" ? method : "email_password";
|
|
2224
2239
|
} catch {
|
|
2225
2240
|
return "email_password";
|
|
2226
2241
|
}
|
|
@@ -2259,11 +2274,29 @@ var AuthService = class extends UserService {
|
|
|
2259
2274
|
});
|
|
2260
2275
|
return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
|
|
2261
2276
|
}
|
|
2262
|
-
/**
|
|
2263
|
-
|
|
2264
|
-
|
|
2277
|
+
/**
|
|
2278
|
+
* Signs in the account on `phone` with the code it was sent, opening one the first time.
|
|
2279
|
+
* With `askIfNew`, on a store that signs in either way, a phone with no account opens none:
|
|
2280
|
+
* the answer is `{ newPhone: true, phoneToken }`, and the storefront asks "Already have an
|
|
2281
|
+
* account?" — `login` with the token adds the phone to it, `openPhoneAccount` opens a new one (D123).
|
|
2282
|
+
*/
|
|
2283
|
+
async verifyOtp({ phone, otp, askIfNew }) {
|
|
2284
|
+
const res = await this.account("/x/identity/otp/verify", {
|
|
2265
2285
|
method: "POST",
|
|
2266
|
-
body: {
|
|
2286
|
+
body: {
|
|
2287
|
+
phone: String(phone ?? "").trim(),
|
|
2288
|
+
code: String(otp ?? "").trim(),
|
|
2289
|
+
...askIfNew ? { ask_if_new: true } : {}
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
if ("new_phone" in res && res.new_phone) return { newPhone: true, phoneToken: res.phone_token };
|
|
2293
|
+
return this.signedIn(res);
|
|
2294
|
+
}
|
|
2295
|
+
/** Opens a new account on a phone `verifyOtp({ askIfNew: true })` proved, and signs it in (D123). */
|
|
2296
|
+
async openPhoneAccount({ phone, phoneToken }) {
|
|
2297
|
+
const auth = await this.account("/x/identity/otp/new-account", {
|
|
2298
|
+
method: "POST",
|
|
2299
|
+
body: { phone: String(phone ?? "").trim(), phone_token: phoneToken }
|
|
2267
2300
|
});
|
|
2268
2301
|
return this.signedIn(auth);
|
|
2269
2302
|
}
|
|
@@ -2278,6 +2311,25 @@ var ProfileService = class extends UserService {
|
|
|
2278
2311
|
async save(profile) {
|
|
2279
2312
|
return this.updateProfile(profile);
|
|
2280
2313
|
}
|
|
2314
|
+
/** Texts a code to a phone the signed-in shopper wants to add (D118). */
|
|
2315
|
+
async requestPhoneLink({ phone }) {
|
|
2316
|
+
const res = await this.account("/x/identity/me/phone", {
|
|
2317
|
+
method: "POST",
|
|
2318
|
+
auth: true,
|
|
2319
|
+
body: { phone: String(phone ?? "").trim() }
|
|
2320
|
+
});
|
|
2321
|
+
return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
|
|
2322
|
+
}
|
|
2323
|
+
/** Adds the phone with its code; from then on it signs in to this account too. */
|
|
2324
|
+
async verifyPhoneLink({ phone, otp }) {
|
|
2325
|
+
const c = await this.account("/x/identity/me/phone/verify", {
|
|
2326
|
+
method: "POST",
|
|
2327
|
+
auth: true,
|
|
2328
|
+
body: { phone: String(phone ?? "").trim(), code: String(otp ?? "").trim() }
|
|
2329
|
+
});
|
|
2330
|
+
updateMe(c);
|
|
2331
|
+
return toUser(c);
|
|
2332
|
+
}
|
|
2281
2333
|
};
|
|
2282
2334
|
var userService = new UserService();
|
|
2283
2335
|
var authService = new AuthService();
|
|
@@ -2624,7 +2676,7 @@ var StoreService = class extends BaseService {
|
|
|
2624
2676
|
// The one way this store signs customers in (D116), which the sign-in
|
|
2625
2677
|
// form reads as PHONE or EMAIL. Without the accounts module the static
|
|
2626
2678
|
// record says.
|
|
2627
|
-
...plugins.has("identity") ? { loginType: plugins.get("identity")?.settings?.login_method
|
|
2679
|
+
...plugins.has("identity") ? { loginType: LOGIN_TYPES[String(plugins.get("identity")?.settings?.login_method)] ?? "EMAIL" } : {}
|
|
2628
2680
|
};
|
|
2629
2681
|
}
|
|
2630
2682
|
};
|
|
@@ -2643,6 +2695,7 @@ function regionName(code) {
|
|
|
2643
2695
|
return code;
|
|
2644
2696
|
}
|
|
2645
2697
|
}
|
|
2698
|
+
var LOGIN_TYPES = { phone_otp: "PHONE", email_or_phone: "BOTH", email_password: "EMAIL" };
|
|
2646
2699
|
|
|
2647
2700
|
// src/services/page-service.ts
|
|
2648
2701
|
var PageService = class extends BaseService {
|