@workos-inc/node
Advanced tools
Comparing version 0.10.1 to 0.10.2
{ | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"name": "@workos-inc/node", | ||
@@ -12,3 +12,3 @@ "author": "WorkOS", | ||
"volta": { | ||
"node": "10.24.1", | ||
"node": "14.16.1", | ||
"yarn": "1.22.10" | ||
@@ -42,4 +42,4 @@ }, | ||
"devDependencies": { | ||
"@types/jest": "26.0.22", | ||
"@types/node": "12.20.10", | ||
"@types/jest": "26.0.23", | ||
"@types/node": "12.20.12", | ||
"@types/pluralize": "0.0.29", | ||
@@ -50,3 +50,3 @@ "axios-mock-adapter": "1.19.0", | ||
"supertest": "6.1.3", | ||
"ts-jest": "26.5.5", | ||
"ts-jest": "26.5.6", | ||
"tslint": "6.1.3", | ||
@@ -53,0 +53,0 @@ "typescript": "4.2.4" |
@@ -10,2 +10,6 @@ import { ConnectionType } from './connection-type.enum'; | ||
id: string; | ||
state: 'draft' | 'active' | 'inactive'; | ||
/** | ||
* @deprecated The status parameter has been deprecated. Please use state. | ||
*/ | ||
status: 'linked' | 'unlinked'; | ||
@@ -12,0 +16,0 @@ name: string; |
{ | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"name": "@workos-inc/node", | ||
@@ -12,3 +12,3 @@ "author": "WorkOS", | ||
"volta": { | ||
"node": "10.24.1", | ||
"node": "14.16.1", | ||
"yarn": "1.22.10" | ||
@@ -42,4 +42,4 @@ }, | ||
"devDependencies": { | ||
"@types/jest": "26.0.22", | ||
"@types/node": "12.20.10", | ||
"@types/jest": "26.0.23", | ||
"@types/node": "12.20.12", | ||
"@types/pluralize": "0.0.29", | ||
@@ -50,3 +50,3 @@ "axios-mock-adapter": "1.19.0", | ||
"supertest": "6.1.3", | ||
"ts-jest": "26.5.5", | ||
"ts-jest": "26.5.6", | ||
"tslint": "6.1.3", | ||
@@ -53,0 +53,0 @@ "typescript": "4.2.4" |
113
README.md
@@ -1,8 +0,12 @@ | ||
# workos-node | ||
# WorkOS Node.js Library | ||
A WorkOS client for node applications in your organization to control and monitor the access of information within your organization. | ||
The WorkOS library for Node.js provides convenient access to the WorkOS API from applications written in server-side JavaScript. | ||
## Documentation | ||
See the [API Reference](https://workos.com/docs/reference/client-libraries) for Node.js usage examples. | ||
## Installation | ||
You can install the WorkOS JS client in your local environment by running: | ||
Install the package with: | ||
@@ -15,9 +19,9 @@ ``` | ||
To use the client you must provide an API key located from the WorkOS dashboard either as an environment variable `WORKOS_API_KEY`: | ||
To use the library you must provide an API key, located in the WorkOS dashboard, as an environment variable `WORKOS_API_KEY`: | ||
```sh | ||
WORKOS_API_KEY="sk_1234" ./app | ||
WORKOS_API_KEY="sk_1234" | ||
``` | ||
Or you can set it on your own before your application starts: | ||
Or, you can set it on your own before your application starts: | ||
@@ -30,94 +34,7 @@ ```ts | ||
## Usage | ||
## More Information | ||
Creating an Audit Trail event requires a descriptive action name and annotating the event with its CRUD identifier. The action name must contain an action category and an action name separated by a period, for example, `user.login`. | ||
```ts | ||
const event = { | ||
group: 'organization_1', | ||
action: 'user.login', | ||
action_type: 'C', | ||
actor_name: 'user@email.com', | ||
actor_id: 'user_1', | ||
target_name: 'user@email.com', | ||
target_id: 'user_1', | ||
location: '1.1.1.1', | ||
occurred_at: new Date(0), | ||
}; | ||
workos.auditTrail.createEvent(event); | ||
``` | ||
The resulting event being sent to WorkOS looks like: | ||
```json | ||
{ | ||
"group": "organization_1", | ||
"action": "user.login", | ||
"action_type": "C", | ||
"actor_name": "user@email.com", | ||
"actor_id": "user_1", | ||
"target_name": "user@email.com", | ||
"target_id": "user_1", | ||
"location": "1.1.1.1", | ||
"occurred_at": "2019-05-01T01:15:55.619355Z", | ||
"metadata": {} | ||
} | ||
``` | ||
All events are published to WorkOS asynchronously by default and support `await / async` behavior. | ||
## Adding Metadata To Events | ||
Metadata provides additional context for your Audit Trail events that would be helpful to you or others in the future when looking at an Audit Trail event. Values for your metadata are expected to be primitive types: | ||
- string | ||
- boolean | ||
- number | ||
- Date | ||
_You're allowed to have maps with its elements being any one of the primitive types._ | ||
You can add metadata directly to events by appending the `metadata` property.: | ||
```ts | ||
const event = { | ||
group: 'user_1', | ||
action: 'tweet.update', | ||
action_type: 'U', | ||
actor_name: 'user@email.com', | ||
actor_id: 'user_1', | ||
target_name: 'user@email.com', | ||
target_id: 'tweet_5', | ||
location: '1.1.1.1', | ||
occurred_at: '2019-05-01T01:15:55.619355Z', | ||
metadata: { | ||
body_was: 'What time is the event', | ||
body: 'What time is the event?', | ||
}, | ||
}; | ||
workos.auditTrail.createEvent(event); | ||
``` | ||
Resulting in the following being sent to WorkOS: | ||
```json | ||
{ | ||
"group": "user_1", | ||
"action": "tweet.update", | ||
"action_type": "U", | ||
"actor_name": "user@email.com", | ||
"actor_id": "user_1", | ||
"target_name": "user@email.com", | ||
"target_id": "tweet_5", | ||
"location": "1.1.1.1", | ||
"occurred_at": "2019-05-01T01:15:55.619355Z", | ||
"metadata": { | ||
"body_was": "What time is the event", | ||
"body": "What time is the event?" | ||
} | ||
} | ||
``` | ||
By adding supportive metadata when you create the event you can see what the original tweet body was and what the body was updated to. For something like a tweet that could get updated multiple times over the course of time, you can't always depend on the database representation to tell you what the body has always been. Without logging it right when the change occurs, you'll forever lose all the individual changes along the way. Good Audit Trail events attach all supporting information surrounding the event which could be used to inform the reader in the future what exactly happened, how it happened, and when it happened. | ||
* [Single Sign-On Guide](https://workos.com/docs/sso/guide) | ||
* [Directory Sync Guide](https://workos.com/docs/directory-sync/guide) | ||
* [Admin Portal Guide](https://workos.com/docs/admin-portal/guide) | ||
* [Magic Link Guide](https://workos.com/docs/magic-link/guide) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1075
48570
39