@workos-inc/node
Advanced tools
Comparing version 7.8.0 to 7.9.0
import { AuthenticateWithOptionsBase, SerializedAuthenticateWithOptionsBase } from './authenticate-with-options-base.interface'; | ||
export interface AuthenticateWithCodeOptions extends AuthenticateWithOptionsBase { | ||
codeVerifier?: string; | ||
code: string; | ||
@@ -11,4 +12,5 @@ invitationToken?: string; | ||
grant_type: 'authorization_code'; | ||
code_verifier?: string; | ||
code: string; | ||
invitation_token?: string; | ||
} |
export interface AuthorizationURLOptions { | ||
clientId: string; | ||
codeChallenge?: string; | ||
codeChallengeMethod?: 'S256'; | ||
connectionId?: string; | ||
@@ -4,0 +6,0 @@ organizationId?: string; |
@@ -9,2 +9,3 @@ "use strict"; | ||
code: options.code, | ||
code_verifier: options.codeVerifier, | ||
invitation_token: options.invitationToken, | ||
@@ -11,0 +12,0 @@ ip_address: options.ipAddress, |
@@ -72,3 +72,3 @@ import { WorkOS } from '../workos'; | ||
revokeSession(payload: RevokeSessionOptions): Promise<void>; | ||
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }: AuthorizationURLOptions): string; | ||
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }: AuthorizationURLOptions): string; | ||
getLogoutUrl({ sessionId }: { | ||
@@ -75,0 +75,0 @@ sessionId: string; |
@@ -272,3 +272,3 @@ "use strict"; | ||
} | ||
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }) { | ||
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }) { | ||
if (!provider && !connectionId && !organizationId) { | ||
@@ -282,2 +282,4 @@ throw new TypeError(`Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.`); | ||
connection_id: connectionId, | ||
code_challenge: codeChallenge, | ||
code_challenge_method: codeChallengeMethod, | ||
organization_id: organizationId, | ||
@@ -284,0 +286,0 @@ domain_hint: domainHint, |
@@ -166,2 +166,23 @@ "use strict"; | ||
})); | ||
it('sends a token authentication request when including the code_verifier', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, test_utils_1.fetchOnce)({ user: user_json_1.default }); | ||
const resp = yield workos.userManagement.authenticateWithCode({ | ||
clientId: 'proj_whatever', | ||
code: 'or this', | ||
codeVerifier: 'code_verifier_value', | ||
}); | ||
expect((0, test_utils_1.fetchURL)()).toContain('/user_management/authenticate'); | ||
expect((0, test_utils_1.fetchBody)()).toEqual({ | ||
client_id: 'proj_whatever', | ||
client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU', | ||
code: 'or this', | ||
code_verifier: 'code_verifier_value', | ||
grant_type: 'authorization_code', | ||
}); | ||
expect(resp).toMatchObject({ | ||
user: { | ||
email: 'test01@example.com', | ||
}, | ||
}); | ||
})); | ||
it('deserializes authentication_method', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -872,2 +893,15 @@ (0, test_utils_1.fetchOnce)({ | ||
}); | ||
describe('with a code_challenge and code_challenge_method', () => { | ||
it('generates an authorize url', () => { | ||
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); | ||
const url = workos.userManagement.getAuthorizationUrl({ | ||
provider: 'authkit', | ||
clientId: 'proj_123', | ||
redirectUri: 'example.com/auth/workos/callback', | ||
codeChallenge: 'code_challenge_value', | ||
codeChallengeMethod: 'S256', | ||
}); | ||
expect(url).toMatchSnapshot(); | ||
}); | ||
}); | ||
describe('with no custom api hostname', () => { | ||
@@ -874,0 +908,0 @@ it('generates an authorize url with the default api hostname', () => { |
@@ -27,3 +27,3 @@ "use strict"; | ||
const fetch_client_1 = require("./common/utils/fetch-client"); | ||
const VERSION = '7.8.0'; | ||
const VERSION = '7.9.0'; | ||
const DEFAULT_HOSTNAME = 'api.workos.com'; | ||
@@ -30,0 +30,0 @@ class WorkOS { |
{ | ||
"version": "7.8.0", | ||
"version": "7.9.0", | ||
"name": "@workos-inc/node", | ||
@@ -4,0 +4,0 @@ "author": "WorkOS", |
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
434205
9362