@stacksjs/composables 0.70.294 → 0.70.297
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/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/session-handoff.d.ts +63 -0
- package/dist/session-handoff.js +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -269,3 +269,16 @@ export { useThrottledRef as throttledRef } from './useThrottledRef';
|
|
|
269
269
|
export { useThrottledRef as refThrottled } from './useThrottledRef';
|
|
270
270
|
export { watchDebounced as debouncedWatch } from './watchDebounced';
|
|
271
271
|
export { watchThrottled as throttledWatch } from './watchThrottled';
|
|
272
|
+
// Moving a server-minted session into the browser at the end of a redirect
|
|
273
|
+
// flow (stacksjs/stacks#2236). Shared by @stacksjs/socials (which builds the
|
|
274
|
+
// redirect) and @stacksjs/browser (which consumes it), so the storage format
|
|
275
|
+
// is never re-derived by an application.
|
|
276
|
+
export {
|
|
277
|
+
buildSessionHandoffUrl,
|
|
278
|
+
decodeSessionHandoff,
|
|
279
|
+
encodeSessionHandoff,
|
|
280
|
+
readSessionHandoff,
|
|
281
|
+
SESSION_HANDOFF_KEY,
|
|
282
|
+
stripSessionHandoff,
|
|
283
|
+
type SessionHandoffPack,
|
|
284
|
+
} from './session-handoff';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{defaultDocument,defaultNavigator,defaultWindow,isRef,noop,toValue,unref}from"./_shared";export{getSSRHandler,setSSRHandler,customStorageEventName}from"./ssrHandlers";export{useStorage}from"./useStorage";export{useLocalStorage}from"./useLocalStorage";export{useSessionStorage}from"./useSessionStorage";export{useDark,usePreferredDark}from"./useDark";export{useColorMode}from"./useColorMode";export{usePreferredColorScheme}from"./usePreferredColorScheme";export{usePreferredContrast}from"./usePreferredContrast";export{usePreferredReducedMotion}from"./usePreferredReducedMotion";export{useOnline}from"./useOnline";export{useNetwork}from"./useNetwork";export{useToggle}from"./useToggle";export{useFetch}from"./useFetch";export{createFetch}from"./createFetch";export{createQueryClient,queryClient,useMutation,useQuery}from"./useQuery";export{useForm}from"./useForm";export{useDateFormat}from"./useDateFormat";export{useNow}from"./useNow";export{useTimestamp}from"./useTimestamp";export{useTimeAgo}from"./useTimeAgo";export{useEventListener}from"./useEventListener";export{useEventBus}from"./useEventBus";export{createEventHook}from"./createEventHook";export{useDebounceFn}from"./useDebounceFn";export{useThrottleFn}from"./useThrottleFn";export{useDebouncedRef}from"./useDebouncedRef";export{useThrottledRef}from"./useThrottledRef";export{useDebounce}from"./useDebounce";export{useThrottle}from"./useThrottle";export{useInterval}from"./useInterval";export{useIntervalFn}from"./useIntervalFn";export{useTimeout}from"./useTimeout";export{useTimeoutFn}from"./useTimeoutFn";export{useTimeoutPoll}from"./useTimeoutPoll";export{useRafFn}from"./useRafFn";export{useFps}from"./useFps";export{useClipboard}from"./useClipboard";export{useClipboardItems}from"./useClipboardItems";export{useMediaQuery}from"./useMediaQuery";export{breakpointsAntDesign,breakpointsBootstrap,breakpointsBootstrapV5,breakpointsMasterCss,breakpointsQuasar,breakpointsSematic,breakpointsTailwind,breakpointsMaterialDesign,useBreakpoints}from"./useBreakpoints";export{useTitle}from"./useTitle";export{useFavicon}from"./useFavicon";export{useDocumentVisibility}from"./useDocumentVisibility";export{useTextDirection}from"./useTextDirection";export{useTextSelection}from"./useTextSelection";export{useUrlSearchParams}from"./useUrlSearchParams";export{useBrowserLocation}from"./useBrowserLocation";export{useWindowSize}from"./useWindowSize";export{useWindowFocus}from"./useWindowFocus";export{useWindowScroll}from"./useWindowScroll";export{useScroll}from"./useScroll";export{useScrollLock}from"./useScrollLock";export{useInfiniteScroll}from"./useInfiniteScroll";export{useFullscreen}from"./useFullscreen";export{onClickOutside}from"./onClickOutside";export{onKeyStroke,onKeyDown,onKeyUp}from"./onKeyStroke";export{onLongPress}from"./onLongPress";export{onStartTyping}from"./onStartTyping";export{useKeyModifier}from"./useKeyModifier";export{useMagicKeys}from"./useMagicKeys";export{and,logicNot,logicOr,or,useAbs,useAverage,useCeil,useClamp,useFloor,useMax,useMin,usePrecision,useRound,useSum,useTrunc}from"./useMath";export{useCounter}from"./useCounter";export{usePrevious}from"./usePrevious";export{useLastChanged}from"./useLastChanged";export{useStepper}from"./useStepper";export{useCycleList}from"./useCycleList";export{useSorted}from"./useSorted";export{useCloned}from"./useCloned";export{useManualRefHistory}from"./useManualRefHistory";export{useRefHistory}from"./useRefHistory";export{useDebouncedRefHistory}from"./useDebouncedRefHistory";export{useThrottledRefHistory}from"./useThrottledRefHistory";export{useAsyncState}from"./useAsyncState";export{useAsyncQueue}from"./useAsyncQueue";export{whenever}from"./whenever";export{watchOnce}from"./watchOnce";export{watchDebounced}from"./watchDebounced";export{watchThrottled}from"./watchThrottled";export{watchPausable,pausableWatch}from"./watchPausable";export{watchIgnorable,ignorableWatch}from"./watchIgnorable";export{watchArray}from"./watchArray";export{watchAtMost}from"./watchAtMost";export{watchDeep}from"./watchDeep";export{watchImmediate}from"./watchImmediate";export{watchTriggerable}from"./watchTriggerable";export{watchWithFilter}from"./watchWithFilter";export{useWebSocket}from"./useWebSocket";export{useEventSource}from"./useEventSource";export{useBroadcastChannel}from"./useBroadcastChannel";export{computedAsync}from"./computedAsync";export{computedEager}from"./computedEager";export{useIntersectionObserver}from"./useIntersectionObserver";export{useResizeObserver}from"./useResizeObserver";export{useMutationObserver}from"./useMutationObserver";export{useElementSize}from"./useElementSize";export{useElementBounding}from"./useElementBounding";export{useElementVisibility}from"./useElementVisibility";export{useElementHover}from"./useElementHover";export{useElementByPoint}from"./useElementByPoint";export{useCssVar}from"./useCssVar";export{unrefElement}from"./unrefElement";export{useMouse}from"./useMouse";export{useMouseInElement}from"./useMouseInElement";export{useMousePressed}from"./useMousePressed";export{usePointer}from"./usePointer";export{useSwipe}from"./useSwipe";export{usePointerSwipe}from"./usePointerSwipe";export{usePointerLock}from"./usePointerLock";export{useParallax}from"./useParallax";export{useGeolocation}from"./useGeolocation";export{useDeviceMotion}from"./useDeviceMotion";export{useDeviceOrientation}from"./useDeviceOrientation";export{useDevicePixelRatio}from"./useDevicePixelRatio";export{useBattery}from"./useBattery";export{useFocus}from"./useFocus";export{useFocusWithin}from"./useFocusWithin";export{useActiveElement}from"./useActiveElement";export{useIdle}from"./useIdle";export{usePageLeave}from"./usePageLeave";export{useMounted}from"./useMounted";export{useDraggable}from"./useDraggable";export{useDropZone}from"./useDropZone";export{useNavigatorLanguage}from"./useNavigatorLanguage";export{usePreferredLanguages}from"./usePreferredLanguages";export{useScreenOrientation}from"./useScreenOrientation";export{useScreenSafeArea}from"./useScreenSafeArea";export{useParentElement}from"./useParentElement";export{usePermission}from"./usePermission";export{useShare}from"./useShare";export{useObjectUrl}from"./useObjectUrl";export{useImage}from"./useImage";export{useBase64}from"./useBase64";export{useAnimate}from"./useAnimate";export{useTransition,executeTransition,TransitionPresets}from"./useTransition";export{useScriptTag}from"./useScriptTag";export{useStyleTag}from"./useStyleTag";export{useConfirmDialog}from"./useConfirmDialog";export{useFileDialog}from"./useFileDialog";export{useEyeDropper}from"./useEyeDropper";export{useTextareaAutosize}from"./useTextareaAutosize";export{useWebNotification}from"./useWebNotification";export{useVibrate}from"./useVibrate";export{useWakeLock}from"./useWakeLock";export{useWebWorker,useWebWorkerFn}from"./useWebWorker";export{useVirtualList}from"./useVirtualList";export{useOffsetPagination}from"./useOffsetPagination";export{isDefined}from"./isDefined";export{useSupported}from"./useSupported";export{useToNumber}from"./useToNumber";export{useToString}from"./useToString";export{refDefault}from"./refDefault";export{refAutoReset,autoResetRef}from"./refAutoReset";export{cloneFnJSON}from"./cloneFnJSON";export{formatTimeAgo}from"./formatTimeAgo";export{until}from"./until";export{resolveRef}from"./resolveRef";export{extendRef}from"./extendRef";export{useMemoize}from"./useMemoize";export{makeDestructurable}from"./makeDestructurable";export{syncRef,syncRefs}from"./syncRef";export{createGlobalState}from"./createGlobalState";export{createSharedComposable}from"./createSharedComposable";export{tryOnMounted,tryOnBeforeMount,tryOnUnmounted,tryOnBeforeUnmount,tryOnScopeDispose}from"./tryOnMounted";export{useArrayDifference,useArrayEvery,useArrayFilter,useArrayFind,useArrayFindIndex,useArrayIncludes,useArrayMap,useArrayReduce,useArraySome,useArrayUnique}from"./useArrayUtils";export{computedAsync as asyncComputed}from"./computedAsync";export{computedEager as eagerComputed}from"./computedEager";export{useDebouncedRef as debouncedRef}from"./useDebouncedRef";export{useDebouncedRef as refDebounced}from"./useDebouncedRef";export{useThrottledRef as throttledRef}from"./useThrottledRef";export{useThrottledRef as refThrottled}from"./useThrottledRef";export{watchDebounced as debouncedWatch}from"./watchDebounced";export{watchThrottled as throttledWatch}from"./watchThrottled";
|
|
1
|
+
export{defaultDocument,defaultNavigator,defaultWindow,isRef,noop,toValue,unref}from"./_shared";export{getSSRHandler,setSSRHandler,customStorageEventName}from"./ssrHandlers";export{useStorage}from"./useStorage";export{useLocalStorage}from"./useLocalStorage";export{useSessionStorage}from"./useSessionStorage";export{useDark,usePreferredDark}from"./useDark";export{useColorMode}from"./useColorMode";export{usePreferredColorScheme}from"./usePreferredColorScheme";export{usePreferredContrast}from"./usePreferredContrast";export{usePreferredReducedMotion}from"./usePreferredReducedMotion";export{useOnline}from"./useOnline";export{useNetwork}from"./useNetwork";export{useToggle}from"./useToggle";export{useFetch}from"./useFetch";export{createFetch}from"./createFetch";export{createQueryClient,queryClient,useMutation,useQuery}from"./useQuery";export{useForm}from"./useForm";export{useDateFormat}from"./useDateFormat";export{useNow}from"./useNow";export{useTimestamp}from"./useTimestamp";export{useTimeAgo}from"./useTimeAgo";export{useEventListener}from"./useEventListener";export{useEventBus}from"./useEventBus";export{createEventHook}from"./createEventHook";export{useDebounceFn}from"./useDebounceFn";export{useThrottleFn}from"./useThrottleFn";export{useDebouncedRef}from"./useDebouncedRef";export{useThrottledRef}from"./useThrottledRef";export{useDebounce}from"./useDebounce";export{useThrottle}from"./useThrottle";export{useInterval}from"./useInterval";export{useIntervalFn}from"./useIntervalFn";export{useTimeout}from"./useTimeout";export{useTimeoutFn}from"./useTimeoutFn";export{useTimeoutPoll}from"./useTimeoutPoll";export{useRafFn}from"./useRafFn";export{useFps}from"./useFps";export{useClipboard}from"./useClipboard";export{useClipboardItems}from"./useClipboardItems";export{useMediaQuery}from"./useMediaQuery";export{breakpointsAntDesign,breakpointsBootstrap,breakpointsBootstrapV5,breakpointsMasterCss,breakpointsQuasar,breakpointsSematic,breakpointsTailwind,breakpointsMaterialDesign,useBreakpoints}from"./useBreakpoints";export{useTitle}from"./useTitle";export{useFavicon}from"./useFavicon";export{useDocumentVisibility}from"./useDocumentVisibility";export{useTextDirection}from"./useTextDirection";export{useTextSelection}from"./useTextSelection";export{useUrlSearchParams}from"./useUrlSearchParams";export{useBrowserLocation}from"./useBrowserLocation";export{useWindowSize}from"./useWindowSize";export{useWindowFocus}from"./useWindowFocus";export{useWindowScroll}from"./useWindowScroll";export{useScroll}from"./useScroll";export{useScrollLock}from"./useScrollLock";export{useInfiniteScroll}from"./useInfiniteScroll";export{useFullscreen}from"./useFullscreen";export{onClickOutside}from"./onClickOutside";export{onKeyStroke,onKeyDown,onKeyUp}from"./onKeyStroke";export{onLongPress}from"./onLongPress";export{onStartTyping}from"./onStartTyping";export{useKeyModifier}from"./useKeyModifier";export{useMagicKeys}from"./useMagicKeys";export{and,logicNot,logicOr,or,useAbs,useAverage,useCeil,useClamp,useFloor,useMax,useMin,usePrecision,useRound,useSum,useTrunc}from"./useMath";export{useCounter}from"./useCounter";export{usePrevious}from"./usePrevious";export{useLastChanged}from"./useLastChanged";export{useStepper}from"./useStepper";export{useCycleList}from"./useCycleList";export{useSorted}from"./useSorted";export{useCloned}from"./useCloned";export{useManualRefHistory}from"./useManualRefHistory";export{useRefHistory}from"./useRefHistory";export{useDebouncedRefHistory}from"./useDebouncedRefHistory";export{useThrottledRefHistory}from"./useThrottledRefHistory";export{useAsyncState}from"./useAsyncState";export{useAsyncQueue}from"./useAsyncQueue";export{whenever}from"./whenever";export{watchOnce}from"./watchOnce";export{watchDebounced}from"./watchDebounced";export{watchThrottled}from"./watchThrottled";export{watchPausable,pausableWatch}from"./watchPausable";export{watchIgnorable,ignorableWatch}from"./watchIgnorable";export{watchArray}from"./watchArray";export{watchAtMost}from"./watchAtMost";export{watchDeep}from"./watchDeep";export{watchImmediate}from"./watchImmediate";export{watchTriggerable}from"./watchTriggerable";export{watchWithFilter}from"./watchWithFilter";export{useWebSocket}from"./useWebSocket";export{useEventSource}from"./useEventSource";export{useBroadcastChannel}from"./useBroadcastChannel";export{computedAsync}from"./computedAsync";export{computedEager}from"./computedEager";export{useIntersectionObserver}from"./useIntersectionObserver";export{useResizeObserver}from"./useResizeObserver";export{useMutationObserver}from"./useMutationObserver";export{useElementSize}from"./useElementSize";export{useElementBounding}from"./useElementBounding";export{useElementVisibility}from"./useElementVisibility";export{useElementHover}from"./useElementHover";export{useElementByPoint}from"./useElementByPoint";export{useCssVar}from"./useCssVar";export{unrefElement}from"./unrefElement";export{useMouse}from"./useMouse";export{useMouseInElement}from"./useMouseInElement";export{useMousePressed}from"./useMousePressed";export{usePointer}from"./usePointer";export{useSwipe}from"./useSwipe";export{usePointerSwipe}from"./usePointerSwipe";export{usePointerLock}from"./usePointerLock";export{useParallax}from"./useParallax";export{useGeolocation}from"./useGeolocation";export{useDeviceMotion}from"./useDeviceMotion";export{useDeviceOrientation}from"./useDeviceOrientation";export{useDevicePixelRatio}from"./useDevicePixelRatio";export{useBattery}from"./useBattery";export{useFocus}from"./useFocus";export{useFocusWithin}from"./useFocusWithin";export{useActiveElement}from"./useActiveElement";export{useIdle}from"./useIdle";export{usePageLeave}from"./usePageLeave";export{useMounted}from"./useMounted";export{useDraggable}from"./useDraggable";export{useDropZone}from"./useDropZone";export{useNavigatorLanguage}from"./useNavigatorLanguage";export{usePreferredLanguages}from"./usePreferredLanguages";export{useScreenOrientation}from"./useScreenOrientation";export{useScreenSafeArea}from"./useScreenSafeArea";export{useParentElement}from"./useParentElement";export{usePermission}from"./usePermission";export{useShare}from"./useShare";export{useObjectUrl}from"./useObjectUrl";export{useImage}from"./useImage";export{useBase64}from"./useBase64";export{useAnimate}from"./useAnimate";export{useTransition,executeTransition,TransitionPresets}from"./useTransition";export{useScriptTag}from"./useScriptTag";export{useStyleTag}from"./useStyleTag";export{useConfirmDialog}from"./useConfirmDialog";export{useFileDialog}from"./useFileDialog";export{useEyeDropper}from"./useEyeDropper";export{useTextareaAutosize}from"./useTextareaAutosize";export{useWebNotification}from"./useWebNotification";export{useVibrate}from"./useVibrate";export{useWakeLock}from"./useWakeLock";export{useWebWorker,useWebWorkerFn}from"./useWebWorker";export{useVirtualList}from"./useVirtualList";export{useOffsetPagination}from"./useOffsetPagination";export{isDefined}from"./isDefined";export{useSupported}from"./useSupported";export{useToNumber}from"./useToNumber";export{useToString}from"./useToString";export{refDefault}from"./refDefault";export{refAutoReset,autoResetRef}from"./refAutoReset";export{cloneFnJSON}from"./cloneFnJSON";export{formatTimeAgo}from"./formatTimeAgo";export{until}from"./until";export{resolveRef}from"./resolveRef";export{extendRef}from"./extendRef";export{useMemoize}from"./useMemoize";export{makeDestructurable}from"./makeDestructurable";export{syncRef,syncRefs}from"./syncRef";export{createGlobalState}from"./createGlobalState";export{createSharedComposable}from"./createSharedComposable";export{tryOnMounted,tryOnBeforeMount,tryOnUnmounted,tryOnBeforeUnmount,tryOnScopeDispose}from"./tryOnMounted";export{useArrayDifference,useArrayEvery,useArrayFilter,useArrayFind,useArrayFindIndex,useArrayIncludes,useArrayMap,useArrayReduce,useArraySome,useArrayUnique}from"./useArrayUtils";export{computedAsync as asyncComputed}from"./computedAsync";export{computedEager as eagerComputed}from"./computedEager";export{useDebouncedRef as debouncedRef}from"./useDebouncedRef";export{useDebouncedRef as refDebounced}from"./useDebouncedRef";export{useThrottledRef as throttledRef}from"./useThrottledRef";export{useThrottledRef as refThrottled}from"./useThrottledRef";export{watchDebounced as debouncedWatch}from"./watchDebounced";export{watchThrottled as throttledWatch}from"./watchThrottled";export{buildSessionHandoffUrl,decodeSessionHandoff,encodeSessionHandoff,readSessionHandoff,SESSION_HANDOFF_KEY,stripSessionHandoff}from"./session-handoff";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Encode a token pack for the fragment. */
|
|
2
|
+
export declare function encodeSessionHandoff(pack: SessionHandoffPack): string;
|
|
3
|
+
/**
|
|
4
|
+
* Decode a fragment payload.
|
|
5
|
+
*
|
|
6
|
+
* Returns null rather than throwing for anything malformed. This runs on a
|
|
7
|
+
* value an attacker can put in a URL, and a thrown error on page load would
|
|
8
|
+
* be a denial of service on the destination page.
|
|
9
|
+
*/
|
|
10
|
+
export declare function decodeSessionHandoff(value: string | null | undefined): SessionHandoffPack | null;
|
|
11
|
+
/**
|
|
12
|
+
* Append the handoff to a redirect target.
|
|
13
|
+
*
|
|
14
|
+
* Any fragment already on `redirectTo` is preserved ahead of the handoff, so
|
|
15
|
+
* `/account#billing` still lands on the billing section.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSessionHandoffUrl(redirectTo: string, pack: SessionHandoffPack): string;
|
|
18
|
+
/** Pull the handoff out of a `location.hash`-shaped string. */
|
|
19
|
+
export declare function readSessionHandoff(hash: string | null | undefined): SessionHandoffPack | null;
|
|
20
|
+
/**
|
|
21
|
+
* The same hash with the handoff removed, ready for `history.replaceState`.
|
|
22
|
+
*
|
|
23
|
+
* Returns '' when nothing else was in it, so the caller can drop the `#`
|
|
24
|
+
* entirely rather than leaving a bare one in the address bar.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripSessionHandoff(hash: string | null | undefined): string;
|
|
27
|
+
/**
|
|
28
|
+
* Moving a server-minted session into the browser (stacksjs/stacks#2236).
|
|
29
|
+
*
|
|
30
|
+
* `@stacksjs/socials` covers the OAuth exchange and `@stacksjs/auth` covers
|
|
31
|
+
* `loginUsingId()` server-side. Nothing bridged the two for a browser, so an
|
|
32
|
+
* app finishing a redirect flow had to hand-serialize a token pack into the
|
|
33
|
+
* framework's own storage keys — from a server action, inside an HTML
|
|
34
|
+
* response:
|
|
35
|
+
*
|
|
36
|
+
* localStorage.setItem('token', JSON.stringify(JSON.stringify(token)))
|
|
37
|
+
*
|
|
38
|
+
* That double stringify is not a typo: the session persists through
|
|
39
|
+
* `useStorage`, which JSON-stringifies on write, so the string that belongs IN
|
|
40
|
+
* localStorage under `token` is `"abc"` — quotes included. One app got it
|
|
41
|
+
* wrong for `user` and stored the literal `[object Object]`, so every social
|
|
42
|
+
* sign-in produced a broken session. The same inline script also needed
|
|
43
|
+
* hand-written escaping, because a display name containing a closing script
|
|
44
|
+
* tag would terminate the block early.
|
|
45
|
+
*
|
|
46
|
+
* None of that is application logic. This module is the format, owned once.
|
|
47
|
+
*
|
|
48
|
+
* The pack travels in the URL **fragment**, which is never sent to a server:
|
|
49
|
+
* it stays out of access logs, out of `Referer`, and out of any proxy in
|
|
50
|
+
* between — all of which an HTML body carrying the same tokens was exposed to.
|
|
51
|
+
* It does land in browser history, so the client strips it the moment it is
|
|
52
|
+
* read. A single-use code exchanged over POST would keep the tokens out of the
|
|
53
|
+
* URL entirely and is the stronger design; it needs server-side state with a
|
|
54
|
+
* short TTL, which this deliberately does not.
|
|
55
|
+
*/
|
|
56
|
+
/** The fragment key the handoff travels under. */
|
|
57
|
+
export declare const SESSION_HANDOFF_KEY: 'stx_auth';
|
|
58
|
+
export declare interface SessionHandoffPack {
|
|
59
|
+
token: string
|
|
60
|
+
refreshToken?: string
|
|
61
|
+
user?: unknown
|
|
62
|
+
expiresIn?: number
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SESSION_HANDOFF_KEY="stx_auth";function toBase64Url(input){const bytes=new TextEncoder().encode(input);let binary="";for(const byte of bytes)binary+=String.fromCharCode(byte);return btoa(binary).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function fromBase64Url(input){const padded=input.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-input.length%4)%4),binary=atob(padded),bytes=new Uint8Array(binary.length);for(let i=0;i<binary.length;i++)bytes[i]=binary.charCodeAt(i);return new TextDecoder().decode(bytes)}export function encodeSessionHandoff(pack){return toBase64Url(JSON.stringify({token:pack.token,refresh_token:pack.refreshToken,user:pack.user,expires_in:pack.expiresIn}))}export function decodeSessionHandoff(value){if(!value)return null;try{const parsed=JSON.parse(fromBase64Url(value)),token=parsed.token??parsed.access_token;if(typeof token!=="string"||token.length===0)return null;return{token,refreshToken:typeof parsed.refresh_token==="string"?parsed.refresh_token:void 0,user:parsed.user,expiresIn:typeof parsed.expires_in==="number"?parsed.expires_in:void 0}}catch{return null}}export function buildSessionHandoffUrl(redirectTo,pack){const encoded=encodeSessionHandoff(pack),[base,existingHash]=splitHash(redirectTo),prefix=existingHash?`${existingHash}&`:"";return`${base}#${prefix}${SESSION_HANDOFF_KEY}=${encoded}`}export function readSessionHandoff(hash){if(!hash)return null;const params=new URLSearchParams(hash.startsWith("#")?hash.slice(1):hash);return decodeSessionHandoff(params.get(SESSION_HANDOFF_KEY))}export function stripSessionHandoff(hash){if(!hash)return"";const params=new URLSearchParams(hash.startsWith("#")?hash.slice(1):hash);params.delete(SESSION_HANDOFF_KEY);const rest=params.toString();return rest?`#${rest}`:""}function splitHash(url){const at=url.indexOf("#");return at===-1?[url,""]:[url.slice(0,at),url.slice(at+1)]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/composables",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.297",
|
|
6
6
|
"description": "Stacks composables powered by stx reactivity.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@stacksjs/stx": "^0.2.148",
|
|
55
|
-
"@stacksjs/datetime": "0.70.
|
|
55
|
+
"@stacksjs/datetime": "0.70.297"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"better-dx": "^0.2.17"
|