@hellocoop/vue 2.1.7 → 2.1.10

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/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  [Hellō](https://hello.dev) is an identity network that provides login and registration using the standard OpenID Connect protocol. Hellō offers your users choice between all popular social login providers.
4
4
 
5
5
  This [Vue](https://vuejs.org/) package provides:
6
+
6
7
  - Vue components for buttons and logged in context
7
8
 
8
9
  See the [Vue SDK documentation](https://www.hello.dev/docs/sdks/vue) for details.
9
-
10
-
@@ -27,5 +27,5 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
27
27
  promptConsent: boolean;
28
28
  loginHint: string;
29
29
  domainHint: string;
30
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
30
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLButtonElement>;
31
31
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLButtonElement>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLButtonElement>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLButtonElement>;
2
2
  export default _default;
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@ export { default as LoggedIn } from './login-status/LoggedIn.vue';
5
5
  export { default as LoggedOut } from './login-status/LoggedOut.vue';
6
6
  export * from './auth.js';
7
7
  export * from './logout.js';
8
- export { default as HelloProvider, routeConfig, useHelloProviderContext } from './provider.js';
8
+ export { default as HelloProvider, routeConfig, useHelloProviderContext, } from './provider.js';
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { provide as oe, inject as le, defineComponent as C, onMounted as Q, ref as X, openBlock as E, createElementBlock as M, normalizeClass as ue, unref as Y, normalizeStyle as se, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as me, renderSlot as Z, createCommentVNode as ee } from "vue";
1
+ import { inject as oe, provide as le, defineComponent as E, onMounted as Q, ref as X, openBlock as I, createElementBlock as M, normalizeStyle as ue, normalizeClass as se, unref as Y, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as me, renderSlot as Z, createCommentVNode as ee } from "vue";
2
2
  const w = {
3
3
  login: "/api/hellocoop?login=true",
4
4
  auth: "/api/hellocoop?auth=true",
5
5
  logout: "/api/hellocoop?logout=true"
6
- }, te = "HelloAuth", ye = () => le(te), Te = {
6
+ }, te = "HelloAuth", ye = () => oe(te), Te = {
7
7
  props: ["auth", "config"],
8
8
  setup(t) {
9
9
  var n, e, i;
10
- (n = t == null ? void 0 : t.config) != null && n.login && (w.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (w.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (w.logout = t.config.logout), oe(te, t.auth);
10
+ (n = t == null ? void 0 : t.config) != null && n.login && (w.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (w.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (w.logout = t.config.logout), le(te, t.auth);
11
11
  },
12
12
  render() {
13
13
  return this.$slots.default();
@@ -35,7 +35,7 @@ var A;
35
35
  }
36
36
  };
37
37
  })(A || (A = {}));
38
- const pe = ["disabled"], be = ["innerHTML"], U = /* @__PURE__ */ C({
38
+ const pe = ["disabled"], be = ["innerHTML"], U = /* @__PURE__ */ E({
39
39
  __name: "BaseButton",
40
40
  props: {
41
41
  label: { default: "ō&nbsp;&nbsp;&nbsp;Continue with Hellō" },
@@ -57,44 +57,56 @@ const pe = ["disabled"], be = ["innerHTML"], U = /* @__PURE__ */ C({
57
57
  setup(t) {
58
58
  let n = !1;
59
59
  Q(() => {
60
- typeof window < "u" && !n && (Array.from(document.head.getElementsByTagName("link")).find(
61
- (f) => {
60
+ typeof window < "u" && !n && (Array.from(
61
+ document.head.getElementsByTagName("link")
62
+ ).find(
63
+ (d) => {
62
64
  var u;
63
- return f.getAttribute("rel") === "stylesheet" && ((u = f.getAttribute("href")) == null ? void 0 : u.startsWith(A.STYLES_URL));
65
+ return d.getAttribute("rel") === "stylesheet" && ((u = d.getAttribute("href")) == null ? void 0 : u.startsWith(A.STYLES_URL));
64
66
  }
65
- ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), n = !0);
67
+ ) || console.warn(
68
+ "Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."
69
+ ), n = !0);
66
70
  });
67
71
  const e = X(!1), i = t, a = new URL(w.login, window.location.origin);
68
- i.scope && a.searchParams.set("scope", i.scope.join(" ")), a.searchParams.set("target_uri", i.targetURI || window.location.pathname), i.update && a.searchParams.set("prompt", "consent"), i.promptLogin && i.promptConsent ? a.searchParams.set("prompt", "login consent") : i.promptLogin ? a.searchParams.set("prompt", "login") : i.promptConsent && a.searchParams.set("prompt", "consent"), i.loginHint && a.searchParams.set("login_hint", i.loginHint), i.domainHint && a.searchParams.set("login_hint", i.domainHint), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
72
+ i.scope && a.searchParams.set("scope", i.scope.join(" ")), a.searchParams.set(
73
+ "target_uri",
74
+ i.targetURI || window.location.pathname
75
+ ), i.update && a.searchParams.set("prompt", "consent"), i.promptLogin && i.promptConsent ? a.searchParams.set("prompt", "login consent") : i.promptLogin ? a.searchParams.set("prompt", "login") : i.promptConsent && a.searchParams.set("prompt", "consent"), i.loginHint && a.searchParams.set("login_hint", i.loginHint), i.domainHint && a.searchParams.set("login_hint", i.domainHint), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
69
76
  const r = () => {
70
77
  e.value = !0, window.location.href = a.href;
71
78
  };
72
- return (l, f) => {
79
+ return (l, d) => {
73
80
  var u;
74
- return E(), M("button", {
75
- onClick: r,
76
- class: ue(["hello-btn", (u = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : u[i.theme], Y(A).HOVER_MAPPING[l.hover], (l.showLoader || e.value) && "hello-btn-loader"]),
81
+ return I(), M("button", {
82
+ class: se([
83
+ "hello-btn",
84
+ (u = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : u[i.theme],
85
+ Y(A).HOVER_MAPPING[l.hover],
86
+ (l.showLoader || e.value) && "hello-btn-loader"
87
+ ]),
77
88
  disabled: i.disabled || e.value,
78
- style: se(l.style)
89
+ style: ue(l.style),
90
+ onClick: r
79
91
  }, [
80
92
  ce("span", { innerHTML: l.label }, null, 8, be)
81
93
  ], 14, pe);
82
94
  };
83
95
  }
84
- }), De = /* @__PURE__ */ C({
96
+ }), De = /* @__PURE__ */ E({
85
97
  __name: "ContinueButton",
86
98
  setup(t) {
87
- return (n, e) => (E(), j(U));
99
+ return (n, e) => (I(), j(U));
88
100
  }
89
- }), xe = /* @__PURE__ */ C({
101
+ }), xe = /* @__PURE__ */ E({
90
102
  __name: "LoginButton",
91
103
  setup(t) {
92
- return (n, e) => (E(), j(U, { label: "ō   Login with Hellō" }));
104
+ return (n, e) => (I(), j(U, { label: "ō   Login with Hellō" }));
93
105
  }
94
- }), $e = /* @__PURE__ */ C({
106
+ }), $e = /* @__PURE__ */ E({
95
107
  __name: "UpdateProfileButton",
96
108
  setup(t) {
97
- return (n, e) => (E(), j(U, {
109
+ return (n, e) => (I(), j(U, {
98
110
  label: "ō   Update Profile with Hellō",
99
111
  update: !0
100
112
  }));
@@ -131,12 +143,12 @@ var F = (
131
143
  var e = this.serializeKey(n);
132
144
  return this.items.get(e);
133
145
  }, t.prototype.set = function(n, e, i) {
134
- var a = this.serializeKey(n), r = i || this.ttl, l = Date.now(), f = {
146
+ var a = this.serializeKey(n), r = i || this.ttl, l = Date.now(), d = {
135
147
  data: e,
136
148
  createdAt: l,
137
149
  expiresAt: r ? l + r : 1 / 0
138
150
  };
139
- this.dispatchExpire(r, f, a), this.items.set(a, f);
151
+ this.dispatchExpire(r, d, a), this.items.set(a, d);
140
152
  }, t.prototype.dispatchExpire = function(n, e, i) {
141
153
  var a = this;
142
154
  n && setTimeout(function() {
@@ -148,10 +160,10 @@ var F = (
148
160
  }, t;
149
161
  }()
150
162
  );
151
- function Re() {
163
+ function Le() {
152
164
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
153
165
  }
154
- function Le() {
166
+ function Re() {
155
167
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
156
168
  }
157
169
  var Ce = function(t) {
@@ -160,8 +172,8 @@ var Ce = function(t) {
160
172
  });
161
173
  };
162
174
  const x = {
163
- isOnline: Re,
164
- isDocumentVisible: Le,
175
+ isOnline: Le,
176
+ isDocumentVisible: Re,
165
177
  fetcher: Ce
166
178
  };
167
179
  var y = function() {
@@ -179,36 +191,36 @@ var y = function() {
179
191
  });
180
192
  }
181
193
  return new (e || (e = Promise))(function(r, l) {
182
- function f(s) {
194
+ function d(c) {
183
195
  try {
184
- o(i.next(s));
196
+ o(i.next(c));
185
197
  } catch (g) {
186
198
  l(g);
187
199
  }
188
200
  }
189
- function u(s) {
201
+ function u(c) {
190
202
  try {
191
- o(i.throw(s));
203
+ o(i.throw(c));
192
204
  } catch (g) {
193
205
  l(g);
194
206
  }
195
207
  }
196
- function o(s) {
197
- s.done ? r(s.value) : a(s.value).then(f, u);
208
+ function o(c) {
209
+ c.done ? r(c.value) : a(c.value).then(d, u);
198
210
  }
199
211
  o((i = i.apply(t, n || [])).next());
200
212
  });
201
- }, L = function(t, n) {
213
+ }, C = function(t, n) {
202
214
  var e = { label: 0, sent: function() {
203
215
  if (r[0] & 1) throw r[1];
204
216
  return r[1];
205
217
  }, trys: [], ops: [] }, i, a, r, l;
206
- return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
218
+ return l = { next: d(0), throw: d(1), return: d(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
207
219
  return this;
208
220
  }), l;
209
- function f(o) {
210
- return function(s) {
211
- return u([o, s]);
221
+ function d(o) {
222
+ return function(c) {
223
+ return u([o, c]);
212
224
  };
213
225
  }
214
226
  function u(o) {
@@ -249,8 +261,8 @@ var y = function() {
249
261
  continue;
250
262
  }
251
263
  o = n.call(t, e);
252
- } catch (s) {
253
- o = [6, s], a = 0;
264
+ } catch (c) {
265
+ o = [6, c], a = 0;
254
266
  } finally {
255
267
  i = r = 0;
256
268
  }
@@ -263,8 +275,8 @@ var y = function() {
263
275
  var i = e.call(t), a, r = [], l;
264
276
  try {
265
277
  for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; ) r.push(a.value);
266
- } catch (f) {
267
- l = { error: f };
278
+ } catch (d) {
279
+ l = { error: d };
268
280
  } finally {
269
281
  try {
270
282
  a && !a.done && (e = i.return) && e.call(i);
@@ -311,18 +323,18 @@ function Ae(t, n, e) {
311
323
  }
312
324
  var J = function(t, n, e, i) {
313
325
  return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), R(void 0, void 0, void 0, function() {
314
- var a, r, l, f, u, o, s;
315
- return L(this, function(g) {
326
+ var a, r, l, d, u, o, c;
327
+ return C(this, function(g) {
316
328
  switch (g.label) {
317
329
  case 0:
318
- if (!Ve(n)) return [3, 5];
330
+ if (!Pe(n)) return [3, 5];
319
331
  g.label = 1;
320
332
  case 1:
321
333
  return g.trys.push([1, 3, , 4]), [4, n];
322
334
  case 2:
323
335
  return a = g.sent(), [3, 4];
324
336
  case 3:
325
- return f = g.sent(), r = f, [3, 4];
337
+ return d = g.sent(), r = d, [3, 4];
326
338
  case 4:
327
339
  return [3, 6];
328
340
  case 5:
@@ -331,73 +343,74 @@ var J = function(t, n, e, i) {
331
343
  if (l = !1, u = { data: a, error: r, isValidating: l }, typeof a < "u")
332
344
  try {
333
345
  e.set(t, u, i);
334
- } catch (v) {
335
- console.error("swrv(mutate): failed to set cache", v);
346
+ } catch (h) {
347
+ console.error("swrv(mutate): failed to set cache", h);
336
348
  }
337
- return o = H.get(t), o && o.data.length && (s = o.data.filter(function(v) {
338
- return v.key === t;
339
- }), s.forEach(function(v, d) {
340
- typeof u.data < "u" && (v.data = u.data), v.error = u.error, v.isValidating = u.isValidating;
341
- var p = d === s.length - 1;
342
- p || delete s[d];
343
- }), s = s.filter(Boolean)), [2, u];
349
+ return o = H.get(t), o && o.data.length && (c = o.data.filter(function(h) {
350
+ return h.key === t;
351
+ }), c.forEach(function(h, s) {
352
+ typeof u.data < "u" && (h.data = u.data), h.error = u.error, h.isValidating = u.isValidating, h.isLoading = u.isValidating;
353
+ var p = s === c.length - 1;
354
+ p || delete c[s];
355
+ }), c = c.filter(Boolean)), [2, u];
344
356
  }
345
357
  });
346
358
  });
347
359
  };
348
- function Pe() {
360
+ function Ve() {
349
361
  for (var t = this, n = [], e = 0; e < arguments.length; e++)
350
362
  n[e] = arguments[e];
351
- var i, a, r = y({}, re), l = !1, f = !1, u = fe(), o = (u == null ? void 0 : u.proxy) || u;
363
+ var i, a, r = y({}, re), l = !1, d = !1, u = fe(), o = (u == null ? void 0 : u.proxy) || u;
352
364
  if (!o)
353
365
  return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
354
- var s = (o == null ? void 0 : o.$isServer) || !1;
366
+ var c = (o == null ? void 0 : o.$isServer) || !1;
355
367
  n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = y(y({}, r), n[2]));
356
- var g = s ? r.serverTTL : r.ttl, v = typeof i == "function" ? i : X(i);
368
+ var g = c ? r.serverTTL : r.ttl, h = typeof i == "function" ? i : X(i);
357
369
  typeof a > "u" && (a = r.fetcher);
358
- var d = null;
359
- d || (d = de({
370
+ var s = null;
371
+ s || (s = de({
360
372
  data: void 0,
361
373
  error: void 0,
362
374
  isValidating: !0,
375
+ isLoading: !0,
363
376
  key: null
364
377
  }));
365
- var p = function(h, c) {
378
+ var p = function(v, f) {
366
379
  return R(t, void 0, void 0, function() {
367
- var N, m, I, S, O, z, k, G = this;
368
- return L(this, function(B) {
380
+ var N, m, S, L, O, z, k, G = this;
381
+ return C(this, function(B) {
369
382
  switch (B.label) {
370
383
  case 0:
371
- return N = d.data === void 0, m = v.value, m ? (I = r.cache.get(m), S = I && I.data, d.isValidating = !0, S && (d.data = S.data, d.error = S.error), O = h || a, !O || !r.isDocumentVisible() && !N || (c == null ? void 0 : c.forceRevalidate) !== void 0 && !(c != null && c.forceRevalidate) ? (d.isValidating = !1, [
384
+ return N = s.data === void 0, m = h.value, m ? (S = r.cache.get(m), L = S && S.data, s.isValidating = !0, s.isLoading = !L, L && (s.data = L.data, s.error = L.error), O = v || a, !O || !r.isDocumentVisible() && !N || (f == null ? void 0 : f.forceRevalidate) !== void 0 && !(f != null && f.forceRevalidate) ? (s.isValidating = !1, s.isLoading = !1, [
372
385
  2
373
386
  /*return*/
374
- ]) : I && (z = !!(Date.now() - I.createdAt >= r.dedupingInterval || c != null && c.forceRevalidate), !z) ? (d.isValidating = !1, [
387
+ ]) : S && (z = !!(Date.now() - S.createdAt >= r.dedupingInterval || f != null && f.forceRevalidate), !z) ? (s.isValidating = !1, s.isLoading = !1, [
375
388
  2
376
389
  /*return*/
377
390
  ]) : (k = function() {
378
391
  return R(G, void 0, void 0, function() {
379
392
  var b, K, T, W;
380
- return L(this, function(V) {
381
- switch (V.label) {
393
+ return C(this, function(P) {
394
+ switch (P.label) {
382
395
  case 0:
383
396
  return b = $.get(m), b ? [3, 2] : (K = Array.isArray(m) ? m : [m], T = O.apply(void 0, Ie([], Ee(K), !1)), $.set(m, T, r.dedupingInterval), [4, J(m, T, r.cache, g)]);
384
397
  case 1:
385
- return V.sent(), [3, 4];
398
+ return P.sent(), [3, 4];
386
399
  case 2:
387
400
  return [4, J(m, b.data, r.cache, g)];
388
401
  case 3:
389
- V.sent(), V.label = 4;
402
+ P.sent(), P.label = 4;
390
403
  case 4:
391
- return d.isValidating = !1, $.delete(m), d.error !== void 0 && (W = !l && r.shouldRetryOnError && (c ? c.shouldRetryOnError : !0), W && Ae(p, c ? c.errorRetryCount : 1, r)), [
404
+ return s.isValidating = !1, s.isLoading = !1, $.delete(m), s.error !== void 0 && (W = !l && r.shouldRetryOnError && (f ? f.shouldRetryOnError : !0), W && Ae(p, f ? f.errorRetryCount : 1, r)), [
392
405
  2
393
406
  /*return*/
394
407
  ];
395
408
  }
396
409
  });
397
410
  });
398
- }, S && r.revalidateDebounce ? (setTimeout(function() {
411
+ }, L && r.revalidateDebounce ? (setTimeout(function() {
399
412
  return R(G, void 0, void 0, function() {
400
- return L(this, function(b) {
413
+ return C(this, function(b) {
401
414
  switch (b.label) {
402
415
  case 0:
403
416
  return l ? [3, 2] : [4, k()];
@@ -427,26 +440,26 @@ function Pe() {
427
440
  }
428
441
  });
429
442
  });
430
- }, P = function() {
443
+ }, V = function() {
431
444
  return R(t, void 0, void 0, function() {
432
- return L(this, function(h) {
445
+ return C(this, function(v) {
433
446
  return [2, p(null, { shouldRetryOnError: !1 })];
434
447
  });
435
448
  });
436
449
  }, _ = null;
437
450
  Q(function() {
438
- var h = function() {
451
+ var v = function() {
439
452
  return R(t, void 0, void 0, function() {
440
- return L(this, function(c) {
441
- switch (c.label) {
453
+ return C(this, function(f) {
454
+ switch (f.label) {
442
455
  case 0:
443
- return !d.error && r.isOnline() ? [4, p()] : [3, 2];
456
+ return !s.error && r.isOnline() ? [4, p()] : [3, 2];
444
457
  case 1:
445
- return c.sent(), [3, 3];
458
+ return f.sent(), [3, 3];
446
459
  case 2:
447
- _ && clearTimeout(_), c.label = 3;
460
+ _ && clearTimeout(_), f.label = 3;
448
461
  case 3:
449
- return r.refreshInterval && !l && (_ = setTimeout(h, r.refreshInterval)), [
462
+ return r.refreshInterval && !l && (_ = setTimeout(v, r.refreshInterval)), [
450
463
  2
451
464
  /*return*/
452
465
  ];
@@ -454,28 +467,28 @@ function Pe() {
454
467
  });
455
468
  });
456
469
  };
457
- r.refreshInterval && (_ = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", P, !1), window.addEventListener("focus", P, !1));
470
+ r.refreshInterval && (_ = setTimeout(v, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", V, !1), window.addEventListener("focus", V, !1));
458
471
  }), he(function() {
459
- l = !0, _ && clearTimeout(_), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", P, !1), window.removeEventListener("focus", P, !1));
460
- var h = H.get(v.value);
461
- h && (h.data = h.data.filter(function(c) {
462
- return c !== d;
472
+ l = !0, _ && clearTimeout(_), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", V, !1), window.removeEventListener("focus", V, !1));
473
+ var v = H.get(h.value);
474
+ v && (v.data = v.data.filter(function(f) {
475
+ return f !== s;
463
476
  }));
464
477
  });
465
478
  try {
466
- ve(v, function(h) {
467
- ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Se(v.value, d, g), !s && !f && v.value && p(), f = !1;
479
+ ve(h, function(v) {
480
+ ge(h) || (h.value = v), s.key = v, s.isValidating = !!v, Se(h.value, s, g), !c && !d && h.value && p(), d = !1;
468
481
  }, {
469
482
  immediate: !0
470
483
  });
471
484
  } catch {
472
485
  }
473
- var ae = y(y({}, me(d)), { mutate: function(h, c) {
474
- return p(h, y(y({}, c), { forceRevalidate: !0 }));
486
+ var ae = y(y({}, me(s)), { mutate: function(v, f) {
487
+ return p(v, y(y({}, f), { forceRevalidate: !0 }));
475
488
  } });
476
489
  return ae;
477
490
  }
478
- function Ve(t) {
491
+ function Pe(t) {
479
492
  return t !== null && typeof t == "object" && typeof t.then == "function";
480
493
  }
481
494
  const He = async (t) => {
@@ -486,7 +499,10 @@ const He = async (t) => {
486
499
  return;
487
500
  }
488
501
  }, ie = () => {
489
- const t = ye(), { data: n = t, isValidating: e } = Pe(w.auth, He);
502
+ const t = ye(), { data: n = t, isValidating: e } = Ve(
503
+ w.auth,
504
+ He
505
+ );
490
506
  return {
491
507
  auth: n || {},
492
508
  // @ts-ignore //TBD
@@ -494,25 +510,25 @@ const He = async (t) => {
494
510
  // @ts-ignore
495
511
  isLoggedIn: n == null ? void 0 : n.isLoggedIn
496
512
  };
497
- }, Oe = { key: 0 }, Me = /* @__PURE__ */ C({
513
+ }, Oe = { key: 0 }, Me = /* @__PURE__ */ E({
498
514
  __name: "LoggedIn",
499
515
  setup(t) {
500
516
  const n = () => {
501
517
  var e;
502
518
  return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
503
519
  };
504
- return (e, i) => n() ? (E(), M("div", Oe, [
520
+ return (e, i) => n() ? (I(), M("div", Oe, [
505
521
  Z(e.$slots, "default")
506
522
  ])) : ee("", !0);
507
523
  }
508
- }), ke = { key: 0 }, je = /* @__PURE__ */ C({
524
+ }), ke = { key: 0 }, je = /* @__PURE__ */ E({
509
525
  __name: "LoggedOut",
510
526
  setup(t) {
511
527
  const n = () => {
512
528
  var e;
513
529
  return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
514
530
  };
515
- return (e, i) => n() ? ee("", !0) : (E(), M("div", ke, [
531
+ return (e, i) => n() ? ee("", !0) : (I(), M("div", ke, [
516
532
  Z(e.$slots, "default")
517
533
  ]));
518
534
  }
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(v,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(v=typeof globalThis<"u"?globalThis:v||self,a(v["@hellocoop/vue"]={},v.Vue))})(this,function(v,a){"use strict";const w={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},N="HelloAuth",z=()=>a.inject(N),Z={props:["auth","config"],setup(t){var n,e,i;(n=t==null?void 0:t.config)!=null&&n.login&&(w.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(w.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(w.logout=t.config.logout),a.provide(N,t.auth)},render(){return this.$slots.default()}};var S;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(S||(S={}));const ee=["disabled"],te=["innerHTML"],B=a.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},update:{type:Boolean},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},promptLogin:{type:Boolean,default:!1},promptConsent:{type:Boolean,default:!1},loginHint:{default:""},domainHint:{default:""}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(d=>{var s;return d.getAttribute("rel")==="stylesheet"&&((s=d.getAttribute("href"))==null?void 0:s.startsWith(S.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const e=a.ref(!1),i=t,o=new URL(w.login,window.location.origin);i.scope&&o.searchParams.set("scope",i.scope.join(" ")),o.searchParams.set("target_uri",i.targetURI||window.location.pathname),i.update&&o.searchParams.set("prompt","consent"),i.promptLogin&&i.promptConsent?o.searchParams.set("prompt","login consent"):i.promptLogin?o.searchParams.set("prompt","login"):i.promptConsent&&o.searchParams.set("prompt","consent"),i.loginHint&&o.searchParams.set("login_hint",i.loginHint),i.domainHint&&o.searchParams.set("login_hint",i.domainHint),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(u,d)=>{var s;return a.openBlock(),a.createElementBlock("button",{onClick:r,class:a.normalizeClass(["hello-btn",(s=a.unref(S).CLASS_MAPPING[i.color])==null?void 0:s[i.theme],a.unref(S).HOVER_MAPPING[u.hover],(u.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(u.style)},[a.createElementVNode("span",{innerHTML:u.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Update Profile with Hellō",update:!0}))}});var O=new WeakMap,x=0;function oe(t){if(!t.length)return"";for(var n="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):O.has(t[e])?i=O.get(t[e]):(i=x,O.set(t[e],x++)),n+="@"+i}return n}function ae(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=oe(t):t=String(t||""),t}var H=function(){function t(n){n===void 0&&(n=0),this.items=new Map,this.ttl=n}return t.prototype.serializeKey=function(n){return ae(n)},t.prototype.get=function(n){var e=this.serializeKey(n);return this.items.get(e)},t.prototype.set=function(n,e,i){var o=this.serializeKey(n),r=i||this.ttl,u=Date.now(),d={data:e,createdAt:u,expiresAt:r?u+r:1/0};this.dispatchExpire(r,d,o),this.items.set(o,d)},t.prototype.dispatchExpire=function(n,e,i){var o=this;n&&setTimeout(function(){var r=Date.now(),u=r>=e.expiresAt;u&&o.delete(i)},n)},t.prototype.delete=function(n){this.items.delete(n)},t}();function le(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function ue(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var se=function(t){return fetch(t).then(function(n){return n.json()})};const T={isOnline:le,isDocumentVisible:ue,fetcher:se};var b=function(){return b=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},b.apply(this,arguments)},R=function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(u){u(r)})}return new(e||(e=Promise))(function(r,u){function d(c){try{l(i.next(c))}catch(y){u(y)}}function s(c){try{l(i.throw(c))}catch(y){u(y)}}function l(c){c.done?r(c.value):o(c.value).then(d,s)}l((i=i.apply(t,n||[])).next())})},L=function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,u;return u={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function d(l){return function(c){return s([l,c])}}function s(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(r=l[0]&2?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,o=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){e.label=l[1];break}if(l[0]===6&&e.label<r[1]){e.label=r[1],r=l;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(l);break}r[2]&&e.ops.pop(),e.trys.pop();continue}l=n.call(t,e)}catch(c){l=[6,c],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ce=function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],u;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(d){u={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(u)throw u.error}}return r},fe=function(t,n,e){if(e||arguments.length===2)for(var i=0,o=n.length,r;i<o;i++)(r||!(i in n))&&(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))},G=new H,A=new H,D=new H,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:T.fetcher,isOnline:T.isOnline,isDocumentVisible:T.isDocumentVisible};function de(t,n,e){var i=A.get(t);if(i)i.data.push(n);else{var o=5e3;A.set(t,[n],e>0?e+o:e)}}function he(t,n,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&n>e.errorRetryCount)){var i=Math.min(n||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,n,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),R(void 0,void 0,void 0,function(){var o,r,u,d,s,l,c;return L(this,function(y){switch(y.label){case 0:if(!ge(n))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,n];case 2:return o=y.sent(),[3,4];case 3:return d=y.sent(),r=d,[3,4];case 4:return[3,6];case 5:o=n,y.label=6;case 6:if(u=!1,s={data:o,error:r,isValidating:u},typeof o<"u")try{e.set(t,s,i)}catch(m){console.error("swrv(mutate): failed to set cache",m)}return l=A.get(t),l&&l.data.length&&(c=l.data.filter(function(m){return m.key===t}),c.forEach(function(m,h){typeof s.data<"u"&&(m.data=s.data),m.error=s.error,m.isValidating=s.isValidating;var _=h===c.length-1;_||delete c[h]}),c=c.filter(Boolean)),[2,s]}})})};function ve(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=b({},K),u=!1,d=!1,s=a.getCurrentInstance(),l=(s==null?void 0:s.proxy)||s;if(!l)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var c=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=b(b({},r),n[2]));var y=c?r.serverTTL:r.ttl,m=typeof i=="function"?i:a.ref(i);typeof o>"u"&&(o=r.fetcher);var h=null;h||(h=a.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var _=function(g,f){return R(t,void 0,void 0,function(){var Y,p,k,I,$,q,j,J=this;return L(this,function(U){switch(U.label){case 0:return Y=h.data===void 0,p=m.value,p?(k=r.cache.get(p),I=k&&k.data,h.isValidating=!0,I&&(h.data=I.data,h.error=I.error),$=g||o,!$||!r.isDocumentVisible()&&!Y||(f==null?void 0:f.forceRevalidate)!==void 0&&!(f!=null&&f.forceRevalidate)?(h.isValidating=!1,[2]):k&&(q=!!(Date.now()-k.createdAt>=r.dedupingInterval||f!=null&&f.forceRevalidate),!q)?(h.isValidating=!1,[2]):(j=function(){return R(J,void 0,void 0,function(){var C,Q,F,X;return L(this,function(V){switch(V.label){case 0:return C=D.get(p),C?[3,2]:(Q=Array.isArray(p)?p:[p],F=$.apply(void 0,fe([],ce(Q),!1)),D.set(p,F,r.dedupingInterval),[4,W(p,F,r.cache,y)]);case 1:return V.sent(),[3,4];case 2:return[4,W(p,C.data,r.cache,y)];case 3:V.sent(),V.label=4;case 4:return h.isValidating=!1,D.delete(p),h.error!==void 0&&(X=!u&&r.shouldRetryOnError&&(f?f.shouldRetryOnError:!0),X&&he(_,f?f.errorRetryCount:1,r)),[2]}})})},I&&r.revalidateDebounce?(setTimeout(function(){return R(J,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return u?[3,2]:[4,j()];case 1:C.sent(),C.label=2;case 2:return[2]}})})},r.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,j()];case 2:U.sent(),U.label=3;case 3:return[2]}})})},P=function(){return R(t,void 0,void 0,function(){return L(this,function(g){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var g=function(){return R(t,void 0,void 0,function(){return L(this,function(f){switch(f.label){case 0:return!h.error&&r.isOnline()?[4,_()]:[3,2];case 1:return f.sent(),[3,3];case 2:E&&clearTimeout(E),f.label=3;case 3:return r.refreshInterval&&!u&&(E=setTimeout(g,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(g,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",P,!1),window.addEventListener("focus",P,!1))}),a.onUnmounted(function(){u=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",P,!1),window.removeEventListener("focus",P,!1));var g=A.get(m.value);g&&(g.data=g.data.filter(function(f){return f!==h}))});try{a.watch(m,function(g){a.isReadonly(m)||(m.value=g),h.key=g,h.isValidating=!!g,de(m.value,h,y),!c&&!d&&m.value&&_(),d=!1},{immediate:!0})}catch{}var Re=b(b({},a.toRefs(h)),{mutate:function(g,f){return _(g,b(b({},f),{forceRevalidate:!0}))}});return Re}function ge(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const me=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ve(w.auth,me);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},ye={key:0},pe=a.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?(a.openBlock(),a.createElementBlock("div",ye,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),be={key:0},we=a.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",be,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Ce(){window.location.href=w.logout}v.ContinueButton=ne,v.HelloProvider=Z,v.LoggedIn=pe,v.LoggedOut=we,v.LoginButton=re,v.UpdateProfileButton=ie,v.getLogOutRoute=_e,v.logOut=Ce,v.routeConfig=w,v.useAuth=M,v.useHelloProviderContext=z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,a){"use strict";const w={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},N="HelloAuth",z=()=>a.inject(N),Z={props:["auth","config"],setup(t){var n,e,i;(n=t==null?void 0:t.config)!=null&&n.login&&(w.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(w.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(w.logout=t.config.logout),a.provide(N,t.auth)},render(){return this.$slots.default()}};var k;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(k||(k={}));const ee=["disabled"],te=["innerHTML"],B=a.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},update:{type:Boolean},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},promptLogin:{type:Boolean,default:!1},promptConsent:{type:Boolean,default:!1},loginHint:{default:""},domainHint:{default:""}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(h=>{var u;return h.getAttribute("rel")==="stylesheet"&&((u=h.getAttribute("href"))==null?void 0:u.startsWith(k.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const e=a.ref(!1),i=t,o=new URL(w.login,window.location.origin);i.scope&&o.searchParams.set("scope",i.scope.join(" ")),o.searchParams.set("target_uri",i.targetURI||window.location.pathname),i.update&&o.searchParams.set("prompt","consent"),i.promptLogin&&i.promptConsent?o.searchParams.set("prompt","login consent"):i.promptLogin?o.searchParams.set("prompt","login"):i.promptConsent&&o.searchParams.set("prompt","consent"),i.loginHint&&o.searchParams.set("login_hint",i.loginHint),i.domainHint&&o.searchParams.set("login_hint",i.domainHint),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(s,h)=>{var u;return a.openBlock(),a.createElementBlock("button",{class:a.normalizeClass(["hello-btn",(u=a.unref(k).CLASS_MAPPING[i.color])==null?void 0:u[i.theme],a.unref(k).HOVER_MAPPING[s.hover],(s.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(s.style),onClick:r},[a.createElementVNode("span",{innerHTML:s.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Update Profile with Hellō",update:!0}))}});var O=new WeakMap,x=0;function oe(t){if(!t.length)return"";for(var n="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):O.has(t[e])?i=O.get(t[e]):(i=x,O.set(t[e],x++)),n+="@"+i}return n}function ae(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=oe(t):t=String(t||""),t}var H=function(){function t(n){n===void 0&&(n=0),this.items=new Map,this.ttl=n}return t.prototype.serializeKey=function(n){return ae(n)},t.prototype.get=function(n){var e=this.serializeKey(n);return this.items.get(e)},t.prototype.set=function(n,e,i){var o=this.serializeKey(n),r=i||this.ttl,s=Date.now(),h={data:e,createdAt:s,expiresAt:r?s+r:1/0};this.dispatchExpire(r,h,o),this.items.set(o,h)},t.prototype.dispatchExpire=function(n,e,i){var o=this;n&&setTimeout(function(){var r=Date.now(),s=r>=e.expiresAt;s&&o.delete(i)},n)},t.prototype.delete=function(n){this.items.delete(n)},t}();function le(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function se(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ue=function(t){return fetch(t).then(function(n){return n.json()})};const T={isOnline:le,isDocumentVisible:se,fetcher:ue};var b=function(){return b=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},b.apply(this,arguments)},C=function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(s){s(r)})}return new(e||(e=Promise))(function(r,s){function h(f){try{l(i.next(f))}catch(y){s(y)}}function u(f){try{l(i.throw(f))}catch(y){s(y)}}function l(f){f.done?r(f.value):o(f.value).then(h,u)}l((i=i.apply(t,n||[])).next())})},R=function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s;return s={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function h(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(r=l[0]&2?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,o=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){e.label=l[1];break}if(l[0]===6&&e.label<r[1]){e.label=r[1],r=l;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(l);break}r[2]&&e.ops.pop(),e.trys.pop();continue}l=n.call(t,e)}catch(f){l=[6,f],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ce=function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],s;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(h){s={error:h}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return r},fe=function(t,n,e){if(e||arguments.length===2)for(var i=0,o=n.length,r;i<o;i++)(r||!(i in n))&&(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))},G=new H,A=new H,D=new H,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:T.fetcher,isOnline:T.isOnline,isDocumentVisible:T.isDocumentVisible};function de(t,n,e){var i=A.get(t);if(i)i.data.push(n);else{var o=5e3;A.set(t,[n],e>0?e+o:e)}}function he(t,n,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&n>e.errorRetryCount)){var i=Math.min(n||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,n,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),C(void 0,void 0,void 0,function(){var o,r,s,h,u,l,f;return R(this,function(y){switch(y.label){case 0:if(!ve(n))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,n];case 2:return o=y.sent(),[3,4];case 3:return h=y.sent(),r=h,[3,4];case 4:return[3,6];case 5:o=n,y.label=6;case 6:if(s=!1,u={data:o,error:r,isValidating:s},typeof o<"u")try{e.set(t,u,i)}catch(v){console.error("swrv(mutate): failed to set cache",v)}return l=A.get(t),l&&l.data.length&&(f=l.data.filter(function(v){return v.key===t}),f.forEach(function(v,c){typeof u.data<"u"&&(v.data=u.data),v.error=u.error,v.isValidating=u.isValidating,v.isLoading=u.isValidating;var _=c===f.length-1;_||delete f[c]}),f=f.filter(Boolean)),[2,u]}})})};function ge(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=b({},K),s=!1,h=!1,u=a.getCurrentInstance(),l=(u==null?void 0:u.proxy)||u;if(!l)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var f=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=b(b({},r),n[2]));var y=f?r.serverTTL:r.ttl,v=typeof i=="function"?i:a.ref(i);typeof o>"u"&&(o=r.fetcher);var c=null;c||(c=a.reactive({data:void 0,error:void 0,isValidating:!0,isLoading:!0,key:null}));var _=function(m,d){return C(t,void 0,void 0,function(){var Y,p,I,S,$,q,j,J=this;return R(this,function(U){switch(U.label){case 0:return Y=c.data===void 0,p=v.value,p?(I=r.cache.get(p),S=I&&I.data,c.isValidating=!0,c.isLoading=!S,S&&(c.data=S.data,c.error=S.error),$=m||o,!$||!r.isDocumentVisible()&&!Y||(d==null?void 0:d.forceRevalidate)!==void 0&&!(d!=null&&d.forceRevalidate)?(c.isValidating=!1,c.isLoading=!1,[2]):I&&(q=!!(Date.now()-I.createdAt>=r.dedupingInterval||d!=null&&d.forceRevalidate),!q)?(c.isValidating=!1,c.isLoading=!1,[2]):(j=function(){return C(J,void 0,void 0,function(){var L,Q,F,X;return R(this,function(P){switch(P.label){case 0:return L=D.get(p),L?[3,2]:(Q=Array.isArray(p)?p:[p],F=$.apply(void 0,fe([],ce(Q),!1)),D.set(p,F,r.dedupingInterval),[4,W(p,F,r.cache,y)]);case 1:return P.sent(),[3,4];case 2:return[4,W(p,L.data,r.cache,y)];case 3:P.sent(),P.label=4;case 4:return c.isValidating=!1,c.isLoading=!1,D.delete(p),c.error!==void 0&&(X=!s&&r.shouldRetryOnError&&(d?d.shouldRetryOnError:!0),X&&he(_,d?d.errorRetryCount:1,r)),[2]}})})},S&&r.revalidateDebounce?(setTimeout(function(){return C(J,void 0,void 0,function(){return R(this,function(L){switch(L.label){case 0:return s?[3,2]:[4,j()];case 1:L.sent(),L.label=2;case 2:return[2]}})})},r.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,j()];case 2:U.sent(),U.label=3;case 3:return[2]}})})},V=function(){return C(t,void 0,void 0,function(){return R(this,function(m){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var m=function(){return C(t,void 0,void 0,function(){return R(this,function(d){switch(d.label){case 0:return!c.error&&r.isOnline()?[4,_()]:[3,2];case 1:return d.sent(),[3,3];case 2:E&&clearTimeout(E),d.label=3;case 3:return r.refreshInterval&&!s&&(E=setTimeout(m,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(m,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",V,!1),window.addEventListener("focus",V,!1))}),a.onUnmounted(function(){s=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",V,!1),window.removeEventListener("focus",V,!1));var m=A.get(v.value);m&&(m.data=m.data.filter(function(d){return d!==c}))});try{a.watch(v,function(m){a.isReadonly(v)||(v.value=m),c.key=m,c.isValidating=!!m,de(v.value,c,y),!f&&!h&&v.value&&_(),h=!1},{immediate:!0})}catch{}var Ce=b(b({},a.toRefs(c)),{mutate:function(m,d){return _(m,b(b({},d),{forceRevalidate:!0}))}});return Ce}function ve(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const me=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ge(w.auth,me);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},ye={key:0},pe=a.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?(a.openBlock(),a.createElementBlock("div",ye,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),be={key:0},we=a.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",be,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Le(){window.location.href=w.logout}g.ContinueButton=ne,g.HelloProvider=Z,g.LoggedIn=pe,g.LoggedOut=we,g.LoginButton=re,g.UpdateProfileButton=ie,g.getLogOutRoute=_e,g.logOut=Le,g.routeConfig=w,g.useAuth=M,g.useHelloProviderContext=z,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
@@ -1,9 +1,10 @@
1
1
  declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
2
3
  slots: {
3
4
  default?(_: {}): any;
4
5
  };
5
6
  refs: {};
6
- attrs: Partial<{}>;
7
+ rootEl: any;
7
8
  };
8
9
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
9
10
  declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -1,9 +1,10 @@
1
1
  declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
2
3
  slots: {
3
4
  default?(_: {}): any;
4
5
  };
5
6
  refs: {};
6
- attrs: Partial<{}>;
7
+ rootEl: any;
7
8
  };
8
9
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
9
10
  declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
package/dist/types.d.ts CHANGED
@@ -8,11 +8,11 @@ export declare const VALID_SCOPES: readonly ["name", "nickname", "preferred_user
8
8
  export declare const VALID_RESPONSE_TYPE: readonly ["id_token", "code"];
9
9
  export declare const VALID_RESPONSE_MODE: string[];
10
10
  export declare const VALID_PROVIDER_HINT: readonly ["apple", "discord", "facebook", "github", "gitlab", "google", "twitch", "twitter", "tumblr", "mastodon", "microsoft", "line", "wordpress", "yahoo", "phone", "ethereum", "qrcode", "apple--", "microsoft--", "google--", "email--", "passkey--"];
11
- export type Scope = typeof VALID_SCOPES[number];
12
- export type AuthResponseType = typeof VALID_RESPONSE_TYPE[number];
13
- export type AuthResponseMode = typeof VALID_RESPONSE_MODE[number];
14
- export type ProviderHint = typeof VALID_PROVIDER_HINT[number];
15
- type IdentityClaims = typeof VALID_IDENTITY_CLAIMS[number];
11
+ export type Scope = (typeof VALID_SCOPES)[number];
12
+ export type AuthResponseType = (typeof VALID_RESPONSE_TYPE)[number];
13
+ export type AuthResponseMode = (typeof VALID_RESPONSE_MODE)[number];
14
+ export type ProviderHint = (typeof VALID_PROVIDER_HINT)[number];
15
+ type IdentityClaims = (typeof VALID_IDENTITY_CLAIMS)[number];
16
16
  type OptionalClaims = {
17
17
  [K in IdentityClaims]?: unknown;
18
18
  };
@@ -34,9 +34,9 @@ export type TokenHeader = {
34
34
  alg: string;
35
35
  };
36
36
  export declare namespace Button {
37
- type Color = "black" | "white";
38
- type Theme = "ignore-light" | "ignore-dark" | "aware-invert" | "aware-static";
39
- type Hover = "pop" | "glow" | "flare" | "none";
37
+ type Color = 'black' | 'white';
38
+ type Theme = 'ignore-light' | 'ignore-dark' | 'aware-invert' | 'aware-static';
39
+ type Hover = 'pop' | 'glow' | 'flare' | 'none';
40
40
  type Update = boolean;
41
41
  const STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css";
42
42
  const HOVER_MAPPING: {
@@ -47,16 +47,16 @@ export declare namespace Button {
47
47
  };
48
48
  const CLASS_MAPPING: {
49
49
  black: {
50
- "ignore-light": string;
51
- "ignore-dark": string;
52
- "aware-invert": string;
53
- "aware-static": string;
50
+ 'ignore-light': string;
51
+ 'ignore-dark': string;
52
+ 'aware-invert': string;
53
+ 'aware-static': string;
54
54
  };
55
55
  white: {
56
- "ignore-light": string;
57
- "ignore-dark": string;
58
- "aware-invert": string;
59
- "aware-static": string;
56
+ 'ignore-light': string;
57
+ 'ignore-dark': string;
58
+ 'aware-invert': string;
59
+ 'aware-static': string;
60
60
  };
61
61
  };
62
62
  }
package/package.json CHANGED
@@ -1,55 +1,55 @@
1
1
  {
2
- "name": "@hellocoop/vue",
3
- "version": "2.1.7",
4
- "description": "Svelte SDK for Hellō https://hello.dev",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/hellocoop/packages.git"
8
- },
9
- "homepage": "https://www.hello.dev/docs/sdks/vue",
10
- "keywords": [
11
- "vuejs",
12
- "vue",
13
- "vue.js",
14
- "hello",
15
- "openid",
16
- "oidc",
17
- "sso"
18
- ],
19
- "author": {
20
- "name": "Hello Identity Co-op",
21
- "email": "contact@hello.coop",
22
- "url": "https://hello.coop"
23
- },
24
- "main": "./dist/index.umd.js",
25
- "module": "./dist/index.mjs",
26
- "exports": {
27
- ".": {
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.umd.js"
30
- }
31
- },
32
- "unpkg": "dist/index.umd.min.js",
33
- "types": "./dist/index.d.ts",
34
- "license": "MIT",
35
- "bugs": {
36
- "url": "https://github.com/hellocoop/packages/issues"
37
- },
38
- "files": [
39
- "dist"
40
- ],
41
- "scripts": {
42
- "build": "vite build",
43
- "prebuild": "rimraf dist node_modules"
44
- },
45
- "devDependencies": {
46
- "typescript": "^5.7.2",
47
- "vite-plugin-dts": "^4.3.0"
48
- },
49
- "gitHead": "8e7b54124db48051b9e03031399e4df1b6e41a4e",
50
- "dependencies": {
51
- "@vitejs/plugin-vue": "^5.2.1",
52
- "swrv": "^1.0.4",
53
- "vue": "^3.5.13"
54
- }
2
+ "name": "@hellocoop/vue",
3
+ "version": "2.1.10",
4
+ "description": "Svelte SDK for Hellō https://hello.dev",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/hellocoop/packages-js.git"
8
+ },
9
+ "homepage": "https://www.hello.dev/docs/sdks/vue",
10
+ "keywords": [
11
+ "vuejs",
12
+ "vue",
13
+ "vue.js",
14
+ "hello",
15
+ "openid",
16
+ "oidc",
17
+ "sso"
18
+ ],
19
+ "author": {
20
+ "name": "Hello Identity Co-op",
21
+ "email": "contact@hello.coop",
22
+ "url": "https://hello.coop"
23
+ },
24
+ "main": "./dist/index.umd.js",
25
+ "module": "./dist/index.mjs",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/index.mjs",
29
+ "require": "./dist/index.umd.js"
30
+ }
31
+ },
32
+ "unpkg": "dist/index.umd.min.js",
33
+ "types": "./dist/index.d.ts",
34
+ "license": "MIT",
35
+ "bugs": {
36
+ "url": "https://github.com/hellocoop/packages-js/issues"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "scripts": {
42
+ "build": "vite build",
43
+ "prebuild": "rimraf dist node_modules"
44
+ },
45
+ "devDependencies": {
46
+ "typescript": "^5.7.2",
47
+ "vite-plugin-dts": "^4.3.0"
48
+ },
49
+ "gitHead": "96cc2f3fa1a3724a4a96b19cc7c5d97f04cc49f8",
50
+ "dependencies": {
51
+ "@vitejs/plugin-vue": "^5.2.1",
52
+ "swrv": "^1.0.4",
53
+ "vue": "^3.5.13"
54
+ }
55
55
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Hellō
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.