Skip to content

Commit

Permalink
Use proper format values, and pass in body instead of query parmeter
Browse files Browse the repository at this point in the history
  • Loading branch information
BRKalow committed Jan 13, 2025
1 parent 2e9888f commit 9bd2134
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/backend/src/api/endpoints/SessionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type RefreshTokenParams = {
request_originating_ip?: string;
request_headers?: Record<string, string[]>;
suffixed_cookies?: boolean;
format?: 'token' | 'cookies';
format?: 'token' | 'cookie';
};

export class SessionAPI extends AbstractAPI {
Expand Down Expand Up @@ -68,16 +68,16 @@ export class SessionAPI extends AbstractAPI {
}

public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'token ' }): Promise<Token>;
public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'cookies' }): Promise<Cookies>;
public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'cookie' }): Promise<Cookies>;
public async refreshSession(sessionId: string, params: RefreshTokenParams): Promise<Token>;
public async refreshSession(sessionId: string, params: RefreshTokenParams): Promise<Token | Cookies> {
this.requireId(sessionId);
const { format = 'token', suffixed_cookies, ...restParams } = params;
const { suffixed_cookies, ...restParams } = params;
return this.request({
method: 'POST',
path: joinPaths(basePath, sessionId, 'refresh'),
bodyParams: restParams,
queryParams: { format, suffixed_cookies },
queryParams: { suffixed_cookies },
});
}
}
3 changes: 3 additions & 0 deletions packages/backend/src/api/resources/Deserializer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AllowlistIdentifier,
Client,
Cookies,
DeletedObject,
Email,
EmailAddress,
Expand Down Expand Up @@ -72,6 +73,8 @@ function jsonToObject(item: any): any {
return AllowlistIdentifier.fromJSON(item);
case ObjectType.Client:
return Client.fromJSON(item);
case ObjectType.Cookies:
return Cookies.fromJSON(item);
case ObjectType.EmailAddress:
return EmailAddress.fromJSON(item);
case ObjectType.Email:
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/api/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './AccountlessApplication';
export * from './AllowlistIdentifier';
export * from './Client';
export * from './Cookies';
export * from './DeletedObject';
export * from './Email';
export * from './EmailAddress';
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/tokens/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ ${error.getFullMessage()}`,
try {
// Perform the actual token refresh.
const response = await options.apiClient.sessions.refreshSession(decodeResult.payload.sid, {
format: 'cookies',
format: 'cookie',
suffixed_cookies: authenticateContext.usesSuffixedCookies(),
expired_token: expiredSessionToken || '',
refresh_token: refreshToken || '',
Expand Down

0 comments on commit 9bd2134

Please sign in to comment.