Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

RyuNen344/WebAuthnKt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebAuthnKt

Maven Central jitpack

Pure pre-implementation of Web Authentication: An API for accessing Public Key Credentials Level 2
This library allows you to use WebAuthn JSON without self-implementation.
Assume that uses this library with CredentialManager
But your app doesn't need to depend on GMS APIs.
Inspired by webauthn-json

Pre-implemented JSONs

Supported Serialization Library

Setup

MavenCentral

Set your settings.gradle like below

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

Set your build.gradle like below

dependencies {
    // moshi
    implementation 'io.github.ryunen344.webauthn:webauthn2-json-moshi:${version}'
    
    // kotlinx.serialization
    implementation 'io.github.ryunen344.webauthn:webauthn2-json-serialization:${version}'
}

JitPack

Set your settings.gradle like below

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Set your build.gradle like below

dependencies {
    // moshi
    implementation 'com.github.RyuNen344.WebAuthnKt:webauthn2-json-moshi:${version}'
    
    // kotlinx.serialization
    implementation 'com.github.RyuNen344.WebAuthnKt:webauthn2-json-serialization:${version}'
}

Usage

Moshi

you need to use WebAuthnAdapterHelper to setup moshi

val moshi = Moshi.Builder().apply(WebAuthnAdapterHelper()::setup).build()
val adapter = moshi.adapter(PublicKeyCredentialCreationOptions::class.java)
val json = adapter.fromJson(PublicKeyCredentialCreationOptionsJSON)

kotlinx.serialization

you can use serializers, directly

Json {}.encodeToString(
    PublicKeyCredentialRequestOptions.serializer(),
    PublicKeyCredentialRequestOptionsJSON
)

License

Copyright 2023 RyuNen344
Copyright 2015 Square, Inc.
Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0.txt

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.