@frak-labs/nexus-sdk 0.0.10 → 0.0.11

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.
Files changed (37) hide show
  1. package/dist/chunk-5CFD5FM2.js +86 -0
  2. package/dist/chunk-7MVQQ2X6.js +381 -0
  3. package/dist/{chunk-72IEHEQX.js → chunk-GUDT2W6I.js} +32 -10
  4. package/dist/{chunk-NIFJZD3M.cjs → chunk-IQQTTKJL.cjs} +30 -8
  5. package/dist/chunk-S5FVCA2E.cjs +86 -0
  6. package/dist/chunk-V3S6RBRJ.cjs +381 -0
  7. package/dist/{client-6_BJp7Ub.d.ts → client-C7u9zGwC.d.cts} +135 -142
  8. package/dist/{client--U_6SK0l.d.cts → client-gE3fYzkD.d.ts} +135 -142
  9. package/dist/core/actions/index.cjs +2 -7
  10. package/dist/core/actions/index.d.cts +16 -35
  11. package/dist/core/actions/index.d.ts +16 -35
  12. package/dist/core/actions/index.js +5 -10
  13. package/dist/core/index.cjs +2 -4
  14. package/dist/core/index.d.cts +3 -3
  15. package/dist/core/index.d.ts +3 -3
  16. package/dist/core/index.js +2 -4
  17. package/dist/core/interactions/index.cjs +6 -2
  18. package/dist/core/interactions/index.d.cts +20 -6
  19. package/dist/core/interactions/index.d.ts +20 -6
  20. package/dist/core/interactions/index.js +7 -3
  21. package/dist/{interaction-D_CzyqRE.d.cts → interaction-D3-M3nBh.d.cts} +2 -2
  22. package/dist/{interaction-D_CzyqRE.d.ts → interaction-D3-M3nBh.d.ts} +2 -2
  23. package/dist/react/index.cjs +146 -158
  24. package/dist/react/index.d.cts +44 -51
  25. package/dist/react/index.d.ts +44 -51
  26. package/dist/react/index.js +152 -164
  27. package/dist/sendTransaction-BZW627cT.d.cts +30 -0
  28. package/dist/sendTransaction-DpJTfGJc.d.ts +30 -0
  29. package/package.json +8 -5
  30. package/dist/chunk-3T2FNW6E.cjs +0 -100
  31. package/dist/chunk-BPFJZRJ6.cjs +0 -152
  32. package/dist/chunk-HOX3RRO6.js +0 -199
  33. package/dist/chunk-SGLR6RFA.cjs +0 -199
  34. package/dist/chunk-T54VMWHQ.js +0 -100
  35. package/dist/chunk-TPC5PMRC.js +0 -152
  36. package/dist/watchUnlockStatus-CxnibdQx.d.cts +0 -43
  37. package/dist/watchUnlockStatus-g8wIxpeM.d.ts +0 -43
