@kivacore/signin 0.20.0 → 0.21.1

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/vue/index.js CHANGED
@@ -15,8 +15,9 @@ var DEFAULT_OAUTH_SCOPES = [
15
15
  "DS.Read.All"
16
16
  ];
17
17
  var DEFAULT_CALLBACK_PATH = "/auth/callback";
18
- var DEFAULT_ALLOWED_HOST_PATTERN = /^https:\/\/[^/]+\.docyrus\.app$/;
19
- var REDIRECT_RETURN_KEY = "docyrus_auth_return_url";
18
+ var DEFAULT_ALLOWED_HOST_PATTERN = /^https:\/\/[^/]+\.(?:kiva|docyrus)\.app$/;
19
+ var REDIRECT_RETURN_KEY = "kiva_auth_return_url";
20
+ var LEGACY_REDIRECT_RETURN_KEY = "docyrus_auth_return_url";
20
21
  var TOKEN_EXPIRY_BUFFER_SECONDS = 60;
21
22
  var MIN_TOKEN_REFRESH_INTERVAL_MS = 1e4;
22
23
  var IFRAME_TOKEN_REFRESH_TIMEOUT_MS = 1e4;
@@ -61,7 +62,7 @@ var StandaloneOAuth2Auth = class {
61
62
  const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
62
63
  if (!config.clientId) {
63
64
  throw new Error(
64
- 'DocyrusAuthProvider: "clientId" is required. Set it via the clientId prop or the VITE_DOCYRUS_CLIENT_ID / NEXT_PUBLIC_DOCYRUS_CLIENT_ID environment variable.'
65
+ 'KivaAuthProvider: "clientId" is required. Set it via the clientId prop or the VITE_KIVA_CLIENT_ID / NEXT_PUBLIC_KIVA_CLIENT_ID environment variable.'
65
66
  );
66
67
  }
67
68
  const { clientId } = config;
@@ -70,7 +71,7 @@ var StandaloneOAuth2Auth = class {
70
71
  const redirectUri = config.redirectUri ?? `${window.location.origin}${this.callbackPath}`;
71
72
  this.storage = config.tokenStorage ?? new BrowserOAuth2TokenStorage(
72
73
  window.localStorage,
73
- config.storageKeyPrefix ?? "docyrus_oauth2"
74
+ config.storageKeyPrefix ?? "kiva_oauth2"
74
75
  );
75
76
  this.oauth2Client = new OAuth2Client({
76
77
  baseURL: apiUrl,
@@ -124,8 +125,9 @@ var StandaloneOAuth2Auth = class {
124
125
  * Clears the stored value after retrieval.
125
126
  */
126
127
  getReturnUrl() {
127
- const url = window.localStorage.getItem(REDIRECT_RETURN_KEY);
128
+ const url = window.localStorage.getItem(REDIRECT_RETURN_KEY) ?? window.localStorage.getItem(LEGACY_REDIRECT_RETURN_KEY);
128
129
  window.localStorage.removeItem(REDIRECT_RETURN_KEY);
130
+ window.localStorage.removeItem(LEGACY_REDIRECT_RETURN_KEY);
129
131
  return url;
130
132
  }
131
133
  /** Get currently stored tokens (e.g., on page reload). */
@@ -187,7 +189,7 @@ function getJwtSessionKey(accessToken) {
187
189
  // src/core/iframe-auth.ts
188
190
  function postToHost(data) {
189
191
  const rnwv = window.ReactNativeWebView;
190
- const tap = window.__DOCYRUS_DEVTOOLS_MESSAGE_TAP__;
192
+ const tap = window.__KIVA_DEVTOOLS_MESSAGE_TAP__ ?? window.__DOCYRUS_DEVTOOLS_MESSAGE_TAP__;
191
193
  if (rnwv && typeof rnwv.postMessage === "function") {
192
194
  if (typeof tap === "function") tap("out", data, { transport: "webview" });
193
195
  rnwv.postMessage(JSON.stringify(data));
@@ -593,7 +595,7 @@ var IframeAuth = class {
593
595
  try {
594
596
  handler(message);
595
597
  } catch (err) {
596
- console.warn("[docyrus-signin] guidy command handler threw:", err);
598
+ console.warn("[kiva-signin] guidy command handler threw:", err);
597
599
  }
598
600
  }
599
601
  }
@@ -619,7 +621,7 @@ var IframeAuth = class {
619
621
  try {
620
622
  handler(message);
621
623
  } catch (err) {
622
- console.warn("[docyrus-signin] host navigation handler threw:", err);
624
+ console.warn("[kiva-signin] host navigation handler threw:", err);
623
625
  }
624
626
  }
625
627
  }
@@ -632,7 +634,7 @@ var IframeAuth = class {
632
634
  try {
633
635
  handler(notification);
634
636
  } catch (err) {
635
- console.warn("[docyrus-signin] host notification handler threw:", err);
637
+ console.warn("[kiva-signin] host notification handler threw:", err);
636
638
  }
637
639
  }
638
640
  }
@@ -1011,17 +1013,17 @@ var ReactNativeOAuth2Auth = class {
1011
1013
  const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
1012
1014
  if (!config.clientId) {
1013
1015
  throw new Error(
1014
- 'DocyrusAuthProvider: "clientId" is required for React Native mode.'
1016
+ 'KivaAuthProvider: "clientId" is required for React Native mode.'
1015
1017
  );
1016
1018
  }
1017
1019
  if (!config.nativeRedirectUri) {
1018
1020
  throw new Error(
1019
- `DocyrusAuthProvider: "nativeRedirectUri" is required for React Native mode. Set it to your app's deep link URI (e.g., "myapp://auth/callback").`
1021
+ `KivaAuthProvider: "nativeRedirectUri" is required for React Native mode. Set it to your app's deep link URI (e.g., "myapp://auth/callback").`
1020
1022
  );
1021
1023
  }
1022
1024
  if (!config.openAuthSession) {
1023
1025
  throw new Error(
1024
- 'DocyrusAuthProvider: "openAuthSession" is required for React Native mode. Pass WebBrowser.openAuthSessionAsync from expo-web-browser.'
1026
+ 'KivaAuthProvider: "openAuthSession" is required for React Native mode. Pass WebBrowser.openAuthSessionAsync from expo-web-browser.'
1025
1027
  );
1026
1028
  }
1027
1029
  const scopes = config.scopes ?? DEFAULT_OAUTH_SCOPES;
@@ -1080,7 +1082,12 @@ var ReactNativeOAuth2Auth = class {
1080
1082
  };
1081
1083
 
1082
1084
  // src/core/cookie-sync.ts
1083
- var DEFAULT_SSR_COOKIE_KEY = "docyrus-token";
1085
+ var DEFAULT_SSR_COOKIE_KEY = "kiva-token";
1086
+ var LEGACY_SSR_COOKIE_KEY = "docyrus-token";
1087
+ function removeCookie(key) {
1088
+ const secure = window.location.protocol === "https:" ? ";Secure" : "";
1089
+ document.cookie = `${key}=;path=/;max-age=0;SameSite=Lax${secure}`;
1090
+ }
1084
1091
  function syncTokenToCookie(accessToken, cookieKey, expiresAt) {
1085
1092
  if (typeof document === "undefined") return;
1086
1093
  const key = cookieKey ?? DEFAULT_SSR_COOKIE_KEY;
@@ -1091,12 +1098,13 @@ function syncTokenToCookie(accessToken, cookieKey, expiresAt) {
1091
1098
  if (seconds > 0) maxAge = `;max-age=${seconds}`;
1092
1099
  }
1093
1100
  document.cookie = `${key}=${encodeURIComponent(accessToken)};path=/;SameSite=Lax${secure}${maxAge}`;
1101
+ if (key === DEFAULT_SSR_COOKIE_KEY) removeCookie(LEGACY_SSR_COOKIE_KEY);
1094
1102
  }
1095
1103
  function clearTokenCookie(cookieKey) {
1096
1104
  if (typeof document === "undefined") return;
1097
1105
  const key = cookieKey ?? DEFAULT_SSR_COOKIE_KEY;
1098
- const secure = window.location.protocol === "https:" ? ";Secure" : "";
1099
- document.cookie = `${key}=;path=/;max-age=0;SameSite=Lax${secure}`;
1106
+ removeCookie(key);
1107
+ if (key === DEFAULT_SSR_COOKIE_KEY) removeCookie(LEGACY_SSR_COOKIE_KEY);
1100
1108
  }
1101
1109
 
1102
1110
  // src/core/host-api-url.ts
@@ -1105,7 +1113,11 @@ var LOOPBACK_HOSTS = [
1105
1113
  "127.0.0.1",
1106
1114
  "[::1]"
1107
1115
  ];
1108
- var TRUSTED_DOMAINS = ["docyrus.com", "attornaid.com"];
1116
+ var TRUSTED_DOMAINS = [
1117
+ "kiva.app",
1118
+ "docyrus.com",
1119
+ "attornaid.com"
1120
+ ];
1109
1121
  function readHostApiUrl() {
1110
1122
  if (typeof window === "undefined" || !window.location) return void 0;
1111
1123
  const params = new URLSearchParams(window.location.search);
@@ -1213,7 +1225,7 @@ var AuthManager = class {
1213
1225
  /** Initialize the auth manager. Must be called once on mount. */
1214
1226
  async initialize() {
1215
1227
  if (this.status === "error") {
1216
- console.error("[docyrus-signin]", UNTRUSTED_BACKEND_MESSAGE);
1228
+ console.error("[kiva-signin]", UNTRUSTED_BACKEND_MESSAGE);
1217
1229
  this.notify();
1218
1230
  return;
1219
1231
  }
@@ -1255,7 +1267,7 @@ var AuthManager = class {
1255
1267
  ssoAuth.cleanUrl();
1256
1268
  return;
1257
1269
  } catch (err) {
1258
- console.warn("[docyrus-signin] SSO token exchange failed:", err);
1270
+ console.warn("[kiva-signin] SSO token exchange failed:", err);
1259
1271
  }
1260
1272
  }
1261
1273
  }
@@ -1311,7 +1323,7 @@ var AuthManager = class {
1311
1323
  try {
1312
1324
  handler(message);
1313
1325
  } catch (err) {
1314
- console.warn("[docyrus-signin] host navigation handler threw:", err);
1326
+ console.warn("[kiva-signin] host navigation handler threw:", err);
1315
1327
  }
1316
1328
  }
1317
1329
  });
@@ -1320,7 +1332,7 @@ var AuthManager = class {
1320
1332
  try {
1321
1333
  handler(notification);
1322
1334
  } catch (err) {
1323
- console.warn("[docyrus-signin] host notification handler threw:", err);
1335
+ console.warn("[kiva-signin] host notification handler threw:", err);
1324
1336
  }
1325
1337
  }
1326
1338
  });
@@ -1773,24 +1785,24 @@ var AuthManager = class {
1773
1785
  };
1774
1786
 
1775
1787
  // src/vue/index.ts
1776
- var DOCYRUS_AUTH_KEY = /* @__PURE__ */ Symbol("docyrus-auth");
1777
- function getDocyrusAuth() {
1778
- const context = inject(DOCYRUS_AUTH_KEY);
1788
+ var KIVA_AUTH_KEY = /* @__PURE__ */ Symbol("kiva-auth");
1789
+ function getKivaAuth() {
1790
+ const context = inject(KIVA_AUTH_KEY);
1779
1791
  if (!context) {
1780
1792
  throw new Error(
1781
- "getDocyrusAuth() must be used within a <DocyrusAuthProvider>. Wrap your app with <DocyrusAuthProvider> to provide auth context."
1793
+ "getKivaAuth() must be used within a <KivaAuthProvider>. Wrap your app with <KivaAuthProvider> to provide auth context."
1782
1794
  );
1783
1795
  }
1784
1796
  return context;
1785
1797
  }
1786
- var useDocyrusAuth = getDocyrusAuth;
1787
- function getDocyrusClient() {
1788
- const auth = getDocyrusAuth();
1798
+ var useKivaAuth = getKivaAuth;
1799
+ function getKivaClient() {
1800
+ const auth = getKivaAuth();
1789
1801
  return computed(() => auth.client);
1790
1802
  }
1791
- var useDocyrusClient = getDocyrusClient;
1792
- var DocyrusAuthProvider = defineComponent({
1793
- name: "DocyrusAuthProvider",
1803
+ var useKivaClient = getKivaClient;
1804
+ var KivaAuthProvider = defineComponent({
1805
+ name: "KivaAuthProvider",
1794
1806
  props: {
1795
1807
  clientId: { type: String, default: void 0 },
1796
1808
  apiUrl: { type: String, default: void 0 },
@@ -1899,7 +1911,7 @@ var DocyrusAuthProvider = defineComponent({
1899
1911
  sendToEmail,
1900
1912
  sendToCalendar
1901
1913
  };
1902
- provide(DOCYRUS_AUTH_KEY, authState);
1914
+ provide(KIVA_AUTH_KEY, authState);
1903
1915
  onMounted(() => {
1904
1916
  manager = bootManager;
1905
1917
  mode.value = manager.getMode();
@@ -1924,16 +1936,19 @@ var DocyrusAuthProvider = defineComponent({
1924
1936
  }
1925
1937
  });
1926
1938
  var ICON_SIZE = 20;
1927
- var LOGO_PATH = "M768.11,531.68l-.24.21v101.17c0,26.8-21.79,48.63-48.59,48.63h-101.17c-8.72,0-16.82-2.33-23.88-6.35l-113.69,113.73c7.41,11.02,11.77,24.33,11.77,38.47,0,18.98-7.62,36.17-20.04,48.63-12.42,12.42-29.65,20.04-48.63,20.04s-36.2-7.62-48.63-20.04c-12.42-12.46-20.04-29.65-20.04-48.63,0-37.96,30.75-68.91,68.87-68.91,14.48,0,27.76,4.43,38.78,11.94l113.62-113.62c-4.19-7.1-6.55-15.31-6.55-24.09v-101.17c0-11.12,3.81-21.48,10.19-29.68l-93.72-127.52h-229.96V127.7h246.57v225.88l97.6,132.84c5.56-2.23,11.63-3.36,17.95-3.36h101.17c26.8,0,48.63,21.83,48.63,48.63Z";
1928
- function renderDocyrusLogo(size = ICON_SIZE) {
1939
+ var MARK_VIEW_BOX = "0 0 1914 1145";
1940
+ var MARK_TRANSFORM = "matrix(1 0 0 -1 0 1145)";
1941
+ var MARK_PATH = "M338 1144 c-3 -1 -8 -3 -10 -4 -11 -6 -9 -3 -106 -169 -49 -86 -92 -159 -94 -163 -3 -4 -11 -18 -19 -31 -36 -65 -91 -162 -97 -171 -10 -16 -11 -20 -11 -33 0 -14 1 -19 11 -35 4 -6 17 -28 29 -49 12 -21 38 -67 58 -101 20 -34 76 -131 124 -215 49 -84 90 -155 92 -157 4 -6 11 -11 19 -14 l6 -2 151 0 150 1 3 3 c4 4 4 11 0 17 -3 5 -274 474 -276 479 -1 1 -11 19 -22 38 l-21 36 157 270 c86 148 158 272 160 276 7 11 6 20 -2 24 -4 2 -295 2 -302 0z M744 1144 c-1 -1 -4 -4 -5 -7 -2 -3 -35 -60 -75 -127 -48 -82 -71 -124 -73 -128 -2 -8 -1 -22 2 -31 1 -4 46 -82 102 -179 55 -94 163 -280 240 -413 99 -171 141 -243 145 -247 3 -4 7 -6 11 -8 l7 -3 151 -1 c132 0 152 0 157 1 7 3 16 9 21 18 12 17 471 810 482 832 3 7 4 8 4 16 0 5 0 10 -1 12 -2 5 -148 259 -151 262 -5 6 -12 5 -18 -3 -2 -2 -69 -119 -151 -259 -81 -141 -149 -257 -150 -258 -1 -2 -10 -17 -19 -34 -10 -17 -33 -58 -52 -91 -19 -33 -50 -86 -69 -119 -54 -93 -51 -88 -52 -87 -1 1 -10 18 -21 37 -11 19 -20 35 -20 34 -1 0 -108 185 -123 214 -7 13 -16 28 -19 33 -2 5 -72 125 -154 267 -83 141 -151 259 -153 261 -2 4 -9 9 -12 9 -1 0 -3 -1 -4 -1z";
1942
+ var MARK_ACCENT_PATH = "M307 544 c-45 -78 -135 -234 -141 -244 -1 -2 -2 -3 -2 -3 1 0 3 3 5 7 7 11 29 42 40 56 49 64 101 111 147 134 l12 6 -9 16 c-21 35 -33 57 -34 57 0 1 -8 -13 -18 -29z M1209 339 c-1 -24 -3 -39 -8 -64 -12 -56 -38 -126 -74 -198 -7 -15 -13 -27 -13 -27 1 0 32 54 69 120 56 96 69 119 67 119 0 1 -9 17 -20 36 -10 18 -19 34 -20 35 0 1 -1 -7 -1 -21z";
1943
+ function renderKivaLogo(size = ICON_SIZE) {
1929
1944
  return h("svg", {
1930
1945
  xmlns: "http://www.w3.org/2000/svg",
1931
- viewBox: "0 0 1024 1024",
1946
+ viewBox: MARK_VIEW_BOX,
1932
1947
  width: size,
1933
1948
  height: size,
1934
1949
  "aria-hidden": "true",
1935
1950
  style: { display: "block", flexShrink: 0 }
1936
- }, [h("path", { fill: "#dc2626", d: LOGO_PATH })]);
1951
+ }, [h("path", { fill: "#2887EB", transform: MARK_TRANSFORM, d: MARK_PATH }), h("path", { fill: "#58595B", transform: MARK_TRANSFORM, d: MARK_ACCENT_PATH })]);
1937
1952
  }
1938
1953
  function renderSpinner(size = ICON_SIZE) {
1939
1954
  return h("svg", {
@@ -1943,7 +1958,7 @@ function renderSpinner(size = ICON_SIZE) {
1943
1958
  height: size,
1944
1959
  fill: "none",
1945
1960
  "aria-hidden": "true",
1946
- style: { display: "block", flexShrink: 0, animation: "docyrus-spin 1s linear infinite" }
1961
+ style: { display: "block", flexShrink: 0, animation: "kiva-spin 1s linear infinite" }
1947
1962
  }, [
1948
1963
  h("circle", {
1949
1964
  cx: 12,
@@ -1959,19 +1974,19 @@ function renderSpinner(size = ICON_SIZE) {
1959
1974
  "stroke-width": 3,
1960
1975
  "stroke-linecap": "round"
1961
1976
  }),
1962
- h("style", {}, "@keyframes docyrus-spin{to{transform:rotate(360deg)}}")
1977
+ h("style", {}, "@keyframes kiva-spin{to{transform:rotate(360deg)}}")
1963
1978
  ]);
1964
1979
  }
1965
1980
  var SignInButton = defineComponent({
1966
1981
  name: "SignInButton",
1967
1982
  props: {
1968
- label: { type: String, default: "Sign in with Docyrus" },
1983
+ label: { type: String, default: "Sign in with Kiva" },
1969
1984
  disabled: { type: Boolean, default: false }
1970
1985
  },
1971
1986
  setup(props, { slots, attrs }) {
1972
- const auth = inject(DOCYRUS_AUTH_KEY);
1987
+ const auth = inject(KIVA_AUTH_KEY);
1973
1988
  if (!auth) {
1974
- throw new Error("SignInButton must be used within a <DocyrusAuthProvider>.");
1989
+ throw new Error("SignInButton must be used within a <KivaAuthProvider>.");
1975
1990
  }
1976
1991
  const { signIn, status, mode } = auth;
1977
1992
  return () => {
@@ -1995,12 +2010,17 @@ var SignInButton = defineComponent({
1995
2010
  },
1996
2011
  ...attrs
1997
2012
  },
1998
- [isLoading ? renderSpinner() : renderDocyrusLogo(), h("span", {}, props.label)]
2013
+ [isLoading ? renderSpinner() : renderKivaLogo(), h("span", {}, props.label)]
1999
2014
  );
2000
2015
  };
2001
2016
  }
2002
2017
  });
2018
+ var getDocyrusAuth = getKivaAuth;
2019
+ var getDocyrusClient = getKivaClient;
2020
+ var useDocyrusAuth = useKivaAuth;
2021
+ var useDocyrusClient = useKivaClient;
2022
+ var DocyrusAuthProvider = KivaAuthProvider;
2003
2023
 
2004
- export { DocyrusAuthProvider, SignInButton, getDocyrusAuth, getDocyrusClient, useDocyrusAuth, useDocyrusClient };
2024
+ export { DocyrusAuthProvider, KivaAuthProvider, SignInButton, getDocyrusAuth, getDocyrusClient, getKivaAuth, getKivaClient, useDocyrusAuth, useDocyrusClient, useKivaAuth, useKivaClient };
2005
2025
  //# sourceMappingURL=index.js.map
2006
2026
  //# sourceMappingURL=index.js.map