create-fuzionx 0.1.33 → 0.1.34
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/package.json
CHANGED
package/templates/spa/meta.json
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FuzionX SSR Client — WASM ASP HTTP + WebSocket 통합 클라이언트
|
|
3
|
+
*
|
|
4
|
+
* create-fuzionx tester 레이아웃 패턴 기반.
|
|
5
|
+
* WASM 로드 → FuzionXClient, FuzionXSocket, aspFetch 글로벌 노출.
|
|
6
|
+
*
|
|
7
|
+
* 사용법 (인증 유저):
|
|
8
|
+
* FxClient.init(clientSecret, encSecret, headerSignal)
|
|
9
|
+
*
|
|
10
|
+
* 사용법 (공개 페이지):
|
|
11
|
+
* FxClient.initPublic(masterSecret, headerSignal)
|
|
12
|
+
*/
|
|
13
|
+
(function () {
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 인증 유저용 — 암호화된 masterSecret 복호화 후 ASP 클라이언트 생성
|
|
18
|
+
*/
|
|
19
|
+
function init(clientSecret, encSecret, headerSignal) {
|
|
20
|
+
if (!clientSecret || !encSecret) return;
|
|
21
|
+
|
|
22
|
+
window.aspEnabled = true;
|
|
23
|
+
window._aspReady = (async () => {
|
|
24
|
+
try {
|
|
25
|
+
const _v = Date.now();
|
|
26
|
+
const mod = await import(`/wasm/fuzionx_client_wasm.js?v=${_v}`);
|
|
27
|
+
await mod.default({ module_or_path: `/wasm/fuzionx_client_wasm_bg.wasm?v=${_v}` });
|
|
28
|
+
const { FuzionXClient, FuzionXSocket } = mod;
|
|
29
|
+
window.FuzionXSocket = FuzionXSocket;
|
|
30
|
+
|
|
31
|
+
// 임시 클라이언트로 masterSecret 복호화
|
|
32
|
+
const tmp = new FuzionXClient('_init_');
|
|
33
|
+
const masterSecret = tmp.decrypt_custom(clientSecret, encSecret);
|
|
34
|
+
window._aspMasterSecret = masterSecret;
|
|
35
|
+
|
|
36
|
+
// ASP 활성 클라이언트 생성
|
|
37
|
+
window._aspClient = FuzionXClient.new_with_options(
|
|
38
|
+
masterSecret,
|
|
39
|
+
headerSignal || 'Ruxy-Enc-Mode',
|
|
40
|
+
);
|
|
41
|
+
console.log('[FxClient] WASM ASP client ready');
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.warn('[FxClient] WASM init failed:', e);
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 공개 페이지용 — masterSecret 직접 사용
|
|
50
|
+
*/
|
|
51
|
+
function initPublic(masterSecret, headerSignal) {
|
|
52
|
+
window.aspEnabled = !!masterSecret;
|
|
53
|
+
if (masterSecret) window._aspMasterSecret = masterSecret;
|
|
54
|
+
|
|
55
|
+
window._aspReady = (async () => {
|
|
56
|
+
try {
|
|
57
|
+
const _v = Date.now();
|
|
58
|
+
const mod = await import(`/wasm/fuzionx_client_wasm.js?v=${_v}`);
|
|
59
|
+
await mod.default({ module_or_path: `/wasm/fuzionx_client_wasm_bg.wasm?v=${_v}` });
|
|
60
|
+
const { FuzionXClient, FuzionXSocket } = mod;
|
|
61
|
+
window.FuzionXSocket = FuzionXSocket;
|
|
62
|
+
|
|
63
|
+
if (masterSecret) {
|
|
64
|
+
window._aspClient = FuzionXClient.new_with_options(
|
|
65
|
+
masterSecret,
|
|
66
|
+
headerSignal || 'Ruxy-Enc-Mode',
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
console.log('[FxClient] WASM client ready (public)');
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.warn('[FxClient] WASM init failed:', e);
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* ASP 암호화 fetch — create-fuzionx tester aspFetch 동일 패턴
|
|
78
|
+
*/
|
|
79
|
+
window.aspFetch = async function (url, opts = {}) {
|
|
80
|
+
if (window._aspReady) await window._aspReady;
|
|
81
|
+
const method = (opts.method || 'GET').toUpperCase();
|
|
82
|
+
if (!url.startsWith('/api') || !window._aspClient) return fetch(url, opts);
|
|
83
|
+
|
|
84
|
+
if (opts.body instanceof FormData) {
|
|
85
|
+
return window._aspClient.upload(url, opts.body);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let bodyObj = undefined;
|
|
89
|
+
if (opts.body) {
|
|
90
|
+
bodyObj = typeof opts.body === 'string' ? JSON.parse(opts.body) : opts.body;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
switch (method) {
|
|
94
|
+
case 'GET': return window._aspClient.get(url);
|
|
95
|
+
case 'POST': return window._aspClient.post(url, bodyObj);
|
|
96
|
+
case 'PUT': return window._aspClient.put(url, bodyObj);
|
|
97
|
+
case 'PATCH': return window._aspClient.patch(url, bodyObj);
|
|
98
|
+
case 'DELETE': return window._aspClient.delete(url);
|
|
99
|
+
default: return window._aspClient.get(url);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 글로벌 노출
|
|
104
|
+
window.FxClient = { init, initPublic };
|
|
105
|
+
window.aspEnabled = false;
|
|
106
|
+
window._aspReady = Promise.resolve();
|
|
107
|
+
})();
|