Skip to content

Instantly share code, notes, and snippets.

@wabzqem
Created September 13, 2021 02:43
Show Gist options
  • Save wabzqem/b99cf9eb3f398b387bb2a1c55d19ddb4 to your computer and use it in GitHub Desktop.
Save wabzqem/b99cf9eb3f398b387bb2a1c55d19ddb4 to your computer and use it in GitHub Desktop.
e.generateSignedJWT = function(t, c, s, v) {
var p;
return n.async(function(h) {
for (; ; )
switch (h.prev = h.next) {
case 0:
return h.next = 2,
n.awrap(l.default.getPrivateKey(c));
case 2:
return p = h.sent,
h.next = 5,
n.awrap(f.createSignedJWT(u(u({}, t), {
c: o.FIVE_MINUTES,
p: s.unix(),
s: v
}), p || ''));
case 5:
return h.abrupt("return", h.sent);
case 6:
case "end":
return h.stop()
}
}, null, this)
}
,
e.generateQRCode = function() {
var t, u, c, s, o, l, f, p, I, S, b, x, C = arguments;
return n.async(function(J) {
for (; ; )
switch (J.prev = J.next) {
case 0:
return t = C.length > 0 && void 0 !== C[0] ? C[0] : 0,
u = C.length > 1 ? C[1] : void 0,
c = C.length > 2 ? C[2] : void 0,
s = C.length > 3 ? C[3] : void 0,
o = C.length > 4 ? C[4] : void 0,
l = C.length > 5 ? C[5] : void 0,
p = _(t, o, c),
J.next = 9,
n.awrap(e.generateSignedJWT(u, s, o, l));
case 9:
if (void 0 !== (I = J.sent)) {
J.next = 12;
break
}
return J.abrupt("return");
case 12:
return S = I.indexOf('.'),
b = I.substr(0, S),
x = null !== (f = v.default.get(h, b)) && void 0 !== f ? f : b,
J.abrupt("return", x + I.substr(S) + '.' + p);
case 16:
case "end":
return J.stop()
}
}, null, this)
}
;
var _ = function(t, n, u) {
var c = t + '.' + u + '.' + n.unix();
return p.base64Encode(c)
};
e.extractJWTFromQRCode = function(t) {
var n = t.split('.')
, u = n[0]
, c = n[1]
, s = n[2];
return (v.default.findKey(h, function(t) {
return t === u
}) || u) + '.' + c + '.' + s
}
,
e.isQRCodeFormatValid = function(n) {
var u = n.split('.');
if (4 !== u.length)
return !1;
var c = t(u, 4)
, s = c[0]
, o = c[3]
, l = {
driverLicence: 28 === o.length,
photoCard: 32 === o.length
};
return !!['0', '1'].includes(s) && Object.values(l).includes(!0)
}
,
e.extractTimestampFromQRCode = function(t) {
var n = p.utf8Stringify(t.split('.')[3]);
return parseInt(n.split('.')[2], 10)
}
}, 1027, [25, 109, 6, 832, 1028, 649, 484]);
__d(function(g, r, i, a, m, e, d) {
"use strict";
var t = r(d[0]);
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = r(d[1]);
e.createSignedJWT = function(c, s) {
return t.async(function(u) {
for (; ; )
switch (u.prev = u.next) {
case 0:
return u.prev = 0,
u.next = 3,
t.awrap(n.NativeModules.Crypto.createSignedJWT(c, s));
case 3:
return u.abrupt("return", u.sent);
case 6:
u.prev = 6,
u.t0 = u.catch(0);
case 8:
case "end":
return u.stop()
}
}, null, this, [[0, 6]])
}
}, 1028, [109, 16]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment