Skip to content

Commit

Permalink
Added types, updated Android and iOS SDK-s, updated package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKuliahin96 committed Sep 27, 2023
1 parent fb610a5 commit 4ec2225
Show file tree
Hide file tree
Showing 7 changed files with 432 additions and 280 deletions.
141 changes: 95 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,113 @@
## **System Requirements**

* iOS 14+, Swift 5.3
* Android API level 23 or higher, AndroidX, Kotlin coroutines compatability
* iOS 14+, Swift 5.3
* Android API level 23 or higher, target sdk 33 or higher AndroidX, Kotlin coroutines compatability

## **Interacting with the Plugin**

Please see the examples below as well as a full set of method examples here: https://github.com/Keyri-Co/sample-cordova-app/blob/main/keyriSample/www/js/index.js
Please see the examples below as well as a full set of method examples
here: https://github.com/Keyri-Co/sample-cordova-app/blob/main/keyriSample/www/js/index.js

### Initialize Keyri
To initialize the Keyri object, simply call the initialize method, and pass in your app key and api key, generated in the Keyri dashboard
```JS
let Keyri;
let appKey = 'your_app_key'
let publicApiKey = 'your_api_key'

Keyri.initialize(appKey, publicApiKey, true, (message) => {
console.log('CordovaKeyri.initialize', message);
}, (e) => {
console.log('CordovaKeyri.initialize', e);

To initialize the Keyri object, simply call the initialize method, and pass in your app key and api key, generated in
the Keyri dashboard

```javascript
Keyri.initialize({
appKey: appKey,
publicApiKey: publicApiKey,
serviceEncryptionKey: serviceEncryptionKey,
blockEmulatorDetection: true
})
.then((message) => {
console.log('CordovaKeyri.initialize', message);
isInitialized();
})
.catch((e) => {
console.log('CordovaKeyri.initialize', e);
});
```

### Generate and retrieve association key
The association key is the cryptographic identity we use to identify users. It sits in the Trusted Development Environment, a hardware separated chip shielded from attacks to the main perating system. The key functions as a P256 Curve signing key. To generate:
```JS
Keyri.generateAssociationKey('kuliahin.andrew@gmail.com', (key) => {
console.log('CordovaKeyri.generateAssociationKey', key);
alert('Key generated: ' + key)
}, (e) => {
console.log('CordovaKeyri.generateAssociationKey', e);
})

The association key is the cryptographic identity we use to identify users. It sits in the Trusted Development
Environment, a hardware separated chip shielded from attacks to the main perating system. The key functions as a P256
Curve signing key. To generate:

```javascript
Keyri.generateAssociationKey('kuliahin.andrew@gmail.com')
.then((key) => {
console.log('CordovaKeyri.generateAssociationKey', key);
alert('Key generated: ' + key)
})
.catch((e) => {
console.log('CordovaKeyri.generateAssociationKey', e);
});
```

To look up an existing user's key:
```JS
Keyri.getAssociationKey('kuliahin.andrew@gmail.com', (key) => {
console.log('CordovaKeyri.getAssociationKey', key);
alert('Association key: ' + key);
}, (e) => {
console.log('CordovaKeyri.getAssociationKey', e);
})

```javascript
Keyri.getAssociationKey('kuliahin.andrew@gmail.com')
.then((key) => {
console.log('CordovaKeyri.getAssociationKey', key);
alert('Association key: ' + key);
})
.catch((e) => {
console.log('CordovaKeyri.getAssociationKey', e);
});
```

### Enable QR Auth
QR Auth can be enabled with a single function call. This process handles scanning the code, generating the session info, displaying a confirmation screen to the user, and, if the user confirms, sending the encrypted payload you provide to the Keyri widget in your browser.
```JS
Keyri.easyKeyriAuth(appKey, publicAppKey, 'Some Payload', 'kulahin.andrew@gmail.com', () => {
console.log('CordovaKeyri.easyKeyriAuth', 'ok');
alert('Payload sent');
}, (e) => {
console.log('CordovaKeyri.easyKeyriAuth', e);
})

QR Auth can be enabled with a single function call. This process handles scanning the code, generating the session info,
displaying a confirmation screen to the user, and, if the user confirms, sending the encrypted payload you provide to
the Keyri widget in your browser.

```javascript
Keyri.easyKeyriAuth('Payload', 'kulagin.andrew38@gmail.com')
.then(() => {
console.log('CordovaKeyri.easyKeyriAuth', 'ok');
alert('Authorized');
})
.catch((e) => {
console.log('CordovaKeyri.easyKeyriAuth', e);
});
```

