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

Export JWT types #79

Merged
merged 1 commit into from
Apr 22, 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: 6 additions & 1 deletion packages/js-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export {
jwtIsIntegration,
jwtIsSalesChannel,
jwtIsUser,
jwtIsWebApp
jwtIsWebApp,
type JWTDashboard,
type JWTIntegration,
type JWTSalesChannel,
type JWTUser,
type JWTWebApp
} from './jwtDecode.js'

export { createAssertion } from './jwtEncode.js'
Expand Down
10 changes: 5 additions & 5 deletions packages/js-auth/src/jwtDecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface JWTBase {
iss: string
}

type JWTUser = JWTBase & {
export type JWTUser = JWTBase & {
/** The type of credentials you're using to authenticate to the APIs. */
application: {
kind: 'user'
Expand All @@ -65,7 +65,7 @@ type JWTUser = JWTBase & {
}
}

type JWTDashboard = JWTBase & {
export type JWTDashboard = JWTBase & {
/** The type of credentials you're using to authenticate to the APIs. */
application: {
kind: 'dashboard'
Expand Down Expand Up @@ -107,7 +107,7 @@ type JWTOrganizationBase = JWTBase & {
}
}

type JWTWebApp = SetRequired<JWTOrganizationBase, 'owner'> & {
export type JWTWebApp = SetRequired<JWTOrganizationBase, 'owner'> & {
/** The type of credentials you're using to authenticate to the APIs. */
application: {
kind: 'webapp'
Expand All @@ -117,14 +117,14 @@ type JWTWebApp = SetRequired<JWTOrganizationBase, 'owner'> & {
/** Create a type that makes the given keys required. The remaining keys are kept as is. */
type SetRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }

type JWTSalesChannel = JWTOrganizationBase & {
export type JWTSalesChannel = JWTOrganizationBase & {
/** The type of credentials you're using to authenticate to the APIs. */
application: {
kind: 'sales_channel'
}
}

type JWTIntegration = JWTOrganizationBase & {
export type JWTIntegration = JWTOrganizationBase & {
/** The type of credentials you're using to authenticate to the APIs. */
application: {
kind: 'integration'
Expand Down