@tern-secure/react 1.2.0-canary.v20251030165007 → 1.2.0-canary.v20251125170702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/components/TernSecureHostRenderer.d.mts +24 -0
  2. package/dist/components/TernSecureHostRenderer.d.ts +24 -0
  3. package/dist/components/TernSecureHostRenderer.js +2 -0
  4. package/dist/components/TernSecureHostRenderer.js.map +1 -0
  5. package/dist/components/TernSecureHostRenderer.mjs +2 -0
  6. package/dist/components/TernSecureHostRenderer.mjs.map +1 -0
  7. package/dist/components/uiComponent.d.mts +30 -0
  8. package/dist/components/uiComponent.d.ts +30 -0
  9. package/dist/components/uiComponent.js +2 -0
  10. package/dist/components/uiComponent.js.map +1 -0
  11. package/dist/components/uiComponent.mjs +2 -0
  12. package/dist/components/uiComponent.mjs.map +1 -0
  13. package/dist/components/withTernSecure.d.mts +16 -0
  14. package/dist/components/withTernSecure.d.ts +16 -0
  15. package/dist/components/withTernSecure.js +2 -0
  16. package/dist/components/withTernSecure.js.map +1 -0
  17. package/dist/components/withTernSecure.mjs +2 -0
  18. package/dist/components/withTernSecure.mjs.map +1 -0
  19. package/dist/ctx/AuthProvider.d.mts +2 -2
  20. package/dist/ctx/AuthProvider.d.ts +2 -2
  21. package/dist/ctx/IsomorphicTernSecureCtx.d.mts +2 -2
  22. package/dist/ctx/IsomorphicTernSecureCtx.d.ts +2 -2
  23. package/dist/ctx/TernSecureCtxProvider.d.mts +2 -2
  24. package/dist/ctx/TernSecureCtxProvider.d.ts +2 -2
  25. package/dist/ctx/TernSecureCtxProvider.js +1 -1
  26. package/dist/ctx/TernSecureCtxProvider.js.map +1 -1
  27. package/dist/ctx/TernSecureCtxProvider.mjs +1 -1
  28. package/dist/ctx/TernSecureCtxProvider.mjs.map +1 -1
  29. package/dist/ctx/TernSecureProvider.d.mts +2 -2
  30. package/dist/ctx/TernSecureProvider.d.ts +2 -2
  31. package/dist/hooks/useMaxAllowedInstances.d.mts +6 -0
  32. package/dist/hooks/useMaxAllowedInstances.d.ts +6 -0
  33. package/dist/hooks/useMaxAllowedInstances.js +2 -0
  34. package/dist/hooks/useMaxAllowedInstances.js.map +1 -0
  35. package/dist/hooks/useMaxAllowedInstances.mjs +2 -0
  36. package/dist/hooks/useMaxAllowedInstances.mjs.map +1 -0
  37. package/dist/hooks/useSignIn.d.mts +4 -4
  38. package/dist/hooks/useSignIn.d.ts +4 -4
  39. package/dist/hooks/useSignIn.js +1 -1
  40. package/dist/hooks/useSignIn.js.map +1 -1
  41. package/dist/hooks/useSignIn.mjs +1 -1
  42. package/dist/hooks/useSignIn.mjs.map +1 -1
  43. package/dist/hooks/useWaitForComponentMount.d.mts +8 -0
  44. package/dist/hooks/useWaitForComponentMount.d.ts +8 -0
  45. package/dist/hooks/useWaitForComponentMount.js +2 -0
  46. package/dist/hooks/useWaitForComponentMount.js.map +1 -0
  47. package/dist/hooks/useWaitForComponentMount.mjs +2 -0
  48. package/dist/hooks/useWaitForComponentMount.mjs.map +1 -0
  49. package/dist/index.d.mts +3 -5
  50. package/dist/index.d.ts +3 -5
  51. package/dist/index.js +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.mjs +1 -1
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/lib/isoTernSecureAuth.d.mts +29 -5
  56. package/dist/lib/isoTernSecureAuth.d.ts +29 -5
  57. package/dist/lib/isoTernSecureAuth.js +1 -1
  58. package/dist/lib/isoTernSecureAuth.js.map +1 -1
  59. package/dist/lib/isoTernSecureAuth.mjs +1 -1
  60. package/dist/lib/isoTernSecureAuth.mjs.map +1 -1
  61. package/dist/types.d.mts +43 -28
  62. package/dist/types.d.ts +43 -28
  63. package/dist/types.js +1 -1
  64. package/dist/types.js.map +1 -1
  65. package/dist/types.mjs.map +1 -1
  66. package/dist/utils/debug.d.mts +2 -1
  67. package/dist/utils/debug.d.ts +2 -1
  68. package/dist/utils/debug.js +1 -1
  69. package/dist/utils/debug.js.map +1 -1
  70. package/dist/utils/debug.mjs +1 -1
  71. package/dist/utils/debug.mjs.map +1 -1
  72. package/dist/utils/isConstructor.d.mts +3 -0
  73. package/dist/utils/isConstructor.d.ts +3 -0
  74. package/dist/utils/isConstructor.js +2 -0
  75. package/dist/utils/isConstructor.js.map +1 -0
  76. package/dist/utils/isConstructor.mjs +2 -0
  77. package/dist/utils/isConstructor.mjs.map +1 -0
  78. package/package.json +4 -5
  79. package/dist/ctx/SignInCtx.d.mts +0 -27
  80. package/dist/ctx/SignInCtx.d.ts +0 -27
  81. package/dist/ctx/SignInCtx.js +0 -2
  82. package/dist/ctx/SignInCtx.js.map +0 -1
  83. package/dist/ctx/SignInCtx.mjs +0 -2
  84. package/dist/ctx/SignInCtx.mjs.map +0 -1
  85. package/dist/ctx/SignUpCtx.d.mts +0 -22
  86. package/dist/ctx/SignUpCtx.d.ts +0 -22
  87. package/dist/ctx/SignUpCtx.js +0 -2
  88. package/dist/ctx/SignUpCtx.js.map +0 -1
  89. package/dist/ctx/SignUpCtx.mjs +0 -2
  90. package/dist/ctx/SignUpCtx.mjs.map +0 -1
