Skip to content

Instantly share code, notes, and snippets.

@itskhanow
itskhanow / twiliovoice.md
Last active April 9, 2024 23:11
Twilio Voice Client Store

Twilio Voice

Twilio Account Setup

In order to authorize with Twilio Voice certain SIDs and API keys and secrets need to be set for the domain. The JSON object for this is of the form:

"khanchat.onetechnology.com": {
  "accountSid": "ACda6d0dc86c5d8e4f9bc38d2c65cb7068",
  "twimlAppSid": "AP790b21f8cedcbfd9d389e92b66939916",
 "apiKey": "SK74f0e340cb54587726b8a31c8f0e9725",
@itskhanow
itskhanow / SprenVision.md
Last active February 17, 2023 00:25
Spren Vision Native

Native Spren Vision WIP

Store Actions

"Start Spren Capture"

startSprenCapture()

@itskhanow
itskhanow / DocuSign.md
Last active September 26, 2022 21:16
DocuSign Integration

DocuSign Integration WIP

This is an in-progress integration of the DocuSign API that currently gets clientside user authentication from the client store which provides a user object that contains a token that can be used to then interact with the rest of the DocuSign API on behalf of the user.

Request User (Sender) Consent

Raw geo data

'[{"latitude":34.0175403,"longitude":-84.1286544,"accuracy":23.021,"altitude":279.79998779296875,"altitudeAccuracy":1.577968955039978,"simulated":false,"speed":null,"bearing":null,"time":1651716479377},{"latitude":34.0175403,"longitude":-84.1286544,"accuracy":23.021,"altitude":279.79998779296875,"altitudeAccuracy":1.577968955039978,"simulated":false,"speed":null,"bearing":null,"time":1651716482597},{"latitude":34.0175215,"longitude":-84.1285554,"accuracy":17.152,"altitude":279.79998779296875,"altitudeAccuracy":1.6625217199325562,"simulated":false,"speed":0.96899706,"bearing":102.92135,"time":1651716487660},{"latitude":34.0175261,"longitude":-84.1285824,"accuracy":16.08,"altitude":279.79998779296875,"altitudeAccuracy":1.66587233543396,"simulated":false,"speed":0.19058104,"bearing":54.765434,"time":1651716488673},{"latitude":34.0175286,"longitude":-84.1285976,"accuracy":15.967,"altitude":279.79998779296875,"altitudeAccuracy":1.4540882110595703,"simulated":false,"speed":0.26729792,"bearing":66

Native Background Geolocation WIP

This integration makes use of the Native OS's Geolocation API which is different from the browser-provided Geolocation API (which is still accessible) but unlike the browser implementation this won't shut off when the app goes into the background. The locations are broadcast by the device once it has reached a distance threshold from the previously broadcasted distance and can be set using the parameter distanceFilter. The broadcasted locations are stored in IndexedDB in a background thread. The values can be retrieved at a later date and, once retrieved, can be bound to using the event system.

Flow

Start Background Watcher

The Start Background Geo Watcher store action starts a background thread that listens for location broadcasts and persists it into IndexedDB. Starting the watcher will trigger onStartBackgroundGeoWatcher with a payload of the watcherId and each broadcast will trigger onBackgroundGeolocation with a payload of the location. The locations

LoginID Integration WIP

This integration utilizes LoginID's client and backend SDKs to implement FIDO registration and authentication. This document assumes familiarity with the FIDO process. The integration to the ONEtech platform is specific to the app domain and all necessary configurations (clientIDs, private keys, etc.) are attached to the app's domain name and stored in the cluster. A ONEtech WorkflowAPI JWT that contains the correct domain is needed in all calls to the REST API as they will look up the necessary config using the domain property.

A number of different tokens may be referred to:

  • WORKFLOWAPI_TOKEN: This is the ONEtech WorkflowAPI JWT that we use on the platform.
  • SERVICE_TOKEN: This service token is generated using the private key stored in-cluster. This is needed to communicate with LoginID's REST API.
  • CREDENTIAL_TOKEN: This JWT is obtained by the client when they successfully authenticate and can be passed along with any workflow calls and can be verified that the caller

User Video Record and Upload

This provides a set of client store actions and REST API endpoints that allows securely recording and uploading user media. Since video clips need to be finalized before being able to be played by a video player, and to make this process more robust against interruptions, the media recorder can be given a segment length (in seconds) so that the client can persist and upload the clip segments before the actual end of the recording session.

We can then POST a message to the service to start a job that will stitch together the individual clips into one final video. Since this is all stored in a private secure bucket, grants for viewership can be requested in the form of temporary pre-signed URLs that we can set as the source for a video player. All calls are privileged and thus require a valid JWT in the Authorization header. In the case of the grant request call, the JWT must also be from a user with RoleId of Admin (of any app, currently)

Store Actions

"Record User Vid

let rowsToProcess = [];
request.on("row", (row) => {
rowsToProcess.push(row);
if (rowsToProcess.length >= 15) {
request.pause();
processRows();
}
});
request.on("done", () => {
processRows();
@itskhanow
itskhanow / onetech-image-resizer.md
Created July 2, 2021 04:17
Onetech Image Resizer

Onetech Image Resizer

TL;DR: Put an image into the onetech-media-source bucket and look at it at https://media.onerenderer.com (Initial view might take a second depending on image size)

Input

Put an image in onetech-media-source bucket. Currently supported formats: .jpg, .jpeg, and .png Example: s3://onetech-media-source/test-app/test-user/test-large.jpg

Output

Access the image at https://media.onerenderer.com/{PATH}/{OPTIMIZE_OPTIONS}/{FILENAME}.{EXTENSION} where OPTIMIZE_OPTIONS is of the format optimize_{WIDTH}x{HEIGHT}_[min|max]. Note that {WIDTH} and {HEIGHT} can be any integer or auto to maintain aspect ratio. A _min or _max can be appended to the optimization string to set whether the width and height should be treated as minimum resolutions or maximum resolutions while maintaining aspect ratio if both width and height are defined. The _min or _max can be omitted but be aware that defining both dimensions without this string will cause the image to be croppe