@workos-inc/node 7.11.3 → 7.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ export declare class NodeHttpClient extends HttpClient implements HttpClientInte
9
9
  private httpsAgent;
10
10
  constructor(baseURL: string, options?: RequestInit | undefined);
11
11
  getClientName(): string;
12
+ static getBody(entity: unknown): string | null;
12
13
  get(path: string, options: RequestOptions): Promise<HttpClientResponseInterface>;
13
14
  post<Entity = any>(path: string, entity: Entity, options: RequestOptions): Promise<HttpClientResponseInterface>;
14
15
  put<Entity = any>(path: string, entity: Entity, options: RequestOptions): Promise<HttpClientResponseInterface>;
@@ -55,6 +55,15 @@ class NodeHttpClient extends http_client_1.HttpClient {
55
55
  getClientName() {
56
56
  return 'node';
57
57
  }
58
+ static getBody(entity) {
59
+ if (entity === null || entity === undefined) {
60
+ return null;
61
+ }
62
+ if (entity instanceof URLSearchParams) {
63
+ return entity.toString();
64
+ }
65
+ return JSON.stringify(entity);
66
+ }
58
67
  get(path, options) {
59
68
  return __awaiter(this, void 0, void 0, function* () {
60
69
  const resourceURL = http_client_1.HttpClient.getResourceURL(this.baseURL, path, options.params);
@@ -64,13 +73,13 @@ class NodeHttpClient extends http_client_1.HttpClient {
64
73
  post(path, entity, options) {
65
74
  return __awaiter(this, void 0, void 0, function* () {
66
75
  const resourceURL = http_client_1.HttpClient.getResourceURL(this.baseURL, path, options.params);
67
- return yield this.nodeRequest(resourceURL, 'POST', http_client_1.HttpClient.getBody(entity), Object.assign(Object.assign({}, http_client_1.HttpClient.getContentTypeHeader(entity)), options.headers));
76
+ return yield this.nodeRequest(resourceURL, 'POST', NodeHttpClient.getBody(entity), Object.assign(Object.assign({}, http_client_1.HttpClient.getContentTypeHeader(entity)), options.headers));
68
77
  });
69
78
  }
70
79
  put(path, entity, options) {
71
80
  return __awaiter(this, void 0, void 0, function* () {
72
81
  const resourceURL = http_client_1.HttpClient.getResourceURL(this.baseURL, path, options.params);
73
- return yield this.nodeRequest(resourceURL, 'PUT', http_client_1.HttpClient.getBody(entity), Object.assign(Object.assign({}, http_client_1.HttpClient.getContentTypeHeader(entity)), options.headers));
82
+ return yield this.nodeRequest(resourceURL, 'PUT', NodeHttpClient.getBody(entity), Object.assign(Object.assign({}, http_client_1.HttpClient.getContentTypeHeader(entity)), options.headers));
74
83
  });
75
84
  }
76
85
  delete(path, options) {
@@ -17,12 +17,4 @@ export interface AuthenticationResponseResponse {
17
17
  impersonator?: ImpersonatorResponse;
18
18
  authentication_method?: AuthenticationMethod;
19
19
  }
20
- export interface RefreshAuthenticationResponse {
21
- accessToken: string;
22
- refreshToken: string;
23
- }
24
- export interface RefreshAuthenticationResponseResponse {
25
- access_token: string;
26
- refresh_token: string;
27
- }
28
20
  export {};
@@ -1,3 +1,2 @@
1
- import { AuthenticationResponse, AuthenticationResponseResponse, RefreshAuthenticationResponse, RefreshAuthenticationResponseResponse } from '../interfaces';
1
+ import { AuthenticationResponse, AuthenticationResponseResponse } from '../interfaces';
2
2
  export declare const deserializeAuthenticationResponse: (authenticationResponse: AuthenticationResponseResponse) => AuthenticationResponse;
3
- export declare const deserializeRefreshAuthenticationResponse: (refreshAuthenticationResponse: RefreshAuthenticationResponseResponse) => RefreshAuthenticationResponse;
@@ -11,15 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.deserializeRefreshAuthenticationResponse = exports.deserializeAuthenticationResponse = void 0;
14
+ exports.deserializeAuthenticationResponse = void 0;
15
15
  const user_serializer_1 = require("./user.serializer");
16
16
  const deserializeAuthenticationResponse = (authenticationResponse) => {
17
17
  const { user, organization_id, access_token, refresh_token, authentication_method, impersonator } = authenticationResponse, rest = __rest(authenticationResponse, ["user", "organization_id", "access_token", "refresh_token", "authentication_method", "impersonator"]);
18
18
  return Object.assign({ user: (0, user_serializer_1.deserializeUser)(user), organizationId: organization_id, accessToken: access_token, refreshToken: refresh_token, impersonator, authenticationMethod: authentication_method }, rest);
19
19
  };
20
20
  exports.deserializeAuthenticationResponse = deserializeAuthenticationResponse;
21
- const deserializeRefreshAuthenticationResponse = (refreshAuthenticationResponse) => {
22
- const { access_token, refresh_token } = refreshAuthenticationResponse, rest = __rest(refreshAuthenticationResponse, ["access_token", "refresh_token"]);
23
- return Object.assign({ accessToken: access_token, refreshToken: refresh_token }, rest);
24
- };
25
- exports.deserializeRefreshAuthenticationResponse = deserializeRefreshAuthenticationResponse;
@@ -1,6 +1,6 @@
1
1
  import { WorkOS } from '../workos';
2
2
  import { AutoPaginatable } from '../common/utils/pagination';
3
- import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, RefreshAuthenticationResponse, MagicAuth, CreateMagicAuthOptions, EmailVerification, PasswordReset, CreatePasswordResetOptions } from './interfaces';
3
+ import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, MagicAuth, CreateMagicAuthOptions, EmailVerification, PasswordReset, CreatePasswordResetOptions } from './interfaces';
4
4
  import { Challenge } from '../mfa/interfaces';
5
5
  import { OrganizationMembership } from './interfaces/organization-membership.interface';
6
6
  import { ListOrganizationMembershipsOptions } from './interfaces/list-organization-memberships-options.interface';
@@ -23,7 +23,7 @@ export declare class UserManagement {
23
23
  authenticateWithMagicAuth(payload: AuthenticateWithMagicAuthOptions): Promise<AuthenticationResponse>;
24
24
  authenticateWithPassword(payload: AuthenticateWithPasswordOptions): Promise<AuthenticationResponse>;
25
25
  authenticateWithCode(payload: AuthenticateWithCodeOptions): Promise<AuthenticationResponse>;
26
- authenticateWithRefreshToken(payload: AuthenticateWithRefreshTokenOptions): Promise<RefreshAuthenticationResponse>;
26
+ authenticateWithRefreshToken(payload: AuthenticateWithRefreshTokenOptions): Promise<AuthenticationResponse>;
27
27
  authenticateWithTotp(payload: AuthenticateWithTotpOptions): Promise<AuthenticationResponse>;
28
28
  authenticateWithEmailVerification(payload: AuthenticateWithEmailVerificationOptions): Promise<AuthenticationResponse>;
29
29
  authenticateWithOrganizationSelection(payload: AuthenticateWithOrganizationSelectionOptions): Promise<AuthenticationResponse>;
@@ -90,7 +90,7 @@ class UserManagement {
90
90
  authenticateWithRefreshToken(payload) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
92
  const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_1.serializeAuthenticateWithRefreshTokenOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
93
- return (0, serializers_1.deserializeRefreshAuthenticationResponse)(data);
93
+ return (0, serializers_1.deserializeAuthenticationResponse)(data);
94
94
  });
95
95
  }
96
96
  authenticateWithTotp(payload) {
@@ -228,6 +228,7 @@ describe('UserManagement', () => {
228
228
  describe('authenticateWithRefreshToken', () => {
229
229
  it('sends a refresh_token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
230
230
  (0, test_utils_1.fetchOnce)({
231
+ user: user_json_1.default,
231
232
  access_token: 'access_token',
232
233
  refresh_token: 'refreshToken2',
233
234
  });
package/lib/workos.js CHANGED
@@ -26,7 +26,7 @@ const bad_request_exception_1 = require("./common/exceptions/bad-request.excepti
26
26
  const http_client_1 = require("./common/net/http-client");
27
27
  const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
28
28
  const fetch_client_1 = require("./common/net/fetch-client");
29
- const VERSION = '7.11.3';
29
+ const VERSION = '7.12.0';
30
30
  const DEFAULT_HOSTNAME = 'api.workos.com';
31
31
  class WorkOS {
32
32
  constructor(key, options = {}) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.11.3",
2
+ "version": "7.12.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",