@@ -0,0 +1,24 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React__default, { PropsWithChildren } from 'react';
3
+ import { MountProps, OpenProps } from '../types.mjs';
4
+ import '@tern-secure/types';
5
+
6
+ type HostRendererProps = PropsWithChildren<(MountProps | OpenProps) & {
7
+ component?: string;
8
+ hideRootHtmlElement?: boolean;
9
+ rootProps?: React__default.JSX.IntrinsicElements['div'];
10
+ }>;
11
+ /**
12
+ * TernSecureHostRenderer is responsible for the actual mounting/unmounting of UI components
13
+ * from the @tern-secure/auth package. It handles the lifecycle of the mounted component
14
+ * and ensures proper cleanup.
15
+ */
16
+ declare class TernSecureHostRenderer extends React__default.PureComponent<HostRendererProps> {
17
+ private rootRef;
18
+ componentDidUpdate(_prevProps: Readonly<MountProps | OpenProps>): void;
19
+ componentDidMount(): void;
20
+ componentWillUnmount(): void;
21
+ render(): react_jsx_runtime.JSX.Element;
22
+ }
23
+
24
+ export { TernSecureHostRenderer };
@@ -0,0 +1,24 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React__default, { PropsWithChildren } from 'react';
3
+ import { MountProps, OpenProps } from '../types.js';
4
+ import '@tern-secure/types';
5
+
6
+ type HostRendererProps = PropsWithChildren<(MountProps | OpenProps) & {
7
+ component?: string;
8
+ hideRootHtmlElement?: boolean;
9
+ rootProps?: React__default.JSX.IntrinsicElements['div'];
10
+ }>;
11
+ /**
12
+ * TernSecureHostRenderer is responsible for the actual mounting/unmounting of UI components
13
+ * from the @tern-secure/auth package. It handles the lifecycle of the mounted component
14
+ * and ensures proper cleanup.
15
+ */
16
+ declare class TernSecureHostRenderer extends React__default.PureComponent<HostRendererProps> {
17
+ private rootRef;
18
+ componentDidUpdate(_prevProps: Readonly<MountProps | OpenProps>): void;
19
+ componentDidMount(): void;
20
+ componentWillUnmount(): void;
21
+ render(): react_jsx_runtime.JSX.Element;
22
+ }
23
+
24
+ export { TernSecureHostRenderer };
@@ -0,0 +1,2 @@
1
+ "use strict";var M=Object.create;var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var H=(o,t)=>{for(var s in t)p(o,s,{get:t[s],enumerable:!0})},h=(o,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!y.call(o,r)&&r!==s&&p(o,r,{get:()=>t[r],enumerable:!(e=R(t,r))||e.enumerable});return o};var v=(o,t,s)=>(s=o!=null?M(g(o)):{},h(t||!o||!o.__esModule?p(s,"default",{value:o,enumerable:!0}):s,o)),E=o=>h(p({},"__esModule",{value:!0}),o);var C={};H(C,{TernSecureHostRenderer:()=>D});module.exports=E(C);var n=require("react/jsx-runtime"),u=require("@tern-secure/shared/object"),m=require("@tern-secure/shared/react"),c=v(require("react"));const i=o=>"mount"in o,l=o=>"open"in o,a=o=>o?.map(({mountIcon:t,unmountIcon:s,...e})=>e);class D extends c.default.PureComponent{rootRef=c.default.createRef();componentDidUpdate(t){if(!i(t)||!i(this.props))return;const s=(0,u.without)(t.props,"customPages","customMenuItems","children"),e=(0,u.without)(this.props.props,"customPages","customMenuItems","children"),r=s.customPages?.length!==e.customPages?.length,d=s.customMenuItems?.length!==e.customMenuItems?.length,f=a(t.props.customMenuItems),P=a(this.props.props.customMenuItems);(!(0,m.isDeeplyEqual)(s,e)||!(0,m.isDeeplyEqual)(f,P)||r||d)&&this.rootRef.current&&this.props.updateProps({node:this.rootRef.current,props:this.props.props})}componentDidMount(){this.rootRef.current&&(i(this.props)&&this.props.mount(this.rootRef.current,this.props.props),l(this.props)&&this.props.open(this.props.props))}componentWillUnmount(){this.rootRef.current&&(i(this.props)&&this.props.unmount(this.rootRef.current),l(this.props)&&this.props.close())}render(){const{hideRootHtmlElement:t=!1}=this.props,s={ref:this.rootRef,...this.props.rootProps,...this.props.component&&{"data-ternsecure-component":this.props.component}};return(0,n.jsxs)(n.Fragment,{children:[!t&&(0,n.jsx)("div",{...s}),this.props.children]})}}0&&(module.exports={TernSecureHostRenderer});
2
+ //# sourceMappingURL=TernSecureHostRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/TernSecureHostRenderer.tsx"],"sourcesContent":["import { without } from '@tern-secure/shared/object';\nimport { isDeeplyEqual } from '@tern-secure/shared/react';\nimport type { PropsWithChildren } from 'react';\nimport React from 'react';\n\nimport type { MountProps, OpenProps } from '../types';\n\nconst isMountProps = (props: any): props is MountProps => {\n return 'mount' in props;\n};\n\nconst isOpenProps = (props: any): props is OpenProps => {\n return 'open' in props;\n};\n\nconst stripMenuItemIconHandlers = (\n menuItems?: Array<{\n mountIcon?: (el: HTMLDivElement) => void;\n unmountIcon?: (el: HTMLDivElement) => void;\n [key: string]: any;\n }>,\n) => {\n return menuItems?.map(({ mountIcon, unmountIcon, ...rest }) => rest);\n};\n\ntype HostRendererProps = PropsWithChildren<\n (MountProps | OpenProps) & {\n component?: string;\n hideRootHtmlElement?: boolean;\n rootProps?: React.JSX.IntrinsicElements['div'];\n }\n>;\n\n/**\n * TernSecureHostRenderer is responsible for the actual mounting/unmounting of UI components\n * from the @tern-secure/auth package. It handles the lifecycle of the mounted component\n * and ensures proper cleanup.\n */\nexport class TernSecureHostRenderer extends React.PureComponent<HostRendererProps> {\n private rootRef = React.createRef<HTMLDivElement>();\n\n componentDidUpdate(_prevProps: Readonly<MountProps | OpenProps>) {\n if (!isMountProps(_prevProps) || !isMountProps(this.props)) {\n return;\n }\n\n const prevProps = without(_prevProps.props, 'customPages', 'customMenuItems', 'children');\n const newProps = without(this.props.props, 'customPages', 'customMenuItems', 'children');\n\n const customPagesChanged = prevProps.customPages?.length !== newProps.customPages?.length;\n const customMenuItemsChanged =\n prevProps.customMenuItems?.length !== newProps.customMenuItems?.length;\n\n const prevMenuItemsWithoutHandlers = stripMenuItemIconHandlers(\n _prevProps.props.customMenuItems,\n );\n const newMenuItemsWithoutHandlers = stripMenuItemIconHandlers(this.props.props.customMenuItems);\n\n if (\n !isDeeplyEqual(prevProps, newProps) ||\n !isDeeplyEqual(prevMenuItemsWithoutHandlers, newMenuItemsWithoutHandlers) ||\n customPagesChanged ||\n customMenuItemsChanged\n ) {\n if (this.rootRef.current) {\n this.props.updateProps({ node: this.rootRef.current, props: this.props.props });\n }\n }\n }\n\n componentDidMount() {\n if (this.rootRef.current) {\n if (isMountProps(this.props)) {\n this.props.mount(this.rootRef.current, this.props.props);\n }\n\n if (isOpenProps(this.props)) {\n this.props.open(this.props.props);\n }\n }\n }\n\n componentWillUnmount() {\n if (this.rootRef.current) {\n if (isMountProps(this.props)) {\n this.props.unmount(this.rootRef.current);\n }\n if (isOpenProps(this.props)) {\n this.props.close();\n }\n }\n }\n\n render() {\n const { hideRootHtmlElement = false } = this.props;\n const rootAttributes = {\n ref: this.rootRef,\n ...this.props.rootProps,\n ...(this.props.component && { 'data-ternsecure-component': this.props.component }),\n };\n\n return (\n <>\n {!hideRootHtmlElement && <div {...rootAttributes} />}\n {this.props.children}\n </>\n );\n }\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAsGM,IAAAI,EAAA,6BAtGNC,EAAwB,sCACxBC,EAA8B,qCAE9BA,EAAkB,oBAIlB,MAAMC,EAAgBC,GACb,UAAWA,EAGdC,EAAeD,GACZ,SAAUA,EAGbE,EACJC,GAMOA,GAAW,IAAI,CAAC,CAAE,UAAAC,EAAW,YAAAC,EAAa,GAAGC,CAAK,IAAMA,CAAI,EAgB9D,MAAMZ,UAA+B,EAAAa,QAAM,aAAiC,CACzE,QAAU,EAAAA,QAAM,UAA0B,EAElD,mBAAmBC,EAA8C,CAC/D,GAAI,CAACT,EAAaS,CAAU,GAAK,CAACT,EAAa,KAAK,KAAK,EACvD,OAGF,MAAMU,KAAY,WAAQD,EAAW,MAAO,cAAe,kBAAmB,UAAU,EAClFE,KAAW,WAAQ,KAAK,MAAM,MAAO,cAAe,kBAAmB,UAAU,EAEjFC,EAAqBF,EAAU,aAAa,SAAWC,EAAS,aAAa,OAC7EE,EACJH,EAAU,iBAAiB,SAAWC,EAAS,iBAAiB,OAE5DG,EAA+BX,EACnCM,EAAW,MAAM,eACnB,EACMM,EAA8BZ,EAA0B,KAAK,MAAM,MAAM,eAAe,GAG5F,IAAC,iBAAcO,EAAWC,CAAQ,GAClC,IAAC,iBAAcG,EAA8BC,CAA2B,GACxEH,GACAC,IAEI,KAAK,QAAQ,SACf,KAAK,MAAM,YAAY,CAAE,KAAM,KAAK,QAAQ,QAAS,MAAO,KAAK,MAAM,KAAM,CAAC,CAGpF,CAEA,mBAAoB,CACd,KAAK,QAAQ,UACXb,EAAa,KAAK,KAAK,GACzB,KAAK,MAAM,MAAM,KAAK,QAAQ,QAAS,KAAK,MAAM,KAAK,EAGrDE,EAAY,KAAK,KAAK,GACxB,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,EAGtC,CAEA,sBAAuB,CACjB,KAAK,QAAQ,UACXF,EAAa,KAAK,KAAK,GACzB,KAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,EAErCE,EAAY,KAAK,KAAK,GACxB,KAAK,MAAM,MAAM,EAGvB,CAEA,QAAS,CACP,KAAM,CAAE,oBAAAc,EAAsB,EAAM,EAAI,KAAK,MACvCC,EAAiB,CACrB,IAAK,KAAK,QACV,GAAG,KAAK,MAAM,UACd,GAAI,KAAK,MAAM,WAAa,CAAE,4BAA6B,KAAK,MAAM,SAAU,CAClF,EAEA,SACE,oBACG,WAACD,MAAuB,OAAC,OAAK,GAAGC,EAAgB,EACjD,KAAK,MAAM,UACd,CAEJ,CACF","names":["TernSecureHostRenderer_exports","__export","TernSecureHostRenderer","__toCommonJS","import_jsx_runtime","import_object","import_react","isMountProps","props","isOpenProps","stripMenuItemIconHandlers","menuItems","mountIcon","unmountIcon","rest","React","_prevProps","prevProps","newProps","customPagesChanged","customMenuItemsChanged","prevMenuItemsWithoutHandlers","newMenuItemsWithoutHandlers","hideRootHtmlElement","rootAttributes"]}
@@ -0,0 +1,2 @@
1
+ import{Fragment as f,jsx as d,jsxs as P}from"react/jsx-runtime";import{without as n}from"@tern-secure/shared/object";import{isDeeplyEqual as p}from"@tern-secure/shared/react";import i from"react";const r=o=>"mount"in o,u=o=>"open"in o,m=o=>o?.map(({mountIcon:t,unmountIcon:s,...e})=>e);class g extends i.PureComponent{rootRef=i.createRef();componentDidUpdate(t){if(!r(t)||!r(this.props))return;const s=n(t.props,"customPages","customMenuItems","children"),e=n(this.props.props,"customPages","customMenuItems","children"),c=s.customPages?.length!==e.customPages?.length,h=s.customMenuItems?.length!==e.customMenuItems?.length,l=m(t.props.customMenuItems),a=m(this.props.props.customMenuItems);(!p(s,e)||!p(l,a)||c||h)&&this.rootRef.current&&this.props.updateProps({node:this.rootRef.current,props:this.props.props})}componentDidMount(){this.rootRef.current&&(r(this.props)&&this.props.mount(this.rootRef.current,this.props.props),u(this.props)&&this.props.open(this.props.props))}componentWillUnmount(){this.rootRef.current&&(r(this.props)&&this.props.unmount(this.rootRef.current),u(this.props)&&this.props.close())}render(){const{hideRootHtmlElement:t=!1}=this.props,s={ref:this.rootRef,...this.props.rootProps,...this.props.component&&{"data-ternsecure-component":this.props.component}};return P(f,{children:[!t&&d("div",{...s}),this.props.children]})}}export{g as TernSecureHostRenderer};
2
+ //# sourceMappingURL=TernSecureHostRenderer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/TernSecureHostRenderer.tsx"],"sourcesContent":["import { without } from '@tern-secure/shared/object';\nimport { isDeeplyEqual } from '@tern-secure/shared/react';\nimport type { PropsWithChildren } from 'react';\nimport React from 'react';\n\nimport type { MountProps, OpenProps } from '../types';\n\nconst isMountProps = (props: any): props is MountProps => {\n return 'mount' in props;\n};\n\nconst isOpenProps = (props: any): props is OpenProps => {\n return 'open' in props;\n};\n\nconst stripMenuItemIconHandlers = (\n menuItems?: Array<{\n mountIcon?: (el: HTMLDivElement) => void;\n unmountIcon?: (el: HTMLDivElement) => void;\n [key: string]: any;\n }>,\n) => {\n return menuItems?.map(({ mountIcon, unmountIcon, ...rest }) => rest);\n};\n\ntype HostRendererProps = PropsWithChildren<\n (MountProps | OpenProps) & {\n component?: string;\n hideRootHtmlElement?: boolean;\n rootProps?: React.JSX.IntrinsicElements['div'];\n }\n>;\n\n/**\n * TernSecureHostRenderer is responsible for the actual mounting/unmounting of UI components\n * from the @tern-secure/auth package. It handles the lifecycle of the mounted component\n * and ensures proper cleanup.\n */\nexport class TernSecureHostRenderer extends React.PureComponent<HostRendererProps> {\n private rootRef = React.createRef<HTMLDivElement>();\n\n componentDidUpdate(_prevProps: Readonly<MountProps | OpenProps>) {\n if (!isMountProps(_prevProps) || !isMountProps(this.props)) {\n return;\n }\n\n const prevProps = without(_prevProps.props, 'customPages', 'customMenuItems', 'children');\n const newProps = without(this.props.props, 'customPages', 'customMenuItems', 'children');\n\n const customPagesChanged = prevProps.customPages?.length !== newProps.customPages?.length;\n const customMenuItemsChanged =\n prevProps.customMenuItems?.length !== newProps.customMenuItems?.length;\n\n const prevMenuItemsWithoutHandlers = stripMenuItemIconHandlers(\n _prevProps.props.customMenuItems,\n );\n const newMenuItemsWithoutHandlers = stripMenuItemIconHandlers(this.props.props.customMenuItems);\n\n if (\n !isDeeplyEqual(prevProps, newProps) ||\n !isDeeplyEqual(prevMenuItemsWithoutHandlers, newMenuItemsWithoutHandlers) ||\n customPagesChanged ||\n customMenuItemsChanged\n ) {\n if (this.rootRef.current) {\n this.props.updateProps({ node: this.rootRef.current, props: this.props.props });\n }\n }\n }\n\n componentDidMount() {\n if (this.rootRef.current) {\n if (isMountProps(this.props)) {\n this.props.mount(this.rootRef.current, this.props.props);\n }\n\n if (isOpenProps(this.props)) {\n this.props.open(this.props.props);\n }\n }\n }\n\n componentWillUnmount() {\n if (this.rootRef.current) {\n if (isMountProps(this.props)) {\n this.props.unmount(this.rootRef.current);\n }\n if (isOpenProps(this.props)) {\n this.props.close();\n }\n }\n }\n\n render() {\n const { hideRootHtmlElement = false } = this.props;\n const rootAttributes = {\n ref: this.rootRef,\n ...this.props.rootProps,\n ...(this.props.component && { 'data-ternsecure-component': this.props.component }),\n };\n\n return (\n <>\n {!hideRootHtmlElement && <div {...rootAttributes} />}\n {this.props.children}\n </>\n );\n }\n}\n"],"mappings":"AAsGM,mBAAAA,EAC2B,OAAAC,EAD3B,QAAAC,MAAA,oBAtGN,OAAS,WAAAC,MAAe,6BACxB,OAAS,iBAAAC,MAAqB,4BAE9B,OAAOC,MAAW,QAIlB,MAAMC,EAAgBC,GACb,UAAWA,EAGdC,EAAeD,GACZ,SAAUA,EAGbE,EACJC,GAMOA,GAAW,IAAI,CAAC,CAAE,UAAAC,EAAW,YAAAC,EAAa,GAAGC,CAAK,IAAMA,CAAI,EAgB9D,MAAMC,UAA+BT,EAAM,aAAiC,CACzE,QAAUA,EAAM,UAA0B,EAElD,mBAAmBU,EAA8C,CAC/D,GAAI,CAACT,EAAaS,CAAU,GAAK,CAACT,EAAa,KAAK,KAAK,EACvD,OAGF,MAAMU,EAAYb,EAAQY,EAAW,MAAO,cAAe,kBAAmB,UAAU,EAClFE,EAAWd,EAAQ,KAAK,MAAM,MAAO,cAAe,kBAAmB,UAAU,EAEjFe,EAAqBF,EAAU,aAAa,SAAWC,EAAS,aAAa,OAC7EE,EACJH,EAAU,iBAAiB,SAAWC,EAAS,iBAAiB,OAE5DG,EAA+BX,EACnCM,EAAW,MAAM,eACnB,EACMM,EAA8BZ,EAA0B,KAAK,MAAM,MAAM,eAAe,GAG5F,CAACL,EAAcY,EAAWC,CAAQ,GAClC,CAACb,EAAcgB,EAA8BC,CAA2B,GACxEH,GACAC,IAEI,KAAK,QAAQ,SACf,KAAK,MAAM,YAAY,CAAE,KAAM,KAAK,QAAQ,QAAS,MAAO,KAAK,MAAM,KAAM,CAAC,CAGpF,CAEA,mBAAoB,CACd,KAAK,QAAQ,UACXb,EAAa,KAAK,KAAK,GACzB,KAAK,MAAM,MAAM,KAAK,QAAQ,QAAS,KAAK,MAAM,KAAK,EAGrDE,EAAY,KAAK,KAAK,GACxB,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,EAGtC,CAEA,sBAAuB,CACjB,KAAK,QAAQ,UACXF,EAAa,KAAK,KAAK,GACzB,KAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,EAErCE,EAAY,KAAK,KAAK,GACxB,KAAK,MAAM,MAAM,EAGvB,CAEA,QAAS,CACP,KAAM,CAAE,oBAAAc,EAAsB,EAAM,EAAI,KAAK,MACvCC,EAAiB,CACrB,IAAK,KAAK,QACV,GAAG,KAAK,MAAM,UACd,GAAI,KAAK,MAAM,WAAa,CAAE,4BAA6B,KAAK,MAAM,SAAU,CAClF,EAEA,OACErB,EAAAF,EAAA,CACG,WAACsB,GAAuBrB,EAAC,OAAK,GAAGsB,EAAgB,EACjD,KAAK,MAAM,UACd,CAEJ,CACF","names":["Fragment","jsx","jsxs","without","isDeeplyEqual","React","isMountProps","props","isOpenProps","stripMenuItemIconHandlers","menuItems","mountIcon","unmountIcon","rest","TernSecureHostRenderer","_prevProps","prevProps","newProps","customPagesChanged","customMenuItemsChanged","prevMenuItemsWithoutHandlers","newMenuItemsWithoutHandlers","hideRootHtmlElement","rootAttributes"]}
@@ -0,0 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _tern_secure_types from '@tern-secure/types';
3
+ import { SignInProps, SignUpProps } from '@tern-secure/types';
4
+ import { WithTernSecureProp } from '../types.mjs';
5
+
6
+ type FallbackProp = {
7
+ /**
8
+ * An optional element to render while the component is mounting.
9
+ */
10
+ fallback?: React.ReactNode;
11
+ };
12
+ type SignInComponentProps = WithTernSecureProp<SignInProps> & FallbackProp;
13
+ type SignUpComponentProps = WithTernSecureProp<SignUpProps> & FallbackProp;
14
+ declare const SignIn: {
15
+ (props: _tern_secure_types.Without<SignInComponentProps, "ternsecure">): react_jsx_runtime.JSX.Element | null;
16
+ displayName: string;
17
+ };
18
+ declare const SignUp: {
19
+ (props: _tern_secure_types.Without<SignUpComponentProps, "ternsecure">): react_jsx_runtime.JSX.Element | null;
20
+ displayName: string;
21
+ };
22
+ declare const UserButton: {
23
+ (props: _tern_secure_types.Without<{
24
+ ternsecure: _tern_secure_types.TernSecureAuth;
25
+ component?: string;
26
+ }, "ternsecure">): react_jsx_runtime.JSX.Element | null;
27
+ displayName: string;
28
+ };
29
+
30
+ export { SignIn, SignUp, UserButton };
@@ -0,0 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _tern_secure_types from '@tern-secure/types';
3
+ import { SignInProps, SignUpProps } from '@tern-secure/types';
4
+ import { WithTernSecureProp } from '../types.js';
5
+
6
+ type FallbackProp = {
7
+ /**
8
+ * An optional element to render while the component is mounting.
9
+ */
10
+ fallback?: React.ReactNode;
11
+ };
12
+ type SignInComponentProps = WithTernSecureProp<SignInProps> & FallbackProp;
13
+ type SignUpComponentProps = WithTernSecureProp<SignUpProps> & FallbackProp;
14
+ declare const SignIn: {
15
+ (props: _tern_secure_types.Without<SignInComponentProps, "ternsecure">): react_jsx_runtime.JSX.Element | null;
16
+ displayName: string;
17
+ };
18
+ declare const SignUp: {
19
+ (props: _tern_secure_types.Without<SignUpComponentProps, "ternsecure">): react_jsx_runtime.JSX.Element | null;
20
+ displayName: string;
21
+ };
22
+ declare const UserButton: {
23
+ (props: _tern_secure_types.Without<{
24
+ ternsecure: _tern_secure_types.TernSecureAuth;
25
+ component?: string;
26
+ }, "ternsecure">): react_jsx_runtime.JSX.Element | null;
27
+ displayName: string;
28
+ };
29
+
30
+ export { SignIn, SignUp, UserButton };
@@ -0,0 +1,2 @@
1
+ "use strict";var S=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var P=(o,n)=>{for(var p in n)S(o,p,{get:n[p],enumerable:!0})},y=(o,n,p,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of g(n))!l.call(o,e)&&e!==p&&S(o,e,{get:()=>n[e],enumerable:!(r=m(n,e))||r.enumerable});return o};var h=o=>y(S({},"__esModule",{value:!0}),o);var R={};P(R,{SignIn:()=>c,SignUp:()=>U,UserButton:()=>_});module.exports=h(R);var t=require("react/jsx-runtime"),i=require("../hooks/useWaitForComponentMount"),a=require("./TernSecureHostRenderer"),u=require("./withTernSecure");const c=(0,u.withTernSecure)(({ternsecure:o,component:n,fallback:p,...r})=>{const s=(0,i.useWaitForComponentMount)(n)==="rendering"||!o.isReady,d={...s&&p&&{style:{display:"none"}}};return(0,t.jsxs)(t.Fragment,{children:[s&&p,o.isReady&&(0,t.jsx)(a.TernSecureHostRenderer,{component:n,mount:o.showSignIn,unmount:o.hideSignIn,updateProps:o.__unstable__updateProps,props:r,rootProps:d})]})},{component:"SignIn",renderWhileLoading:!0}),U=(0,u.withTernSecure)(({ternsecure:o,component:n,fallback:p,...r})=>{const s=(0,i.useWaitForComponentMount)(n)==="rendering"||!o.isReady,d={...s&&p&&{style:{display:"none"}}};return(0,t.jsxs)(t.Fragment,{children:[s&&p,o.isReady&&(0,t.jsx)(a.TernSecureHostRenderer,{component:n,mount:o.showSignUp,unmount:o.hideSignUp,updateProps:o.__unstable__updateProps,props:r,rootProps:d})]})},{component:"SignUp",renderWhileLoading:!0}),_=(0,u.withTernSecure)(({ternsecure:o,component:n})=>{const r=(0,i.useWaitForComponentMount)(n)==="rendering"||!o.isReady;return(0,t.jsxs)(t.Fragment,{children:[r,o.isReady&&(0,t.jsx)(a.TernSecureHostRenderer,{component:n,mount:o.showUserButton,unmount:o.hideUserButton,updateProps:o.__unstable__updateProps,props:{},rootProps:{...r&&{style:{display:"none"}}}})]})},{component:"UserButton",renderWhileLoading:!0});0&&(module.exports={SignIn,SignUp,UserButton});
2
+ //# sourceMappingURL=uiComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/uiComponent.tsx"],"sourcesContent":["import type {\n SignInProps,\n SignUpProps,\n} from '@tern-secure/types';\n\nimport { useWaitForComponentMount } from '../hooks/useWaitForComponentMount';\nimport type { WithTernSecureProp } from '../types';\nimport { TernSecureHostRenderer } from './TernSecureHostRenderer';\nimport { withTernSecure } from './withTernSecure';\n\ntype FallbackProp = {\n /**\n * An optional element to render while the component is mounting.\n */\n fallback?: React.ReactNode;\n};\n\n// Internal component props including ternsecure instance from withTernSecure\ntype SignInComponentProps = WithTernSecureProp<SignInProps> & FallbackProp;\n\ntype SignUpComponentProps = WithTernSecureProp<SignUpProps> & FallbackProp;\n\nexport const SignIn = withTernSecure(\n ({ ternsecure, component, fallback, ...props }: SignInComponentProps) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n const rendererRootProps = {\n ...(shouldShowFallback && fallback && { style: { display: 'none' } }),\n }\n\n return (\n <>\n {shouldShowFallback && fallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showSignIn}\n unmount={ternsecure.hideSignIn}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={props}\n rootProps={rendererRootProps}\n />\n )}\n </>\n );\n },\n { component: 'SignIn', renderWhileLoading: true },\n);\n\nexport const SignUp = withTernSecure(\n ({ ternsecure, component, fallback, ...props }: SignUpComponentProps) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n const rendererRootProps = {\n ...(shouldShowFallback && fallback && { style: { display: 'none' } }),\n }\n\n return (\n <>\n {shouldShowFallback && fallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showSignUp}\n unmount={ternsecure.hideSignUp}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={props}\n rootProps={rendererRootProps}\n />\n )}\n </>\n );\n },\n { component: 'SignUp', renderWhileLoading: true },\n);\n\nexport const UserButton = withTernSecure(\n ({ ternsecure, component }) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n return (\n <>\n {shouldShowFallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showUserButton}\n unmount={ternsecure.hideUserButton}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={{}}\n rootProps={{\n ...(shouldShowFallback && { style: { display: 'none' } }),\n }}\n />\n )}\n </>\n );\n },\n { component: 'UserButton', renderWhileLoading: true },\n);\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,WAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAL,GAgCM,IAAAM,EAAA,6BA3BNC,EAAyC,6CAEzCC,EAAuC,oCACvCC,EAA+B,4BAcxB,MAAMP,KAAS,kBACpB,CAAC,CAAE,WAAAQ,EAAY,UAAAC,EAAW,SAAAC,EAAU,GAAGC,CAAM,IAA4B,CAEvE,MAAMC,KADiB,4BAAyBH,CAAS,IACX,aAAe,CAACD,EAAW,QAEnEK,EAAqB,CACzB,GAAID,GAAsBF,GAAY,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACrE,EAEA,SACE,oBACG,UAAAE,GAAsBF,EACtBF,EAAW,YACV,OAAC,0BACC,UAAWC,EACX,MAAOD,EAAW,WAClB,QAASA,EAAW,WACpB,YAAcA,EAAmB,wBACjC,MAAOG,EACP,UAAWE,EACb,GAEJ,CAEJ,EACA,CAAE,UAAW,SAAU,mBAAoB,EAAK,CAClD,EAEaZ,KAAS,kBACpB,CAAC,CAAE,WAAAO,EAAY,UAAAC,EAAW,SAAAC,EAAU,GAAGC,CAAM,IAA4B,CAEvE,MAAMC,KADiB,4BAAyBH,CAAS,IACX,aAAe,CAACD,EAAW,QAEnEK,EAAoB,CACxB,GAAID,GAAsBF,GAAY,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACrE,EAEA,SACE,oBACG,UAAAE,GAAsBF,EACtBF,EAAW,YACV,OAAC,0BACC,UAAWC,EACX,MAAOD,EAAW,WAClB,QAASA,EAAW,WACpB,YAAcA,EAAmB,wBACjC,MAAOG,EACP,UAAWE,EACb,GAEJ,CAEJ,EACA,CAAE,UAAW,SAAU,mBAAoB,EAAK,CAClD,EAEaX,KAAa,kBACxB,CAAC,CAAE,WAAAM,EAAY,UAAAC,CAAU,IAAM,CAE7B,MAAMG,KADiB,4BAAyBH,CAAS,IACX,aAAe,CAACD,EAAW,QAEzE,SACE,oBACG,UAAAI,EACAJ,EAAW,YACV,OAAC,0BACC,UAAWC,EACX,MAAOD,EAAW,eAClB,QAASA,EAAW,eACpB,YAAcA,EAAmB,wBACjC,MAAO,CAAC,EACR,UAAW,CACT,GAAII,GAAsB,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACzD,EACF,GAEJ,CAEJ,EACA,CAAE,UAAW,aAAc,mBAAoB,EAAK,CACtD","names":["uiComponent_exports","__export","SignIn","SignUp","UserButton","__toCommonJS","import_jsx_runtime","import_useWaitForComponentMount","import_TernSecureHostRenderer","import_withTernSecure","ternsecure","component","fallback","props","shouldShowFallback","rendererRootProps"]}
@@ -0,0 +1,2 @@
1
+ import{Fragment as d,jsx as u,jsxs as S}from"react/jsx-runtime";import{useWaitForComponentMount as s}from"../hooks/useWaitForComponentMount";import{TernSecureHostRenderer as i}from"./TernSecureHostRenderer";import{withTernSecure as a}from"./withTernSecure";const y=a(({ternsecure:o,component:n,fallback:t,...p})=>{const r=s(n)==="rendering"||!o.isReady,e={...r&&t&&{style:{display:"none"}}};return S(d,{children:[r&&t,o.isReady&&u(i,{component:n,mount:o.showSignIn,unmount:o.hideSignIn,updateProps:o.__unstable__updateProps,props:p,rootProps:e})]})},{component:"SignIn",renderWhileLoading:!0}),h=a(({ternsecure:o,component:n,fallback:t,...p})=>{const r=s(n)==="rendering"||!o.isReady,e={...r&&t&&{style:{display:"none"}}};return S(d,{children:[r&&t,o.isReady&&u(i,{component:n,mount:o.showSignUp,unmount:o.hideSignUp,updateProps:o.__unstable__updateProps,props:p,rootProps:e})]})},{component:"SignUp",renderWhileLoading:!0}),c=a(({ternsecure:o,component:n})=>{const p=s(n)==="rendering"||!o.isReady;return S(d,{children:[p,o.isReady&&u(i,{component:n,mount:o.showUserButton,unmount:o.hideUserButton,updateProps:o.__unstable__updateProps,props:{},rootProps:{...p&&{style:{display:"none"}}}})]})},{component:"UserButton",renderWhileLoading:!0});export{y as SignIn,h as SignUp,c as UserButton};
2
+ //# sourceMappingURL=uiComponent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/uiComponent.tsx"],"sourcesContent":["import type {\n SignInProps,\n SignUpProps,\n} from '@tern-secure/types';\n\nimport { useWaitForComponentMount } from '../hooks/useWaitForComponentMount';\nimport type { WithTernSecureProp } from '../types';\nimport { TernSecureHostRenderer } from './TernSecureHostRenderer';\nimport { withTernSecure } from './withTernSecure';\n\ntype FallbackProp = {\n /**\n * An optional element to render while the component is mounting.\n */\n fallback?: React.ReactNode;\n};\n\n// Internal component props including ternsecure instance from withTernSecure\ntype SignInComponentProps = WithTernSecureProp<SignInProps> & FallbackProp;\n\ntype SignUpComponentProps = WithTernSecureProp<SignUpProps> & FallbackProp;\n\nexport const SignIn = withTernSecure(\n ({ ternsecure, component, fallback, ...props }: SignInComponentProps) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n const rendererRootProps = {\n ...(shouldShowFallback && fallback && { style: { display: 'none' } }),\n }\n\n return (\n <>\n {shouldShowFallback && fallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showSignIn}\n unmount={ternsecure.hideSignIn}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={props}\n rootProps={rendererRootProps}\n />\n )}\n </>\n );\n },\n { component: 'SignIn', renderWhileLoading: true },\n);\n\nexport const SignUp = withTernSecure(\n ({ ternsecure, component, fallback, ...props }: SignUpComponentProps) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n const rendererRootProps = {\n ...(shouldShowFallback && fallback && { style: { display: 'none' } }),\n }\n\n return (\n <>\n {shouldShowFallback && fallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showSignUp}\n unmount={ternsecure.hideSignUp}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={props}\n rootProps={rendererRootProps}\n />\n )}\n </>\n );\n },\n { component: 'SignUp', renderWhileLoading: true },\n);\n\nexport const UserButton = withTernSecure(\n ({ ternsecure, component }) => {\n const mountingStatus = useWaitForComponentMount(component);\n const shouldShowFallback = mountingStatus === 'rendering' || !ternsecure.isReady;\n\n return (\n <>\n {shouldShowFallback}\n {ternsecure.isReady && (\n <TernSecureHostRenderer\n component={component}\n mount={ternsecure.showUserButton}\n unmount={ternsecure.hideUserButton}\n updateProps={(ternsecure as any).__unstable__updateProps}\n props={{}}\n rootProps={{\n ...(shouldShowFallback && { style: { display: 'none' } }),\n }}\n />\n )}\n </>\n );\n },\n { component: 'UserButton', renderWhileLoading: true },\n);\n"],"mappings":"AAgCM,mBAAAA,EAGI,OAAAC,EAHJ,QAAAC,MAAA,oBA3BN,OAAS,4BAAAC,MAAgC,oCAEzC,OAAS,0BAAAC,MAA8B,2BACvC,OAAS,kBAAAC,MAAsB,mBAcxB,MAAMC,EAASD,EACpB,CAAC,CAAE,WAAAE,EAAY,UAAAC,EAAW,SAAAC,EAAU,GAAGC,CAAM,IAA4B,CAEvE,MAAMC,EADiBR,EAAyBK,CAAS,IACX,aAAe,CAACD,EAAW,QAEnEK,EAAqB,CACzB,GAAID,GAAsBF,GAAY,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACrE,EAEA,OACEP,EAAAF,EAAA,CACG,UAAAW,GAAsBF,EACtBF,EAAW,SACVN,EAACG,EAAA,CACC,UAAWI,EACX,MAAOD,EAAW,WAClB,QAASA,EAAW,WACpB,YAAcA,EAAmB,wBACjC,MAAOG,EACP,UAAWE,EACb,GAEJ,CAEJ,EACA,CAAE,UAAW,SAAU,mBAAoB,EAAK,CAClD,EAEaC,EAASR,EACpB,CAAC,CAAE,WAAAE,EAAY,UAAAC,EAAW,SAAAC,EAAU,GAAGC,CAAM,IAA4B,CAEvE,MAAMC,EADiBR,EAAyBK,CAAS,IACX,aAAe,CAACD,EAAW,QAEnEK,EAAoB,CACxB,GAAID,GAAsBF,GAAY,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACrE,EAEA,OACEP,EAAAF,EAAA,CACG,UAAAW,GAAsBF,EACtBF,EAAW,SACVN,EAACG,EAAA,CACC,UAAWI,EACX,MAAOD,EAAW,WAClB,QAASA,EAAW,WACpB,YAAcA,EAAmB,wBACjC,MAAOG,EACP,UAAWE,EACb,GAEJ,CAEJ,EACA,CAAE,UAAW,SAAU,mBAAoB,EAAK,CAClD,EAEaE,EAAaT,EACxB,CAAC,CAAE,WAAAE,EAAY,UAAAC,CAAU,IAAM,CAE7B,MAAMG,EADiBR,EAAyBK,CAAS,IACX,aAAe,CAACD,EAAW,QAEzE,OACEL,EAAAF,EAAA,CACG,UAAAW,EACAJ,EAAW,SACVN,EAACG,EAAA,CACC,UAAWI,EACX,MAAOD,EAAW,eAClB,QAASA,EAAW,eACpB,YAAcA,EAAmB,wBACjC,MAAO,CAAC,EACR,UAAW,CACT,GAAII,GAAsB,CAAE,MAAO,CAAE,QAAS,MAAO,CAAE,CACzD,EACF,GAEJ,CAEJ,EACA,CAAE,UAAW,aAAc,mBAAoB,EAAK,CACtD","names":["Fragment","jsx","jsxs","useWaitForComponentMount","TernSecureHostRenderer","withTernSecure","SignIn","ternsecure","component","fallback","props","shouldShowFallback","rendererRootProps","SignUp","UserButton"]}
@@ -0,0 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TernSecureAuth, Without } from '@tern-secure/types';
3
+ import React__default from 'react';
4
+
5
+ declare const withTernSecure: <P extends {
6
+ ternsecure: TernSecureAuth;
7
+ component?: string;
8
+ }>(Component: React__default.ComponentType<P>, displayNameOrOptions?: string | {
9
+ component: string;
10
+ renderWhileLoading?: boolean;
11
+ }) => {
12
+ (props: Without<P, "ternsecure">): react_jsx_runtime.JSX.Element | null;
13
+ displayName: string;
14
+ };
15
+
16
+ export { withTernSecure };
@@ -0,0 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TernSecureAuth, Without } from '@tern-secure/types';
3
+ import React__default from 'react';
4
+
5
+ declare const withTernSecure: <P extends {
6
+ ternsecure: TernSecureAuth;
7
+ component?: string;
8
+ }>(Component: React__default.ComponentType<P>, displayNameOrOptions?: string | {
9
+ component: string;
10
+ renderWhileLoading?: boolean;
11
+ }) => {
12
+ (props: Without<P, "ternsecure">): react_jsx_runtime.JSX.Element | null;
13
+ displayName: string;
14
+ };
15
+
16
+ export { withTernSecure };
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var o in e)s(r,o,{get:e[o],enumerable:!0})},T=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!y.call(r,n)&&n!==o&&s(r,n,{get:()=>e[n],enumerable:!(t=d(e,n))||t.enumerable});return r};var g=r=>T(s({},"__esModule",{value:!0}),r);var S={};f(S,{withTernSecure:()=>l});module.exports=g(S);var a=require("react/jsx-runtime"),i=require("../ctx/IsomorphicTernSecureCtx"),p=require("../hooks/useAssertWrappedTernSecureProvider");const l=(r,e)=>{const t=(typeof e=="string"?e:e?.component)||r.displayName||r.name||"Component";r.displayName=t;const n=typeof e=="string"?void 0:e,u=m=>{(0,p.useAssertWrappedByTernSecureAuthProvider)(t||"withTernSecure");const c=(0,i.useIsoTernSecureAuthCtx)();return!c.isReady&&!n?.renderWhileLoading?null:(0,a.jsx)(r,{...m,component:t,ternsecure:c})};return u.displayName=`withTernSecure(${t})`,u};0&&(module.exports={withTernSecure});
2
+ //# sourceMappingURL=withTernSecure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/withTernSecure.tsx"],"sourcesContent":["import type { TernSecureAuth, Without } from '@tern-secure/types';\nimport React from 'react';\n\nimport { useIsoTernSecureAuthCtx } from '../ctx/IsomorphicTernSecureCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from '../hooks/useAssertWrappedTernSecureProvider';\n\n\nexport const withTernSecure = <P extends { ternsecure: TernSecureAuth; component?: string }>(\n Component: React.ComponentType<P>,\n displayNameOrOptions?: string | { component: string; renderWhileLoading?: boolean },\n) => {\n const passedDisplayName = typeof displayNameOrOptions === 'string' ? displayNameOrOptions : displayNameOrOptions?.component;\n const displayName = passedDisplayName || Component.displayName || Component.name || 'Component';\n Component.displayName = displayName;\n\n const options = typeof displayNameOrOptions === 'string' ? undefined : displayNameOrOptions;\n\n const HOC = (props: Without<P, 'ternsecure'>) => {\n useAssertWrappedByTernSecureAuthProvider(displayName || 'withTernSecure');\n\n const ternsecure = useIsoTernSecureAuthCtx();\n\n if (!ternsecure.isReady && !options?.renderWhileLoading) {\n return null;\n }\n\n return (\n <Component\n {...(props as P)}\n component={displayName}\n ternsecure={ternsecure}\n />\n );\n };\n\n HOC.displayName = `withTernSecure(${displayName})`;\n return HOC;\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GA2BM,IAAAI,EAAA,6BAxBNC,EAAwC,0CACxCC,EAAyD,uDAGlD,MAAMJ,EAAiB,CAC5BK,EACAC,IACG,CAEH,MAAMC,GADoB,OAAOD,GAAyB,SAAWA,EAAuBA,GAAsB,YACzED,EAAU,aAAeA,EAAU,MAAQ,YACpFA,EAAU,YAAcE,EAExB,MAAMC,EAAU,OAAOF,GAAyB,SAAW,OAAYA,EAEjEG,EAAOC,GAAoC,IAC/C,4CAAyCH,GAAe,gBAAgB,EAExE,MAAMI,KAAa,2BAAwB,EAE3C,MAAI,CAACA,EAAW,SAAW,CAACH,GAAS,mBAC5B,QAIP,OAACH,EAAA,CACE,GAAIK,EACL,UAAWH,EACX,WAAYI,EACd,CAEJ,EAEA,OAAAF,EAAI,YAAc,kBAAkBF,CAAW,IACxCE,CACT","names":["withTernSecure_exports","__export","withTernSecure","__toCommonJS","import_jsx_runtime","import_IsomorphicTernSecureCtx","import_useAssertWrappedTernSecureProvider","Component","displayNameOrOptions","displayName","options","HOC","props","ternsecure"]}
@@ -0,0 +1,2 @@
1
+ import{jsx as p}from"react/jsx-runtime";import{useIsoTernSecureAuthCtx as c}from"../ctx/IsomorphicTernSecureCtx";import{useAssertWrappedByTernSecureAuthProvider as i}from"../hooks/useAssertWrappedTernSecureProvider";const f=(r,e)=>{const t=(typeof e=="string"?e:e?.component)||r.displayName||r.name||"Component";r.displayName=t;const s=typeof e=="string"?void 0:e,n=u=>{i(t||"withTernSecure");const o=c();return!o.isReady&&!s?.renderWhileLoading?null:p(r,{...u,component:t,ternsecure:o})};return n.displayName=`withTernSecure(${t})`,n};export{f as withTernSecure};
2
+ //# sourceMappingURL=withTernSecure.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/withTernSecure.tsx"],"sourcesContent":["import type { TernSecureAuth, Without } from '@tern-secure/types';\nimport React from 'react';\n\nimport { useIsoTernSecureAuthCtx } from '../ctx/IsomorphicTernSecureCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from '../hooks/useAssertWrappedTernSecureProvider';\n\n\nexport const withTernSecure = <P extends { ternsecure: TernSecureAuth; component?: string }>(\n Component: React.ComponentType<P>,\n displayNameOrOptions?: string | { component: string; renderWhileLoading?: boolean },\n) => {\n const passedDisplayName = typeof displayNameOrOptions === 'string' ? displayNameOrOptions : displayNameOrOptions?.component;\n const displayName = passedDisplayName || Component.displayName || Component.name || 'Component';\n Component.displayName = displayName;\n\n const options = typeof displayNameOrOptions === 'string' ? undefined : displayNameOrOptions;\n\n const HOC = (props: Without<P, 'ternsecure'>) => {\n useAssertWrappedByTernSecureAuthProvider(displayName || 'withTernSecure');\n\n const ternsecure = useIsoTernSecureAuthCtx();\n\n if (!ternsecure.isReady && !options?.renderWhileLoading) {\n return null;\n }\n\n return (\n <Component\n {...(props as P)}\n component={displayName}\n ternsecure={ternsecure}\n />\n );\n };\n\n HOC.displayName = `withTernSecure(${displayName})`;\n return HOC;\n};\n"],"mappings":"AA2BM,cAAAA,MAAA,oBAxBN,OAAS,2BAAAC,MAA+B,iCACxC,OAAS,4CAAAC,MAAgD,8CAGlD,MAAMC,EAAiB,CAC5BC,EACAC,IACG,CAEH,MAAMC,GADoB,OAAOD,GAAyB,SAAWA,EAAuBA,GAAsB,YACzED,EAAU,aAAeA,EAAU,MAAQ,YACpFA,EAAU,YAAcE,EAExB,MAAMC,EAAU,OAAOF,GAAyB,SAAW,OAAYA,EAEjEG,EAAOC,GAAoC,CAC/CP,EAAyCI,GAAe,gBAAgB,EAExE,MAAMI,EAAaT,EAAwB,EAE3C,MAAI,CAACS,EAAW,SAAW,CAACH,GAAS,mBAC5B,KAIPP,EAACI,EAAA,CACE,GAAIK,EACL,UAAWH,EACX,WAAYI,EACd,CAEJ,EAEA,OAAAF,EAAI,YAAc,kBAAkBF,CAAW,IACxCE,CACT","names":["jsx","useIsoTernSecureAuthCtx","useAssertWrappedByTernSecureAuthProvider","withTernSecure","Component","displayNameOrOptions","displayName","options","HOC","props","ternsecure"]}
@@ -1,4 +1,4 @@
1
- import * as react from 'react';
1
+ import * as React from 'react';
2
2
  import { DecodedIdToken, TernSecureUser } from '@tern-secure/types';