@@ -1,152 +0,0 @@
1
- // src/core/types/rpc/error.ts
2
- var FrakRpcError = class extends Error {
3
- constructor(code, message, data) {
4
- super(message);
5
- this.code = code;
6
- this.data = data;
7
- }
8
- };
9
- var ClientNotFound = class extends FrakRpcError {
10
- constructor() {
11
- super(RpcErrorCodes.clientNotConnected, "Client not found");
12
- }
13
- };
14
- var RpcErrorCodes = {
15
- // Standard JSON-RPC 2.0 errors
16
- parseError: -32700,
17
- invalidRequest: -32600,
18
- methodNotFound: -32601,
19
- invalidParams: -32602,
20
- internalError: -32603,
21
- serverError: -32e3,
22
- // Frak specific errors (from -32001 to -32099)
23
- clientNotConnected: -32001,
24
- configError: -32002,
25
- corruptedResponse: -32003,
26
- clientAborted: -32004,
27
- walletNotConnected: -32005,
28
- noInteractionSession: -32006
29
- };
30
-
31
- // src/core/utils/compression/compress.ts
32
- import { compressToBase64 } from "async-lz-string";
33
- import { sha256 } from "js-sha256";
34
- async function hashAndCompressData(data) {
35
- const validationHash = sha256(JSON.stringify(data));
36
- const hashProtectedData = {
37
- ...data,
38
- validationHash
39
- };
40
- const compressed = await compressJson(hashProtectedData);
41
- const compressedHash = sha256(compressed);
42
- return {
43
- compressed,
44
- compressedHash
45
- };
46
- }
47
- async function compressJson(data) {
48
- return compressToBase64(JSON.stringify(data));
49
- }
50
-
51
- // src/core/utils/compression/decompress.ts
52
- import { decompressFromBase64 } from "async-lz-string";
53
- import { sha256 as sha2562 } from "js-sha256";
54
- async function decompressDataAndCheckHash(compressedData) {
55
- if (!(compressedData?.compressed && compressedData?.compressedHash)) {
56
- throw new FrakRpcError(
57
- RpcErrorCodes.corruptedResponse,
58
- "Missing compressed data"
59
- );
60
- }
61
- const parsedData = await decompressJson(
62
- compressedData.compressed
63
- );
64
- if (!parsedData) {
65
- throw new FrakRpcError(
66
- RpcErrorCodes.corruptedResponse,
67
- "Invalid compressed data"
68
- );
69
- }
70
- if (!parsedData?.validationHash) {
71
- throw new FrakRpcError(
72
- RpcErrorCodes.corruptedResponse,
73
- "Missing validation hash"
74
- );
75
- }
76
- const expectedCompressedHash = sha2562(compressedData.compressed);
77
- if (expectedCompressedHash !== compressedData.compressedHash) {
78
- throw new FrakRpcError(
79
- RpcErrorCodes.corruptedResponse,
80
- "Invalid compressed hash"
81
- );
82
- }
83
- const { validationHash: _, ...rawResultData } = parsedData;
84
- const expectedValidationHash = sha2562(JSON.stringify(rawResultData));
85
- if (expectedValidationHash !== parsedData.validationHash) {
86
- throw new FrakRpcError(
87
- RpcErrorCodes.corruptedResponse,
88
- "Invalid data validation hash"
89
- );
90
- }
91
- return parsedData;
92
- }
93
- async function decompressJson(data) {
94
- const decompressed = await decompressFromBase64(data);
95
- try {
96
- return JSON.parse(decompressed);
97
- } catch (e) {
98
- console.error("Invalid compressed data", e);
99
- return null;
100
- }
101
- }
102
-
103
- // src/core/utils/iframeHelper.ts
104
- function createIframe({
105
- walletBaseUrl
106
- }) {
107
- const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
108
- if (alreadyCreatedIFrame) {
109
- return Promise.resolve(void 0);
110
- }
111
- const iframe = document.createElement("iframe");
112
- iframe.name = "nexus-wallet";
113
- iframe.id = "nexus-wallet";
114
- iframe.style.zIndex = "1000";
115
- changeIframeVisibility({ iframe, isVisible: false });
116
- document.body.appendChild(iframe);
117
- return new Promise((resolve) => {
118
- iframe?.addEventListener("load", () => resolve(iframe));
119
- iframe.src = `${walletBaseUrl}/listener`;
120
- });
121
- }
122
- function changeIframeVisibility({
123
- iframe,
124
- isVisible
125
- }) {
126
- if (!isVisible) {
127
- iframe.style.width = "0";
128
- iframe.style.height = "0";
129
- iframe.style.border = "0";
130
- iframe.style.position = "fixed";
131
- iframe.style.top = "-1000px";
132
- iframe.style.left = "-1000px";
133
- return;
134
- }
135
- iframe.style.position = "fixed";
136
- iframe.style.top = "0";
137
- iframe.style.left = "0";
138
- iframe.style.width = "100%";
139
- iframe.style.height = "100%";
140
- }
141
-
142
- export {
143
- FrakRpcError,
144
- ClientNotFound,
145
- RpcErrorCodes,
146
- hashAndCompressData,
147
- compressJson,
148
- decompressDataAndCheckHash,
149
- decompressJson,
150
- createIframe,
151
- changeIframeVisibility
152
- };
@@ -1,43 +0,0 @@
1
- import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client--U_6SK0l.cjs';
3
-
4
- /**
5
- * Type used to get the unlock options
6
- */
7
- type GetUnlockOptionsParams = {
8
- articleId: Hex;
9
- contentId: Hex;
10
- };
11
- /**
12
- * Function used to fetch the unlock option for the given client
13
- * @param client
14
- * @param articleId
15
- * @param contentId
16
- */
17
- declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
18
- frkBalanceAsHex?: Hex;
19
- prices: {
20
- index: number;
21
- unlockDurationInSec: number;
22
- frkAmount: Hex;
23
- isUserAccessible: boolean | null;
24
- }[];
25
- }>>;
26
-
27
- /**
28
- * Type used to get the unlock options
29
- */
30
- type WatchUnlockStatusParams = {
31
- articleId: Hex;
32
- contentId: Hex;
33
- };
34
- /**
35
- * Function used to watch a current article unlock status
36
- * @param client
37
- * @param articleId
38
- * @param contentId
39
- * @param callback
40
- */
41
- declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
42
-
43
- export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };
@@ -1,43 +0,0 @@
1
- import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-6_BJp7Ub.js';
3
-
4
- /**
5
- * Type used to get the unlock options
6
- */
7
- type GetUnlockOptionsParams = {
8
- articleId: Hex;
9
- contentId: Hex;
10
- };
11
- /**
12
- * Function used to fetch the unlock option for the given client
13
- * @param client
14
- * @param articleId
15
- * @param contentId
16
- */
17
- declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
18
- frkBalanceAsHex?: Hex;
19
- prices: {
20
- index: number;
21
- unlockDurationInSec: number;
22
- frkAmount: Hex;
23
- isUserAccessible: boolean | null;
24
- }[];
25
- }>>;
26
-
27
- /**
28
- * Type used to get the unlock options
29
- */
30
- type WatchUnlockStatusParams = {
31
- articleId: Hex;
32
- contentId: Hex;
33
- };
34
- /**
35
- * Function used to watch a current article unlock status
36
- * @param client
37
- * @param articleId
38
- * @param contentId
39
- * @param callback
40
- */
41
- declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
42
-
43
- export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };