@workos-inc/node 7.40.0 → 7.41.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.
- package/lib/actions/actions.spec.js +1 -0
- package/lib/organizations/interfaces/create-organization-options.interface.d.ts +2 -0
- package/lib/organizations/interfaces/organization.interface.d.ts +2 -0
- package/lib/organizations/interfaces/update-organization-options.interface.d.ts +2 -0
- package/lib/organizations/organizations.d.ts +1 -0
- package/lib/organizations/organizations.js +6 -0
- package/lib/organizations/organizations.spec.js +13 -0
- package/lib/organizations/serializers/create-organization-options.serializer.js +1 -0
- package/lib/organizations/serializers/organization.serializer.js +6 -3
- package/lib/organizations/serializers/update-organization-options.serializer.js +1 -0
- package/lib/user-management/session.js +1 -4
- package/lib/user-management/user-management.d.ts +3 -1
- package/lib/user-management/user-management.js +10 -5
- package/lib/workos.js +1 -1
- package/package.json +1 -2
|
@@ -3,6 +3,7 @@ import { DomainData } from './domain-data.interface';
|
|
|
3
3
|
export interface CreateOrganizationOptions {
|
|
4
4
|
name: string;
|
|
5
5
|
domainData?: DomainData[];
|
|
6
|
+
externalId?: string | null;
|
|
6
7
|
/**
|
|
7
8
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
8
9
|
*/
|
|
@@ -15,6 +16,7 @@ export interface CreateOrganizationOptions {
|
|
|
15
16
|
export interface SerializedCreateOrganizationOptions {
|
|
16
17
|
name: string;
|
|
17
18
|
domain_data?: DomainData[];
|
|
19
|
+
external_id?: string | null;
|
|
18
20
|
/**
|
|
19
21
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
20
22
|
*/
|
|
@@ -8,6 +8,7 @@ export interface Organization {
|
|
|
8
8
|
stripeCustomerId?: string;
|
|
9
9
|
createdAt: string;
|
|
10
10
|
updatedAt: string;
|
|
11
|
+
externalId: string | null;
|
|
11
12
|
}
|
|
12
13
|
export interface OrganizationResponse {
|
|
13
14
|
object: 'organization';
|
|
@@ -18,4 +19,5 @@ export interface OrganizationResponse {
|
|
|
18
19
|
stripe_customer_id?: string;
|
|
19
20
|
created_at: string;
|
|
20
21
|
updated_at: string;
|
|
22
|
+
external_id?: string | null;
|
|
21
23
|
}
|
|
@@ -4,6 +4,7 @@ export interface UpdateOrganizationOptions {
|
|
|
4
4
|
name?: string;
|
|
5
5
|
domainData?: DomainData[];
|
|
6
6
|
stripeCustomerId?: string | null;
|
|
7
|
+
externalId?: string | null;
|
|
7
8
|
/**
|
|
8
9
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
9
10
|
*/
|
|
@@ -17,6 +18,7 @@ export interface SerializedUpdateOrganizationOptions {
|
|
|
17
18
|
name?: string;
|
|
18
19
|
domain_data?: DomainData[];
|
|
19
20
|
stripe_customer_id?: string | null;
|
|
21
|
+
external_id?: string | null;
|
|
20
22
|
/**
|
|
21
23
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
22
24
|
*/
|
|
@@ -10,6 +10,7 @@ export declare class Organizations {
|
|
|
10
10
|
createOrganization(payload: CreateOrganizationOptions, requestOptions?: CreateOrganizationRequestOptions): Promise<Organization>;
|
|
11
11
|
deleteOrganization(id: string): Promise<void>;
|
|
12
12
|
getOrganization(id: string): Promise<Organization>;
|
|
13
|
+
getOrganizationByExternalId(externalId: string): Promise<Organization>;
|
|
13
14
|
updateOrganization(options: UpdateOrganizationOptions): Promise<Organization>;
|
|
14
15
|
listOrganizationRoles(options: ListOrganizationRolesOptions): Promise<RoleList>;
|
|
15
16
|
}
|
|
@@ -51,6 +51,12 @@ class Organizations {
|
|
|
51
51
|
return (0, serializers_1.deserializeOrganization)(data);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
getOrganizationByExternalId(externalId) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const { data } = yield this.workos.get(`/organizations/external_id/${externalId}`);
|
|
57
|
+
return (0, serializers_1.deserializeOrganization)(data);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
54
60
|
updateOrganization(options) {
|
|
55
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
62
|
const { organization: organizationId } = options, payload = __rest(options, ["organization"]);
|
|
@@ -194,6 +194,19 @@ describe('Organizations', () => {
|
|
|
194
194
|
]);
|
|
195
195
|
}));
|
|
196
196
|
});
|
|
197
|
+
describe('getOrganizationByExternalId', () => {
|
|
198
|
+
it('sends request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
|
+
const externalId = 'user_external_id';
|
|
200
|
+
const apiResponse = Object.assign(Object.assign({}, get_organization_json_1.default), { external_id: externalId });
|
|
201
|
+
(0, test_utils_1.fetchOnce)(apiResponse);
|
|
202
|
+
const organization = yield workos.organizations.getOrganizationByExternalId(externalId);
|
|
203
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/organizations/external_id/${externalId}`);
|
|
204
|
+
expect(organization).toMatchObject({
|
|
205
|
+
id: apiResponse.id,
|
|
206
|
+
externalId: apiResponse.external_id,
|
|
207
|
+
});
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
197
210
|
describe('deleteOrganization', () => {
|
|
198
211
|
it('sends request to delete an Organization', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
212
|
(0, test_utils_1.fetchOnce)();
|
|
@@ -6,5 +6,6 @@ const serializeCreateOrganizationOptions = (options) => ({
|
|
|
6
6
|
allow_profiles_outside_organization: options.allowProfilesOutsideOrganization,
|
|
7
7
|
domain_data: options.domainData,
|
|
8
8
|
domains: options.domains,
|
|
9
|
+
external_id: options.externalId,
|
|
9
10
|
});
|
|
10
11
|
exports.serializeCreateOrganizationOptions = serializeCreateOrganizationOptions;
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeOrganization = void 0;
|
|
4
4
|
const organization_domain_serializer_1 = require("../../organization-domains/serializers/organization-domain.serializer");
|
|
5
|
-
const deserializeOrganization = (organization) =>
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const deserializeOrganization = (organization) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return (Object.assign(Object.assign({ object: organization.object, id: organization.id, name: organization.name, allowProfilesOutsideOrganization: organization.allow_profiles_outside_organization, domains: organization.domains.map(organization_domain_serializer_1.deserializeOrganizationDomain) }, (typeof organization.stripe_customer_id === 'undefined'
|
|
8
|
+
? undefined
|
|
9
|
+
: { stripeCustomerId: organization.stripe_customer_id })), { createdAt: organization.created_at, updatedAt: organization.updated_at, externalId: (_a = organization.external_id) !== null && _a !== void 0 ? _a : null }));
|
|
10
|
+
};
|
|
8
11
|
exports.deserializeOrganization = deserializeOrganization;
|
|
@@ -7,5 +7,6 @@ const serializeUpdateOrganizationOptions = (options) => ({
|
|
|
7
7
|
domain_data: options.domainData,
|
|
8
8
|
domains: options.domains,
|
|
9
9
|
stripe_customer_id: options.stripeCustomerId,
|
|
10
|
+
external_id: options.externalId,
|
|
10
11
|
});
|
|
11
12
|
exports.serializeUpdateOrganizationOptions = serializeUpdateOrganizationOptions;
|
|
@@ -22,10 +22,7 @@ class Session {
|
|
|
22
22
|
this.ironSessionProvider = userManagement.ironSessionProvider;
|
|
23
23
|
this.cookiePassword = cookiePassword;
|
|
24
24
|
this.sessionData = sessionData;
|
|
25
|
-
|
|
26
|
-
this.jwks = clientId
|
|
27
|
-
? (0, jose_1.createRemoteJWKSet)(new URL(userManagement.getJwksUrl(clientId)))
|
|
28
|
-
: undefined;
|
|
25
|
+
this.jwks = this.userManagement.jwks;
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
28
|
* Authenticates a user with a session cookie.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRemoteJWKSet } from 'jose';
|
|
1
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
2
3
|
import { Challenge } from '../mfa/interfaces';
|
|
3
4
|
import { WorkOS } from '../workos';
|
|
@@ -22,10 +23,11 @@ import { IronSessionProvider } from '../common/iron-session/iron-session-provide
|
|
|
22
23
|
import { Session } from './session';
|
|
23
24
|
export declare class UserManagement {
|
|
24
25
|
private readonly workos;
|
|
25
|
-
private
|
|
26
|
+
private _jwks;
|
|
26
27
|
clientId: string | undefined;
|
|
27
28
|
ironSessionProvider: IronSessionProvider;
|
|
28
29
|
constructor(workos: WorkOS, ironSessionProvider: IronSessionProvider);
|
|
30
|
+
get jwks(): ReturnType<typeof createRemoteJWKSet> | undefined;
|
|
29
31
|
/**
|
|
30
32
|
* Loads a sealed session using the provided session data and cookie password.
|
|
31
33
|
*
|
|
@@ -60,12 +60,17 @@ class UserManagement {
|
|
|
60
60
|
const { clientId } = workos.options;
|
|
61
61
|
this.clientId = clientId;
|
|
62
62
|
this.ironSessionProvider = ironSessionProvider;
|
|
63
|
+
}
|
|
64
|
+
get jwks() {
|
|
65
|
+
var _a;
|
|
66
|
+
if (!this.clientId) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
63
69
|
// Set the JWKS URL. This is used to verify if the JWT is still valid
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
: undefined;
|
|
70
|
+
(_a = this._jwks) !== null && _a !== void 0 ? _a : (this._jwks = (0, jose_1.createRemoteJWKSet)(new URL(this.getJwksUrl(this.clientId)), {
|
|
71
|
+
cooldownDuration: 1000 * 60 * 5,
|
|
72
|
+
}));
|
|
73
|
+
return this._jwks;
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
71
76
|
* Loads a sealed session using the provided session data and cookie password.
|
package/lib/workos.js
CHANGED
|
@@ -29,7 +29,7 @@ const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider
|
|
|
29
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
30
30
|
const widgets_1 = require("./widgets/widgets");
|
|
31
31
|
const actions_1 = require("./actions/actions");
|
|
32
|
-
const VERSION = '7.
|
|
32
|
+
const VERSION = '7.41.0';
|
|
33
33
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
34
34
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
35
35
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|