Skip to content

Commit 2b226ea

Browse files
committed
SSR support
1 parent 1c2638a commit 2b226ea

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,5 @@ $RECYCLE.BIN/
343343
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,vim,emacs,windows,macos,node
344344
.yalc
345345
yalc.lock
346+
packages/node/pnpm-workspace.yaml
347+
packages/node/pnpm-lock.yaml

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"user"
1313
],
1414
"dependencies": {
15-
"@propelauth/node-apis": "^2.1.34",
15+
"@propelauth/node-apis": "link:../../../node-apis",
1616
"jose": "^5.2.0"
1717
},
1818
"devDependencies": {

packages/node/src/auth.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
TokenVerificationMetadataWithPublicKey,
1818
} from "./tokenVerificationMetadata"
1919
import { validateAuthUrl } from "./validators"
20+
import { createRouteHandler } from "./routeHandlers"
2021

2122
export type BaseAuthOptions = {
2223
authUrl: string
@@ -71,6 +72,9 @@ export function initBaseAuth(opts: BaseAuthOptions) {
7172
const validateAccessTokenAndGetUserWithOrgInfoWithAllPermissions =
7273
wrapValidateAccessTokenAndGetUserWithOrgInfoWithAllPermissions(tokenVerificationMetadataWithPublicKeyPromise)
7374

75+
const authUrlOrigin = `${authUrl.protocol}//${authUrl.host}`
76+
const { handleAuthRequest } = createRouteHandler(authUrlOrigin, integrationApiKey, validateAccessTokenAndGetUser, validateAccessTokenAndGetUserClass)
77+
7478
// Note: We exclude fetchTokenVerificationMetadata from the returned object
7579
// because we have explicit usage of it above. Thus, it is not used in the returned object.
7680
const { fetchTokenVerificationMetadata, ...nodeApis } = apis
@@ -84,6 +88,8 @@ export function initBaseAuth(opts: BaseAuthOptions) {
8488
validateAccessTokenAndGetUserWithOrgInfoWithExactRole,
8589
validateAccessTokenAndGetUserWithOrgInfoWithPermission,
8690
validateAccessTokenAndGetUserWithOrgInfoWithAllPermissions,
91+
// route handler
92+
handleAuthRequest,
8793
...nodeApis,
8894
}
8995
}

packages/node/src/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export {
1616
MagicLinkCreationException,
1717
MigrateUserException,
1818
MigrateUserPasswordException,
19-
OrgMemberInfo,
19+
OrgMemberInfo,
20+
Organization,
2021
RateLimitedException,
2122
RemoveUserFromOrgException,
2223
toOrgIdToOrgMemberInfo,
@@ -35,9 +36,10 @@ export {
3536
IncorrectMfaCodeException,
3637
RevokePendingOrgInviteException,
3738
ApiKeyImportException,
39+
OrgRoleStructure
3840
} from "@propelauth/node-apis"
3941
export type {
40-
AccessToken,
42+
AccessToken,
4143
AddUserToOrgRequest,
4244
ApiKeyFull,
4345
ApiKeyNew,
@@ -120,3 +122,12 @@ export {
120122
initBaseAuth,
121123
RequiredOrgInfo as RequriedOrgInfo,
122124
} from "./auth"
125+
export {
126+
ACCESS_TOKEN_COOKIE_NAME,
127+
REFRESH_TOKEN_COOKIE_NAME,
128+
ACTIVE_ORG_ID_COOKIE_NAME,
129+
RETURN_TO_PATH_COOKIE_NAME,
130+
STATE_COOKIE_NAME,
131+
} from "./routeHandlers"
132+
export { createRouteHandler, getAccessTokenFromCookies } from "./routeHandlers"
133+
export type { AuthRequestParams, AuthResponse } from "./routeHandlers"

0 commit comments

Comments
 (0)