Skip to content

Commit

Permalink
feat: export jwt types
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed Apr 22, 2024
1 parent c204e59 commit 65e8ec7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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

0 comments on commit 65e8ec7

Please sign in to comment.