@frak-labs/nexus-sdk 0.0.1-alpha → 0.0.3-alpha
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/README.md +3 -0
- package/dist/{chunk-JE64MPH2.js → chunk-6ZFDRVV6.js} +3 -3
- package/dist/{chunk-4X75PGSK.cjs → chunk-N4N55SQ6.cjs} +3 -3
- package/dist/{client-SCwoh_kP.d.cts → client-CkvisXxD.d.cts} +4 -4
- package/dist/{client-SCwoh_kP.d.ts → client-CkvisXxD.d.ts} +4 -4
- package/dist/core/actions/index.cjs +5 -5
- package/dist/core/actions/index.d.cts +5 -5
- package/dist/core/actions/index.d.ts +5 -5
- package/dist/core/actions/index.js +1 -1
- package/dist/core/index.cjs +21 -21
- package/dist/core/index.d.cts +6 -6
- package/dist/core/index.d.ts +6 -6
- package/dist/core/index.js +8 -8
- package/package.json +18 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ Checkout our documentation for more informations about the usage:
|
|
|
8
8
|
|
|
9
9
|
To have more info about how does it works under the hood, you can check [this](https://docs.frak.id/wallet-sdk/under-the-hood)
|
|
10
10
|
|
|
11
|
+
> :warning: **This is in active development**: Only supporting polygon Mumbai at the moment, **DO NOT USE IN PROD**
|
|
12
|
+
|
|
13
|
+
|
|
11
14
|
## Installation
|
|
12
15
|
|
|
13
16
|
```bash
|
|
@@ -104,13 +104,13 @@ function getIFrameResponseKeyProvider(param) {
|
|
|
104
104
|
function createIframe({
|
|
105
105
|
walletBaseUrl
|
|
106
106
|
}) {
|
|
107
|
-
const isAlreadyCreated = document.querySelector("#
|
|
107
|
+
const isAlreadyCreated = document.querySelector("#nexus-wallet");
|
|
108
108
|
if (isAlreadyCreated) {
|
|
109
109
|
return Promise.resolve(void 0);
|
|
110
110
|
}
|
|
111
111
|
const iframe = document.createElement("iframe");
|
|
112
|
-
iframe.name = "
|
|
113
|
-
iframe.id = "
|
|
112
|
+
iframe.name = "nexus-wallet";
|
|
113
|
+
iframe.id = "nexus-wallet";
|
|
114
114
|
iframe.style.width = "0";
|
|
115
115
|
iframe.style.height = "0";
|
|
116
116
|
iframe.style.border = "0";
|
|
@@ -104,13 +104,13 @@ function getIFrameResponseKeyProvider(param) {
|
|
|
104
104
|
function createIframe({
|
|
105
105
|
walletBaseUrl
|
|
106
106
|
}) {
|
|
107
|
-
const isAlreadyCreated = document.querySelector("#
|
|
107
|
+
const isAlreadyCreated = document.querySelector("#nexus-wallet");
|
|
108
108
|
if (isAlreadyCreated) {
|
|
109
109
|
return Promise.resolve(void 0);
|
|
110
110
|
}
|
|
111
111
|
const iframe = document.createElement("iframe");
|
|
112
|
-
iframe.name = "
|
|
113
|
-
iframe.id = "
|
|
112
|
+
iframe.name = "nexus-wallet";
|
|
113
|
+
iframe.id = "nexus-wallet";
|
|
114
114
|
iframe.style.width = "0";
|
|
115
115
|
iframe.style.height = "0";
|
|
116
116
|
iframe.style.border = "0";
|
|
@@ -4,7 +4,7 @@ import { Prettify } from 'viem/chains';
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for the Frak Wallet SDK
|
|
6
6
|
*/
|
|
7
|
-
type
|
|
7
|
+
type NexusWalletSdkConfig = Readonly<{
|
|
8
8
|
walletUrl: string;
|
|
9
9
|
contentId: Hex;
|
|
10
10
|
contentTitle: string;
|
|
@@ -239,8 +239,8 @@ type IFrameLifecycleEvent = {
|
|
|
239
239
|
/**
|
|
240
240
|
* Representing a Frak client
|
|
241
241
|
*/
|
|
242
|
-
type
|
|
243
|
-
config:
|
|
242
|
+
type NexusClient = {
|
|
243
|
+
config: NexusWalletSdkConfig;
|
|
244
244
|
} & IFrameTransport;
|
|
245
245
|
|
|
246
|
-
export type { ArticleUnlockStatusReturnType as A, ExtractedParametersFromRpc as E,
|
|
246
|
+
export type { ArticleUnlockStatusReturnType as A, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, NexusClient as N, PaidArticleUnlockPrice as P, RedirectRpcSchema as R, StartArticleUnlockReturnType as S, UnlockOptionsReturnType as U, WalletStatusReturnType as W, NexusWalletSdkConfig as a, StartArticleUnlockParams as b, ExtractedReturnTypeFromRpc as c, IFrameTransport as d, IFrameRpcEvent as e, IFrameEvent as f };
|
|
@@ -4,7 +4,7 @@ import { Prettify } from 'viem/chains';
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for the Frak Wallet SDK
|
|
6
6
|
*/
|
|
7
|
-
type
|
|
7
|
+
type NexusWalletSdkConfig = Readonly<{
|
|
8
8
|
walletUrl: string;
|
|
9
9
|
contentId: Hex;
|
|
10
10
|
contentTitle: string;
|
|
@@ -239,8 +239,8 @@ type IFrameLifecycleEvent = {
|
|
|
239
239
|
/**
|
|
240
240
|
* Representing a Frak client
|
|
241
241
|
*/
|
|
242
|
-
type
|
|
243
|
-
config:
|
|
242
|
+
type NexusClient = {
|
|
243
|
+
config: NexusWalletSdkConfig;
|
|
244
244
|
} & IFrameTransport;
|
|
245
245
|
|
|
246
|
-
export type { ArticleUnlockStatusReturnType as A, ExtractedParametersFromRpc as E,
|
|
246
|
+
export type { ArticleUnlockStatusReturnType as A, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, NexusClient as N, PaidArticleUnlockPrice as P, RedirectRpcSchema as R, StartArticleUnlockReturnType as S, UnlockOptionsReturnType as U, WalletStatusReturnType as W, NexusWalletSdkConfig as a, StartArticleUnlockParams as b, ExtractedReturnTypeFromRpc as c, IFrameTransport as d, IFrameRpcEvent as e, IFrameEvent as f };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkN4N55SQ6cjs = require('../../chunk-N4N55SQ6.cjs');
|
|
7
7
|
|
|
8
8
|
// src/core/actions/getUnlockOptions.ts
|
|
9
9
|
function getArticleUnlockOptions(client, { articleId }) {
|
|
@@ -36,7 +36,7 @@ function watchWalletStatus(client, callback) {
|
|
|
36
36
|
|
|
37
37
|
// src/core/actions/startUnlock.ts
|
|
38
38
|
async function getStartArticleUnlockUrl(config, params) {
|
|
39
|
-
const { compressed, compressedHash } = await
|
|
39
|
+
const { compressed, compressedHash } = await _chunkN4N55SQ6cjs.hashAndCompressData.call(void 0,
|
|
40
40
|
{
|
|
41
41
|
method: "frak_startArticleUnlock",
|
|
42
42
|
params: {
|
|
@@ -45,7 +45,7 @@ async function getStartArticleUnlockUrl(config, params) {
|
|
|
45
45
|
contentTitle: config.contentTitle
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
|
|
48
|
+
_chunkN4N55SQ6cjs.redirectRequestKeyProvider
|
|
49
49
|
);
|
|
50
50
|
const outputUrl = new URL(config.walletUrl);
|
|
51
51
|
outputUrl.pathname = "/paywall";
|
|
@@ -57,10 +57,10 @@ async function decodeStartUnlockReturn({
|
|
|
57
57
|
result,
|
|
58
58
|
hash
|
|
59
59
|
}) {
|
|
60
|
-
const keyProvider =
|
|
60
|
+
const keyProvider = _chunkN4N55SQ6cjs.getRedirectResponseResponseKeyProvider.call(void 0,
|
|
61
61
|
"frak_startArticleUnlock"
|
|
62
62
|
);
|
|
63
|
-
return
|
|
63
|
+
return _chunkN4N55SQ6cjs.decompressDataAndCheckHash.call(void 0,
|
|
64
64
|
{
|
|
65
65
|
compressed: decodeURIComponent(result),
|
|
66
66
|
compressedHash: decodeURIComponent(hash)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { N as NexusClient, A as ArticleUnlockStatusReturnType, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-CkvisXxD.cjs';
|
|
3
3
|
import 'viem/chains';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ type GetUnlockOptionsParams = {
|
|
|
13
13
|
* @param client
|
|
14
14
|
* @param articleId
|
|
15
15
|
*/
|
|
16
|
-
declare function getArticleUnlockOptions(client:
|
|
16
|
+
declare function getArticleUnlockOptions(client: NexusClient, { articleId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
17
17
|
prices: {
|
|
18
18
|
index: number;
|
|
19
19
|
unlockDurationInSec: number;
|
|
@@ -34,14 +34,14 @@ type WatchUnlockStatusParams = {
|
|
|
34
34
|
* @param articleId
|
|
35
35
|
* @param callback
|
|
36
36
|
*/
|
|
37
|
-
declare function watchUnlockStatus(client:
|
|
37
|
+
declare function watchUnlockStatus(client: NexusClient, { articleId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Function used to watch the current nexus wallet status
|
|
41
41
|
* @param client
|
|
42
42
|
* @param callback
|
|
43
43
|
*/
|
|
44
|
-
declare function watchWalletStatus(client:
|
|
44
|
+
declare function watchWalletStatus(client: NexusClient, callback: (status: WalletStatusReturnType) => void): Promise<void>;
|
|
45
45
|
|
|
46
46
|
type GetStartUnlockUrlParams = Omit<StartArticleUnlockParams, "contentId" | "contentTitle">;
|
|
47
47
|
/**
|
|
@@ -49,7 +49,7 @@ type GetStartUnlockUrlParams = Omit<StartArticleUnlockParams, "contentId" | "con
|
|
|
49
49
|
* @param config
|
|
50
50
|
* @param params
|
|
51
51
|
*/
|
|
52
|
-
declare function getStartArticleUnlockUrl(config:
|
|
52
|
+
declare function getStartArticleUnlockUrl(config: NexusWalletSdkConfig, params: GetStartUnlockUrlParams): Promise<string>;
|
|
53
53
|
/**
|
|
54
54
|
* Function used to decode the response from the start unlock request (return typed passed as query param)
|
|
55
55
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { N as NexusClient, A as ArticleUnlockStatusReturnType, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-CkvisXxD.js';
|
|
3
3
|
import 'viem/chains';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ type GetUnlockOptionsParams = {
|
|
|
13
13
|
* @param client
|
|
14
14
|
* @param articleId
|
|
15
15
|
*/
|
|
16
|
-
declare function getArticleUnlockOptions(client:
|
|
16
|
+
declare function getArticleUnlockOptions(client: NexusClient, { articleId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
17
17
|
prices: {
|
|
18
18
|
index: number;
|
|
19
19
|
unlockDurationInSec: number;
|
|
@@ -34,14 +34,14 @@ type WatchUnlockStatusParams = {
|
|
|
34
34
|
* @param articleId
|
|
35
35
|
* @param callback
|
|
36
36
|
*/
|
|
37
|
-
declare function watchUnlockStatus(client:
|
|
37
|
+
declare function watchUnlockStatus(client: NexusClient, { articleId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Function used to watch the current nexus wallet status
|
|
41
41
|
* @param client
|
|
42
42
|
* @param callback
|
|
43
43
|
*/
|
|
44
|
-
declare function watchWalletStatus(client:
|
|
44
|
+
declare function watchWalletStatus(client: NexusClient, callback: (status: WalletStatusReturnType) => void): Promise<void>;
|
|
45
45
|
|
|
46
46
|
type GetStartUnlockUrlParams = Omit<StartArticleUnlockParams, "contentId" | "contentTitle">;
|
|
47
47
|
/**
|
|
@@ -49,7 +49,7 @@ type GetStartUnlockUrlParams = Omit<StartArticleUnlockParams, "contentId" | "con
|
|
|
49
49
|
* @param config
|
|
50
50
|
* @param params
|
|
51
51
|
*/
|
|
52
|
-
declare function getStartArticleUnlockUrl(config:
|
|
52
|
+
declare function getStartArticleUnlockUrl(config: NexusWalletSdkConfig, params: GetStartUnlockUrlParams): Promise<string>;
|
|
53
53
|
/**
|
|
54
54
|
* Function used to decode the response from the start unlock request (return typed passed as query param)
|
|
55
55
|
*/
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getRedirectResponseResponseKeyProvider,
|
|
4
4
|
hashAndCompressData,
|
|
5
5
|
redirectRequestKeyProvider
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-6ZFDRVV6.js";
|
|
7
7
|
|
|
8
8
|
// src/core/actions/getUnlockOptions.ts
|
|
9
9
|
function getArticleUnlockOptions(client, { articleId }) {
|
package/dist/core/index.cjs
CHANGED
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkN4N55SQ6cjs = require('../chunk-N4N55SQ6.cjs');
|
|
11
11
|
|
|
12
12
|
// src/core/utils/Deferred.ts
|
|
13
13
|
var Deferred = class {
|
|
14
14
|
constructor() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
_chunkN4N55SQ6cjs.__publicField.call(void 0, this, "_promise");
|
|
16
|
+
_chunkN4N55SQ6cjs.__publicField.call(void 0, this, "_resolve");
|
|
17
|
+
_chunkN4N55SQ6cjs.__publicField.call(void 0, this, "_reject");
|
|
18
|
+
_chunkN4N55SQ6cjs.__publicField.call(void 0, this, "resolve", (value) => {
|
|
19
19
|
_optionalChain([this, 'access', _ => _._resolve, 'optionalCall', _2 => _2(value)]);
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
_chunkN4N55SQ6cjs.__publicField.call(void 0, this, "reject", (reason) => {
|
|
22
22
|
_optionalChain([this, 'access', _3 => _3._reject, 'optionalCall', _4 => _4(reason)]);
|
|
23
23
|
});
|
|
24
24
|
this._promise = new Promise((resolve, reject) => {
|
|
@@ -49,7 +49,7 @@ function createIFrameChannelManager() {
|
|
|
49
49
|
|
|
50
50
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
51
51
|
function createIFrameMessageHandler({
|
|
52
|
-
|
|
52
|
+
nexusWalletUrl,
|
|
53
53
|
iframe,
|
|
54
54
|
channelManager
|
|
55
55
|
}) {
|
|
@@ -65,7 +65,7 @@ function createIFrameMessageHandler({
|
|
|
65
65
|
if (!event.origin) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
if (new URL(event.origin).origin.toLowerCase() !== new URL(
|
|
68
|
+
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
if ("lifecycle" in event.data) {
|
|
@@ -82,7 +82,7 @@ function createIFrameMessageHandler({
|
|
|
82
82
|
window.addEventListener("message", msgHandler);
|
|
83
83
|
const sendEvent = (message) => {
|
|
84
84
|
contentWindow.postMessage(message, {
|
|
85
|
-
targetOrigin:
|
|
85
|
+
targetOrigin: nexusWalletUrl
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
const cleanup = () => {
|
|
@@ -95,14 +95,14 @@ function createIFrameMessageHandler({
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// src/core/clients/
|
|
99
|
-
function
|
|
98
|
+
// src/core/clients/createIFrameNexusClient.ts
|
|
99
|
+
function createIFrameNexusClient({
|
|
100
100
|
config,
|
|
101
101
|
iframe
|
|
102
102
|
}) {
|
|
103
103
|
const channelManager = createIFrameChannelManager();
|
|
104
104
|
const messageHandler = createIFrameMessageHandler({
|
|
105
|
-
|
|
105
|
+
nexusWalletUrl: config.walletUrl,
|
|
106
106
|
iframe,
|
|
107
107
|
channelManager
|
|
108
108
|
});
|
|
@@ -112,18 +112,18 @@ function createIFrameFrakClient({
|
|
|
112
112
|
throw new Error("The iframe provider isn't connected yet");
|
|
113
113
|
}
|
|
114
114
|
const result = new Deferred();
|
|
115
|
-
const resultCompressionKeyProvider =
|
|
115
|
+
const resultCompressionKeyProvider = _chunkN4N55SQ6cjs.getIFrameResponseKeyProvider.call(void 0, args);
|
|
116
116
|
const channelId = channelManager.createChannel(async (message) => {
|
|
117
|
-
const decompressed = await
|
|
117
|
+
const decompressed = await _chunkN4N55SQ6cjs.decompressDataAndCheckHash.call(void 0,
|
|
118
118
|
message.data,
|
|
119
119
|
resultCompressionKeyProvider
|
|
120
120
|
);
|
|
121
121
|
result.resolve(decompressed);
|
|
122
122
|
channelManager.removeChannel(channelId);
|
|
123
123
|
});
|
|
124
|
-
const compressedMessage = await
|
|
124
|
+
const compressedMessage = await _chunkN4N55SQ6cjs.hashAndCompressData.call(void 0,
|
|
125
125
|
args,
|
|
126
|
-
|
|
126
|
+
_chunkN4N55SQ6cjs.iFrameRequestKeyProvider
|
|
127
127
|
);
|
|
128
128
|
messageHandler.sendEvent({
|
|
129
129
|
id: channelId,
|
|
@@ -137,17 +137,17 @@ function createIFrameFrakClient({
|
|
|
137
137
|
if (!isConnected) {
|
|
138
138
|
throw new Error("The iframe provider isn't connected yet");
|
|
139
139
|
}
|
|
140
|
-
const resultCompressionKeyProvider =
|
|
140
|
+
const resultCompressionKeyProvider = _chunkN4N55SQ6cjs.getIFrameResponseKeyProvider.call(void 0, args);
|
|
141
141
|
const channelId = channelManager.createChannel(async (message) => {
|
|
142
|
-
const decompressed = await
|
|
142
|
+
const decompressed = await _chunkN4N55SQ6cjs.decompressDataAndCheckHash.call(void 0,
|
|
143
143
|
message.data,
|
|
144
144
|
resultCompressionKeyProvider
|
|
145
145
|
);
|
|
146
146
|
callback(decompressed);
|
|
147
147
|
});
|
|
148
|
-
const compressedMessage = await
|
|
148
|
+
const compressedMessage = await _chunkN4N55SQ6cjs.hashAndCompressData.call(void 0,
|
|
149
149
|
args,
|
|
150
|
-
|
|
150
|
+
_chunkN4N55SQ6cjs.iFrameRequestKeyProvider
|
|
151
151
|
);
|
|
152
152
|
messageHandler.sendEvent({
|
|
153
153
|
id: channelId,
|
|
@@ -176,4 +176,4 @@ function createIFrameFrakClient({
|
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
exports.
|
|
179
|
+
exports.createIFrameNexusClient = createIFrameNexusClient; exports.createIframe = _chunkN4N55SQ6cjs.createIframe; exports.decompressDataAndCheckHash = _chunkN4N55SQ6cjs.decompressDataAndCheckHash; exports.getIFrameResponseKeyProvider = _chunkN4N55SQ6cjs.getIFrameResponseKeyProvider; exports.getRedirectResponseResponseKeyProvider = _chunkN4N55SQ6cjs.getRedirectResponseResponseKeyProvider; exports.hashAndCompressData = _chunkN4N55SQ6cjs.hashAndCompressData; exports.iFrameRequestKeyProvider = _chunkN4N55SQ6cjs.iFrameRequestKeyProvider; exports.redirectRequestKeyProvider = _chunkN4N55SQ6cjs.redirectRequestKeyProvider;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-
|
|
1
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-CkvisXxD.cjs';
|
|
2
|
+
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-CkvisXxD.cjs';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new iframe Frak client
|
|
8
8
|
*/
|
|
9
|
-
declare function
|
|
10
|
-
config:
|
|
9
|
+
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
10
|
+
config: NexusWalletSdkConfig;
|
|
11
11
|
iframe: HTMLIFrameElement;
|
|
12
|
-
}):
|
|
12
|
+
}): NexusClient;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Create the given iframe
|
|
@@ -80,4 +80,4 @@ type RedirectRpcResponseKeyProvider<TMethod extends ExtractedParametersFromRpc<R
|
|
|
80
80
|
*/
|
|
81
81
|
declare function getRedirectResponseResponseKeyProvider<TMethod extends ExtractedParametersFromRpc<RedirectRpcSchema>["method"]>(method: TMethod): RedirectRpcResponseKeyProvider<TMethod>;
|
|
82
82
|
|
|
83
|
-
export { type CompressedData, ExtractedParametersFromRpc, ExtractedReturnTypeFromRpc,
|
|
83
|
+
export { type CompressedData, ExtractedParametersFromRpc, ExtractedReturnTypeFromRpc, type HashProtectedData, IFrameRpcSchema, type KeyProvider, NexusClient, NexusWalletSdkConfig, RedirectRpcSchema, createIFrameNexusClient, createIframe, decompressDataAndCheckHash, getIFrameResponseKeyProvider, getRedirectResponseResponseKeyProvider, hashAndCompressData, iFrameRequestKeyProvider, redirectRequestKeyProvider };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-
|
|
1
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-CkvisXxD.js';
|
|
2
|
+
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-CkvisXxD.js';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new iframe Frak client
|
|
8
8
|
*/
|
|
9
|
-
declare function
|
|
10
|
-
config:
|
|
9
|
+
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
10
|
+
config: NexusWalletSdkConfig;
|
|
11
11
|
iframe: HTMLIFrameElement;
|
|
12
|
-
}):
|
|
12
|
+
}): NexusClient;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Create the given iframe
|
|
@@ -80,4 +80,4 @@ type RedirectRpcResponseKeyProvider<TMethod extends ExtractedParametersFromRpc<R
|
|
|
80
80
|
*/
|
|
81
81
|
declare function getRedirectResponseResponseKeyProvider<TMethod extends ExtractedParametersFromRpc<RedirectRpcSchema>["method"]>(method: TMethod): RedirectRpcResponseKeyProvider<TMethod>;
|
|
82
82
|
|
|
83
|
-
export { type CompressedData, ExtractedParametersFromRpc, ExtractedReturnTypeFromRpc,
|
|
83
|
+
export { type CompressedData, ExtractedParametersFromRpc, ExtractedReturnTypeFromRpc, type HashProtectedData, IFrameRpcSchema, type KeyProvider, NexusClient, NexusWalletSdkConfig, RedirectRpcSchema, createIFrameNexusClient, createIframe, decompressDataAndCheckHash, getIFrameResponseKeyProvider, getRedirectResponseResponseKeyProvider, hashAndCompressData, iFrameRequestKeyProvider, redirectRequestKeyProvider };
|
package/dist/core/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
hashAndCompressData,
|
|
8
8
|
iFrameRequestKeyProvider,
|
|
9
9
|
redirectRequestKeyProvider
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-6ZFDRVV6.js";
|
|
11
11
|
|
|
12
12
|
// src/core/utils/Deferred.ts
|
|
13
13
|
var Deferred = class {
|
|
@@ -49,7 +49,7 @@ function createIFrameChannelManager() {
|
|
|
49
49
|
|
|
50
50
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
51
51
|
function createIFrameMessageHandler({
|
|
52
|
-
|
|
52
|
+
nexusWalletUrl,
|
|
53
53
|
iframe,
|
|
54
54
|
channelManager
|
|
55
55
|
}) {
|
|
@@ -65,7 +65,7 @@ function createIFrameMessageHandler({
|
|
|
65
65
|
if (!event.origin) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
if (new URL(event.origin).origin.toLowerCase() !== new URL(
|
|
68
|
+
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
if ("lifecycle" in event.data) {
|
|
@@ -82,7 +82,7 @@ function createIFrameMessageHandler({
|
|
|
82
82
|
window.addEventListener("message", msgHandler);
|
|
83
83
|
const sendEvent = (message) => {
|
|
84
84
|
contentWindow.postMessage(message, {
|
|
85
|
-
targetOrigin:
|
|
85
|
+
targetOrigin: nexusWalletUrl
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
const cleanup = () => {
|
|
@@ -95,14 +95,14 @@ function createIFrameMessageHandler({
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// src/core/clients/
|
|
99
|
-
function
|
|
98
|
+
// src/core/clients/createIFrameNexusClient.ts
|
|
99
|
+
function createIFrameNexusClient({
|
|
100
100
|
config,
|
|
101
101
|
iframe
|
|
102
102
|
}) {
|
|
103
103
|
const channelManager = createIFrameChannelManager();
|
|
104
104
|
const messageHandler = createIFrameMessageHandler({
|
|
105
|
-
|
|
105
|
+
nexusWalletUrl: config.walletUrl,
|
|
106
106
|
iframe,
|
|
107
107
|
channelManager
|
|
108
108
|
});
|
|
@@ -168,7 +168,7 @@ function createIFrameFrakClient({
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
export {
|
|
171
|
-
|
|
171
|
+
createIFrameNexusClient,
|
|
172
172
|
createIframe,
|
|
173
173
|
decompressDataAndCheckHash,
|
|
174
174
|
getIFrameResponseKeyProvider,
|
package/package.json
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frak-labs/nexus-sdk",
|
|
3
3
|
"author": "Frak Labs",
|
|
4
|
-
"
|
|
4
|
+
"maintainers": [
|
|
5
|
+
{
|
|
6
|
+
"name": "srod",
|
|
7
|
+
"url": "https://twitter.com/srod"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "Quentin Nivelais",
|
|
11
|
+
"url": "https://twitter.com/QNivelais"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"version": "0.0.3-alpha",
|
|
5
15
|
"description": "Nexus Wallet client SDK, helping any person to interact with the Frak wallet, and require the unlock of a premium article within the Frak ecosystem.",
|
|
6
16
|
"repository": "https://github.com/frak-id/wallet",
|
|
7
17
|
"homepage": "https://docs.frak.id/wallet-sdk",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"frak-labs",
|
|
20
|
+
"nexus-wallet",
|
|
21
|
+
"erc-4337",
|
|
22
|
+
"eip-4337",
|
|
23
|
+
"smart-wallet"
|
|
24
|
+
],
|
|
8
25
|
"license": "GNU GPL 3.0",
|
|
9
26
|
"sideEffects": false,
|
|
10
27
|
"private": false,
|