3
3
 
4
4
  type AuthProviderCtxValue = {
@@ -6,7 +6,7 @@ type AuthProviderCtxValue = {
6
6
  sessionClaims: DecodedIdToken | null | undefined;
7
7
  user: TernSecureUser | null | undefined;
8
8
  };
9
- declare const AuthProviderCtx: react.Context<{
9
+ declare const AuthProviderCtx: React.Context<{
10
10
  value: AuthProviderCtxValue;
11
11
  } | undefined>;
12
12
  declare const useAuthProviderCtx: () => AuthProviderCtxValue;
@@ -1,4 +1,4 @@
1
- import * as react from 'react';
1
+ import * as React from 'react';
2
2
  import { DecodedIdToken, TernSecureUser } from '@tern-secure/types';
3
3
 
4
4
  type AuthProviderCtxValue = {
@@ -6,7 +6,7 @@ type AuthProviderCtxValue = {
6
6
  sessionClaims: DecodedIdToken | null | undefined;
7
7
  user: TernSecureUser | null | undefined;
8
8
  };
9
- declare const AuthProviderCtx: react.Context<{
9
+ declare const AuthProviderCtx: React.Context<{
10
10
  value: AuthProviderCtxValue;
11
11
  } | undefined>;
12
12
  declare const useAuthProviderCtx: () => AuthProviderCtxValue;
@@ -1,9 +1,9 @@
1
- import * as react from 'react';
1
+ import * as React from 'react';
2
2
  import * as _tern_secure_types from '@tern-secure/types';
3
3
  import { IsoTernSecureAuth } from '../lib/isoTernSecureAuth.mjs';
4
4
  import '../types.mjs';
5
5
 
6
- declare const IsoTernSecureAuthCtx: react.Context<{
6
+ declare const IsoTernSecureAuthCtx: React.Context<{
7
7
  value: _tern_secure_types.TernSecureAuth;
8
8
  } | undefined>;
9
9
  declare const useIsoTernSecureAuthCtx: () => IsoTernSecureAuth;
@@ -1,9 +1,9 @@
1
- import * as react from 'react';
1
+ import * as React from 'react';
2
2
  import * as _tern_secure_types from '@tern-secure/types';
3
3
  import { IsoTernSecureAuth } from '../lib/isoTernSecureAuth.js';
4
4
  import '../types.js';
5
5
 
6
- declare const IsoTernSecureAuthCtx: react.Context<{
6
+ declare const IsoTernSecureAuthCtx: React.Context<{
7
7
  value: _tern_secure_types.TernSecureAuth;
8
8
  } | undefined>;
9
9
  declare const useIsoTernSecureAuthCtx: () => IsoTernSecureAuth;
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';
3
- import react__default from 'react';
3
+ import React__default from 'react';
4
4
  import { IsoTernSecureAuthOptions } from '../types.mjs';
5
5
 
6
6
  type TernSecureCtxProviderProps = {
7
- children: react__default.ReactNode;
7
+ children: React__default.ReactNode;
8
8
  instanceOptions: IsoTernSecureAuthOptions;
9
9
  initialState: TernSecureInitialState | undefined;
10
10
  };
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';
3
- import react__default from 'react';
3
+ import React__default from 'react';
4
4
  import { IsoTernSecureAuthOptions } from '../types.js';
5
5
 
6
6
  type TernSecureCtxProviderProps = {
7
- children: react__default.ReactNode;
7
+ children: React__default.ReactNode;
8
8
  instanceOptions: IsoTernSecureAuthOptions;
9
9
  initialState: TernSecureInitialState | undefined;
10
10
  };
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var x=Object.create;var o=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},h=(t,e,n,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of O(e))!E.call(t,s)&&s!==n&&o(t,s,{get:()=>e[s],enumerable:!(u=y(e,s))||u.enumerable});return t};var z=(t,e,n)=>(n=t!=null?x(R(t)):{},h(e||!t||!t.__esModule?o(n,"default",{value:t,enumerable:!0}):n,t)),L=t=>h(o({},"__esModule",{value:!0}),t);var b={};g(b,{TernSecureCtxProvider:()=>M});module.exports=L(b);var c=require("react/jsx-runtime"),T=require("@tern-secure/shared/derivedAuthState"),r=z(require("react")),i=require("../lib/isoTernSecureAuth"),l=require("./AuthProvider"),m=require("./IsomorphicTernSecureCtx");function M(t){const{children:e,initialState:n,instanceOptions:u}=t,{isoTernSecureAuth:s,instanceStatus:a}=N(u),[f,A]=(0,r.useState)({user:s.user,session:s.currentSession});r.default.useEffect(()=>s.addListener(v=>A({...v})),[]);const C=(0,T.deriveAuthState)(f,n),{sessionClaims:S,user:d,userId:p}=C,I=(0,r.useMemo)(()=>({value:{userId:p,user:d,sessionClaims:S}}),[p,d,S]),P=(0,r.useMemo)(()=>({value:s,instanceStatus:a}),[s,a]);return(0,c.jsx)(m.IsoTernSecureAuthCtx.Provider,{value:P,children:(0,c.jsx)(l.AuthProviderCtx.Provider,{value:I,children:e})})}const N=t=>{const e=(0,r.useMemo)(()=>i.IsoTernSecureAuth.getOrCreateInstance(t),[]),[n,u]=(0,r.useState)(e.status);return(0,r.useEffect)(()=>(e.on("status",u),()=>e.off("status",u)),[e]),(0,r.useEffect)(()=>{e.initialize()},[e]),(0,r.useEffect)(()=>()=>{i.IsoTernSecureAuth.clearInstance()},[]),{isoTernSecureAuth:e,instanceStatus:n}};0&&(module.exports={TernSecureCtxProvider});
1
+ "use strict";"use client";var x=Object.create;var o=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of O(e))!E.call(t,s)&&s!==n&&o(t,s,{get:()=>e[s],enumerable:!(u=y(e,s))||u.enumerable});return t};var z=(t,e,n)=>(n=t!=null?x(R(t)):{},v(e||!t||!t.__esModule?o(n,"default",{value:t,enumerable:!0}):n,t)),L=t=>v(o({},"__esModule",{value:!0}),t);var b={};g(b,{TernSecureCtxProvider:()=>M});module.exports=L(b);var c=require("react/jsx-runtime"),h=require("@tern-secure/shared/derivedAuthState"),r=z(require("react")),i=require("../lib/isoTernSecureAuth"),T=require("./AuthProvider"),l=require("./IsomorphicTernSecureCtx");function M(t){const{children:e,initialState:n,instanceOptions:u}=t,{isoTernSecureAuth:s,instanceStatus:m}=N(u),[f,A]=(0,r.useState)({user:s.user,session:s.currentSession});r.default.useEffect(()=>s.addListener(p=>A({...p})),[]);const C=(0,h.deriveAuthState)(f,n),{sessionClaims:a,user:S,userId:d}=C,I=(0,r.useMemo)(()=>({value:{userId:d,user:S,sessionClaims:a}}),[d,S,a]),P=(0,r.useMemo)(()=>({value:s}),[m]);return(0,c.jsx)(l.IsoTernSecureAuthCtx.Provider,{value:P,children:(0,c.jsx)(T.AuthProviderCtx.Provider,{value:I,children:e})})}const N=t=>{const e=(0,r.useMemo)(()=>i.IsoTernSecureAuth.getOrCreateInstance(t),[]),[n,u]=(0,r.useState)(e.status);return(0,r.useEffect)(()=>(e.on("status",u),()=>e.off("status",u)),[e]),(0,r.useEffect)(()=>{e.initialize()},[e]),(0,r.useEffect)(()=>()=>{i.IsoTernSecureAuth.clearInstance()},[]),{isoTernSecureAuth:e,instanceStatus:n}};0&&(module.exports={TernSecureCtxProvider});
2
2
  //# sourceMappingURL=TernSecureCtxProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ctx/TernSecureCtxProvider.tsx"],"sourcesContent":["'use client';\n\nimport { deriveAuthState } from '@tern-secure/shared/derivedAuthState';\nimport type { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport { IsoTernSecureAuth } from '../lib/isoTernSecureAuth';\nimport type { IsoTernSecureAuthOptions } from '../types';\nimport { AuthProviderCtx } from './AuthProvider';\nimport { IsoTernSecureAuthCtx } from './IsomorphicTernSecureCtx';\n\ntype TernSecureCtxProviderProps = {\n children: React.ReactNode;\n instanceOptions: IsoTernSecureAuthOptions;\n initialState: TernSecureInitialState | undefined;\n};\n\nexport type TernSecureCtxProviderState = TernSecureResources;\n\nexport function TernSecureCtxProvider(props: TernSecureCtxProviderProps) {\n const { children, initialState, instanceOptions } = props;\n\n const { isoTernSecureAuth: instance, instanceStatus } = useInitTernSecureAuth(instanceOptions);\n\n const [authState, setAuthState] = useState<TernSecureCtxProviderState>({\n user: instance.user,\n session: instance.currentSession,\n });\n\n React.useEffect(() => {\n return instance.addListener(e => setAuthState({ ...e }));\n }, []);\n\n const derivedState = deriveAuthState(authState, initialState);\n const { sessionClaims, user, userId } = derivedState;\n\n const authCtx = useMemo(() => {\n const value = {\n userId: userId,\n user: user,\n sessionClaims: sessionClaims,\n };\n return { value };\n }, [userId, user, sessionClaims]);\n\n const ternAuthCtx = useMemo(\n () => ({\n value: instance,\n instanceStatus,\n }),\n [instance, instanceStatus],\n );\n\n return (\n <IsoTernSecureAuthCtx.Provider value={ternAuthCtx}>\n <AuthProviderCtx.Provider value={authCtx}>{children}</AuthProviderCtx.Provider>\n </IsoTernSecureAuthCtx.Provider>\n );\n}\n\nconst useInitTernSecureAuth = (options: IsoTernSecureAuthOptions) => {\n const isoTernSecureAuth = useMemo(() => {\n return IsoTernSecureAuth.getOrCreateInstance(options);\n }, []);\n\n const [instanceStatus, setInstanceStatus] = useState(isoTernSecureAuth.status);\n\n useEffect(() => {\n void isoTernSecureAuth.on('status', setInstanceStatus);\n return () => isoTernSecureAuth.off('status', setInstanceStatus);\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n void isoTernSecureAuth.initialize();\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n return () => {\n IsoTernSecureAuth.clearInstance();\n };\n }, []);\n\n return {\n isoTernSecureAuth,\n instanceStatus,\n };\n};\n"],"mappings":"ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAuDM,IAAAI,EAAA,6BArDNC,EAAgC,gDAEhCC,EAAoD,oBAEpDC,EAAkC,oCAElCC,EAAgC,0BAChCC,EAAqC,qCAU9B,SAASP,EAAsBQ,EAAmC,CACvE,KAAM,CAAE,SAAAC,EAAU,aAAAC,EAAc,gBAAAC,CAAgB,EAAIH,EAE9C,CAAE,kBAAmBI,EAAU,eAAAC,CAAe,EAAIC,EAAsBH,CAAe,EAEvF,CAACI,EAAWC,CAAY,KAAI,YAAqC,CACrE,KAAMJ,EAAS,KACf,QAASA,EAAS,cACpB,CAAC,EAED,EAAAK,QAAM,UAAU,IACPL,EAAS,YAAYM,GAAKF,EAAa,CAAE,GAAGE,CAAE,CAAC,CAAC,EACtD,CAAC,CAAC,EAEL,MAAMC,KAAe,mBAAgBJ,EAAWL,CAAY,EACtD,CAAE,cAAAU,EAAe,KAAAC,EAAM,OAAAC,CAAO,EAAIH,EAElCI,KAAU,WAAQ,KAMf,CAAE,MALK,CACZ,OAAQD,EACR,KAAMD,EACN,cAAeD,CACjB,CACe,GACd,CAACE,EAAQD,EAAMD,CAAa,CAAC,EAE1BI,KAAc,WAClB,KAAO,CACL,MAAOZ,EACP,eAAAC,CACF,GACA,CAACD,EAAUC,CAAc,CAC3B,EAEA,SACE,OAAC,uBAAqB,SAArB,CAA8B,MAAOW,EACpC,mBAAC,kBAAgB,SAAhB,CAAyB,MAAOD,EAAU,SAAAd,EAAS,EACtD,CAEJ,CAEA,MAAMK,EAAyBW,GAAsC,CACnE,MAAMC,KAAoB,WAAQ,IACzB,oBAAkB,oBAAoBD,CAAO,EACnD,CAAC,CAAC,EAEC,CAACZ,EAAgBc,CAAiB,KAAI,YAASD,EAAkB,MAAM,EAE7E,sBAAU,KACHA,EAAkB,GAAG,SAAUC,CAAiB,EAC9C,IAAMD,EAAkB,IAAI,SAAUC,CAAiB,GAC7D,CAACD,CAAiB,CAAC,KAEtB,aAAU,IAAM,CACTA,EAAkB,WAAW,CACpC,EAAG,CAACA,CAAiB,CAAC,KAEtB,aAAU,IACD,IAAM,CACX,oBAAkB,cAAc,CAClC,EACC,CAAC,CAAC,EAEE,CACL,kBAAAA,EACA,eAAAb,CACF,CACF","names":["TernSecureCtxProvider_exports","__export","TernSecureCtxProvider","__toCommonJS","import_jsx_runtime","import_derivedAuthState","import_react","import_isoTernSecureAuth","import_AuthProvider","import_IsomorphicTernSecureCtx","props","children","initialState","instanceOptions","instance","instanceStatus","useInitTernSecureAuth","authState","setAuthState","React","e","derivedState","sessionClaims","user","userId","authCtx","ternAuthCtx","options","isoTernSecureAuth","setInstanceStatus"]}
1
+ {"version":3,"sources":["../../src/ctx/TernSecureCtxProvider.tsx"],"sourcesContent":["'use client';\n\nimport { deriveAuthState } from '@tern-secure/shared/derivedAuthState';\nimport type { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport { IsoTernSecureAuth } from '../lib/isoTernSecureAuth';\nimport type { IsoTernSecureAuthOptions } from '../types';\nimport { AuthProviderCtx } from './AuthProvider';\nimport { IsoTernSecureAuthCtx } from './IsomorphicTernSecureCtx';\n\ntype TernSecureCtxProviderProps = {\n children: React.ReactNode;\n instanceOptions: IsoTernSecureAuthOptions;\n initialState: TernSecureInitialState | undefined;\n};\n\nexport type TernSecureCtxProviderState = TernSecureResources;\n\nexport function TernSecureCtxProvider(props: TernSecureCtxProviderProps) {\n const { children, initialState, instanceOptions } = props;\n const { isoTernSecureAuth: instance, instanceStatus } = useInitTernSecureAuth(instanceOptions);\n\n const [authState, setAuthState] = useState<TernSecureCtxProviderState>({\n user: instance.user,\n session: instance.currentSession,\n });\n\n React.useEffect(() => {\n return instance.addListener(e => setAuthState({ ...e }));\n }, []);\n\n const derivedState = deriveAuthState(authState, initialState);\n const { sessionClaims, user, userId } = derivedState;\n\n const authCtx = useMemo(() => {\n const value = {\n userId: userId,\n user: user,\n sessionClaims: sessionClaims,\n };\n return { value };\n }, [userId, user, sessionClaims]);\n\n const ternAuthCtx = useMemo(\n () => ({ value: instance}),[instanceStatus],\n );\n\n return (\n <IsoTernSecureAuthCtx.Provider value={ternAuthCtx}>\n <AuthProviderCtx.Provider value={authCtx}>{children}</AuthProviderCtx.Provider>\n </IsoTernSecureAuthCtx.Provider>\n );\n}\n\nconst useInitTernSecureAuth = (options: IsoTernSecureAuthOptions) => {\n const isoTernSecureAuth = useMemo(() => {\n return IsoTernSecureAuth.getOrCreateInstance(options);\n }, []);\n\n const [instanceStatus, setInstanceStatus] = useState(isoTernSecureAuth.status);\n\n useEffect(() => {\n void isoTernSecureAuth.on('status', setInstanceStatus);\n return () => isoTernSecureAuth.off('status', setInstanceStatus);\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n void isoTernSecureAuth.initialize();\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n return () => {\n IsoTernSecureAuth.clearInstance();\n };\n }, []);\n\n return {\n isoTernSecureAuth,\n instanceStatus,\n };\n};\n"],"mappings":"ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAkDM,IAAAI,EAAA,6BAhDNC,EAAgC,gDAEhCC,EAAoD,oBAEpDC,EAAkC,oCAElCC,EAAgC,0BAChCC,EAAqC,qCAU9B,SAASP,EAAsBQ,EAAmC,CACvE,KAAM,CAAE,SAAAC,EAAU,aAAAC,EAAc,gBAAAC,CAAgB,EAAIH,EAC9C,CAAE,kBAAmBI,EAAU,eAAAC,CAAe,EAAIC,EAAsBH,CAAe,EAEvF,CAACI,EAAWC,CAAY,KAAI,YAAqC,CACrE,KAAMJ,EAAS,KACf,QAASA,EAAS,cACpB,CAAC,EAED,EAAAK,QAAM,UAAU,IACPL,EAAS,YAAYM,GAAKF,EAAa,CAAE,GAAGE,CAAE,CAAC,CAAC,EACtD,CAAC,CAAC,EAEL,MAAMC,KAAe,mBAAgBJ,EAAWL,CAAY,EACtD,CAAE,cAAAU,EAAe,KAAAC,EAAM,OAAAC,CAAO,EAAIH,EAElCI,KAAU,WAAQ,KAMf,CAAE,MALK,CACZ,OAAQD,EACR,KAAMD,EACN,cAAeD,CACjB,CACe,GACd,CAACE,EAAQD,EAAMD,CAAa,CAAC,EAE1BI,KAAc,WAClB,KAAO,CAAE,MAAOZ,CAAQ,GAAG,CAACC,CAAc,CAC5C,EAEA,SACE,OAAC,uBAAqB,SAArB,CAA8B,MAAOW,EACpC,mBAAC,kBAAgB,SAAhB,CAAyB,MAAOD,EAAU,SAAAd,EAAS,EACtD,CAEJ,CAEA,MAAMK,EAAyBW,GAAsC,CACnE,MAAMC,KAAoB,WAAQ,IACzB,oBAAkB,oBAAoBD,CAAO,EACnD,CAAC,CAAC,EAEC,CAACZ,EAAgBc,CAAiB,KAAI,YAASD,EAAkB,MAAM,EAE7E,sBAAU,KACHA,EAAkB,GAAG,SAAUC,CAAiB,EAC9C,IAAMD,EAAkB,IAAI,SAAUC,CAAiB,GAC7D,CAACD,CAAiB,CAAC,KAEtB,aAAU,IAAM,CACTA,EAAkB,WAAW,CACpC,EAAG,CAACA,CAAiB,CAAC,KAEtB,aAAU,IACD,IAAM,CACX,oBAAkB,cAAc,CAClC,EACC,CAAC,CAAC,EAEE,CACL,kBAAAA,EACA,eAAAb,CACF,CACF","names":["TernSecureCtxProvider_exports","__export","TernSecureCtxProvider","__toCommonJS","import_jsx_runtime","import_derivedAuthState","import_react","import_isoTernSecureAuth","import_AuthProvider","import_IsomorphicTernSecureCtx","props","children","initialState","instanceOptions","instance","instanceStatus","useInitTernSecureAuth","authState","setAuthState","React","e","derivedState","sessionClaims","user","userId","authCtx","ternAuthCtx","options","isoTernSecureAuth","setInstanceStatus"]}
@@ -1,2 +1,2 @@
1
- "use client";import{jsx as h}from"react/jsx-runtime";import{deriveAuthState as C}from"@tern-secure/shared/derivedAuthState";import I,{useEffect as u,useMemo as o,useState as p}from"react";import{IsoTernSecureAuth as v}from"../lib/isoTernSecureAuth";import{AuthProviderCtx as P}from"./AuthProvider";import{IsoTernSecureAuthCtx as x}from"./IsomorphicTernSecureCtx";function L(n){const{children:e,initialState:s,instanceOptions:r}=n,{isoTernSecureAuth:t,instanceStatus:i}=y(r),[T,l]=p({user:t.user,session:t.currentSession});I.useEffect(()=>t.addListener(d=>l({...d})),[]);const m=C(T,s),{sessionClaims:c,user:a,userId:S}=m,f=o(()=>({value:{userId:S,user:a,sessionClaims:c}}),[S,a,c]),A=o(()=>({value:t,instanceStatus:i}),[t,i]);return h(x.Provider,{value:A,children:h(P.Provider,{value:f,children:e})})}const y=n=>{const e=o(()=>v.getOrCreateInstance(n),[]),[s,r]=p(e.status);return u(()=>(e.on("status",r),()=>e.off("status",r)),[e]),u(()=>{e.initialize()},[e]),u(()=>()=>{v.clearInstance()},[]),{isoTernSecureAuth:e,instanceStatus:s}};export{L as TernSecureCtxProvider};
1
+ "use client";import{jsx as v}from"react/jsx-runtime";import{deriveAuthState as C}from"@tern-secure/shared/derivedAuthState";import I,{useEffect as u,useMemo as o,useState as d}from"react";import{IsoTernSecureAuth as p}from"../lib/isoTernSecureAuth";import{AuthProviderCtx as P}from"./AuthProvider";import{IsoTernSecureAuthCtx as x}from"./IsomorphicTernSecureCtx";function L(n){const{children:e,initialState:s,instanceOptions:t}=n,{isoTernSecureAuth:r,instanceStatus:h}=y(t),[T,l]=d({user:r.user,session:r.currentSession});I.useEffect(()=>r.addListener(S=>l({...S})),[]);const m=C(T,s),{sessionClaims:i,user:c,userId:a}=m,f=o(()=>({value:{userId:a,user:c,sessionClaims:i}}),[a,c,i]),A=o(()=>({value:r}),[h]);return v(x.Provider,{value:A,children:v(P.Provider,{value:f,children:e})})}const y=n=>{const e=o(()=>p.getOrCreateInstance(n),[]),[s,t]=d(e.status);return u(()=>(e.on("status",t),()=>e.off("status",t)),[e]),u(()=>{e.initialize()},[e]),u(()=>()=>{p.clearInstance()},[]),{isoTernSecureAuth:e,instanceStatus:s}};export{L as TernSecureCtxProvider};
2
2
  //# sourceMappingURL=TernSecureCtxProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ctx/TernSecureCtxProvider.tsx"],"sourcesContent":["'use client';\n\nimport { deriveAuthState } from '@tern-secure/shared/derivedAuthState';\nimport type { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport { IsoTernSecureAuth } from '../lib/isoTernSecureAuth';\nimport type { IsoTernSecureAuthOptions } from '../types';\nimport { AuthProviderCtx } from './AuthProvider';\nimport { IsoTernSecureAuthCtx } from './IsomorphicTernSecureCtx';\n\ntype TernSecureCtxProviderProps = {\n children: React.ReactNode;\n instanceOptions: IsoTernSecureAuthOptions;\n initialState: TernSecureInitialState | undefined;\n};\n\nexport type TernSecureCtxProviderState = TernSecureResources;\n\nexport function TernSecureCtxProvider(props: TernSecureCtxProviderProps) {\n const { children, initialState, instanceOptions } = props;\n\n const { isoTernSecureAuth: instance, instanceStatus } = useInitTernSecureAuth(instanceOptions);\n\n const [authState, setAuthState] = useState<TernSecureCtxProviderState>({\n user: instance.user,\n session: instance.currentSession,\n });\n\n React.useEffect(() => {\n return instance.addListener(e => setAuthState({ ...e }));\n }, []);\n\n const derivedState = deriveAuthState(authState, initialState);\n const { sessionClaims, user, userId } = derivedState;\n\n const authCtx = useMemo(() => {\n const value = {\n userId: userId,\n user: user,\n sessionClaims: sessionClaims,\n };\n return { value };\n }, [userId, user, sessionClaims]);\n\n const ternAuthCtx = useMemo(\n () => ({\n value: instance,\n instanceStatus,\n }),\n [instance, instanceStatus],\n );\n\n return (\n <IsoTernSecureAuthCtx.Provider value={ternAuthCtx}>\n <AuthProviderCtx.Provider value={authCtx}>{children}</AuthProviderCtx.Provider>\n </IsoTernSecureAuthCtx.Provider>\n );\n}\n\nconst useInitTernSecureAuth = (options: IsoTernSecureAuthOptions) => {\n const isoTernSecureAuth = useMemo(() => {\n return IsoTernSecureAuth.getOrCreateInstance(options);\n }, []);\n\n const [instanceStatus, setInstanceStatus] = useState(isoTernSecureAuth.status);\n\n useEffect(() => {\n void isoTernSecureAuth.on('status', setInstanceStatus);\n return () => isoTernSecureAuth.off('status', setInstanceStatus);\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n void isoTernSecureAuth.initialize();\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n return () => {\n IsoTernSecureAuth.clearInstance();\n };\n }, []);\n\n return {\n isoTernSecureAuth,\n instanceStatus,\n };\n};\n"],"mappings":"aAuDM,cAAAA,MAAA,oBArDN,OAAS,mBAAAC,MAAuB,uCAEhC,OAAOC,GAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAEpD,OAAS,qBAAAC,MAAyB,2BAElC,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,wBAAAC,MAA4B,4BAU9B,SAASC,EAAsBC,EAAmC,CACvE,KAAM,CAAE,SAAAC,EAAU,aAAAC,EAAc,gBAAAC,CAAgB,EAAIH,EAE9C,CAAE,kBAAmBI,EAAU,eAAAC,CAAe,EAAIC,EAAsBH,CAAe,EAEvF,CAACI,EAAWC,CAAY,EAAIb,EAAqC,CACrE,KAAMS,EAAS,KACf,QAASA,EAAS,cACpB,CAAC,EAEDZ,EAAM,UAAU,IACPY,EAAS,YAAYK,GAAKD,EAAa,CAAE,GAAGC,CAAE,CAAC,CAAC,EACtD,CAAC,CAAC,EAEL,MAAMC,EAAenB,EAAgBgB,EAAWL,CAAY,EACtD,CAAE,cAAAS,EAAe,KAAAC,EAAM,OAAAC,CAAO,EAAIH,EAElCI,EAAUpB,EAAQ,KAMf,CAAE,MALK,CACZ,OAAQmB,EACR,KAAMD,EACN,cAAeD,CACjB,CACe,GACd,CAACE,EAAQD,EAAMD,CAAa,CAAC,EAE1BI,EAAcrB,EAClB,KAAO,CACL,MAAOU,EACP,eAAAC,CACF,GACA,CAACD,EAAUC,CAAc,CAC3B,EAEA,OACEf,EAACQ,EAAqB,SAArB,CAA8B,MAAOiB,EACpC,SAAAzB,EAACO,EAAgB,SAAhB,CAAyB,MAAOiB,EAAU,SAAAb,EAAS,EACtD,CAEJ,CAEA,MAAMK,EAAyBU,GAAsC,CACnE,MAAMC,EAAoBvB,EAAQ,IACzBE,EAAkB,oBAAoBoB,CAAO,EACnD,CAAC,CAAC,EAEC,CAACX,EAAgBa,CAAiB,EAAIvB,EAASsB,EAAkB,MAAM,EAE7E,OAAAxB,EAAU,KACHwB,EAAkB,GAAG,SAAUC,CAAiB,EAC9C,IAAMD,EAAkB,IAAI,SAAUC,CAAiB,GAC7D,CAACD,CAAiB,CAAC,EAEtBxB,EAAU,IAAM,CACTwB,EAAkB,WAAW,CACpC,EAAG,CAACA,CAAiB,CAAC,EAEtBxB,EAAU,IACD,IAAM,CACXG,EAAkB,cAAc,CAClC,EACC,CAAC,CAAC,EAEE,CACL,kBAAAqB,EACA,eAAAZ,CACF,CACF","names":["jsx","deriveAuthState","React","useEffect","useMemo","useState","IsoTernSecureAuth","AuthProviderCtx","IsoTernSecureAuthCtx","TernSecureCtxProvider","props","children","initialState","instanceOptions","instance","instanceStatus","useInitTernSecureAuth","authState","setAuthState","e","derivedState","sessionClaims","user","userId","authCtx","ternAuthCtx","options","isoTernSecureAuth","setInstanceStatus"]}
1
+ {"version":3,"sources":["../../src/ctx/TernSecureCtxProvider.tsx"],"sourcesContent":["'use client';\n\nimport { deriveAuthState } from '@tern-secure/shared/derivedAuthState';\nimport type { TernSecureInitialState, TernSecureResources } from '@tern-secure/types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport { IsoTernSecureAuth } from '../lib/isoTernSecureAuth';\nimport type { IsoTernSecureAuthOptions } from '../types';\nimport { AuthProviderCtx } from './AuthProvider';\nimport { IsoTernSecureAuthCtx } from './IsomorphicTernSecureCtx';\n\ntype TernSecureCtxProviderProps = {\n children: React.ReactNode;\n instanceOptions: IsoTernSecureAuthOptions;\n initialState: TernSecureInitialState | undefined;\n};\n\nexport type TernSecureCtxProviderState = TernSecureResources;\n\nexport function TernSecureCtxProvider(props: TernSecureCtxProviderProps) {\n const { children, initialState, instanceOptions } = props;\n const { isoTernSecureAuth: instance, instanceStatus } = useInitTernSecureAuth(instanceOptions);\n\n const [authState, setAuthState] = useState<TernSecureCtxProviderState>({\n user: instance.user,\n session: instance.currentSession,\n });\n\n React.useEffect(() => {\n return instance.addListener(e => setAuthState({ ...e }));\n }, []);\n\n const derivedState = deriveAuthState(authState, initialState);\n const { sessionClaims, user, userId } = derivedState;\n\n const authCtx = useMemo(() => {\n const value = {\n userId: userId,\n user: user,\n sessionClaims: sessionClaims,\n };\n return { value };\n }, [userId, user, sessionClaims]);\n\n const ternAuthCtx = useMemo(\n () => ({ value: instance}),[instanceStatus],\n );\n\n return (\n <IsoTernSecureAuthCtx.Provider value={ternAuthCtx}>\n <AuthProviderCtx.Provider value={authCtx}>{children}</AuthProviderCtx.Provider>\n </IsoTernSecureAuthCtx.Provider>\n );\n}\n\nconst useInitTernSecureAuth = (options: IsoTernSecureAuthOptions) => {\n const isoTernSecureAuth = useMemo(() => {\n return IsoTernSecureAuth.getOrCreateInstance(options);\n }, []);\n\n const [instanceStatus, setInstanceStatus] = useState(isoTernSecureAuth.status);\n\n useEffect(() => {\n void isoTernSecureAuth.on('status', setInstanceStatus);\n return () => isoTernSecureAuth.off('status', setInstanceStatus);\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n void isoTernSecureAuth.initialize();\n }, [isoTernSecureAuth]);\n\n useEffect(() => {\n return () => {\n IsoTernSecureAuth.clearInstance();\n };\n }, []);\n\n return {\n isoTernSecureAuth,\n instanceStatus,\n };\n};\n"],"mappings":"aAkDM,cAAAA,MAAA,oBAhDN,OAAS,mBAAAC,MAAuB,uCAEhC,OAAOC,GAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAEpD,OAAS,qBAAAC,MAAyB,2BAElC,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,wBAAAC,MAA4B,4BAU9B,SAASC,EAAsBC,EAAmC,CACvE,KAAM,CAAE,SAAAC,EAAU,aAAAC,EAAc,gBAAAC,CAAgB,EAAIH,EAC9C,CAAE,kBAAmBI,EAAU,eAAAC,CAAe,EAAIC,EAAsBH,CAAe,EAEvF,CAACI,EAAWC,CAAY,EAAIb,EAAqC,CACrE,KAAMS,EAAS,KACf,QAASA,EAAS,cACpB,CAAC,EAEDZ,EAAM,UAAU,IACPY,EAAS,YAAYK,GAAKD,EAAa,CAAE,GAAGC,CAAE,CAAC,CAAC,EACtD,CAAC,CAAC,EAEL,MAAMC,EAAenB,EAAgBgB,EAAWL,CAAY,EACtD,CAAE,cAAAS,EAAe,KAAAC,EAAM,OAAAC,CAAO,EAAIH,EAElCI,EAAUpB,EAAQ,KAMf,CAAE,MALK,CACZ,OAAQmB,EACR,KAAMD,EACN,cAAeD,CACjB,CACe,GACd,CAACE,EAAQD,EAAMD,CAAa,CAAC,EAE1BI,EAAcrB,EAClB,KAAO,CAAE,MAAOU,CAAQ,GAAG,CAACC,CAAc,CAC5C,EAEA,OACEf,EAACQ,EAAqB,SAArB,CAA8B,MAAOiB,EACpC,SAAAzB,EAACO,EAAgB,SAAhB,CAAyB,MAAOiB,EAAU,SAAAb,EAAS,EACtD,CAEJ,CAEA,MAAMK,EAAyBU,GAAsC,CACnE,MAAMC,EAAoBvB,EAAQ,IACzBE,EAAkB,oBAAoBoB,CAAO,EACnD,CAAC,CAAC,EAEC,CAACX,EAAgBa,CAAiB,EAAIvB,EAASsB,EAAkB,MAAM,EAE7E,OAAAxB,EAAU,KACHwB,EAAkB,GAAG,SAAUC,CAAiB,EAC9C,IAAMD,EAAkB,IAAI,SAAUC,CAAiB,GAC7D,CAACD,CAAiB,CAAC,EAEtBxB,EAAU,IAAM,CACTwB,EAAkB,WAAW,CACpC,EAAG,CAACA,CAAiB,CAAC,EAEtBxB,EAAU,IACD,IAAM,CACXG,EAAkB,cAAc,CAClC,EACC,CAAC,CAAC,EAEE,CACL,kBAAAqB,EACA,eAAAZ,CACF,CACF","names":["jsx","deriveAuthState","React","useEffect","useMemo","useState","IsoTernSecureAuth","AuthProviderCtx","IsoTernSecureAuthCtx","TernSecureCtxProvider","props","children","initialState","instanceOptions","instance","instanceStatus","useInitTernSecureAuth","authState","setAuthState","e","derivedState","sessionClaims","user","userId","authCtx","ternAuthCtx","options","isoTernSecureAuth","setInstanceStatus"]}
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import react__default from 'react';
2
+ import React__default from 'react';
3
3
  import { TernSecureProviderProps } from '../types.mjs';
4
4
  import '@tern-secure/types';
5
5
 
6
6
  declare function TernSecureProviderBase(props: TernSecureProviderProps): react_jsx_runtime.JSX.Element;
7
- declare const TernSecureProvider: react__default.MemoExoticComponent<typeof TernSecureProviderBase>;
7
+ declare const TernSecureProvider: React__default.MemoExoticComponent<typeof TernSecureProviderBase>;
8
8
 
9
9
  export { TernSecureProvider };
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import react__default from 'react';
2
+ import React__default from 'react';
3
3
  import { TernSecureProviderProps } from '../types.js';
4
4
  import '@tern-secure/types';
5
5
 
6
6
  declare function TernSecureProviderBase(props: TernSecureProviderProps): react_jsx_runtime.JSX.Element;
7
- declare const TernSecureProvider: react__default.MemoExoticComponent<typeof TernSecureProviderBase>;
7
+ declare const TernSecureProvider: React__default.MemoExoticComponent<typeof TernSecureProviderBase>;
8
8
 
9
9
  export { TernSecureProvider };
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ declare function useMaxAllowedInstancesGuard(name: string, error: string, maxCount?: number): void;
4
+ declare function withMaxAllowedInstancesGuard<P>(WrappedComponent: React__default.ComponentType<P>, name: string, error: string): React__default.ComponentType<P>;
5
+
6
+ export { useMaxAllowedInstancesGuard, withMaxAllowedInstancesGuard };
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ declare function useMaxAllowedInstancesGuard(name: string, error: string, maxCount?: number): void;
4
+ declare function withMaxAllowedInstancesGuard<P>(WrappedComponent: React__default.ComponentType<P>, name: string, error: string): React__default.ComponentType<P>;
5
+
6
+ export { useMaxAllowedInstancesGuard, withMaxAllowedInstancesGuard };
@@ -0,0 +1,2 @@
1
+ "use strict";var f=Object.create;var r=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var M=(t,n)=>{for(var e in n)r(t,e,{get:n[e],enumerable:!0})},a=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of g(n))!y.call(t,s)&&s!==e&&r(t,s,{get:()=>n[s],enumerable:!(o=w(n,s))||o.enumerable});return t};var h=(t,n,e)=>(e=t!=null?f(p(t)):{},a(n||!t||!t.__esModule?r(e,"default",{value:t,enumerable:!0}):e,t)),m=t=>a(r({},"__esModule",{value:!0}),t);var P={};M(P,{useMaxAllowedInstancesGuard:()=>u,withMaxAllowedInstancesGuard:()=>x});module.exports=m(P);var d=require("react/jsx-runtime"),i=h(require("react"));const c=new Map;function u(t,n,e=1){i.default.useEffect(()=>{const o=c.get(t)||0;if(o==e)throw new Error(`Maximum number of instances (${e}) of ${t} reached. ${n}`);return c.set(t,o+1),()=>{c.set(t,(c.get(t)||1)-1)}},[])}function x(t,n,e){const o=t.displayName||t.name||n||"Component",s=l=>(u(n,e),(0,d.jsx)(t,{...l}));return s.displayName=`withMaxAllowedInstancesGuard(${o})`,s}0&&(module.exports={useMaxAllowedInstancesGuard,withMaxAllowedInstancesGuard});
2
+ //# sourceMappingURL=useMaxAllowedInstances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useMaxAllowedInstances.tsx"],"sourcesContent":["import React from 'react';\n\nconst counts = new Map<string, number>();\n\nexport function useMaxAllowedInstancesGuard(name: string, error: string, maxCount = 1): void {\n React.useEffect(() => {\n const count = counts.get(name) || 0;\n if (count == maxCount) {\n throw new Error(\n `Maximum number of instances (${maxCount}) of ${name} reached. ${error}`,\n );\n }\n counts.set(name, count + 1);\n\n return () => {\n counts.set(name, (counts.get(name) || 1) - 1);\n };\n }, []);\n}\n\nexport function withMaxAllowedInstancesGuard<P>(\n WrappedComponent: React.ComponentType<P>,\n name: string,\n error: string,\n): React.ComponentType<P> {\n const displayName = WrappedComponent.displayName || WrappedComponent.name || name || 'Component';\n const Hoc = (props: P) => {\n useMaxAllowedInstancesGuard(name, error);\n return <WrappedComponent {...(props as any)} />;\n };\n Hoc.displayName = `withMaxAllowedInstancesGuard(${displayName})`;\n return Hoc;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,iCAAAC,IAAA,eAAAC,EAAAJ,GA4BW,IAAAK,EAAA,6BA5BXC,EAAkB,oBAElB,MAAMC,EAAS,IAAI,IAEZ,SAASL,EAA4BM,EAAcC,EAAeC,EAAW,EAAS,CAC3F,EAAAC,QAAM,UAAU,IAAM,CACpB,MAAMC,EAAQL,EAAO,IAAIC,CAAI,GAAK,EAClC,GAAII,GAASF,EACT,MAAM,IAAI,MACN,gCAAgCA,CAAQ,QAAQF,CAAI,aAAaC,CAAK,EAC1E,EAEJ,OAAAF,EAAO,IAAIC,EAAMI,EAAQ,CAAC,EAEnB,IAAM,CACXL,EAAO,IAAIC,GAAOD,EAAO,IAAIC,CAAI,GAAK,GAAK,CAAC,CAC9C,CACF,EAAG,CAAC,CAAC,CACP,CAEO,SAASL,EACdU,EACAL,EACAC,EACwB,CACxB,MAAMK,EAAcD,EAAiB,aAAeA,EAAiB,MAAQL,GAAQ,YAC/EO,EAAOC,IACXd,EAA4BM,EAAMC,CAAK,KAChC,OAACI,EAAA,CAAkB,GAAIG,EAAe,GAE/C,OAAAD,EAAI,YAAc,gCAAgCD,CAAW,IACtDC,CACT","names":["useMaxAllowedInstances_exports","__export","useMaxAllowedInstancesGuard","withMaxAllowedInstancesGuard","__toCommonJS","import_jsx_runtime","import_react","counts","name","error","maxCount","React","count","WrappedComponent","displayName","Hoc","props"]}
@@ -0,0 +1,2 @@
1
+ import{jsx as u}from"react/jsx-runtime";import a from"react";const o=new Map;function i(t,n,e=1){a.useEffect(()=>{const s=o.get(t)||0;if(s==e)throw new Error(`Maximum number of instances (${e}) of ${t} reached. ${n}`);return o.set(t,s+1),()=>{o.set(t,(o.get(t)||1)-1)}},[])}function l(t,n,e){const s=t.displayName||t.name||n||"Component",r=c=>(i(n,e),u(t,{...c}));return r.displayName=`withMaxAllowedInstancesGuard(${s})`,r}export{i as useMaxAllowedInstancesGuard,l as withMaxAllowedInstancesGuard};
2
+ //# sourceMappingURL=useMaxAllowedInstances.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useMaxAllowedInstances.tsx"],"sourcesContent":["import React from 'react';\n\nconst counts = new Map<string, number>();\n\nexport function useMaxAllowedInstancesGuard(name: string, error: string, maxCount = 1): void {\n React.useEffect(() => {\n const count = counts.get(name) || 0;\n if (count == maxCount) {\n throw new Error(\n `Maximum number of instances (${maxCount}) of ${name} reached. ${error}`,\n );\n }\n counts.set(name, count + 1);\n\n return () => {\n counts.set(name, (counts.get(name) || 1) - 1);\n };\n }, []);\n}\n\nexport function withMaxAllowedInstancesGuard<P>(\n WrappedComponent: React.ComponentType<P>,\n name: string,\n error: string,\n): React.ComponentType<P> {\n const displayName = WrappedComponent.displayName || WrappedComponent.name || name || 'Component';\n const Hoc = (props: P) => {\n useMaxAllowedInstancesGuard(name, error);\n return <WrappedComponent {...(props as any)} />;\n };\n Hoc.displayName = `withMaxAllowedInstancesGuard(${displayName})`;\n return Hoc;\n}\n"],"mappings":"AA4BW,cAAAA,MAAA,oBA5BX,OAAOC,MAAW,QAElB,MAAMC,EAAS,IAAI,IAEZ,SAASC,EAA4BC,EAAcC,EAAeC,EAAW,EAAS,CAC3FL,EAAM,UAAU,IAAM,CACpB,MAAMM,EAAQL,EAAO,IAAIE,CAAI,GAAK,EAClC,GAAIG,GAASD,EACT,MAAM,IAAI,MACN,gCAAgCA,CAAQ,QAAQF,CAAI,aAAaC,CAAK,EAC1E,EAEJ,OAAAH,EAAO,IAAIE,EAAMG,EAAQ,CAAC,EAEnB,IAAM,CACXL,EAAO,IAAIE,GAAOF,EAAO,IAAIE,CAAI,GAAK,GAAK,CAAC,CAC9C,CACF,EAAG,CAAC,CAAC,CACP,CAEO,SAASI,EACdC,EACAL,EACAC,EACwB,CACxB,MAAMK,EAAcD,EAAiB,aAAeA,EAAiB,MAAQL,GAAQ,YAC/EO,EAAOC,IACXT,EAA4BC,EAAMC,CAAK,EAChCL,EAACS,EAAA,CAAkB,GAAIG,EAAe,GAE/C,OAAAD,EAAI,YAAc,gCAAgCD,CAAW,IACtDC,CACT","names":["jsx","React","counts","useMaxAllowedInstancesGuard","name","error","maxCount","count","withMaxAllowedInstancesGuard","WrappedComponent","displayName","Hoc","props"]}
@@ -1,4 +1,4 @@
1
- import { UseSignInReturn, SignInFormValues, SignInResponse, SocialProviderOptions, ResendEmailVerification } from '@tern-secure/types';
1
+ import { UseSignInReturn, SignInPasswordParams, SignInResponse, SocialProviderOptions, SignInVerificationResponse } from '@tern-secure/types';
2
2
 
