@misiki/gocommerce-connector 0.4.7 → 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-CQTW5q1J.d.cts → index-Bjx8kR8G.d.cts} +38 -4
- package/dist/{index-CQTW5q1J.d.ts → index-Bjx8kR8G.d.ts} +38 -4
- package/dist/index.cjs +38 -7
- 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 +38 -7
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +38 -7
- 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 +38 -7
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4672,10 +4672,16 @@ declare const orderService: OrderService;
|
|
|
4672
4672
|
* as "Accounts are not available on this store" rather than as a route error.
|
|
4673
4673
|
*/
|
|
4674
4674
|
declare class UserService extends BaseService {
|
|
4675
|
-
/**
|
|
4676
|
-
|
|
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, }: {
|
|
4677
4681
|
email: string;
|
|
4678
4682
|
password: string;
|
|
4683
|
+
phone?: string;
|
|
4684
|
+
phoneToken?: string;
|
|
4679
4685
|
cartId?: string | null;
|
|
4680
4686
|
}): Promise<{
|
|
4681
4687
|
id: string;
|
|
@@ -4999,10 +5005,38 @@ declare class AuthService extends UserService {
|
|
|
4999
5005
|
}): Promise<{
|
|
5000
5006
|
expiresInMinutes: number;
|
|
5001
5007
|
}>;
|
|
5002
|
-
/**
|
|
5003
|
-
|
|
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 }: {
|
|
5004
5015
|
phone: string;
|
|
5005
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;
|
|
5006
5040
|
}): Promise<{
|
|
5007
5041
|
id: string;
|
|
5008
5042
|
userId: string;
|
|
@@ -4672,10 +4672,16 @@ declare const orderService: OrderService;
|
|
|
4672
4672
|
* as "Accounts are not available on this store" rather than as a route error.
|
|
4673
4673
|
*/
|
|
4674
4674
|
declare class UserService extends BaseService {
|
|
4675
|
-
/**
|
|
4676
|
-
|
|
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, }: {
|
|
4677
4681
|
email: string;
|
|
4678
4682
|
password: string;
|
|
4683
|
+
phone?: string;
|
|
4684
|
+
phoneToken?: string;
|
|
4679
4685
|
cartId?: string | null;
|
|
4680
4686
|
}): Promise<{
|
|
4681
4687
|
id: string;
|
|
@@ -4999,10 +5005,38 @@ declare class AuthService extends UserService {
|
|
|
4999
5005
|
}): Promise<{
|
|
5000
5006
|
expiresInMinutes: number;
|
|
5001
5007
|
}>;
|
|
5002
|
-
/**
|
|
5003
|
-
|
|
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 }: {
|
|
5004
5015
|
phone: string;
|
|
5005
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;
|
|
5006
5040
|
}): Promise<{
|
|
5007
5041
|
id: string;
|
|
5008
5042
|
userId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -2085,11 +2085,24 @@ var orderService = new OrderService();
|
|
|
2085
2085
|
|
|
2086
2086
|
// src/services/user-service.ts
|
|
2087
2087
|
var UserService = class extends BaseService {
|
|
2088
|
-
/**
|
|
2089
|
-
|
|
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
|
+
}) {
|
|
2090
2099
|
const auth = await this.account("/x/identity/login", {
|
|
2091
2100
|
method: "POST",
|
|
2092
|
-
body: {
|
|
2101
|
+
body: {
|
|
2102
|
+
email: String(email ?? "").trim(),
|
|
2103
|
+
password: String(password ?? ""),
|
|
2104
|
+
...phoneToken ? { phone: String(phone ?? "").trim(), phone_token: phoneToken } : {}
|
|
2105
|
+
}
|
|
2093
2106
|
});
|
|
2094
2107
|
return this.signedIn(auth);
|
|
2095
2108
|
}
|
|
@@ -2261,11 +2274,29 @@ var AuthService = class extends UserService {
|
|
|
2261
2274
|
});
|
|
2262
2275
|
return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
|
|
2263
2276
|
}
|
|
2264
|
-
/**
|
|
2265
|
-
|
|
2266
|
-
|
|
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", {
|
|
2267
2285
|
method: "POST",
|
|
2268
|
-
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 }
|
|
2269
2300
|
});
|
|
2270
2301
|
return this.signedIn(auth);
|
|
2271
2302
|
}
|