@misiki/gocommerce-connector 0.4.4 → 0.4.5
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-BNYk4TS2.d.cts → index-CmPI-hcH.d.cts} +47 -5
- package/dist/{index-BNYk4TS2.d.ts → index-CmPI-hcH.d.ts} +47 -5
- package/dist/index.cjs +32 -5
- 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 +32 -5
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +32 -5
- 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 +32 -5
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4901,15 +4901,35 @@ declare class UserService extends BaseService {
|
|
|
4901
4901
|
deleteUser(): Promise<never>;
|
|
4902
4902
|
checkEmail(): Promise<never>;
|
|
4903
4903
|
joinAsVendor(): Promise<never>;
|
|
4904
|
-
|
|
4904
|
+
protected signedIn(auth: AuthResponse): Promise<{
|
|
4905
|
+
id: string;
|
|
4906
|
+
userId: string;
|
|
4907
|
+
email: string;
|
|
4908
|
+
phone: string | null;
|
|
4909
|
+
firstName: string;
|
|
4910
|
+
lastName: string;
|
|
4911
|
+
name: string;
|
|
4912
|
+
fullName: string;
|
|
4913
|
+
avatar: null;
|
|
4914
|
+
role: string;
|
|
4915
|
+
emailVerified: boolean;
|
|
4916
|
+
storeId: null;
|
|
4917
|
+
}>;
|
|
4905
4918
|
/** An identity call, with a 404 from a build without the module said in words. */
|
|
4906
4919
|
protected account<T>(path: string, req?: Parameters<BaseService['engine']>[1]): Promise<T>;
|
|
4907
4920
|
}
|
|
4908
4921
|
/**
|
|
4909
|
-
* Password resets
|
|
4910
|
-
*
|
|
4922
|
+
* Password resets, email confirmation, and phone sign-in. A store signs its
|
|
4923
|
+
* customers in one way (D116), read from `loginMethod`; the engine refuses
|
|
4924
|
+
* the other.
|
|
4911
4925
|
*/
|
|
4912
4926
|
declare class AuthService extends UserService {
|
|
4927
|
+
private readonly facts;
|
|
4928
|
+
/**
|
|
4929
|
+
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
4930
|
+
* A store whose accounts module says nothing signs in by email.
|
|
4931
|
+
*/
|
|
4932
|
+
loginMethod(): Promise<'email_password' | 'phone_otp'>;
|
|
4913
4933
|
forgotPassword({ email }: {
|
|
4914
4934
|
email: string;
|
|
4915
4935
|
referrer?: string;
|
|
@@ -4956,8 +4976,30 @@ declare class AuthService extends UserService {
|
|
|
4956
4976
|
errorCode: string;
|
|
4957
4977
|
message: string;
|
|
4958
4978
|
}>;
|
|
4959
|
-
|
|
4960
|
-
|
|
4979
|
+
/** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
|
|
4980
|
+
getOtp({ phone }: {
|
|
4981
|
+
phone: string;
|
|
4982
|
+
}): Promise<{
|
|
4983
|
+
expiresInMinutes: number;
|
|
4984
|
+
}>;
|
|
4985
|
+
/** Signs in the account on `phone` with the code it was sent, opening one the first time. */
|
|
4986
|
+
verifyOtp({ phone, otp }: {
|
|
4987
|
+
phone: string;
|
|
4988
|
+
otp: string;
|
|
4989
|
+
}): Promise<{
|
|
4990
|
+
id: string;
|
|
4991
|
+
userId: string;
|
|
4992
|
+
email: string;
|
|
4993
|
+
phone: string | null;
|
|
4994
|
+
firstName: string;
|
|
4995
|
+
lastName: string;
|
|
4996
|
+
name: string;
|
|
4997
|
+
fullName: string;
|
|
4998
|
+
avatar: null;
|
|
4999
|
+
role: string;
|
|
5000
|
+
emailVerified: boolean;
|
|
5001
|
+
storeId: null;
|
|
5002
|
+
}>;
|
|
4961
5003
|
joinAsAdmin(): Promise<never>;
|
|
4962
5004
|
}
|
|
4963
5005
|
/** The `/my/profile` form: the same account, read and saved. */
|
|
@@ -4901,15 +4901,35 @@ declare class UserService extends BaseService {
|
|
|
4901
4901
|
deleteUser(): Promise<never>;
|
|
4902
4902
|
checkEmail(): Promise<never>;
|
|
4903
4903
|
joinAsVendor(): Promise<never>;
|
|
4904
|
-
|
|
4904
|
+
protected signedIn(auth: AuthResponse): Promise<{
|
|
4905
|
+
id: string;
|
|
4906
|
+
userId: string;
|
|
4907
|
+
email: string;
|
|
4908
|
+
phone: string | null;
|
|
4909
|
+
firstName: string;
|
|
4910
|
+
lastName: string;
|
|
4911
|
+
name: string;
|
|
4912
|
+
fullName: string;
|
|
4913
|
+
avatar: null;
|
|
4914
|
+
role: string;
|
|
4915
|
+
emailVerified: boolean;
|
|
4916
|
+
storeId: null;
|
|
4917
|
+
}>;
|
|
4905
4918
|
/** An identity call, with a 404 from a build without the module said in words. */
|
|
4906
4919
|
protected account<T>(path: string, req?: Parameters<BaseService['engine']>[1]): Promise<T>;
|
|
4907
4920
|
}
|
|
4908
4921
|
/**
|
|
4909
|
-
* Password resets
|
|
4910
|
-
*
|
|
4922
|
+
* Password resets, email confirmation, and phone sign-in. A store signs its
|
|
4923
|
+
* customers in one way (D116), read from `loginMethod`; the engine refuses
|
|
4924
|
+
* the other.
|
|
4911
4925
|
*/
|
|
4912
4926
|
declare class AuthService extends UserService {
|
|
4927
|
+
private readonly facts;
|
|
4928
|
+
/**
|
|
4929
|
+
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
4930
|
+
* A store whose accounts module says nothing signs in by email.
|
|
4931
|
+
*/
|
|
4932
|
+
loginMethod(): Promise<'email_password' | 'phone_otp'>;
|
|
4913
4933
|
forgotPassword({ email }: {
|
|
4914
4934
|
email: string;
|
|
4915
4935
|
referrer?: string;
|
|
@@ -4956,8 +4976,30 @@ declare class AuthService extends UserService {
|
|
|
4956
4976
|
errorCode: string;
|
|
4957
4977
|
message: string;
|
|
4958
4978
|
}>;
|
|
4959
|
-
|
|
4960
|
-
|
|
4979
|
+
/** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
|
|
4980
|
+
getOtp({ phone }: {
|
|
4981
|
+
phone: string;
|
|
4982
|
+
}): Promise<{
|
|
4983
|
+
expiresInMinutes: number;
|
|
4984
|
+
}>;
|
|
4985
|
+
/** Signs in the account on `phone` with the code it was sent, opening one the first time. */
|
|
4986
|
+
verifyOtp({ phone, otp }: {
|
|
4987
|
+
phone: string;
|
|
4988
|
+
otp: string;
|
|
4989
|
+
}): Promise<{
|
|
4990
|
+
id: string;
|
|
4991
|
+
userId: string;
|
|
4992
|
+
email: string;
|
|
4993
|
+
phone: string | null;
|
|
4994
|
+
firstName: string;
|
|
4995
|
+
lastName: string;
|
|
4996
|
+
name: string;
|
|
4997
|
+
fullName: string;
|
|
4998
|
+
avatar: null;
|
|
4999
|
+
role: string;
|
|
5000
|
+
emailVerified: boolean;
|
|
5001
|
+
storeId: null;
|
|
5002
|
+
}>;
|
|
4961
5003
|
joinAsAdmin(): Promise<never>;
|
|
4962
5004
|
}
|
|
4963
5005
|
/** The `/my/profile` form: the same account, read and saved. */
|
package/dist/index.cjs
CHANGED
|
@@ -2205,6 +2205,19 @@ var UserService = class extends BaseService {
|
|
|
2205
2205
|
}
|
|
2206
2206
|
};
|
|
2207
2207
|
var AuthService = class extends UserService {
|
|
2208
|
+
facts = new StoreFacts(this._fetch);
|
|
2209
|
+
/**
|
|
2210
|
+
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
2211
|
+
* A store whose accounts module says nothing signs in by email.
|
|
2212
|
+
*/
|
|
2213
|
+
async loginMethod() {
|
|
2214
|
+
try {
|
|
2215
|
+
const method = (await this.facts.plugins()).get("identity")?.settings?.login_method;
|
|
2216
|
+
return method === "phone_otp" ? "phone_otp" : "email_password";
|
|
2217
|
+
} catch {
|
|
2218
|
+
return "email_password";
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2208
2221
|
async forgotPassword({ email }) {
|
|
2209
2222
|
return this.account("/x/identity/password-reset", {
|
|
2210
2223
|
method: "POST",
|
|
@@ -2231,11 +2244,21 @@ var AuthService = class extends UserService {
|
|
|
2231
2244
|
return { errorCode: err.code ?? "invalid_token", message: err.message };
|
|
2232
2245
|
}
|
|
2233
2246
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2247
|
+
/** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
|
|
2248
|
+
async getOtp({ phone }) {
|
|
2249
|
+
const res = await this.account("/x/identity/otp", {
|
|
2250
|
+
method: "POST",
|
|
2251
|
+
body: { phone: String(phone ?? "").trim() }
|
|
2252
|
+
});
|
|
2253
|
+
return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
|
|
2236
2254
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2255
|
+
/** Signs in the account on `phone` with the code it was sent, opening one the first time. */
|
|
2256
|
+
async verifyOtp({ phone, otp }) {
|
|
2257
|
+
const auth = await this.account("/x/identity/otp/verify", {
|
|
2258
|
+
method: "POST",
|
|
2259
|
+
body: { phone: String(phone ?? "").trim(), code: String(otp ?? "").trim() }
|
|
2260
|
+
});
|
|
2261
|
+
return this.signedIn(auth);
|
|
2239
2262
|
}
|
|
2240
2263
|
async joinAsAdmin() {
|
|
2241
2264
|
throw new NotSupportedError("AuthService", "joinAsAdmin", "operators are invited from the admin panel");
|
|
@@ -2587,7 +2610,11 @@ var StoreService = class extends BaseService {
|
|
|
2587
2610
|
...flag(plugins.has("product-reviews"))
|
|
2588
2611
|
}
|
|
2589
2612
|
},
|
|
2590
|
-
...menus?.length ? { menu: menus } : {}
|
|
2613
|
+
...menus?.length ? { menu: menus } : {},
|
|
2614
|
+
// The one way this store signs customers in (D116), which the sign-in
|
|
2615
|
+
// form reads as PHONE or EMAIL. Without the accounts module the static
|
|
2616
|
+
// record says.
|
|
2617
|
+
...plugins.has("identity") ? { loginType: plugins.get("identity")?.settings?.login_method === "phone_otp" ? "PHONE" : "EMAIL" } : {}
|
|
2591
2618
|
};
|
|
2592
2619
|
}
|
|
2593
2620
|
};
|