3
3
  /**
4
4
  * Hook to access the SignInResource methods from TernSecureAuth
@@ -6,9 +6,9 @@ import { UseSignInReturn, SignInFormValues, SignInResponse, SocialProviderOption
6
6
  */
7
7
  declare const useSignIn: () => UseSignInReturn;
8
8
  declare const signIn: {
9
- withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
10
- withSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
- resendEmailVerification: () => Promise<ResendEmailVerification>;
9
+ authenticateWithPasswordd: (params: SignInPasswordParams) => Promise<SignInResponse>;
10
+ authenticateWithSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
+ attemptEmailVerification: () => Promise<SignInVerificationResponse>;
12
12
  checkRedirectResult: () => Promise<SignInResponse | null>;
13
13
  };
14
14
 
@@ -1,4 +1,4 @@
1
- import { UseSignInReturn, SignInFormValues, SignInResponse, SocialProviderOptions, ResendEmailVerification } from '@tern-secure/types';
1
+ import { UseSignInReturn, SignInPasswordParams, SignInResponse, SocialProviderOptions, SignInVerificationResponse } from '@tern-secure/types';
2
2
 
3
3
  /**
4
4
  * Hook to access the SignInResource methods from TernSecureAuth
@@ -6,9 +6,9 @@ import { UseSignInReturn, SignInFormValues, SignInResponse, SocialProviderOption
6
6
  */
