@nokinc-flur/sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -1566,6 +1556,8 @@ function decodeAuthorizationQR(s) {
|
|
|
1566
1556
|
|
|
1567
1557
|
// src/offline/settlements.ts
|
|
1568
1558
|
var import_zod6 = require("zod");
|
|
1559
|
+
var import_sha256 = require("@noble/hashes/sha256");
|
|
1560
|
+
var import_utils = require("@noble/hashes/utils");
|
|
1569
1561
|
var OfflineTokenSchema = import_zod6.z.object({
|
|
1570
1562
|
tokenId: import_zod6.z.string().uuid(),
|
|
1571
1563
|
tokenSerial: import_zod6.z.string(),
|
|
@@ -1616,14 +1608,7 @@ var SettleResponseSchema = import_zod6.z.object({
|
|
|
1616
1608
|
});
|
|
1617
1609
|
var ENCOUNTER_DOMAIN = "offline:v1:encounter";
|
|
1618
1610
|
async function sha256Hex(input) {
|
|
1619
|
-
|
|
1620
|
-
const enc2 = new TextEncoder().encode(input);
|
|
1621
|
-
if (subtle) {
|
|
1622
|
-
const buf = await subtle.digest("SHA-256", enc2);
|
|
1623
|
-
return Array.from(new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1624
|
-
}
|
|
1625
|
-
const mod = await import("crypto");
|
|
1626
|
-
return mod.createHash("sha256").update(input).digest("hex");
|
|
1611
|
+
return (0, import_utils.bytesToHex)((0, import_sha256.sha256)(new TextEncoder().encode(input)));
|
|
1627
1612
|
}
|
|
1628
1613
|
async function computeEncounterId(input) {
|
|
1629
1614
|
return sha256Hex(
|
|
@@ -1671,8 +1656,8 @@ function createOfflineSettlementsClient(partner) {
|
|
|
1671
1656
|
|
|
1672
1657
|
// src/auth/hmac.ts
|
|
1673
1658
|
var import_hmac = require("@noble/hashes/hmac");
|
|
1674
|
-
var
|
|
1675
|
-
function
|
|
1659
|
+
var import_sha2562 = require("@noble/hashes/sha256");
|
|
1660
|
+
function bytesToHex3(b) {
|
|
1676
1661
|
let s = "";
|
|
1677
1662
|
for (let i = 0; i < b.length; i++) s += b[i].toString(16).padStart(2, "0");
|
|
1678
1663
|
return s;
|
|
@@ -1684,7 +1669,7 @@ function constantTimeStringEqual(a, b) {
|
|
|
1684
1669
|
return diff === 0;
|
|
1685
1670
|
}
|
|
1686
1671
|
function bodySha256Hex(body) {
|
|
1687
|
-
return
|
|
1672
|
+
return bytesToHex3((0, import_sha2562.sha256)(new TextEncoder().encode(body)));
|
|
1688
1673
|
}
|
|
1689
1674
|
function canonicalRequestString(input) {
|
|
1690
1675
|
return [
|
|
@@ -1696,8 +1681,8 @@ function canonicalRequestString(input) {
|
|
|
1696
1681
|
].join("\n");
|
|
1697
1682
|
}
|
|
1698
1683
|
function signRequestHMAC(input) {
|
|
1699
|
-
return
|
|
1700
|
-
(0, import_hmac.hmac)(
|
|
1684
|
+
return bytesToHex3(
|
|
1685
|
+
(0, import_hmac.hmac)(import_sha2562.sha256, input.apiSecret, canonicalRequestString(input))
|
|
1701
1686
|
);
|
|
1702
1687
|
}
|
|
1703
1688
|
function verifyRequestHMAC(input) {
|
|
@@ -2456,6 +2441,9 @@ function createAccountsClient(opts) {
|
|
|
2456
2441
|
|
|
2457
2442
|
// src/partner/client.ts
|
|
2458
2443
|
var import_zod11 = require("zod");
|
|
2444
|
+
var import_sha2563 = require("@noble/hashes/sha256");
|
|
2445
|
+
var import_hmac4 = require("@noble/hashes/hmac");
|
|
2446
|
+
var import_utils2 = require("@noble/hashes/utils");
|
|
2459
2447
|
var PARTNER_SCOPES = [
|
|
2460
2448
|
"passes:write",
|
|
2461
2449
|
"passes:read",
|
|
@@ -2479,39 +2467,13 @@ var ApiCredentialPublicSchema = import_zod11.z.object({
|
|
|
2479
2467
|
var MintedApiCredentialSchema = ApiCredentialPublicSchema.extend({
|
|
2480
2468
|
secret: import_zod11.z.string().min(1)
|
|
2481
2469
|
});
|
|
2482
|
-
async function getSubtle() {
|
|
2483
|
-
const c = globalThis.crypto;
|
|
2484
|
-
if (c?.subtle) return c.subtle;
|
|
2485
|
-
const mod = await import("crypto");
|
|
2486
|
-
return mod.webcrypto.subtle;
|
|
2487
|
-
}
|
|
2488
2470
|
var enc = new TextEncoder();
|
|
2489
|
-
function bytesToHex3(buf) {
|
|
2490
|
-
const u = new Uint8Array(buf);
|
|
2491
|
-
let s = "";
|
|
2492
|
-
for (let i = 0; i < u.length; i++) {
|
|
2493
|
-
s += u[i].toString(16).padStart(2, "0");
|
|
2494
|
-
}
|
|
2495
|
-
return s;
|
|
2496
|
-
}
|
|
2497
2471
|
async function sha256Hex2(input) {
|
|
2498
|
-
const subtle = await getSubtle();
|
|
2499
2472
|
const data = typeof input === "string" ? enc.encode(input) : input;
|
|
2500
|
-
|
|
2501
|
-
const buf = await subtle.digest("SHA-256", buffer);
|
|
2502
|
-
return bytesToHex3(buf);
|
|
2473
|
+
return (0, import_utils2.bytesToHex)((0, import_sha2563.sha256)(data));
|
|
2503
2474
|
}
|
|
2504
2475
|
async function hmacSha256Hex(keyHex, message) {
|
|
2505
|
-
|
|
2506
|
-
const key = await subtle.importKey(
|
|
2507
|
-
"raw",
|
|
2508
|
-
enc.encode(keyHex),
|
|
2509
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
2510
|
-
false,
|
|
2511
|
-
["sign"]
|
|
2512
|
-
);
|
|
2513
|
-
const sig = await subtle.sign("HMAC", key, enc.encode(message));
|
|
2514
|
-
return bytesToHex3(sig);
|
|
2476
|
+
return (0, import_utils2.bytesToHex)((0, import_hmac4.hmac)(import_sha2563.sha256, enc.encode(keyHex), enc.encode(message)));
|
|
2515
2477
|
}
|
|
2516
2478
|
function defaultNonce2() {
|
|
2517
2479
|
const c = globalThis.crypto;
|