diff --git a/api/oauth2.d.js b/api/oauth2.d.js index 6bb7a3a..37dfa28 100644 --- a/api/oauth2.d.js +++ b/api/oauth2.d.js @@ -28,3 +28,5 @@ oauth2.AccessToken; * }} */ oauth2.AccessTokenRequest; + +export default oauth2; diff --git a/birimler/cloudflare/targets.js b/birimler/cloudflare/targets.js index 9fa4ec7..93d54db 100644 --- a/birimler/cloudflare/targets.js +++ b/birimler/cloudflare/targets.js @@ -2,7 +2,7 @@ /** * @typedef {{ * accountId: string, - * authToken: string + * token: string * }} */ const Auth = {}; @@ -12,7 +12,57 @@ const Auth = {}; * @param {string} name * @param {string} url * @param {string} code + * @param {!Array<{ + * name: string, + * namespace_id: string + * }>=} kvBindings */ -const uploadWoker = (auth, name, url, code) => { +const uploadWorker = (auth, name, code, kvBindings) => { + /** @const {string} */ + const yesterday = new Date(Date.now() - 86400000) + .toISOString().split('T')[0]; + /** @dict */ + const metadata = { + "main_module": "a.js", + "compatibility_date": yesterday + }; + if (kvBindings && kvBindings.length) { + for (const kv of kvBindings) + kv["type"] = "kv_namespace"; + metadata["bindings"] = kvBindings; + } + /** @const {!FormData} */ + const form = new FormData(); + form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" })); + form.append("a.js", new File([code], "a.js", { type: "application/javascript+module;charset=utf-8" })); + return fetch(`https://api.cloudflare.com/client/v4/accounts/${auth.accountId}/workers/scripts/${name}`, { + method: "PUT", + headers: { "authorization": `Bearer ${auth.token}` }, + body: form + }).then((res) => res.json()); +}; -} \ No newline at end of file +/** + * @param {Auth} auth + * @param {string} name + * @param {string} url + */ +const bindWorker = (auth, name, url) => fetch( + `https://api.cloudflare.com/client/v4/accounts/${auth.accountId}/workers/domains`, { + method: "PUT", + headers: { + "authorization": `Bearer ${auth.token}`, + "content-type": "application/json" + }, + body: JSON.stringify({ + "environment": "production", + "hostname": url, + "service": name + }) +}).then((res) => res.json()); + +export { + Auth, + bindWorker, + uploadWorker +}; diff --git a/birimler/js/build.js b/birimler/js/build.js deleted file mode 100644 index 8043dd8..0000000 --- a/birimler/js/build.js +++ /dev/null @@ -1,4 +0,0 @@ - -const sayfaJs = () => { - -} \ No newline at end of file diff --git a/birimler/js/util.js b/birimler/js/util.js index 9db86c0..490bf59 100644 --- a/birimler/js/util.js +++ b/birimler/js/util.js @@ -4,7 +4,7 @@ import toml from "toml"; /** * @param {string} definesFile * @param {string} module - * @return {!Array} + * @return {!Promise>} */ const readDefines = (definesFile, module) => readFile(definesFile) .then( diff --git a/birimler/js/worker.js b/birimler/js/worker.js deleted file mode 100644 index 3170cff..0000000 --- a/birimler/js/worker.js +++ /dev/null @@ -1,13 +0,0 @@ -import { compile } from "../../kdjs/compile"; - -/** - * @param {string} worker - * @return {!Promise} - */ -const build = (worker) => compile({ - "entry": worker, - "nologs": true, - "output": "build/" + worker -}) - -const deployToCloudflare = () => { } diff --git a/crosschain/chains.js b/crosschain/chains.js index febe2cc..a1658f6 100644 --- a/crosschain/chains.js +++ b/crosschain/chains.js @@ -28,8 +28,15 @@ const ChainGroup = { */ const ChainGroups = [ChainGroup.EVM, ChainGroup.MINA]; +/** + * @param {ChainId} id + * @return {ChainGroup} + */ +const chainIdToGroup = (id) => /** @type {ChainGroup} */(id.slice(2)); + export { ChainGroup, ChainGroups, - ChainId + ChainId, + chainIdToGroup }; diff --git a/crypto/modular.js b/crypto/modular.js index 5aa8be9..b26870f 100644 --- a/crypto/modular.js +++ b/crypto/modular.js @@ -137,7 +137,7 @@ const expTimesExp = (a, x, b, y, M) => { */ const tonelliShanks = (n, P, Q, c, M) => { if (n == 0n) return 0n; - /**@type {bigint} */ + /** @type {bigint} */ let t = exp(n, (Q - 1n) >> 1n, P); /** @type {bigint} */ let R = t * n % P; diff --git a/kdjs/compile.js b/kdjs/compile.js index 769fcbb..5a1f7d5 100644 --- a/kdjs/compile.js +++ b/kdjs/compile.js @@ -17,7 +17,7 @@ const Params = {}; const compile = async (params, checkFreshFn) => { /** @const {string} */ const isolateDir = combine( - getDir(/** @type {string} */(params["output"] || /** @type {string} */(params["entry"]))), + getDir(/** @type {string} */(params["output"] || "build/" + /** @type {string} */(params["entry"]))), /** @type {string} */(params["isolateDir"]) || ".kdjs_isolate"); const { /** @const {!Map} */ missingImports, diff --git a/node/ipfs.d.js b/node/ipfs.d.js index 7df6996..440b195 100644 --- a/node/ipfs.d.js +++ b/node/ipfs.d.js @@ -9,10 +9,8 @@ import node from "./node.d"; node.ipfs = {}; /** - * @constructor - * @struct + * @typedef {{ + * Hash: string + * }} */ -node.ipfs.AddResult = function () { } - -/** @type {string} */ -node.ipfs.AddResult.prototype.Hash; +node.ipfs.AddResult; diff --git a/node/ipfs.js b/node/ipfs.js index 594c689..faf1f73 100644 --- a/node/ipfs.js +++ b/node/ipfs.js @@ -101,7 +101,7 @@ const yaz = (nodeUrl, veri, veriŞekli) => { body: formData }) .then((res) => res.json()) - .then((/** @type {!node.ipfs.AddResult} */ res) => res.Hash) + .then((/** @type {node.ipfs.AddResult} */ res) => res.Hash) return Promise.all([hash(encoded), gelenSöz]) .then(([/** !Uint8Array */ yerel, /** string */ gelen]) => CID(yerel) == gelen diff --git a/package.json b/package.json index d9208ee..f7e825b 100644 --- a/package.json +++ b/package.json @@ -11,16 +11,16 @@ }, "devDependencies": { "@ethereumjs/evm": "^3.1.0", - "@noble/secp256k1": "^2.0.0", + "@noble/secp256k1": "^2.1.0", "ethers": "^6.13.2", "mina-signer": "^3.0.7" }, "dependencies": { "acorn": "^8.12.1", "acorn-walk": "^8.3.3", - "astring": "^1.8.6", + "astring": "^1.9.0", "google-closure-compiler": "^20240317.0.0", "htmlparser2": "^9.1.0", - "uglify-js": "^3.19.1" + "uglify-js": "^3.19.2" } }