7
7
  declare const useSignIn: () => UseSignInReturn;
8
8
  declare const signIn: {
9
- withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
10
- withSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
- resendEmailVerification: () => Promise<ResendEmailVerification>;
9
+ authenticateWithPasswordd: (params: SignInPasswordParams) => Promise<SignInResponse>;
10
+ authenticateWithSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
+ attemptEmailVerification: () => Promise<SignInVerificationResponse>;
12
12
  checkRedirectResult: () => Promise<SignInResponse | null>;
13
13
  };
14
14
 
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=(n,i)=>{for(var e in i)o(n,e,{get:i[e],enumerable:!0})},h=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of d(i))!l.call(n,r)&&r!==e&&o(n,r,{get:()=>i[r],enumerable:!(s=u(i,r))||s.enumerable});return n};var m=n=>h(o({},"__esModule",{value:!0}),n);var I={};c(I,{signIn:()=>g,useSignIn:()=>S});module.exports=m(I);var t=require("../ctx/TernSecureAuthResourcesCtx"),a=require("./useAssertWrappedTernSecureProvider");const S=()=>{(0,a.useAssertWrappedByTernSecureAuthProvider)("useSignIn");const n=(0,t.useAuthSignInCtx)();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},g={withEmailAndPassword:async n=>{const i=(0,t.useAuthSignInCtx)();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.withEmailAndPassword(n)},withSocialProvider:async(n,i)=>{const e=(0,t.useAuthSignInCtx)();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.withSocialProvider(n,i)},resendEmailVerification:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.resendEmailVerification()},checkRedirectResult:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};0&&(module.exports={signIn,useSignIn});
1
+ "use strict";"use client";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var i in e)o(n,i,{get:e[i],enumerable:!0})},l=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!h.call(n,r)&&r!==i&&o(n,r,{get:()=>e[r],enumerable:!(s=u(e,r))||s.enumerable});return n};var S=n=>l(o({},"__esModule",{value:!0}),n);var I={};d(I,{signIn:()=>m,useSignIn:()=>g});module.exports=S(I);var t=require("../ctx/TernSecureAuthResourcesCtx"),a=require("./useAssertWrappedTernSecureProvider");const g=()=>{(0,a.useAssertWrappedByTernSecureAuthProvider)("useSignIn");const n=(0,t.useAuthSignInCtx)();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},m={authenticateWithPasswordd:async n=>{const e=(0,t.useAuthSignInCtx)();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,e)=>{const i=(0,t.useAuthSignInCtx)();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithSocialProvider(n,e)},attemptEmailVerification:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};0&&(module.exports={signIn,useSignIn});
2
2
  //# sourceMappingURL=useSignIn.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n ResendEmailVerification,\n SignInFormValues,\n SignInResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n withEmailAndPassword: async (params: SignInFormValues): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.withEmailAndPassword(params);\n },\n\n withSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.withSocialProvider(provider, customOptions);\n },\n\n resendEmailVerification: async (): Promise<ResendEmailVerification> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.resendEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAUA,IAAAK,EAAiC,6CACjCC,EAAyD,gDAMlD,MAAMH,EAAY,IAAuB,IAC9C,4CAAyC,WAAW,EACpD,MAAMI,KAAO,oBAAiB,EAE9B,OAAKA,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaL,EAAS,CACpB,qBAAsB,MAAOM,GAAsD,CACjF,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,qBAAqBC,CAAM,CACzC,EAEA,mBAAoB,MAClBC,EACAC,IACmC,CACnC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,mBAAmBE,EAAUC,CAAa,CACxD,EAEA,wBAAyB,SAA8C,CACrE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,wBAAwB,CACtC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useSignIn_exports","__export","signIn","useSignIn","__toCommonJS","import_TernSecureAuthResourcesCtx","import_useAssertWrappedTernSecureProvider","auth","params","provider","customOptions"]}
