Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Defs/Html/Html.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<WarningLevel>4</WarningLevel>
<OutputPath>bin\$(Configuration)\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>SharpKit.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -649,6 +648,16 @@
<Compile Include="custom\modules\indexeddb\IDBRequest.cs" />
<Compile Include="custom\modules\indexeddb\IDBTransaction.cs" />
<Compile Include="custom\modules\indexeddb\ObjectStoreOptions.cs" />
<Compile Include="custom\modules\u2f\U2F.cs" />
<Compile Include="custom\modules\u2f\DOMWindow.cs" />
<Compile Include="custom\modules\u2f\Request.cs" />
<Compile Include="custom\modules\u2f\Response.cs" />
<Compile Include="custom\modules\u2f\SignRequest.cs" />
<Compile Include="custom\modules\u2f\RegisterRequest.cs" />
<Compile Include="custom\modules\u2f\ErrorCode.cs" />
<Compile Include="custom\modules\u2f\SignResponse.cs" />
<Compile Include="custom\modules\u2f\RegisterResponse.cs" />
<Compile Include="custom\modules\u2f\ResponseData.cs" />
</ItemGroup>
<ItemGroup>
<None Include="SharpKit.snk" />
Expand Down Expand Up @@ -679,4 +688,7 @@
</Target>
-->
<ItemGroup />
<ItemGroup>
<Folder Include="custom\modules\u2f\" />
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions Defs/Html/custom/modules/u2f/DOMWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html
{
[JsType(JsMode.Prototype, Export = false, PropertiesAsFields = true, NativeCasts = true, Name = "Window")]
public partial class Window
{
/// <summary>
/// FIDO U2F
/// http://fidoalliance.org/specs/fido-u2f-javascript-api-v1.0-rd-20141008.pdf
/// </summary>
public SharpKit.Html.U2F.U2F u2f { get; set; }
}
}
36 changes: 36 additions & 0 deletions Defs/Html/custom/modules/u2f/ErrorCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
[JsType(JsMode.Json)]
public enum ErrorCode
{
/// <summary>
/// Success. Not used in errors but reserved
/// </summary>
OK = 0,
/// <summary>
/// An error otherwise not enumerated here
/// </summary>
OtherError = 1,
/// <summary>
/// The request cannot be processed
/// </summary>
BadRequest = 2,
/// <summary>
/// Client configuration is not supported
/// </summary>
ConfigurationUnsupported = 3,
/// <summary>
/// The presented device is not eligible for this request. For a registration request this may mean that the token is already registered, and
/// for a sign request it may mean the token does not know the presented key handle.
/// </summary>
DeviceIneligible = 4,
/// <summary>
/// Timeout reached before request could be satisfied
/// </summary>
Timeout = 5,
}
}

30 changes: 30 additions & 0 deletions Defs/Html/custom/modules/u2f/RegisterRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class RegisterRequest
{
/// <summary>
/// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2".
/// </summary>
[JsProperty(Name = "version", NativeField = true)]
public JsString Version { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "challenge", NativeField = true)]
public JsString Challenge { get; set; }

/// <summary>
/// The application id that the RP asserts. The new key pair that the U2F token generates will be associated with this application id.
/// (For application id details see [U2FAppFacet] in bibliography).
/// </summary>
[JsProperty(Name = "appId", NativeField = true)]
public JsString AppID { get; set; }

}
}

29 changes: 29 additions & 0 deletions Defs/Html/custom/modules/u2f/RegisterResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
/// <summary>
/// Error or RegisterResponse or SignResponse
/// - all in one class
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class RegisterResponse
{
[JsProperty(Name = "errorCode", NativeField = true)]
public ErrorCode ErrorCode { get; set; }

[JsProperty(Name = "errorMessage", NativeField = true)]
public JsString ErrorMessage { get; set; }

[JsProperty(Name = "registrationData", NativeField = true)]
public JsString RegistrationData { get; set; }

/// <summary>
/// The client data created by the FIDO client, websafe-base64 encoded
/// </summary>
[JsProperty(Name = "clientData", NativeField = true)]
public JsString ClientData { get; set; }
}
}

