@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
package/dist/services/index.cjs
CHANGED
|
@@ -2186,6 +2186,19 @@ var UserService = class extends BaseService {
|
|
|
2186
2186
|
}
|
|
2187
2187
|
};
|
|
2188
2188
|
var AuthService = class extends UserService {
|
|
2189
|
+
facts = new StoreFacts(this._fetch);
|
|
2190
|
+
/**
|
|
2191
|
+
* How this store signs customers in: `email_password` or `phone_otp`.
|
|
2192
|
+
* A store whose accounts module says nothing signs in by email.
|
|
2193
|
+
*/
|
|
2194
|
+
async loginMethod() {
|
|
2195
|
+
try {
|
|
2196
|
+
const method = (await this.facts.plugins()).get("identity")?.settings?.login_method;
|
|
2197
|
+
return method === "phone_otp" ? "phone_otp" : "email_password";
|
|
2198
|
+
} catch {
|
|
2199
|
+
return "email_password";
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2189
2202
|
async forgotPassword({ email }) {
|
|
2190
2203
|
return this.account("/x/identity/password-reset", {
|
|
2191
2204
|
method: "POST",
|
|
@@ -2212,11 +2225,21 @@ var AuthService = class extends UserService {
|
|
|
2212
2225
|
return { errorCode: err.code ?? "invalid_token", message: err.message };
|
|
2213
2226
|
}
|
|
2214
2227
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2228
|
+
/** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
|
|
2229
|
+
async getOtp({ phone }) {
|
|
2230
|
+
const res = await this.account("/x/identity/otp", {
|
|
2231
|
+
method: "POST",
|
|
2232
|
+
body: { phone: String(phone ?? "").trim() }
|
|
2233
|
+
});
|
|
2234
|
+
return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
|
|
2217
2235
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2236
|
+
/** Signs in the account on `phone` with the code it was sent, opening one the first time. */
|
|
2237
|
+
async verifyOtp({ phone, otp }) {
|
|
2238
|
+
const auth = await this.account("/x/identity/otp/verify", {
|
|
2239
|
+
method: "POST",
|
|
2240
|
+
body: { phone: String(phone ?? "").trim(), code: String(otp ?? "").trim() }
|
|
2241
|
+
});
|
|
2242
|
+
return this.signedIn(auth);
|
|
2220
2243
|
}
|
|
2221
2244
|
async joinAsAdmin() {
|
|
2222
2245
|
throw new NotSupportedError("AuthService", "joinAsAdmin", "operators are invited from the admin panel");
|
|
@@ -2571,7 +2594,11 @@ var StoreService = class extends BaseService {
|
|
|
2571
2594
|
...flag(plugins.has("product-reviews"))
|
|
2572
2595
|
}
|
|
2573
2596
|
},
|
|
2574
|
-
...menus?.length ? { menu: menus } : {}
|
|
2597
|
+
...menus?.length ? { menu: menus } : {},
|
|
2598
|
+
// The one way this store signs customers in (D116), which the sign-in
|
|
2599
|
+
// form reads as PHONE or EMAIL. Without the accounts module the static
|
|
2600
|
+
// record says.
|
|
2601
|
+
...plugins.has("identity") ? { loginType: plugins.get("identity")?.settings?.login_method === "phone_otp" ? "PHONE" : "EMAIL" } : {}
|
|
2575
2602
|
};
|
|
2576
2603
|
}
|
|
2577
2604
|
};
|