@sanvika/auth 2.10.1 → 2.10.3

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -24
  2. 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
- if (a === b) return true;
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" },
@@ -1109,7 +1101,7 @@ function PolicySearchableCountrySelect({
1109
1101
  import "react-phone-number-input/style.css";
1110
1102
 
1111
1103
  // MobilePolicyPhoneInput.css
1112
- styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--searchable-country .PhoneInput {\n overflow: visible;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n}\n.sa-phone-input .PhoneInputCountry {\n position: relative;\n flex: 0 0 auto;\n align-self: stretch;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-width: 5.25rem;\n max-width: 6.75rem;\n border-right: 1px solid #dddddd;\n background: #f5f5f5;\n}\n.sa-phone-input--dark .PhoneInputCountry {\n border-right-color: #333333;\n background: #2a2a2a;\n}\n.sa-phone-input--searchable-country .PhoneInputCountryIcon,\n.sa-phone-input--searchable-country .PhoneInputCountryIconUnicode,\n.sa-phone-input--searchable-country .PhoneInputCountrySelectArrow {\n display: none !important;\n}\n.sa-phone-input .PhoneInputInput {\n flex: 1 1 auto;\n min-width: 0;\n width: 100%;\n border: none;\n outline: none;\n padding: 10px 12px;\n font-size: 15px;\n background: transparent;\n color: #222222;\n}\n.sa-phone-input--dark .PhoneInputInput {\n color: #ffffff;\n}\n.sa-phone-input .PhoneInputInput::placeholder {\n color: #999999;\n}\n.sa-phone-input--dark .PhoneInputInput::placeholder {\n color: #666666;\n}\n.sa-country-picker {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 42px;\n}\n.sa-country-picker__trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n width: 100%;\n height: 100%;\n min-height: 42px;\n padding: 0 8px;\n margin: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n color: inherit;\n font: inherit;\n}\n.sa-country-picker__trigger:disabled {\n cursor: default;\n opacity: 0.65;\n}\n.sa-country-picker__flag {\n font-size: 1.15rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__dial {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n flex-shrink: 0;\n}\n.sa-country-picker__chev {\n font-size: 10px;\n opacity: 0.7;\n flex-shrink: 0;\n margin-left: 1px;\n}\n.sa-country-picker__panel {\n position: absolute;\n top: calc(100% + 4px);\n left: 0;\n z-index: 50;\n width: min(20rem, calc(100vw - 2rem));\n max-height: min(20rem, 55vh);\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n border: 1px solid #dddddd;\n background: #ffffff;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);\n overflow: hidden;\n}\n.sa-phone-input--dark .sa-country-picker__panel {\n border-color: #444444;\n background: #1e1e1e;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);\n}\n.sa-country-picker__search {\n flex-shrink: 0;\n width: 100%;\n padding: 10px 12px;\n border: none;\n border-bottom: 1px solid #eeeeee;\n outline: none;\n font-size: 14px;\n background: #fafafa;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__search {\n border-bottom-color: #333333;\n background: #252525;\n color: #ffffff;\n}\n.sa-country-picker__list {\n list-style: none;\n margin: 0;\n padding: 4px 0;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n.sa-country-picker__option {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: transparent;\n cursor: pointer;\n text-align: left;\n font-size: 14px;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__option {\n color: #eeeeee;\n}\n.sa-country-picker__option:hover,\n.sa-country-picker__option--active {\n background: #f0f4ff;\n}\n.sa-phone-input--dark .sa-country-picker__option:hover,\n.sa-phone-input--dark .sa-country-picker__option--active {\n background: #2a3344;\n}\n.sa-country-picker__option-flag {\n font-size: 1.1rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sa-country-picker__code {\n flex-shrink: 0;\n font-size: 12px;\n font-weight: 600;\n color: #666666;\n}\n.sa-phone-input--dark .sa-country-picker__code {\n color: #999999;\n}\n.sa-country-picker__empty {\n padding: 12px;\n font-size: 13px;\n color: #888888;\n text-align: center;\n}\n.sa-phone-preview {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 10px;\n margin-top: 8px;\n padding: 8px 10px;\n border-radius: 6px;\n font-size: 12px;\n background: #f0f7ff;\n border: 1px solid #cce4ff;\n}\n.sa-phone-preview--dark {\n background: #1a2433;\n border-color: #2a3f5f;\n}\n.sa-phone-preview__label {\n font-weight: 600;\n color: #555555;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n font-size: 10px;\n}\n.sa-phone-preview--dark .sa-phone-preview__label {\n color: #8899aa;\n}\n.sa-phone-preview__value {\n color: #0984e3;\n font-weight: 500;\n}\n.sa-phone-preview--dark .sa-phone-preview__value {\n color: #88c5ff;\n}\n.sa-phone-preview__e164 {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #333333;\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 6px;\n border-radius: 4px;\n}\n.sa-phone-preview--dark .sa-phone-preview__e164 {\n color: #cccccc;\n background: rgba(255, 255, 255, 0.06);\n}\n");
1104
+ styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--searchable-country .PhoneInput {\n overflow: visible;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n color: #f1f5f9;\n}\n.sa-phone-input .PhoneInputCountry {\n position: relative;\n flex: 0 0 auto;\n align-self: stretch;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-width: 5.25rem;\n max-width: 6.75rem;\n border-right: 1px solid #dddddd;\n background: #f5f5f5;\n}\n.sa-phone-input--dark .PhoneInputCountry {\n border-right-color: #333333;\n background: #2a2a2a;\n color: #f1f5f9;\n}\n.sa-phone-input--searchable-country .PhoneInputCountryIcon,\n.sa-phone-input--searchable-country .PhoneInputCountryIconUnicode,\n.sa-phone-input--searchable-country .PhoneInputCountrySelectArrow {\n display: none !important;\n}\n.sa-phone-input .PhoneInputInput {\n flex: 1 1 auto;\n min-width: 0;\n width: 100%;\n border: none;\n outline: none;\n padding: 10px 12px;\n font-size: 15px;\n background: transparent;\n color: #222222;\n}\n.sa-phone-input--dark .PhoneInputInput {\n color: #ffffff;\n}\n.sa-phone-input .PhoneInputInput::placeholder {\n color: #999999;\n}\n.sa-phone-input--dark .PhoneInputInput::placeholder {\n color: #666666;\n}\n.sa-country-picker {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 42px;\n}\n.sa-country-picker__trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n width: 100%;\n height: 100%;\n min-height: 42px;\n padding: 0 8px;\n margin: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n color: #222222;\n font: inherit;\n}\n.sa-phone-input--dark .sa-country-picker__trigger {\n color: #f1f5f9;\n}\n.sa-country-picker__trigger:disabled {\n cursor: default;\n opacity: 0.65;\n}\n.sa-country-picker__flag {\n font-size: 1.15rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__dial {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n flex-shrink: 0;\n color: #333333;\n}\n.sa-phone-input--dark .sa-country-picker__dial {\n color: #f8fafc;\n}\n.sa-country-picker__chev {\n font-size: 10px;\n opacity: 0.7;\n flex-shrink: 0;\n margin-left: 1px;\n}\n.sa-phone-input--dark .sa-country-picker__chev {\n color: #cbd5e1;\n opacity: 0.9;\n}\n.sa-country-picker__panel {\n position: absolute;\n top: calc(100% + 4px);\n left: 0;\n z-index: 50;\n width: min(20rem, calc(100vw - 2rem));\n max-height: min(20rem, 55vh);\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n border: 1px solid #dddddd;\n background: #ffffff;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);\n overflow: hidden;\n}\n.sa-phone-input--dark .sa-country-picker__panel {\n border-color: #444444;\n background: #1e1e1e;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);\n}\n.sa-country-picker__search {\n flex-shrink: 0;\n width: 100%;\n padding: 10px 12px;\n border: none;\n border-bottom: 1px solid #eeeeee;\n outline: none;\n font-size: 14px;\n background: #fafafa;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__search {\n border-bottom-color: #333333;\n background: #252525;\n color: #ffffff;\n}\n.sa-country-picker__list {\n list-style: none;\n margin: 0;\n padding: 4px 0;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n.sa-country-picker__option {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: transparent;\n cursor: pointer;\n text-align: left;\n font-size: 14px;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__option {\n color: #eeeeee;\n}\n.sa-country-picker__option:hover,\n.sa-country-picker__option--active {\n background: #f0f4ff;\n}\n.sa-phone-input--dark .sa-country-picker__option:hover,\n.sa-phone-input--dark .sa-country-picker__option--active {\n background: #2a3344;\n}\n.sa-country-picker__option-flag {\n font-size: 1.1rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sa-country-picker__code {\n flex-shrink: 0;\n font-size: 12px;\n font-weight: 600;\n color: #666666;\n}\n.sa-phone-input--dark .sa-country-picker__code {\n color: #999999;\n}\n.sa-country-picker__empty {\n padding: 12px;\n font-size: 13px;\n color: #888888;\n text-align: center;\n}\n.sa-phone-preview {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 10px;\n margin-top: 8px;\n padding: 8px 10px;\n border-radius: 6px;\n font-size: 12px;\n background: #f0f7ff;\n border: 1px solid #cce4ff;\n}\n.sa-phone-preview--dark {\n background: #1a2433;\n border-color: #2a3f5f;\n}\n.sa-phone-preview__label {\n font-weight: 600;\n color: #555555;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n font-size: 10px;\n}\n.sa-phone-preview--dark .sa-phone-preview__label {\n color: #8899aa;\n}\n.sa-phone-preview__value {\n color: #0984e3;\n font-weight: 500;\n}\n.sa-phone-preview--dark .sa-phone-preview__value {\n color: #88c5ff;\n}\n.sa-phone-preview__e164 {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #333333;\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 6px;\n border-radius: 4px;\n}\n.sa-phone-preview--dark .sa-phone-preview__e164 {\n color: #cccccc;\n background: rgba(255, 255, 255, 0.06);\n}\n");
1113
1105
 
1114
1106
  // MobilePolicyPhoneInput.jsx
1115
1107
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -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.IN_10;
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 SSO" }),
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: "Enter phone number",
1446
- showPreview: false
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" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "2.10.1",
3
+ "version": "2.10.3",
4
4
  "description": "Sanvika Auth SDK — React components/hooks + server-side token verification and user proxy",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",