Skip to content

Instantly share code, notes, and snippets.

View dmennis's full-sized avatar

Dennis Hills dmennis

View GitHub Profile
func doSomething() {
connection { connection in
self.log(message: "Connection: \(connection.description)")
guard let smartCard = connection.smartCardInterface else {
self.log(error: "Failed to get smart card interface.")
return
}
@dmennis
dmennis / OATH-NFC-Controller.swift
Last active June 5, 2020 23:41
iOS Swift view controller to interact with the OATH module of a YubiKey over NFC
//
// ViewController.swift
// OATH-NFC
//
// Created by Dennis Hills on 6/5/20.
// Copyright © 2020 Dennis Hills. All rights reserved.
//
// Description: This is sample app demonstrating NFC interaction with the OATH module of a YubiKey using the Yubico iOS SDK
// The app establishes an open NFC connection with the YubiKey, reads the credentials from the OATH module and retrieves a TOTP code based on the first OATH credential retrieved.
//

Keybase proof

I hereby claim:

  • I am dmennis on github.
  • I am dmennis (https://keybase.io/dmennis) on keybase.
  • I have a public key ASBrIJGI2iMPmyP7t29Dn8csXeYGFYrBjQcg8sXAMY--tQo

To claim this, I am signing this object:

@dmennis
dmennis / CreateUser.json
Created October 15, 2019 19:52
cURL command for creating a new user with SingularKey
// (POST) Create NEW User (createUser) - Appears to be indopotent
// Doc: https://devapi.singularkey.com/docs/index.html?http#createuser
curl -X POST \
https://devapi.singularkey.com/v1/users/ \
-H 'Accept: application/json' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 58' \
-H 'Content-Type: application/json' \
@dmennis
dmennis / AppSync_Client_API_KEY.swift
Created May 30, 2019 22:51
iOS AppSync Multi Auth - API_KEY
// WITH multi-auth
func initializeAppSync_API_Key() {
do {
// Reference the API_KEY auth mode setting in awsconfiguration.json
let serviceConfigAPI_Key = try AWSAppSyncServiceConfig(forKey: "recipedemo_API_KEY")
// useClientDatabasePrefix: true is telling the AppSync client to look for 'ClientDatabasePrefix' in awsconfiguration.json
// why the cacheConfig? AppSync client uses a unique cache database for each auth type
let cacheConfig = try AWSAppSyncCacheConfiguration(useClientDatabasePrefix: true,
appSyncServiceConfig: serviceConfigAPI_Key)
@dmennis
dmennis / CredentialsProvider.swift
Created May 7, 2019 21:56
Used for the Celebrity app/blog
// Initialize Identity Provider
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: .USEast1,
identityPoolId: "<YOUR-COGNITO-IDENTITY-POOL-ID-HERE>")
let configuration = AWSServiceConfiguration(
region: .USEast1,
credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
@dmennis
dmennis / amazon-lex-echobot-lambda-function.js
Last active January 10, 2019 02:07
This is the source code for the EchoMe Lex Chatbot Lambda function
'use strict';
/**
* This code sample demonstrates an implementation of the Amazon Lex Code Hook Interface
* to echo back what the user says
* Written by: Dennis Hills
* Date: Jan 9, 2019
* Amazon Lex Bot setup requires only a single slot
* Usage: "repeat after me I am the boss" or "repeat after me the quick brown fox jumped over the lazy dog"
*/
//
// ViewController.swift
// AuthLWA
//
// Created by Hills, Dennis on 12/7/18.
// Copyright © 2018 Hills, Dennis. All rights reserved.
//
// Requires LoginWithAmazonProxy via Gist here: https://gist.github.com/mobilequickie/56916503a41ebb2374fea241ede26eab
// This gist: https://gist.github.com/mobilequickie/47a238e073043a271425f7ffe9d56d5e
//
@dmennis
dmennis / Drop-inAuthUI.swift
Last active March 19, 2019 18:39
Drop-in auth UI
import UIKit
import AWSMobileClient
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initializeAWSMobileClient() // Initialize the AWSMobileClient
}
@dmennis
dmennis / BasicAuthViewController2.7.swift
Last active March 19, 2019 18:39
AWS SDK for iOS 2.7.0+
import UIKit
import AWSMobileClient
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initializeAWSMobileClient() // Initialize the AWSMobileClient
}