iOS 计划完成:流式发送 / 后台续传 / APNs / Share Extension / 控制中心控件 + 真机分发预备
- 发送端流式(R-iOS-4):新增 FileSource 抽象(web/src/features/transfer/source.ts),iOS 经 HTTP Range 惰性拉取(原生 WKURLSchemeHandler 认 Range 头 seek 回 206),整文件不进 WebView 内存;web/桌面经 fileSource 包装字节不变。p2p/relay/transfer 改吃 FileSource - 后台续传:iOS 26 BGContinuedProcessingTask(BackgroundTaskManager + AppDelegate 注册 + BGTaskSchedulerPermittedIdentifiers),引擎传输进度驱动系统进度 UI - APNs:后端 internal/apns(ES256 .p8 JWT + HTTP/2,仿 internal/push)+ push_subscriptions.platform 列 + POST /api/push/apns/register + transfer/message 未投递分支分流;原生 PushRegistry 授权 + 设备令牌经引擎桥 registerPush 上报;aps-environment + remote-notification 后台模式 - Share Extension:CDropShare appex 抓文件 → App Group 收件箱 → cdrop://share 深链唤主程序选设备发送(只交接、不跑引擎) - 控制中心剪贴板两控件:CDropWidgets widgetkit appex(ControlWidget + AppIntent + 纯原生 ClipboardClient REST);用专用 broker 设备会话(主程序经引擎 provisionWidgetSession 代铸独立 device_id 会话存 App Group,控件自刷不与引擎抢 refresh 轮换) - 真机分发预备:committed 签名改 ad-hoc 使模拟器 entitlement 生效;真机手动签名 scaffold(Signing.xcconfig 仅 device SDK 套 Manual + gitignore 的 Local.xcconfig 填 Team/profile)+ just ios-device / ios-devices 全 CLI 装机;包名改 net.commilitia.Commilitia-Drop(含 .share/.widgets,BG task 前缀同改);REALDEVICE.md 重写为门户 + CLI 装机手册 - I18n.swift 移 Shared/ 供三 target 共用;i18n 加 ios.bg/share/control.* 键 - ultracode 多 agent 审查修复(0 HIGH,2 MED + 7 LOW):分享 send 后留收件箱致重发→move 私有暂存;WidgetSession 锁屏文件保护→UntilFirstUserAuthentication;outgoing/安全作用域登出释放;控件 device_id 登出清理;并发控件 refresh CAS-before-clear;APNs 读 reason + prune bad token + bust 过期 JWT;APNSEnv 大小写归一;Share-ext completeRequest 挪进 open 回调
This commit is contained in:
@@ -13,6 +13,11 @@ import (
|
||||
"github.com/knadh/koanf/v2"
|
||||
)
|
||||
|
||||
// errAPNsHalfConfig is returned when some but not all APNs fields are set.
|
||||
var errAPNsHalfConfig = errors.New(
|
||||
"CDROP_APNS_KEY_PATH, CDROP_APNS_KEY_ID, CDROP_APNS_TEAM_ID, and CDROP_APNS_TOPIC " +
|
||||
"must all be set together, or none at all (partial config is always an operator error)")
|
||||
|
||||
const envPrefix = "CDROP_"
|
||||
|
||||
type Config struct {
|
||||
@@ -86,6 +91,24 @@ type Config struct {
|
||||
VAPIDPrivateKey string `koanf:"vapid_private_key"`
|
||||
VAPIDSubject string `koanf:"vapid_subject"`
|
||||
|
||||
// APNs (Apple Push Notification service): iOS device push channel.
|
||||
// All four fields must be set together or none (partial config is an error).
|
||||
// APNSKeyPath — filesystem path to the .p8 (PEM PKCS8 ES256) key Apple issues.
|
||||
// APNSKeyID — the 10-character Key ID from the Apple Developer portal.
|
||||
// APNSTeamID — the 10-character Team ID from the Apple Developer portal.
|
||||
// APNSTopic — the app bundle ID (e.g. "net.commilitia.cdrop").
|
||||
// APNSEnv — "prod" (default) or "sandbox" (dev/TestFlight builds).
|
||||
// When unset, APNs is disabled and the register endpoint returns 503.
|
||||
APNSKeyPath string `koanf:"apns_key_path"`
|
||||
APNSKeyID string `koanf:"apns_key_id"`
|
||||
APNSTeamID string `koanf:"apns_team_id"`
|
||||
APNSTopic string `koanf:"apns_topic"`
|
||||
APNSEnv string `koanf:"apns_env"`
|
||||
|
||||
// apnsKeyPEM is the loaded .p8 file contents, populated by Load() when
|
||||
// APNSKeyPath is set. Callers read it via APNSKeyPEM().
|
||||
apnsKeyPEM []byte
|
||||
|
||||
// 扫码登录(QR):新设备出码、已登录设备扫码批准,经 Auth Broker 委托签发会话。
|
||||
// QRLoginEnabled 关闭则 /api/auth/qr/* 返回 503。QRRequestTTLSeconds 是一条扫码
|
||||
// 请求的存活秒数(默认 120)。批准后铸的会话寿命取上面的按档 TTL(full / guest)。
|
||||
@@ -151,6 +174,17 @@ func Load() (*Config, error) {
|
||||
if err := cfg.validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Load the APNs .p8 key file after validation (validate() already confirmed
|
||||
// that if APNSKeyPath is set, all other APNs fields are also set).
|
||||
if cfg.APNSKeyPath != "" {
|
||||
pem, err := os.ReadFile(cfg.APNSKeyPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read CDROP_APNS_KEY_PATH %q: %w", cfg.APNSKeyPath, err)
|
||||
}
|
||||
cfg.apnsKeyPEM = pem
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
@@ -195,9 +229,32 @@ func (c *Config) validate() error {
|
||||
"CDROP_VAPID_PUBLIC_KEY and CDROP_VAPID_PRIVATE_KEY must be set together " +
|
||||
"(run `just vapid-keygen`); set neither to disable Web Push")
|
||||
}
|
||||
|
||||
// APNs is optional, but partial config is always an operator error: all four
|
||||
// fields must be present for APNs to function. Count how many are set; any
|
||||
// non-zero count that is not four is a mistake.
|
||||
apnsSet := 0
|
||||
for _, v := range []string{c.APNSKeyPath, c.APNSKeyID, c.APNSTeamID, c.APNSTopic} {
|
||||
if v != "" {
|
||||
apnsSet++
|
||||
}
|
||||
}
|
||||
if apnsSet > 0 && apnsSet < 4 {
|
||||
return errAPNsHalfConfig
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// APNSKeyPEM returns the loaded .p8 key contents. Empty when APNs is
|
||||
// unconfigured (APNSKeyPath was not set).
|
||||
func (c *Config) APNSKeyPEM() []byte { return c.apnsKeyPEM }
|
||||
|
||||
// APNSEnabled reports whether all APNs fields are configured.
|
||||
func (c *Config) APNSEnabled() bool {
|
||||
return c.APNSKeyPath != "" && c.APNSKeyID != "" && c.APNSTeamID != "" && c.APNSTopic != ""
|
||||
}
|
||||
|
||||
// PushEnabled reports whether Web Push is configured (both VAPID keys present).
|
||||
func (c *Config) PushEnabled() bool {
|
||||
return c.VAPIDPublicKey != "" && c.VAPIDPrivateKey != ""
|
||||
|
||||
Reference in New Issue
Block a user