Loading...
Loading...
Compare original and translation side by side
privacypublicunlistedprivatehttpPrivacypublicrestrictedupdate_valprivacyset_http_privacyrestrictedhttpPrivacyget_val_detaillist_valscreate_valremix_valprivacypublicunlistedprivatehttpPrivacypublicrestrictedupdate_valprivacyset_http_privacyrestrictedget_val_detaillist_valscreate_valremix_valhttpPrivacystd/oauthoauthstd/oauthoauthMiddlewarestd/oauthoauthstd/oauthoauthMiddlewareadd_allowed_userlist_allowed_usersremove_allowed_userlist_allowed_usersadd_allowed_userlist_allowed_usersremove_allowed_userlist_allowed_users302fetch_val_endpointcurl302val.town403httpPrivacyrestrictedset_http_privacy302fetch_val_endpointcurlval.town302403httpPrivacyrestrictedset_http_privacycreate_bypass_tokenlist_bypass_tokensrevoke_bypass_token// Header (preferred — keeps the secret out of logs and referrers)
await fetch(url, { headers: { "X-Val-Town-Access": Deno.env.get("MY_BYPASS_TOKEN")! } });
// Query param (for services that only accept a URL, e.g. some webhook configs)
await fetch(`${url}?val_town_access=${Deno.env.get("MY_BYPASS_TOKEN")}`);create_bypass_tokenlist_bypass_tokensrevoke_bypass_token// Header (preferred — keeps the secret out of logs and referrers)
await fetch(url, { headers: { "X-Val-Town-Access": Deno.env.get("MY_BYPASS_TOKEN")! } });
// Query param (for services that only accept a URL, e.g. some webhook configs)
await fetch(`${url}?val_town_access=${Deno.env.get("MY_BYPASS_TOKEN")}`);X-Val-Town-Uservaltownconst IDENTITY_HEADER = "X-Val-Town-User";
/** Returns the viewer's public profile, or null when there isn't one. */
async function getViewer(req: Request) {
const signed = req.headers.get(IDENTITY_HEADER);
if (!signed) return null;
const res = await fetch("https://api.val.town/v3/val/viewer", {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
[IDENTITY_HEADER]: signed,
},
});
if (!res.ok) return null;
// { id, username, type, bio, profileImageUrl, url, links }
return await res.json();
}!X-Val-Town-User/v3/val/viewerX-Val-Town-Uservaltownconst IDENTITY_HEADER = "X-Val-Town-User";
/** Returns the viewer's public profile, or null when there isn't one. */
async function getViewer(req: Request) {
const signed = req.headers.get(IDENTITY_HEADER);
if (!signed) return null;
const res = await fetch("https://api.val.town/v3/val/viewer", {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
[IDENTITY_HEADER]: signed,
},
});
if (!res.ok) return null;
// { id, username, type, bio, profileImageUrl, url, links }
return await res.json();
}!X-Val-Town-User/v3/val/viewer| Task | Tool |
|---|---|
| Check the current setting | |
| Make an endpoint public or restricted | |
| See who has access | |
| Grant / revoke an org | |
| Create / list / revoke automation secrets | |
| 任务 | 工具 |
|---|---|
| 查看当前设置 | |
| 将端点设为公开或受限 | |
| 查看拥有访问权的对象 | |
| 授予/撤销组织访问权 | |
| 创建/查看/撤销自动化密钥 | |