1- import { WorkOS } from './index.client ' ;
1+ import { WorkOS } from './index.public ' ;
22
3- describe ( 'WorkOS Client ' , ( ) => {
4- let workosClient : WorkOS ;
3+ describe ( 'WorkOS Public API ' , ( ) => {
4+ let workosPublic : WorkOS ;
55
66 beforeEach ( ( ) => {
7- workosClient = new WorkOS ( {
7+ workosPublic = new WorkOS ( {
88 clientId : 'client_123' ,
99 apiHostname : 'api.workos.dev' ,
1010 } ) ;
@@ -15,7 +15,7 @@ describe('WorkOS Client', () => {
1515 expect ( ( ) => new WorkOS ( ) ) . not . toThrow ( ) ;
1616 } ) ;
1717
18- it ( 'should accept client configuration options' , ( ) => {
18+ it ( 'should accept public configuration options' , ( ) => {
1919 const client = new WorkOS ( {
2020 clientId : 'test_client' ,
2121 apiHostname : 'test.api.com' ,
@@ -30,43 +30,43 @@ describe('WorkOS Client', () => {
3030
3131 describe ( 'exposed services' , ( ) => {
3232 it ( 'should expose webhooks service' , ( ) => {
33- expect ( workosClient . webhooks ) . toBeDefined ( ) ;
34- expect ( workosClient . webhooks . verifyHeader ) . toBeDefined ( ) ;
35- expect ( workosClient . webhooks . computeSignature ) . toBeDefined ( ) ;
36- expect ( workosClient . webhooks . constructEvent ) . toBeDefined ( ) ;
33+ expect ( workosPublic . webhooks ) . toBeDefined ( ) ;
34+ expect ( workosPublic . webhooks . verifyHeader ) . toBeDefined ( ) ;
35+ expect ( workosPublic . webhooks . computeSignature ) . toBeDefined ( ) ;
36+ expect ( workosPublic . webhooks . constructEvent ) . toBeDefined ( ) ;
3737 } ) ;
3838
3939 it ( 'should expose actions service' , ( ) => {
40- expect ( workosClient . actions ) . toBeDefined ( ) ;
41- expect ( workosClient . actions . verifyHeader ) . toBeDefined ( ) ;
42- expect ( workosClient . actions . signResponse ) . toBeDefined ( ) ;
43- expect ( workosClient . actions . constructAction ) . toBeDefined ( ) ;
40+ expect ( workosPublic . actions ) . toBeDefined ( ) ;
41+ expect ( workosPublic . actions . verifyHeader ) . toBeDefined ( ) ;
42+ expect ( workosPublic . actions . signResponse ) . toBeDefined ( ) ;
43+ expect ( workosPublic . actions . constructAction ) . toBeDefined ( ) ;
4444 } ) ;
4545
4646 it ( 'should expose client-safe user management methods' , ( ) => {
47- expect ( workosClient . userManagement ) . toBeDefined ( ) ;
47+ expect ( workosPublic . userManagement ) . toBeDefined ( ) ;
4848 expect (
49- workosClient . userManagement . authenticateWithCodeAndVerifier ,
49+ workosPublic . userManagement . authenticateWithCodeAndVerifier ,
5050 ) . toBeDefined ( ) ;
51- expect ( workosClient . userManagement . getAuthorizationUrl ) . toBeDefined ( ) ;
52- expect ( workosClient . userManagement . getLogoutUrl ) . toBeDefined ( ) ;
53- expect ( workosClient . userManagement . getJwksUrl ) . toBeDefined ( ) ;
51+ expect ( workosPublic . userManagement . getAuthorizationUrl ) . toBeDefined ( ) ;
52+ expect ( workosPublic . userManagement . getLogoutUrl ) . toBeDefined ( ) ;
53+ expect ( workosPublic . userManagement . getJwksUrl ) . toBeDefined ( ) ;
5454 } ) ;
5555
5656 it ( 'should expose client-safe SSO methods' , ( ) => {
57- expect ( workosClient . sso ) . toBeDefined ( ) ;
58- expect ( workosClient . sso . getAuthorizationUrl ) . toBeDefined ( ) ;
57+ expect ( workosPublic . sso ) . toBeDefined ( ) ;
58+ expect ( workosPublic . sso . getAuthorizationUrl ) . toBeDefined ( ) ;
5959 } ) ;
6060
6161 it ( 'should expose version' , ( ) => {
62- expect ( workosClient . version ) . toBeDefined ( ) ;
63- expect ( typeof workosClient . version ) . toBe ( 'string' ) ;
62+ expect ( workosPublic . version ) . toBeDefined ( ) ;
63+ expect ( typeof workosPublic . version ) . toBe ( 'string' ) ;
6464 } ) ;
6565 } ) ;
6666
6767 describe ( 'method behavior' , ( ) => {
6868 it ( 'should be able to call URL generation methods' , ( ) => {
69- const authUrl = workosClient . userManagement . getAuthorizationUrl ( {
69+ const authUrl = workosPublic . userManagement . getAuthorizationUrl ( {
7070 clientId : 'client_123' ,
7171 redirectUri : 'https://example.com/callback' ,
7272 provider : 'GoogleOAuth' ,
@@ -78,12 +78,12 @@ describe('WorkOS Client', () => {
7878 } ) ;
7979
8080 it ( 'should be able to call JWKS URL generation' , ( ) => {
81- const jwksUrl = workosClient . userManagement . getJwksUrl ( 'client_123' ) ;
81+ const jwksUrl = workosPublic . userManagement . getJwksUrl ( 'client_123' ) ;
8282 expect ( jwksUrl ) . toBe ( 'https://api.workos.dev/sso/jwks/client_123' ) ;
8383 } ) ;
8484
8585 it ( 'should be able to call logout URL generation' , ( ) => {
86- const logoutUrl = workosClient . userManagement . getLogoutUrl ( {
86+ const logoutUrl = workosPublic . userManagement . getLogoutUrl ( {
8787 sessionId : 'session_123' ,
8888 returnTo : 'https://example.com' ,
8989 } ) ;
@@ -93,7 +93,7 @@ describe('WorkOS Client', () => {
9393 } ) ;
9494
9595 it ( 'should be able to call SSO authorization URL generation' , ( ) => {
96- const authUrl = workosClient . sso . getAuthorizationUrl ( {
96+ const authUrl = workosPublic . sso . getAuthorizationUrl ( {
9797 clientId : 'client_123' ,
9898 redirectUri : 'https://example.com/callback' ,
9999 provider : 'GoogleOAuth' ,
@@ -106,45 +106,45 @@ describe('WorkOS Client', () => {
106106
107107 describe ( 'server-only methods should not be exposed' , ( ) => {
108108 it ( 'should not expose getUser on userManagement' , ( ) => {
109- expect ( ( workosClient . userManagement as any ) . getUser ) . toBeUndefined ( ) ;
109+ expect ( ( workosPublic . userManagement as any ) . getUser ) . toBeUndefined ( ) ;
110110 } ) ;
111111
112112 it ( 'should not expose createUser on userManagement' , ( ) => {
113- expect ( ( workosClient . userManagement as any ) . createUser ) . toBeUndefined ( ) ;
113+ expect ( ( workosPublic . userManagement as any ) . createUser ) . toBeUndefined ( ) ;
114114 } ) ;
115115
116116 it ( 'should not expose listUsers on userManagement' , ( ) => {
117- expect ( ( workosClient . userManagement as any ) . listUsers ) . toBeUndefined ( ) ;
117+ expect ( ( workosPublic . userManagement as any ) . listUsers ) . toBeUndefined ( ) ;
118118 } ) ;
119119
120120 it ( 'should not expose updateUser on userManagement' , ( ) => {
121- expect ( ( workosClient . userManagement as any ) . updateUser ) . toBeUndefined ( ) ;
121+ expect ( ( workosPublic . userManagement as any ) . updateUser ) . toBeUndefined ( ) ;
122122 } ) ;
123123
124124 it ( 'should not expose server-only authentication methods' , ( ) => {
125125 expect (
126- ( workosClient . userManagement as any ) . authenticateWithPassword ,
126+ ( workosPublic . userManagement as any ) . authenticateWithPassword ,
127127 ) . toBeUndefined ( ) ;
128128 expect (
129- ( workosClient . userManagement as any ) . authenticateWithMagicAuth ,
129+ ( workosPublic . userManagement as any ) . authenticateWithMagicAuth ,
130130 ) . toBeUndefined ( ) ;
131131 expect (
132- ( workosClient . userManagement as any ) . authenticateWithRefreshToken ,
132+ ( workosPublic . userManagement as any ) . authenticateWithRefreshToken ,
133133 ) . toBeUndefined ( ) ;
134134 } ) ;
135135 } ) ;
136136
137137 describe ( 'type safety' , ( ) => {
138138 it ( 'should provide proper TypeScript types for exposed methods' , ( ) => {
139139 // These should compile without errors
140- const authUrl : string = workosClient . userManagement . getAuthorizationUrl ( {
140+ const authUrl : string = workosPublic . userManagement . getAuthorizationUrl ( {
141141 clientId : 'test' ,
142142 redirectUri : 'https://example.com' ,
143143 provider : 'GoogleOAuth' ,
144144 } ) ;
145145
146146 const jwksUrl : string =
147- workosClient . userManagement . getJwksUrl ( 'client_id' ) ;
147+ workosPublic . userManagement . getJwksUrl ( 'client_id' ) ;
148148
149149 expect ( typeof authUrl ) . toBe ( 'string' ) ;
150150 expect ( typeof jwksUrl ) . toBe ( 'string' ) ;
0 commit comments