npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

onstarjs2

v2.6.1

Published

Unofficial package for making OnStar API requests

Downloads

1,963

Readme

OnStarJS (OnStarJS2)

npm version Create Github Release Publish Package Coverage Status

An unofficial NodeJS library to make OnStar requests. This version has been forked from samrum/OnStarJS and includes the new TOTP login mechanism implemented by metheos.

Published as OnStarJS2 at https://www.npmjs.com/package/onstarjs2

Use at your own risk. This is an unofficial library.

Usage

Use the Get Account Vehicles request to see which requests your vehicle supports if you don't already know.

New Requirement as of 2024-11-19

Updated to use TOTP to fulfill new authentication process from GM.

You will need to change your OnStar account's MFA method to "Third-Party Authenticator App"

The "Third-Party Authenticator App" option doesn't seem to show up on mobile, so please try from a desktop browser.

You will need to capture your TOTP key from the "Third-Party Authenticator App" setup so that you can provide it in your .env or initialization config.

You may be able to obtain your TOTP key by inspecting/hovering over the link under the QR code when you are setting it up.

If you use an authenticator app such as Stratum, Bitwarden, or Vaultwarden that allows you to view your TOTP key, you can view it at any time.

In the IOS Passwords app you can tap "Copy Setup URL" and obtain the secret from the copied data.

If you cannot find the option to configure a "Third-Party Authenticator App" on your GM account page, try contacting OnStar to see if there is another way to enable it.

If that fails, use: this Windows exe or this web app

for email TOTP and then save the resulting token and provide the token location for use with https://github.com/BigThunderSR/onstar2mqtt and/or https://github.com/BigThunderSR/homeassistant-addons-onstar2mqtt.

Additional comments are noted here.

Sample

Use a random version 4 uuid as a deviceId. Generator available here.

import OnStar from "onstarjs";

const onStar = OnStar.create({
  deviceId: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  vin: "1G2ZF58B774109863",
  username: "[email protected]",
  password: "p@ssw0rd",
  onStarPin: "1234",
  onStarTOTP: "XXXXXXXXXXXXXXXX"
});

try {
  await onStar.alert({
    action: ["Flash"],
  });

  await onStar.start();
} catch (e) {
  console.error(e);
}

Additional Configuration Options

Default Value: true

When false, requests resolve when the API returns an 'In Progress' response. For requests that return data, this option is ignored.

This is useful because, with the usual request polling to wait for a "Complete" response from the API, requests will take much longer to resolve.

Default Value: 6

When checkRequestStatus is true, this is how often status check requests will be made (in seconds)

Default Value: 90

When checkRequestStatus is true, this is how long a request will make subsequent status check requests before timing out (in seconds)

Responses

For commands that return data like diagnostics or location, the data returned by the API is accessible via result.response.data

Commands

onStar.getAccountVehicles();
onStar.start();
onStar.cancelStart();
onStar.alert([options]);

| Option | Default | Valid Values | | -------- | -------------------------- | -------------------------- | | action | ["Flash", "Honk"] | ["Flash", "Honk"] | | delay | 0 | Any integer (minutes) | | duration | 1 | Any integer (minutes) | | override | ["DoorOpen", "IgnitionOn"] | ["DoorOpen", "IgnitionOn"] |

onStar.cancelAlert();
onStar.lockDoor([options]);

| Option | Default | Valid Values | | ------ | ------- | --------------------- | | delay | 0 | Any integer (minutes) |

onStar.unlockDoor([options]);

| Option | Default | Valid Values | | ------ | ------- | --------------------- | | delay | 0 | Any integer (minutes) |

Locks the trunk but doesn't automatically close it.

onStar.lockTrunk([options]);

| Option | Default | Valid Values | | ------ | ------- | --------------------- | | delay | 0 | Any integer (minutes) |

Unlocks the trunk but doesn't automatically open it. All doors remain locked.

onStar.unlockTrunk([options]);

| Option | Default | Valid Values | | ------ | ------- | --------------------- | | delay | 0 | Any integer (minutes) |

Returns the location of the vehicle

onStar.location();

Example Response

{ location: { lat: '50', long: '-75' } }
onStar.chargeOverride([options]);

| Option | Default | Valid Values | | ------ | ------------ | ------------------------------- | | mode | "CHARGE_NOW" | "CHARGE_NOW", "CANCEL_OVERRIDE" |

onStar.getChargingProfile();
onStar.setChargingProfile([options]);

| Option | Default | Valid Values | | ---------- | ----------- | ---------------------------------------------------------------------------------------- | | chargeMode | "IMMEDIATE" | "DEFAULT_IMMEDIATE", "IMMEDIATE", "DEPARTURE_BASED", "RATE_BASED", "PHEV_AFTER_MIDNIGHT" | | rateType | "MIDPEAK" | "OFFPEAK", "MIDPEAK", "PEAK" |

onStar.diagnostics([options]);

| Option | Default | Valid Values | | -------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | diagnosticItem | ["ODOMETER", "TIRE PRESSURE", "AMBIENT AIR TEMPERATURE", "LAST TRIP DISTANCE"] | ["ENGINE COOLANT TEMP", "ENGINE RPM", "LAST TRIP FUEL ECONOMY", "EV ESTIMATED CHARGE END", "EV BATTERY LEVEL", "OIL LIFE", "EV PLUG VOLTAGE", "LIFETIME FUEL ECON", "HOTSPOT CONFIG", "LIFETIME FUEL USED", "ODOMETER", "HOTSPOT STATUS", "LIFETIME EV ODOMETER", "EV PLUG STATE", "EV CHARGE STATE", "TIRE PRESSURE", "AMBIENT AIR TEMPERATURE", "LAST TRIP DISTANCE", "INTERM VOLT BATT VOLT", "GET COMMUTE SCHEDULE", "GET CHARGE MODE", "EV SCHEDULED CHARGE START", "FUEL TANK INFO", "HANDS FREE CALLING", "ENERGY EFFICIENCY", "VEHICLE RANGE"] |

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install

Tests

All

Run both unit and functional tests

pnpm test

Unit

pnpm test:unit

Auth

pnpm test:auth

Functional

These tests will execute actual requests to the OnStar API. They will perform a Get Account Vehicles request followed by a Cancel Alert request and then a Diagnostics request.

Because of this, the test will require actual OnStar credentials to run. To provide them, copy .env.example to .env and replace the placeholder values inside.

pnpm test:functional

Credits

Made possible by mikenemat's work in gm-onstar-probe. Their work describing the process for remote start enabled the rest of the methods implemented here.

samrum/OnStarJS for the original OnStarJS

New GMAuth functionality implemented by metheos