Skip to content

Commit f742023

Browse files
committed
Expose token and session types
1 parent 57d1e67 commit f742023

File tree

3 files changed

+37
-38
lines changed

3 files changed

+37
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- [2025-04-15] [Expose token and session types](https://github.com/RubricLab/auth/commit/e898a1f64f1ea77bdd02ce89ff027c2f7593d89f)
12
- [2025-04-07] [verbose utils, bump](https://github.com/RubricLab/auth/commit/fd78ca0bc1824339b2b1a6ffb72eccc5c13d8d1c)
23
- [2025-02-14] [fix build](https://github.com/RubricLab/auth/commit/c54af553ae56c720d886f97e6ee510bbb2ade498)
34
- [2025-02-14] [apiKeyAuthorizationProviders, vercel, brex](https://github.com/RubricLab/auth/commit/498233933eccab4cb147a0b4bd8a01f75ccc2a75)

lib/types.ts

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
11
// export type AuthUrl = `http${'s' | ''}://${string}${'.' | ':'}${string}`
2-
32
export type AuthUrl = string
3+
export type Token = {
4+
accessToken: string
5+
refreshToken: string
6+
expiresAt: Date
7+
}
8+
export type Session = {
9+
key: string
10+
userId: string
11+
expiresAt: Date
12+
user: {
13+
apiKeyAuthorizationAccounts: {
14+
provider: string
15+
accountId: string
16+
apiKey: string
17+
}[]
18+
oAuth2AuthenticationAccounts: {
19+
provider: string
20+
accountId: string
21+
accessToken: string
22+
refreshToken: string
23+
expiresAt: Date
24+
}[]
25+
oAuth2AuthorizationAccounts: {
26+
provider: string
27+
accountId: string
28+
accessToken: string
29+
refreshToken: string
30+
expiresAt: Date
31+
}[]
32+
}
33+
}
434
export type Oauth2AuthenticationProvider = {
535
method: 'oauth2'
636
getAuthenticationUrl: (options: { redirectUri: string; state: string }) => Promise<URL>
7-
getToken: (options: { code: string; redirectUri: string }) => Promise<{
8-
accessToken: string
9-
refreshToken: string
10-
expiresAt: Date
11-
}>
37+
getToken: (options: { code: string; redirectUri: string }) => Promise<Token>
1238
getUser: (options: { accessToken: string }) => Promise<{
1339
accountId: string
1440
email: string
@@ -26,11 +52,7 @@ export type Oauth2AuthorizationProvider = {
2652
redirectUri: string
2753
state: string
2854
}) => Promise<URL>
29-
getToken: (options: { code: string; redirectUri: string }) => Promise<{
30-
accessToken: string
31-
refreshToken: string
32-
expiresAt: Date
33-
}>
55+
getToken: (options: { code: string; redirectUri: string }) => Promise<Token>
3456
getUser: (options: { accessToken: string }) => Promise<{
3557
accountId: string
3658
email: string
@@ -94,32 +116,7 @@ export type DatabaseProvider = {
94116
email: string
95117
expiresAt: Date
96118
}>
97-
getSession: (data: { key: string }) => Promise<{
98-
key: string
99-
userId: string
100-
expiresAt: Date
101-
user: {
102-
apiKeyAuthorizationAccounts: {
103-
provider: string
104-
accountId: string
105-
apiKey: string
106-
}[]
107-
oAuth2AuthenticationAccounts: {
108-
provider: string
109-
accountId: string
110-
accessToken: string
111-
refreshToken: string
112-
expiresAt: Date
113-
}[]
114-
oAuth2AuthorizationAccounts: {
115-
provider: string
116-
accountId: string
117-
accessToken: string
118-
refreshToken: string
119-
expiresAt: Date
120-
}[]
121-
}
122-
} | null>
119+
getSession: (data: { key: string }) => Promise<Session | null>
123120
getOAuth2AuthenticationAccount: (data: {
124121
provider: string
125122
accountId: string

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"lint:fix": "bun x biome check --fix --unsafe . && bun x biome lint --write --unsafe ."
1111
},
1212
"name": "@rubriclab/auth",
13-
"version": "0.0.32",
13+
"version": "0.0.33",
1414
"main": "lib/index.ts",
15+
"types": "lib/types.ts",
1516
"dependencies": {
1617
"@rubriclab/config": "*",
1718
"@rubriclab/package": "*",

0 commit comments

Comments
 (0)