@evervault/sdk
Advanced tools
Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "@evervault/sdk", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "evervault Browser SDK", | ||
@@ -5,0 +5,0 @@ "repository": { |
29
utils.js
@@ -15,4 +15,29 @@ /** @format */ | ||
static padString(input) { | ||
let segmentLength = 4; | ||
let stringLength = input.length; | ||
let diff = stringLength % segmentLength; | ||
if (!diff) { | ||
return input; | ||
} | ||
let position = stringLength; | ||
let padLength = segmentLength - diff; | ||
let paddedStringLength = stringLength + padLength; | ||
let buffer = Buffer.alloc(paddedStringLength); | ||
buffer.write(input); | ||
while (padLength--) { | ||
buffer.write("=", position++); | ||
} | ||
return buffer.toString(); | ||
} | ||
static b64ToBuffer(b64String) { | ||
const decodedStr = window.atob(b64String); | ||
const reEncodedString = this.padString(b64String) | ||
.replace(/\-/g, "+") | ||
.replace(/_/g, "/"); | ||
const decodedStr = window.atob(reEncodedString); | ||
var buf = new ArrayBuffer(decodedStr.length); | ||
@@ -156,3 +181,3 @@ var bufView = new Uint8Array(buf); | ||
static areHashValuesFromAuth(urlValues) { | ||
const authRegex = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=?){1}:((eyJ){1}[A-Za-z0-9-_]+\.(eyJ){1}[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+\/=]*){1}:([a-z]+-[a-z]+-[0-9]{6,8}.[a-f0-9]{8}-[a-f0-9]{3,4}-[a-f0-9]{3,4}-[a-f0-9]{3,4}-[a-f0-9]{12}){1}$/; | ||
const authRegex = /^([A-Za-z0-9-_])+:((eyJ){1}[A-Za-z0-9-_]+\.(eyJ){1}[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+\/=]*){1}:([a-z]+-[a-z]+-[0-9]{6,8}.[a-f0-9]{8}-[a-f0-9]{3,4}-[a-f0-9]{3,4}-[a-f0-9]{3,4}-[a-f0-9]{12}){1}$/; | ||
return authRegex.test(urlValues); | ||
@@ -159,0 +184,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56361
1031