This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dressly: add parse cookies and jwt decoded
- Loading branch information
1 parent
501efa3
commit cd3c98a
Showing
9 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PUBLIC_CF_ACCESS=khafidprayoga.cloudflareaccess.com |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
<script> | ||
import { search, cart, account, menu } from '@icons/index'; | ||
<script lang="ts"> | ||
import { search, cart, account, } from '@icons/index'; | ||
import { userData } from '@store/auth'; | ||
$: userName = $userData.email; | ||
</script> | ||
|
||
<div class="flex items-center space-x-4"> | ||
<button | ||
class="hidden md:block text-gray-700 hover:text-gray-900 hover:bg-gray-100 px-3 py-2 rounded-md" | ||
aria-label="Search" | ||
> | ||
<img src={search} alt="Search" class="h-6 w-6" /> | ||
</button> | ||
<button class="text-gray-700 hover:text-gray-900 hover:bg-gray-200 px-3 py-2 rounded-md" aria-label="Shopping cart"> | ||
<button | ||
class="text-gray-700 hover:text-gray-900 hover:bg-gray-200 px-3 py-2 rounded-md" | ||
aria-label="Shopping cart" | ||
> | ||
<img src={cart} alt="Shopping cart" class="h-6 w-6" /> | ||
</button> | ||
<button | ||
class="hidden md:block text-gray-700 hover:text-gray-900 hover:bg-gray-200 px-3 py-2 rounded-md" | ||
aria-label="User account" | ||
> | ||
<img src={account} alt="User Account Login" class="w-6 h-6" /> | ||
<img src={account} alt="User Account " class="w-6 h-6" /> | ||
</button> | ||
{#if userName} | ||
<span class="hidden sm:inline-block font-thin font-OpenSans" | ||
>{userName}</span | ||
> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export interface SessionData { | ||
id: number | ||
name: string | ||
email: string | ||
groups: any[] | ||
idp: Idp | ||
geo: Geo | ||
user_uuid: string | ||
account_id: string | ||
iat: number | ||
ip: string | ||
auth_status: string | ||
common_name: string | ||
service_token_id: string | ||
service_token_status: boolean | ||
is_warp: boolean | ||
is_gateway: boolean | ||
version: number | ||
} | ||
|
||
export interface Idp { | ||
id: string | ||
type: string | ||
} | ||
|
||
export interface Geo { | ||
country: string | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Cookies from "js-cookie"; | ||
import { jwtDecode } from 'jwt-decode'; | ||
|
||
import { writable } from 'svelte/store'; | ||
let defaultUserData = {} as JWTPayload; | ||
export const userData = writable(defaultUserData); | ||
export function getAuthorizationToken() { | ||
let jwt = Cookies.get("CF_Authorization") || null; | ||
if (!jwt) { | ||
return null; | ||
} | ||
|
||
const decoded: JWTPayload = jwtDecode(jwt, ); | ||
|
||
return decoded | ||
} | ||
|
||
|
||
export interface JWTPayload { | ||
aud: string[] | ||
email: string | ||
exp: number | ||
iat: number | ||
nbf: number | ||
iss: string | ||
type: string | ||
identity_nonce: string | ||
sub: string | ||
pathCookie: boolean | ||
pathText: string | ||
country: string | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters