@frak-labs/nexus-sdk 0.0.8 → 0.0.10
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/chunk-3T2FNW6E.cjs +100 -0
- package/dist/chunk-72IEHEQX.js +48 -0
- package/dist/chunk-BPFJZRJ6.cjs +152 -0
- package/dist/chunk-ETV4XYOV.cjs +7 -0
- package/dist/{chunk-OXP3VK26.js → chunk-HOX3RRO6.js} +58 -30
- package/dist/chunk-NIFJZD3M.cjs +48 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/{chunk-JXQKTLEE.cjs → chunk-SGLR6RFA.cjs} +59 -31
- package/dist/chunk-T54VMWHQ.js +100 -0
- package/dist/chunk-TPC5PMRC.js +152 -0
- package/dist/{client-MgLVRfPw.d.cts → client--U_6SK0l.d.cts} +101 -12
- package/dist/{client-MgLVRfPw.d.ts → client-6_BJp7Ub.d.ts} +101 -12
- package/dist/core/actions/index.cjs +10 -3
- package/dist/core/actions/index.d.cts +31 -3
- package/dist/core/actions/index.d.ts +31 -3
- package/dist/core/actions/index.js +9 -2
- package/dist/core/index.cjs +4 -7
- package/dist/core/index.d.cts +8 -35
- package/dist/core/index.d.ts +8 -35
- package/dist/core/index.js +9 -12
- package/dist/core/interactions/index.cjs +9 -0
- package/dist/core/interactions/index.d.cts +39 -0
- package/dist/core/interactions/index.d.ts +39 -0
- package/dist/core/interactions/index.js +9 -0
- package/dist/error-C4Zm5nQe.d.cts +27 -0
- package/dist/error-C4Zm5nQe.d.ts +27 -0
- package/dist/interaction-D_CzyqRE.d.cts +22 -0
- package/dist/interaction-D_CzyqRE.d.ts +22 -0
- package/dist/react/index.cjs +276 -42
- package/dist/react/index.d.cts +72 -12
- package/dist/react/index.d.ts +72 -12
- package/dist/react/index.js +272 -38
- package/dist/{watchUnlockStatus-DQYfUj46.d.ts → watchUnlockStatus-CxnibdQx.d.cts} +3 -3
- package/dist/{watchUnlockStatus-DqWkImYK.d.cts → watchUnlockStatus-g8wIxpeM.d.ts} +3 -3
- package/package.json +11 -5
- package/dist/chunk-2XUJYDD3.cjs +0 -160
- package/dist/chunk-4VFMYMTH.js +0 -74
- package/dist/chunk-5QWG35A2.js +0 -160
- package/dist/chunk-6V4UCVTD.cjs +0 -74
package/dist/chunk-2XUJYDD3.cjs
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/core/utils/compression/compress.ts
|
|
9
|
-
var _asynclzstring = require('async-lz-string');
|
|
10
|
-
var _jssha256 = require('js-sha256');
|
|
11
|
-
async function hashAndCompressData(data, keyProvider) {
|
|
12
|
-
const keys = keyProvider(data);
|
|
13
|
-
const validationHash = _jssha256.sha256.call(void 0, keys.join("_"));
|
|
14
|
-
const hashProtectedData = {
|
|
15
|
-
...data,
|
|
16
|
-
validationHash
|
|
17
|
-
};
|
|
18
|
-
const compressed = await compressJson(hashProtectedData);
|
|
19
|
-
const compressedHash = _jssha256.sha256.call(void 0, compressed);
|
|
20
|
-
return {
|
|
21
|
-
compressed,
|
|
22
|
-
compressedHash
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
async function compressJson(data) {
|
|
26
|
-
return _asynclzstring.compressToBase64.call(void 0, JSON.stringify(data));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/core/utils/compression/decompress.ts
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
async function decompressDataAndCheckHash(compressedData, keyAccessor) {
|
|
33
|
-
if (!(_optionalChain([compressedData, 'optionalAccess', _ => _.compressed]) && _optionalChain([compressedData, 'optionalAccess', _2 => _2.compressedHash]))) {
|
|
34
|
-
throw new Error("Missing compressed data");
|
|
35
|
-
}
|
|
36
|
-
const parsedData = await decompressJson(
|
|
37
|
-
compressedData.compressed
|
|
38
|
-
);
|
|
39
|
-
if (!parsedData) {
|
|
40
|
-
throw new Error(`Invalid compressed data: ${parsedData}`);
|
|
41
|
-
}
|
|
42
|
-
if (!_optionalChain([parsedData, 'optionalAccess', _3 => _3.validationHash])) {
|
|
43
|
-
throw new Error("Missing validation hash");
|
|
44
|
-
}
|
|
45
|
-
const expectedCompressedHash = _jssha256.sha256.call(void 0, compressedData.compressed);
|
|
46
|
-
if (expectedCompressedHash !== compressedData.compressedHash) {
|
|
47
|
-
throw new Error("Invalid compressed hash");
|
|
48
|
-
}
|
|
49
|
-
const keys = keyAccessor(parsedData);
|
|
50
|
-
const expectedValidationHash = _jssha256.sha256.call(void 0, keys.join("_"));
|
|
51
|
-
if (expectedValidationHash !== parsedData.validationHash) {
|
|
52
|
-
throw new Error("Invalid data validation hash");
|
|
53
|
-
}
|
|
54
|
-
return parsedData;
|
|
55
|
-
}
|
|
56
|
-
async function decompressJson(data) {
|
|
57
|
-
const decompressed = await _asynclzstring.decompressFromBase64.call(void 0, data);
|
|
58
|
-
try {
|
|
59
|
-
return JSON.parse(decompressed);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
console.error("Invalid compressed data", e);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// src/core/utils/compression/iframeRpcKeyProvider.ts
|
|
67
|
-
var iFrameRequestKeyProvider = (args) => {
|
|
68
|
-
if (args.method === "frak_getArticleUnlockOptions") {
|
|
69
|
-
return ["get-price", args.params[0], args.params[1]];
|
|
70
|
-
}
|
|
71
|
-
if (args.method === "frak_listenToWalletStatus") {
|
|
72
|
-
return ["wallet-status"];
|
|
73
|
-
}
|
|
74
|
-
if (args.method === "frak_listenToArticleUnlockStatus") {
|
|
75
|
-
return ["article-unlock-status", args.params[0], args.params[1]];
|
|
76
|
-
}
|
|
77
|
-
throw new Error(`No key provider found for the arguments ${args}`);
|
|
78
|
-
};
|
|
79
|
-
function getIFrameResponseKeyProvider(param) {
|
|
80
|
-
if (param.method === "frak_getArticleUnlockOptions") {
|
|
81
|
-
return (response) => [
|
|
82
|
-
"get-price-response",
|
|
83
|
-
response.prices.length
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
if (param.method === "frak_listenToWalletStatus") {
|
|
87
|
-
return (response) => [
|
|
88
|
-
"wallet-status",
|
|
89
|
-
response.key,
|
|
90
|
-
response.key === "connected" ? response.wallet : "0xdeadbeef"
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
if (param.method === "frak_listenToArticleUnlockStatus") {
|
|
94
|
-
return (response) => [
|
|
95
|
-
"article-unlock-status",
|
|
96
|
-
response.key,
|
|
97
|
-
response.key === "valid" ? response.allowedUntil.toString(16) : "deadbeef"
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
throw new Error(`No key provider found for the request ${param}`);
|
|
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.width = "0";
|
|
115
|
-
iframe.style.height = "0";
|
|
116
|
-
iframe.style.border = "0";
|
|
117
|
-
iframe.style.position = "absolute";
|
|
118
|
-
iframe.style.top = "-1000px";
|
|
119
|
-
iframe.style.left = "-1000px";
|
|
120
|
-
document.body.appendChild(iframe);
|
|
121
|
-
return new Promise((resolve) => {
|
|
122
|
-
_optionalChain([iframe, 'optionalAccess', _4 => _4.addEventListener, 'call', _5 => _5("load", () => resolve(iframe))]);
|
|
123
|
-
iframe.src = `${walletBaseUrl}/listener`;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/core/utils/compression/redirectKeyProvider.ts
|
|
128
|
-
var redirectRequestKeyProvider = (args) => {
|
|
129
|
-
if (args.method === "frak_startArticleUnlock") {
|
|
130
|
-
return [
|
|
131
|
-
"start-unlock",
|
|
132
|
-
args.params.contentId,
|
|
133
|
-
args.params.articleId,
|
|
134
|
-
args.params.price.index.toString()
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
throw new Error(`No key provider found for the arguments ${args}`);
|
|
138
|
-
};
|
|
139
|
-
function getRedirectResponseResponseKeyProvider(method) {
|
|
140
|
-
if (method === "frak_startArticleUnlock") {
|
|
141
|
-
return (response) => [
|
|
142
|
-
"start-unlock",
|
|
143
|
-
response.key,
|
|
144
|
-
response.status,
|
|
145
|
-
_nullishCoalesce(response.user, () => ( "0xdeadbeef"))
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
throw new Error(`No key provider found for the method ${method}`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
exports.__publicField = __publicField; exports.hashAndCompressData = hashAndCompressData; exports.decompressDataAndCheckHash = decompressDataAndCheckHash; exports.iFrameRequestKeyProvider = iFrameRequestKeyProvider; exports.getIFrameResponseKeyProvider = getIFrameResponseKeyProvider; exports.createIframe = createIframe; exports.redirectRequestKeyProvider = redirectRequestKeyProvider; exports.getRedirectResponseResponseKeyProvider = getRedirectResponseResponseKeyProvider;
|
package/dist/chunk-4VFMYMTH.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decompressDataAndCheckHash,
|
|
3
|
-
getRedirectResponseResponseKeyProvider,
|
|
4
|
-
hashAndCompressData,
|
|
5
|
-
redirectRequestKeyProvider
|
|
6
|
-
} from "./chunk-5QWG35A2.js";
|
|
7
|
-
|
|
8
|
-
// src/core/actions/getUnlockOptions.ts
|
|
9
|
-
function getArticleUnlockOptions(client, { articleId, contentId }) {
|
|
10
|
-
return client.request({
|
|
11
|
-
method: "frak_getArticleUnlockOptions",
|
|
12
|
-
params: [contentId, articleId]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// src/core/actions/watchUnlockStatus.ts
|
|
17
|
-
function watchUnlockStatus(client, { articleId, contentId }, callback) {
|
|
18
|
-
return client.listenerRequest(
|
|
19
|
-
{
|
|
20
|
-
method: "frak_listenToArticleUnlockStatus",
|
|
21
|
-
params: [contentId, articleId]
|
|
22
|
-
},
|
|
23
|
-
callback
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/core/actions/watchWalletStatus.ts
|
|
28
|
-
function watchWalletStatus(client, callback) {
|
|
29
|
-
return client.listenerRequest(
|
|
30
|
-
{
|
|
31
|
-
method: "frak_listenToWalletStatus"
|
|
32
|
-
},
|
|
33
|
-
callback
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/core/actions/startUnlock.ts
|
|
38
|
-
async function getStartArticleUnlockUrl(config, params) {
|
|
39
|
-
const { compressed, compressedHash } = await hashAndCompressData(
|
|
40
|
-
{
|
|
41
|
-
method: "frak_startArticleUnlock",
|
|
42
|
-
params
|
|
43
|
-
},
|
|
44
|
-
redirectRequestKeyProvider
|
|
45
|
-
);
|
|
46
|
-
const outputUrl = new URL(config.walletUrl);
|
|
47
|
-
outputUrl.pathname = "/paywall";
|
|
48
|
-
outputUrl.searchParams.set("params", encodeURIComponent(compressed));
|
|
49
|
-
outputUrl.searchParams.set("hash", encodeURIComponent(compressedHash));
|
|
50
|
-
return outputUrl.toString();
|
|
51
|
-
}
|
|
52
|
-
async function decodeStartUnlockReturn({
|
|
53
|
-
result,
|
|
54
|
-
hash
|
|
55
|
-
}) {
|
|
56
|
-
const keyProvider = getRedirectResponseResponseKeyProvider(
|
|
57
|
-
"frak_startArticleUnlock"
|
|
58
|
-
);
|
|
59
|
-
return decompressDataAndCheckHash(
|
|
60
|
-
{
|
|
61
|
-
compressed: decodeURIComponent(result),
|
|
62
|
-
compressedHash: decodeURIComponent(hash)
|
|
63
|
-
},
|
|
64
|
-
keyProvider
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export {
|
|
69
|
-
getArticleUnlockOptions,
|
|
70
|
-
watchUnlockStatus,
|
|
71
|
-
watchWalletStatus,
|
|
72
|
-
getStartArticleUnlockUrl,
|
|
73
|
-
decodeStartUnlockReturn
|
|
74
|
-
};
|
package/dist/chunk-5QWG35A2.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/core/utils/compression/compress.ts
|
|
9
|
-
import { compressToBase64 } from "async-lz-string";
|
|
10
|
-
import { sha256 } from "js-sha256";
|
|
11
|
-
async function hashAndCompressData(data, keyProvider) {
|
|
12
|
-
const keys = keyProvider(data);
|
|
13
|
-
const validationHash = sha256(keys.join("_"));
|
|
14
|
-
const hashProtectedData = {
|
|
15
|
-
...data,
|
|
16
|
-
validationHash
|
|
17
|
-
};
|
|
18
|
-
const compressed = await compressJson(hashProtectedData);
|
|
19
|
-
const compressedHash = sha256(compressed);
|
|
20
|
-
return {
|
|
21
|
-
compressed,
|
|
22
|
-
compressedHash
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
async function compressJson(data) {
|
|
26
|
-
return compressToBase64(JSON.stringify(data));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/core/utils/compression/decompress.ts
|
|
30
|
-
import { decompressFromBase64 } from "async-lz-string";
|
|
31
|
-
import { sha256 as sha2562 } from "js-sha256";
|
|
32
|
-
async function decompressDataAndCheckHash(compressedData, keyAccessor) {
|
|
33
|
-
if (!(compressedData?.compressed && compressedData?.compressedHash)) {
|
|
34
|
-
throw new Error("Missing compressed data");
|
|
35
|
-
}
|
|
36
|
-
const parsedData = await decompressJson(
|
|
37
|
-
compressedData.compressed
|
|
38
|
-
);
|
|
39
|
-
if (!parsedData) {
|
|
40
|
-
throw new Error(`Invalid compressed data: ${parsedData}`);
|
|
41
|
-
}
|
|
42
|
-
if (!parsedData?.validationHash) {
|
|
43
|
-
throw new Error("Missing validation hash");
|
|
44
|
-
}
|
|
45
|
-
const expectedCompressedHash = sha2562(compressedData.compressed);
|
|
46
|
-
if (expectedCompressedHash !== compressedData.compressedHash) {
|
|
47
|
-
throw new Error("Invalid compressed hash");
|
|
48
|
-
}
|
|
49
|
-
const keys = keyAccessor(parsedData);
|
|
50
|
-
const expectedValidationHash = sha2562(keys.join("_"));
|
|
51
|
-
if (expectedValidationHash !== parsedData.validationHash) {
|
|
52
|
-
throw new Error("Invalid data validation hash");
|
|
53
|
-
}
|
|
54
|
-
return parsedData;
|
|
55
|
-
}
|
|
56
|
-
async function decompressJson(data) {
|
|
57
|
-
const decompressed = await decompressFromBase64(data);
|
|
58
|
-
try {
|
|
59
|
-
return JSON.parse(decompressed);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
console.error("Invalid compressed data", e);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// src/core/utils/compression/iframeRpcKeyProvider.ts
|
|
67
|
-
var iFrameRequestKeyProvider = (args) => {
|
|
68
|
-
if (args.method === "frak_getArticleUnlockOptions") {
|
|
69
|
-
return ["get-price", args.params[0], args.params[1]];
|
|
70
|
-
}
|
|
71
|
-
if (args.method === "frak_listenToWalletStatus") {
|
|
72
|
-
return ["wallet-status"];
|
|
73
|
-
}
|
|
74
|
-
if (args.method === "frak_listenToArticleUnlockStatus") {
|
|
75
|
-
return ["article-unlock-status", args.params[0], args.params[1]];
|
|
76
|
-
}
|
|
77
|
-
throw new Error(`No key provider found for the arguments ${args}`);
|
|
78
|
-
};
|
|
79
|
-
function getIFrameResponseKeyProvider(param) {
|
|
80
|
-
if (param.method === "frak_getArticleUnlockOptions") {
|
|
81
|
-
return (response) => [
|
|
82
|
-
"get-price-response",
|
|
83
|
-
response.prices.length
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
if (param.method === "frak_listenToWalletStatus") {
|
|
87
|
-
return (response) => [
|
|
88
|
-
"wallet-status",
|
|
89
|
-
response.key,
|
|
90
|
-
response.key === "connected" ? response.wallet : "0xdeadbeef"
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
if (param.method === "frak_listenToArticleUnlockStatus") {
|
|
94
|
-
return (response) => [
|
|
95
|
-
"article-unlock-status",
|
|
96
|
-
response.key,
|
|
97
|
-
response.key === "valid" ? response.allowedUntil.toString(16) : "deadbeef"
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
throw new Error(`No key provider found for the request ${param}`);
|
|
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.width = "0";
|
|
115
|
-
iframe.style.height = "0";
|
|
116
|
-
iframe.style.border = "0";
|
|
117
|
-
iframe.style.position = "absolute";
|
|
118
|
-
iframe.style.top = "-1000px";
|
|
119
|
-
iframe.style.left = "-1000px";
|
|
120
|
-
document.body.appendChild(iframe);
|
|
121
|
-
return new Promise((resolve) => {
|
|
122
|
-
iframe?.addEventListener("load", () => resolve(iframe));
|
|
123
|
-
iframe.src = `${walletBaseUrl}/listener`;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/core/utils/compression/redirectKeyProvider.ts
|
|
128
|
-
var redirectRequestKeyProvider = (args) => {
|
|
129
|
-
if (args.method === "frak_startArticleUnlock") {
|
|
130
|
-
return [
|
|
131
|
-
"start-unlock",
|
|
132
|
-
args.params.contentId,
|
|
133
|
-
args.params.articleId,
|
|
134
|
-
args.params.price.index.toString()
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
throw new Error(`No key provider found for the arguments ${args}`);
|
|
138
|
-
};
|
|
139
|
-
function getRedirectResponseResponseKeyProvider(method) {
|
|
140
|
-
if (method === "frak_startArticleUnlock") {
|
|
141
|
-
return (response) => [
|
|
142
|
-
"start-unlock",
|
|
143
|
-
response.key,
|
|
144
|
-
response.status,
|
|
145
|
-
response.user ?? "0xdeadbeef"
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
throw new Error(`No key provider found for the method ${method}`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export {
|
|
152
|
-
__publicField,
|
|
153
|
-
hashAndCompressData,
|
|
154
|
-
decompressDataAndCheckHash,
|
|
155
|
-
iFrameRequestKeyProvider,
|
|
156
|
-
getIFrameResponseKeyProvider,
|
|
157
|
-
createIframe,
|
|
158
|
-
redirectRequestKeyProvider,
|
|
159
|
-
getRedirectResponseResponseKeyProvider
|
|
160
|
-
};
|
package/dist/chunk-6V4UCVTD.cjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk2XUJYDD3cjs = require('./chunk-2XUJYDD3.cjs');
|
|
7
|
-
|
|
8
|
-
// src/core/actions/getUnlockOptions.ts
|
|
9
|
-
function getArticleUnlockOptions(client, { articleId, contentId }) {
|
|
10
|
-
return client.request({
|
|
11
|
-
method: "frak_getArticleUnlockOptions",
|
|
12
|
-
params: [contentId, articleId]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// src/core/actions/watchUnlockStatus.ts
|
|
17
|
-
function watchUnlockStatus(client, { articleId, contentId }, callback) {
|
|
18
|
-
return client.listenerRequest(
|
|
19
|
-
{
|
|
20
|
-
method: "frak_listenToArticleUnlockStatus",
|
|
21
|
-
params: [contentId, articleId]
|
|
22
|
-
},
|
|
23
|
-
callback
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/core/actions/watchWalletStatus.ts
|
|
28
|
-
function watchWalletStatus(client, callback) {
|
|
29
|
-
return client.listenerRequest(
|
|
30
|
-
{
|
|
31
|
-
method: "frak_listenToWalletStatus"
|
|
32
|
-
},
|
|
33
|
-
callback
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/core/actions/startUnlock.ts
|
|
38
|
-
async function getStartArticleUnlockUrl(config, params) {
|
|
39
|
-
const { compressed, compressedHash } = await _chunk2XUJYDD3cjs.hashAndCompressData.call(void 0,
|
|
40
|
-
{
|
|
41
|
-
method: "frak_startArticleUnlock",
|
|
42
|
-
params
|
|
43
|
-
},
|
|
44
|
-
_chunk2XUJYDD3cjs.redirectRequestKeyProvider
|
|
45
|
-
);
|
|
46
|
-
const outputUrl = new URL(config.walletUrl);
|
|
47
|
-
outputUrl.pathname = "/paywall";
|
|
48
|
-
outputUrl.searchParams.set("params", encodeURIComponent(compressed));
|
|
49
|
-
outputUrl.searchParams.set("hash", encodeURIComponent(compressedHash));
|
|
50
|
-
return outputUrl.toString();
|
|
51
|
-
}
|
|
52
|
-
async function decodeStartUnlockReturn({
|
|
53
|
-
result,
|
|
54
|
-
hash
|
|
55
|
-
}) {
|
|
56
|
-
const keyProvider = _chunk2XUJYDD3cjs.getRedirectResponseResponseKeyProvider.call(void 0,
|
|
57
|
-
"frak_startArticleUnlock"
|
|
58
|
-
);
|
|
59
|
-
return _chunk2XUJYDD3cjs.decompressDataAndCheckHash.call(void 0,
|
|
60
|
-
{
|
|
61
|
-
compressed: decodeURIComponent(result),
|
|
62
|
-
compressedHash: decodeURIComponent(hash)
|
|
63
|
-
},
|
|
64
|
-
keyProvider
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
exports.getArticleUnlockOptions = getArticleUnlockOptions; exports.watchUnlockStatus = watchUnlockStatus; exports.watchWalletStatus = watchWalletStatus; exports.getStartArticleUnlockUrl = getStartArticleUnlockUrl; exports.decodeStartUnlockReturn = decodeStartUnlockReturn;
|