workos 0.11.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -6
- package/dist/bin.js +22 -1
- package/dist/bin.js.map +1 -1
- package/dist/check-coverage.ts +237 -0
- package/dist/commands/debug.js +0 -1
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/dev.d.ts +23 -0
- package/dist/commands/dev.js +139 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/emulate.d.ts +6 -0
- package/dist/commands/emulate.js +64 -0
- package/dist/commands/emulate.js.map +1 -0
- package/dist/commands/login.js +0 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/emulate/core/id.d.ts +48 -0
- package/dist/emulate/core/id.js +73 -0
- package/dist/emulate/core/id.js.map +1 -0
- package/dist/emulate/core/index.d.ts +8 -0
- package/dist/emulate/core/index.js +8 -0
- package/dist/emulate/core/index.js.map +1 -0
- package/dist/emulate/core/jwt.d.ts +28 -0
- package/dist/emulate/core/jwt.js +78 -0
- package/dist/emulate/core/jwt.js.map +1 -0
- package/dist/emulate/core/middleware/auth.d.ts +15 -0
- package/dist/emulate/core/middleware/auth.js +17 -0
- package/dist/emulate/core/middleware/auth.js.map +1 -0
- package/dist/emulate/core/middleware/error-handler.d.ts +22 -0
- package/dist/emulate/core/middleware/error-handler.js +72 -0
- package/dist/emulate/core/middleware/error-handler.js.map +1 -0
- package/dist/emulate/core/pagination.d.ts +27 -0
- package/dist/emulate/core/pagination.js +43 -0
- package/dist/emulate/core/pagination.js.map +1 -0
- package/dist/emulate/core/plugin.d.ts +15 -0
- package/dist/emulate/core/plugin.js +2 -0
- package/dist/emulate/core/plugin.js.map +1 -0
- package/dist/emulate/core/server.d.ts +17 -0
- package/dist/emulate/core/server.js +90 -0
- package/dist/emulate/core/server.js.map +1 -0
- package/dist/emulate/core/store.d.ts +44 -0
- package/dist/emulate/core/store.js +169 -0
- package/dist/emulate/core/store.js.map +1 -0
- package/dist/emulate/index.d.ts +25 -0
- package/dist/emulate/index.js +47 -0
- package/dist/emulate/index.js.map +1 -0
- package/dist/emulate/workos/constants.d.ts +56 -0
- package/dist/emulate/workos/constants.js +56 -0
- package/dist/emulate/workos/constants.js.map +1 -0
- package/dist/emulate/workos/entities.d.ts +360 -0
- package/dist/emulate/workos/entities.js +2 -0
- package/dist/emulate/workos/entities.js.map +1 -0
- package/dist/emulate/workos/event-bus.d.ts +17 -0
- package/dist/emulate/workos/event-bus.js +70 -0
- package/dist/emulate/workos/event-bus.js.map +1 -0
- package/dist/emulate/workos/helpers.d.ts +72 -0
- package/dist/emulate/workos/helpers.js +211 -0
- package/dist/emulate/workos/helpers.js.map +1 -0
- package/dist/emulate/workos/index.d.ts +91 -0
- package/dist/emulate/workos/index.js +322 -0
- package/dist/emulate/workos/index.js.map +1 -0
- package/dist/emulate/workos/role-helpers.d.ts +21 -0
- package/dist/emulate/workos/role-helpers.js +130 -0
- package/dist/emulate/workos/role-helpers.js.map +1 -0
- package/dist/emulate/workos/routes/api-keys.d.ts +2 -0
- package/dist/emulate/workos/routes/api-keys.js +32 -0
- package/dist/emulate/workos/routes/api-keys.js.map +1 -0
- package/dist/emulate/workos/routes/audit-logs.d.ts +2 -0
- package/dist/emulate/workos/routes/audit-logs.js +104 -0
- package/dist/emulate/workos/routes/audit-logs.js.map +1 -0
- package/dist/emulate/workos/routes/auth-challenges.d.ts +2 -0
- package/dist/emulate/workos/routes/auth-challenges.js +51 -0
- package/dist/emulate/workos/routes/auth-challenges.js.map +1 -0
- package/dist/emulate/workos/routes/auth-factors.d.ts +2 -0
- package/dist/emulate/workos/routes/auth-factors.js +51 -0
- package/dist/emulate/workos/routes/auth-factors.js.map +1 -0
- package/dist/emulate/workos/routes/auth.d.ts +2 -0
- package/dist/emulate/workos/routes/auth.js +350 -0
- package/dist/emulate/workos/routes/auth.js.map +1 -0
- package/dist/emulate/workos/routes/authorization-checks.d.ts +10 -0
- package/dist/emulate/workos/routes/authorization-checks.js +123 -0
- package/dist/emulate/workos/routes/authorization-checks.js.map +1 -0
- package/dist/emulate/workos/routes/authorization-org-roles.d.ts +2 -0
- package/dist/emulate/workos/routes/authorization-org-roles.js +64 -0
- package/dist/emulate/workos/routes/authorization-org-roles.js.map +1 -0
- package/dist/emulate/workos/routes/authorization-permissions.d.ts +2 -0
- package/dist/emulate/workos/routes/authorization-permissions.js +67 -0
- package/dist/emulate/workos/routes/authorization-permissions.js.map +1 -0
- package/dist/emulate/workos/routes/authorization-resources.d.ts +2 -0
- package/dist/emulate/workos/routes/authorization-resources.js +117 -0
- package/dist/emulate/workos/routes/authorization-resources.js.map +1 -0
- package/dist/emulate/workos/routes/authorization-roles.d.ts +2 -0
- package/dist/emulate/workos/routes/authorization-roles.js +13 -0
- package/dist/emulate/workos/routes/authorization-roles.js.map +1 -0
- package/dist/emulate/workos/routes/config.d.ts +2 -0
- package/dist/emulate/workos/routes/config.js +57 -0
- package/dist/emulate/workos/routes/config.js.map +1 -0
- package/dist/emulate/workos/routes/connect.d.ts +2 -0
- package/dist/emulate/workos/routes/connect.js +65 -0
- package/dist/emulate/workos/routes/connect.js.map +1 -0
- package/dist/emulate/workos/routes/connections.d.ts +2 -0
- package/dist/emulate/workos/routes/connections.js +73 -0
- package/dist/emulate/workos/routes/connections.js.map +1 -0
- package/dist/emulate/workos/routes/data-integrations.d.ts +2 -0
- package/dist/emulate/workos/routes/data-integrations.js +55 -0
- package/dist/emulate/workos/routes/data-integrations.js.map +1 -0
- package/dist/emulate/workos/routes/directories.d.ts +2 -0
- package/dist/emulate/workos/routes/directories.js +90 -0
- package/dist/emulate/workos/routes/directories.js.map +1 -0
- package/dist/emulate/workos/routes/email-verification.d.ts +2 -0
- package/dist/emulate/workos/routes/email-verification.js +49 -0
- package/dist/emulate/workos/routes/email-verification.js.map +1 -0
- package/dist/emulate/workos/routes/events.d.ts +2 -0
- package/dist/emulate/workos/routes/events.js +18 -0
- package/dist/emulate/workos/routes/events.js.map +1 -0
- package/dist/emulate/workos/routes/feature-flags.d.ts +2 -0
- package/dist/emulate/workos/routes/feature-flags.js +103 -0
- package/dist/emulate/workos/routes/feature-flags.js.map +1 -0
- package/dist/emulate/workos/routes/invitations.d.ts +2 -0
- package/dist/emulate/workos/routes/invitations.js +122 -0
- package/dist/emulate/workos/routes/invitations.js.map +1 -0
- package/dist/emulate/workos/routes/legacy-mfa.d.ts +2 -0
- package/dist/emulate/workos/routes/legacy-mfa.js +75 -0
- package/dist/emulate/workos/routes/legacy-mfa.js.map +1 -0
- package/dist/emulate/workos/routes/magic-auth.d.ts +2 -0
- package/dist/emulate/workos/routes/magic-auth.js +32 -0
- package/dist/emulate/workos/routes/magic-auth.js.map +1 -0
- package/dist/emulate/workos/routes/memberships.d.ts +2 -0
- package/dist/emulate/workos/routes/memberships.js +114 -0
- package/dist/emulate/workos/routes/memberships.js.map +1 -0
- package/dist/emulate/workos/routes/organization-domains.d.ts +2 -0
- package/dist/emulate/workos/routes/organization-domains.js +58 -0
- package/dist/emulate/workos/routes/organization-domains.js.map +1 -0
- package/dist/emulate/workos/routes/organizations.d.ts +2 -0
- package/dist/emulate/workos/routes/organizations.js +131 -0
- package/dist/emulate/workos/routes/organizations.js.map +1 -0
- package/dist/emulate/workos/routes/password-reset.d.ts +2 -0
- package/dist/emulate/workos/routes/password-reset.js +61 -0
- package/dist/emulate/workos/routes/password-reset.js.map +1 -0
- package/dist/emulate/workos/routes/pipes.d.ts +2 -0
- package/dist/emulate/workos/routes/pipes.js +82 -0
- package/dist/emulate/workos/routes/pipes.js.map +1 -0
- package/dist/emulate/workos/routes/portal.d.ts +2 -0
- package/dist/emulate/workos/routes/portal.js +18 -0
- package/dist/emulate/workos/routes/portal.js.map +1 -0
- package/dist/emulate/workos/routes/radar.d.ts +2 -0
- package/dist/emulate/workos/routes/radar.js +41 -0
- package/dist/emulate/workos/routes/radar.js.map +1 -0
- package/dist/emulate/workos/routes/sessions.d.ts +2 -0
- package/dist/emulate/workos/routes/sessions.js +51 -0
- package/dist/emulate/workos/routes/sessions.js.map +1 -0
- package/dist/emulate/workos/routes/sso.d.ts +2 -0
- package/dist/emulate/workos/routes/sso.js +161 -0
- package/dist/emulate/workos/routes/sso.js.map +1 -0
- package/dist/emulate/workos/routes/user-features.d.ts +2 -0
- package/dist/emulate/workos/routes/user-features.js +50 -0
- package/dist/emulate/workos/routes/user-features.js.map +1 -0
- package/dist/emulate/workos/routes/users.d.ts +2 -0
- package/dist/emulate/workos/routes/users.js +129 -0
- package/dist/emulate/workos/routes/users.js.map +1 -0
- package/dist/emulate/workos/routes/webhook-endpoints.d.ts +2 -0
- package/dist/emulate/workos/routes/webhook-endpoints.js +66 -0
- package/dist/emulate/workos/routes/webhook-endpoints.js.map +1 -0
- package/dist/emulate/workos/routes/widgets.d.ts +2 -0
- package/dist/emulate/workos/routes/widgets.js +27 -0
- package/dist/emulate/workos/routes/widgets.js.map +1 -0
- package/dist/emulate/workos/store.d.ts +48 -0
- package/dist/emulate/workos/store.js +102 -0
- package/dist/emulate/workos/store.js.map +1 -0
- package/dist/emulate/workos/webhook-signer.d.ts +1 -0
- package/dist/emulate/workos/webhook-signer.js +8 -0
- package/dist/emulate/workos/webhook-signer.js.map +1 -0
- package/dist/gen-routes-lib.spec.ts +659 -0
- package/dist/gen-routes-lib.ts +647 -0
- package/dist/gen-routes.ts +96 -0
- package/dist/lib/dev-command.d.ts +26 -0
- package/dist/lib/dev-command.js +122 -0
- package/dist/lib/dev-command.js.map +1 -0
- package/dist/lib/run-with-core.js +0 -3
- package/dist/lib/run-with-core.js.map +1 -1
- package/dist/lib/settings.js +1 -1
- package/dist/lib/settings.js.map +1 -1
- package/dist/utils/help-json.js +1 -0
- package/dist/utils/help-json.js.map +1 -1
- package/dist/utils/register-subcommand.d.ts +5 -2
- package/dist/utils/register-subcommand.js +16 -19
- package/dist/utils/register-subcommand.js.map +1 -1
- package/package.json +21 -8
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import type { Entity } from '../core/index.js';
|
|
2
|
+
export interface WorkOSOrganization extends Entity {
|
|
3
|
+
object: 'organization';
|
|
4
|
+
name: string;
|
|
5
|
+
external_id: string | null;
|
|
6
|
+
metadata: Record<string, string>;
|
|
7
|
+
stripe_customer_id: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface WorkOSOrganizationDomain extends Entity {
|
|
10
|
+
object: 'organization_domain';
|
|
11
|
+
organization_id: string;
|
|
12
|
+
domain: string;
|
|
13
|
+
state: 'verified' | 'pending';
|
|
14
|
+
verification_strategy: 'manual' | 'dns';
|
|
15
|
+
verification_token: string;
|
|
16
|
+
verification_prefix: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkOSOrganizationMembership extends Entity {
|
|
19
|
+
object: 'organization_membership';
|
|
20
|
+
organization_id: string;
|
|
21
|
+
user_id: string;
|
|
22
|
+
role: {
|
|
23
|
+
slug: string;
|
|
24
|
+
};
|
|
25
|
+
status: 'active' | 'inactive' | 'pending';
|
|
26
|
+
external_id: string | null;
|
|
27
|
+
metadata: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
export interface WorkOSUser extends Entity {
|
|
30
|
+
object: 'user';
|
|
31
|
+
email: string;
|
|
32
|
+
first_name: string | null;
|
|
33
|
+
last_name: string | null;
|
|
34
|
+
email_verified: boolean;
|
|
35
|
+
profile_picture_url: string | null;
|
|
36
|
+
last_sign_in_at: string | null;
|
|
37
|
+
external_id: string | null;
|
|
38
|
+
metadata: Record<string, string>;
|
|
39
|
+
locale: string | null;
|
|
40
|
+
password_hash: string | null;
|
|
41
|
+
impersonator: {
|
|
42
|
+
email: string;
|
|
43
|
+
reason: string;
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
export interface WorkOSSession extends Entity {
|
|
47
|
+
object: 'session';
|
|
48
|
+
user_id: string;
|
|
49
|
+
organization_id: string | null;
|
|
50
|
+
ip_address: string | null;
|
|
51
|
+
user_agent: string | null;
|
|
52
|
+
}
|
|
53
|
+
export interface WorkOSEmailVerification extends Entity {
|
|
54
|
+
object: 'email_verification';
|
|
55
|
+
user_id: string;
|
|
56
|
+
email: string;
|
|
57
|
+
code: string;
|
|
58
|
+
expires_at: string;
|
|
59
|
+
}
|
|
60
|
+
export interface WorkOSPasswordReset extends Entity {
|
|
61
|
+
object: 'password_reset';
|
|
62
|
+
user_id: string;
|
|
63
|
+
email: string;
|
|
64
|
+
token: string;
|
|
65
|
+
expires_at: string;
|
|
66
|
+
}
|
|
67
|
+
export interface WorkOSMagicAuth extends Entity {
|
|
68
|
+
object: 'magic_auth';
|
|
69
|
+
user_id: string;
|
|
70
|
+
email: string;
|
|
71
|
+
code: string;
|
|
72
|
+
expires_at: string;
|
|
73
|
+
}
|
|
74
|
+
export interface WorkOSAuthenticationFactor extends Entity {
|
|
75
|
+
object: 'authentication_factor';
|
|
76
|
+
user_id: string;
|
|
77
|
+
type: 'totp';
|
|
78
|
+
totp: {
|
|
79
|
+
issuer: string;
|
|
80
|
+
user: string;
|
|
81
|
+
uri: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface WorkOSAuthorizationCode extends Entity {
|
|
85
|
+
user_id: string;
|
|
86
|
+
organization_id: string | null;
|
|
87
|
+
code: string;
|
|
88
|
+
redirect_uri: string;
|
|
89
|
+
expires_at: string;
|
|
90
|
+
code_challenge: string | null;
|
|
91
|
+
code_challenge_method: string | null;
|
|
92
|
+
}
|
|
93
|
+
export interface WorkOSIdentity extends Entity {
|
|
94
|
+
object: 'identity';
|
|
95
|
+
user_id: string;
|
|
96
|
+
provider: string;
|
|
97
|
+
provider_id: string;
|
|
98
|
+
type: 'OAuth';
|
|
99
|
+
}
|
|
100
|
+
export type WorkOSConnectionType = 'ADFSSAML' | 'AzureSAML' | 'GenericOIDC' | 'GenericSAML' | 'GoogleOAuth' | 'GoogleSAML' | 'OktaSAML' | 'OneLoginSAML' | 'PingFederateSAML' | 'PingOneSAML' | 'GitHubOAuth' | 'MicrosoftOAuth' | 'AppleOAuth';
|
|
101
|
+
export interface WorkOSConnectionDomain {
|
|
102
|
+
object: 'connection_domain';
|
|
103
|
+
id: string;
|
|
104
|
+
domain: string;
|
|
105
|
+
}
|
|
106
|
+
export interface WorkOSConnection extends Entity {
|
|
107
|
+
object: 'connection';
|
|
108
|
+
organization_id: string;
|
|
109
|
+
connection_type: WorkOSConnectionType;
|
|
110
|
+
name: string;
|
|
111
|
+
state: 'active' | 'inactive' | 'validating';
|
|
112
|
+
domains: WorkOSConnectionDomain[];
|
|
113
|
+
}
|
|
114
|
+
export interface WorkOSSSOProfile extends Entity {
|
|
115
|
+
object: 'profile';
|
|
116
|
+
connection_id: string;
|
|
117
|
+
connection_type: WorkOSConnectionType;
|
|
118
|
+
organization_id: string;
|
|
119
|
+
idp_id: string;
|
|
120
|
+
email: string;
|
|
121
|
+
first_name: string | null;
|
|
122
|
+
last_name: string | null;
|
|
123
|
+
groups: string[];
|
|
124
|
+
raw_attributes: Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
export interface WorkOSSSOAuthorization extends Entity {
|
|
127
|
+
code: string;
|
|
128
|
+
connection_id: string;
|
|
129
|
+
organization_id: string;
|
|
130
|
+
profile_id: string;
|
|
131
|
+
redirect_uri: string;
|
|
132
|
+
state: string | null;
|
|
133
|
+
expires_at: string;
|
|
134
|
+
}
|
|
135
|
+
export interface WorkOSInvitation extends Entity {
|
|
136
|
+
object: 'invitation';
|
|
137
|
+
email: string;
|
|
138
|
+
state: 'pending' | 'accepted' | 'expired' | 'revoked';
|
|
139
|
+
token: string;
|
|
140
|
+
accept_invitation_url: string;
|
|
141
|
+
organization_id: string | null;
|
|
142
|
+
inviter_user_id: string | null;
|
|
143
|
+
role_slug: string | null;
|
|
144
|
+
expires_at: string;
|
|
145
|
+
}
|
|
146
|
+
export interface WorkOSRedirectUri extends Entity {
|
|
147
|
+
object: 'redirect_uri';
|
|
148
|
+
uri: string;
|
|
149
|
+
}
|
|
150
|
+
export interface WorkOSCorsOrigin extends Entity {
|
|
151
|
+
object: 'cors_origin';
|
|
152
|
+
origin: string;
|
|
153
|
+
}
|
|
154
|
+
export interface WorkOSAuthorizedApplication extends Entity {
|
|
155
|
+
object: 'authorized_application';
|
|
156
|
+
user_id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
redirect_uri: string;
|
|
159
|
+
}
|
|
160
|
+
export interface WorkOSConnectedAccount extends Entity {
|
|
161
|
+
object: 'connected_account';
|
|
162
|
+
user_id: string;
|
|
163
|
+
provider: string;
|
|
164
|
+
provider_id: string;
|
|
165
|
+
}
|
|
166
|
+
export type PipeProvider = 'github' | 'slack' | 'google' | 'salesforce';
|
|
167
|
+
export type PipeConnectionStatus = 'connected' | 'disconnected' | 'requires_reauth';
|
|
168
|
+
export interface WorkOSPipeConnection extends Entity {
|
|
169
|
+
object: 'pipe_connection';
|
|
170
|
+
user_id: string;
|
|
171
|
+
provider: PipeProvider;
|
|
172
|
+
scopes: string[];
|
|
173
|
+
status: PipeConnectionStatus;
|
|
174
|
+
external_account_id: string | null;
|
|
175
|
+
}
|
|
176
|
+
export interface WorkOSRefreshToken extends Entity {
|
|
177
|
+
token: string;
|
|
178
|
+
user_id: string;
|
|
179
|
+
organization_id: string | null;
|
|
180
|
+
session_id: string;
|
|
181
|
+
expires_at: string;
|
|
182
|
+
}
|
|
183
|
+
export interface WorkOSAuthenticationChallenge extends Entity {
|
|
184
|
+
object: 'authentication_challenge';
|
|
185
|
+
user_id: string;
|
|
186
|
+
factor_id: string;
|
|
187
|
+
expires_at: string;
|
|
188
|
+
code: string | null;
|
|
189
|
+
}
|
|
190
|
+
export interface WorkOSDeviceAuthorization extends Entity {
|
|
191
|
+
device_code: string;
|
|
192
|
+
user_code: string;
|
|
193
|
+
user_id: string | null;
|
|
194
|
+
client_id: string;
|
|
195
|
+
expires_at: string;
|
|
196
|
+
interval: number;
|
|
197
|
+
}
|
|
198
|
+
export interface WorkOSRole extends Entity {
|
|
199
|
+
object: 'role';
|
|
200
|
+
slug: string;
|
|
201
|
+
name: string;
|
|
202
|
+
description: string | null;
|
|
203
|
+
type: 'EnvironmentRole' | 'OrganizationRole';
|
|
204
|
+
organization_id: string | null;
|
|
205
|
+
is_default_role: boolean;
|
|
206
|
+
priority: number;
|
|
207
|
+
}
|
|
208
|
+
export interface WorkOSPermission extends Entity {
|
|
209
|
+
object: 'permission';
|
|
210
|
+
slug: string;
|
|
211
|
+
name: string;
|
|
212
|
+
description: string | null;
|
|
213
|
+
}
|
|
214
|
+
export interface WorkOSRolePermission extends Entity {
|
|
215
|
+
role_id: string;
|
|
216
|
+
permission_id: string;
|
|
217
|
+
}
|
|
218
|
+
export interface WorkOSAuthorizationResource extends Entity {
|
|
219
|
+
object: 'authorization_resource';
|
|
220
|
+
resource_type_slug: string;
|
|
221
|
+
external_id: string;
|
|
222
|
+
organization_id: string;
|
|
223
|
+
metadata: Record<string, string>;
|
|
224
|
+
}
|
|
225
|
+
export interface WorkOSRoleAssignment extends Entity {
|
|
226
|
+
object: 'role_assignment';
|
|
227
|
+
organization_membership_id: string;
|
|
228
|
+
role_id: string;
|
|
229
|
+
}
|
|
230
|
+
export interface WorkOSDirectory extends Entity {
|
|
231
|
+
object: 'directory';
|
|
232
|
+
name: string;
|
|
233
|
+
organization_id: string | null;
|
|
234
|
+
domain: string | null;
|
|
235
|
+
type: string;
|
|
236
|
+
state: 'linked' | 'unlinked' | 'deleting' | 'invalid_credentials';
|
|
237
|
+
external_key: string | null;
|
|
238
|
+
}
|
|
239
|
+
export interface WorkOSDirectoryUser extends Entity {
|
|
240
|
+
object: 'directory_user';
|
|
241
|
+
directory_id: string;
|
|
242
|
+
organization_id: string | null;
|
|
243
|
+
idp_id: string;
|
|
244
|
+
first_name: string | null;
|
|
245
|
+
last_name: string | null;
|
|
246
|
+
email: string | null;
|
|
247
|
+
username: string | null;
|
|
248
|
+
state: 'active' | 'inactive';
|
|
249
|
+
role: {
|
|
250
|
+
slug: string;
|
|
251
|
+
} | null;
|
|
252
|
+
custom_attributes: Record<string, unknown>;
|
|
253
|
+
raw_attributes: Record<string, unknown>;
|
|
254
|
+
groups: Array<{
|
|
255
|
+
object: 'directory_group';
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
}>;
|
|
259
|
+
}
|
|
260
|
+
export interface WorkOSDirectoryGroup extends Entity {
|
|
261
|
+
object: 'directory_group';
|
|
262
|
+
directory_id: string;
|
|
263
|
+
organization_id: string | null;
|
|
264
|
+
idp_id: string;
|
|
265
|
+
name: string;
|
|
266
|
+
raw_attributes: Record<string, unknown>;
|
|
267
|
+
}
|
|
268
|
+
export interface WorkOSAuditLogAction extends Entity {
|
|
269
|
+
object: 'audit_log_action';
|
|
270
|
+
name: string;
|
|
271
|
+
description: string | null;
|
|
272
|
+
condition: string | null;
|
|
273
|
+
}
|
|
274
|
+
export interface WorkOSAuditLogEvent extends Entity {
|
|
275
|
+
object: 'audit_log_event';
|
|
276
|
+
organization_id: string;
|
|
277
|
+
action: {
|
|
278
|
+
name: string;
|
|
279
|
+
type: string;
|
|
280
|
+
id: string;
|
|
281
|
+
};
|
|
282
|
+
actor: Record<string, unknown>;
|
|
283
|
+
targets: Array<Record<string, unknown>>;
|
|
284
|
+
metadata: Record<string, unknown> | null;
|
|
285
|
+
occurred_at: string;
|
|
286
|
+
}
|
|
287
|
+
export interface WorkOSAuditLogExport extends Entity {
|
|
288
|
+
object: 'audit_log_export';
|
|
289
|
+
organization_id: string;
|
|
290
|
+
state: 'pending' | 'ready' | 'error';
|
|
291
|
+
url: string | null;
|
|
292
|
+
filters: Record<string, unknown>;
|
|
293
|
+
}
|
|
294
|
+
export interface WorkOSFeatureFlag extends Entity {
|
|
295
|
+
object: 'feature_flag';
|
|
296
|
+
slug: string;
|
|
297
|
+
name: string;
|
|
298
|
+
description: string | null;
|
|
299
|
+
type: 'boolean' | 'string' | 'number';
|
|
300
|
+
default_value: unknown;
|
|
301
|
+
enabled: boolean;
|
|
302
|
+
}
|
|
303
|
+
export interface WorkOSFlagTarget extends Entity {
|
|
304
|
+
object: 'flag_target';
|
|
305
|
+
flag_slug: string;
|
|
306
|
+
resource_id: string;
|
|
307
|
+
resource_type: string;
|
|
308
|
+
value: unknown;
|
|
309
|
+
}
|
|
310
|
+
export interface WorkOSConnectApplication extends Entity {
|
|
311
|
+
object: 'connect_application';
|
|
312
|
+
name: string;
|
|
313
|
+
redirect_uris: string[];
|
|
314
|
+
client_id: string;
|
|
315
|
+
logo_url: string | null;
|
|
316
|
+
}
|
|
317
|
+
export interface WorkOSClientSecret extends Entity {
|
|
318
|
+
object: 'client_secret';
|
|
319
|
+
application_id: string;
|
|
320
|
+
value: string;
|
|
321
|
+
last_four: string;
|
|
322
|
+
}
|
|
323
|
+
export interface WorkOSDataIntegrationAuth extends Entity {
|
|
324
|
+
slug: string;
|
|
325
|
+
code: string;
|
|
326
|
+
redirect_uri: string;
|
|
327
|
+
state: string | null;
|
|
328
|
+
expires_at: string;
|
|
329
|
+
}
|
|
330
|
+
export interface WorkOSRadarAttempt extends Entity {
|
|
331
|
+
object: 'radar_attempt';
|
|
332
|
+
user_id: string | null;
|
|
333
|
+
ip_address: string;
|
|
334
|
+
user_agent: string | null;
|
|
335
|
+
verdict: 'allow' | 'deny' | 'challenge';
|
|
336
|
+
signals: Array<{
|
|
337
|
+
type: string;
|
|
338
|
+
confidence: number;
|
|
339
|
+
}>;
|
|
340
|
+
}
|
|
341
|
+
export interface WorkOSApiKey extends Entity {
|
|
342
|
+
object: 'api_key';
|
|
343
|
+
name: string;
|
|
344
|
+
key: string;
|
|
345
|
+
environment: string;
|
|
346
|
+
}
|
|
347
|
+
export interface WorkOSEvent extends Entity {
|
|
348
|
+
object: 'event';
|
|
349
|
+
event: string;
|
|
350
|
+
data: Record<string, unknown>;
|
|
351
|
+
environment_id: string | null;
|
|
352
|
+
}
|
|
353
|
+
export interface WorkOSWebhookEndpoint extends Entity {
|
|
354
|
+
object: 'webhook_endpoint';
|
|
355
|
+
url: string;
|
|
356
|
+
secret: string;
|
|
357
|
+
enabled: boolean;
|
|
358
|
+
events: string[];
|
|
359
|
+
description: string | null;
|
|
360
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/emulate/workos/entities.ts"],"names":[],"mappings":"","sourcesContent":["import type { Entity } from '../core/index.js';\n\nexport interface WorkOSOrganization extends Entity {\n object: 'organization';\n name: string;\n external_id: string | null;\n metadata: Record<string, string>;\n stripe_customer_id: string | null;\n}\n\nexport interface WorkOSOrganizationDomain extends Entity {\n object: 'organization_domain';\n organization_id: string;\n domain: string;\n state: 'verified' | 'pending';\n verification_strategy: 'manual' | 'dns';\n verification_token: string;\n verification_prefix: string;\n}\n\nexport interface WorkOSOrganizationMembership extends Entity {\n object: 'organization_membership';\n organization_id: string;\n user_id: string;\n role: { slug: string };\n status: 'active' | 'inactive' | 'pending';\n external_id: string | null;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSUser extends Entity {\n object: 'user';\n email: string;\n first_name: string | null;\n last_name: string | null;\n email_verified: boolean;\n profile_picture_url: string | null;\n last_sign_in_at: string | null;\n external_id: string | null;\n metadata: Record<string, string>;\n locale: string | null;\n password_hash: string | null;\n impersonator: { email: string; reason: string } | null;\n}\n\nexport interface WorkOSSession extends Entity {\n object: 'session';\n user_id: string;\n organization_id: string | null;\n ip_address: string | null;\n user_agent: string | null;\n}\n\nexport interface WorkOSEmailVerification extends Entity {\n object: 'email_verification';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSPasswordReset extends Entity {\n object: 'password_reset';\n user_id: string;\n email: string;\n token: string;\n expires_at: string;\n}\n\nexport interface WorkOSMagicAuth extends Entity {\n object: 'magic_auth';\n user_id: string;\n email: string;\n code: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationFactor extends Entity {\n object: 'authentication_factor';\n user_id: string;\n type: 'totp';\n totp: {\n issuer: string;\n user: string;\n uri: string;\n };\n}\n\nexport interface WorkOSAuthorizationCode extends Entity {\n user_id: string;\n organization_id: string | null;\n code: string;\n redirect_uri: string;\n expires_at: string;\n code_challenge: string | null;\n code_challenge_method: string | null;\n}\n\nexport interface WorkOSIdentity extends Entity {\n object: 'identity';\n user_id: string;\n provider: string;\n provider_id: string;\n type: 'OAuth';\n}\n\nexport type WorkOSConnectionType =\n | 'ADFSSAML'\n | 'AzureSAML'\n | 'GenericOIDC'\n | 'GenericSAML'\n | 'GoogleOAuth'\n | 'GoogleSAML'\n | 'OktaSAML'\n | 'OneLoginSAML'\n | 'PingFederateSAML'\n | 'PingOneSAML'\n | 'GitHubOAuth'\n | 'MicrosoftOAuth'\n | 'AppleOAuth';\n\nexport interface WorkOSConnectionDomain {\n object: 'connection_domain';\n id: string;\n domain: string;\n}\n\nexport interface WorkOSConnection extends Entity {\n object: 'connection';\n organization_id: string;\n connection_type: WorkOSConnectionType;\n name: string;\n state: 'active' | 'inactive' | 'validating';\n domains: WorkOSConnectionDomain[];\n}\n\nexport interface WorkOSSSOProfile extends Entity {\n object: 'profile';\n connection_id: string;\n connection_type: WorkOSConnectionType;\n organization_id: string;\n idp_id: string;\n email: string;\n first_name: string | null;\n last_name: string | null;\n groups: string[];\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSSSOAuthorization extends Entity {\n code: string;\n connection_id: string;\n organization_id: string;\n profile_id: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSInvitation extends Entity {\n object: 'invitation';\n email: string;\n state: 'pending' | 'accepted' | 'expired' | 'revoked';\n token: string;\n accept_invitation_url: string;\n organization_id: string | null;\n inviter_user_id: string | null;\n role_slug: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRedirectUri extends Entity {\n object: 'redirect_uri';\n uri: string;\n}\n\nexport interface WorkOSCorsOrigin extends Entity {\n object: 'cors_origin';\n origin: string;\n}\n\nexport interface WorkOSAuthorizedApplication extends Entity {\n object: 'authorized_application';\n user_id: string;\n name: string;\n redirect_uri: string;\n}\n\nexport interface WorkOSConnectedAccount extends Entity {\n object: 'connected_account';\n user_id: string;\n provider: string;\n provider_id: string;\n}\n\nexport type PipeProvider = 'github' | 'slack' | 'google' | 'salesforce';\nexport type PipeConnectionStatus = 'connected' | 'disconnected' | 'requires_reauth';\n\nexport interface WorkOSPipeConnection extends Entity {\n object: 'pipe_connection';\n user_id: string;\n provider: PipeProvider;\n scopes: string[];\n status: PipeConnectionStatus;\n external_account_id: string | null;\n}\n\nexport interface WorkOSRefreshToken extends Entity {\n token: string;\n user_id: string;\n organization_id: string | null;\n session_id: string;\n expires_at: string;\n}\n\nexport interface WorkOSAuthenticationChallenge extends Entity {\n object: 'authentication_challenge';\n user_id: string;\n factor_id: string;\n expires_at: string;\n code: string | null;\n}\n\nexport interface WorkOSDeviceAuthorization extends Entity {\n device_code: string;\n user_code: string;\n user_id: string | null;\n client_id: string;\n expires_at: string;\n interval: number;\n}\n\nexport interface WorkOSRole extends Entity {\n object: 'role';\n slug: string;\n name: string;\n description: string | null;\n type: 'EnvironmentRole' | 'OrganizationRole';\n organization_id: string | null;\n is_default_role: boolean;\n priority: number;\n}\n\nexport interface WorkOSPermission extends Entity {\n object: 'permission';\n slug: string;\n name: string;\n description: string | null;\n}\n\nexport interface WorkOSRolePermission extends Entity {\n role_id: string;\n permission_id: string;\n}\n\nexport interface WorkOSAuthorizationResource extends Entity {\n object: 'authorization_resource';\n resource_type_slug: string;\n external_id: string;\n organization_id: string;\n metadata: Record<string, string>;\n}\n\nexport interface WorkOSRoleAssignment extends Entity {\n object: 'role_assignment';\n organization_membership_id: string;\n role_id: string;\n}\n\nexport interface WorkOSDirectory extends Entity {\n object: 'directory';\n name: string;\n organization_id: string | null;\n domain: string | null;\n type: string;\n state: 'linked' | 'unlinked' | 'deleting' | 'invalid_credentials';\n external_key: string | null;\n}\n\nexport interface WorkOSDirectoryUser extends Entity {\n object: 'directory_user';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n first_name: string | null;\n last_name: string | null;\n email: string | null;\n username: string | null;\n state: 'active' | 'inactive';\n role: { slug: string } | null;\n custom_attributes: Record<string, unknown>;\n raw_attributes: Record<string, unknown>;\n groups: Array<{ object: 'directory_group'; id: string; name: string }>;\n}\n\nexport interface WorkOSDirectoryGroup extends Entity {\n object: 'directory_group';\n directory_id: string;\n organization_id: string | null;\n idp_id: string;\n name: string;\n raw_attributes: Record<string, unknown>;\n}\n\nexport interface WorkOSAuditLogAction extends Entity {\n object: 'audit_log_action';\n name: string;\n description: string | null;\n condition: string | null;\n}\n\nexport interface WorkOSAuditLogEvent extends Entity {\n object: 'audit_log_event';\n organization_id: string;\n action: { name: string; type: string; id: string };\n actor: Record<string, unknown>;\n targets: Array<Record<string, unknown>>;\n metadata: Record<string, unknown> | null;\n occurred_at: string;\n}\n\nexport interface WorkOSAuditLogExport extends Entity {\n object: 'audit_log_export';\n organization_id: string;\n state: 'pending' | 'ready' | 'error';\n url: string | null;\n filters: Record<string, unknown>;\n}\n\nexport interface WorkOSFeatureFlag extends Entity {\n object: 'feature_flag';\n slug: string;\n name: string;\n description: string | null;\n type: 'boolean' | 'string' | 'number';\n default_value: unknown;\n enabled: boolean;\n}\n\nexport interface WorkOSFlagTarget extends Entity {\n object: 'flag_target';\n flag_slug: string;\n resource_id: string;\n resource_type: string;\n value: unknown;\n}\n\nexport interface WorkOSConnectApplication extends Entity {\n object: 'connect_application';\n name: string;\n redirect_uris: string[];\n client_id: string;\n logo_url: string | null;\n}\n\nexport interface WorkOSClientSecret extends Entity {\n object: 'client_secret';\n application_id: string;\n value: string;\n last_four: string;\n}\n\nexport interface WorkOSDataIntegrationAuth extends Entity {\n slug: string;\n code: string;\n redirect_uri: string;\n state: string | null;\n expires_at: string;\n}\n\nexport interface WorkOSRadarAttempt extends Entity {\n object: 'radar_attempt';\n user_id: string | null;\n ip_address: string;\n user_agent: string | null;\n verdict: 'allow' | 'deny' | 'challenge';\n signals: Array<{ type: string; confidence: number }>;\n}\n\nexport interface WorkOSApiKey extends Entity {\n object: 'api_key';\n name: string;\n key: string;\n environment: string;\n}\n\nexport interface WorkOSEvent extends Entity {\n object: 'event';\n event: string;\n data: Record<string, unknown>;\n environment_id: string | null;\n}\n\nexport interface WorkOSWebhookEndpoint extends Entity {\n object: 'webhook_endpoint';\n url: string;\n secret: string;\n enabled: boolean;\n events: string[];\n description: string | null;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Store } from '../core/index.js';
|
|
2
|
+
import type { WorkOSEventName } from './constants.js';
|
|
3
|
+
export interface EventPayload {
|
|
4
|
+
event: WorkOSEventName | string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
environment_id?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class EventBus {
|
|
9
|
+
private store;
|
|
10
|
+
private endpointsByEvent;
|
|
11
|
+
private catchAllEndpoints;
|
|
12
|
+
constructor(store: Store);
|
|
13
|
+
/** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */
|
|
14
|
+
rebuildIndex(): void;
|
|
15
|
+
emit(payload: EventPayload): void;
|
|
16
|
+
private deliver;
|
|
17
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getWorkOSStore } from './store.js';
|
|
2
|
+
import { signWebhookPayload } from './webhook-signer.js';
|
|
3
|
+
export class EventBus {
|
|
4
|
+
store;
|
|
5
|
+
endpointsByEvent = new Map();
|
|
6
|
+
catchAllEndpoints = new Set();
|
|
7
|
+
constructor(store) {
|
|
8
|
+
this.store = store;
|
|
9
|
+
}
|
|
10
|
+
/** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */
|
|
11
|
+
rebuildIndex() {
|
|
12
|
+
this.endpointsByEvent.clear();
|
|
13
|
+
this.catchAllEndpoints.clear();
|
|
14
|
+
const ws = getWorkOSStore(this.store);
|
|
15
|
+
for (const ep of ws.webhookEndpoints.all()) {
|
|
16
|
+
if (!ep.enabled)
|
|
17
|
+
continue;
|
|
18
|
+
if (ep.events.length === 0) {
|
|
19
|
+
this.catchAllEndpoints.add(ep.id);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
for (const evt of ep.events) {
|
|
23
|
+
const set = this.endpointsByEvent.get(evt) ?? new Set();
|
|
24
|
+
set.add(ep.id);
|
|
25
|
+
this.endpointsByEvent.set(evt, set);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
emit(payload) {
|
|
31
|
+
const ws = getWorkOSStore(this.store);
|
|
32
|
+
const event = ws.events.insert({
|
|
33
|
+
object: 'event',
|
|
34
|
+
event: payload.event,
|
|
35
|
+
data: payload.data,
|
|
36
|
+
environment_id: payload.environment_id ?? null,
|
|
37
|
+
});
|
|
38
|
+
// Pre-filtered: only endpoints that care about this event
|
|
39
|
+
const targetIds = new Set(this.catchAllEndpoints);
|
|
40
|
+
const eventSpecific = this.endpointsByEvent.get(payload.event);
|
|
41
|
+
if (eventSpecific) {
|
|
42
|
+
for (const id of eventSpecific)
|
|
43
|
+
targetIds.add(id);
|
|
44
|
+
}
|
|
45
|
+
for (const id of targetIds) {
|
|
46
|
+
const endpoint = ws.webhookEndpoints.get(id);
|
|
47
|
+
if (endpoint)
|
|
48
|
+
this.deliver(endpoint, event).catch(() => { });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async deliver(endpoint, event) {
|
|
52
|
+
const body = JSON.stringify({
|
|
53
|
+
id: event.id,
|
|
54
|
+
event: event.event,
|
|
55
|
+
data: event.data,
|
|
56
|
+
created_at: event.created_at,
|
|
57
|
+
});
|
|
58
|
+
const signature = signWebhookPayload(body, endpoint.secret);
|
|
59
|
+
await fetch(endpoint.url, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'WorkOS-Signature': signature,
|
|
64
|
+
},
|
|
65
|
+
body,
|
|
66
|
+
signal: AbortSignal.timeout(5000),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../src/emulate/workos/event-bus.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Store } from '../core/index.js';\nimport { getWorkOSStore } from './store.js';\nimport type { WorkOSWebhookEndpoint, WorkOSEvent } from './entities.js';\nimport { signWebhookPayload } from './webhook-signer.js';\nimport type { WorkOSEventName } from './constants.js';\n\nexport interface EventPayload {\n event: WorkOSEventName | string;\n data: Record<string, unknown>;\n environment_id?: string;\n}\n\nexport class EventBus {\n private endpointsByEvent = new Map<string, Set<string>>();\n private catchAllEndpoints = new Set<string>();\n\n constructor(private store: Store) {}\n\n /** Rebuild the event-type index. Auto-called via collection hooks; call manually only in tests. */\n rebuildIndex(): void {\n this.endpointsByEvent.clear();\n this.catchAllEndpoints.clear();\n const ws = getWorkOSStore(this.store);\n for (const ep of ws.webhookEndpoints.all()) {\n if (!ep.enabled) continue;\n if (ep.events.length === 0) {\n this.catchAllEndpoints.add(ep.id);\n } else {\n for (const evt of ep.events) {\n const set = this.endpointsByEvent.get(evt) ?? new Set();\n set.add(ep.id);\n this.endpointsByEvent.set(evt, set);\n }\n }\n }\n }\n\n emit(payload: EventPayload): void {\n const ws = getWorkOSStore(this.store);\n\n const event = ws.events.insert({\n object: 'event',\n event: payload.event,\n data: payload.data,\n environment_id: payload.environment_id ?? null,\n });\n\n // Pre-filtered: only endpoints that care about this event\n const targetIds = new Set(this.catchAllEndpoints);\n const eventSpecific = this.endpointsByEvent.get(payload.event);\n if (eventSpecific) {\n for (const id of eventSpecific) targetIds.add(id);\n }\n\n for (const id of targetIds) {\n const endpoint = ws.webhookEndpoints.get(id);\n if (endpoint) this.deliver(endpoint, event).catch(() => {});\n }\n }\n\n private async deliver(endpoint: WorkOSWebhookEndpoint, event: WorkOSEvent): Promise<void> {\n const body = JSON.stringify({\n id: event.id,\n event: event.event,\n data: event.data,\n created_at: event.created_at,\n });\n\n const signature = signWebhookPayload(body, endpoint.secret);\n\n await fetch(endpoint.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'WorkOS-Signature': signature,\n },\n body,\n signal: AbortSignal.timeout(5000),\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type CursorPaginatedResult, type Entity } from '../core/index.js';
|
|
2
|
+
import type { WorkOSStore } from './store.js';
|
|
3
|
+
import type { WorkOSOrganization, WorkOSOrganizationDomain, WorkOSOrganizationMembership, WorkOSUser, WorkOSSession, WorkOSEmailVerification, WorkOSPasswordReset, WorkOSMagicAuth, WorkOSAuthenticationFactor, WorkOSIdentity, WorkOSConnection, WorkOSSSOProfile, WorkOSPipeConnection, WorkOSInvitation, WorkOSRedirectUri, WorkOSCorsOrigin, WorkOSAuthorizedApplication, WorkOSConnectedAccount, WorkOSAuthenticationChallenge, WorkOSDeviceAuthorization, WorkOSRole, WorkOSPermission, WorkOSAuthorizationResource, WorkOSRoleAssignment, WorkOSDirectory, WorkOSDirectoryUser, WorkOSDirectoryGroup, WorkOSAuditLogAction, WorkOSAuditLogEvent, WorkOSAuditLogExport, WorkOSFeatureFlag, WorkOSFlagTarget, WorkOSConnectApplication, WorkOSClientSecret, WorkOSRadarAttempt, WorkOSApiKey, WorkOSEvent, WorkOSWebhookEndpoint } from './entities.js';
|
|
4
|
+
export declare function formatEntity<T extends Entity>(entity: T, opts?: {
|
|
5
|
+
exclude?: Set<string>;
|
|
6
|
+
}): Record<string, unknown>;
|
|
7
|
+
export declare function formatListResponse<T>(result: CursorPaginatedResult<T>, formatter: (item: T) => Record<string, unknown>): {
|
|
8
|
+
object: 'list';
|
|
9
|
+
data: Record<string, unknown>[];
|
|
10
|
+
list_metadata: {
|
|
11
|
+
before: string | null;
|
|
12
|
+
after: string | null;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function formatOrganization(org: WorkOSOrganization, ws: WorkOSStore, opts?: {
|
|
16
|
+
domains?: WorkOSOrganizationDomain[];
|
|
17
|
+
}): Record<string, unknown>;
|
|
18
|
+
export declare function formatDomain(domain: WorkOSOrganizationDomain): Record<string, unknown>;
|
|
19
|
+
export declare function formatMembership(m: WorkOSOrganizationMembership): Record<string, unknown>;
|
|
20
|
+
export declare function formatUser(user: WorkOSUser): Record<string, unknown>;
|
|
21
|
+
export declare function formatSession(s: WorkOSSession): Record<string, unknown>;
|
|
22
|
+
export declare function formatEmailVerification(ev: WorkOSEmailVerification): Record<string, unknown>;
|
|
23
|
+
export declare function formatPasswordReset(pr: WorkOSPasswordReset): Record<string, unknown>;
|
|
24
|
+
export declare function formatMagicAuth(ma: WorkOSMagicAuth): Record<string, unknown>;
|
|
25
|
+
export declare function formatAuthFactor(f: WorkOSAuthenticationFactor): Record<string, unknown>;
|
|
26
|
+
export declare function formatIdentity(i: WorkOSIdentity): Record<string, unknown>;
|
|
27
|
+
export declare function generateVerificationToken(): string;
|
|
28
|
+
export declare function generateCode(): string;
|
|
29
|
+
export declare function hashPassword(password: string): string;
|
|
30
|
+
export declare function verifyPassword(password: string, hash: string): boolean;
|
|
31
|
+
export declare function expiresIn(minutes: number): string;
|
|
32
|
+
export declare function isExpired(expiresAt: string): boolean;
|
|
33
|
+
export declare function formatConnection(conn: WorkOSConnection): Record<string, unknown>;
|
|
34
|
+
export declare function formatSSOProfile(p: WorkOSSSOProfile): Record<string, unknown>;
|
|
35
|
+
export declare function formatPipeConnection(pc: WorkOSPipeConnection): Record<string, unknown>;
|
|
36
|
+
export declare function formatInvitation(inv: WorkOSInvitation): Record<string, unknown>;
|
|
37
|
+
export declare function formatRedirectUri(r: WorkOSRedirectUri): Record<string, unknown>;
|
|
38
|
+
export declare function formatCorsOrigin(o: WorkOSCorsOrigin): Record<string, unknown>;
|
|
39
|
+
export declare function formatAuthorizedApplication(a: WorkOSAuthorizedApplication): Record<string, unknown>;
|
|
40
|
+
export declare function formatConnectedAccount(a: WorkOSConnectedAccount): Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Validate that a redirect_uri points to a localhost origin.
|
|
43
|
+
* Prevents the emulator from being used as an open redirect.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertLocalRedirectUri(uri: string): void;
|
|
46
|
+
export declare function formatAuthChallenge(c: WorkOSAuthenticationChallenge): Record<string, unknown>;
|
|
47
|
+
export declare function formatRole(role: WorkOSRole): Record<string, unknown>;
|
|
48
|
+
export declare function formatPermission(p: WorkOSPermission): Record<string, unknown>;
|
|
49
|
+
export declare function formatAuthorizationResource(r: WorkOSAuthorizationResource): Record<string, unknown>;
|
|
50
|
+
export declare function formatRoleAssignment(ra: WorkOSRoleAssignment): Record<string, unknown>;
|
|
51
|
+
export declare function formatDeviceAuthorization(d: WorkOSDeviceAuthorization): Record<string, unknown>;
|
|
52
|
+
export declare function formatDirectory(d: WorkOSDirectory): Record<string, unknown>;
|
|
53
|
+
export declare function formatDirectoryUser(u: WorkOSDirectoryUser): Record<string, unknown>;
|
|
54
|
+
export declare function formatDirectoryGroup(g: WorkOSDirectoryGroup): Record<string, unknown>;
|
|
55
|
+
export declare function formatAuditLogAction(a: WorkOSAuditLogAction): Record<string, unknown>;
|
|
56
|
+
export declare function formatAuditLogEvent(e: WorkOSAuditLogEvent): Record<string, unknown>;
|
|
57
|
+
export declare function formatAuditLogExport(ex: WorkOSAuditLogExport): Record<string, unknown>;
|
|
58
|
+
export declare function formatFeatureFlag(f: WorkOSFeatureFlag): Record<string, unknown>;
|
|
59
|
+
export declare function formatFlagTarget(t: WorkOSFlagTarget): Record<string, unknown>;
|
|
60
|
+
export declare function formatConnectApplication(a: WorkOSConnectApplication): Record<string, unknown>;
|
|
61
|
+
export declare function formatClientSecret(s: WorkOSClientSecret): Record<string, unknown>;
|
|
62
|
+
export declare function formatRadarAttempt(a: WorkOSRadarAttempt): Record<string, unknown>;
|
|
63
|
+
export declare function formatApiKeyRecord(k: WorkOSApiKey): Record<string, unknown>;
|
|
64
|
+
export declare function formatEvent(e: WorkOSEvent): Record<string, unknown>;
|
|
65
|
+
export declare function formatWebhookEndpoint(ep: WorkOSWebhookEndpoint, opts?: {
|
|
66
|
+
includeSecret?: boolean;
|
|
67
|
+
}): Record<string, unknown>;
|
|
68
|
+
export declare function sealSession(data: {
|
|
69
|
+
access_token: string;
|
|
70
|
+
refresh_token: string;
|
|
71
|
+
session_id: string;
|
|
72
|
+
}, apiKey: string): string;
|