-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathbox.go
More file actions
59 lines (54 loc) · 3.35 KB
/
Copy pathbox.go
File metadata and controls
59 lines (54 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SiYuan - Refactor your thinking
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package conf
import "github.com/siyuan-note/siyuan/kernel/util"
// BoxConf 维护 .siyuan/conf.json 笔记本配置。
type BoxConf struct {
Name string `json:"name"` // 笔记本名称
Sort int `json:"sort"` // 排序字段
Icon string `json:"icon"` // 图标
Closed bool `json:"closed"` // 是否处于关闭状态
RefCreateSaveBox string `json:"refCreateSaveBox"` // 块引时新建文档存储笔记本
RefCreateSavePath string `json:"refCreateSavePath"` // 块引时新建文档存储路径
DocCreateSaveBox string `json:"docCreateSaveBox"` // 新建文档存储笔记本
DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径
DocCreateTemplatePath string `json:"docCreateTemplatePath"` // 新建文档使用的模板路径
DailyNoteSavePath string `json:"dailyNoteSavePath"` // 新建日记存储路径
DailyNoteTemplatePath string `json:"dailyNoteTemplatePath"` // 新建日记使用的模板路径
DailyNoteDatabaseID string `json:"dailyNoteDatabaseID"` // 新建日记自动添加到的目标数据库(属性视图)块 ID
SortMode int `json:"sortMode"` // 排序方式
Encrypted bool `json:"encrypted"` // 是否为加密笔记本
BoxCrypt *BoxEncryption `json:"boxCrypt"` // 笔记本加密参数,仅 Encrypted=true 时有值
}
// BoxEncryption 维护单个加密笔记本的密钥包络参数。WrappedDEK 是用全局 KEK 加密后的 DEK,本身可落盘。
type BoxEncryption struct {
Spec int `json:"spec"` // 当前包络规范标识,WrappedDEK 绑定 boxID AAD
WrappedDEK []byte `json:"wrappedDEK"` // 用 KEK 经 AES-GCM 加密后的 DEK
WrapNonce []byte `json:"wrapNonce"` // 包络用的 GCM nonce(从加密信封中提取)
Metadata []byte `json:"metadata,omitempty"` // 用 DEK 加密的图标和排序元数据
CreatedAt int64 `json:"createdAt"` // 创建时间,单位毫秒,便于未来按时间轮换密钥
}
func NewBoxConf() *BoxConf {
return &BoxConf{
Name: "Untitled",
Closed: true,
DailyNoteSavePath: "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}",
DailyNoteTemplatePath: "",
DailyNoteDatabaseID: "",
SortMode: util.SortModeFileTree,
Encrypted: false,
}
}