### User Signatures
The association keys can be used to sign data to send to a remote server. If the server has the user's public key (see above), it can then verify the identity of the user as a security measure. Below is an example of how to create a signature of some data, passed in as a string
```JS
Keyri.getUserSignature('kuliahin.andrew@gmail.com', 'Custom data', (signature) => {
console.log('CordovaKeyri.getUserSignature', signature);
alert('Signature generated: ' + signature);
}, (e) => {
console.log('CordovaKeyri.getUserSignature', e);
})

The association keys can be used to sign data to send to a remote server. If the server has the user's public key (see
above), it can then verify the identity of the user as a security measure. Below is an example of how to create a
signature of some data, passed in as a string

```javascript
Keyri.generateUserSignature('kuliahin.andrew@gmail.com', 'Custom data')
.then((signature) => {
console.log('CordovaKeyri.generateUserSignature', signature);
alert('Signature generated: ' + signature)
})
.catch((e) => {
console.log('CordovaKeyri.generateUserSignature', e);
});
```

### Fingerprint Events

You can send an event containing a device snapshot to our dashboard. The response you receive will be sent, as
is, to your own backend, where you can utilize our scripts to help you decrypt. See the code sample below
and https://docs.keyri.com/fraud-prevention for more

```javascript
Keyri.sendEvent({publicUserId: 'kuliahin.andrew@gmail.com', eventType: 'visits', success: true})
.then(() => {
console.log('CordovaKeyri.sendEvent', 'ok');
alert('Event sent!');
})
.catch((e) => {
console.log('CordovaKeyri.sendEvent', e);
});
```

## License
Expand All @@ -87,7 +133,10 @@ What's not allowed under the license:
* Indemnification: using this free software is ‘at your own risk’, so you can’t sue Keyri, Inc. for
problems caused by this library


### Disclaimer

We care deeply about the quality of our product and rigorously test every piece of functionality we offer. That said, every integration is different. Every app on the App Store has a different permutation of build settings, compiler flags, processor requirements, compatability issues etc and it's impossible for us to cover all of those bases, so we strongly recommend thourough testing of your integration before shipping to production. Please feel free to file a bug or issue if you notice anything that seems wrong or weird on GitHub 🙂
We care deeply about the quality of our product and rigorously test every piece of functionality we offer. That said,
every integration is different. Every app on the App Store has a different permutation of build settings, compiler
flags, processor requirements, compatability issues etc and it's impossible for us to cover all of those bases, so we
strongly recommend thorough testing of your integration before shipping to production. Please feel free to file a bug
or issue if you notice anything that seems wrong or weird on GitHub 🙂
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.0",
"version": "0.1.3",
"name": "@keyri/cordova-keyri",
"cordova_name": "Cordova Keyri Plugin",
"description": "Cordova Keyri SDK Plugin for QR login",
Expand Down
14 changes: 8 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-keyri"
version="0.1.0">
version="0.1.3">

<name>CordovaKeyri</name>
<description>Cordova Keyri SDK Plugin</description>

<keywords>authentication, qr-login, passwordless, multifactor-authentication, mobile-authentication, ecosystem:cordova, cordova-android, cordova, camera, cordova-ios</keywords>
<license>MIT</license>

<engines>
<engine name="cordova" version=">=11.0.0"/>
<engine name="cordova-android" version=">=11.0.0"/>
</engines>

<js-module src="www/CordovaKeyri.js" name="CordovaKeyri">
<clobbers target="cordova.plugins.CordovaKeyri"/>
<js-module src="dist/index.js" name="CordovaKeyriPlugin">
<clobbers target="CordovaKeyri"/>
</js-module>

<js-module src="dist/types.js" name="types"/>

<platform name="android">
<framework src="com.keyri:keyrisdk:4.0.0"/>
<framework src="com.keyri:scanner:4.0.0"/>
Expand All @@ -27,7 +29,7 @@

<config-file target="config.xml" parent="/*">
<preference name="GradlePluginKotlinEnabled" value="true"/>
<preference name="GradlePluginKotlinVersion" value="1.6.0"/>
<preference name="GradlePluginKotlinVersion" value="1.8.21"/>

<feature name="CordovaKeyri">
<param name="android-package" value="com.keyri.cordova.plugin.CordovaKeyri"/>
Expand All @@ -50,7 +52,7 @@
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="keyri-pod" spec="~> 4.1.2"/>
<pod name="keyri-pod" spec="~> 4.2.0"/>
</pods>
</podspec>
</platform>
Expand Down
Loading

0 comments on commit 4ec2225

Please sign in to comment.