Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'rol' to private claims #271

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/cuddly-terms-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@quiltt/react-native": patch
"@quiltt/react": patch
"@quiltt/core": patch
---

Add 'rol' to private claims
6 changes: 3 additions & 3 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- name: 'Test Next App'
directory: './examples/react-nextjs'
package_manager: 'pnpm'
- name: 'Test Expo App'
directory: './examples/react-native-expo'
package_manager: 'yarn'
# - name: 'Test Expo App'
# directory: './examples/react-native-expo'
# package_manager: 'yarn'

steps:
- name: Checkout branch
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.14.0
v20.15.0
6 changes: 3 additions & 3 deletions examples/react-native-expo/app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"expo": {
"name": "react-native-expo-new",
"slug": "react-native-expo-new",
"name": "react-native-expo",
"slug": "react-native-expo",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
Expand Down Expand Up @@ -29,7 +29,7 @@
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": ["expo-router"],
"plugins": ["expo-router", "expo-font"],
"experiments": {
"typedRoutes": true
}
Expand Down
24 changes: 12 additions & 12 deletions examples/react-native-expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"android": "expo run:android",
"build": "CI=1 expo prebuild --no-install",
"ios": "expo start --ios",
"ios": "expo run:ios",
"jest": "jest --watchAll",
"lint": "expo lint",
"start": "expo start",
Expand All @@ -19,22 +19,22 @@
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "14.0.0",
"@quiltt/react-native": "3.6.9",
"@expo/vector-icons": "^14.0.2",
"@quiltt/react-native": "3.6.10",
"@react-navigation/native": "6.0.2",
"base-64": "1.0.0",
"expo": "~51.0.7",
"expo-constants": "16.0.1",
"expo-font": "12.0.5",
"expo": "~51.0.17",
"expo-constants": "~16.0.2",
"expo-font": "~12.0.7",
"expo-linking": "6.3.1",
"expo-router": "~3.5.14",
"expo-splash-screen": "0.27.4",
"expo-router": "~3.5.17",
"expo-splash-screen": "~0.27.5",
"expo-status-bar": "1.12.1",
"expo-system-ui": "3.0.4",
"expo-system-ui": "~3.0.7",
"expo-web-browser": "13.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.1",
"react-native": "0.74.3",
"react-native-gesture-handler": "2.16.1",
"react-native-reanimated": "3.10.1",
"react-native-safe-area-context": "4.10.1",
Expand All @@ -49,9 +49,9 @@
"@types/react": "~18.2.79",
"@types/react-test-renderer": "18.0.7",
"jest": "^29.4.0",
"jest-expo": "51.0.1",
"jest-expo": "~51.0.3",
"react-test-renderer": "18.2.0",
"typescript": "5.3.3"
"typescript": "~5.3.3"
},
"packageManager": "[email protected]"
}
2,061 changes: 1,077 additions & 984 deletions examples/react-native-expo/yarn.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions examples/react-nextjs/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
rgb(var(--background-start-rgb));
}
8 changes: 4 additions & 4 deletions examples/react-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@biomejs/biome": "1.8.1",
"@types/node": "20.14.5",
"@types/react": "18.2.73",
"@biomejs/biome": "1.8.3",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-dom": "18.2.6",
"autoprefixer": "10.4.14",
"cypress": "12.16.0",
"encoding": "0.1.13",
"postcss": "8.4.31",
"tailwindcss": "3.3.2",
"typescript": "5.4.3"
"typescript": "5.5.3"
},
"publishConfig": {
"access": "restricted"
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"postversion": "pnpm exec pnpm install --filter=./packages/** "
},
"devDependencies": {
"@biomejs/biome": "1.8.1",
"@biomejs/biome": "1.8.3",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.1",
"@changesets/cli": "2.27.7",
"@testing-library/react": "15.0.5",
"@testing-library/react-native": "12.4.5",
"@types/node": "20.14.5",
"@types/node": "20.14.10",
"@vitejs/plugin-react": "4.2.1",
"@vitest/coverage-v8": "1.5.2",
"@vitest/coverage-v8": "1.6.0",
"check-dependency-version-consistency": "4.1.0",
"genversion": "3.2.0",
"happy-dom": "14.7.1",
"turbo": "2.0.4",
"vite": "5.2.10",
"turbo": "2.0.6",
"vite": "5.3.3",
"vite-tsconfig-paths": "4.3.2",
"vitest": "1.5.2",
"vitest": "1.6.0",
"vitest-react-native": "0.1.5"
},
"packageManager": "[email protected]"
Expand Down
32 changes: 11 additions & 21 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
"name": "@quiltt/core",
"version": "3.6.10",
"description": "Javascript API client and utilities for Quiltt",
"keywords": [
"quiltt",
"typescript"
],
"keywords": ["quiltt", "typescript"],
"homepage": "https://github.com/quiltt/quiltt-js/tree/main/packages/core#readme",
"repository": {
"type": "git",
"url": "https://github.com/quiltt/quiltt-js.git",
"directory": "packages/core"
},
"license": "MIT",
"sideEffects": [
"./src/Storage/Local.ts",
"./src/api/graphql/links/SubscriptionLink.ts"
],
"sideEffects": ["./src/Storage/Local.ts", "./src/api/graphql/links/SubscriptionLink.ts"],
"type": "module",
"exports": {
".": {
Expand All @@ -27,11 +21,7 @@
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**",
"src/**",
"CHANGELOG.md"
],
"files": ["dist/**", "src/**", "CHANGELOG.md"],
"scripts": {
"build": "bunchee",
"clean": "rimraf .turbo dist",
Expand All @@ -42,16 +32,16 @@
"dependencies": {
"@apollo/client": "^3.9.9",
"cross-fetch": "^4.0.0",
"graphql": "^16.8.1",
"graphql-ruby-client": "^1.13.3"
"graphql": "^16.9.0",
"graphql-ruby-client": "^1.14.0"
},
"devDependencies": {
"@biomejs/biome": "1.8.1",
"@types/node": "20.14.5",
"@types/react": "18.2.73",
"bunchee": "4.4.8",
"rimraf": "5.0.5",
"typescript": "5.4.3"
"@biomejs/biome": "1.8.3",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"bunchee": "5.2.2",
"rimraf": "6.0.0",
"typescript": "5.5.3"
},
"publishConfig": {
"access": "public"
Expand Down
17 changes: 10 additions & 7 deletions packages/core/src/JsonWebToken.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type { Maybe } from './types'

export type JsonWebToken<T> = {
token: string // Raw JWT Token
claims: Claims<T>
}

export type Claims<T> = RegisteredClaims & T
type AdminRole = 'manager' | 'core' | 'basic'

export type RegisteredClaims = {
iss: string // (issuer): Issuer of the JWT
Expand All @@ -23,6 +18,14 @@ export type PrivateClaims = {
cid: string // Client ID
aid: string // Administrator ID
ver: number // Session Token Version
rol: AdminRole // Administrator Role
}

export type Claims<T> = RegisteredClaims & T

export type JsonWebToken<T> = {
token: string // Raw JWT Token
claims: Claims<T>
}

export type QuilttJWT = JsonWebToken<PrivateClaims>
Expand All @@ -42,7 +45,7 @@ export const JsonWebTokenParse = <T>(
const [_header, payload, _signature] = token.split('.')

try {
return { token: token, claims: JSON.parse(atob(payload)) }
return { token, claims: JSON.parse(atob(payload)) }
} catch (error) {
console.error(`Invalid Session Token: ${error}`)
}
Expand Down
18 changes: 7 additions & 11 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**",
"src/**",
"CHANGELOG.md"
],
"files": ["dist/**", "src/**", "CHANGELOG.md"],
"scripts": {
"addApiKey": "node scripts/addApiKey.js",
"addVersion": "genversion --esm -f src/version.ts",
Expand All @@ -44,15 +40,15 @@
},
"devDependencies": {
"@apollo/client": "3.9.9",
"@biomejs/biome": "1.8.1",
"@biomejs/biome": "1.8.3",
"@types/base-64": "1.0.2",
"@types/node": "20.14.5",
"@types/react": "18.2.73",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-native": "0.72.5",
"bunchee": "4.4.8",
"bunchee": "5.2.2",
"react": "18.2.0",
"rimraf": "5.0.5",
"typescript": "5.4.3"
"rimraf": "6.0.0",
"typescript": "5.5.3"
},
"peerDependencies": {
"base-64": "*",
Expand Down
25 changes: 8 additions & 17 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"name": "@quiltt/react",
"version": "3.6.10",
"description": "React components and hooks for Quiltt Connector",
"keywords": [
"quiltt",
"quiltt-connector",
"react",
"typescript"
],
"keywords": ["quiltt", "quiltt-connector", "react", "typescript"],
"homepage": "https://github.com/quiltt/quiltt-js/tree/main/packages/react#readme",
"repository": {
"type": "git",
Expand All @@ -31,11 +26,7 @@
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**",
"src/**",
"CHANGELOG.md"
],
"files": ["dist/**", "src/**", "CHANGELOG.md"],
"scripts": {
"addVersion": "genversion --esm -f src/version.ts",
"build": "pnpm run addVersion && bunchee",
Expand All @@ -49,15 +40,15 @@
},
"devDependencies": {
"@apollo/client": "3.9.9",
"@biomejs/biome": "1.8.1",
"@types/node": "20.14.5",
"@types/react": "18.2.73",
"@biomejs/biome": "1.8.3",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-dom": "18.2.6",
"bunchee": "4.4.8",
"bunchee": "5.2.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"rimraf": "5.0.5",
"typescript": "5.4.3"
"rimraf": "6.0.0",
"typescript": "5.5.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useQuilttSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useCallback } from 'react'
import { AuthAPI } from '@quiltt/core'
import type { Maybe, QuilttJWT } from '@quiltt/core'

import { useSession } from './useSession'
import {
useAuthenticateSession,
useIdentifySession,
Expand All @@ -14,6 +13,7 @@ import {
} from './session'
import type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession } from './session'
import { useQuilttSettings } from './useQuilttSettings'
import { useSession } from './useSession'

export type UseQuilttSession = (environmentId?: string) => {
session: Maybe<QuilttJWT> | undefined
Expand Down
1 change: 1 addition & 0 deletions packages/react/tests/hooks/useSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('useSession', () => {
exp: Math.floor(Date.now() / 1000) + 3600,
iss: 'issuer',
sub: 'subject',
rol: 'manager',
aud: '',
nbf: 1,
iat: Date.now(),
Expand Down
Loading
Loading