-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea45aaa
commit 21c9655
Showing
31 changed files
with
809 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NOnStar\NOnStar.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace NOnStar.ConsoleApp | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//must specify email address, password & PIN used for OnStar | ||
var client = new OnStarClient("your_email_address", "onstar_password", "pin"); | ||
|
||
//Uncomment and try one: | ||
//client.UnlockVehical().GetAwaiter().GetResult(); | ||
//client.LockVehical().GetAwaiter().GetResult(); | ||
//client.StartVehical().GetAwaiter().GetResult(); | ||
//client.StopVehical().GetAwaiter().GetResult(); | ||
|
||
Console.WriteLine("Done"); | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27703.2035 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NOnStar", "NOnStar\NOnStar.csproj", "{B2E505EC-2F16-4DF1-9AA9-80176658D455}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NOnStar.ConsoleApp", "NOnStar.ConsoleApp\NOnStar.ConsoleApp.csproj", "{F9E9AE6A-1D1F-4D25-8ECF-41A16E17707D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B2E505EC-2F16-4DF1-9AA9-80176658D455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B2E505EC-2F16-4DF1-9AA9-80176658D455}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B2E505EC-2F16-4DF1-9AA9-80176658D455}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B2E505EC-2F16-4DF1-9AA9-80176658D455}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{F9E9AE6A-1D1F-4D25-8ECF-41A16E17707D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F9E9AE6A-1D1F-4D25-8ECF-41A16E17707D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F9E9AE6A-1D1F-4D25-8ECF-41A16E17707D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F9E9AE6A-1D1F-4D25-8ECF-41A16E17707D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A727B3BB-C9A5-4273-A4B8-705522DE1F87} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar | ||
{ | ||
abstract class BaseAuth | ||
{ | ||
public string nonce = GetNonce(); | ||
public string timestamp = GetTimestamp(); | ||
|
||
protected static string GetNonce() | ||
{ | ||
return Guid.NewGuid().ToString("N").ToLower(); | ||
} | ||
|
||
protected static string GetTimestamp() | ||
{ | ||
return DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); | ||
} | ||
} | ||
|
||
class DeviceAuth : BaseAuth | ||
{ | ||
public string client_id; | ||
public string device_id; | ||
public string grant_type; | ||
public string username; | ||
public string password; | ||
public string scope = "onstar gmoc commerce msso"; | ||
} | ||
|
||
|
||
class PinAuth : BaseAuth | ||
{ | ||
public string credential; | ||
public string device_id; | ||
public string scope = "onstar commerce"; | ||
public string credential_type = "PIN"; | ||
public string client_id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar.CommandAndControl | ||
{ | ||
class Body | ||
{ | ||
public Error error { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar.CommandAndControl | ||
{ | ||
public class CommandRequestStatus | ||
{ | ||
public bool Successful { get; internal set; } | ||
public string ErrorMessage { get; internal set; } | ||
|
||
public static CommandRequestStatus GetSuccessful() | ||
{ | ||
return new CommandRequestStatus() { Successful = true }; | ||
} | ||
|
||
public static CommandRequestStatus GetFailed(string errorMessage) | ||
{ | ||
return new CommandRequestStatus() { Successful = false, ErrorMessage = errorMessage }; | ||
} | ||
} | ||
|
||
public class CommandRequestStatus<T> : CommandRequestStatus | ||
{ | ||
public T Content { get; internal set; } | ||
|
||
public static CommandRequestStatus<T> GetSuccessful(T content) | ||
{ | ||
return new CommandRequestStatus<T>() { Successful = true, Content = content }; | ||
} | ||
|
||
public static new CommandRequestStatus<T> GetFailed(string errorMessage) | ||
{ | ||
return new CommandRequestStatus<T>() { Successful = false, ErrorMessage = errorMessage }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar.CommandAndControl | ||
{ | ||
class CommandResponse | ||
{ | ||
public DateTime requestTime { get; set; } | ||
public DateTime completionTime { get; set; } | ||
public string url { get; set; } | ||
public string status { get; set; } | ||
public string type { get; set; } | ||
public Body body { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar.CommandAndControl | ||
{ | ||
class Error | ||
{ | ||
public string code { get; set; } | ||
public string description { get; set; } | ||
public string subCode { get; set; } | ||
public string subCodeDescription { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar.CommandAndControl | ||
{ | ||
class OuterCommandResponse | ||
{ | ||
public CommandResponse commandResponse { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using JWT.Builder; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NOnStar | ||
{ | ||
static class ExtensionMethods | ||
{ | ||
public static JwtBuilder AddClaims(this JwtBuilder builder, DeviceAuth deviceAuth) | ||
{ | ||
return builder | ||
.AddClaim("client_id", deviceAuth.client_id) | ||
.AddClaim("device_id", deviceAuth.device_id) | ||
.AddClaim("username", deviceAuth.username) | ||
.AddClaim("password", deviceAuth.password) | ||
.AddClaim("nonce", deviceAuth.nonce) | ||
.AddClaim("timestamp", deviceAuth.timestamp) | ||
.AddClaim("scope", deviceAuth.scope) | ||
.AddClaim("grant_type", deviceAuth.grant_type); | ||
} | ||
|
||
public static JwtBuilder AddClaims(this JwtBuilder builder, PinAuth pinPayload) | ||
{ | ||
return builder | ||
.AddClaim("client_id", pinPayload.client_id) | ||
.AddClaim("device_id", pinPayload.device_id) | ||
.AddClaim("credential", pinPayload.credential) | ||
.AddClaim("credential_type", pinPayload.credential_type) | ||
.AddClaim("nonce", pinPayload.nonce) | ||
.AddClaim("timestamp", pinPayload.timestamp) | ||
.AddClaim("scope", pinPayload.scope); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<AssemblyName>NOnStar</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JWT" Version="4.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.