@workos-inc/node
Advanced tools
Comparing version 7.21.0 to 7.22.0
import { AuthenticationResponse } from './authentication-response.interface'; | ||
export interface AuthenticateWithSessionCookieOptions { | ||
sessionData: string; | ||
cookiePassword?: string; | ||
} | ||
export interface AccessToken { | ||
@@ -3,0 +7,0 @@ sid: string; |
@@ -9,2 +9,7 @@ export declare enum RefreshAndSealSessionDataFailureReason { | ||
INVALID_GRANT = "invalid_grant", | ||
MFA_ENROLLMENT = "mfa_enrollment", | ||
SSO_REQUIRED = "sso_required", | ||
/** | ||
* @deprecated To be removed in a future major version. | ||
*/ | ||
ORGANIZATION_NOT_AUTHORIZED = "organization_not_authorized" | ||
@@ -11,0 +16,0 @@ } |
@@ -14,3 +14,8 @@ "use strict"; | ||
RefreshAndSealSessionDataFailureReason["INVALID_GRANT"] = "invalid_grant"; | ||
RefreshAndSealSessionDataFailureReason["MFA_ENROLLMENT"] = "mfa_enrollment"; | ||
RefreshAndSealSessionDataFailureReason["SSO_REQUIRED"] = "sso_required"; | ||
/** | ||
* @deprecated To be removed in a future major version. | ||
*/ | ||
RefreshAndSealSessionDataFailureReason["ORGANIZATION_NOT_AUTHORIZED"] = "organization_not_authorized"; | ||
})(RefreshAndSealSessionDataFailureReason || (exports.RefreshAndSealSessionDataFailureReason = RefreshAndSealSessionDataFailureReason = {})); |
export interface SessionHandlerOptions { | ||
sessionData: string; | ||
cookiePassword?: string; | ||
organizationId?: string; | ||
} |
@@ -7,3 +7,3 @@ import { AutoPaginatable } from '../common/utils/pagination'; | ||
import { AuthenticateWithOrganizationSelectionOptions } from './interfaces/authenticate-with-organization-selection.interface'; | ||
import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieSuccessResponse, SessionCookieData } from './interfaces/authenticate-with-session-cookie.interface'; | ||
import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieOptions, AuthenticateWithSessionCookieSuccessResponse, SessionCookieData } from './interfaces/authenticate-with-session-cookie.interface'; | ||
import { AuthorizationURLOptions } from './interfaces/authorization-url-options.interface'; | ||
@@ -38,5 +38,5 @@ import { CreateOrganizationMembershipOptions } from './interfaces/create-organization-membership-options.interface'; | ||
authenticateWithOrganizationSelection(payload: AuthenticateWithOrganizationSelectionOptions): Promise<AuthenticationResponse>; | ||
authenticateWithSessionCookie({ sessionData, cookiePassword, }: SessionHandlerOptions): Promise<AuthenticateWithSessionCookieSuccessResponse | AuthenticateWithSessionCookieFailedResponse>; | ||
authenticateWithSessionCookie({ sessionData, cookiePassword, }: AuthenticateWithSessionCookieOptions): Promise<AuthenticateWithSessionCookieSuccessResponse | AuthenticateWithSessionCookieFailedResponse>; | ||
private isValidJwt; | ||
refreshAndSealSessionData({ sessionData, cookiePassword, }: SessionHandlerOptions): Promise<RefreshAndSealSessionDataResponse>; | ||
refreshAndSealSessionData({ sessionData, organizationId, cookiePassword, }: SessionHandlerOptions): Promise<RefreshAndSealSessionDataResponse>; | ||
private prepareAuthenticationResponse; | ||
@@ -43,0 +43,0 @@ private sealSessionDataFromAuthenticationResponse; |
@@ -206,3 +206,3 @@ "use strict"; | ||
} | ||
refreshAndSealSessionData({ sessionData, cookiePassword = process.env.WORKOS_COOKIE_PASSWORD, }) { | ||
refreshAndSealSessionData({ sessionData, organizationId, cookiePassword = process.env.WORKOS_COOKIE_PASSWORD, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -227,2 +227,3 @@ if (!cookiePassword) { | ||
} | ||
const { org_id: organizationIdFromAccessToken } = (0, jose_1.decodeJwt)(session.accessToken); | ||
try { | ||
@@ -232,2 +233,3 @@ const { sealedSession } = yield this.authenticateWithRefreshToken({ | ||
refreshToken: session.refreshToken, | ||
organizationId: organizationId !== null && organizationId !== void 0 ? organizationId : organizationIdFromAccessToken, | ||
session: { sealSession: true, cookiePassword }, | ||
@@ -248,3 +250,4 @@ }); | ||
error.error === | ||
refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.ORGANIZATION_NOT_AUTHORIZED)) { | ||
refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.MFA_ENROLLMENT || | ||
error.error === refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.SSO_REQUIRED)) { | ||
return { | ||
@@ -251,0 +254,0 @@ authenticated: false, |
@@ -30,3 +30,3 @@ "use strict"; | ||
const fetch_client_1 = require("./common/net/fetch-client"); | ||
const VERSION = '7.21.0'; | ||
const VERSION = '7.22.0'; | ||
const DEFAULT_HOSTNAME = 'api.workos.com'; | ||
@@ -33,0 +33,0 @@ const HEADER_AUTHORIZATION = 'Authorization'; |
{ | ||
"version": "7.21.0", | ||
"version": "7.22.0", | ||
"name": "@workos-inc/node", | ||
@@ -61,6 +61,10 @@ "author": "WorkOS", | ||
"types": "./lib/index.d.ts", | ||
"worker": { | ||
"workerd": { | ||
"import": "./lib/index.worker.js", | ||
"default": "./lib/index.worker.js" | ||
}, | ||
"edge-light": { | ||
"import": "./lib/index.worker.js", | ||
"default": "./lib/index.worker.js" | ||
}, | ||
"default": { | ||
@@ -67,0 +71,0 @@ "import": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
626386
13517