@sanvika/auth 2.10.1 → 2.10.2
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.js +15 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,6 +39,11 @@ var CLIENT_MOBILE_POLICIES = Object.freeze({
|
|
|
39
39
|
format: "IN_10",
|
|
40
40
|
defaultCountryCode: "91",
|
|
41
41
|
allowedDialCodes: ["91"]
|
|
42
|
+
},
|
|
43
|
+
/** SuperAdmin panel — E.164 digits-only SSOT; must match User.mobile exactly (no IN_10 alias lookup). */
|
|
44
|
+
ADMIN_E164: {
|
|
45
|
+
format: "E164",
|
|
46
|
+
defaultCountryCode: "91"
|
|
42
47
|
}
|
|
43
48
|
});
|
|
44
49
|
|
|
@@ -162,20 +167,6 @@ function normalizeMobileWithPolicy(raw, policy = DEFAULT_MOBILE_POLICY) {
|
|
|
162
167
|
function isValidMobileWithPolicy(raw, policy = DEFAULT_MOBILE_POLICY) {
|
|
163
168
|
return normalizeMobileWithPolicy(raw, policy) != null;
|
|
164
169
|
}
|
|
165
|
-
function getMobileLookupValues(normalized, policy = DEFAULT_MOBILE_POLICY) {
|
|
166
|
-
if (!normalized) return [];
|
|
167
|
-
const p = mergeMobilePolicy(policy);
|
|
168
|
-
const values = /* @__PURE__ */ new Set([normalized]);
|
|
169
|
-
if (p.format !== MOBILE_FORMAT.IN_10) {
|
|
170
|
-
if (normalized.startsWith("91") && normalized.length === 12) {
|
|
171
|
-
values.add(normalized.slice(2));
|
|
172
|
-
}
|
|
173
|
-
if (/^\d{10}$/.test(normalized)) {
|
|
174
|
-
values.add(`91${normalized}`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return [...values];
|
|
178
|
-
}
|
|
179
170
|
function formatMobileForDisplay(normalized, policy = DEFAULT_MOBILE_POLICY) {
|
|
180
171
|
if (!normalized) return "";
|
|
181
172
|
const p = mergeMobilePolicy(policy);
|
|
@@ -213,13 +204,10 @@ function toIndiaE164FromLegacyIn10(mobile) {
|
|
|
213
204
|
return `91${d}`;
|
|
214
205
|
}
|
|
215
206
|
function mobilesMatchIdentity(stored, candidate) {
|
|
216
|
-
const policy = { format: MOBILE_FORMAT.E164 };
|
|
217
207
|
const a = digitsOnly(stored);
|
|
218
208
|
const b = digitsOnly(candidate);
|
|
219
209
|
if (!a || !b) return false;
|
|
220
|
-
|
|
221
|
-
const aliasA = new Set(getMobileLookupValues(a, policy));
|
|
222
|
-
return getMobileLookupValues(b, policy).some((v) => aliasA.has(v));
|
|
210
|
+
return a === b;
|
|
223
211
|
}
|
|
224
212
|
|
|
225
213
|
// authFlow.js
|
|
@@ -290,7 +278,8 @@ async function checkMobile({
|
|
|
290
278
|
mobile: normalized,
|
|
291
279
|
deviceId,
|
|
292
280
|
clientId,
|
|
293
|
-
...callbackUrl ? { callbackUrl } : {}
|
|
281
|
+
...callbackUrl ? { callbackUrl } : {},
|
|
282
|
+
...mobilePolicy ? { mobilePolicy: mergeMobilePolicy(mobilePolicy) } : {}
|
|
294
283
|
})
|
|
295
284
|
});
|
|
296
285
|
const data = await res.json();
|
|
@@ -320,6 +309,9 @@ async function postLogin({
|
|
|
320
309
|
if (password) {
|
|
321
310
|
body.password = password;
|
|
322
311
|
}
|
|
312
|
+
if (mobilePolicy) {
|
|
313
|
+
body.mobilePolicy = mergeMobilePolicy(mobilePolicy);
|
|
314
|
+
}
|
|
323
315
|
const res = await fetch(authApiUrl(AUTH_API.LOGIN, authBaseUrl), {
|
|
324
316
|
method: "POST",
|
|
325
317
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1245,7 +1237,7 @@ function mobilePlaceholder(config) {
|
|
|
1245
1237
|
// SanvikaAdminLogin.jsx
|
|
1246
1238
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1247
1239
|
var DEVICE_ID_KEY = "sanvika_admin_device_id";
|
|
1248
|
-
var ADMIN_MOBILE_POLICY = CLIENT_MOBILE_POLICIES.
|
|
1240
|
+
var ADMIN_MOBILE_POLICY = CLIENT_MOBILE_POLICIES.ADMIN_E164;
|
|
1249
1241
|
function getDeviceId() {
|
|
1250
1242
|
var _a;
|
|
1251
1243
|
if (typeof window === "undefined") return "";
|
|
@@ -1431,7 +1423,7 @@ function SanvikaAdminLogin({
|
|
|
1431
1423
|
serviceName,
|
|
1432
1424
|
" Admin"
|
|
1433
1425
|
] }),
|
|
1434
|
-
/* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "SuperAdmin access \u2014 Sanvika Accounts
|
|
1426
|
+
/* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "SuperAdmin access \u2014 enter mobile with country code (E.164, as stored in Sanvika Accounts)" }),
|
|
1435
1427
|
/* @__PURE__ */ jsxs4("form", { onSubmit: handleLogin, style: S.form, autoComplete: "off", children: [
|
|
1436
1428
|
/* @__PURE__ */ jsx5("label", { style: S.label, htmlFor: "admin-mobile-phone", children: "Mobile Number" }),
|
|
1437
1429
|
/* @__PURE__ */ jsx5(
|
|
@@ -1442,8 +1434,8 @@ function SanvikaAdminLogin({
|
|
|
1442
1434
|
onChange: setPhoneValue,
|
|
1443
1435
|
theme: "dark",
|
|
1444
1436
|
id: "admin-mobile-phone",
|
|
1445
|
-
placeholder: "
|
|
1446
|
-
showPreview:
|
|
1437
|
+
placeholder: "Include country code, e.g. +91 88002 18812",
|
|
1438
|
+
showPreview: true
|
|
1447
1439
|
}
|
|
1448
1440
|
),
|
|
1449
1441
|
/* @__PURE__ */ jsx5("label", { style: S.label, children: "Password" }),
|