@tern-secure/shared 1.1.2 → 1.2.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/browser.d.mts +28 -0
- package/dist/browser.d.ts +28 -0
- package/dist/browser.js +95 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.mjs +66 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/chunk-2UQ43P4P.mjs +45 -0
- package/dist/chunk-2UQ43P4P.mjs.map +1 -0
- package/dist/{chunk-HATJQ74R.mjs → chunk-33U3M4YY.mjs} +2 -2
- package/dist/chunk-33U3M4YY.mjs.map +1 -0
- package/dist/chunk-CGGW4CI3.mjs +265 -0
- package/dist/chunk-CGGW4CI3.mjs.map +1 -0
- package/dist/chunk-PHCVLVZY.mjs +12 -0
- package/dist/chunk-PHCVLVZY.mjs.map +1 -0
- package/dist/cookie.d.mts +4 -1
- package/dist/cookie.d.ts +4 -1
- package/dist/cookie.js +35 -2
- package/dist/cookie.js.map +1 -1
- package/dist/cookie.mjs +33 -1
- package/dist/cookie.mjs.map +1 -1
- package/dist/derivedAuthState.d.mts +13 -7
- package/dist/derivedAuthState.d.ts +13 -7
- package/dist/derivedAuthState.js +22 -34
- package/dist/derivedAuthState.js.map +1 -1
- package/dist/derivedAuthState.mjs +22 -33
- package/dist/derivedAuthState.mjs.map +1 -1
- package/dist/errors-api.d.mts +49 -0
- package/dist/errors-api.d.ts +49 -0
- package/dist/errors-api.js +124 -0
- package/dist/errors-api.js.map +1 -0
- package/dist/errors-api.mjs +91 -0
- package/dist/errors-api.mjs.map +1 -0
- package/dist/errors.d.mts +17 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +139 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +111 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/eventBus.d.mts +28 -7
- package/dist/eventBus.d.ts +28 -7
- package/dist/eventBus.js +36 -21
- package/dist/eventBus.js.map +1 -1
- package/dist/eventBus.mjs +4 -26
- package/dist/eventBus.mjs.map +1 -1
- package/dist/{types/eventBus.d.ts → eventEmitter.d.mts} +4 -2
- package/dist/eventEmitter.d.ts +9 -0
- package/dist/eventEmitter.js +57 -0
- package/dist/eventEmitter.js.map +1 -0
- package/dist/eventEmitter.mjs +32 -0
- package/dist/eventEmitter.mjs.map +1 -0
- package/dist/loadScript.js +1 -1
- package/dist/loadScript.js.map +1 -1
- package/dist/loadScript.mjs +1 -1
- package/dist/loadTernUIScript.d.mts +4 -5
- package/dist/loadTernUIScript.d.ts +4 -5
- package/dist/loadTernUIScript.js +15 -7
- package/dist/loadTernUIScript.js.map +1 -1
- package/dist/loadTernUIScript.mjs +10 -7
- package/dist/loadTernUIScript.mjs.map +1 -1
- package/dist/pathMatcher.d.mts +14 -0
- package/dist/pathMatcher.d.ts +14 -0
- package/dist/pathMatcher.js +263 -0
- package/dist/pathMatcher.js.map +1 -0
- package/dist/pathMatcher.mjs +17 -0
- package/dist/pathMatcher.mjs.map +1 -0
- package/dist/pathToRegexp.d.mts +81 -0
- package/dist/pathToRegexp.d.ts +81 -0
- package/dist/pathToRegexp.js +292 -0
- package/dist/pathToRegexp.js.map +1 -0
- package/dist/pathToRegexp.mjs +9 -0
- package/dist/pathToRegexp.mjs.map +1 -0
- package/dist/react/index.d.mts +8 -2
- package/dist/react/index.d.ts +8 -2
- package/dist/react/index.js +28 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +25 -2
- package/dist/react/index.mjs.map +1 -1
- package/dist/resolveVersion.d.mts +3 -0
- package/dist/resolveVersion.d.ts +3 -0
- package/dist/resolveVersion.js +36 -0
- package/dist/resolveVersion.js.map +1 -0
- package/dist/resolveVersion.mjs +7 -0
- package/dist/resolveVersion.mjs.map +1 -0
- package/dist/serviceWorker.js +1 -1
- package/dist/serviceWorker.js.map +1 -1
- package/dist/serviceWorker.mjs +1 -1
- package/dist/serviceWorker.mjs.map +1 -1
- package/dist/ternStatusEvent.d.mts +15 -0
- package/dist/ternStatusEvent.d.ts +15 -0
- package/dist/ternStatusEvent.js +81 -0
- package/dist/ternStatusEvent.js.map +1 -0
- package/dist/ternStatusEvent.mjs +16 -0
- package/dist/ternStatusEvent.mjs.map +1 -0
- package/dist/url.d.mts +3 -0
- package/dist/url.d.ts +3 -0
- package/dist/url.js +33 -0
- package/dist/url.js.map +1 -0
- package/dist/url.mjs +8 -0
- package/dist/url.mjs.map +1 -0
- package/dist/utils/index.d.mts +5 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +44 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +17 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +23 -6
- package/dist/chunk-HATJQ74R.mjs.map +0 -1
- package/dist/types/cookie.d.ts +0 -12
- package/dist/types/cookie.d.ts.map +0 -1
- package/dist/types/derivedAuthState.d.ts +0 -7
- package/dist/types/derivedAuthState.d.ts.map +0 -1
- package/dist/types/eventBus.d.ts.map +0 -1
- package/dist/types/loadScript.d.ts +0 -10
- package/dist/types/loadScript.d.ts.map +0 -1
- package/dist/types/loadTernUIScript.d.ts +0 -21
- package/dist/types/loadTernUIScript.d.ts.map +0 -1
- package/dist/types/nextjs/client/auth-actions.d.ts +0 -1
- package/dist/types/nextjs/client/auth-actions.d.ts.map +0 -1
- package/dist/types/react/hooks/index.d.ts +0 -2
- package/dist/types/react/hooks/index.d.ts.map +0 -1
- package/dist/types/react/hooks/useTernSecure.d.ts +0 -3
- package/dist/types/react/hooks/useTernSecure.d.ts.map +0 -1
- package/dist/types/react/index.d.ts +0 -4
- package/dist/types/react/index.d.ts.map +0 -1
- package/dist/types/react/ternsecureCtx.d.ts +0 -26
- package/dist/types/react/ternsecureCtx.d.ts.map +0 -1
- package/dist/types/react/ternsecureProvider.d.ts +0 -20
- package/dist/types/react/ternsecureProvider.d.ts.map +0 -1
- package/dist/types/retry.d.ts +0 -46
- package/dist/types/retry.d.ts.map +0 -1
- package/dist/types/serviceWorker.d.ts +0 -12
- package/dist/types/serviceWorker.d.ts.map +0 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/pathToRegexp.ts
|
|
21
|
+
var pathToRegexp_exports = {};
|
|
22
|
+
__export(pathToRegexp_exports, {
|
|
23
|
+
match: () => match,
|
|
24
|
+
pathToRegexp: () => pathToRegexp
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(pathToRegexp_exports);
|
|
27
|
+
|
|
28
|
+
// src/compiled/path-to-regexp/index.js
|
|
29
|
+
function _(r) {
|
|
30
|
+
for (var n = [], e = 0; e < r.length; ) {
|
|
31
|
+
var a = r[e];
|
|
32
|
+
if (a === "*" || a === "+" || a === "?") {
|
|
33
|
+
n.push({
|
|
34
|
+
type: "MODIFIER",
|
|
35
|
+
index: e,
|
|
36
|
+
value: r[e++]
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (a === "\\") {
|
|
41
|
+
n.push({
|
|
42
|
+
type: "ESCAPED_CHAR",
|
|
43
|
+
index: e++,
|
|
44
|
+
value: r[e++]
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (a === "{") {
|
|
49
|
+
n.push({
|
|
50
|
+
type: "OPEN",
|
|
51
|
+
index: e,
|
|
52
|
+
value: r[e++]
|
|
53
|
+
});
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (a === "}") {
|
|
57
|
+
n.push({
|
|
58
|
+
type: "CLOSE",
|
|
59
|
+
index: e,
|
|
60
|
+
value: r[e++]
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (a === ":") {
|
|
65
|
+
for (var u = "", t = e + 1; t < r.length; ) {
|
|
66
|
+
var c = r.charCodeAt(t);
|
|
67
|
+
if (c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95) {
|
|
68
|
+
u += r[t++];
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (!u) throw new TypeError("Missing parameter name at ".concat(e));
|
|
74
|
+
n.push({
|
|
75
|
+
type: "NAME",
|
|
76
|
+
index: e,
|
|
77
|
+
value: u
|
|
78
|
+
}), e = t;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (a === "(") {
|
|
82
|
+
var o = 1, m = "", t = e + 1;
|
|
83
|
+
if (r[t] === "?") throw new TypeError('Pattern cannot start with "?" at '.concat(t));
|
|
84
|
+
for (; t < r.length; ) {
|
|
85
|
+
if (r[t] === "\\") {
|
|
86
|
+
m += r[t++] + r[t++];
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (r[t] === ")") {
|
|
90
|
+
if (o--, o === 0) {
|
|
91
|
+
t++;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
} else if (r[t] === "(" && (o++, r[t + 1] !== "?"))
|
|
95
|
+
throw new TypeError("Capturing groups are not allowed at ".concat(t));
|
|
96
|
+
m += r[t++];
|
|
97
|
+
}
|
|
98
|
+
if (o) throw new TypeError("Unbalanced pattern at ".concat(e));
|
|
99
|
+
if (!m) throw new TypeError("Missing pattern at ".concat(e));
|
|
100
|
+
n.push({
|
|
101
|
+
type: "PATTERN",
|
|
102
|
+
index: e,
|
|
103
|
+
value: m
|
|
104
|
+
}), e = t;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
n.push({
|
|
108
|
+
type: "CHAR",
|
|
109
|
+
index: e,
|
|
110
|
+
value: r[e++]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return n.push({
|
|
114
|
+
type: "END",
|
|
115
|
+
index: e,
|
|
116
|
+
value: ""
|
|
117
|
+
}), n;
|
|
118
|
+
}
|
|
119
|
+
function F(r, n) {
|
|
120
|
+
n === void 0 && (n = {});
|
|
121
|
+
for (var e = _(r), a = n.prefixes, u = a === void 0 ? "./" : a, t = n.delimiter, c = t === void 0 ? "/#?" : t, o = [], m = 0, h = 0, p = "", f = function(l) {
|
|
122
|
+
if (h < e.length && e[h].type === l) return e[h++].value;
|
|
123
|
+
}, w = function(l) {
|
|
124
|
+
var v = f(l);
|
|
125
|
+
if (v !== void 0) return v;
|
|
126
|
+
var E = e[h], N = E.type, S = E.index;
|
|
127
|
+
throw new TypeError("Unexpected ".concat(N, " at ").concat(S, ", expected ").concat(l));
|
|
128
|
+
}, d = function() {
|
|
129
|
+
for (var l = "", v; v = f("CHAR") || f("ESCAPED_CHAR"); ) l += v;
|
|
130
|
+
return l;
|
|
131
|
+
}, M = function(l) {
|
|
132
|
+
for (var v = 0, E = c; v < E.length; v++) {
|
|
133
|
+
var N = E[v];
|
|
134
|
+
if (l.indexOf(N) > -1) return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}, A = function(l) {
|
|
138
|
+
var v = o[o.length - 1], E = l || (v && typeof v == "string" ? v : "");
|
|
139
|
+
if (v && !E)
|
|
140
|
+
throw new TypeError('Must have text between two parameters, missing text after "'.concat(v.name, '"'));
|
|
141
|
+
return !E || M(E) ? "[^".concat(s(c), "]+?") : "(?:(?!".concat(s(E), ")[^").concat(s(c), "])+?");
|
|
142
|
+
}; h < e.length; ) {
|
|
143
|
+
var T = f("CHAR"), x = f("NAME"), C = f("PATTERN");
|
|
144
|
+
if (x || C) {
|
|
145
|
+
var g = T || "";
|
|
146
|
+
u.indexOf(g) === -1 && (p += g, g = ""), p && (o.push(p), p = ""), o.push({
|
|
147
|
+
name: x || m++,
|
|
148
|
+
prefix: g,
|
|
149
|
+
suffix: "",
|
|
150
|
+
pattern: C || A(g),
|
|
151
|
+
modifier: f("MODIFIER") || ""
|
|
152
|
+
});
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
var i = T || f("ESCAPED_CHAR");
|
|
156
|
+
if (i) {
|
|
157
|
+
p += i;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
p && (o.push(p), p = "");
|
|
161
|
+
var R = f("OPEN");
|
|
162
|
+
if (R) {
|
|
163
|
+
var g = d(), y = f("NAME") || "", O = f("PATTERN") || "", b = d();
|
|
164
|
+
w("CLOSE"), o.push({
|
|
165
|
+
name: y || (O ? m++ : ""),
|
|
166
|
+
pattern: y && !O ? A(g) : O,
|
|
167
|
+
prefix: g,
|
|
168
|
+
suffix: b,
|
|
169
|
+
modifier: f("MODIFIER") || ""
|
|
170
|
+
});
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
w("END");
|
|
174
|
+
}
|
|
175
|
+
return o;
|
|
176
|
+
}
|
|
177
|
+
function H(r, n) {
|
|
178
|
+
var e = [], a = P(r, e, n);
|
|
179
|
+
return I(a, e, n);
|
|
180
|
+
}
|
|
181
|
+
function I(r, n, e) {
|
|
182
|
+
e === void 0 && (e = {});
|
|
183
|
+
var a = e.decode, u = a === void 0 ? function(t) {
|
|
184
|
+
return t;
|
|
185
|
+
} : a;
|
|
186
|
+
return function(t) {
|
|
187
|
+
var c = r.exec(t);
|
|
188
|
+
if (!c) return false;
|
|
189
|
+
for (var o = c[0], m = c.index, h = /* @__PURE__ */ Object.create(null), p = function(w) {
|
|
190
|
+
if (c[w] === void 0) return "continue";
|
|
191
|
+
var d = n[w - 1];
|
|
192
|
+
d.modifier === "*" || d.modifier === "+" ? h[d.name] = c[w].split(d.prefix + d.suffix).map(function(M) {
|
|
193
|
+
return u(M, d);
|
|
194
|
+
}) : h[d.name] = u(c[w], d);
|
|
195
|
+
}, f = 1; f < c.length; f++)
|
|
196
|
+
p(f);
|
|
197
|
+
return {
|
|
198
|
+
path: o,
|
|
199
|
+
index: m,
|
|
200
|
+
params: h
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function s(r) {
|
|
205
|
+
return r.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
206
|
+
}
|
|
207
|
+
function D(r) {
|
|
208
|
+
return r && r.sensitive ? "" : "i";
|
|
209
|
+
}
|
|
210
|
+
function $(r, n) {
|
|
211
|
+
if (!n) return r;
|
|
212
|
+
for (var e = /\((?:\?<(.*?)>)?(?!\?)/g, a = 0, u = e.exec(r.source); u; )
|
|
213
|
+
n.push({
|
|
214
|
+
name: u[1] || a++,
|
|
215
|
+
prefix: "",
|
|
216
|
+
suffix: "",
|
|
217
|
+
modifier: "",
|
|
218
|
+
pattern: ""
|
|
219
|
+
}), u = e.exec(r.source);
|
|
220
|
+
return r;
|
|
221
|
+
}
|
|
222
|
+
function W(r, n, e) {
|
|
223
|
+
var a = r.map(function(u) {
|
|
224
|
+
return P(u, n, e).source;
|
|
225
|
+
});
|
|
226
|
+
return new RegExp("(?:".concat(a.join("|"), ")"), D(e));
|
|
227
|
+
}
|
|
228
|
+
function L(r, n, e) {
|
|
229
|
+
return U(F(r, e), n, e);
|
|
230
|
+
}
|
|
231
|
+
function U(r, n, e) {
|
|
232
|
+
e === void 0 && (e = {});
|
|
233
|
+
for (var a = e.strict, u = a === void 0 ? false : a, t = e.start, c = t === void 0 ? true : t, o = e.end, m = o === void 0 ? true : o, h = e.encode, p = h === void 0 ? function(v) {
|
|
234
|
+
return v;
|
|
235
|
+
} : h, f = e.delimiter, w = f === void 0 ? "/#?" : f, d = e.endsWith, M = d === void 0 ? "" : d, A = "[".concat(s(M), "]|$"), T = "[".concat(s(w), "]"), x = c ? "^" : "", C = 0, g = r; C < g.length; C++) {
|
|
236
|
+
var i = g[C];
|
|
237
|
+
if (typeof i == "string") x += s(p(i));
|
|
238
|
+
else {
|
|
239
|
+
var R = s(p(i.prefix)), y = s(p(i.suffix));
|
|
240
|
+
if (i.pattern)
|
|
241
|
+
if (n && n.push(i), R || y)
|
|
242
|
+
if (i.modifier === "+" || i.modifier === "*") {
|
|
243
|
+
var O = i.modifier === "*" ? "?" : "";
|
|
244
|
+
x += "(?:".concat(R, "((?:").concat(i.pattern, ")(?:").concat(y).concat(R, "(?:").concat(i.pattern, "))*)").concat(y, ")").concat(O);
|
|
245
|
+
} else x += "(?:".concat(R, "(").concat(i.pattern, ")").concat(y, ")").concat(i.modifier);
|
|
246
|
+
else {
|
|
247
|
+
if (i.modifier === "+" || i.modifier === "*")
|
|
248
|
+
throw new TypeError('Can not repeat "'.concat(i.name, '" without a prefix and suffix'));
|
|
249
|
+
x += "(".concat(i.pattern, ")").concat(i.modifier);
|
|
250
|
+
}
|
|
251
|
+
else x += "(?:".concat(R).concat(y, ")").concat(i.modifier);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (m) u || (x += "".concat(T, "?")), x += e.endsWith ? "(?=".concat(A, ")") : "$";
|
|
255
|
+
else {
|
|
256
|
+
var b = r[r.length - 1], l = typeof b == "string" ? T.indexOf(b[b.length - 1]) > -1 : b === void 0;
|
|
257
|
+
u || (x += "(?:".concat(T, "(?=").concat(A, "))?")), l || (x += "(?=".concat(T, "|").concat(A, ")"));
|
|
258
|
+
}
|
|
259
|
+
return new RegExp(x, D(e));
|
|
260
|
+
}
|
|
261
|
+
function P(r, n, e) {
|
|
262
|
+
return r instanceof RegExp ? $(r, n) : Array.isArray(r) ? W(r, n, e) : L(r, n, e);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/pathToRegexp.ts
|
|
266
|
+
var pathToRegexp = (path) => {
|
|
267
|
+
try {
|
|
268
|
+
return P(path);
|
|
269
|
+
} catch (e) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Invalid path: ${path}.
|
|
272
|
+
Consult the documentation of path-to-regexp here: https://github.com/pillarjs/path-to-regexp/tree/6.x
|
|
273
|
+
${e.message}`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
function match(str, options) {
|
|
278
|
+
try {
|
|
279
|
+
return H(str, options);
|
|
280
|
+
} catch (e) {
|
|
281
|
+
throw new Error(
|
|
282
|
+
`Invalid path and options: Consult the documentation of path-to-regexp here: https://github.com/pillarjs/path-to-regexp/tree/6.x
|
|
283
|
+
${e.message}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
288
|
+
0 && (module.exports = {
|
|
289
|
+
match,
|
|
290
|
+
pathToRegexp
|
|
291
|
+
});
|
|
292
|
+
//# sourceMappingURL=pathToRegexp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pathToRegexp.ts","../src/compiled/path-to-regexp/index.js"],"sourcesContent":["import type {\n Match,\n MatchFunction,\n ParseOptions,\n Path,\n RegexpToFunctionOptions,\n TokensToRegexpOptions,\n} from './compiled/path-to-regexp';\nimport { match as matchBase, pathToRegexp as pathToRegexpBase } from './compiled/path-to-regexp';\n\nexport const pathToRegexp = (path: string) => {\n try {\n // @ts-ignore no types exists for the pre-compiled package\n return pathToRegexpBase(path);\n } catch (e: any) {\n throw new Error(\n `Invalid path: ${path}.\\nConsult the documentation of path-to-regexp here: https://github.com/pillarjs/path-to-regexp/tree/6.x\\n${e.message}`,\n );\n }\n};\n\nexport function match<P extends object = object>(\n str: Path,\n options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions,\n): MatchFunction<P> {\n try {\n // @ts-ignore no types exists for the pre-compiled package\n return matchBase(str, options);\n } catch (e: any) {\n throw new Error(\n `Invalid path and options: Consult the documentation of path-to-regexp here: https://github.com/pillarjs/path-to-regexp/tree/6.x\\n${e.message}`,\n );\n }\n}\n\nexport { type Match, type MatchFunction };\n","/* eslint-disable no-redeclare, curly */\n\nfunction _(r) {\n for (var n = [], e = 0; e < r.length; ) {\n var a = r[e];\n if (a === '*' || a === '+' || a === '?') {\n n.push({\n type: 'MODIFIER',\n index: e,\n value: r[e++],\n });\n continue;\n }\n if (a === '\\\\') {\n n.push({\n type: 'ESCAPED_CHAR',\n index: e++,\n value: r[e++],\n });\n continue;\n }\n if (a === '{') {\n n.push({\n type: 'OPEN',\n index: e,\n value: r[e++],\n });\n continue;\n }\n if (a === '}') {\n n.push({\n type: 'CLOSE',\n index: e,\n value: r[e++],\n });\n continue;\n }\n if (a === ':') {\n for (var u = '', t = e + 1; t < r.length; ) {\n var c = r.charCodeAt(t);\n if ((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95) {\n u += r[t++];\n continue;\n }\n break;\n }\n if (!u) throw new TypeError('Missing parameter name at '.concat(e));\n n.push({\n type: 'NAME',\n index: e,\n value: u,\n }),\n (e = t);\n continue;\n }\n if (a === '(') {\n var o = 1,\n m = '',\n t = e + 1;\n if (r[t] === '?') throw new TypeError('Pattern cannot start with \"?\" at '.concat(t));\n for (; t < r.length; ) {\n if (r[t] === '\\\\') {\n m += r[t++] + r[t++];\n continue;\n }\n if (r[t] === ')') {\n if ((o--, o === 0)) {\n t++;\n break;\n }\n } else if (r[t] === '(' && (o++, r[t + 1] !== '?'))\n throw new TypeError('Capturing groups are not allowed at '.concat(t));\n m += r[t++];\n }\n if (o) throw new TypeError('Unbalanced pattern at '.concat(e));\n if (!m) throw new TypeError('Missing pattern at '.concat(e));\n n.push({\n type: 'PATTERN',\n index: e,\n value: m,\n }),\n (e = t);\n continue;\n }\n n.push({\n type: 'CHAR',\n index: e,\n value: r[e++],\n });\n }\n return (\n n.push({\n type: 'END',\n index: e,\n value: '',\n }),\n n\n );\n}\n\nfunction F(r, n) {\n n === void 0 && (n = {});\n for (\n var e = _(r),\n a = n.prefixes,\n u = a === void 0 ? './' : a,\n t = n.delimiter,\n c = t === void 0 ? '/#?' : t,\n o = [],\n m = 0,\n h = 0,\n p = '',\n f = function (l) {\n if (h < e.length && e[h].type === l) return e[h++].value;\n },\n w = function (l) {\n var v = f(l);\n if (v !== void 0) return v;\n var E = e[h],\n N = E.type,\n S = E.index;\n throw new TypeError('Unexpected '.concat(N, ' at ').concat(S, ', expected ').concat(l));\n },\n d = function () {\n for (var l = '', v; (v = f('CHAR') || f('ESCAPED_CHAR')); ) l += v;\n return l;\n },\n M = function (l) {\n for (var v = 0, E = c; v < E.length; v++) {\n var N = E[v];\n if (l.indexOf(N) > -1) return !0;\n }\n return !1;\n },\n A = function (l) {\n var v = o[o.length - 1],\n E = l || (v && typeof v == 'string' ? v : '');\n if (v && !E)\n throw new TypeError('Must have text between two parameters, missing text after \"'.concat(v.name, '\"'));\n return !E || M(E) ? '[^'.concat(s(c), ']+?') : '(?:(?!'.concat(s(E), ')[^').concat(s(c), '])+?');\n };\n h < e.length;\n\n ) {\n var T = f('CHAR'),\n x = f('NAME'),\n C = f('PATTERN');\n if (x || C) {\n var g = T || '';\n u.indexOf(g) === -1 && ((p += g), (g = '')),\n p && (o.push(p), (p = '')),\n o.push({\n name: x || m++,\n prefix: g,\n suffix: '',\n pattern: C || A(g),\n modifier: f('MODIFIER') || '',\n });\n continue;\n }\n var i = T || f('ESCAPED_CHAR');\n if (i) {\n p += i;\n continue;\n }\n p && (o.push(p), (p = ''));\n var R = f('OPEN');\n if (R) {\n var g = d(),\n y = f('NAME') || '',\n O = f('PATTERN') || '',\n b = d();\n w('CLOSE'),\n o.push({\n name: y || (O ? m++ : ''),\n pattern: y && !O ? A(g) : O,\n prefix: g,\n suffix: b,\n modifier: f('MODIFIER') || '',\n });\n continue;\n }\n w('END');\n }\n return o;\n}\n\nfunction H(r, n) {\n var e = [],\n a = P(r, e, n);\n return I(a, e, n);\n}\n\nfunction I(r, n, e) {\n e === void 0 && (e = {});\n var a = e.decode,\n u =\n a === void 0\n ? function (t) {\n return t;\n }\n : a;\n return function (t) {\n var c = r.exec(t);\n if (!c) return !1;\n for (\n var o = c[0],\n m = c.index,\n h = Object.create(null),\n p = function (w) {\n if (c[w] === void 0) return 'continue';\n var d = n[w - 1];\n d.modifier === '*' || d.modifier === '+'\n ? (h[d.name] = c[w].split(d.prefix + d.suffix).map(function (M) {\n return u(M, d);\n }))\n : (h[d.name] = u(c[w], d));\n },\n f = 1;\n f < c.length;\n f++\n )\n p(f);\n return {\n path: o,\n index: m,\n params: h,\n };\n };\n}\n\nfunction s(r) {\n return r.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1');\n}\n\nfunction D(r) {\n return r && r.sensitive ? '' : 'i';\n}\n\nfunction $(r, n) {\n if (!n) return r;\n for (var e = /\\((?:\\?<(.*?)>)?(?!\\?)/g, a = 0, u = e.exec(r.source); u; )\n n.push({\n name: u[1] || a++,\n prefix: '',\n suffix: '',\n modifier: '',\n pattern: '',\n }),\n (u = e.exec(r.source));\n return r;\n}\n\nfunction W(r, n, e) {\n var a = r.map(function (u) {\n return P(u, n, e).source;\n });\n return new RegExp('(?:'.concat(a.join('|'), ')'), D(e));\n}\n\nfunction L(r, n, e) {\n return U(F(r, e), n, e);\n}\n\nfunction U(r, n, e) {\n e === void 0 && (e = {});\n for (\n var a = e.strict,\n u = a === void 0 ? !1 : a,\n t = e.start,\n c = t === void 0 ? !0 : t,\n o = e.end,\n m = o === void 0 ? !0 : o,\n h = e.encode,\n p =\n h === void 0\n ? function (v) {\n return v;\n }\n : h,\n f = e.delimiter,\n w = f === void 0 ? '/#?' : f,\n d = e.endsWith,\n M = d === void 0 ? '' : d,\n A = '['.concat(s(M), ']|$'),\n T = '['.concat(s(w), ']'),\n x = c ? '^' : '',\n C = 0,\n g = r;\n C < g.length;\n C++\n ) {\n var i = g[C];\n if (typeof i == 'string') x += s(p(i));\n else {\n var R = s(p(i.prefix)),\n y = s(p(i.suffix));\n if (i.pattern)\n if ((n && n.push(i), R || y))\n if (i.modifier === '+' || i.modifier === '*') {\n var O = i.modifier === '*' ? '?' : '';\n x += '(?:'\n .concat(R, '((?:')\n .concat(i.pattern, ')(?:')\n .concat(y)\n .concat(R, '(?:')\n .concat(i.pattern, '))*)')\n .concat(y, ')')\n .concat(O);\n } else x += '(?:'.concat(R, '(').concat(i.pattern, ')').concat(y, ')').concat(i.modifier);\n else {\n if (i.modifier === '+' || i.modifier === '*')\n throw new TypeError('Can not repeat \"'.concat(i.name, '\" without a prefix and suffix'));\n x += '('.concat(i.pattern, ')').concat(i.modifier);\n }\n else x += '(?:'.concat(R).concat(y, ')').concat(i.modifier);\n }\n }\n if (m) u || (x += ''.concat(T, '?')), (x += e.endsWith ? '(?='.concat(A, ')') : '$');\n else {\n var b = r[r.length - 1],\n l = typeof b == 'string' ? T.indexOf(b[b.length - 1]) > -1 : b === void 0;\n u || (x += '(?:'.concat(T, '(?=').concat(A, '))?')), l || (x += '(?='.concat(T, '|').concat(A, ')'));\n }\n return new RegExp(x, D(e));\n}\n\nfunction P(r, n, e) {\n return r instanceof RegExp ? $(r, n) : Array.isArray(r) ? W(r, n, e) : L(r, n, e);\n}\nexport { H as match, P as pathToRegexp };"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,SAAS,EAAE,GAAG;AACZ,WAAS,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,UAAU;AACtC,QAAI,IAAI,EAAE,CAAC;AACX,QAAI,MAAM,OA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* as _tern_secure_types from '@tern-secure/types';
|
|
2
|
-
import { TernSecureInstanceTree, TernSecureAuthProvider, TernSecureState } from '@tern-secure/types';
|
|
2
|
+
import { TernSecureInstanceTree, TernSecureAuthProvider, TernSecureState, TernSecureAuth } from '@tern-secure/types';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default from 'react';
|
|
5
5
|
|
|
@@ -51,4 +51,10 @@ type UseCtxFn<T> = () => T;
|
|
|
51
51
|
*/
|
|
52
52
|
declare const createContextAndHook: <CtxValue>(displayName: string, options?: Options) => [ContextAndHook<CtxValue>, UseCtxFn<CtxValue>, UseCtxFn<CtxValue | Partial<CtxValue>>];
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
declare const TernSecureAuthCtx: react.Context<{
|
|
55
|
+
value: TernSecureAuth;
|
|
56
|
+
} | undefined>;
|
|
57
|
+
declare const useTernSecureAuthCtx: () => TernSecureAuth;
|
|
58
|
+
declare function useAssertWrappedByTernSecureAuthProvider(displayNameOrFn: string | (() => void)): void;
|
|
59
|
+
|
|
60
|
+
export { SessionContext, TernSecureAuthContext, TernSecureAuthCtx, TernSecureInstanceContext, UserContext, assertContextExists, createContextAndHook, useAssertWrappedByTernSecureAuthProvider, useAssertWrappedByTernSecureProvider, useSessionContext, useTernSecure, useTernSecureAuthContext, useTernSecureAuthCtx, useTernSecureInstanceContext, useUserContext };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _tern_secure_types from '@tern-secure/types';
|
|
2
|
-
import { TernSecureInstanceTree, TernSecureAuthProvider, TernSecureState } from '@tern-secure/types';
|
|
2
|
+
import { TernSecureInstanceTree, TernSecureAuthProvider, TernSecureState, TernSecureAuth } from '@tern-secure/types';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default from 'react';
|
|
5
5
|
|
|
@@ -51,4 +51,10 @@ type UseCtxFn<T> = () => T;
|
|
|
51
51
|
*/
|
|
52
52
|
declare const createContextAndHook: <CtxValue>(displayName: string, options?: Options) => [ContextAndHook<CtxValue>, UseCtxFn<CtxValue>, UseCtxFn<CtxValue | Partial<CtxValue>>];
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
declare const TernSecureAuthCtx: react.Context<{
|
|
55
|
+
value: TernSecureAuth;
|
|
56
|
+
} | undefined>;
|
|
57
|
+
declare const useTernSecureAuthCtx: () => TernSecureAuth;
|
|
58
|
+
declare function useAssertWrappedByTernSecureAuthProvider(displayNameOrFn: string | (() => void)): void;
|
|
59
|
+
|
|
60
|
+
export { SessionContext, TernSecureAuthContext, TernSecureAuthCtx, TernSecureInstanceContext, UserContext, assertContextExists, createContextAndHook, useAssertWrappedByTernSecureAuthProvider, useAssertWrappedByTernSecureProvider, useSessionContext, useTernSecure, useTernSecureAuthContext, useTernSecureAuthCtx, useTernSecureInstanceContext, useUserContext };
|
package/dist/react/index.js
CHANGED
|
@@ -32,20 +32,23 @@ var react_exports = {};
|
|
|
32
32
|
__export(react_exports, {
|
|
33
33
|
SessionContext: () => SessionContext,
|
|
34
34
|
TernSecureAuthContext: () => TernSecureAuthContext,
|
|
35
|
+
TernSecureAuthCtx: () => TernSecureAuthCtx,
|
|
35
36
|
TernSecureInstanceContext: () => TernSecureInstanceContext,
|
|
36
37
|
UserContext: () => UserContext,
|
|
37
38
|
assertContextExists: () => assertContextExists,
|
|
38
39
|
createContextAndHook: () => createContextAndHook,
|
|
40
|
+
useAssertWrappedByTernSecureAuthProvider: () => useAssertWrappedByTernSecureAuthProvider,
|
|
39
41
|
useAssertWrappedByTernSecureProvider: () => useAssertWrappedByTernSecureProvider,
|
|
40
42
|
useSessionContext: () => useSessionContext,
|
|
41
43
|
useTernSecure: () => useTernSecure,
|
|
42
44
|
useTernSecureAuthContext: () => useTernSecureAuthContext,
|
|
45
|
+
useTernSecureAuthCtx: () => useTernSecureAuthCtx,
|
|
43
46
|
useTernSecureInstanceContext: () => useTernSecureInstanceContext,
|
|
44
47
|
useUserContext: () => useUserContext
|
|
45
48
|
});
|
|
46
49
|
module.exports = __toCommonJS(react_exports);
|
|
47
50
|
|
|
48
|
-
// src/react/
|
|
51
|
+
// src/react/ternSecureProvider.tsx
|
|
49
52
|
var import_react2 = require("react");
|
|
50
53
|
|
|
51
54
|
// src/react/ternsecureCtx.ts
|
|
@@ -71,7 +74,7 @@ var createContextAndHook = (displayName, options) => {
|
|
|
71
74
|
return [Ctx, useCtx, useCtxWithoutGuarantee];
|
|
72
75
|
};
|
|
73
76
|
|
|
74
|
-
// src/react/
|
|
77
|
+
// src/react/ternSecureProvider.tsx
|
|
75
78
|
var [TernSecureInstanceContext, useTernSecureInstanceContext] = createContextAndHook("TernSecureInstanceContext");
|
|
76
79
|
var [TernSecureAuthContext, useTernSecureAuthContext] = createContextAndHook("TernSecureAuthContext");
|
|
77
80
|
var [SessionContext, useSessionContext] = createContextAndHook("SessionContext");
|
|
@@ -98,18 +101,41 @@ var useTernSecure = () => {
|
|
|
98
101
|
useAssertWrappedByTernSecureProvider("useTernSecure");
|
|
99
102
|
return useTernSecureInstanceContext();
|
|
100
103
|
};
|
|
104
|
+
|
|
105
|
+
// src/react/ternSecureAuthProvider.tsx
|
|
106
|
+
var import_react3 = require("react");
|
|
107
|
+
var [TernSecureAuthCtx, useTernSecureAuthCtx] = createContextAndHook("TernSecureAuthCtx");
|
|
108
|
+
function useAssertWrappedByTernSecureAuthProvider(displayNameOrFn) {
|
|
109
|
+
const ctx = (0, import_react3.useContext)(TernSecureAuthCtx);
|
|
110
|
+
if (!ctx) {
|
|
111
|
+
if (typeof displayNameOrFn === "function") {
|
|
112
|
+
displayNameOrFn();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
throw new Error(
|
|
116
|
+
`${displayNameOrFn} can only be used within the <TernSecureProvider /> component.
|
|
117
|
+
|
|
118
|
+
Possible fixes:
|
|
119
|
+
1. Ensure that the <TernSecureProvider /> is correctly wrapping your application
|
|
120
|
+
2. Check for multiple versions of @tern-secure packages in your project`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
101
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102
125
|
0 && (module.exports = {
|
|
103
126
|
SessionContext,
|
|
104
127
|
TernSecureAuthContext,
|
|
128
|
+
TernSecureAuthCtx,
|
|
105
129
|
TernSecureInstanceContext,
|
|
106
130
|
UserContext,
|
|
107
131
|
assertContextExists,
|
|
108
132
|
createContextAndHook,
|
|
133
|
+
useAssertWrappedByTernSecureAuthProvider,
|
|
109
134
|
useAssertWrappedByTernSecureProvider,
|
|
110
135
|
useSessionContext,
|
|
111
136
|
useTernSecure,
|
|
112
137
|
useTernSecureAuthContext,
|
|
138
|
+
useTernSecureAuthCtx,
|
|
113
139
|
useTernSecureInstanceContext,
|
|
114
140
|
useUserContext
|
|
115
141
|
});
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/index.ts","../../src/react/
|
|
1
|
+
{"version":3,"sources":["../../src/react/index.ts","../../src/react/ternSecureProvider.tsx","../../src/react/ternsecureCtx.ts","../../src/react/hooks/useTernSecure.ts","../../src/react/ternSecureAuthProvider.tsx"],"sourcesContent":["export * from './hooks'\n\nexport {\n useAssertWrappedByTernSecureProvider,\n useTernSecureInstanceContext,\n useTernSecureAuthContext,\n useSessionContext,\n useUserContext,\n SessionContext,\n UserContext,\n TernSecureAuthContext,\n TernSecureInstanceContext\n} from './ternSecureProvider'\n\nexport {\n assertContextExists,\n createContextAndHook\n} from './ternsecureCtx'\n\nexport {\n TernSecureAuthCtx,\n useTernSecureAuthCtx,\n useAssertWrappedByTernSecureAuthProvider\n} from './ternSecureAuthProvider'","'use client'\n\nimport type { \n TernSecureAuthProvider,\n TernSecureInstanceTree,\n TernSecureState,\n} from '@tern-secure/types';\nimport { useContext } from 'react';\n\nimport { createContextAndHook } from './ternsecureCtx';\n\nexport type TernSecureAuthContextType = {\n authProvider: TernSecureAuthProvider | null | undefined;\n authState: TernSecureState;\n}\n\n\n// Create TernSecure instance context\nconst [TernSecureInstanceContext, useTernSecureInstanceContext] = \n createContextAndHook<TernSecureInstanceTree>('TernSecureInstanceContext');\n\nconst [TernSecureAuthContext, useTernSecureAuthContext] =\n createContextAndHook<TernSecureAuthContextType>('TernSecureAuthContext');\n\nconst [SessionContext, useSessionContext] = \ncreateContextAndHook<TernSecureInstanceTree['auth']['session']>('SessionContext');\n\nconst [UserContext, useUserContext] = \ncreateContextAndHook<TernSecureInstanceTree['auth']['user']>('UserContext');\n\n// Assert helper\nfunction useAssertWrappedByTernSecureProvider(displayNameOrFn: string | (() => void)): void {\n //const ctx = useTernSecureInstanceContext();\n const ctx = useContext(TernSecureInstanceContext);\n \n if (!ctx) {\n if (typeof displayNameOrFn === 'function') {\n displayNameOrFn();\n return;\n }\n\n throw new Error(\n `${displayNameOrFn} can only be used within the <TernSecureProvider /> component.\n \nPossible fixes:\n1. Ensure that the <TernSecureProvider /> is correctly wrapping your application\n2. Check for multiple versions of @tern-secure packages in your project`\n );\n }\n}\n\n\nexport {\n TernSecureInstanceContext,\n TernSecureAuthContext,\n SessionContext,\n UserContext,\n useTernSecureAuthContext,\n useSessionContext,\n useUserContext,\n useTernSecureInstanceContext,\n useAssertWrappedByTernSecureProvider\n};","'use client'\n\nimport React from 'react';\n\n/**\n * Assert that the context value exists, otherwise throw an error.\n *\n * @internal\n */\nexport function assertContextExists(contextVal: unknown, msgOrCtx: string | React.Context<any>): asserts contextVal {\n if (!contextVal) {\n throw typeof msgOrCtx === 'string' ? new Error(msgOrCtx) : new Error(`${msgOrCtx.displayName} not found`);\n }\n}\ntype Options = { assertCtxFn?: (v: unknown, msg: string) => void };\ntype ContextAndHook<T> = React.Context<{ value: T } | undefined>;\ntype UseCtxFn<T> = () => T;\n\n/**\n * Create and return a Context and two hooks that return the context value.\n * The Context type is derived from the type passed in by the user.\n *\n * The first hook returned guarantees that the context exists so the returned value is always `CtxValue`\n * The second hook makes no guarantees, so the returned value can be `CtxValue | undefined`\n *\n * @internal\n */\n\nexport const createContextAndHook = <CtxValue>(\n displayName: string,\n options?: Options,\n): [ContextAndHook<CtxValue>, UseCtxFn<CtxValue>, UseCtxFn<CtxValue | Partial<CtxValue>>] => {\n const { assertCtxFn = assertContextExists } = options || {};\n const Ctx = React.createContext<{ value: CtxValue } | undefined >(undefined);\n Ctx.displayName = displayName;\n\n const useCtx = () => {\n const ctx = React.useContext(Ctx);\n assertCtxFn(ctx, `${displayName} not found`);\n return (ctx as any).value as CtxValue;\n };\n\n const useCtxWithoutGuarantee = () => {\n const ctx = React.useContext(Ctx);\n return ctx ? ctx.value : {}\n };\n\n /**\n * Assert that the context value exists, otherwise throw an error.\n if (ctx === undefined) {\n throw new Error(`use${name} must be used within a ${name}Provider`);\n }\n return ctx.value;\n */\n\n return [Ctx, useCtx, useCtxWithoutGuarantee];\n}","import type { \n TernSecureInstanceTree\n} from \"@tern-secure/types\";\n\nimport { \n useAssertWrappedByTernSecureProvider, \n useTernSecureInstanceContext \n} from \"../ternSecureProvider\";\n\nexport const useTernSecure = (): TernSecureInstanceTree => {\n /**\n * if no assertion is needed, you can use the following:\n * const instance = useTernSecureInstanceContext();\n * if (!instance) {\n * throw new Error('useTernSecure must be used within a TernSecureProvider');\n * }\n * return instance;\n */\n \n useAssertWrappedByTernSecureProvider('useTernSecure');\n return useTernSecureInstanceContext();\n}","'use client'\n\nimport type { \n TernSecureAuth,\n} from '@tern-secure/types';\nimport { useContext } from 'react';\n\nimport { createContextAndHook } from './ternsecureCtx';\n\n\nconst [TernSecureAuthCtx, useTernSecureAuthCtx] =\n createContextAndHook<TernSecureAuth>('TernSecureAuthCtx');\n\nfunction useAssertWrappedByTernSecureAuthProvider(displayNameOrFn: string | (() => void)): void {\n //const ctx = useTernSecureInstanceContext();\n const ctx = useContext(TernSecureAuthCtx);\n \n if (!ctx) {\n if (typeof displayNameOrFn === 'function') {\n displayNameOrFn();\n return;\n }\n \n throw new Error(\n `${displayNameOrFn} can only be used within the <TernSecureProvider /> component.\n \nPossible fixes:\n1. Ensure that the <TernSecureProvider /> is correctly wrapping your application\n2. Check for multiple versions of @tern-secure packages in your project`\n );\n }\n}\n\n\n\nexport {\n TernSecureAuthCtx,\n useTernSecureAuthCtx,\n useAssertWrappedByTernSecureAuthProvider,\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,IAAAA,gBAA2B;;;ACL3B,mBAAkB;AAOX,SAAS,oBAAoB,YAAqB,UAA2D;AAClH,MAAI,CAAC,YAAY;AACf,UAAM,OAAO,aAAa,WAAW,IAAI,MAAM,QAAQ,IAAI,IAAI,MAAM,GAAG,SAAS,WAAW,YAAY;AAAA,EAC1G;AACF;AAeO,IAAM,uBAAuB,CAClC,aACA,YAC2F;AAC3F,QAAM,EAAE,cAAc,oBAAoB,IAAI,WAAW,CAAC;AAC1D,QAAM,MAAM,aAAAC,QAAM,cAAgD,MAAS;AAC3E,MAAI,cAAc;AAElB,QAAM,SAAS,MAAM;AACnB,UAAM,MAAM,aAAAA,QAAM,WAAW,GAAG;AAChC,gBAAY,KAAK,GAAG,WAAW,YAAY;AAC3C,WAAQ,IAAY;AAAA,EACtB;AAEA,QAAM,yBAAyB,MAAM;AACnC,UAAM,MAAM,aAAAA,QAAM,WAAW,GAAG;AAChC,WAAO,MAAM,IAAI,QAAQ,CAAC;AAAA,EAC5B;AAUA,SAAO,CAAC,KAAK,QAAQ,sBAAsB;AAC7C;;;ADtCA,IAAM,CAAC,2BAA2B,4BAA4B,IAC5D,qBAA6C,2BAA2B;AAE1E,IAAM,CAAC,uBAAuB,wBAAwB,IACpD,qBAAgD,uBAAuB;AAEzE,IAAM,CAAC,gBAAgB,iBAAiB,IACxC,qBAAgE,gBAAgB;AAEhF,IAAM,CAAC,aAAa,cAAc,IAClC,qBAA6D,aAAa;AAG1E,SAAS,qCAAqC,iBAA8C;AAE1F,QAAM,UAAM,0BAAW,yBAAyB;AAEhD,MAAI,CAAC,KAAK;AACR,QAAI,OAAO,oBAAoB,YAAY;AACzC,sBAAgB;AAChB;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,GAAG,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpB;AAAA,EACF;AACF;;;AExCO,IAAM,gBAAgB,MAA8B;AAUvD,uCAAqC,eAAe;AACpD,SAAO,6BAA6B;AACxC;;;AChBA,IAAAC,gBAA2B;AAK3B,IAAM,CAAC,mBAAmB,oBAAoB,IAC5C,qBAAqC,mBAAmB;AAE1D,SAAS,yCAAyC,iBAA8C;AAE9F,QAAM,UAAM,0BAAW,iBAAiB;AAExC,MAAI,CAAC,KAAK;AACR,QAAI,OAAO,oBAAoB,YAAY;AACzC,sBAAgB;AAChB;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,GAAG,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpB;AAAA,EACF;AACF;","names":["import_react","React","import_react"]}
|
package/dist/react/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/react/
|
|
1
|
+
// src/react/ternSecureProvider.tsx
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
|
|
4
4
|
// src/react/ternsecureCtx.ts
|
|
@@ -24,7 +24,7 @@ var createContextAndHook = (displayName, options) => {
|
|
|
24
24
|
return [Ctx, useCtx, useCtxWithoutGuarantee];
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
// src/react/
|
|
27
|
+
// src/react/ternSecureProvider.tsx
|
|
28
28
|
var [TernSecureInstanceContext, useTernSecureInstanceContext] = createContextAndHook("TernSecureInstanceContext");
|
|
29
29
|
var [TernSecureAuthContext, useTernSecureAuthContext] = createContextAndHook("TernSecureAuthContext");
|
|
30
30
|
var [SessionContext, useSessionContext] = createContextAndHook("SessionContext");
|
|
@@ -51,17 +51,40 @@ var useTernSecure = () => {
|
|
|
51
51
|
useAssertWrappedByTernSecureProvider("useTernSecure");
|
|
52
52
|
return useTernSecureInstanceContext();
|
|
53
53
|
};
|
|
54
|
+
|
|
55
|
+
// src/react/ternSecureAuthProvider.tsx
|
|
56
|
+
import { useContext as useContext2 } from "react";
|
|
57
|
+
var [TernSecureAuthCtx, useTernSecureAuthCtx] = createContextAndHook("TernSecureAuthCtx");
|
|
58
|
+
function useAssertWrappedByTernSecureAuthProvider(displayNameOrFn) {
|
|
59
|
+
const ctx = useContext2(TernSecureAuthCtx);
|
|
60
|
+
if (!ctx) {
|
|
61
|
+
if (typeof displayNameOrFn === "function") {
|
|
62
|
+
displayNameOrFn();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(
|
|
66
|
+
`${displayNameOrFn} can only be used within the <TernSecureProvider /> component.
|
|
67
|
+
|
|
68
|
+
Possible fixes:
|
|
69
|
+
1. Ensure that the <TernSecureProvider /> is correctly wrapping your application
|
|
70
|
+
2. Check for multiple versions of @tern-secure packages in your project`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
54
74
|
export {
|
|
55
75
|
SessionContext,
|
|
56
76
|
TernSecureAuthContext,
|
|
77
|
+
TernSecureAuthCtx,
|
|
57
78
|
TernSecureInstanceContext,
|
|
58
79
|
UserContext,
|
|
59
80
|
assertContextExists,
|
|
60
81
|
createContextAndHook,
|
|
82
|
+
useAssertWrappedByTernSecureAuthProvider,
|
|
61
83
|
useAssertWrappedByTernSecureProvider,
|
|
62
84
|
useSessionContext,
|
|
63
85
|
useTernSecure,
|
|
64
86
|
useTernSecureAuthContext,
|
|
87
|
+
useTernSecureAuthCtx,
|
|
65
88
|
useTernSecureInstanceContext,
|
|
66
89
|
useUserContext
|
|
67
90
|
};
|
package/dist/react/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/
|
|
1
|
+
{"version":3,"sources":["../../src/react/ternSecureProvider.tsx","../../src/react/ternsecureCtx.ts","../../src/react/hooks/useTernSecure.ts","../../src/react/ternSecureAuthProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { \n TernSecureAuthProvider,\n TernSecureInstanceTree,\n TernSecureState,\n} from '@tern-secure/types';\nimport { useContext } from 'react';\n\nimport { createContextAndHook } from './ternsecureCtx';\n\nexport type TernSecureAuthContextType = {\n authProvider: TernSecureAuthProvider | null | undefined;\n authState: TernSecureState;\n}\n\n\n// Create TernSecure instance context\nconst [TernSecureInstanceContext, useTernSecureInstanceContext] = \n createContextAndHook<TernSecureInstanceTree>('TernSecureInstanceContext');\n\nconst [TernSecureAuthContext, useTernSecureAuthContext] =\n createContextAndHook<TernSecureAuthContextType>('TernSecureAuthContext');\n\nconst [SessionContext, useSessionContext] = \ncreateContextAndHook<TernSecureInstanceTree['auth']['session']>('SessionContext');\n\nconst [UserContext, useUserContext] = \ncreateContextAndHook<TernSecureInstanceTree['auth']['user']>('UserContext');\n\n// Assert helper\nfunction useAssertWrappedByTernSecureProvider(displayNameOrFn: string | (() => void)): void {\n //const ctx = useTernSecureInstanceContext();\n const ctx = useContext(TernSecureInstanceContext);\n \n if (!ctx) {\n if (typeof displayNameOrFn === 'function') {\n displayNameOrFn();\n return;\n }\n\n throw new Error(\n `${displayNameOrFn} can only be used within the <TernSecureProvider /> component.\n \nPossible fixes:\n1. Ensure that the <TernSecureProvider /> is correctly wrapping your application\n2. Check for multiple versions of @tern-secure packages in your project`\n );\n }\n}\n\n\nexport {\n TernSecureInstanceContext,\n TernSecureAuthContext,\n SessionContext,\n UserContext,\n useTernSecureAuthContext,\n useSessionContext,\n useUserContext,\n useTernSecureInstanceContext,\n useAssertWrappedByTernSecureProvider\n};","'use client'\n\nimport React from 'react';\n\n/**\n * Assert that the context value exists, otherwise throw an error.\n *\n * @internal\n */\nexport function assertContextExists(contextVal: unknown, msgOrCtx: string | React.Context<any>): asserts contextVal {\n if (!contextVal) {\n throw typeof msgOrCtx === 'string' ? new Error(msgOrCtx) : new Error(`${msgOrCtx.displayName} not found`);\n }\n}\ntype Options = { assertCtxFn?: (v: unknown, msg: string) => void };\ntype ContextAndHook<T> = React.Context<{ value: T } | undefined>;\ntype UseCtxFn<T> = () => T;\n\n/**\n * Create and return a Context and two hooks that return the context value.\n * The Context type is derived from the type passed in by the user.\n *\n * The first hook returned guarantees that the context exists so the returned value is always `CtxValue`\n * The second hook makes no guarantees, so the returned value can be `CtxValue | undefined`\n *\n * @internal\n */\n\nexport const createContextAndHook = <CtxValue>(\n displayName: string,\n options?: Options,\n): [ContextAndHook<CtxValue>, UseCtxFn<CtxValue>, UseCtxFn<CtxValue | Partial<CtxValue>>] => {\n const { assertCtxFn = assertContextExists } = options || {};\n const Ctx = React.createContext<{ value: CtxValue } | undefined >(undefined);\n Ctx.displayName = displayName;\n\n const useCtx = () => {\n const ctx = React.useContext(Ctx);\n assertCtxFn(ctx, `${displayName} not found`);\n return (ctx as any).value as CtxValue;\n };\n\n const useCtxWithoutGuarantee = () => {\n const ctx = React.useContext(Ctx);\n return ctx ? ctx.value : {}\n };\n\n /**\n * Assert that the context value exists, otherwise throw an error.\n if (ctx === undefined) {\n throw new Error(`use${name} must be used within a ${name}Provider`);\n }\n return ctx.value;\n */\n\n return [Ctx, useCtx, useCtxWithoutGuarantee];\n}","import type { \n TernSecureInstanceTree\n} from \"@tern-secure/types\";\n\nimport { \n useAssertWrappedByTernSecureProvider, \n useTernSecureInstanceContext \n} from \"../ternSecureProvider\";\n\nexport const useTernSecure = (): TernSecureInstanceTree => {\n /**\n * if no assertion is needed, you can use the following:\n * const instance = useTernSecureInstanceContext();\n * if (!instance) {\n * throw new Error('useTernSecure must be used within a TernSecureProvider');\n * }\n * return instance;\n */\n \n useAssertWrappedByTernSecureProvider('useTernSecure');\n return useTernSecureInstanceContext();\n}","'use client'\n\nimport type { \n TernSecureAuth,\n} from '@tern-secure/types';\nimport { useContext } from 'react';\n\nimport { createContextAndHook } from './ternsecureCtx';\n\n\nconst [TernSecureAuthCtx, useTernSecureAuthCtx] =\n createContextAndHook<TernSecureAuth>('TernSecureAuthCtx');\n\nfunction useAssertWrappedByTernSecureAuthProvider(displayNameOrFn: string | (() => void)): void {\n //const ctx = useTernSecureInstanceContext();\n const ctx = useContext(TernSecureAuthCtx);\n \n if (!ctx) {\n if (typeof displayNameOrFn === 'function') {\n displayNameOrFn();\n return;\n }\n \n throw new Error(\n `${displayNameOrFn} can only be used within the <TernSecureProvider /> component.\n \nPossible fixes:\n1. Ensure that the <TernSecureProvider /> is correctly wrapping your application\n2. Check for multiple versions of @tern-secure packages in your project`\n );\n }\n}\n\n\n\nexport {\n TernSecureAuthCtx,\n useTernSecureAuthCtx,\n useAssertWrappedByTernSecureAuthProvider,\n};"],"mappings":";AAOA,SAAS,kBAAkB;;;ACL3B,OAAO,WAAW;AAOX,SAAS,oBAAoB,YAAqB,UAA2D;AAClH,MAAI,CAAC,YAAY;AACf,UAAM,OAAO,aAAa,WAAW,IAAI,MAAM,QAAQ,IAAI,IAAI,MAAM,GAAG,SAAS,WAAW,YAAY;AAAA,EAC1G;AACF;AAeO,IAAM,uBAAuB,CAClC,aACA,YAC2F;AAC3F,QAAM,EAAE,cAAc,oBAAoB,IAAI,WAAW,CAAC;AAC1D,QAAM,MAAM,MAAM,cAAgD,MAAS;AAC3E,MAAI,cAAc;AAElB,QAAM,SAAS,MAAM;AACnB,UAAM,MAAM,MAAM,WAAW,GAAG;AAChC,gBAAY,KAAK,GAAG,WAAW,YAAY;AAC3C,WAAQ,IAAY;AAAA,EACtB;AAEA,QAAM,yBAAyB,MAAM;AACnC,UAAM,MAAM,MAAM,WAAW,GAAG;AAChC,WAAO,MAAM,IAAI,QAAQ,CAAC;AAAA,EAC5B;AAUA,SAAO,CAAC,KAAK,QAAQ,sBAAsB;AAC7C;;;ADtCA,IAAM,CAAC,2BAA2B,4BAA4B,IAC5D,qBAA6C,2BAA2B;AAE1E,IAAM,CAAC,uBAAuB,wBAAwB,IACpD,qBAAgD,uBAAuB;AAEzE,IAAM,CAAC,gBAAgB,iBAAiB,IACxC,qBAAgE,gBAAgB;AAEhF,IAAM,CAAC,aAAa,cAAc,IAClC,qBAA6D,aAAa;AAG1E,SAAS,qCAAqC,iBAA8C;AAE1F,QAAM,MAAM,WAAW,yBAAyB;AAEhD,MAAI,CAAC,KAAK;AACR,QAAI,OAAO,oBAAoB,YAAY;AACzC,sBAAgB;AAChB;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,GAAG,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpB;AAAA,EACF;AACF;;;AExCO,IAAM,gBAAgB,MAA8B;AAUvD,uCAAqC,eAAe;AACpD,SAAO,6BAA6B;AACxC;;;AChBA,SAAS,cAAAA,mBAAkB;AAK3B,IAAM,CAAC,mBAAmB,oBAAoB,IAC5C,qBAAqC,mBAAmB;AAE1D,SAAS,yCAAyC,iBAA8C;AAE9F,QAAM,MAAMC,YAAW,iBAAiB;AAExC,MAAI,CAAC,KAAK;AACR,QAAI,OAAO,oBAAoB,YAAY;AACzC,sBAAgB;AAChB;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,GAAG,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,IAKpB;AAAA,EACF;AACF;","names":["useContext","useContext"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/resolveVersion.ts
|
|
21
|
+
var resolveVersion_exports = {};
|
|
22
|
+
__export(resolveVersion_exports, {
|
|
23
|
+
resolveVersion: () => resolveVersion
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(resolveVersion_exports);
|
|
26
|
+
var resolveVersion = (ternUIVersion, packageVersion = TERN_UI_VERSION) => {
|
|
27
|
+
if (ternUIVersion) {
|
|
28
|
+
return ternUIVersion;
|
|
29
|
+
}
|
|
30
|
+
return packageVersion;
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
resolveVersion
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=resolveVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolveVersion.ts"],"sourcesContent":["\nexport const resolveVersion = (ternUIVersion: string | undefined, packageVersion = TERN_UI_VERSION) => {\n if (ternUIVersion) {\n return ternUIVersion\n }\n\n return packageVersion;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,IAAM,iBAAiB,CAAC,eAAmC,iBAAiB,oBAAoB;AACnG,MAAI,eAAe;AACf,WAAO;AAAA,EACX;AAEA,SAAO;AACX;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|