43 changes: 43 additions & 0 deletions Defs/Html/custom/modules/u2f/Request.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
/// <summary>
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class Request
{
/// <summary>
/// The type of request, either "u2f_register_request" or "u2f_sign_request".
/// </summary>
[JsProperty(Name = "type", NativeField = true)]
public JsString Type { get; set; }

/// <summary>
/// A list of SignRequest dictionaries, one for each token already registered with this RP.
/// </summary>
[JsProperty(Name = "signRequests", NativeField = true)]
public SignRequest[] SignRequest { get; set; }

/// <summary>
/// A list of RegisterRequest dictionaries, one for each protocol version that the RP is willing to register.
/// </summary>
[JsProperty(Name = "registerRequests", NativeField = true)]
public RegisterRequest[] RegisterRequest { get; set; }

/// <summary>
/// A timeout for the FIDO Client's processing, in seconds
/// </summary>
[JsProperty(Name = "timeoutSeconds", NativeField = true)]
public int TimeoutSeconds { get; set; }

/// <summary>
/// An integer identifying this request from concurrent requests.
/// </summary>
[JsProperty(Name = "requestId", NativeField = true)]
public int RequestId { get; set; }
}
}

31 changes: 31 additions & 0 deletions Defs/Html/custom/modules/u2f/Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
/// <summary>
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class Response
{
/// <summary>
/// The type of request, either "u2f_register_request" or "u2f_sign_request".
/// </summary>
[JsProperty(Name = "type", NativeField = true)]
public JsString Type { get; set; }

/// <summary>
/// Error or RegisterResponse or SignResponse
/// </summary>
[JsProperty(Name = "responseData", NativeField = true)]
public ResponseData ResponseData { get; set; }

/// <summary>
/// An integer identifying this request from concurrent requests.
/// </summary>
[JsProperty(Name = "requestId", NativeField = true)]
public int RequestId { get; set; }
}
}

60 changes: 60 additions & 0 deletions Defs/Html/custom/modules/u2f/ResponseData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
/// <summary>
/// Error or RegisterResponse or SignResponse
/// - all in one class
/// Low-level API
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class ResponseData
{
#region Error

[JsProperty(Name = "errorCode", NativeField = true)]
public ErrorCode ErrorCode { get; set; }

[JsProperty(Name = "errorMessage", NativeField = true)]
public JsString ErrorMessage { get; set; }

#endregion

#region RegisterResponse

[JsProperty(Name = "registrationData", NativeField = true)]
public JsString RegistrationData { get; set; }

//clientData

#endregion

#region SignResponse

/// <summary>
/// The keyHandle of the SignRequest that was processed.
/// </summary>
[JsProperty(Name = "keyHandle", NativeField = true)]
public JsString KeyHandle { get; set; }

/// <summary>
/// The raw response from U2F device, websafe-base64 encoded.
/// </summary>
[JsProperty(Name = "signatureData", NativeField = true)]
public JsString SignatureData { get; set; }

//clientData

#endregion

//Shared in RegisterResponse and SingResposne
/// <summary>
/// The client data created by the FIDO client, websafe-base64 encoded
/// </summary>
[JsProperty(Name = "clientData", NativeField = true)]
public JsString ClientData { get; set; }

}
}

36 changes: 36 additions & 0 deletions Defs/Html/custom/modules/u2f/SignRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class SignRequest
{
/// <summary>
/// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2".
/// </summary>
[JsProperty(Name = "version", NativeField = true)]
public JsString Version { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "challenge", NativeField = true)]
public JsString Challenge { get; set; }

/// <summary>
/// The websafe-base64-encoded challenge.
/// </summary>
[JsProperty(Name = "keyHandle", NativeField = true)]
public JsString KeyHandle { get; set; }

/// <summary>
/// The application id that the RP asserts. The new key pair that the U2F token generates will be associated with this application id.
/// (For application id details see [U2FAppFacet] in bibliography).
/// </summary>
[JsProperty(Name = "appId", NativeField = true)]
public JsString AppID { get; set; }

}
}

39 changes: 39 additions & 0 deletions Defs/Html/custom/modules/u2f/SignResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using SharpKit.JavaScript;

namespace SharpKit.Html.U2F
{
/// <summary>
/// Error or RegisterResponse or SignResponse
/// - all in one class
/// </summary>
[JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)]
public class SignResponse
{
[JsProperty(Name = "errorCode", NativeField = true)]
public ErrorCode ErrorCode { get; set; }

[JsProperty(Name = "errorMessage", NativeField = true)]
public JsString ErrorMessage { get; set; }

/// <summary>
/// The keyHandle of the SignRequest that was processed.
/// </summary>
[JsProperty(Name = "keyHandle", NativeField = true)]
public JsString KeyHandle { get; set; }

/// <summary>
/// The raw response from U2F device, websafe-base64 encoded.
/// </summary>
[JsProperty(Name = "signatureData", NativeField = true)]
public JsString SignatureData { get; set; }

/// <summary>
/// The client data created by the FIDO client, websafe-base64 encoded
/// </summary>
[JsProperty(Name = "clientData", NativeField = true)]
public JsString ClientData { get; set; }

}
}

Loading