1
+ {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n SignInPasswordParams,\n SignInResponse,\n SignInVerificationResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n authenticateWithPasswordd: async (params: SignInPasswordParams): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithPassword(params);\n },\n\n authenticateWithSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithSocialProvider(provider, customOptions);\n },\n\n attemptEmailVerification: async (): Promise<SignInVerificationResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.attemptEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAUA,IAAAK,EAAiC,6CACjCC,EAAyD,gDAMlD,MAAMH,EAAY,IAAuB,IAC9C,4CAAyC,WAAW,EACpD,MAAMI,KAAO,oBAAiB,EAE9B,OAAKA,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaL,EAAS,CACpB,0BAA2B,MAAOM,GAA0D,CAC1F,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyBC,CAAM,CAC7C,EAEA,+BAAgC,MAC9BC,EACAC,IACmC,CACnC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,+BAA+BE,EAAUC,CAAa,CACpE,EAEA,yBAA0B,SAAiD,CACzE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyB,CACvC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useSignIn_exports","__export","signIn","useSignIn","__toCommonJS","import_TernSecureAuthResourcesCtx","import_useAssertWrappedTernSecureProvider","auth","params","provider","customOptions"]}
@@ -1,2 +1,2 @@
1
- "use client";import{useAuthSignInCtx as i}from"../ctx/TernSecureAuthResourcesCtx";import{useAssertWrappedByTernSecureAuthProvider as r}from"./useAssertWrappedTernSecureProvider";const a=()=>{r("useSignIn");const n=i();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},u={withEmailAndPassword:async n=>{const e=i();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.withEmailAndPassword(n)},withSocialProvider:async(n,e)=>{const t=i();if(!t)throw new Error("SignIn methods not available - auth not initialized");return t.withSocialProvider(n,e)},resendEmailVerification:async()=>{const n=i();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.resendEmailVerification()},checkRedirectResult:async()=>{const n=i();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};export{u as signIn,a as useSignIn};
1
+ "use client";import{useAuthSignInCtx as e}from"../ctx/TernSecureAuthResourcesCtx";import{useAssertWrappedByTernSecureAuthProvider as r}from"./useAssertWrappedTernSecureProvider";const a=()=>{r("useSignIn");const n=e();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},u={authenticateWithPasswordd:async n=>{const i=e();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,i)=>{const t=e();if(!t)throw new Error("SignIn methods not available - auth not initialized");return t.authenticateWithSocialProvider(n,i)},attemptEmailVerification:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};export{u as signIn,a as useSignIn};
2
2
  //# sourceMappingURL=useSignIn.mjs.map