@nokinc-flur/sdk 1.0.4 → 1.0.5
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 +352 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1343 -10
- package/dist/index.d.ts +1343 -10
- package/dist/index.js +334 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,16 @@ __export(index_exports, {
|
|
|
26
26
|
AccountMembershipSchema: () => AccountMembershipSchema,
|
|
27
27
|
AccountSchema: () => AccountSchema,
|
|
28
28
|
ApiCredentialPublicSchema: () => ApiCredentialPublicSchema,
|
|
29
|
+
ConsumerOACRecordSchema: () => OACRecordSchema,
|
|
30
|
+
ConsumerOACSchema: () => ConsumerOACSchema,
|
|
31
|
+
ConsumerPaymentClaimSchema: () => ConsumerPaymentClaimSchema,
|
|
32
|
+
ConsumerSettleResultSchema: () => ConsumerSettleResultSchema,
|
|
33
|
+
ConsumerSettlementSchema: () => ConsumerSettlementSchema,
|
|
34
|
+
DeviceKeyRecordSchema: () => DeviceKeyRecordSchema,
|
|
35
|
+
DisableOfflineInputSchema: () => DisableOfflineInputSchema,
|
|
36
|
+
DisableOfflineResultSchema: () => DisableOfflineResultSchema,
|
|
37
|
+
EnableOfflineInputSchema: () => EnableOfflineInputSchema,
|
|
38
|
+
EnableOfflineResultSchema: () => EnableOfflineResultSchema,
|
|
29
39
|
FIELD: () => FIELD,
|
|
30
40
|
FlurApiError: () => FlurApiError,
|
|
31
41
|
FlurCapExceededError: () => FlurCapExceededError,
|
|
@@ -33,6 +43,7 @@ __export(index_exports, {
|
|
|
33
43
|
FlurError: () => FlurError,
|
|
34
44
|
FlurExpiredError: () => FlurExpiredError,
|
|
35
45
|
FlurReplayError: () => FlurReplayError,
|
|
46
|
+
IssueOACInputSchema: () => IssueOACInputSchema,
|
|
36
47
|
MEMBERSHIP_ROLES: () => MEMBERSHIP_ROLES,
|
|
37
48
|
MintedApiCredentialSchema: () => MintedApiCredentialSchema,
|
|
38
49
|
NGN_CURRENCY_CODE: () => NGN_CURRENCY_CODE,
|
|
@@ -42,8 +53,11 @@ __export(index_exports, {
|
|
|
42
53
|
OAC_DEFAULT_CUMULATIVE_KOBO: () => OAC_DEFAULT_CUMULATIVE_KOBO,
|
|
43
54
|
OAC_DEFAULT_PER_TX_KOBO: () => OAC_DEFAULT_PER_TX_KOBO,
|
|
44
55
|
OAC_DEFAULT_VALIDITY_MS: () => OAC_DEFAULT_VALIDITY_MS,
|
|
56
|
+
OfflineHoldRecordSchema: () => OfflineHoldRecordSchema,
|
|
45
57
|
OfflinePaymentAuthorizationSchema: () => OfflinePaymentAuthorizationSchema,
|
|
46
58
|
OfflinePaymentRequestSchema: () => OfflinePaymentRequestSchema,
|
|
59
|
+
OfflineStateResultSchema: () => OfflineStateResultSchema,
|
|
60
|
+
OfflineStatusResultSchema: () => OfflineStatusResultSchema,
|
|
47
61
|
OfflineTokenSchema: () => OfflineTokenSchema,
|
|
48
62
|
PARTNER_SCOPES: () => PARTNER_SCOPES,
|
|
49
63
|
PASS_KINDS: () => PASS_KINDS,
|
|
@@ -59,8 +73,11 @@ __export(index_exports, {
|
|
|
59
73
|
ReceiptPayloadSchema: () => ReceiptPayloadSchema,
|
|
60
74
|
ReceiptSchema: () => ReceiptSchema,
|
|
61
75
|
RedemptionSchema: () => RedemptionSchema,
|
|
76
|
+
RegisterDeviceKeyInputSchema: () => RegisterDeviceKeyInputSchema,
|
|
77
|
+
RevokeDeviceKeyInputSchema: () => RevokeDeviceKeyInputSchema,
|
|
62
78
|
SettleResponseSchema: () => SettleResponseSchema,
|
|
63
79
|
SettlementSchema: () => SettlementSchema,
|
|
80
|
+
SignedConsumerOACSchema: () => SignedConsumerOACSchema,
|
|
64
81
|
bodySha256Hex: () => bodySha256Hex,
|
|
65
82
|
buildAuthorization: () => buildAuthorization,
|
|
66
83
|
buildOAC: () => buildOAC,
|
|
@@ -79,6 +96,7 @@ __export(index_exports, {
|
|
|
79
96
|
createApiCredentialsAdminClient: () => createApiCredentialsAdminClient,
|
|
80
97
|
createFlurPartnerClient: () => createFlurPartnerClient,
|
|
81
98
|
createHmacFetch: () => createHmacFetch,
|
|
99
|
+
createMeOfflineClient: () => createMeOfflineClient,
|
|
82
100
|
createOfflineSettlementsClient: () => createOfflineSettlementsClient,
|
|
83
101
|
createPassesClient: () => createPassesClient,
|
|
84
102
|
createReceiptsClient: () => createReceiptsClient,
|
|
@@ -169,7 +187,9 @@ var OnboardingCompleteResponseSchema = import_zod.z.object({
|
|
|
169
187
|
sessionToken: import_zod.z.string().min(1),
|
|
170
188
|
userId: UuidSchema,
|
|
171
189
|
restricted: import_zod.z.boolean(),
|
|
172
|
-
risk_reasons: import_zod.z.array(
|
|
190
|
+
risk_reasons: import_zod.z.array(
|
|
191
|
+
import_zod.z.enum(["SIM_SWAP_RECENT", "ROAMING", "CARRIER_CHANGED"])
|
|
192
|
+
),
|
|
173
193
|
stepUpRequired: import_zod.z.boolean().optional(),
|
|
174
194
|
riskStatus: import_zod.z.enum(["ok", "unavailable"]).optional()
|
|
175
195
|
});
|
|
@@ -222,9 +242,11 @@ var RegisterSendDeviceKeyRequestSchema = import_zod.z.object({
|
|
|
222
242
|
deviceId: import_zod.z.string().min(3),
|
|
223
243
|
publicKey: import_zod.z.string().min(32)
|
|
224
244
|
});
|
|
245
|
+
var SEND_AUTH_PURPOSES = ["send_money", "offline_revoke"];
|
|
225
246
|
var SendChallengeRequestSchema = import_zod.z.object({
|
|
226
247
|
userId: UuidSchema,
|
|
227
|
-
deviceId: import_zod.z.string().min(3)
|
|
248
|
+
deviceId: import_zod.z.string().min(3),
|
|
249
|
+
purpose: import_zod.z.enum(SEND_AUTH_PURPOSES).optional()
|
|
228
250
|
});
|
|
229
251
|
var SendChallengeResponseSchema = import_zod.z.object({
|
|
230
252
|
challengeId: UuidSchema,
|
|
@@ -524,10 +546,20 @@ var FlurClient = class {
|
|
|
524
546
|
this.getExtraHeaders = opts.getExtraHeaders;
|
|
525
547
|
}
|
|
526
548
|
async health() {
|
|
527
|
-
return this.requestJson(
|
|
549
|
+
return this.requestJson(
|
|
550
|
+
"/health",
|
|
551
|
+
{ method: "GET" },
|
|
552
|
+
void 0,
|
|
553
|
+
HealthResponseSchema
|
|
554
|
+
);
|
|
528
555
|
}
|
|
529
556
|
async welcome() {
|
|
530
|
-
return this.requestJson(
|
|
557
|
+
return this.requestJson(
|
|
558
|
+
"/welcome",
|
|
559
|
+
{ method: "GET" },
|
|
560
|
+
void 0,
|
|
561
|
+
WelcomeResponseSchema
|
|
562
|
+
);
|
|
531
563
|
}
|
|
532
564
|
async onboardingStart(input) {
|
|
533
565
|
return this.requestJson(
|
|
@@ -672,24 +704,33 @@ var FlurClient = class {
|
|
|
672
704
|
}
|
|
673
705
|
async registerBiometricDeviceKey(input) {
|
|
674
706
|
const publicKey = await input.signer.getOrCreateKeyPair(input.deviceId);
|
|
675
|
-
return this.registerSendDeviceKey(
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
707
|
+
return this.registerSendDeviceKey(
|
|
708
|
+
{
|
|
709
|
+
userId: input.userId,
|
|
710
|
+
deviceId: input.deviceId,
|
|
711
|
+
publicKey
|
|
712
|
+
},
|
|
713
|
+
{ accessToken: input.accessToken }
|
|
714
|
+
);
|
|
680
715
|
}
|
|
681
716
|
async authorizeSendWithBiometric(input) {
|
|
682
|
-
const challenge = await this.createSendChallenge(
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
717
|
+
const challenge = await this.createSendChallenge(
|
|
718
|
+
{
|
|
719
|
+
userId: input.userId,
|
|
720
|
+
deviceId: input.deviceId
|
|
721
|
+
},
|
|
722
|
+
{ accessToken: input.accessToken }
|
|
723
|
+
);
|
|
686
724
|
const signature = await input.signer.sign(challenge.nonce);
|
|
687
|
-
return this.verifySendChallenge(
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
725
|
+
return this.verifySendChallenge(
|
|
726
|
+
{
|
|
727
|
+
userId: input.userId,
|
|
728
|
+
deviceId: input.deviceId,
|
|
729
|
+
challengeId: challenge.challengeId,
|
|
730
|
+
signature
|
|
731
|
+
},
|
|
732
|
+
{ accessToken: input.accessToken }
|
|
733
|
+
);
|
|
693
734
|
}
|
|
694
735
|
async resolveRecipient(input, options) {
|
|
695
736
|
return this.requestJson(
|
|
@@ -854,7 +895,12 @@ var FlurClient = class {
|
|
|
854
895
|
...init2.headers,
|
|
855
896
|
...extraHeaders
|
|
856
897
|
};
|
|
857
|
-
const res = await this.fetchImpl(url, {
|
|
898
|
+
const res = await this.fetchImpl(url, {
|
|
899
|
+
...init2,
|
|
900
|
+
headers: finalHeaders,
|
|
901
|
+
body,
|
|
902
|
+
signal: controller.signal
|
|
903
|
+
});
|
|
858
904
|
if (!res.ok) throw await mapToFlurError(res);
|
|
859
905
|
const payload = await res.json();
|
|
860
906
|
if (!responseSchema) return payload;
|
|
@@ -862,9 +908,13 @@ var FlurClient = class {
|
|
|
862
908
|
return responseSchema.parse(payload);
|
|
863
909
|
} catch (err) {
|
|
864
910
|
if (err instanceof import_zod3.z.ZodError) {
|
|
865
|
-
throw new FlurError(
|
|
866
|
-
|
|
867
|
-
|
|
911
|
+
throw new FlurError(
|
|
912
|
+
"SDK contract validation failed",
|
|
913
|
+
"INVALID_REQUEST",
|
|
914
|
+
{
|
|
915
|
+
details: err.flatten()
|
|
916
|
+
}
|
|
917
|
+
);
|
|
868
918
|
}
|
|
869
919
|
throw err;
|
|
870
920
|
}
|
|
@@ -873,7 +923,9 @@ var FlurClient = class {
|
|
|
873
923
|
throw new FlurError("Request timed out", "TIMEOUT");
|
|
874
924
|
}
|
|
875
925
|
if (err instanceof FlurError) throw err;
|
|
876
|
-
throw new FlurError("Network error", "NETWORK_ERROR", {
|
|
926
|
+
throw new FlurError("Network error", "NETWORK_ERROR", {
|
|
927
|
+
details: String(err)
|
|
928
|
+
});
|
|
877
929
|
} finally {
|
|
878
930
|
clearTimeout(t);
|
|
879
931
|
}
|
|
@@ -883,7 +935,10 @@ function getSecureRandomUuid() {
|
|
|
883
935
|
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
884
936
|
return globalThis.crypto.randomUUID();
|
|
885
937
|
}
|
|
886
|
-
throw new FlurError(
|
|
938
|
+
throw new FlurError(
|
|
939
|
+
"Secure UUID generator unavailable; provide idempotencyKey",
|
|
940
|
+
"INVALID_REQUEST"
|
|
941
|
+
);
|
|
887
942
|
}
|
|
888
943
|
|
|
889
944
|
// src/nqr/fields.ts
|
|
@@ -2634,6 +2689,260 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2634
2689
|
)
|
|
2635
2690
|
};
|
|
2636
2691
|
}
|
|
2692
|
+
|
|
2693
|
+
// src/me-offline/client.ts
|
|
2694
|
+
var import_zod12 = require("zod");
|
|
2695
|
+
var Hex64 = import_zod12.z.string().regex(/^[0-9a-f]{64}$/i);
|
|
2696
|
+
var HexAny = import_zod12.z.string().regex(/^[0-9a-f]+$/i);
|
|
2697
|
+
var Sha256Hex = import_zod12.z.string().regex(/^[0-9a-f]{64}$/i);
|
|
2698
|
+
var RegisterDeviceKeyInputSchema = import_zod12.z.object({
|
|
2699
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2700
|
+
publicKeyHex: Hex64
|
|
2701
|
+
});
|
|
2702
|
+
var DeviceKeyRecordSchema = import_zod12.z.object({
|
|
2703
|
+
id: import_zod12.z.string().uuid(),
|
|
2704
|
+
userId: import_zod12.z.string().uuid(),
|
|
2705
|
+
deviceId: import_zod12.z.string(),
|
|
2706
|
+
publicKeyHex: Hex64,
|
|
2707
|
+
createdAtMs: import_zod12.z.number().int().nonnegative(),
|
|
2708
|
+
revokedAtMs: import_zod12.z.number().int().nonnegative().nullable()
|
|
2709
|
+
});
|
|
2710
|
+
var ConsumerOACSchema = import_zod12.z.object({
|
|
2711
|
+
oacId: import_zod12.z.string().uuid(),
|
|
2712
|
+
issuerId: import_zod12.z.string().min(1).max(64),
|
|
2713
|
+
userId: import_zod12.z.string().uuid(),
|
|
2714
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2715
|
+
devicePubkeyHex: Hex64,
|
|
2716
|
+
perTxCapKobo: import_zod12.z.number().int().positive(),
|
|
2717
|
+
cumulativeCapKobo: import_zod12.z.number().int().positive(),
|
|
2718
|
+
currency: import_zod12.z.string().length(3),
|
|
2719
|
+
validFromMs: import_zod12.z.number().int().nonnegative(),
|
|
2720
|
+
validUntilMs: import_zod12.z.number().int().nonnegative(),
|
|
2721
|
+
counterSeed: import_zod12.z.number().int().nonnegative(),
|
|
2722
|
+
issuedAtMs: import_zod12.z.number().int().nonnegative()
|
|
2723
|
+
});
|
|
2724
|
+
var SignedConsumerOACSchema = import_zod12.z.object({
|
|
2725
|
+
oac: ConsumerOACSchema,
|
|
2726
|
+
issuerSig: HexAny,
|
|
2727
|
+
issuerPublicKeyHex: Hex64
|
|
2728
|
+
});
|
|
2729
|
+
var OACRecordSchema = SignedConsumerOACSchema.extend({
|
|
2730
|
+
currentOfflineSpentKobo: import_zod12.z.number().int().nonnegative(),
|
|
2731
|
+
status: import_zod12.z.enum([
|
|
2732
|
+
"active",
|
|
2733
|
+
"superseded",
|
|
2734
|
+
"expired",
|
|
2735
|
+
"revoked",
|
|
2736
|
+
"disabling",
|
|
2737
|
+
"draining",
|
|
2738
|
+
"closed"
|
|
2739
|
+
]),
|
|
2740
|
+
supersededAtMs: import_zod12.z.number().int().nonnegative().nullable(),
|
|
2741
|
+
revokedAtMs: import_zod12.z.number().int().nonnegative().nullable(),
|
|
2742
|
+
holdId: import_zod12.z.string().uuid().nullable().optional()
|
|
2743
|
+
});
|
|
2744
|
+
var IssueOACInputSchema = import_zod12.z.object({
|
|
2745
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2746
|
+
perTxCapKobo: import_zod12.z.number().int().positive().optional(),
|
|
2747
|
+
cumulativeCapKobo: import_zod12.z.number().int().positive().optional(),
|
|
2748
|
+
ttlMs: import_zod12.z.number().int().min(6e4).max(1e3 * 60 * 60 * 24 * 7).optional(),
|
|
2749
|
+
spendableOnlineKobo: import_zod12.z.number().int().nonnegative().optional()
|
|
2750
|
+
});
|
|
2751
|
+
var EnableOfflineInputSchema = import_zod12.z.object({
|
|
2752
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2753
|
+
amountKobo: import_zod12.z.number().int().positive(),
|
|
2754
|
+
perTxCapKobo: import_zod12.z.number().int().positive().optional(),
|
|
2755
|
+
ttlMs: import_zod12.z.number().int().min(6e4).max(1e3 * 60 * 60 * 24 * 7).optional(),
|
|
2756
|
+
installId: import_zod12.z.string().min(1).max(128),
|
|
2757
|
+
partnerId: import_zod12.z.string().min(1).max(64).optional()
|
|
2758
|
+
});
|
|
2759
|
+
var DisableOfflineInputSchema = import_zod12.z.object({
|
|
2760
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2761
|
+
installId: import_zod12.z.string().min(1).max(128).optional(),
|
|
2762
|
+
claims: import_zod12.z.array(import_zod12.z.unknown()).max(256).optional()
|
|
2763
|
+
});
|
|
2764
|
+
var OfflineHoldRecordSchema = import_zod12.z.object({
|
|
2765
|
+
holdId: import_zod12.z.string().uuid(),
|
|
2766
|
+
userId: import_zod12.z.string().uuid(),
|
|
2767
|
+
deviceId: import_zod12.z.string(),
|
|
2768
|
+
partnerId: import_zod12.z.string(),
|
|
2769
|
+
adapterKind: import_zod12.z.string(),
|
|
2770
|
+
externalHoldRef: import_zod12.z.string().nullable(),
|
|
2771
|
+
amountKobo: import_zod12.z.number().int().nonnegative(),
|
|
2772
|
+
capturedKobo: import_zod12.z.number().int().nonnegative(),
|
|
2773
|
+
releasedKobo: import_zod12.z.number().int().nonnegative(),
|
|
2774
|
+
remainingKobo: import_zod12.z.number().int().nonnegative(),
|
|
2775
|
+
currency: import_zod12.z.string().length(3),
|
|
2776
|
+
status: import_zod12.z.enum([
|
|
2777
|
+
"placing",
|
|
2778
|
+
"active",
|
|
2779
|
+
"disabling",
|
|
2780
|
+
"draining",
|
|
2781
|
+
"closed",
|
|
2782
|
+
"revoked",
|
|
2783
|
+
"failed"
|
|
2784
|
+
]),
|
|
2785
|
+
installId: import_zod12.z.string().nullable(),
|
|
2786
|
+
drainDeadlineMs: import_zod12.z.number().int().nonnegative(),
|
|
2787
|
+
disableRequestedAtMs: import_zod12.z.number().int().nonnegative().nullable(),
|
|
2788
|
+
createdAtMs: import_zod12.z.number().int().nonnegative(),
|
|
2789
|
+
closedAtMs: import_zod12.z.number().int().nonnegative().nullable(),
|
|
2790
|
+
isTrusted: import_zod12.z.boolean().optional()
|
|
2791
|
+
});
|
|
2792
|
+
var EnableOfflineResultSchema = import_zod12.z.object({
|
|
2793
|
+
hold: OfflineHoldRecordSchema,
|
|
2794
|
+
oac: OACRecordSchema
|
|
2795
|
+
});
|
|
2796
|
+
var DisableOfflineResultSchema = import_zod12.z.object({
|
|
2797
|
+
hold: OfflineHoldRecordSchema,
|
|
2798
|
+
trusted: import_zod12.z.boolean(),
|
|
2799
|
+
settledClaims: import_zod12.z.number().int().nonnegative()
|
|
2800
|
+
});
|
|
2801
|
+
var OfflineStatusResultSchema = import_zod12.z.object({
|
|
2802
|
+
hold: OfflineHoldRecordSchema.nullable(),
|
|
2803
|
+
active: OACRecordSchema.nullable()
|
|
2804
|
+
});
|
|
2805
|
+
var OfflineStateResultSchema = import_zod12.z.object({
|
|
2806
|
+
active: OACRecordSchema.nullable()
|
|
2807
|
+
});
|
|
2808
|
+
var ConsumerPaymentClaimSchema = import_zod12.z.object({
|
|
2809
|
+
oacId: import_zod12.z.string().uuid(),
|
|
2810
|
+
encounterId: Sha256Hex.optional(),
|
|
2811
|
+
payerUserId: import_zod12.z.string().uuid(),
|
|
2812
|
+
payeeUserId: import_zod12.z.string().uuid(),
|
|
2813
|
+
payerDeviceId: import_zod12.z.string().min(1).max(128),
|
|
2814
|
+
payerNonce: import_zod12.z.string().min(8).max(128),
|
|
2815
|
+
payeeNonce: import_zod12.z.string().min(8).max(128),
|
|
2816
|
+
amountKobo: import_zod12.z.number().int().positive(),
|
|
2817
|
+
currency: import_zod12.z.string().length(3).default("NGN"),
|
|
2818
|
+
occurredAtMs: import_zod12.z.number().int().nonnegative(),
|
|
2819
|
+
completedAtMs: import_zod12.z.number().int().nonnegative().optional(),
|
|
2820
|
+
contextId: import_zod12.z.string().max(128).optional(),
|
|
2821
|
+
payerPubkeyHex: Hex64,
|
|
2822
|
+
payerSignature: HexAny,
|
|
2823
|
+
payeePubkeyHex: Hex64.optional(),
|
|
2824
|
+
payeeSignature: HexAny.optional()
|
|
2825
|
+
});
|
|
2826
|
+
var ConsumerSettlementSchema = import_zod12.z.object({
|
|
2827
|
+
settlementId: import_zod12.z.string().uuid(),
|
|
2828
|
+
settlementKey: Sha256Hex,
|
|
2829
|
+
encounterId: Sha256Hex,
|
|
2830
|
+
oacId: import_zod12.z.string().uuid(),
|
|
2831
|
+
payerUserId: import_zod12.z.string().uuid(),
|
|
2832
|
+
payeeUserId: import_zod12.z.string().uuid(),
|
|
2833
|
+
amountKobo: import_zod12.z.number().int().positive(),
|
|
2834
|
+
currency: import_zod12.z.string().length(3),
|
|
2835
|
+
status: import_zod12.z.enum(["SETTLED", "REVIEW"]),
|
|
2836
|
+
reviewReason: import_zod12.z.string().nullable(),
|
|
2837
|
+
ledgerRef: import_zod12.z.string().nullable(),
|
|
2838
|
+
issuerSig: HexAny,
|
|
2839
|
+
createdAtMs: import_zod12.z.number().int().nonnegative()
|
|
2840
|
+
});
|
|
2841
|
+
var ConsumerSettleResultSchema = import_zod12.z.object({
|
|
2842
|
+
settlement: ConsumerSettlementSchema,
|
|
2843
|
+
encounterId: Sha256Hex,
|
|
2844
|
+
replayed: import_zod12.z.boolean()
|
|
2845
|
+
});
|
|
2846
|
+
var RevokeDeviceKeyInputSchema = import_zod12.z.object({
|
|
2847
|
+
deviceId: import_zod12.z.string().min(1).max(128),
|
|
2848
|
+
/** Step-up token from /api/v1/auth/send/verify with purpose='offline_revoke'. */
|
|
2849
|
+
sendAuthToken: import_zod12.z.string().min(16)
|
|
2850
|
+
});
|
|
2851
|
+
function createMeOfflineClient(opts) {
|
|
2852
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
2853
|
+
if (!fetchImpl) {
|
|
2854
|
+
throw new Error("createMeOfflineClient: no fetch implementation available");
|
|
2855
|
+
}
|
|
2856
|
+
const baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
2857
|
+
async function call(method, path, body, parser) {
|
|
2858
|
+
const init2 = {
|
|
2859
|
+
method,
|
|
2860
|
+
headers: {
|
|
2861
|
+
"content-type": "application/json",
|
|
2862
|
+
accept: "application/json"
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
if (body !== void 0) init2.body = JSON.stringify(body);
|
|
2866
|
+
const resp = await fetchImpl(`${baseUrl}${path}`, init2);
|
|
2867
|
+
const text = await resp.text();
|
|
2868
|
+
let raw = void 0;
|
|
2869
|
+
if (text) {
|
|
2870
|
+
try {
|
|
2871
|
+
raw = JSON.parse(text);
|
|
2872
|
+
} catch {
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
if (!resp.ok) {
|
|
2876
|
+
const code = raw && typeof raw === "object" && "code" in raw && typeof raw.code === "string" ? raw.code : `http_${resp.status}`;
|
|
2877
|
+
const message = raw && typeof raw === "object" && "message" in raw && typeof raw.message === "string" ? raw.message : `request failed with status ${resp.status}`;
|
|
2878
|
+
throw new FlurApiError(resp.status, code, message, raw);
|
|
2879
|
+
}
|
|
2880
|
+
return parser(raw);
|
|
2881
|
+
}
|
|
2882
|
+
const deviceKeyItems = import_zod12.z.object({ items: import_zod12.z.array(DeviceKeyRecordSchema) });
|
|
2883
|
+
return {
|
|
2884
|
+
registerDeviceKey: (input) => call(
|
|
2885
|
+
"POST",
|
|
2886
|
+
"/v1/me/offline/keys",
|
|
2887
|
+
RegisterDeviceKeyInputSchema.parse(input),
|
|
2888
|
+
(raw) => DeviceKeyRecordSchema.parse(raw)
|
|
2889
|
+
),
|
|
2890
|
+
listDeviceKeys: () => call(
|
|
2891
|
+
"GET",
|
|
2892
|
+
"/v1/me/offline/keys",
|
|
2893
|
+
void 0,
|
|
2894
|
+
(raw) => deviceKeyItems.parse(raw)
|
|
2895
|
+
),
|
|
2896
|
+
revokeDeviceKey: (input) => call(
|
|
2897
|
+
"POST",
|
|
2898
|
+
"/v1/me/offline/keys/revoke",
|
|
2899
|
+
RevokeDeviceKeyInputSchema.parse(input),
|
|
2900
|
+
() => void 0
|
|
2901
|
+
),
|
|
2902
|
+
enable: (input) => call(
|
|
2903
|
+
"POST",
|
|
2904
|
+
"/v1/me/offline/enable",
|
|
2905
|
+
EnableOfflineInputSchema.parse(input),
|
|
2906
|
+
(raw) => EnableOfflineResultSchema.parse(raw)
|
|
2907
|
+
),
|
|
2908
|
+
refresh: (input) => call(
|
|
2909
|
+
"POST",
|
|
2910
|
+
"/v1/me/offline/refresh",
|
|
2911
|
+
IssueOACInputSchema.parse(input),
|
|
2912
|
+
(raw) => OACRecordSchema.parse(raw)
|
|
2913
|
+
),
|
|
2914
|
+
disable: (input) => call(
|
|
2915
|
+
"POST",
|
|
2916
|
+
"/v1/me/offline/disable",
|
|
2917
|
+
DisableOfflineInputSchema.parse(input),
|
|
2918
|
+
(raw) => DisableOfflineResultSchema.parse(raw)
|
|
2919
|
+
),
|
|
2920
|
+
getStatus: (deviceId) => {
|
|
2921
|
+
const qs = deviceId ? `?deviceId=${encodeURIComponent(deviceId)}` : "";
|
|
2922
|
+
return call(
|
|
2923
|
+
"GET",
|
|
2924
|
+
`/v1/me/offline/status${qs}`,
|
|
2925
|
+
void 0,
|
|
2926
|
+
(raw) => OfflineStatusResultSchema.parse(raw)
|
|
2927
|
+
);
|
|
2928
|
+
},
|
|
2929
|
+
getState: (deviceId) => {
|
|
2930
|
+
const qs = deviceId ? `?deviceId=${encodeURIComponent(deviceId)}` : "";
|
|
2931
|
+
return call(
|
|
2932
|
+
"GET",
|
|
2933
|
+
`/v1/me/offline/state${qs}`,
|
|
2934
|
+
void 0,
|
|
2935
|
+
(raw) => OfflineStateResultSchema.parse(raw)
|
|
2936
|
+
);
|
|
2937
|
+
},
|
|
2938
|
+
submitClaim: (claim) => call(
|
|
2939
|
+
"POST",
|
|
2940
|
+
"/v1/me/offline/claims",
|
|
2941
|
+
ConsumerPaymentClaimSchema.parse(claim),
|
|
2942
|
+
(raw) => ConsumerSettleResultSchema.parse(raw)
|
|
2943
|
+
)
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2637
2946
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2638
2947
|
0 && (module.exports = {
|
|
2639
2948
|
ACCOUNT_STATUSES,
|
|
@@ -2642,6 +2951,16 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2642
2951
|
AccountMembershipSchema,
|
|
2643
2952
|
AccountSchema,
|
|
2644
2953
|
ApiCredentialPublicSchema,
|
|
2954
|
+
ConsumerOACRecordSchema,
|
|
2955
|
+
ConsumerOACSchema,
|
|
2956
|
+
ConsumerPaymentClaimSchema,
|
|
2957
|
+
ConsumerSettleResultSchema,
|
|
2958
|
+
ConsumerSettlementSchema,
|
|
2959
|
+
DeviceKeyRecordSchema,
|
|
2960
|
+
DisableOfflineInputSchema,
|
|
2961
|
+
DisableOfflineResultSchema,
|
|
2962
|
+
EnableOfflineInputSchema,
|
|
2963
|
+
EnableOfflineResultSchema,
|
|
2645
2964
|
FIELD,
|
|
2646
2965
|
FlurApiError,
|
|
2647
2966
|
FlurCapExceededError,
|
|
@@ -2649,6 +2968,7 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2649
2968
|
FlurError,
|
|
2650
2969
|
FlurExpiredError,
|
|
2651
2970
|
FlurReplayError,
|
|
2971
|
+
IssueOACInputSchema,
|
|
2652
2972
|
MEMBERSHIP_ROLES,
|
|
2653
2973
|
MintedApiCredentialSchema,
|
|
2654
2974
|
NGN_CURRENCY_CODE,
|
|
@@ -2658,8 +2978,11 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2658
2978
|
OAC_DEFAULT_CUMULATIVE_KOBO,
|
|
2659
2979
|
OAC_DEFAULT_PER_TX_KOBO,
|
|
2660
2980
|
OAC_DEFAULT_VALIDITY_MS,
|
|
2981
|
+
OfflineHoldRecordSchema,
|
|
2661
2982
|
OfflinePaymentAuthorizationSchema,
|
|
2662
2983
|
OfflinePaymentRequestSchema,
|
|
2984
|
+
OfflineStateResultSchema,
|
|
2985
|
+
OfflineStatusResultSchema,
|
|
2663
2986
|
OfflineTokenSchema,
|
|
2664
2987
|
PARTNER_SCOPES,
|
|
2665
2988
|
PASS_KINDS,
|
|
@@ -2675,8 +2998,11 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2675
2998
|
ReceiptPayloadSchema,
|
|
2676
2999
|
ReceiptSchema,
|
|
2677
3000
|
RedemptionSchema,
|
|
3001
|
+
RegisterDeviceKeyInputSchema,
|
|
3002
|
+
RevokeDeviceKeyInputSchema,
|
|
2678
3003
|
SettleResponseSchema,
|
|
2679
3004
|
SettlementSchema,
|
|
3005
|
+
SignedConsumerOACSchema,
|
|
2680
3006
|
bodySha256Hex,
|
|
2681
3007
|
buildAuthorization,
|
|
2682
3008
|
buildOAC,
|
|
@@ -2695,6 +3021,7 @@ function createApiCredentialsAdminClient(opts) {
|
|
|
2695
3021
|
createApiCredentialsAdminClient,
|
|
2696
3022
|
createFlurPartnerClient,
|
|
2697
3023
|
createHmacFetch,
|
|
3024
|
+
createMeOfflineClient,
|
|
2698
3025
|
createOfflineSettlementsClient,
|
|
2699
3026
|
createPassesClient,
|
|
2700
3027
|
createReceiptsClient,
|