@lightsparkdev/lightspark-sdk 1.6.0 → 1.7.0
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/CHANGELOG.md +7 -0
- package/dist/{chunk-UHTZSOPX.js → chunk-DSWMAFFH.js} +18 -2
- package/dist/{index-145ff316.d.ts → index-2f0cac65.d.ts} +39 -7
- package/dist/index.cjs +72 -5
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -4
- package/dist/objects/index.cjs +19 -2
- package/dist/objects/index.d.cts +1 -1
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +3 -1
- package/package.json +1 -1
- package/src/client.ts +63 -1
- package/src/graphql/CreateUmaInvoice.ts +2 -0
- package/src/graphql/PayUmaInvoice.ts +2 -0
- package/src/objects/Account.ts +1 -0
- package/src/objects/CreateLnurlInvoiceInput.ts +6 -0
- package/src/objects/CreateUmaInvoiceInput.ts +4 -0
- package/src/objects/CurrencyUnit.ts +1 -1
- package/src/objects/Entity.ts +1 -0
- package/src/objects/PayUmaInvoiceInput.ts +8 -0
- package/src/objects/RequestInitiator.ts +15 -0
- package/src/objects/TransactionStatus.ts +1 -1
- package/src/objects/Wallet.ts +1 -0
- package/src/objects/WalletStatus.ts +2 -2
- package/src/objects/WithdrawalRequest.ts +7 -0
- package/src/objects/index.ts +1 -0
- package/src/tests/integration/general-regtest.test.ts +3 -0
- package/src/tests/uma-utils.test.ts +70 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CurrencyAmountToJson,
|
|
10
10
|
} from "./CurrencyAmount.js";
|
|
11
11
|
import type Entity from "./Entity.js";
|
|
12
|
+
import RequestInitiator from "./RequestInitiator.js";
|
|
12
13
|
import WithdrawalMode from "./WithdrawalMode.js";
|
|
13
14
|
import WithdrawalRequestStatus from "./WithdrawalRequestStatus.js";
|
|
14
15
|
import type WithdrawalRequestToChannelClosingTransactionsConnection from "./WithdrawalRequestToChannelClosingTransactionsConnection.js";
|
|
@@ -55,6 +56,8 @@ class WithdrawalRequest implements Entity {
|
|
|
55
56
|
public readonly withdrawalMode: WithdrawalMode,
|
|
56
57
|
/** The current status of this withdrawal request. **/
|
|
57
58
|
public readonly status: WithdrawalRequestStatus,
|
|
59
|
+
/** The initiator of the withdrawal. **/
|
|
60
|
+
public readonly initiator: RequestInitiator,
|
|
58
61
|
/** The typename of the object **/
|
|
59
62
|
public readonly typename: string,
|
|
60
63
|
/**
|
|
@@ -320,6 +323,7 @@ ${FRAGMENT}
|
|
|
320
323
|
withdrawal_request_completed_at: this.completedAt,
|
|
321
324
|
withdrawal_request_withdrawal: { id: this.withdrawalId } ?? undefined,
|
|
322
325
|
withdrawal_request_idempotency_key: this.idempotencyKey,
|
|
326
|
+
withdrawal_request_initiator: this.initiator,
|
|
323
327
|
};
|
|
324
328
|
}
|
|
325
329
|
}
|
|
@@ -336,6 +340,8 @@ export const WithdrawalRequestFromJson = (obj: any): WithdrawalRequest => {
|
|
|
336
340
|
WithdrawalMode.FUTURE_VALUE,
|
|
337
341
|
WithdrawalRequestStatus[obj["withdrawal_request_status"]] ??
|
|
338
342
|
WithdrawalRequestStatus.FUTURE_VALUE,
|
|
343
|
+
RequestInitiator[obj["withdrawal_request_initiator"]] ??
|
|
344
|
+
RequestInitiator.FUTURE_VALUE,
|
|
339
345
|
"WithdrawalRequest",
|
|
340
346
|
!!obj["withdrawal_request_estimated_amount"]
|
|
341
347
|
? CurrencyAmountFromJson(obj["withdrawal_request_estimated_amount"])
|
|
@@ -406,6 +412,7 @@ fragment WithdrawalRequestFragment on WithdrawalRequest {
|
|
|
406
412
|
id
|
|
407
413
|
}
|
|
408
414
|
withdrawal_request_idempotency_key: idempotency_key
|
|
415
|
+
withdrawal_request_initiator: initiator
|
|
409
416
|
}`;
|
|
410
417
|
|
|
411
418
|
export default WithdrawalRequest;
|
package/src/objects/index.ts
CHANGED
|
@@ -152,6 +152,7 @@ export { default as ReleaseChannelPerCommitmentSecretOutput } from "./ReleaseCha
|
|
|
152
152
|
export { default as ReleasePaymentPreimageInput } from "./ReleasePaymentPreimageInput.js";
|
|
153
153
|
export { default as ReleasePaymentPreimageOutput } from "./ReleasePaymentPreimageOutput.js";
|
|
154
154
|
export { default as RemoteSigningSubEventType } from "./RemoteSigningSubEventType.js";
|
|
155
|
+
export { default as RequestInitiator } from "./RequestInitiator.js";
|
|
155
156
|
export { default as RequestWithdrawalInput } from "./RequestWithdrawalInput.js";
|
|
156
157
|
export { default as RequestWithdrawalOutput } from "./RequestWithdrawalOutput.js";
|
|
157
158
|
export { default as RichText } from "./RichText.js";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import LightsparkClient from "../client.js";
|
|
3
|
+
import { getCredentialsFromEnvOrThrow } from "../env.js";
|
|
4
|
+
import { AccountTokenAuthProvider } from "../index.js";
|
|
5
|
+
import { TESTS_TIMEOUT } from "./integration/constants.js";
|
|
6
|
+
|
|
7
|
+
const { apiTokenClientId, apiTokenClientSecret, baseUrl } =
|
|
8
|
+
getCredentialsFromEnvOrThrow();
|
|
9
|
+
|
|
10
|
+
const accountAuthProvider = new AccountTokenAuthProvider(
|
|
11
|
+
apiTokenClientId,
|
|
12
|
+
apiTokenClientSecret,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
16
|
+
|
|
17
|
+
describe("UmaUtils", () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.spyOn(lightsparkClient, "getUtcDateTime");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test(
|
|
23
|
+
"Should return same uma identifier hash for same month",
|
|
24
|
+
async () => {
|
|
25
|
+
const privKeyBytes = Buffer.from("xyz");
|
|
26
|
+
(lightsparkClient.getUtcDateTime as jest.Mock).mockReturnValue(
|
|
27
|
+
new Date(Date.UTC(2021, 0, 1, 0, 0, 0)),
|
|
28
|
+
);
|
|
29
|
+
const hashedUma = await lightsparkClient.hashUmaIdentifier(
|
|
30
|
+
"user@domain.com",
|
|
31
|
+
privKeyBytes,
|
|
32
|
+
);
|
|
33
|
+
const hashedUmaSameMonth = await lightsparkClient.hashUmaIdentifier(
|
|
34
|
+
"user@domain.com",
|
|
35
|
+
privKeyBytes,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(hashedUmaSameMonth).toStrictEqual(hashedUma);
|
|
39
|
+
console.log(hashedUma);
|
|
40
|
+
},
|
|
41
|
+
TESTS_TIMEOUT,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
test(
|
|
45
|
+
"Should return different uma identifier hash for different months",
|
|
46
|
+
async () => {
|
|
47
|
+
const privKeyBytes = Buffer.from("xyz");
|
|
48
|
+
(lightsparkClient.getUtcDateTime as jest.Mock).mockReturnValue(
|
|
49
|
+
new Date(Date.UTC(2021, 0, 1, 0, 0, 0)),
|
|
50
|
+
);
|
|
51
|
+
const hashedUma = await lightsparkClient.hashUmaIdentifier(
|
|
52
|
+
"user@domain.com",
|
|
53
|
+
privKeyBytes,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
(lightsparkClient.getUtcDateTime as jest.Mock).mockReturnValue(
|
|
57
|
+
new Date(Date.UTC(2021, 1, 1, 0, 0, 0)),
|
|
58
|
+
);
|
|
59
|
+
const hashedUmaNewMonth = await lightsparkClient.hashUmaIdentifier(
|
|
60
|
+
"user@domain.com",
|
|
61
|
+
privKeyBytes,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(hashedUmaNewMonth).not.toStrictEqual(hashedUma);
|
|
65
|
+
console.log(hashedUma);
|
|
66
|
+
console.log(hashedUmaNewMonth);
|
|
67
|
+
},
|
|
68
|
+
TESTS_TIMEOUT,
|
|
69
|
+
);
|
|
70
|
+
});
|