@workos-inc/node 8.0.0-beta.3 → 8.0.0-beta.4
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.
- package/lib/cjs/audit-logs/audit-logs.d.cts +3 -2
- package/lib/cjs/client/index.cjs +42 -0
- package/lib/cjs/client/index.cjs.map +1 -0
- package/lib/cjs/client/index.d.cts +3 -0
- package/lib/cjs/client/sso.cjs +65 -0
- package/lib/cjs/client/sso.cjs.map +1 -0
- package/lib/cjs/client/sso.d.cts +2 -0
- package/lib/cjs/client/user-management.cjs +110 -0
- package/lib/cjs/client/user-management.cjs.map +1 -0
- package/lib/cjs/client/user-management.d.cts +1 -0
- package/lib/cjs/client/utils.cjs +49 -0
- package/lib/cjs/client/utils.cjs.map +1 -0
- package/lib/cjs/client/utils.d.cts +7 -0
- package/lib/cjs/common/decorators/public-method.cjs +48 -0
- package/lib/cjs/common/decorators/public-method.cjs.map +1 -0
- package/lib/cjs/common/decorators/public-method.d.cts +12 -0
- package/lib/cjs/common/interfaces/event.interface.cjs.map +1 -1
- package/lib/cjs/common/interfaces/event.interface.d.cts +19 -3
- package/lib/cjs/common/interfaces/index.d.cts +1 -1
- package/lib/cjs/common/interfaces/workos-options.interface.cjs.map +1 -1
- package/lib/cjs/common/interfaces/workos-options.interface.d.cts +1 -0
- package/lib/cjs/common/net/fetch-client.cjs +67 -36
- package/lib/cjs/common/net/fetch-client.cjs.map +1 -1
- package/lib/cjs/common/net/fetch-client.d.cts +5 -2
- package/lib/cjs/common/serializers/event.serializer.cjs +2 -0
- package/lib/cjs/common/serializers/event.serializer.cjs.map +1 -1
- package/lib/cjs/common/utils/fetch-and-deserialize.d.cts +3 -2
- package/lib/cjs/common/utils/pagination.cjs +2 -4
- package/lib/cjs/common/utils/pagination.cjs.map +1 -1
- package/lib/cjs/common/utils/runtime-info.cjs +73 -0
- package/lib/cjs/common/utils/runtime-info.cjs.map +1 -0
- package/lib/cjs/common/utils/runtime-info.d.cts +22 -0
- package/lib/cjs/directory-sync/directory-sync.d.cts +4 -3
- package/lib/cjs/events/events.d.cts +3 -2
- package/lib/cjs/fga/fga.d.cts +4 -3
- package/lib/cjs/fga/utils/fetch-and-deserialize-list.d.cts +3 -2
- package/lib/cjs/index.cjs +2 -0
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/index.client.cjs +42 -0
- package/lib/cjs/index.client.cjs.map +1 -0
- package/lib/cjs/index.client.d.cts +3 -0
- package/lib/cjs/index.d.cts +3 -2
- package/lib/cjs/index.public.cjs +52 -0
- package/lib/cjs/index.public.cjs.map +1 -0
- package/lib/cjs/index.public.d.cts +36 -0
- package/lib/cjs/index.worker.d.cts +3 -2
- package/lib/cjs/mfa/mfa.d.cts +3 -2
- package/lib/cjs/organization-domains/organization-domains.d.cts +3 -2
- package/lib/cjs/organizations/interfaces/list-organization-feature-flags-options.interface.cjs.map +1 -1
- package/lib/cjs/organizations/interfaces/list-organization-feature-flags-options.interface.d.cts +3 -1
- package/lib/cjs/organizations/organizations.cjs +15 -5
- package/lib/cjs/organizations/organizations.cjs.map +1 -1
- package/lib/cjs/organizations/organizations.d.cts +4 -3
- package/lib/cjs/passwordless/passwordless.d.cts +3 -2
- package/lib/cjs/portal/portal.d.cts +3 -2
- package/lib/cjs/public/index.cjs +42 -0
- package/lib/cjs/public/index.cjs.map +1 -0
- package/lib/cjs/public/index.d.cts +2 -0
- package/lib/cjs/public/sso.cjs +65 -0
- package/lib/cjs/public/sso.cjs.map +1 -0
- package/lib/cjs/public/sso.d.cts +1 -0
- package/lib/cjs/public/user-management.cjs +110 -0
- package/lib/cjs/public/user-management.cjs.map +1 -0
- package/lib/cjs/public/user-management.d.cts +1 -0
- package/lib/cjs/public/utils.cjs +49 -0
- package/lib/cjs/public/utils.cjs.map +1 -0
- package/lib/cjs/public/utils.d.cts +7 -0
- package/lib/cjs/sso/interfaces/authorization-url-options.interface.cjs.map +1 -1
- package/lib/cjs/sso/interfaces/authorization-url-options.interface.d.cts +19 -4
- package/lib/cjs/sso/interfaces/connection-type.enum.cjs +1 -0
- package/lib/cjs/sso/interfaces/connection-type.enum.cjs.map +1 -1
- package/lib/cjs/sso/interfaces/connection-type.enum.d.cts +1 -0
- package/lib/cjs/sso/interfaces/index.d.cts +1 -0
- package/lib/cjs/sso/interfaces/profile-and-token.interface.cjs.map +1 -1
- package/lib/cjs/sso/interfaces/profile-and-token.interface.d.cts +3 -0
- package/lib/cjs/sso/serializers/index.d.cts +1 -0
- package/lib/cjs/sso/serializers/profile-and-token.serializer.cjs +3 -1
- package/lib/cjs/sso/serializers/profile-and-token.serializer.cjs.map +1 -1
- package/lib/cjs/sso/serializers/profile-and-token.serializer.d.cts +1 -0
- package/lib/cjs/sso/sso.cjs +15 -37
- package/lib/cjs/sso/sso.cjs.map +1 -1
- package/lib/cjs/sso/sso.d.cts +2 -1
- package/lib/cjs/sso-BkBnkcTC.d.cts +22 -0
- package/lib/cjs/sso-Cdnhezcz.d.cts +31 -0
- package/lib/cjs/sso-DwRz-nPM.d.cts +31 -0
- package/lib/cjs/user-management/interfaces/authenticate-with-session-cookie.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/authenticate-with-session-cookie.interface.d.cts +2 -0
- package/lib/cjs/user-management/interfaces/authentication-response.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/authentication-response.interface.d.cts +1 -1
- package/lib/cjs/user-management/interfaces/create-organization-membership-options.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/create-organization-membership-options.interface.d.cts +2 -0
- package/lib/cjs/user-management/interfaces/identity.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/identity.interface.d.cts +2 -2
- package/lib/cjs/user-management/interfaces/list-sessions-options.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/organization-membership.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/organization-membership.interface.d.cts +2 -0
- package/lib/cjs/user-management/interfaces/update-organization-membership-options.interface.cjs.map +1 -1
- package/lib/cjs/user-management/interfaces/update-organization-membership-options.interface.d.cts +2 -0
- package/lib/cjs/user-management/serializers/create-organization-membership-options.serializer.cjs +2 -1
- package/lib/cjs/user-management/serializers/create-organization-membership-options.serializer.cjs.map +1 -1
- package/lib/cjs/user-management/serializers/organization-membership.serializer.cjs +2 -1
- package/lib/cjs/user-management/serializers/organization-membership.serializer.cjs.map +1 -1
- package/lib/cjs/user-management/serializers/update-organization-membership-options.serializer.cjs +2 -1
- package/lib/cjs/user-management/serializers/update-organization-membership-options.serializer.cjs.map +1 -1
- package/lib/cjs/user-management/session.cjs +4 -0
- package/lib/cjs/user-management/session.cjs.map +1 -1
- package/lib/cjs/user-management/session.d.cts +2 -1
- package/lib/cjs/user-management/user-management.cjs +13 -81
- package/lib/cjs/user-management/user-management.cjs.map +1 -1
- package/lib/cjs/user-management/user-management.d.cts +3 -2
- package/lib/cjs/user-management-B-71OTAR.d.cts +401 -0
- package/lib/cjs/user-management-B38wNrIN.d.cts +68 -0
- package/lib/cjs/user-management-Dh73wyCr.d.cts +68 -0
- package/lib/cjs/vault/vault.d.cts +3 -2
- package/lib/cjs/widgets/interfaces/get-token.cjs.map +1 -1
- package/lib/cjs/widgets/interfaces/get-token.d.cts +5 -5
- package/lib/cjs/widgets/widgets.d.cts +3 -2
- package/lib/cjs/workos-BEHZtxw8.d.cts +401 -0
- package/lib/cjs/workos-Bt8QqzZV.d.cts +395 -0
- package/lib/cjs/workos-C6IZ2mAH.d.cts +402 -0
- package/lib/cjs/workos-C7eLbzyK.d.cts +398 -0
- package/lib/cjs/workos-C9Z7mAdD.d.cts +399 -0
- package/lib/cjs/workos-CUh2oD_o.d.cts +396 -0
- package/lib/cjs/workos-Cuegztvg.d.cts +397 -0
- package/lib/cjs/workos-DiEirbod.d.cts +397 -0
- package/lib/cjs/workos-jsQjZHfV.d.cts +395 -0
- package/lib/cjs/workos.cjs +2 -1
- package/lib/cjs/workos.cjs.map +1 -1
- package/lib/cjs/workos.d.cts +3 -2
- package/lib/common/interfaces/event.interface.d.ts +18 -2
- package/lib/common/interfaces/workos-options.interface.d.ts +1 -0
- package/lib/common/net/fetch-client.d.ts +6 -2
- package/lib/common/net/fetch-client.js +67 -31
- package/lib/common/net/fetch-client.spec.js +71 -0
- package/lib/common/serializers/event.serializer.js +2 -0
- package/lib/common/utils/pagination.js +1 -1
- package/lib/esm/audit-logs/audit-logs.d.ts +3 -2
- package/lib/esm/client/index.d.ts +3 -0
- package/lib/esm/client/index.js +7 -0
- package/lib/esm/client/index.js.map +1 -0
- package/lib/esm/client/sso.d.ts +2 -0
- package/lib/esm/client/sso.js +42 -0
- package/lib/esm/client/sso.js.map +1 -0
- package/lib/esm/client/user-management.d.ts +1 -0
- package/lib/esm/client/user-management.js +85 -0
- package/lib/esm/client/user-management.js.map +1 -0
- package/lib/esm/client/utils.d.ts +7 -0
- package/lib/esm/client/utils.js +16 -0
- package/lib/esm/client/utils.js.map +1 -0
- package/lib/esm/common/interfaces/event.interface.d.ts +19 -3
- package/lib/esm/common/interfaces/index.d.ts +1 -1
- package/lib/esm/common/interfaces/workos-options.interface.d.ts +1 -0
- package/lib/esm/common/net/fetch-client.d.ts +5 -2
- package/lib/esm/common/net/fetch-client.js +67 -36
- package/lib/esm/common/net/fetch-client.js.map +1 -1
- package/lib/esm/common/serializers/event.serializer.js +2 -0
- package/lib/esm/common/serializers/event.serializer.js.map +1 -1
- package/lib/esm/common/utils/fetch-and-deserialize.d.ts +3 -2
- package/lib/esm/common/utils/pagination.js +2 -4
- package/lib/esm/common/utils/pagination.js.map +1 -1
- package/lib/esm/directory-sync/directory-sync.d.ts +4 -3
- package/lib/esm/events/events.d.ts +3 -2
- package/lib/esm/fga/fga.d.ts +4 -3
- package/lib/esm/fga/utils/fetch-and-deserialize-list.d.ts +3 -2
- package/lib/esm/index.client.d.ts +3 -0
- package/lib/esm/index.client.js +7 -0
- package/lib/esm/index.client.js.map +1 -0
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.worker.d.ts +3 -2
- package/lib/esm/mfa/mfa.d.ts +3 -2
- package/lib/esm/organization-domains/organization-domains.d.ts +3 -2
- package/lib/esm/organizations/interfaces/list-organization-feature-flags-options.interface.d.ts +3 -1
- package/lib/esm/organizations/organizations.d.ts +4 -3
- package/lib/esm/organizations/organizations.js +15 -5
- package/lib/esm/organizations/organizations.js.map +1 -1
- package/lib/esm/passwordless/passwordless.d.ts +3 -2
- package/lib/esm/portal/portal.d.ts +3 -2
- package/lib/esm/sso/interfaces/authorization-url-options.interface.d.ts +19 -4
- package/lib/esm/sso/interfaces/connection-type.enum.d.ts +1 -0
- package/lib/esm/sso/interfaces/connection-type.enum.js +1 -0
- package/lib/esm/sso/interfaces/connection-type.enum.js.map +1 -1
- package/lib/esm/sso/interfaces/index.d.ts +1 -0
- package/lib/esm/sso/interfaces/profile-and-token.interface.d.ts +3 -0
- package/lib/esm/sso/serializers/index.d.ts +1 -0
- package/lib/esm/sso/serializers/profile-and-token.serializer.d.ts +1 -0
- package/lib/esm/sso/serializers/profile-and-token.serializer.js +3 -1
- package/lib/esm/sso/serializers/profile-and-token.serializer.js.map +1 -1
- package/lib/esm/sso/sso.d.ts +2 -1
- package/lib/esm/sso/sso.js +5 -37
- package/lib/esm/sso/sso.js.map +1 -1
- package/lib/esm/sso-nFEQz_Js.d.ts +22 -0
- package/lib/esm/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +2 -0
- package/lib/esm/user-management/interfaces/authenticate-with-session-cookie.interface.js.map +1 -1
- package/lib/esm/user-management/interfaces/authentication-response.interface.d.ts +1 -1
- package/lib/esm/user-management/interfaces/create-organization-membership-options.interface.d.ts +2 -0
- package/lib/esm/user-management/interfaces/identity.interface.d.ts +2 -2
- package/lib/esm/user-management/interfaces/organization-membership.interface.d.ts +2 -0
- package/lib/esm/user-management/interfaces/update-organization-membership-options.interface.d.ts +2 -0
- package/lib/esm/user-management/serializers/create-organization-membership-options.serializer.js +2 -1
- package/lib/esm/user-management/serializers/create-organization-membership-options.serializer.js.map +1 -1
- package/lib/esm/user-management/serializers/organization-membership.serializer.js +2 -1
- package/lib/esm/user-management/serializers/organization-membership.serializer.js.map +1 -1
- package/lib/esm/user-management/serializers/update-organization-membership-options.serializer.js +2 -1
- package/lib/esm/user-management/serializers/update-organization-membership-options.serializer.js.map +1 -1
- package/lib/esm/user-management/session.d.ts +2 -1
- package/lib/esm/user-management/session.js +4 -0
- package/lib/esm/user-management/session.js.map +1 -1
- package/lib/esm/user-management/user-management.d.ts +3 -2
- package/lib/esm/user-management/user-management.js +13 -81
- package/lib/esm/user-management/user-management.js.map +1 -1
- package/lib/esm/user-management-B38wNrIN.d.ts +68 -0
- package/lib/esm/vault/vault.d.ts +3 -2
- package/lib/esm/widgets/interfaces/get-token.d.ts +5 -5
- package/lib/esm/widgets/interfaces/get-token.js.map +1 -1
- package/lib/esm/widgets/widgets.d.ts +3 -2
- package/lib/esm/{workos-DGRMJ65Z.d.ts → workos-EX3jNkYH.d.ts} +5 -7
- package/lib/esm/workos.d.ts +3 -2
- package/lib/esm/workos.js +2 -1
- package/lib/esm/workos.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/organizations/interfaces/list-organization-feature-flags-options.interface.d.ts +2 -1
- package/lib/organizations/organizations.d.ts +1 -2
- package/lib/organizations/organizations.js +2 -4
- package/lib/organizations/organizations.spec.js +46 -1
- package/lib/sso/interfaces/authorization-url-options.interface.d.ts +2 -0
- package/lib/sso/interfaces/profile-and-token.interface.d.ts +3 -0
- package/lib/sso/serializers/profile-and-token.serializer.js +2 -0
- package/lib/sso/sso.d.ts +1 -1
- package/lib/sso/sso.js +14 -10
- package/lib/sso/sso.spec.js +131 -0
- package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +2 -0
- package/lib/user-management/interfaces/create-organization-membership-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/organization-membership.interface.d.ts +2 -0
- package/lib/user-management/interfaces/update-organization-membership-options.interface.d.ts +2 -0
- package/lib/user-management/serializers/create-organization-membership-options.serializer.js +1 -0
- package/lib/user-management/serializers/organization-membership.serializer.js +1 -11
- package/lib/user-management/serializers/update-organization-membership-options.serializer.js +1 -0
- package/lib/user-management/session.js +4 -2
- package/lib/user-management/session.spec.js +4 -2
- package/lib/user-management/user-management.js +2 -1
- package/lib/user-management/user-management.spec.js +33 -0
- package/lib/widgets/interfaces/get-token.d.ts +5 -5
- package/lib/workos.js +2 -2
- package/package.json +10 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as Widgets } from '../workos-
|
|
1
|
+
export { c as Widgets } from '../workos-EX3jNkYH.js';
|
|
2
2
|
import './interfaces/get-token.js';
|
|
3
3
|
import '../common/interfaces/get-options.interface.js';
|
|
4
4
|
import '../common/interfaces/post-options.interface.js';
|
|
@@ -46,6 +46,7 @@ import '../sso/interfaces/get-profile-options.interface.js';
|
|
|
46
46
|
import '../sso/interfaces/get-profile-and-token-options.interface.js';
|
|
47
47
|
import '../sso/interfaces/list-connections-options.interface.js';
|
|
48
48
|
import '../sso/interfaces/profile-and-token.interface.js';
|
|
49
|
+
import '../user-management/interfaces/oauth-tokens.interface.js';
|
|
49
50
|
import '../sso/interfaces/profile.interface.js';
|
|
50
51
|
import '../webhooks/webhooks.js';
|
|
51
52
|
import '../common/crypto/crypto-provider.js';
|
|
@@ -62,6 +63,7 @@ import '../audit-logs/interfaces/audit-log-export.interface.js';
|
|
|
62
63
|
import '../audit-logs/interfaces/create-audit-log-event-options.interface.js';
|
|
63
64
|
import '../audit-logs/interfaces/create-audit-log-schema-options.interface.js';
|
|
64
65
|
import 'jose';
|
|
66
|
+
import '../user-management-B38wNrIN.js';
|
|
65
67
|
import '../user-management/interfaces/authenticate-with-code-options.interface.js';
|
|
66
68
|
import '../user-management/interfaces/authenticate-with-options-base.interface.js';
|
|
67
69
|
import '../user-management/interfaces/authenticate-with-code-and-verifier-options.interface.js';
|
|
@@ -72,7 +74,6 @@ import '../user-management/interfaces/authenticate-with-password-options.interfa
|
|
|
72
74
|
import '../user-management/interfaces/authenticate-with-refresh-token-options.interface.js';
|
|
73
75
|
import '../user-management/interfaces/authenticate-with-session-cookie.interface.js';
|
|
74
76
|
import '../user-management/interfaces/authentication-response.interface.js';
|
|
75
|
-
import '../user-management/interfaces/oauth-tokens.interface.js';
|
|
76
77
|
import '../user-management/interfaces/authenticate-with-totp-options.interface.js';
|
|
77
78
|
import '../user-management/interfaces/authorization-url-options.interface.js';
|
|
78
79
|
import '../user-management/interfaces/create-magic-auth-options.interface.js';
|
|
@@ -40,6 +40,7 @@ import { AuditLogExport } from './audit-logs/interfaces/audit-log-export.interfa
|
|
|
40
40
|
import { CreateAuditLogEventOptions, CreateAuditLogEventRequestOptions } from './audit-logs/interfaces/create-audit-log-event-options.interface.js';
|
|
41
41
|
import { CreateAuditLogSchemaOptions, CreateAuditLogSchemaRequestOptions, AuditLogSchema } from './audit-logs/interfaces/create-audit-log-schema-options.interface.js';
|
|
42
42
|
import { createRemoteJWKSet } from 'jose';
|
|
43
|
+
import { L as LogoutURLOptions } from './user-management-B38wNrIN.js';
|
|
43
44
|
import { PaginationOptions } from './common/interfaces/pagination-options.interface.js';
|
|
44
45
|
import { AuthenticateWithCodeOptions } from './user-management/interfaces/authenticate-with-code-options.interface.js';
|
|
45
46
|
import { AuthenticateWithCodeAndVerifierOptions } from './user-management/interfaces/authenticate-with-code-and-verifier-options.interface.js';
|
|
@@ -133,7 +134,7 @@ declare class Organizations {
|
|
|
133
134
|
getOrganizationByExternalId(externalId: string): Promise<Organization>;
|
|
134
135
|
updateOrganization(options: UpdateOrganizationOptions): Promise<Organization>;
|
|
135
136
|
listOrganizationRoles(options: ListOrganizationRolesOptions): Promise<RoleList>;
|
|
136
|
-
listOrganizationFeatureFlags(options: ListOrganizationFeatureFlagsOptions): Promise<
|
|
137
|
+
listOrganizationFeatureFlags(options: ListOrganizationFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag, ListOrganizationFeatureFlagsOptions>>;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
declare class OrganizationDomains {
|
|
@@ -170,7 +171,7 @@ declare class SSO {
|
|
|
170
171
|
constructor(workos: WorkOS);
|
|
171
172
|
listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection, SerializedListConnectionsOptions>>;
|
|
172
173
|
deleteConnection(id: string): Promise<void>;
|
|
173
|
-
getAuthorizationUrl(
|
|
174
|
+
getAuthorizationUrl(options: SSOAuthorizationURLOptions): string;
|
|
174
175
|
getConnection(id: string): Promise<Connection>;
|
|
175
176
|
getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
|
|
176
177
|
getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
|
|
@@ -303,11 +304,8 @@ declare class UserManagement {
|
|
|
303
304
|
acceptInvitation(invitationId: string): Promise<Invitation>;
|
|
304
305
|
revokeInvitation(invitationId: string): Promise<Invitation>;
|
|
305
306
|
revokeSession(payload: RevokeSessionOptions): Promise<void>;
|
|
306
|
-
getAuthorizationUrl(
|
|
307
|
-
getLogoutUrl(
|
|
308
|
-
sessionId: string;
|
|
309
|
-
returnTo?: string;
|
|
310
|
-
}): string;
|
|
307
|
+
getAuthorizationUrl(options: UserManagementAuthorizationURLOptions): string;
|
|
308
|
+
getLogoutUrl(options: LogoutURLOptions): string;
|
|
311
309
|
getJwksUrl(clientId: string): string;
|
|
312
310
|
}
|
|
313
311
|
|
package/lib/esm/workos.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import './common/interfaces/get-options.interface.js';
|
|
|
2
2
|
import './common/interfaces/post-options.interface.js';
|
|
3
3
|
import './common/interfaces/put-options.interface.js';
|
|
4
4
|
import './common/interfaces/workos-options.interface.js';
|
|
5
|
-
export { W as WorkOS } from './workos-
|
|
5
|
+
export { W as WorkOS } from './workos-EX3jNkYH.js';
|
|
6
6
|
import './webhooks/webhooks.js';
|
|
7
7
|
import './common/net/http-client.js';
|
|
8
8
|
import './actions/actions.js';
|
|
@@ -49,6 +49,7 @@ import './sso/interfaces/get-profile-options.interface.js';
|
|
|
49
49
|
import './sso/interfaces/get-profile-and-token-options.interface.js';
|
|
50
50
|
import './sso/interfaces/list-connections-options.interface.js';
|
|
51
51
|
import './sso/interfaces/profile-and-token.interface.js';
|
|
52
|
+
import './user-management/interfaces/oauth-tokens.interface.js';
|
|
52
53
|
import './sso/interfaces/profile.interface.js';
|
|
53
54
|
import './mfa/interfaces/challenge-factor-options.js';
|
|
54
55
|
import './mfa/interfaces/challenge.interface.js';
|
|
@@ -63,6 +64,7 @@ import './audit-logs/interfaces/audit-log-export.interface.js';
|
|
|
63
64
|
import './audit-logs/interfaces/create-audit-log-event-options.interface.js';
|
|
64
65
|
import './audit-logs/interfaces/create-audit-log-schema-options.interface.js';
|
|
65
66
|
import 'jose';
|
|
67
|
+
import './user-management-B38wNrIN.js';
|
|
66
68
|
import './user-management/interfaces/authenticate-with-code-options.interface.js';
|
|
67
69
|
import './user-management/interfaces/authenticate-with-options-base.interface.js';
|
|
68
70
|
import './user-management/interfaces/authenticate-with-code-and-verifier-options.interface.js';
|
|
@@ -73,7 +75,6 @@ import './user-management/interfaces/authenticate-with-password-options.interfac
|
|
|
73
75
|
import './user-management/interfaces/authenticate-with-refresh-token-options.interface.js';
|
|
74
76
|
import './user-management/interfaces/authenticate-with-session-cookie.interface.js';
|
|
75
77
|
import './user-management/interfaces/authentication-response.interface.js';
|
|
76
|
-
import './user-management/interfaces/oauth-tokens.interface.js';
|
|
77
78
|
import './user-management/interfaces/authenticate-with-totp-options.interface.js';
|
|
78
79
|
import './user-management/interfaces/authorization-url-options.interface.js';
|
|
79
80
|
import './user-management/interfaces/create-magic-auth-options.interface.js';
|
package/lib/esm/workos.js
CHANGED
|
@@ -31,7 +31,7 @@ import { Vault } from "./vault/vault.js";
|
|
|
31
31
|
import { ConflictException } from "./common/exceptions/conflict.exception.js";
|
|
32
32
|
import { ParseError } from "./common/exceptions/parse-error.js";
|
|
33
33
|
import { getEnv } from "./common/utils/env.js";
|
|
34
|
-
const VERSION = "8.0.0-beta.
|
|
34
|
+
const VERSION = "8.0.0-beta.4";
|
|
35
35
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
36
36
|
const HEADER_AUTHORIZATION = "Authorization";
|
|
37
37
|
const HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
@@ -103,6 +103,7 @@ class WorkOS {
|
|
|
103
103
|
createHttpClient(options, userAgent) {
|
|
104
104
|
return new FetchHttpClient(this.baseURL, {
|
|
105
105
|
...options.config,
|
|
106
|
+
timeout: options.timeout,
|
|
106
107
|
headers: {
|
|
107
108
|
...options.config?.headers,
|
|
108
109
|
Authorization: `Bearer ${this.key}`,
|
package/lib/esm/workos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workos.ts"],"sourcesContent":["import {\n GenericServerException,\n NoApiKeyProvidedException,\n NotFoundException,\n UnauthorizedException,\n UnprocessableEntityException,\n OauthException,\n RateLimitExceededException,\n} from './common/exceptions';\nimport {\n GetOptions,\n HttpClientResponseInterface,\n PostOptions,\n PutOptions,\n WorkOSOptions,\n WorkOSResponseError,\n} from './common/interfaces';\nimport { DirectorySync } from './directory-sync/directory-sync';\nimport { Events } from './events/events';\nimport { Organizations } from './organizations/organizations';\nimport { OrganizationDomains } from './organization-domains/organization-domains';\nimport { Passwordless } from './passwordless/passwordless';\nimport { Portal } from './portal/portal';\nimport { SSO } from './sso/sso';\nimport { Webhooks } from './webhooks/webhooks';\nimport { Mfa } from './mfa/mfa';\nimport { AuditLogs } from './audit-logs/audit-logs';\nimport { UserManagement } from './user-management/user-management';\nimport { FGA } from './fga/fga';\nimport { BadRequestException } from './common/exceptions/bad-request.exception';\n\nimport { HttpClient, HttpClientError } from './common/net/http-client';\nimport { SubtleCryptoProvider } from './common/crypto/subtle-crypto-provider';\nimport { FetchHttpClient } from './common/net/fetch-client';\nimport { Widgets } from './widgets/widgets';\nimport { Actions } from './actions/actions';\nimport { Vault } from './vault/vault';\nimport { ConflictException } from './common/exceptions/conflict.exception';\nimport { CryptoProvider } from './common/crypto/crypto-provider';\nimport { ParseError } from './common/exceptions/parse-error';\nimport { getEnv } from './common/utils/env';\n\nconst VERSION = '8.0.0-beta.3';\n\nconst DEFAULT_HOSTNAME = 'api.workos.com';\n\nconst HEADER_AUTHORIZATION = 'Authorization';\nconst HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';\nconst HEADER_WARRANT_TOKEN = 'Warrant-Token';\n\nexport class WorkOS {\n readonly baseURL: string;\n readonly client: HttpClient;\n readonly clientId?: string;\n\n readonly actions: Actions;\n readonly auditLogs = new AuditLogs(this);\n readonly directorySync = new DirectorySync(this);\n readonly organizations = new Organizations(this);\n readonly organizationDomains = new OrganizationDomains(this);\n readonly passwordless = new Passwordless(this);\n readonly portal = new Portal(this);\n readonly sso = new SSO(this);\n readonly webhooks: Webhooks;\n readonly mfa = new Mfa(this);\n readonly events = new Events(this);\n readonly userManagement: UserManagement;\n readonly fga = new FGA(this);\n readonly widgets = new Widgets(this);\n readonly vault = new Vault(this);\n\n constructor(\n readonly key?: string,\n readonly options: WorkOSOptions = {},\n ) {\n if (!key) {\n this.key = getEnv('WORKOS_API_KEY');\n\n if (!this.key) {\n throw new NoApiKeyProvidedException();\n }\n }\n\n if (this.options.https === undefined) {\n this.options.https = true;\n }\n\n this.clientId = this.options.clientId;\n if (!this.clientId) {\n this.clientId = getEnv('WORKOS_CLIENT_ID');\n }\n\n const protocol: string = this.options.https ? 'https' : 'http';\n const apiHostname: string = this.options.apiHostname || DEFAULT_HOSTNAME;\n const port: number | undefined = this.options.port;\n this.baseURL = `${protocol}://${apiHostname}`;\n\n if (port) {\n this.baseURL = this.baseURL + `:${port}`;\n }\n\n let userAgent: string = `workos-node/${VERSION}`;\n\n if (options.appInfo) {\n const { name, version }: { name: string; version: string } =\n options.appInfo;\n userAgent += ` ${name}: ${version}`;\n }\n\n this.webhooks = this.createWebhookClient();\n this.actions = this.createActionsClient();\n\n // Must initialize UserManagement after baseURL is configured\n this.userManagement = new UserManagement(this);\n\n this.client = this.createHttpClient(options, userAgent);\n }\n\n createWebhookClient() {\n return new Webhooks(this.getCryptoProvider());\n }\n\n createActionsClient() {\n return new Actions(this.getCryptoProvider());\n }\n\n getCryptoProvider(): CryptoProvider {\n return new SubtleCryptoProvider();\n }\n\n createHttpClient(options: WorkOSOptions, userAgent: string) {\n return new FetchHttpClient(this.baseURL, {\n ...options.config,\n headers: {\n ...options.config?.headers,\n Authorization: `Bearer ${this.key}`,\n 'User-Agent': userAgent,\n },\n }) as HttpClient;\n }\n\n get version() {\n return VERSION;\n }\n\n async post<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PostOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.post<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async get<Result = any>(\n path: string,\n options: GetOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.accessToken) {\n requestHeaders[HEADER_AUTHORIZATION] = `Bearer ${options.accessToken}`;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n try {\n res = await this.client.get(path, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async put<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PutOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.put<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async delete(path: string, query?: any): Promise<void> {\n try {\n await this.client.delete(path, {\n params: query,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n }\n\n emitWarning(warning: string) {\n // tslint:disable-next-line:no-console\n console.warn(`WorkOS: ${warning}`);\n }\n\n private async handleParseError(\n error: unknown,\n res: HttpClientResponseInterface,\n ) {\n if (error instanceof SyntaxError) {\n const rawResponse = res.getRawResponse() as Response;\n const requestID = rawResponse.headers.get('X-Request-ID') ?? '';\n const rawStatus = rawResponse.status;\n const rawBody = await rawResponse.text();\n throw new ParseError({\n message: error.message,\n rawBody,\n rawStatus,\n requestID,\n });\n }\n }\n\n private handleHttpError({ path, error }: { path: string; error: unknown }) {\n if (!(error instanceof HttpClientError)) {\n throw new Error(`Unexpected error: ${error}`, { cause: error });\n }\n\n const { response } = error as HttpClientError<WorkOSResponseError>;\n\n if (response) {\n const { status, data, headers } = response;\n\n const requestID = headers['X-Request-ID'] ?? '';\n const {\n code,\n error_description: errorDescription,\n error,\n errors,\n message,\n } = data;\n\n switch (status) {\n case 401: {\n throw new UnauthorizedException(requestID);\n }\n case 409: {\n throw new ConflictException({ requestID, message, error });\n }\n case 422: {\n throw new UnprocessableEntityException({\n code,\n errors,\n message,\n requestID,\n });\n }\n case 404: {\n throw new NotFoundException({\n code,\n message,\n path,\n requestID,\n });\n }\n case 429: {\n const retryAfter = headers.get('Retry-After');\n\n throw new RateLimitExceededException(\n data.message,\n requestID,\n retryAfter ? Number(retryAfter) : null,\n );\n }\n default: {\n if (error || errorDescription) {\n throw new OauthException(\n status,\n requestID,\n error,\n errorDescription,\n data,\n );\n } else if (code && errors) {\n // Note: ideally this should be mapped directly with a `400` status code.\n // However, this would break existing logic for the `OauthException` exception.\n throw new BadRequestException({\n code,\n errors,\n message,\n requestID,\n });\n } else {\n throw new GenericServerException(\n status,\n data.message,\n data,\n requestID,\n );\n }\n }\n }\n }\n }\n}\n"],"mappings":";;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,2BAA2B;AAEpC,SAAqB,uBAAuB;AAC5C,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAElC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,MAAM,UAAU;AAEhB,MAAM,mBAAmB;AAEzB,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAEtB,MAAM,OAAO;AAAA,EAqBlB,YACW,KACA,UAAyB,CAAC,GACnC;AAFS;AACA;AAET,QAAI,CAAC,KAAK;AACR,WAAK,MAAM,OAAO,gBAAgB;AAElC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AAA,QACA,KAAK,KAAK;AACR,gBAAM,IAAI,kBAAkB;AAAA,YAC1B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,aAAa,QAAQ,IAAI,aAAa;AAE5C,gBAAM,IAAI;AAAA,YACR,KAAK;AAAA,YACL;AAAA,YACA,aAAa,OAAO,UAAU,IAAI;AAAA,UACpC;AAAA,QACF;AAAA,QACA,SAAS;AACP,cAAIA,UAAS,kBAAkB;AAC7B,kBAAM,IAAI;AAAA,cACR;AAAA,cACA;AAAA,cACAA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF,WAAW,QAAQ,QAAQ;AAGzB,kBAAM,IAAI,oBAAoB;AAAA,cAC5B;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH,OAAO;AACL,kBAAM,IAAI;AAAA,cACR;AAAA,cACA,KAAK;AAAA,cACL;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["error"]}
|
|
1
|
+
{"version":3,"sources":["../../src/workos.ts"],"sourcesContent":["import {\n GenericServerException,\n NoApiKeyProvidedException,\n NotFoundException,\n UnauthorizedException,\n UnprocessableEntityException,\n OauthException,\n RateLimitExceededException,\n} from './common/exceptions';\nimport {\n GetOptions,\n HttpClientResponseInterface,\n PostOptions,\n PutOptions,\n WorkOSOptions,\n WorkOSResponseError,\n} from './common/interfaces';\nimport { DirectorySync } from './directory-sync/directory-sync';\nimport { Events } from './events/events';\nimport { Organizations } from './organizations/organizations';\nimport { OrganizationDomains } from './organization-domains/organization-domains';\nimport { Passwordless } from './passwordless/passwordless';\nimport { Portal } from './portal/portal';\nimport { SSO } from './sso/sso';\nimport { Webhooks } from './webhooks/webhooks';\nimport { Mfa } from './mfa/mfa';\nimport { AuditLogs } from './audit-logs/audit-logs';\nimport { UserManagement } from './user-management/user-management';\nimport { FGA } from './fga/fga';\nimport { BadRequestException } from './common/exceptions/bad-request.exception';\n\nimport { HttpClient, HttpClientError } from './common/net/http-client';\nimport { SubtleCryptoProvider } from './common/crypto/subtle-crypto-provider';\nimport { FetchHttpClient } from './common/net/fetch-client';\nimport { Widgets } from './widgets/widgets';\nimport { Actions } from './actions/actions';\nimport { Vault } from './vault/vault';\nimport { ConflictException } from './common/exceptions/conflict.exception';\nimport { CryptoProvider } from './common/crypto/crypto-provider';\nimport { ParseError } from './common/exceptions/parse-error';\nimport { getEnv } from './common/utils/env';\n\nconst VERSION = '8.0.0-beta.4';\n\nconst DEFAULT_HOSTNAME = 'api.workos.com';\n\nconst HEADER_AUTHORIZATION = 'Authorization';\nconst HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';\nconst HEADER_WARRANT_TOKEN = 'Warrant-Token';\n\nexport class WorkOS {\n readonly baseURL: string;\n readonly client: HttpClient;\n readonly clientId?: string;\n\n readonly actions: Actions;\n readonly auditLogs = new AuditLogs(this);\n readonly directorySync = new DirectorySync(this);\n readonly organizations = new Organizations(this);\n readonly organizationDomains = new OrganizationDomains(this);\n readonly passwordless = new Passwordless(this);\n readonly portal = new Portal(this);\n readonly sso = new SSO(this);\n readonly webhooks: Webhooks;\n readonly mfa = new Mfa(this);\n readonly events = new Events(this);\n readonly userManagement: UserManagement;\n readonly fga = new FGA(this);\n readonly widgets = new Widgets(this);\n readonly vault = new Vault(this);\n\n constructor(\n readonly key?: string,\n readonly options: WorkOSOptions = {},\n ) {\n if (!key) {\n this.key = getEnv('WORKOS_API_KEY');\n\n if (!this.key) {\n throw new NoApiKeyProvidedException();\n }\n }\n\n if (this.options.https === undefined) {\n this.options.https = true;\n }\n\n this.clientId = this.options.clientId;\n if (!this.clientId) {\n this.clientId = getEnv('WORKOS_CLIENT_ID');\n }\n\n const protocol: string = this.options.https ? 'https' : 'http';\n const apiHostname: string = this.options.apiHostname || DEFAULT_HOSTNAME;\n const port: number | undefined = this.options.port;\n this.baseURL = `${protocol}://${apiHostname}`;\n\n if (port) {\n this.baseURL = this.baseURL + `:${port}`;\n }\n\n let userAgent: string = `workos-node/${VERSION}`;\n\n if (options.appInfo) {\n const { name, version }: { name: string; version: string } =\n options.appInfo;\n userAgent += ` ${name}: ${version}`;\n }\n\n this.webhooks = this.createWebhookClient();\n this.actions = this.createActionsClient();\n\n // Must initialize UserManagement after baseURL is configured\n this.userManagement = new UserManagement(this);\n\n this.client = this.createHttpClient(options, userAgent);\n }\n\n createWebhookClient() {\n return new Webhooks(this.getCryptoProvider());\n }\n\n createActionsClient() {\n return new Actions(this.getCryptoProvider());\n }\n\n getCryptoProvider(): CryptoProvider {\n return new SubtleCryptoProvider();\n }\n\n createHttpClient(options: WorkOSOptions, userAgent: string) {\n return new FetchHttpClient(this.baseURL, {\n ...options.config,\n timeout: options.timeout,\n headers: {\n ...options.config?.headers,\n Authorization: `Bearer ${this.key}`,\n 'User-Agent': userAgent,\n },\n }) as HttpClient;\n }\n\n get version() {\n return VERSION;\n }\n\n async post<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PostOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.post<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async get<Result = any>(\n path: string,\n options: GetOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.accessToken) {\n requestHeaders[HEADER_AUTHORIZATION] = `Bearer ${options.accessToken}`;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n try {\n res = await this.client.get(path, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async put<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PutOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.put<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async delete(path: string, query?: any): Promise<void> {\n try {\n await this.client.delete(path, {\n params: query,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n }\n\n emitWarning(warning: string) {\n // tslint:disable-next-line:no-console\n console.warn(`WorkOS: ${warning}`);\n }\n\n private async handleParseError(\n error: unknown,\n res: HttpClientResponseInterface,\n ) {\n if (error instanceof SyntaxError) {\n const rawResponse = res.getRawResponse() as Response;\n const requestID = rawResponse.headers.get('X-Request-ID') ?? '';\n const rawStatus = rawResponse.status;\n const rawBody = await rawResponse.text();\n throw new ParseError({\n message: error.message,\n rawBody,\n rawStatus,\n requestID,\n });\n }\n }\n\n private handleHttpError({ path, error }: { path: string; error: unknown }) {\n if (!(error instanceof HttpClientError)) {\n throw new Error(`Unexpected error: ${error}`, { cause: error });\n }\n\n const { response } = error as HttpClientError<WorkOSResponseError>;\n\n if (response) {\n const { status, data, headers } = response;\n\n const requestID = headers['X-Request-ID'] ?? '';\n const {\n code,\n error_description: errorDescription,\n error,\n errors,\n message,\n } = data;\n\n switch (status) {\n case 401: {\n throw new UnauthorizedException(requestID);\n }\n case 409: {\n throw new ConflictException({ requestID, message, error });\n }\n case 422: {\n throw new UnprocessableEntityException({\n code,\n errors,\n message,\n requestID,\n });\n }\n case 404: {\n throw new NotFoundException({\n code,\n message,\n path,\n requestID,\n });\n }\n case 429: {\n const retryAfter = headers.get('Retry-After');\n\n throw new RateLimitExceededException(\n data.message,\n requestID,\n retryAfter ? Number(retryAfter) : null,\n );\n }\n default: {\n if (error || errorDescription) {\n throw new OauthException(\n status,\n requestID,\n error,\n errorDescription,\n data,\n );\n } else if (code && errors) {\n // Note: ideally this should be mapped directly with a `400` status code.\n // However, this would break existing logic for the `OauthException` exception.\n throw new BadRequestException({\n code,\n errors,\n message,\n requestID,\n });\n } else {\n throw new GenericServerException(\n status,\n data.message,\n data,\n requestID,\n );\n }\n }\n }\n }\n }\n}\n"],"mappings":";;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,2BAA2B;AAEpC,SAAqB,uBAAuB;AAC5C,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAElC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,MAAM,UAAU;AAEhB,MAAM,mBAAmB;AAEzB,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAEtB,MAAM,OAAO;AA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AAAA,QAC3D;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,IAAI,6BAA6B;AAAA,YACrC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,IAAI,kBAAkB;AAAA,YAC1B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,aAAa,QAAQ,IAAI,aAAa;AAE5C,gBAAM,IAAI;AAAA,YACR,KAAK;AAAA,YACL;AAAA,YACA,aAAa,OAAO,UAAU,IAAI;AAAA,UACpC;AAAA,QACF;AAAA,QACA,SAAS;AACP,cAAIA,UAAS,kBAAkB;AAC7B,kBAAM,IAAI;AAAA,cACR;AAAA,cACA;AAAA,cACAA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF,WAAW,QAAQ,QAAQ;AAGzB,kBAAM,IAAI,oBAAoB;AAAA,cAC5B;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH,OAAO;AACL,kBAAM,IAAI;AAAA,cACR;AAAA,cACA,KAAK;AAAA,cACL;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["error"]}
|
package/lib/index.js
CHANGED
|
@@ -43,7 +43,7 @@ class WorkOSNode extends workos_1.WorkOS {
|
|
|
43
43
|
/** @override */
|
|
44
44
|
createHttpClient(options, userAgent) {
|
|
45
45
|
var _a;
|
|
46
|
-
const opts = Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) });
|
|
46
|
+
const opts = Object.assign(Object.assign({}, options.config), { timeout: options.timeout, headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) });
|
|
47
47
|
if (typeof fetch !== 'undefined' ||
|
|
48
48
|
typeof options.fetchFn !== 'undefined') {
|
|
49
49
|
return new fetch_client_1.FetchHttpClient(this.baseURL, opts, options.fetchFn);
|
|
@@ -2,7 +2,6 @@ import { AutoPaginatable } from '../common/utils/pagination';
|
|
|
2
2
|
import { WorkOS } from '../workos';
|
|
3
3
|
import { CreateOrganizationOptions, CreateOrganizationRequestOptions, ListOrganizationsOptions, Organization, UpdateOrganizationOptions } from './interfaces';
|
|
4
4
|
import { FeatureFlag } from './interfaces/feature-flag.interface';
|
|
5
|
-
import { List } from '../common/interfaces';
|
|
6
5
|
import { RoleList } from '../roles/interfaces';
|
|
7
6
|
import { ListOrganizationRolesOptions } from './interfaces/list-organization-roles-options.interface';
|
|
8
7
|
import { ListOrganizationFeatureFlagsOptions } from './interfaces/list-organization-feature-flags-options.interface';
|
|
@@ -16,5 +15,5 @@ export declare class Organizations {
|
|
|
16
15
|
getOrganizationByExternalId(externalId: string): Promise<Organization>;
|
|
17
16
|
updateOrganization(options: UpdateOrganizationOptions): Promise<Organization>;
|
|
18
17
|
listOrganizationRoles(options: ListOrganizationRolesOptions): Promise<RoleList>;
|
|
19
|
-
listOrganizationFeatureFlags(options: ListOrganizationFeatureFlagsOptions): Promise<
|
|
18
|
+
listOrganizationFeatureFlags(options: ListOrganizationFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
20
19
|
}
|
|
@@ -24,7 +24,6 @@ exports.Organizations = void 0;
|
|
|
24
24
|
const pagination_1 = require("../common/utils/pagination");
|
|
25
25
|
const serializers_1 = require("./serializers");
|
|
26
26
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
27
|
-
const serializers_2 = require("../common/serializers");
|
|
28
27
|
const role_serializer_1 = require("../roles/serializers/role.serializer");
|
|
29
28
|
const feature_flag_serializer_1 = require("./serializers/feature-flag.serializer");
|
|
30
29
|
class Organizations {
|
|
@@ -78,9 +77,8 @@ class Organizations {
|
|
|
78
77
|
}
|
|
79
78
|
listOrganizationFeatureFlags(options) {
|
|
80
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const { organizationId } = options;
|
|
82
|
-
|
|
83
|
-
return (0, serializers_2.deserializeList)(data, feature_flag_serializer_1.deserializeFeatureFlag);
|
|
80
|
+
const { organizationId } = options, paginationOptions = __rest(options, ["organizationId"]);
|
|
81
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/organizations/${organizationId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, paginationOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/organizations/${organizationId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, params), paginationOptions);
|
|
84
82
|
});
|
|
85
83
|
}
|
|
86
84
|
}
|
|
@@ -362,7 +362,7 @@ describe('Organizations', () => {
|
|
|
362
362
|
const { data, object, listMetadata } = yield workos.organizations.listOrganizationFeatureFlags({
|
|
363
363
|
organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
364
364
|
});
|
|
365
|
-
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/
|
|
365
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/feature-flags');
|
|
366
366
|
expect(object).toEqual('list');
|
|
367
367
|
expect(listMetadata).toEqual({});
|
|
368
368
|
expect(data).toHaveLength(3);
|
|
@@ -396,5 +396,50 @@ describe('Organizations', () => {
|
|
|
396
396
|
},
|
|
397
397
|
]);
|
|
398
398
|
}));
|
|
399
|
+
describe('with the before option', () => {
|
|
400
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
401
|
+
(0, test_utils_1.fetchOnce)(list_organization_feature_flags_json_1.default);
|
|
402
|
+
const { data } = yield workos.organizations.listOrganizationFeatureFlags({
|
|
403
|
+
organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
404
|
+
before: 'flag_before_id',
|
|
405
|
+
});
|
|
406
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
407
|
+
before: 'flag_before_id',
|
|
408
|
+
order: 'desc',
|
|
409
|
+
});
|
|
410
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/feature-flags');
|
|
411
|
+
expect(data).toHaveLength(3);
|
|
412
|
+
}));
|
|
413
|
+
});
|
|
414
|
+
describe('with the after option', () => {
|
|
415
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
416
|
+
(0, test_utils_1.fetchOnce)(list_organization_feature_flags_json_1.default);
|
|
417
|
+
const { data } = yield workos.organizations.listOrganizationFeatureFlags({
|
|
418
|
+
organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
419
|
+
after: 'flag_after_id',
|
|
420
|
+
});
|
|
421
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
422
|
+
after: 'flag_after_id',
|
|
423
|
+
order: 'desc',
|
|
424
|
+
});
|
|
425
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/feature-flags');
|
|
426
|
+
expect(data).toHaveLength(3);
|
|
427
|
+
}));
|
|
428
|
+
});
|
|
429
|
+
describe('with the limit option', () => {
|
|
430
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
431
|
+
(0, test_utils_1.fetchOnce)(list_organization_feature_flags_json_1.default);
|
|
432
|
+
const { data } = yield workos.organizations.listOrganizationFeatureFlags({
|
|
433
|
+
organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
434
|
+
limit: 10,
|
|
435
|
+
});
|
|
436
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
437
|
+
limit: '10',
|
|
438
|
+
order: 'desc',
|
|
439
|
+
});
|
|
440
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/feature-flags');
|
|
441
|
+
expect(data).toHaveLength(3);
|
|
442
|
+
}));
|
|
443
|
+
});
|
|
399
444
|
});
|
|
400
445
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
|
|
2
|
+
import { OauthTokens, OauthTokensResponse } from '../../user-management/interfaces/oauth-tokens.interface';
|
|
2
3
|
import { Profile, ProfileResponse } from './profile.interface';
|
|
3
4
|
export interface ProfileAndToken<CustomAttributesType extends UnknownRecord> {
|
|
4
5
|
accessToken: string;
|
|
5
6
|
profile: Profile<CustomAttributesType>;
|
|
7
|
+
oauthTokens?: OauthTokens;
|
|
6
8
|
}
|
|
7
9
|
export interface ProfileAndTokenResponse<CustomAttributesType extends UnknownRecord> {
|
|
8
10
|
access_token: string;
|
|
9
11
|
profile: ProfileResponse<CustomAttributesType>;
|
|
12
|
+
oauth_tokens?: OauthTokensResponse;
|
|
10
13
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeProfileAndToken = void 0;
|
|
4
|
+
const oauth_tokens_serializer_1 = require("../../user-management/serializers/oauth-tokens.serializer");
|
|
4
5
|
const profile_serializer_1 = require("./profile.serializer");
|
|
5
6
|
const deserializeProfileAndToken = (profileAndToken) => ({
|
|
6
7
|
accessToken: profileAndToken.access_token,
|
|
7
8
|
profile: (0, profile_serializer_1.deserializeProfile)(profileAndToken.profile),
|
|
9
|
+
oauthTokens: (0, oauth_tokens_serializer_1.deserializeOauthTokens)(profileAndToken.oauth_tokens),
|
|
8
10
|
});
|
|
9
11
|
exports.deserializeProfileAndToken = deserializeProfileAndToken;
|
package/lib/sso/sso.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class SSO {
|
|
|
7
7
|
constructor(workos: WorkOS);
|
|
8
8
|
listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection>>;
|
|
9
9
|
deleteConnection(id: string): Promise<void>;
|
|
10
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }: SSOAuthorizationURLOptions): string;
|
|
10
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerQueryParams, providerScopes, redirectUri, state, }: SSOAuthorizationURLOptions): string;
|
|
11
11
|
getConnection(id: string): Promise<Connection>;
|
|
12
12
|
getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
|
|
13
13
|
getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
|
package/lib/sso/sso.js
CHANGED
|
@@ -8,21 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.SSO = void 0;
|
|
16
|
+
const qs_1 = __importDefault(require("qs"));
|
|
13
17
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
14
18
|
const pagination_1 = require("../common/utils/pagination");
|
|
15
19
|
const serializers_1 = require("./serializers");
|
|
16
20
|
const toQueryString = (options) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return searchParams.toString();
|
|
21
|
+
return qs_1.default.stringify(options, {
|
|
22
|
+
arrayFormat: 'repeat',
|
|
23
|
+
// sorts the keys alphabetically to maintain backwards compatibility
|
|
24
|
+
sort: (a, b) => a.localeCompare(b),
|
|
25
|
+
// encodes space as + instead of %20 to maintain backwards compatibility
|
|
26
|
+
format: 'RFC1738',
|
|
27
|
+
});
|
|
26
28
|
};
|
|
27
29
|
class SSO {
|
|
28
30
|
constructor(workos) {
|
|
@@ -38,7 +40,7 @@ class SSO {
|
|
|
38
40
|
yield this.workos.delete(`/connections/${id}`);
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }) {
|
|
43
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerQueryParams, providerScopes, redirectUri, state, }) {
|
|
42
44
|
if (!domain && !provider && !connection && !organization) {
|
|
43
45
|
throw new Error(`Incomplete arguments. Need to specify either a 'connection', 'organization', 'domain', or 'provider'.`);
|
|
44
46
|
}
|
|
@@ -52,6 +54,8 @@ class SSO {
|
|
|
52
54
|
domain_hint: domainHint,
|
|
53
55
|
login_hint: loginHint,
|
|
54
56
|
provider,
|
|
57
|
+
provider_query_params: providerQueryParams,
|
|
58
|
+
provider_scopes: providerScopes,
|
|
55
59
|
client_id: clientId,
|
|
56
60
|
redirect_uri: redirectUri,
|
|
57
61
|
response_type: 'code',
|
package/lib/sso/sso.spec.js
CHANGED
|
@@ -161,6 +161,54 @@ describe('SSO', () => {
|
|
|
161
161
|
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
|
+
describe('with providerScopes', () => {
|
|
165
|
+
it('generates an authorize url with the provided provider scopes', () => {
|
|
166
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
167
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
168
|
+
provider: 'Google',
|
|
169
|
+
providerScopes: ['profile', 'email', 'calendar'],
|
|
170
|
+
clientId: 'proj_123',
|
|
171
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
172
|
+
});
|
|
173
|
+
expect(url).toMatchSnapshot();
|
|
174
|
+
});
|
|
175
|
+
it('handles empty provider scopes array', () => {
|
|
176
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
177
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
178
|
+
provider: 'Google',
|
|
179
|
+
providerScopes: [],
|
|
180
|
+
clientId: 'proj_123',
|
|
181
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
182
|
+
});
|
|
183
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
describe('with providerQueryParams', () => {
|
|
187
|
+
it('generates an authorize url with the provided provider query params', () => {
|
|
188
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
189
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
190
|
+
provider: 'Google',
|
|
191
|
+
providerQueryParams: {
|
|
192
|
+
custom_param: 'custom_value',
|
|
193
|
+
another_param: 123,
|
|
194
|
+
bool_param: true,
|
|
195
|
+
},
|
|
196
|
+
clientId: 'proj_123',
|
|
197
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
198
|
+
});
|
|
199
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&provider_query_params%5Banother_param%5D=123&provider_query_params%5Bbool_param%5D=true&provider_query_params%5Bcustom_param%5D=custom_value&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
200
|
+
});
|
|
201
|
+
it('handles empty provider query params', () => {
|
|
202
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
203
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
204
|
+
provider: 'Google',
|
|
205
|
+
providerQueryParams: {},
|
|
206
|
+
clientId: 'proj_123',
|
|
207
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
208
|
+
});
|
|
209
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
164
212
|
});
|
|
165
213
|
describe('getProfileAndToken', () => {
|
|
166
214
|
describe('with all information provided', () => {
|
|
@@ -240,6 +288,89 @@ describe('SSO', () => {
|
|
|
240
288
|
expect(profile).toMatchSnapshot();
|
|
241
289
|
}));
|
|
242
290
|
});
|
|
291
|
+
describe('with oauth tokens in the response', () => {
|
|
292
|
+
it('returns the oauth tokens from the profile and token response', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
293
|
+
(0, test_utils_1.fetchOnce)({
|
|
294
|
+
access_token: '01DMEK0J53CVMC32CK5SE0KZ8Q',
|
|
295
|
+
profile: {
|
|
296
|
+
id: 'prof_123',
|
|
297
|
+
idp_id: '123',
|
|
298
|
+
organization_id: 'org_123',
|
|
299
|
+
connection_id: 'conn_123',
|
|
300
|
+
connection_type: 'OktaSAML',
|
|
301
|
+
email: 'foo@test.com',
|
|
302
|
+
first_name: 'foo',
|
|
303
|
+
last_name: 'bar',
|
|
304
|
+
role: {
|
|
305
|
+
slug: 'admin',
|
|
306
|
+
},
|
|
307
|
+
groups: ['Admins', 'Developers'],
|
|
308
|
+
raw_attributes: {
|
|
309
|
+
email: 'foo@test.com',
|
|
310
|
+
first_name: 'foo',
|
|
311
|
+
last_name: 'bar',
|
|
312
|
+
groups: ['Admins', 'Developers'],
|
|
313
|
+
},
|
|
314
|
+
custom_attributes: {},
|
|
315
|
+
},
|
|
316
|
+
oauth_tokens: {
|
|
317
|
+
access_token: 'oauth_access_token',
|
|
318
|
+
refresh_token: 'oauth_refresh_token',
|
|
319
|
+
expires_at: 1640995200,
|
|
320
|
+
scopes: ['profile', 'email'],
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
324
|
+
const { accessToken, profile, oauthTokens } = yield workos.sso.getProfileAndToken({
|
|
325
|
+
code: 'authorization_code',
|
|
326
|
+
clientId: 'proj_123',
|
|
327
|
+
});
|
|
328
|
+
expect(jest_fetch_mock_1.default.mock.calls.length).toEqual(1);
|
|
329
|
+
expect(accessToken).toBe('01DMEK0J53CVMC32CK5SE0KZ8Q');
|
|
330
|
+
expect(profile).toBeDefined();
|
|
331
|
+
expect(oauthTokens).toEqual({
|
|
332
|
+
accessToken: 'oauth_access_token',
|
|
333
|
+
refreshToken: 'oauth_refresh_token',
|
|
334
|
+
expiresAt: 1640995200,
|
|
335
|
+
scopes: ['profile', 'email'],
|
|
336
|
+
});
|
|
337
|
+
}));
|
|
338
|
+
});
|
|
339
|
+
describe('without oauth tokens in the response', () => {
|
|
340
|
+
it('returns undefined for oauth tokens when not present in response', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
(0, test_utils_1.fetchOnce)({
|
|
342
|
+
access_token: '01DMEK0J53CVMC32CK5SE0KZ8Q',
|
|
343
|
+
profile: {
|
|
344
|
+
id: 'prof_123',
|
|
345
|
+
idp_id: '123',
|
|
346
|
+
organization_id: 'org_123',
|
|
347
|
+
connection_id: 'conn_123',
|
|
348
|
+
connection_type: 'OktaSAML',
|
|
349
|
+
email: 'foo@test.com',
|
|
350
|
+
first_name: 'foo',
|
|
351
|
+
last_name: 'bar',
|
|
352
|
+
role: {
|
|
353
|
+
slug: 'admin',
|
|
354
|
+
},
|
|
355
|
+
raw_attributes: {
|
|
356
|
+
email: 'foo@test.com',
|
|
357
|
+
first_name: 'foo',
|
|
358
|
+
last_name: 'bar',
|
|
359
|
+
},
|
|
360
|
+
custom_attributes: {},
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
364
|
+
const { accessToken, profile, oauthTokens } = yield workos.sso.getProfileAndToken({
|
|
365
|
+
code: 'authorization_code',
|
|
366
|
+
clientId: 'proj_123',
|
|
367
|
+
});
|
|
368
|
+
expect(jest_fetch_mock_1.default.mock.calls.length).toEqual(1);
|
|
369
|
+
expect(accessToken).toBe('01DMEK0J53CVMC32CK5SE0KZ8Q');
|
|
370
|
+
expect(profile).toBeDefined();
|
|
371
|
+
expect(oauthTokens).toBeUndefined();
|
|
372
|
+
}));
|
|
373
|
+
});
|
|
243
374
|
});
|
|
244
375
|
describe('getProfile', () => {
|
|
245
376
|
it('calls the `/sso/profile` endpoint with the provided access token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -9,6 +9,7 @@ export interface AccessToken {
|
|
|
9
9
|
sid: string;
|
|
10
10
|
org_id?: string;
|
|
11
11
|
role?: string;
|
|
12
|
+
roles?: string[];
|
|
12
13
|
permissions?: string[];
|
|
13
14
|
entitlements?: string[];
|
|
14
15
|
feature_flags?: string[];
|
|
@@ -28,6 +29,7 @@ export type AuthenticateWithSessionCookieSuccessResponse = {
|
|
|
28
29
|
sessionId: string;
|
|
29
30
|
organizationId?: string;
|
|
30
31
|
role?: string;
|
|
32
|
+
roles?: string[];
|
|
31
33
|
permissions?: string[];
|
|
32
34
|
entitlements?: string[];
|
|
33
35
|
featureFlags?: string[];
|
package/lib/user-management/interfaces/create-organization-membership-options.interface.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ export interface CreateOrganizationMembershipOptions {
|
|
|
2
2
|
organizationId: string;
|
|
3
3
|
userId: string;
|
|
4
4
|
roleSlug?: string;
|
|
5
|
+
roleSlugs?: string[];
|
|
5
6
|
}
|
|
6
7
|
export interface SerializedCreateOrganizationMembershipOptions {
|
|
7
8
|
organization_id: string;
|
|
8
9
|
user_id: string;
|
|
9
10
|
role_slug?: string;
|
|
11
|
+
role_slugs?: string[];
|
|
10
12
|
}
|
|
@@ -10,6 +10,7 @@ export interface OrganizationMembership {
|
|
|
10
10
|
createdAt: string;
|
|
11
11
|
updatedAt: string;
|
|
12
12
|
role: RoleResponse;
|
|
13
|
+
roles?: RoleResponse[];
|
|
13
14
|
}
|
|
14
15
|
export interface OrganizationMembershipResponse {
|
|
15
16
|
object: 'organization_membership';
|
|
@@ -21,4 +22,5 @@ export interface OrganizationMembershipResponse {
|
|
|
21
22
|
created_at: string;
|
|
22
23
|
updated_at: string;
|
|
23
24
|
role: RoleResponse;
|
|
25
|
+
roles?: RoleResponse[];
|
|
24
26
|
}
|
package/lib/user-management/serializers/create-organization-membership-options.serializer.js
CHANGED
|
@@ -5,5 +5,6 @@ const serializeCreateOrganizationMembershipOptions = (options) => ({
|
|
|
5
5
|
organization_id: options.organizationId,
|
|
6
6
|
user_id: options.userId,
|
|
7
7
|
role_slug: options.roleSlug,
|
|
8
|
+
role_slugs: options.roleSlugs,
|
|
8
9
|
});
|
|
9
10
|
exports.serializeCreateOrganizationMembershipOptions = serializeCreateOrganizationMembershipOptions;
|