{"id":18374567,"url":"https://github.com/jupiterone/jupiterone-client-nodejs","last_synced_at":"2025-03-17T14:11:25.724Z","repository":{"id":34448578,"uuid":"177449052","full_name":"JupiterOne/jupiterone-client-nodejs","owner":"JupiterOne","description":"A node.js client wrapper for JupiterOne public API and a CLI utility","archived":false,"fork":false,"pushed_at":"2025-02-18T13:04:06.000Z","size":1304,"stargazers_count":14,"open_issues_count":3,"forks_count":9,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-02-25T05:34:26.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://support.jupiterone.io/hc/en-us/articles/360022722094","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JupiterOne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T17:50:37.000Z","updated_at":"2025-02-18T13:04:08.000Z","dependencies_parsed_at":"2023-10-11T23:16:26.440Z","dependency_job_id":"82217779-c081-4d5f-9267-77665044a541","html_url":"https://github.com/JupiterOne/jupiterone-client-nodejs","commit_stats":{"total_commits":279,"total_committers":26,"mean_commits":10.73076923076923,"dds":0.7025089605734767,"last_synced_commit":"0da2ff1faf646de3bffd73f8dc717d3ec6e488a2"},"previous_names":[],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fjupiterone-client-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fjupiterone-client-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fjupiterone-client-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fjupiterone-client-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JupiterOne","download_url":"https://codeload.github.com/JupiterOne/jupiterone-client-nodejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827113,"owners_count":20026601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T00:15:05.583Z","updated_at":"2025-03-04T10:11:41.329Z","avatar_url":"https://github.com/JupiterOne.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jupiterone-client-nodejs\n\nA node.js client wrapper and CLI utility for JupiterOne public API.\n\nThis is currently an experimental project and subject to change.\n\n## Installation\n\nTo install the client local to the current project:\n\n```bash\nnpm install @jupiterone/jupiterone-client-nodejs\n```\n\nTo install the client globally:\n\n```bash\nnpm install @jupiterone/jupiterone-client-nodejs -g\n```\n\n## Using the Node.js client\n\n```javascript\nconst { JupiterOneClient } = require('@jupiterone/jupiterone-client-nodejs');\n\nconst j1Client = await new JupiterOneClient({\n  account: 'my-account-id',\n  accessToken: 'my-api-token',\n  apiBaseUrl: 'https://api.us.jupiterone.io', // Optional parameter\n}).init();\nconst integrationInstance = await j1Client.integrationInstances.get(\n  'my-integration-instance-id',\n);\n```\n\n## Using the J1 CLI\n\nUsage:\n\n```bash\n$ j1 --help\nUsage: j1 [options]\n\nOptions:\n  -v, --version             output the version number\n  -a, --account \u003cid\u003e        JupiterOne account ID.\n  -u, --user \u003cemail\u003e        JupiterOne user email.\n  -k, --key \u003capiToken\u003e      JupiterOne API access token.\n  -q, --query \u003cj1ql\u003e        Execute a query.\n  -o, --operation \u003caction\u003e  Supported operations: create, update, upsert, delete, bulk-delete, provision-alert-rule-pack\n  --entity                  Specifies entity operations.\n  --relationship            Specifies relationship operations.\n  --alert                   Specifies alert rule operations.\n  -f, --file \u003cdir\u003e          Input JSON file. Or the filename of the alert rule pack.\n  --api-base-url \u003curl\u003e      Optionally specify base URL to use during execution. (defaults to `https://api.us.jupiterone.io`)\n  -h, --help                output usage information\n```\n\n#### Relevant Environment Variables\n\nJ1_API_TOKEN - Sets the JupiterOne API access token as environment variable\ninstead of passing it through -k parameter\n\nJ1_DEV_ENABLED - Alters the base url. Valid values: 'true' | 'false' (string)\n\n## Examples\n\n### Run a J1QL query\n\n```bash\nj1 -a j1dev -q 'Find jupiterone_account'\nValidating inputs...\nAuthenticating with JupiterOne... OK\n[\n  {\n    \"id\": \"06ab12cd-a402-406c-8582-abcdef001122\",\n    \"entity\": {\n      \"_beginOn\": 1553777431867,\n      \"_createdOn\": 1553366320704,\n      \"_deleted\": false,\n      \"displayName\": \"YCO, Inc.\",\n      \"_type\": [\n        \"jupiterone_account\"\n      ],\n      \"_key\": \"1a2b3c4d-44ce-4a2f-8cd8-99dd88cc77bb\",\n      \"_accountId\": \"j1dev\",\n      \"_source\": \"api\",\n      \"_id\": \"1a2b3c4d-44ce-4a2f-8cd8-99dd88cc77bb\",\n      \"_class\": [\n        \"Account\"\n      ],\n      \"_version\": 6\n    },\n    \"properties\": {\n      \"emailDomain\": \"yourcompany.com\",\n      \"phoneNumber\": \"877-555-4321\",\n      \"webURL\": \"https://yourcompany.com/\",\n      \"name\": \"YCO\"\n    }\n  }\n]\nDone!\n```\n\n#### Advanced Node Usage\n\nYou are able to pass in Apollo Query Options into the `queryV1` method. This is\nbeneficial when you need to change how the cache behaves, for example. More\ninformation about what data you can provide found here:\nhttps://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy\n\nTo do so:\n\n```\n\n  // Pass in options like shown below:\n\n  const options = {\n    'fetchPolicy': 'network-only'\n  }\n\n  j1.queryV1('FIND jupiterone_account', options)\n\n```\n\n### Create or update entities from a JSON input file\n\n```bash\nj1 -o create --entity -a j1dev -f ./local/entities.json\nValidating inputs...\nAuthenticating with JupiterOne... Authenticated!\nCreated entity 12345678-fe34-44ee-b3b0-abcdef123456.\nCreated entity 12345678-e75f-40d6-858e-123456abcdef.\nDone!\n\nj1 -o update --entity -a j1dev -f ./local/entities.json\nValidating inputs...\nAuthenticating with JupiterOne... Authenticated!\nUpdated entity 12345678-fe34-44ee-b3b0-abcdef123456.\nUpdated entity 12345678-e75f-40d6-858e-123456abcdef.\nDone!\n```\n\n**NOTE:** the `create` operation will also update an existing entity, if an\nentity matching the provided Key, Type, and Class already exists in JupiterOne.\nThe `update` operation will fail unless that entity Id already exists.\n\nThe input JSON file is a single entity or an array of entities. For example:\n\n```json\n[\n  {\n    \"entityId\": \"12345678-fe34-44ee-b3b0-abcdef123456\",\n    \"entityKey\": \"test:entity:1\",\n    \"entityType\": \"generic_resource\",\n    \"entityClass\": \"Resource\",\n    \"properties\": {\n      \"name\": \"Test Entity Resource 1\",\n      \"displayName\": \"TER1\"\n    }\n  },\n  {\n    \"entityId\": \"12345678-e75f-40d6-858e-123456abcdef\",\n    \"entityKey\": \"test:entity:3\",\n    \"entityType\": \"generic_resource\",\n    \"entityClass\": \"Resource\",\n    \"properties\": {\n      \"name\": \"Test Entity Resource 2\",\n      \"displayName\": \"TER2\"\n    }\n  }\n]\n```\n\nThe `entityId` property is only necessary for `update` operations.\n\n### Create or update alert rules from a JSON input file\n\n```bash\nj1 -o create --alert -a j1dev -f ./local/alerts.json\nValidating inputs...\nAuthenticating with JupiterOne... OK\nCreated alert rule \u003cuuid\u003e.\nDone!\n```\n\nThe input JSON file is one or an array of alert rule instances. The following is\nan example of a single alert rule instance:\n\n```json\n{\n  \"instance\": {\n    \"name\": \"unencrypted-prod-data\",\n    \"description\": \"Data stores in production tagged critical and unencrypted\",\n    \"specVersion\": 1,\n    \"pollingInterval\": \"ONE_DAY\",\n    \"outputs\": [\"alertLevel\"],\n    \"operations\": [\n      {\n        \"when\": {\n          \"type\": \"FILTER\",\n          \"specVersion\": 1,\n          \"condition\": [\n            \"AND\",\n            [\"queries.unencryptedCriticalData.total\", \"!=\", 0]\n          ]\n        },\n        \"actions\": [\n          {\n            \"type\": \"SET_PROPERTY\",\n            \"targetProperty\": \"alertLevel\",\n            \"targetValue\": \"CRITICAL\"\n          },\n          {\n            \"type\": \"CREATE_ALERT\"\n          }\n        ]\n      }\n    ],\n    \"question\": {\n      \"queries\": [\n        {\n          \"query\": \"Find DataStore with (production=true or tag.Production=true) and classification='critical' and encrypted!=true as d return d.tag.AccountName as Account, d.displayName as UnencryptedDataStores, d._type as Type, d.encrypted as Encrypted\",\n          \"version\": \"v1\",\n          \"name\": \"unencryptedCriticalData\"\n        }\n      ]\n    }\n  }\n}\n```\n\nAdd `\"id\": \"\u003cuuid\u003e\"` property to the instance JSON when updating an alert rule.\n\n### Bulk Delete\n\n```bash\nj1 -q 'Find SomeDataClass with someProp=\"some value\"'\nj1 -e -o bulk-delete -f ./results.json\n```\n\nThe first CLI command queries data using a J1QL query and saves the data locally\nto `results.json`. The second CLI command takes `results.json` as input and bulk\ndeletes all the entities in the file.\n\n### Provision Alert Rules from Rule Pack\n\nThe following command will provision all the default alert rules from\n`jupiterone-alert-rules` with the rule pack name `aws-config`:\n\n```bash\nj1 -a \u003cj1AccountId\u003e -u \u003cj1Username\u003e -o provision-alert-rule-pack --alert -f aws-config\n```\n\nYou can specify your own rule pack to provision as well, by specifying the full\nfile path to the `rule-pack.json` file:\n\n```bash\nj1 -a \u003cj1AccountId\u003e -u \u003cj1Username\u003e -o provision-alert-rule-pack --alert -f path/to/your/rule-pack.json\n```\n\nFor more details about the rules and rule packs, see the\n`jupiterone-alert-rules` project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Fjupiterone-client-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupiterone%2Fjupiterone-client-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Fjupiterone-client-nodejs/lists"}