@www.hyperlinks.space/program-kit 81.81.81 → 123.123.123
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/.eas/workflows/create-development-builds.yml +21 -0
- package/.eas/workflows/create-draft.yml +15 -0
- package/.eas/workflows/deploy-to-production.yml +68 -0
- package/.gitattributes +48 -0
- package/.gitignore +52 -0
- package/.nvmrc +1 -0
- package/.vercelignore +6 -0
- package/README.md +17 -2
- package/ai/openai.ts +202 -0
- package/ai/transmitter.ts +367 -0
- package/backlogs/medium_term_backlog.md +26 -0
- package/backlogs/short_term_backlog.md +42 -0
- package/eslint.config.cjs +10 -0
- package/fullREADME.md +76 -50
- package/npmReadMe.md +17 -2
- package/npmrc.example +1 -0
- package/package.json +3 -28
- package/polyfills/buffer.ts +9 -0
- package/research & docs/github-gitlab-bidirectional-mirroring.md +154 -0
- package/services/wallet/tonWallet.ts +73 -0
- package/ui/components/GlobalBottomBar.tsx +447 -0
- package/ui/components/GlobalBottomBarWeb.tsx +362 -0
- package/ui/components/GlobalLogoBar.tsx +108 -0
- package/ui/components/GlobalLogoBarFallback.tsx +66 -0
- package/ui/components/GlobalLogoBarWithFallback.tsx +24 -0
- package/ui/components/HyperlinksSpaceLogo.tsx +29 -0
- package/ui/components/Telegram.tsx +677 -0
- package/ui/components/telegramWebApp.ts +359 -0
- package/ui/fonts.ts +12 -0
- package/ui/theme.ts +117 -0
- /package/{docs → research & docs}/ai_and_search_bar_input.md +0 -0
- /package/{docs → research & docs}/ai_bot_messages.md +0 -0
- /package/{docs → research & docs}/auth-and-centralized-encrypted-keys-plan.md +0 -0
- /package/{docs → research & docs}/blue_bar_tackling.md +0 -0
- /package/{docs → research & docs}/bot_async_streaming.md +0 -0
- /package/{docs → research & docs}/build_and_install.md +0 -0
- /package/{docs → research & docs}/database_messages.md +0 -0
- /package/{docs → research & docs}/fonts.md +0 -0
- /package/{docs → research & docs}/keys-retrieval-console-scripts.js +0 -0
- /package/{docs → research & docs}/npm-release.md +0 -0
- /package/{docs → research & docs}/releases.md +0 -0
- /package/{docs → research & docs}/releases_github_actions.md +0 -0
- /package/{docs → research & docs}/scalability.md +0 -0
- /package/{docs → research & docs}/security_plan_raw.md +0 -0
- /package/{docs → research & docs}/security_raw.md +0 -0
- /package/{docs → research & docs}/storage-availability-console-script.js +0 -0
- /package/{docs → research & docs}/storage-lifetime.md +0 -0
- /package/{docs → research & docs}/telegram-raw-keys-cloud-storage-risks.md +0 -0
- /package/{docs → research & docs}/timing_raw.md +0 -0
- /package/{docs → research & docs}/tma_logo_bar_jump_investigation.md +0 -0
- /package/{docs → research & docs}/update.md +0 -0
- /package/{docs → research & docs}/wallet_telegram_standalone_multichain_proposal.md +0 -0
- /package/{docs → research & docs}/wallets_hosting_architecture.md +0 -0
package/package.json
CHANGED
|
@@ -2,46 +2,21 @@
|
|
|
2
2
|
"name": "@www.hyperlinks.space/program-kit",
|
|
3
3
|
"productName": "Hyperlinks Space Program",
|
|
4
4
|
"description": "Hyperlinks Space Program",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "https://www.hyperlinks.space",
|
|
6
6
|
"license": "0BSD",
|
|
7
7
|
"private": false,
|
|
8
8
|
"bin": {
|
|
9
9
|
"program-kit": "scripts/program-kit-init.cjs"
|
|
10
10
|
},
|
|
11
|
-
"files": [
|
|
12
|
-
".env.example",
|
|
13
|
-
"README.md",
|
|
14
|
-
"fullREADME.md",
|
|
15
|
-
"npmReadMe.md",
|
|
16
|
-
"app",
|
|
17
|
-
"api",
|
|
18
|
-
"app.json",
|
|
19
|
-
"assets",
|
|
20
|
-
"blockchain",
|
|
21
|
-
"bot",
|
|
22
|
-
"database",
|
|
23
|
-
"docs",
|
|
24
|
-
"!docs/debug.log",
|
|
25
|
-
"!docs/issue.md",
|
|
26
|
-
"eas.json",
|
|
27
|
-
"eslint.config.js",
|
|
28
|
-
"global.css",
|
|
29
|
-
"package-lock.json",
|
|
30
|
-
"scripts",
|
|
31
|
-
"telegram",
|
|
32
|
-
"tsconfig.json",
|
|
33
|
-
"vercel.json",
|
|
34
|
-
"windows"
|
|
35
|
-
],
|
|
36
11
|
"publishConfig": {
|
|
37
12
|
"access": "public"
|
|
38
13
|
},
|
|
39
14
|
"repository": {
|
|
40
15
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/HyperlinksSpace/
|
|
16
|
+
"url": "https://github.com/HyperlinksSpace/HyperlinksSpaceProgram.git"
|
|
42
17
|
},
|
|
43
18
|
"main": "index.js",
|
|
44
|
-
"version": "
|
|
19
|
+
"version": "123.123.123",
|
|
45
20
|
"type": "module",
|
|
46
21
|
"engines": {
|
|
47
22
|
"node": ">=18 <=22"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load before any module that touches Node's `Buffer` at evaluation time (e.g. @ton/*).
|
|
3
|
+
* Browsers and Telegram WebView do not define `globalThis.Buffer`.
|
|
4
|
+
*/
|
|
5
|
+
import { Buffer } from "buffer";
|
|
6
|
+
|
|
7
|
+
if (typeof globalThis !== "undefined" && !(globalThis as { Buffer?: unknown }).Buffer) {
|
|
8
|
+
(globalThis as { Buffer: typeof Buffer }).Buffer = Buffer;
|
|
9
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# GitHub and GitLab Repository Mirroring
|
|
2
|
+
|
|
3
|
+
This document describes how to keep a Git repository synchronized between GitHub and GitLab, including **bidirectional** setups, the problems that appear in practice, **automation guards** that reduce loops and wasted work, and **automatic escalation** when the automation must not guess (for example, divergent histories).
|
|
4
|
+
|
|
5
|
+
It is guidance for operators and automation authors; it is not specific to application code in this repository.
|
|
6
|
+
|
|
7
|
+
## Terminology
|
|
8
|
+
|
|
9
|
+
- **Canonical remote:** The single place where humans are expected to push day-to-day changes (or where merge commits land after review). Everything else is a **mirror**.
|
|
10
|
+
- **One-way mirror:** After a push to A, automation updates B. Humans do not push to B for the same branches (or B is protected so only the mirror bot can push).
|
|
11
|
+
- **Bidirectional mirror:** Automation tries to propagate pushes from A→B and B→A. This is workable only with strict guards and a clear policy when histories **diverge**.
|
|
12
|
+
- **Escalate:** Stop silent auto-fix; surface the condition to people or ticketing (failed job, alert, issue). See [Automatic escalation](#automatic-escalation).
|
|
13
|
+
|
|
14
|
+
## Recommended default: one canonical remote + one-way mirror
|
|
15
|
+
|
|
16
|
+
For most teams, the lowest-risk approach is:
|
|
17
|
+
|
|
18
|
+
1. Choose **one** platform as the source of truth for each protected branch (usually `main`).
|
|
19
|
+
2. Mirror to the other platform with **fast-forward-only** pushes and **short-circuit** when tips already match.
|
|
20
|
+
|
|
21
|
+
Typical implementations (pick **one** row: canonical host is where humans push; the arrow is where commits are **copied** next):
|
|
22
|
+
|
|
23
|
+
| Canonical | Replication direction | How |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **GitHub** | GitHub → GitLab | GitHub Actions on `push`: fetch GitLab, compare SHAs, `git push` to GitLab using a [GitLab deploy key](https://docs.gitlab.com/ee/user/project/deploy_keys/) or [project access token](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html). |
|
|
26
|
+
| **GitLab** | GitHub ← GitLab | [GitLab repository push mirroring](https://docs.gitlab.com/ee/user/project/repository/mirror/) so GitLab pushes to GitHub after receiving commits. |
|
|
27
|
+
|
|
28
|
+
The two directions are **not** used together for the same branch in this pattern: they are **alternatives** depending on which platform is source of truth. (Using both at once without guards is how bidirectional mirroring starts.)
|
|
29
|
+
|
|
30
|
+
Official overview: [GitLab repository mirroring](https://docs.gitlab.com/ee/user/project/repository/mirror/), [GitHub Actions push trigger](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push).
|
|
31
|
+
|
|
32
|
+
This gives **near-instant** propagation from the moment the canonical host accepts the push, without fighting bidirectional edge cases.
|
|
33
|
+
|
|
34
|
+
## Bidirectional mirroring: when it is used and what breaks
|
|
35
|
+
|
|
36
|
+
Bidirectional setups appear when both platforms must accept pushes (different teams, migration, or CI only on one side). They are **not** “set and forget.”
|
|
37
|
+
|
|
38
|
+
| Risk | What goes wrong | Why it matters |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| **Loop / ping-pong** | A push to GitHub triggers sync to GitLab; GitLab triggers sync back to GitHub; repeat or duplicate work | Duplicate CI, wasted API calls, flaky pipelines |
|
|
41
|
+
| **New objects from automation** | Mirror job merges, rebases, or force-pushes to “fix” state | New commits or rewritten history; harder audits; can feed loops |
|
|
42
|
+
| **Divergence** | Two different commits on `main` at each host, neither is ancestor of the other | `git push` rejects (non-fast-forward) unless someone force-pushes |
|
|
43
|
+
| **Duplicate CI** | Same tree built twice because both hosts run pipelines on the same logical change | Cost and noise; confusing status checks |
|
|
44
|
+
| **Credential exposure** | Tokens in logs, overly broad PATs, shared user accounts | Security and compliance issues |
|
|
45
|
+
|
|
46
|
+
## Guards in automation (layered)
|
|
47
|
+
|
|
48
|
+
Use several of these together; one guard rarely covers every failure mode.
|
|
49
|
+
|
|
50
|
+
### 1. Event and scheduling guards
|
|
51
|
+
|
|
52
|
+
- **SHA equality short-circuit:** After fetching both remotes, if `github/main` and `gitlab/main` are the **same commit OID**, exit successfully without pushing.
|
|
53
|
+
- **Ancestor / fast-forward check before push:** Only push from A to B if B’s tip is an **ancestor** of A’s tip (pure fast-forward). If not, do not force-push; treat as divergence and [escalate](#automatic-escalation).
|
|
54
|
+
- **Mirror bot identity:** Perform mirror pushes with a **dedicated** bot user or deploy key. On the receiving side, webhook or pipeline logic can **skip enqueuing reverse sync** when the actor matches the mirror bot (where the platform exposes this).
|
|
55
|
+
- **Idempotency:** Persist “last mirrored OID per branch” (CI cache, KV, issue comment, etc.) and skip if the incoming event’s `after` SHA was already mirrored.
|
|
56
|
+
- **Debounce / concurrency:** One in-flight sync per branch (GitHub Actions `concurrency`, GitLab `resource_group`, or a lock) to avoid stacked identical jobs from webhook retries.
|
|
57
|
+
|
|
58
|
+
### 2. Git protocol guards
|
|
59
|
+
|
|
60
|
+
- **No `--force` on mirrored branches** unless you have an explicit, rare break-glass procedure. Non-fast-forward should **fail** and escalate.
|
|
61
|
+
- **Narrow refspecs:** Mirror only agreed branches (for example `refs/heads/main`, `refs/heads/release/*`), not all refs.
|
|
62
|
+
- **Atomic multi-ref push** when supported (`git push --atomic`) to avoid half-updated mirror state.
|
|
63
|
+
|
|
64
|
+
### 3. Loop-specific logic
|
|
65
|
+
|
|
66
|
+
- **Directional rule:** GitHub→GitLab runs only when GitHub is strictly ahead of GitLab (fast-forward). GitLab→GitHub runs only when GitLab is strictly ahead. If **both** are ahead of the common ancestor (diverged), **neither** direction should force-sync; escalate.
|
|
67
|
+
- **Cooldown:** If the same `(branch, OID)` was mirrored within N seconds, exit (reduces double webhook storms).
|
|
68
|
+
|
|
69
|
+
### 4. CI noise controls
|
|
70
|
+
|
|
71
|
+
Mirroring duplicates pipelines if both hosts run on every push.
|
|
72
|
+
|
|
73
|
+
- Prefer **one** platform for **required** checks; treat the other as informational or limit runs (for example scheduled smoke only).
|
|
74
|
+
- Where policy allows, use host-specific **skip directives** for mirror-only pushes (conventions vary; confirm org rules).
|
|
75
|
+
- **Path filters** help only when mirror commits change nothing meaningful; usually both sides see the same files.
|
|
76
|
+
|
|
77
|
+
### 5. Security guards
|
|
78
|
+
|
|
79
|
+
- **Least privilege:** Repo-scoped tokens or deploy keys; no org-wide admin tokens for mirroring.
|
|
80
|
+
- **Branch protection** on both sides: block force-push to mirrored branches; restrict who may push to protected branches.
|
|
81
|
+
- **Secrets hygiene:** Mask remotes in logs; disable interactive prompts (`GIT_TERMINAL_PROMPT=0`); store credentials only in CI secrets.
|
|
82
|
+
|
|
83
|
+
## Automatic escalation
|
|
84
|
+
|
|
85
|
+
**Escalate** means: the automation **detects a condition it must not resolve alone**, marks the run as failed or blocked, and **notifies** or **files a ticket** with enough context for a human to decide.
|
|
86
|
+
|
|
87
|
+
This is the opposite of silently force-pushing or auto-merging without policy.
|
|
88
|
+
|
|
89
|
+
### When to escalate automatically
|
|
90
|
+
|
|
91
|
+
Typical conditions:
|
|
92
|
+
|
|
93
|
+
- **Divergence:** `main` on GitHub and GitLab point to different commits and neither is an ancestor of the other (merge-base exists but both tips have unique commits).
|
|
94
|
+
- **Non-fast-forward push rejected:** Mirror push fails with non-FF; do not retry with force.
|
|
95
|
+
- **Repeated failures:** Same branch fails N times in a row (may indicate permission, quota, or hook problems).
|
|
96
|
+
- **Unexpected ref state:** Missing branch, empty repo, or OID mismatch after push (verify step fails).
|
|
97
|
+
|
|
98
|
+
### What “automatic escalation” can do (concrete patterns)
|
|
99
|
+
|
|
100
|
+
Implement one or more of the following from the same job that detected the problem:
|
|
101
|
+
|
|
102
|
+
1. **Fail the pipeline** with a clear title and non-zero exit code so the default branch protection and dashboards show breakage.
|
|
103
|
+
2. **Post a structured comment** on a pinned tracking issue (GitHub Issues / GitLab issue) including: branch name, both OIDs, link to the failed pipeline, and a one-line `git` hint (`git merge-base`, `git log --left-right`) for the on-call engineer.
|
|
104
|
+
3. **Send chat or email** via webhook (Slack incoming webhook, Microsoft Teams, email SMTP API) with the same summary fields.
|
|
105
|
+
4. **Open a new issue** (if API token allows) with label `mirror-divergence` so work is tracked and deduplicated (search for open issues with the same branch before creating).
|
|
106
|
+
5. **Set a repository flag** (for example GitHub Actions variable or GitLab CI variable via API) `MIRROR_HALTED=true` and have sync jobs check it at the start so you do not amplify divergence while humans fix it.
|
|
107
|
+
|
|
108
|
+
### Content to include in escalation messages
|
|
109
|
+
|
|
110
|
+
- Repository identifiers (both URLs or slugs).
|
|
111
|
+
- Branch (or ref) name.
|
|
112
|
+
- **OID on side A** and **OID on side B** (full hashes avoid ambiguity).
|
|
113
|
+
- **Pipeline run URL** and job name.
|
|
114
|
+
- Short **runbook pointer** (internal doc link) for “how we pick canonical history” and “who may force-push if ever.”
|
|
115
|
+
|
|
116
|
+
### After humans resolve divergence
|
|
117
|
+
|
|
118
|
+
Runbook should require:
|
|
119
|
+
|
|
120
|
+
1. Agreement on which tip (or merged result) is correct.
|
|
121
|
+
2. A single deliberate push to the **canonical** remote (or fast-forward merge on one side then sync).
|
|
122
|
+
3. Clear `MIRROR_HALTED` reset and verification that both tips match before re-enabling bidirectional automation.
|
|
123
|
+
|
|
124
|
+
## Implementation sketches (non-prescriptive)
|
|
125
|
+
|
|
126
|
+
### GitHub Actions (push to GitLab)
|
|
127
|
+
|
|
128
|
+
- Trigger: `on: push` for selected branches.
|
|
129
|
+
- Steps: clone with depth sufficient for ancestry check (or full clone for simplicity), add GitLab remote with token in secret, `fetch` GitLab, compare OIDs / ancestry, `git push` only on fast-forward.
|
|
130
|
+
- On divergence or push failure: exit 1 and call a small script that opens an issue or posts to Slack.
|
|
131
|
+
|
|
132
|
+
### GitLab push mirror to GitHub
|
|
133
|
+
|
|
134
|
+
- Configure in GitLab project settings; use a GitHub **fine-grained PAT** or deploy key with write access to the target repo.
|
|
135
|
+
- Complement with **branch protection** on GitHub and monitoring for mirror errors in GitLab.
|
|
136
|
+
|
|
137
|
+
### Webhook-driven bidirectional
|
|
138
|
+
|
|
139
|
+
- Each side receives push webhooks; each handler runs the same **guarded** sync script (SHA short-circuit, bot skip, fast-forward only, escalate on divergence).
|
|
140
|
+
- **Do not** run two independent scripts that both force-push without shared policy.
|
|
141
|
+
|
|
142
|
+
## Summary
|
|
143
|
+
|
|
144
|
+
- **Best default:** one canonical remote, **one-way** mirror with fast-forward-only pushes and OID short-circuit.
|
|
145
|
+
- **Bidirectional** is possible with **layered guards** (ancestor checks, bot identity, concurrency, no force).
|
|
146
|
+
- **Escalate automatically** on divergence and non-FF: fail visibly, notify, optionally open issues and halt further sync until humans reconcile.
|
|
147
|
+
|
|
148
|
+
## References
|
|
149
|
+
|
|
150
|
+
- [GitLab: Repository mirroring](https://docs.gitlab.com/ee/user/project/repository/mirror/)
|
|
151
|
+
- [GitHub Actions: Workflow triggers](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)
|
|
152
|
+
- [GitLab: Deploy keys](https://docs.gitlab.com/ee/user/project/deploy_keys/)
|
|
153
|
+
- [GitLab: Project access tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html)
|
|
154
|
+
- [GitHub: Fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { mnemonicNew, mnemonicToPrivateKey } from "@ton/crypto";
|
|
2
|
+
import { WalletContractV4 } from "@ton/ton";
|
|
3
|
+
import { Buffer as BufferPolyfill } from "buffer";
|
|
4
|
+
|
|
5
|
+
if (typeof globalThis !== "undefined" && !(globalThis as { Buffer?: unknown }).Buffer) {
|
|
6
|
+
(globalThis as { Buffer?: unknown }).Buffer = BufferPolyfill;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function bytesToBase64(bytes: Uint8Array): string {
|
|
10
|
+
let binary = "";
|
|
11
|
+
for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
|
|
12
|
+
if (typeof btoa === "function") return btoa(binary);
|
|
13
|
+
return BufferPolyfill.from(bytes).toString("base64");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function sha256Bytes(input: string): Promise<Uint8Array> {
|
|
17
|
+
const digest = await crypto.subtle.digest(
|
|
18
|
+
"SHA-256",
|
|
19
|
+
new TextEncoder().encode(input),
|
|
20
|
+
);
|
|
21
|
+
return new Uint8Array(digest);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function generateMnemonic(words = 24): Promise<string[]> {
|
|
25
|
+
return mnemonicNew(words);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function deriveAddressFromMnemonic(opts: {
|
|
29
|
+
mnemonic: string[];
|
|
30
|
+
testnet?: boolean;
|
|
31
|
+
workchain?: number;
|
|
32
|
+
}): Promise<string> {
|
|
33
|
+
const { mnemonic, testnet = false, workchain = 0 } = opts;
|
|
34
|
+
const keyPair = await mnemonicToPrivateKey(mnemonic);
|
|
35
|
+
const wallet = WalletContractV4.create({
|
|
36
|
+
workchain,
|
|
37
|
+
publicKey: keyPair.publicKey,
|
|
38
|
+
});
|
|
39
|
+
return wallet.address.toString({
|
|
40
|
+
bounceable: false,
|
|
41
|
+
urlSafe: true,
|
|
42
|
+
testOnly: testnet,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function deriveMasterKeyFromMnemonic(mnemonic: string[]): Promise<string> {
|
|
47
|
+
const bytes = await sha256Bytes(mnemonic.join(" "));
|
|
48
|
+
return bytesToBase64(bytes);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function createSeedCipher(
|
|
52
|
+
masterKey: string,
|
|
53
|
+
seed: string,
|
|
54
|
+
): Promise<string> {
|
|
55
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
56
|
+
"raw",
|
|
57
|
+
await sha256Bytes(masterKey),
|
|
58
|
+
{ name: "AES-GCM" },
|
|
59
|
+
false,
|
|
60
|
+
["encrypt"],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
64
|
+
const encrypted = await crypto.subtle.encrypt(
|
|
65
|
+
{ name: "AES-GCM", iv },
|
|
66
|
+
keyMaterial,
|
|
67
|
+
new TextEncoder().encode(seed),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const cipherBytes = new Uint8Array(encrypted);
|
|
71
|
+
return `v1.${bytesToBase64(iv)}.${bytesToBase64(cipherBytes)}`;
|
|
72
|
+
}
|
|
73
|
+
|