@tern-secure/shared 1.2.0 → 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-XCVOYULH.mjs → chunk-PHCVLVZY.mjs} +2 -2
- package/dist/{chunk-XCVOYULH.mjs.map → chunk-PHCVLVZY.mjs.map} +1 -1
- 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.js +5 -3
- package/dist/loadTernUIScript.js.map +1 -1
- package/dist/loadTernUIScript.mjs +7 -5
- 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.js +1 -1
- package/dist/resolveVersion.js.map +1 -1
- package/dist/resolveVersion.mjs +1 -1
- 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 +22 -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 -20
- 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/resolveVersion.d.ts +0 -2
- package/dist/types/resolveVersion.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,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pathToRegexp
|
|
3
|
+
} from "./chunk-CGGW4CI3.mjs";
|
|
4
|
+
|
|
5
|
+
// src/pathMatcher.ts
|
|
6
|
+
var precomputePathRegex = (patterns) => {
|
|
7
|
+
return patterns.map((pattern) => pattern instanceof RegExp ? pattern : pathToRegexp(pattern));
|
|
8
|
+
};
|
|
9
|
+
var createPathMatcher = (patterns) => {
|
|
10
|
+
const routePatterns = [patterns || ""].flat().filter(Boolean);
|
|
11
|
+
const matchers = precomputePathRegex(routePatterns);
|
|
12
|
+
return (pathname) => matchers.some((matcher) => matcher.test(pathname));
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
createPathMatcher
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=pathMatcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pathMatcher.ts"],"sourcesContent":["import type { Autocomplete } from '@tern-secure/types';\n\nimport { pathToRegexp } from './pathToRegexp';\n\nexport type WithPathPatternWildcard<T = string> = `${T & string}(.*)`;\nexport type PathPattern = Autocomplete<WithPathPatternWildcard>;\nexport type PathMatcherParam = Array<RegExp | PathPattern> | RegExp | PathPattern;\n\nconst precomputePathRegex = (patterns: Array<string | RegExp>) => {\n return patterns.map(pattern => (pattern instanceof RegExp ? pattern : pathToRegexp(pattern)));\n};\n\n/**\n * Creates a function that matches paths against a set of patterns.\n *\n * @param patterns - A string, RegExp, or array of patterns to match against\n * @returns A function that takes a pathname and returns true if it matches any of the patterns\n */\nexport const createPathMatcher = (patterns: PathMatcherParam) => {\n const routePatterns = [patterns || ''].flat().filter(Boolean);\n const matchers = precomputePathRegex(routePatterns);\n return (pathname: string) => matchers.some(matcher => matcher.test(pathname));\n};\n"],"mappings":";;;;;AAQA,IAAM,sBAAsB,CAAC,aAAqC;AAChE,SAAO,SAAS,IAAI,aAAY,mBAAmB,SAAS,UAAU,aAAa,OAAO,CAAE;AAC9F;AAQO,IAAM,oBAAoB,CAAC,aAA+B;AAC/D,QAAM,gBAAgB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,OAAO,OAAO;AAC5D,QAAM,WAAW,oBAAoB,aAAa;AAClD,SAAO,CAAC,aAAqB,SAAS,KAAK,aAAW,QAAQ,KAAK,QAAQ,CAAC;AAC9E;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
interface ParseOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Set the default delimiter for repeat parameters. (default: `'/'`)
|
|
4
|
+
*/
|
|
5
|
+
delimiter?: string;
|
|
6
|
+
/**
|
|
7
|
+
* List of characters to automatically consider prefixes when parsing.
|
|
8
|
+
*/
|
|
9
|
+
prefixes?: string;
|
|
10
|
+
}
|
|
11
|
+
interface RegexpToFunctionOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Function for decoding strings for params.
|
|
14
|
+
*/
|
|
15
|
+
decode?: (value: string, token: Key) => string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A match result contains data about the path match.
|
|
19
|
+
*/
|
|
20
|
+
interface MatchResult<P extends object = object> {
|
|
21
|
+
path: string;
|
|
22
|
+
index: number;
|
|
23
|
+
params: P;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A match is either `false` (no match) or a match result.
|
|
27
|
+
*/
|
|
28
|
+
type Match<P extends object = object> = false | MatchResult<P>;
|
|
29
|
+
/**
|
|
30
|
+
* The match function takes a string and returns whether it matched the path.
|
|
31
|
+
*/
|
|
32
|
+
type MatchFunction<P extends object = object> = (path: string) => Match<P>;
|
|
33
|
+
/**
|
|
34
|
+
* Metadata about a key.
|
|
35
|
+
*/
|
|
36
|
+
interface Key {
|
|
37
|
+
name: string | number;
|
|
38
|
+
prefix: string;
|
|
39
|
+
suffix: string;
|
|
40
|
+
pattern: string;
|
|
41
|
+
modifier: string;
|
|
42
|
+
}
|
|
43
|
+
interface TokensToRegexpOptions {
|
|
44
|
+
/**
|
|
45
|
+
* When `true` the regexp will be case sensitive. (default: `false`)
|
|
46
|
+
*/
|
|
47
|
+
sensitive?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`)
|
|
50
|
+
*/
|
|
51
|
+
strict?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When `true` the regexp will match to the end of the string. (default: `true`)
|
|
54
|
+
*/
|
|
55
|
+
end?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `true` the regexp will match from the beginning of the string. (default: `true`)
|
|
58
|
+
*/
|
|
59
|
+
start?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the final character for non-ending optimistic matches. (default: `/`)
|
|
62
|
+
*/
|
|
63
|
+
delimiter?: string;
|
|
64
|
+
/**
|
|
65
|
+
* List of characters that can also be "end" characters.
|
|
66
|
+
*/
|
|
67
|
+
endsWith?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Encode path tokens for use in the `RegExp`.
|
|
70
|
+
*/
|
|
71
|
+
encode?: (value: string) => string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Supported `path-to-regexp` input types.
|
|
75
|
+
*/
|
|
76
|
+
type Path = string | RegExp | Array<string | RegExp>;
|
|
77
|
+
|
|
78
|
+
declare const pathToRegexp: (path: string) => RegExp;
|
|
79
|
+
declare function match<P extends object = object>(str: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions): MatchFunction<P>;
|
|
80
|
+
|
|
81
|
+
export { type Match, type MatchFunction, match, pathToRegexp };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
interface ParseOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Set the default delimiter for repeat parameters. (default: `'/'`)
|
|
4
|
+
*/
|
|
5
|
+
delimiter?: string;
|
|
6
|
+
/**
|
|
7
|
+
* List of characters to automatically consider prefixes when parsing.
|
|
8
|
+
*/
|
|
9
|
+
prefixes?: string;
|
|
10
|
+
}
|
|
11
|
+
interface RegexpToFunctionOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Function for decoding strings for params.
|
|
14
|
+
*/
|
|
15
|
+
decode?: (value: string, token: Key) => string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A match result contains data about the path match.
|
|
19
|
+
*/
|
|
20
|
+
interface MatchResult<P extends object = object> {
|
|
21
|
+
path: string;
|
|
22
|
+
index: number;
|
|
23
|
+
params: P;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A match is either `false` (no match) or a match result.
|
|
27
|
+
*/
|
|
28
|
+
type Match<P extends object = object> = false | MatchResult<P>;
|
|
29
|
+
/**
|
|
30
|
+
* The match function takes a string and returns whether it matched the path.
|
|
31
|
+
*/
|
|
32
|
+
type MatchFunction<P extends object = object> = (path: string) => Match<P>;
|
|
33
|
+
/**
|
|
34
|
+
* Metadata about a key.
|
|
35
|
+
*/
|
|
36
|
+
interface Key {
|
|
37
|
+
name: string | number;
|
|
38
|
+
prefix: string;
|
|
39
|
+
suffix: string;
|
|
40
|
+
pattern: string;
|
|
41
|
+
modifier: string;
|
|
42
|
+
}
|
|
43
|
+
interface TokensToRegexpOptions {
|
|
44
|
+
/**
|
|
45
|
+
* When `true` the regexp will be case sensitive. (default: `false`)
|
|
46
|
+
*/
|
|
47
|
+
sensitive?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`)
|
|
50
|
+
*/
|
|
51
|
+
strict?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When `true` the regexp will match to the end of the string. (default: `true`)
|
|
54
|
+
*/
|
|
55
|
+
end?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `true` the regexp will match from the beginning of the string. (default: `true`)
|
|
58
|
+
*/
|
|
59
|
+
start?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the final character for non-ending optimistic matches. (default: `/`)
|
|
62
|
+
*/
|
|
63
|
+
delimiter?: string;
|
|
64
|
+
/**
|
|
65
|
+
* List of characters that can also be "end" characters.
|
|
66
|
+
*/
|
|
67
|
+
endsWith?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Encode path tokens for use in the `RegExp`.
|
|
70
|
+
*/
|
|
71
|
+
encode?: (value: string) => string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Supported `path-to-regexp` input types.
|
|
75
|
+
*/
|
|
76
|
+
type Path = string | RegExp | Array<string | RegExp>;
|
|
77
|
+
|
|
78
|
+
declare const pathToRegexp: (path: string) => RegExp;
|
|
79
|
+
declare function match<P extends object = object>(str: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions): MatchFunction<P>;
|
|
80
|
+
|
|
81
|
+
export { type Match, type MatchFunction, match, pathToRegexp };
|
|
@@ -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,OAAO,MAAM,OAAO,MAAM,KAAK;AACvC,QAAE,KAAK;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,QACP,OAAO,EAAE,GAAG;AAAA,MACd,CAAC;AACD;AAAA,IACF;AACA,QAAI,MAAM,MAAM;AACd,QAAE,KAAK;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,QACP,OAAO,EAAE,GAAG;AAAA,MACd,CAAC;AACD;AAAA,IACF;AACA,QAAI,MAAM,KAAK;AACb,QAAE,KAAK;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,QACP,OAAO,EAAE,GAAG;AAAA,MACd,CAAC;AACD;AAAA,IACF;AACA,QAAI,MAAM,KAAK;AACb,QAAE,KAAK;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,QACP,OAAO,EAAE,GAAG;AAAA,MACd,CAAC;AACD;AAAA,IACF;AACA,QAAI,MAAM,KAAK;AACb,eAAS,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,EAAE,UAAU;AAC1C,YAAI,IAAI,EAAE,WAAW,CAAC;AACtB,YAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,MAAM,KAAK,MAAQ,KAAK,MAAM,KAAK,OAAQ,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EF,WAAO,EAAiB,IAAI;AAAA,EAC9B,SAAS,GAAQ;AACf,UAAM,IAAI;AAAA,MACR,iBAAiB,IAAI;AAAA;AAAA,EAA6G,EAAE,OAAO;AAAA,IAC7I;AAAA,EACF;AACF;AAEO,SAAS,MACd,KACA,SACkB;AAClB,MAAI;AAEF,WAAO,EAAU,KAAK,OAAO;AAAA,EAC/B,SAAS,GAAQ;AACf,UAAM,IAAI;AAAA,MACR;AAAA,EAAoI,EAAE,OAAO;AAAA,IAC/I;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/react/index.d.mts
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.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
|
});
|