diff --git a/Defs/Defs.sln b/Defs/Defs.sln index 1513927..a0aff6e 100644 --- a/Defs/Defs.sln +++ b/Defs/Defs.sln @@ -109,6 +109,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xdk.IntelXdk", "Xdk.IntelXd EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xdk.JavaScript", "Xdk.JavaScript\Xdk.JavaScript.csproj", "{A7B1398F-706F-4057-9185-5E4B305096BF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIDO", "FIDO\FIDO.csproj", "{7FD68F02-F406-4F7A-9883-865E292B5982}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Defs/FIDO/ErrorCode.cs b/Defs/FIDO/ErrorCode.cs new file mode 100644 index 0000000..1516047 --- /dev/null +++ b/Defs/FIDO/ErrorCode.cs @@ -0,0 +1,36 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + [JsType(JsMode.Json)] + public enum ErrorCode + { + /// + /// Success. Not used in errors but reserved + /// + OK = 0, + /// + /// An error otherwise not enumerated here + /// + OtherError = 1, + /// + /// The request cannot be processed + /// + BadRequest = 2, + /// + /// Client configuration is not supported + /// + ConfigurationUnsupported = 3, + /// + /// 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. + /// + DeviceIneligible = 4, + /// + /// Timeout reached before request could be satisfied + /// + Timeout = 5, + } +} + diff --git a/Defs/FIDO/FIDO.csproj b/Defs/FIDO/FIDO.csproj new file mode 100644 index 0000000..648509f --- /dev/null +++ b/Defs/FIDO/FIDO.csproj @@ -0,0 +1,62 @@ + + + + Debug + AnyCPU + {7FD68F02-F406-4F7A-9883-865E292B5982} + Library + SharpKit.FIDO + U2F + v4.5 + 500 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {5A90FAC8-67DA-4823-B114-91F5A26B2FE9} + JavaScript + + + \ No newline at end of file diff --git a/Defs/FIDO/Properties/AssemblyInfo.cs b/Defs/FIDO/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..734af31 --- /dev/null +++ b/Defs/FIDO/Properties/AssemblyInfo.cs @@ -0,0 +1,25 @@ +using System.Reflection; +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("U2F")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("peter")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Defs/FIDO/RegisterRequest.cs b/Defs/FIDO/RegisterRequest.cs new file mode 100644 index 0000000..084f75b --- /dev/null +++ b/Defs/FIDO/RegisterRequest.cs @@ -0,0 +1,30 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + [JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)] + public class RegisterRequest + { + /// + /// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2". + /// + [JsProperty(Name = "version", NativeField = true)] + public JsString Version { get; set; } + + /// + /// The websafe-base64-encoded challenge. + /// + [JsProperty(Name = "challenge", NativeField = true)] + public JsString Challenge { get; set; } + + /// + /// 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). + /// + [JsProperty(Name = "appId", NativeField = true)] + public JsString AppID { get; set; } + + } +} + diff --git a/Defs/FIDO/RegisterResponse.cs b/Defs/FIDO/RegisterResponse.cs new file mode 100644 index 0000000..368dda2 --- /dev/null +++ b/Defs/FIDO/RegisterResponse.cs @@ -0,0 +1,29 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// Error or RegisterResponse or SignResponse + /// - all in one class + /// + [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; } + + /// + /// The client data created by the FIDO client, websafe-base64 encoded + /// + [JsProperty(Name = "clientData", NativeField = true)] + public JsString ClientData { get; set; } + } +} + diff --git a/Defs/FIDO/Request.cs b/Defs/FIDO/Request.cs new file mode 100644 index 0000000..eb5eb65 --- /dev/null +++ b/Defs/FIDO/Request.cs @@ -0,0 +1,43 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// Low-level API + /// + [JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)] + public class Request + { + /// + /// The type of request, either "u2f_register_request" or "u2f_sign_request". + /// + [JsProperty(Name = "type", NativeField = true)] + public JsString Type { get; set; } + + /// + /// A list of SignRequest dictionaries, one for each token already registered with this RP. + /// + [JsProperty(Name = "signRequests", NativeField = true)] + public SignRequest[] SignRequest { get; set; } + + /// + /// A list of RegisterRequest dictionaries, one for each protocol version that the RP is willing to register. + /// + [JsProperty(Name = "registerRequests", NativeField = true)] + public RegisterRequest[] RegisterRequest { get; set; } + + /// + /// A timeout for the FIDO Client's processing, in seconds + /// + [JsProperty(Name = "timeoutSeconds", NativeField = true)] + public int TimeoutSeconds { get; set; } + + /// + /// An integer identifying this request from concurrent requests. + /// + [JsProperty(Name = "requestId", NativeField = true)] + public int RequestId { get; set; } + } +} + diff --git a/Defs/FIDO/Response.cs b/Defs/FIDO/Response.cs new file mode 100644 index 0000000..e760f6f --- /dev/null +++ b/Defs/FIDO/Response.cs @@ -0,0 +1,31 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// Low-level API + /// + [JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)] + public class Response + { + /// + /// The type of request, either "u2f_register_request" or "u2f_sign_request". + /// + [JsProperty(Name = "type", NativeField = true)] + public JsString Type { get; set; } + + /// + /// Error or RegisterResponse or SignResponse + /// + [JsProperty(Name = "responseData", NativeField = true)] + public ResponseData ResponseData { get; set; } + + /// + /// An integer identifying this request from concurrent requests. + /// + [JsProperty(Name = "requestId", NativeField = true)] + public int RequestId { get; set; } + } +} + diff --git a/Defs/FIDO/ResponseData.cs b/Defs/FIDO/ResponseData.cs new file mode 100644 index 0000000..6549f73 --- /dev/null +++ b/Defs/FIDO/ResponseData.cs @@ -0,0 +1,60 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// Error or RegisterResponse or SignResponse + /// - all in one class + /// Low-level API + /// + [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 + + /// + /// The keyHandle of the SignRequest that was processed. + /// + [JsProperty(Name = "keyHandle", NativeField = true)] + public JsString KeyHandle { get; set; } + + /// + /// The raw response from U2F device, websafe-base64 encoded. + /// + [JsProperty(Name = "signatureData", NativeField = true)] + public JsString SignatureData { get; set; } + + //clientData + + #endregion + + //Shared in RegisterResponse and SingResposne + /// + /// The client data created by the FIDO client, websafe-base64 encoded + /// + [JsProperty(Name = "clientData", NativeField = true)] + public JsString ClientData { get; set; } + + } +} + diff --git a/Defs/FIDO/SignRequest.cs b/Defs/FIDO/SignRequest.cs new file mode 100644 index 0000000..c1d544c --- /dev/null +++ b/Defs/FIDO/SignRequest.cs @@ -0,0 +1,36 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + [JsType(JsMode.Json, PropertiesAsFields = true, NativeCasts = true)] + public class SignRequest + { + /// + /// The version of the protocol that the to-be-registered token must speak. E.g. "U2F_V2". + /// + [JsProperty(Name = "version", NativeField = true)] + public JsString Version { get; set; } + + /// + /// The websafe-base64-encoded challenge. + /// + [JsProperty(Name = "challenge", NativeField = true)] + public JsString Challenge { get; set; } + + /// + /// The websafe-base64-encoded challenge. + /// + [JsProperty(Name = "keyHandle", NativeField = true)] + public JsString KeyHandle { get; set; } + + /// + /// 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). + /// + [JsProperty(Name = "appId", NativeField = true)] + public JsString AppID { get; set; } + + } +} + diff --git a/Defs/FIDO/SignResponse.cs b/Defs/FIDO/SignResponse.cs new file mode 100644 index 0000000..e720ba7 --- /dev/null +++ b/Defs/FIDO/SignResponse.cs @@ -0,0 +1,39 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// Error or RegisterResponse or SignResponse + /// - all in one class + /// + [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; } + + /// + /// The keyHandle of the SignRequest that was processed. + /// + [JsProperty(Name = "keyHandle", NativeField = true)] + public JsString KeyHandle { get; set; } + + /// + /// The raw response from U2F device, websafe-base64 encoded. + /// + [JsProperty(Name = "signatureData", NativeField = true)] + public JsString SignatureData { get; set; } + + /// + /// The client data created by the FIDO client, websafe-base64 encoded + /// + [JsProperty(Name = "clientData", NativeField = true)] + public JsString ClientData { get; set; } + + } +} + diff --git a/Defs/FIDO/U2F.cs b/Defs/FIDO/U2F.cs new file mode 100644 index 0000000..0bdcff6 --- /dev/null +++ b/Defs/FIDO/U2F.cs @@ -0,0 +1,40 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + /// + /// FIDO U2F + /// http://fidoalliance.org/specs/fido-u2f-javascript-api-v1.0-rd-20141008.pdf + /// + [JsType(JsMode.Prototype, Export = false, PropertiesAsFields = true, NativeCasts = true, Name = "U2F")] + public class U2F + { + public const string Version2 = "U2F_V2"; + + /// + /// High-level API + /// + [JsMethod(Name = "register")] + public void Register(RegisterRequest[] registerRequests, SignRequest[] signRequests, JsAction callback, int timeoutSeconds = 0) + { + } + + /// + /// High-level API + /// + [JsMethod(Name = "sign")] + public void Sign(SignRequest[] signRequests, JsAction callback) + { + } + + /// + /// High-level API + /// + [JsMethod(Name = "sign")] + public void Sign(SignRequest[] signRequests, JsAction callback, int timeoutSeconds) + { + } + } +} + diff --git a/Defs/FIDO/U2FWindow.cs b/Defs/FIDO/U2FWindow.cs new file mode 100644 index 0000000..31c2436 --- /dev/null +++ b/Defs/FIDO/U2FWindow.cs @@ -0,0 +1,15 @@ +using System; +using SharpKit.JavaScript; + +namespace SharpKit.FIDO +{ + [JsType(JsMode.Prototype, Export = false, PropertiesAsFields = true, NativeCasts = true, Name = "window")] + public partial class U2FWindow + { + /// + /// FIDO U2F + /// http://fidoalliance.org/specs/fido-u2f-javascript-api-v1.0-rd-20141008.pdf + /// + public static U2F u2f { get; set; } + } +} \ No newline at end of file diff --git a/Defs/Html/generated/modules/vibration/NavigatorVibration.cs b/Defs/Html/generated/modules/vibration/NavigatorVibration.cs index 70aaee9..04b0a26 100644 --- a/Defs/Html/generated/modules/vibration/NavigatorVibration.cs +++ b/Defs/Html/generated/modules/vibration/NavigatorVibration.cs @@ -71,7 +71,7 @@ namespace SharpKit.Html.vibration public partial class Navigator { public void vibrate(int pattern) {} - public void vibrate(int time) {} + //public void vibrate(int time) {} } } \ No newline at end of file