@workos-inc/node 7.16.0 → 7.17.1
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/common/interfaces/get-options.interface.d.ts +1 -0
- package/lib/common/interfaces/post-options.interface.d.ts +1 -0
- package/lib/common/utils/fetch-and-deserialize.d.ts +2 -2
- package/lib/common/utils/fetch-and-deserialize.js +2 -4
- package/lib/fga/fga-live-test.spec.d.ts +1 -0
- package/lib/fga/fga-live-test.spec.js +872 -0
- package/lib/fga/fga.d.ts +18 -0
- package/lib/fga/fga.js +105 -0
- package/lib/fga/fga.spec.d.ts +1 -0
- package/lib/fga/fga.spec.js +518 -0
- package/lib/fga/interfaces/check-op.enum.d.ts +5 -0
- package/lib/fga/interfaces/check-op.enum.js +9 -0
- package/lib/fga/interfaces/check.interface.d.ts +71 -0
- package/lib/fga/interfaces/check.interface.js +21 -0
- package/lib/fga/interfaces/index.d.ts +7 -0
- package/lib/fga/interfaces/index.js +23 -0
- package/lib/fga/interfaces/query.interface.d.ts +30 -0
- package/lib/fga/interfaces/query.interface.js +2 -0
- package/lib/fga/interfaces/resource.interface.d.ts +60 -0
- package/lib/fga/interfaces/resource.interface.js +2 -0
- package/lib/fga/interfaces/warrant-op.enum.d.ts +4 -0
- package/lib/fga/interfaces/warrant-op.enum.js +8 -0
- package/lib/fga/interfaces/warrant-token.interface.d.ts +6 -0
- package/lib/fga/interfaces/warrant-token.interface.js +2 -0
- package/lib/fga/interfaces/warrant.interface.d.ts +65 -0
- package/lib/fga/interfaces/warrant.interface.js +2 -0
- package/lib/fga/serializers/check-options.serializer.d.ts +4 -0
- package/lib/fga/serializers/check-options.serializer.js +62 -0
- package/lib/fga/serializers/create-resource-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/create-resource-options.serializer.js +16 -0
- package/lib/fga/serializers/delete-resource-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/delete-resource-options.serializer.js +15 -0
- package/lib/fga/serializers/index.d.ts +11 -0
- package/lib/fga/serializers/index.js +27 -0
- package/lib/fga/serializers/list-resources-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/list-resources-options.serializer.js +12 -0
- package/lib/fga/serializers/list-warrants-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/list-warrants-options.serializer.js +14 -0
- package/lib/fga/serializers/query-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/query-options.serializer.js +12 -0
- package/lib/fga/serializers/query-result.serializer.d.ts +2 -0
- package/lib/fga/serializers/query-result.serializer.js +21 -0
- package/lib/fga/serializers/resource.serializer.d.ts +2 -0
- package/lib/fga/serializers/resource.serializer.js +9 -0
- package/lib/fga/serializers/warrant-token.serializer.d.ts +2 -0
- package/lib/fga/serializers/warrant-token.serializer.js +7 -0
- package/lib/fga/serializers/warrant.serializer.d.ts +2 -0
- package/lib/fga/serializers/warrant.serializer.js +14 -0
- package/lib/fga/serializers/write-warrant-options.serializer.d.ts +2 -0
- package/lib/fga/serializers/write-warrant-options.serializer.js +27 -0
- package/lib/fga/utils/interface-check.d.ts +3 -0
- package/lib/fga/utils/interface-check.js +15 -0
- package/lib/user-management/interfaces/refresh-and-seal-session-data.interface.d.ts +4 -0
- package/lib/user-management/interfaces/refresh-and-seal-session-data.interface.js +4 -0
- package/lib/user-management/user-management.js +2 -2
- package/lib/workos.d.ts +2 -0
- package/lib/workos.js +19 -7
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isResourceInterface = exports.isSubject = void 0;
|
|
4
|
+
function isSubject(resource) {
|
|
5
|
+
return (Object.prototype.hasOwnProperty.call(resource, 'resourceType') &&
|
|
6
|
+
Object.prototype.hasOwnProperty.call(resource, 'resourceId'));
|
|
7
|
+
}
|
|
8
|
+
exports.isSubject = isSubject;
|
|
9
|
+
function isResourceInterface(resource) {
|
|
10
|
+
return (!!resource &&
|
|
11
|
+
typeof resource === 'object' &&
|
|
12
|
+
'getResouceType' in resource &&
|
|
13
|
+
'getResourceId' in resource);
|
|
14
|
+
}
|
|
15
|
+
exports.isResourceInterface = isResourceInterface;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export declare enum RefreshAndSealSessionDataFailureReason {
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated To be removed in a future major version.
|
|
4
|
+
*/
|
|
2
5
|
INVALID_SESSION_COOKE = "invalid_session_cookie",
|
|
6
|
+
INVALID_SESSION_COOKIE = "invalid_session_cookie",
|
|
3
7
|
NO_SESSION_COOKIE_PROVIDED = "no_session_cookie_provided",
|
|
4
8
|
INVALID_GRANT = "invalid_grant",
|
|
5
9
|
ORGANIZATION_NOT_AUTHORIZED = "organization_not_authorized"
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RefreshAndSealSessionDataFailureReason = void 0;
|
|
4
4
|
var RefreshAndSealSessionDataFailureReason;
|
|
5
5
|
(function (RefreshAndSealSessionDataFailureReason) {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated To be removed in a future major version.
|
|
8
|
+
*/
|
|
6
9
|
RefreshAndSealSessionDataFailureReason["INVALID_SESSION_COOKE"] = "invalid_session_cookie";
|
|
10
|
+
RefreshAndSealSessionDataFailureReason["INVALID_SESSION_COOKIE"] = "invalid_session_cookie";
|
|
7
11
|
RefreshAndSealSessionDataFailureReason["NO_SESSION_COOKIE_PROVIDED"] = "no_session_cookie_provided";
|
|
8
12
|
// API OauthErrors for refresh tokens
|
|
9
13
|
RefreshAndSealSessionDataFailureReason["INVALID_GRANT"] = "invalid_grant";
|
|
@@ -220,7 +220,7 @@ class UserManagement {
|
|
|
220
220
|
if (!session.refreshToken || !session.user) {
|
|
221
221
|
return {
|
|
222
222
|
authenticated: false,
|
|
223
|
-
reason: refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.
|
|
223
|
+
reason: refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.INVALID_SESSION_COOKIE,
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
try {
|
|
@@ -232,7 +232,7 @@ class UserManagement {
|
|
|
232
232
|
if (!sealedSession) {
|
|
233
233
|
return {
|
|
234
234
|
authenticated: false,
|
|
235
|
-
reason: refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.
|
|
235
|
+
reason: refresh_and_seal_session_data_interface_1.RefreshAndSealSessionDataFailureReason.INVALID_SESSION_COOKIE,
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
return { authenticated: true, sealedSession };
|
package/lib/workos.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Webhooks } from './webhooks/webhooks';
|
|
|
10
10
|
import { Mfa } from './mfa/mfa';
|
|
11
11
|
import { AuditLogs } from './audit-logs/audit-logs';
|
|
12
12
|
import { UserManagement } from './user-management/user-management';
|
|
13
|
+
import { FGA } from './fga/fga';
|
|
13
14
|
import { HttpClient } from './common/net/http-client';
|
|
14
15
|
export declare class WorkOS {
|
|
15
16
|
readonly key?: string | undefined;
|
|
@@ -28,6 +29,7 @@ export declare class WorkOS {
|
|
|
28
29
|
readonly mfa: Mfa;
|
|
29
30
|
readonly events: Events;
|
|
30
31
|
readonly userManagement: UserManagement;
|
|
32
|
+
readonly fga: FGA;
|
|
31
33
|
constructor(key?: string | undefined, options?: WorkOSOptions);
|
|
32
34
|
createWebhookClient(): Webhooks;
|
|
33
35
|
createHttpClient(options: WorkOSOptions, userAgent: string): HttpClient;
|
package/lib/workos.js
CHANGED
|
@@ -22,12 +22,16 @@ const webhooks_1 = require("./webhooks/webhooks");
|
|
|
22
22
|
const mfa_1 = require("./mfa/mfa");
|
|
23
23
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
24
24
|
const user_management_1 = require("./user-management/user-management");
|
|
25
|
+
const fga_1 = require("./fga/fga");
|
|
25
26
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
26
27
|
const http_client_1 = require("./common/net/http-client");
|
|
27
28
|
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
28
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
29
|
-
const VERSION = '7.
|
|
30
|
+
const VERSION = '7.17.1';
|
|
30
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
|
+
const HEADER_AUTHORIZATION = 'Authorization';
|
|
33
|
+
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
|
34
|
+
const HEADER_WARRANT_TOKEN = 'Warrant-Token';
|
|
31
35
|
class WorkOS {
|
|
32
36
|
constructor(key, options = {}) {
|
|
33
37
|
var _a;
|
|
@@ -42,6 +46,7 @@ class WorkOS {
|
|
|
42
46
|
this.sso = new sso_1.SSO(this);
|
|
43
47
|
this.mfa = new mfa_1.Mfa(this);
|
|
44
48
|
this.events = new events_1.Events(this);
|
|
49
|
+
this.fga = new fga_1.FGA(this);
|
|
45
50
|
if (!key) {
|
|
46
51
|
// process might be undefined in some environments
|
|
47
52
|
this.key = process === null || process === void 0 ? void 0 : process.env.WORKOS_API_KEY;
|
|
@@ -84,7 +89,10 @@ class WorkOS {
|
|
|
84
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
90
|
const requestHeaders = {};
|
|
86
91
|
if (options.idempotencyKey) {
|
|
87
|
-
requestHeaders[
|
|
92
|
+
requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;
|
|
93
|
+
}
|
|
94
|
+
if (options.warrantToken) {
|
|
95
|
+
requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;
|
|
88
96
|
}
|
|
89
97
|
try {
|
|
90
98
|
const res = yield this.client.post(path, entity, {
|
|
@@ -101,13 +109,17 @@ class WorkOS {
|
|
|
101
109
|
}
|
|
102
110
|
get(path, options = {}) {
|
|
103
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const requestHeaders = {};
|
|
113
|
+
if (options.accessToken) {
|
|
114
|
+
requestHeaders[HEADER_AUTHORIZATION] = `Bearer ${options.accessToken}`;
|
|
115
|
+
}
|
|
116
|
+
if (options.warrantToken) {
|
|
117
|
+
requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;
|
|
118
|
+
}
|
|
104
119
|
try {
|
|
105
|
-
const { accessToken } = options;
|
|
106
120
|
const res = yield this.client.get(path, {
|
|
107
121
|
params: options.query,
|
|
108
|
-
headers:
|
|
109
|
-
? { Authorization: `Bearer ${accessToken}` }
|
|
110
|
-
: undefined,
|
|
122
|
+
headers: requestHeaders,
|
|
111
123
|
});
|
|
112
124
|
return { data: yield res.toJSON() };
|
|
113
125
|
}
|
|
@@ -121,7 +133,7 @@ class WorkOS {
|
|
|
121
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
134
|
const requestHeaders = {};
|
|
123
135
|
if (options.idempotencyKey) {
|
|
124
|
-
requestHeaders[
|
|
136
|
+
requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;
|
|
125
137
|
}
|
|
126
138
|
try {
|
|
127
139
|
const res = yield this.client.put(path, entity, {
|
package/package.json
CHANGED