@enbox/protocols 0.1.0
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/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lists.js +102 -0
- package/dist/esm/lists.js.map +1 -0
- package/dist/esm/preferences.js +61 -0
- package/dist/esm/preferences.js.map +1 -0
- package/dist/esm/profile.js +66 -0
- package/dist/esm/profile.js.map +1 -0
- package/dist/esm/social-graph.js +80 -0
- package/dist/esm/social-graph.js.map +1 -0
- package/dist/esm/status.js +50 -0
- package/dist/esm/status.js.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lists.d.ts +242 -0
- package/dist/types/lists.d.ts.map +1 -0
- package/dist/types/preferences.d.ts +136 -0
- package/dist/types/preferences.d.ts.map +1 -0
- package/dist/types/profile.d.ts +150 -0
- package/dist/types/profile.d.ts.map +1 -0
- package/dist/types/social-graph.d.ts +188 -0
- package/dist/types/social-graph.d.ts.map +1 -0
- package/dist/types/status.d.ts +101 -0
- package/dist/types/status.d.ts.map +1 -0
- package/package.json +60 -0
- package/src/index.ts +17 -0
- package/src/lists.ts +163 -0
- package/src/preferences.ts +120 -0
- package/src/profile.ts +116 -0
- package/src/social-graph.ts +131 -0
- package/src/status.ts +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/lists.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,oCAAoC;AACpC,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;CACvD,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,sCAAsC;AACtC,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAMF,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAMF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EW,CAAC;AAMxC,uDAAuD;AACvD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAGzB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preferences Protocol — user configuration and settings.
|
|
3
|
+
*
|
|
4
|
+
* Stores theme, locale, privacy, and notification preferences.
|
|
5
|
+
* Fully owner-only (no external reads). The `privacy` type uses
|
|
6
|
+
* `encryptionRequired` for at-rest encryption of sensitive settings.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** Data shape for theme preferences. */
|
|
11
|
+
export type ThemeData = {
|
|
12
|
+
mode: 'light' | 'dark' | 'system';
|
|
13
|
+
accentColor?: string;
|
|
14
|
+
fontSize?: 'small' | 'medium' | 'large';
|
|
15
|
+
};
|
|
16
|
+
/** Data shape for locale preferences. */
|
|
17
|
+
export type LocaleData = {
|
|
18
|
+
language: string;
|
|
19
|
+
region?: string;
|
|
20
|
+
timezone?: string;
|
|
21
|
+
dateFormat?: string;
|
|
22
|
+
hourCycle?: '12h' | '24h';
|
|
23
|
+
};
|
|
24
|
+
/** Data shape for privacy preferences. */
|
|
25
|
+
export type PrivacyData = {
|
|
26
|
+
cookieConsent: {
|
|
27
|
+
analytics: boolean;
|
|
28
|
+
marketing: boolean;
|
|
29
|
+
functional: boolean;
|
|
30
|
+
};
|
|
31
|
+
shareUsageData: boolean;
|
|
32
|
+
};
|
|
33
|
+
/** Data shape for notification preferences. */
|
|
34
|
+
export type NotificationData = {
|
|
35
|
+
channel: string;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
quietHoursStart?: string;
|
|
38
|
+
quietHoursEnd?: string;
|
|
39
|
+
};
|
|
40
|
+
/** Maps protocol type names to their TypeScript data shapes. */
|
|
41
|
+
export type PreferencesSchemaMap = {
|
|
42
|
+
theme: ThemeData;
|
|
43
|
+
locale: LocaleData;
|
|
44
|
+
privacy: PrivacyData;
|
|
45
|
+
notification: NotificationData;
|
|
46
|
+
};
|
|
47
|
+
export declare const PreferencesDefinition: {
|
|
48
|
+
readonly protocol: "https://enbox.org/protocols/preferences";
|
|
49
|
+
readonly published: false;
|
|
50
|
+
readonly types: {
|
|
51
|
+
readonly theme: {
|
|
52
|
+
readonly schema: "https://enbox.org/schemas/preferences/theme";
|
|
53
|
+
readonly dataFormats: ["application/json"];
|
|
54
|
+
};
|
|
55
|
+
readonly locale: {
|
|
56
|
+
readonly schema: "https://enbox.org/schemas/preferences/locale";
|
|
57
|
+
readonly dataFormats: ["application/json"];
|
|
58
|
+
};
|
|
59
|
+
readonly privacy: {
|
|
60
|
+
readonly schema: "https://enbox.org/schemas/preferences/privacy";
|
|
61
|
+
readonly dataFormats: ["application/json"];
|
|
62
|
+
readonly encryptionRequired: true;
|
|
63
|
+
};
|
|
64
|
+
readonly notification: {
|
|
65
|
+
readonly schema: "https://enbox.org/schemas/preferences/notification";
|
|
66
|
+
readonly dataFormats: ["application/json"];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly structure: {
|
|
70
|
+
readonly theme: {
|
|
71
|
+
readonly $actions: [];
|
|
72
|
+
};
|
|
73
|
+
readonly locale: {
|
|
74
|
+
readonly $actions: [];
|
|
75
|
+
};
|
|
76
|
+
readonly privacy: {
|
|
77
|
+
readonly $actions: [];
|
|
78
|
+
};
|
|
79
|
+
readonly notification: {
|
|
80
|
+
readonly $actions: [];
|
|
81
|
+
readonly $tags: {
|
|
82
|
+
readonly $requiredTags: ["channel"];
|
|
83
|
+
readonly $allowUndefinedTags: false;
|
|
84
|
+
readonly channel: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/** Typed Preferences protocol for use with `dwn.using()`. */
|
|
92
|
+
export declare const PreferencesProtocol: import("@enbox/api").TypedProtocol<{
|
|
93
|
+
readonly protocol: "https://enbox.org/protocols/preferences";
|
|
94
|
+
readonly published: false;
|
|
95
|
+
readonly types: {
|
|
96
|
+
readonly theme: {
|
|
97
|
+
readonly schema: "https://enbox.org/schemas/preferences/theme";
|
|
98
|
+
readonly dataFormats: ["application/json"];
|
|
99
|
+
};
|
|
100
|
+
readonly locale: {
|
|
101
|
+
readonly schema: "https://enbox.org/schemas/preferences/locale";
|
|
102
|
+
readonly dataFormats: ["application/json"];
|
|
103
|
+
};
|
|
104
|
+
readonly privacy: {
|
|
105
|
+
readonly schema: "https://enbox.org/schemas/preferences/privacy";
|
|
106
|
+
readonly dataFormats: ["application/json"];
|
|
107
|
+
readonly encryptionRequired: true;
|
|
108
|
+
};
|
|
109
|
+
readonly notification: {
|
|
110
|
+
readonly schema: "https://enbox.org/schemas/preferences/notification";
|
|
111
|
+
readonly dataFormats: ["application/json"];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
readonly structure: {
|
|
115
|
+
readonly theme: {
|
|
116
|
+
readonly $actions: [];
|
|
117
|
+
};
|
|
118
|
+
readonly locale: {
|
|
119
|
+
readonly $actions: [];
|
|
120
|
+
};
|
|
121
|
+
readonly privacy: {
|
|
122
|
+
readonly $actions: [];
|
|
123
|
+
};
|
|
124
|
+
readonly notification: {
|
|
125
|
+
readonly $actions: [];
|
|
126
|
+
readonly $tags: {
|
|
127
|
+
readonly $requiredTags: ["channel"];
|
|
128
|
+
readonly $allowUndefinedTags: false;
|
|
129
|
+
readonly channel: {
|
|
130
|
+
readonly type: "string";
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}, PreferencesSchemaMap>;
|
|
136
|
+
//# sourceMappingURL=preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../src/preferences.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,wCAAwC;AACxC,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACzC,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CAC3B,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,EAAE;QACb,SAAS,EAAE,OAAO,CAAC;QACnB,SAAS,EAAE,OAAO,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAMF,gEAAgE;AAChE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,YAAY,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAMF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCK,CAAC;AAMxC,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAG/B,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile Protocol — public and semi-private identity information.
|
|
3
|
+
*
|
|
4
|
+
* Supports a published profile record, avatar (binary), links, and
|
|
5
|
+
* private notes visible only to friends (via Social Graph composition).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** Data shape for a profile record. */
|
|
10
|
+
export type ProfileData = {
|
|
11
|
+
displayName: string;
|
|
12
|
+
bio?: string;
|
|
13
|
+
location?: string;
|
|
14
|
+
website?: string;
|
|
15
|
+
pronouns?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Avatar is stored as binary data (Blob). */
|
|
18
|
+
export type AvatarData = Blob;
|
|
19
|
+
/** Data shape for a link record (e.g. social links). */
|
|
20
|
+
export type LinkData = {
|
|
21
|
+
url: string;
|
|
22
|
+
title: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
sortOrder?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Data shape for a private note (visible only to friends). */
|
|
27
|
+
export type PrivateNoteData = {
|
|
28
|
+
content: string;
|
|
29
|
+
};
|
|
30
|
+
/** Maps protocol type names to their TypeScript data shapes. */
|
|
31
|
+
export type ProfileSchemaMap = {
|
|
32
|
+
profile: ProfileData;
|
|
33
|
+
avatar: AvatarData;
|
|
34
|
+
link: LinkData;
|
|
35
|
+
privateNote: PrivateNoteData;
|
|
36
|
+
};
|
|
37
|
+
export declare const ProfileDefinition: {
|
|
38
|
+
readonly protocol: "https://enbox.org/protocols/profile";
|
|
39
|
+
readonly published: true;
|
|
40
|
+
readonly uses: {
|
|
41
|
+
readonly social: "https://enbox.org/protocols/social-graph";
|
|
42
|
+
};
|
|
43
|
+
readonly types: {
|
|
44
|
+
readonly profile: {
|
|
45
|
+
readonly schema: "https://enbox.org/schemas/profile/profile";
|
|
46
|
+
readonly dataFormats: ["application/json"];
|
|
47
|
+
};
|
|
48
|
+
readonly avatar: {
|
|
49
|
+
readonly dataFormats: ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
50
|
+
};
|
|
51
|
+
readonly link: {
|
|
52
|
+
readonly schema: "https://enbox.org/schemas/profile/link";
|
|
53
|
+
readonly dataFormats: ["application/json"];
|
|
54
|
+
};
|
|
55
|
+
readonly privateNote: {
|
|
56
|
+
readonly schema: "https://enbox.org/schemas/profile/private-note";
|
|
57
|
+
readonly dataFormats: ["application/json"];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly structure: {
|
|
61
|
+
readonly profile: {
|
|
62
|
+
readonly $size: {
|
|
63
|
+
readonly max: 10000;
|
|
64
|
+
};
|
|
65
|
+
readonly $actions: [{
|
|
66
|
+
readonly who: "anyone";
|
|
67
|
+
readonly can: ["read"];
|
|
68
|
+
}];
|
|
69
|
+
readonly avatar: {
|
|
70
|
+
readonly $size: {
|
|
71
|
+
readonly max: 1048576;
|
|
72
|
+
};
|
|
73
|
+
readonly $actions: [{
|
|
74
|
+
readonly who: "anyone";
|
|
75
|
+
readonly can: ["read"];
|
|
76
|
+
}];
|
|
77
|
+
};
|
|
78
|
+
readonly link: {
|
|
79
|
+
readonly $actions: [{
|
|
80
|
+
readonly who: "anyone";
|
|
81
|
+
readonly can: ["read"];
|
|
82
|
+
}];
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
readonly privateNote: {
|
|
86
|
+
readonly $actions: [{
|
|
87
|
+
readonly role: "social:friend";
|
|
88
|
+
readonly can: ["read"];
|
|
89
|
+
}];
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Typed Profile protocol for use with `dwn.using()`. */
|
|
94
|
+
export declare const ProfileProtocol: import("@enbox/api").TypedProtocol<{
|
|
95
|
+
readonly protocol: "https://enbox.org/protocols/profile";
|
|
96
|
+
readonly published: true;
|
|
97
|
+
readonly uses: {
|
|
98
|
+
readonly social: "https://enbox.org/protocols/social-graph";
|
|
99
|
+
};
|
|
100
|
+
readonly types: {
|
|
101
|
+
readonly profile: {
|
|
102
|
+
readonly schema: "https://enbox.org/schemas/profile/profile";
|
|
103
|
+
readonly dataFormats: ["application/json"];
|
|
104
|
+
};
|
|
105
|
+
readonly avatar: {
|
|
106
|
+
readonly dataFormats: ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
107
|
+
};
|
|
108
|
+
readonly link: {
|
|
109
|
+
readonly schema: "https://enbox.org/schemas/profile/link";
|
|
110
|
+
readonly dataFormats: ["application/json"];
|
|
111
|
+
};
|
|
112
|
+
readonly privateNote: {
|
|
113
|
+
readonly schema: "https://enbox.org/schemas/profile/private-note";
|
|
114
|
+
readonly dataFormats: ["application/json"];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
readonly structure: {
|
|
118
|
+
readonly profile: {
|
|
119
|
+
readonly $size: {
|
|
120
|
+
readonly max: 10000;
|
|
121
|
+
};
|
|
122
|
+
readonly $actions: [{
|
|
123
|
+
readonly who: "anyone";
|
|
124
|
+
readonly can: ["read"];
|
|
125
|
+
}];
|
|
126
|
+
readonly avatar: {
|
|
127
|
+
readonly $size: {
|
|
128
|
+
readonly max: 1048576;
|
|
129
|
+
};
|
|
130
|
+
readonly $actions: [{
|
|
131
|
+
readonly who: "anyone";
|
|
132
|
+
readonly can: ["read"];
|
|
133
|
+
}];
|
|
134
|
+
};
|
|
135
|
+
readonly link: {
|
|
136
|
+
readonly $actions: [{
|
|
137
|
+
readonly who: "anyone";
|
|
138
|
+
readonly can: ["read"];
|
|
139
|
+
}];
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
readonly privateNote: {
|
|
143
|
+
readonly $actions: [{
|
|
144
|
+
readonly role: "social:friend";
|
|
145
|
+
readonly can: ["read"];
|
|
146
|
+
}];
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
}, ProfileSchemaMap>;
|
|
150
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC;AAE9B,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAMF,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AAMF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CS,CAAC;AAMxC,yDAAyD;AACzD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAG3B,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Social Graph Protocol — foundation protocol for relationship management.
|
|
3
|
+
*
|
|
4
|
+
* Provides friend, block, group, and member types with role-based access.
|
|
5
|
+
* Other protocols compose with this via `uses` to leverage the `friend` role
|
|
6
|
+
* for cross-protocol authorization.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** Data shape for a friend record. */
|
|
11
|
+
export type FriendData = {
|
|
12
|
+
did: string;
|
|
13
|
+
alias?: string;
|
|
14
|
+
note?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Data shape for a block record. */
|
|
17
|
+
export type BlockData = {
|
|
18
|
+
did: string;
|
|
19
|
+
reason?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Data shape for a group record. */
|
|
22
|
+
export type GroupData = {
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
icon?: string;
|
|
26
|
+
};
|
|
27
|
+
/** Data shape for a group member record. */
|
|
28
|
+
export type MemberData = {
|
|
29
|
+
did: string;
|
|
30
|
+
alias?: string;
|
|
31
|
+
};
|
|
32
|
+
/** Maps protocol type names to their TypeScript data shapes. */
|
|
33
|
+
export type SocialGraphSchemaMap = {
|
|
34
|
+
friend: FriendData;
|
|
35
|
+
block: BlockData;
|
|
36
|
+
group: GroupData;
|
|
37
|
+
member: MemberData;
|
|
38
|
+
};
|
|
39
|
+
export declare const SocialGraphDefinition: {
|
|
40
|
+
readonly protocol: "https://enbox.org/protocols/social-graph";
|
|
41
|
+
readonly published: true;
|
|
42
|
+
readonly types: {
|
|
43
|
+
readonly friend: {
|
|
44
|
+
readonly schema: "https://enbox.org/schemas/social-graph/friend";
|
|
45
|
+
readonly dataFormats: ["application/json"];
|
|
46
|
+
};
|
|
47
|
+
readonly block: {
|
|
48
|
+
readonly schema: "https://enbox.org/schemas/social-graph/block";
|
|
49
|
+
readonly dataFormats: ["application/json"];
|
|
50
|
+
};
|
|
51
|
+
readonly group: {
|
|
52
|
+
readonly schema: "https://enbox.org/schemas/social-graph/group";
|
|
53
|
+
readonly dataFormats: ["application/json"];
|
|
54
|
+
};
|
|
55
|
+
readonly member: {
|
|
56
|
+
readonly schema: "https://enbox.org/schemas/social-graph/member";
|
|
57
|
+
readonly dataFormats: ["application/json"];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly structure: {
|
|
61
|
+
readonly friend: {
|
|
62
|
+
readonly $role: true;
|
|
63
|
+
readonly $actions: [{
|
|
64
|
+
readonly who: "anyone";
|
|
65
|
+
readonly can: ["create"];
|
|
66
|
+
}, {
|
|
67
|
+
readonly who: "author";
|
|
68
|
+
readonly of: "friend";
|
|
69
|
+
readonly can: ["read"];
|
|
70
|
+
}];
|
|
71
|
+
readonly $tags: {
|
|
72
|
+
readonly $requiredTags: ["did"];
|
|
73
|
+
readonly $allowUndefinedTags: false;
|
|
74
|
+
readonly did: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly block: {
|
|
80
|
+
readonly $actions: [{
|
|
81
|
+
readonly who: "anyone";
|
|
82
|
+
readonly can: ["create"];
|
|
83
|
+
}];
|
|
84
|
+
readonly $tags: {
|
|
85
|
+
readonly $requiredTags: ["did"];
|
|
86
|
+
readonly $allowUndefinedTags: false;
|
|
87
|
+
readonly did: {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
readonly group: {
|
|
93
|
+
readonly $actions: [{
|
|
94
|
+
readonly who: "anyone";
|
|
95
|
+
readonly can: ["read"];
|
|
96
|
+
}];
|
|
97
|
+
readonly member: {
|
|
98
|
+
readonly $actions: [{
|
|
99
|
+
readonly who: "anyone";
|
|
100
|
+
readonly can: ["read"];
|
|
101
|
+
}];
|
|
102
|
+
readonly $tags: {
|
|
103
|
+
readonly $requiredTags: ["did"];
|
|
104
|
+
readonly $allowUndefinedTags: false;
|
|
105
|
+
readonly did: {
|
|
106
|
+
readonly type: "string";
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/** Typed Social Graph protocol for use with `dwn.using()`. */
|
|
114
|
+
export declare const SocialGraphProtocol: import("@enbox/api").TypedProtocol<{
|
|
115
|
+
readonly protocol: "https://enbox.org/protocols/social-graph";
|
|
116
|
+
readonly published: true;
|
|
117
|
+
readonly types: {
|
|
118
|
+
readonly friend: {
|
|
119
|
+
readonly schema: "https://enbox.org/schemas/social-graph/friend";
|
|
120
|
+
readonly dataFormats: ["application/json"];
|
|
121
|
+
};
|
|
122
|
+
readonly block: {
|
|
123
|
+
readonly schema: "https://enbox.org/schemas/social-graph/block";
|
|
124
|
+
readonly dataFormats: ["application/json"];
|
|
125
|
+
};
|
|
126
|
+
readonly group: {
|
|
127
|
+
readonly schema: "https://enbox.org/schemas/social-graph/group";
|
|
128
|
+
readonly dataFormats: ["application/json"];
|
|
129
|
+
};
|
|
130
|
+
readonly member: {
|
|
131
|
+
readonly schema: "https://enbox.org/schemas/social-graph/member";
|
|
132
|
+
readonly dataFormats: ["application/json"];
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
readonly structure: {
|
|
136
|
+
readonly friend: {
|
|
137
|
+
readonly $role: true;
|
|
138
|
+
readonly $actions: [{
|
|
139
|
+
readonly who: "anyone";
|
|
140
|
+
readonly can: ["create"];
|
|
141
|
+
}, {
|
|
142
|
+
readonly who: "author";
|
|
143
|
+
readonly of: "friend";
|
|
144
|
+
readonly can: ["read"];
|
|
145
|
+
}];
|
|
146
|
+
readonly $tags: {
|
|
147
|
+
readonly $requiredTags: ["did"];
|
|
148
|
+
readonly $allowUndefinedTags: false;
|
|
149
|
+
readonly did: {
|
|
150
|
+
readonly type: "string";
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
readonly block: {
|
|
155
|
+
readonly $actions: [{
|
|
156
|
+
readonly who: "anyone";
|
|
157
|
+
readonly can: ["create"];
|
|
158
|
+
}];
|
|
159
|
+
readonly $tags: {
|
|
160
|
+
readonly $requiredTags: ["did"];
|
|
161
|
+
readonly $allowUndefinedTags: false;
|
|
162
|
+
readonly did: {
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
readonly group: {
|
|
168
|
+
readonly $actions: [{
|
|
169
|
+
readonly who: "anyone";
|
|
170
|
+
readonly can: ["read"];
|
|
171
|
+
}];
|
|
172
|
+
readonly member: {
|
|
173
|
+
readonly $actions: [{
|
|
174
|
+
readonly who: "anyone";
|
|
175
|
+
readonly can: ["read"];
|
|
176
|
+
}];
|
|
177
|
+
readonly $tags: {
|
|
178
|
+
readonly $requiredTags: ["did"];
|
|
179
|
+
readonly $allowUndefinedTags: false;
|
|
180
|
+
readonly did: {
|
|
181
|
+
readonly type: "string";
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
}, SocialGraphSchemaMap>;
|
|
188
|
+
//# sourceMappingURL=social-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-graph.d.ts","sourceRoot":"","sources":["../../src/social-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,sCAAsC;AACtC,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qCAAqC;AACrC,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qCAAqC;AACrC,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAMF,gEAAgE;AAChE,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAMF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DK,CAAC;AAMxC,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAG/B,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Protocol — ephemeral status updates with reactions.
|
|
3
|
+
*
|
|
4
|
+
* Uses the `published` flag on individual records to control visibility:
|
|
5
|
+
* published statuses are readable by anyone, unpublished ones only by friends.
|
|
6
|
+
* Composes with Social Graph for friend-scoped access and reactions.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** Data shape for a status update. */
|
|
11
|
+
export type StatusData = {
|
|
12
|
+
text: string;
|
|
13
|
+
emoji?: string;
|
|
14
|
+
activity?: 'online' | 'away' | 'busy' | 'offline';
|
|
15
|
+
expiresAt?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Data shape for a reaction to a status. */
|
|
18
|
+
export type ReactionData = {
|
|
19
|
+
emoji: string;
|
|
20
|
+
};
|
|
21
|
+
/** Maps protocol type names to their TypeScript data shapes. */
|
|
22
|
+
export type StatusSchemaMap = {
|
|
23
|
+
status: StatusData;
|
|
24
|
+
reaction: ReactionData;
|
|
25
|
+
};
|
|
26
|
+
export declare const StatusDefinition: {
|
|
27
|
+
readonly protocol: "https://enbox.org/protocols/status";
|
|
28
|
+
readonly published: true;
|
|
29
|
+
readonly uses: {
|
|
30
|
+
readonly social: "https://enbox.org/protocols/social-graph";
|
|
31
|
+
};
|
|
32
|
+
readonly types: {
|
|
33
|
+
readonly status: {
|
|
34
|
+
readonly schema: "https://enbox.org/schemas/status/status";
|
|
35
|
+
readonly dataFormats: ["application/json"];
|
|
36
|
+
};
|
|
37
|
+
readonly reaction: {
|
|
38
|
+
readonly schema: "https://enbox.org/schemas/status/reaction";
|
|
39
|
+
readonly dataFormats: ["application/json"];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly structure: {
|
|
43
|
+
readonly status: {
|
|
44
|
+
readonly $size: {
|
|
45
|
+
readonly max: 5000;
|
|
46
|
+
};
|
|
47
|
+
readonly $actions: [{
|
|
48
|
+
readonly who: "anyone";
|
|
49
|
+
readonly can: ["read"];
|
|
50
|
+
}, {
|
|
51
|
+
readonly role: "social:friend";
|
|
52
|
+
readonly can: ["read"];
|
|
53
|
+
}];
|
|
54
|
+
readonly reaction: {
|
|
55
|
+
readonly $actions: [{
|
|
56
|
+
readonly role: "social:friend";
|
|
57
|
+
readonly can: ["create", "read", "delete"];
|
|
58
|
+
}];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/** Typed Status protocol for use with `dwn.using()`. */
|
|
64
|
+
export declare const StatusProtocol: import("@enbox/api").TypedProtocol<{
|
|
65
|
+
readonly protocol: "https://enbox.org/protocols/status";
|
|
66
|
+
readonly published: true;
|
|
67
|
+
readonly uses: {
|
|
68
|
+
readonly social: "https://enbox.org/protocols/social-graph";
|
|
69
|
+
};
|
|
70
|
+
readonly types: {
|
|
71
|
+
readonly status: {
|
|
72
|
+
readonly schema: "https://enbox.org/schemas/status/status";
|
|
73
|
+
readonly dataFormats: ["application/json"];
|
|
74
|
+
};
|
|
75
|
+
readonly reaction: {
|
|
76
|
+
readonly schema: "https://enbox.org/schemas/status/reaction";
|
|
77
|
+
readonly dataFormats: ["application/json"];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
readonly structure: {
|
|
81
|
+
readonly status: {
|
|
82
|
+
readonly $size: {
|
|
83
|
+
readonly max: 5000;
|
|
84
|
+
};
|
|
85
|
+
readonly $actions: [{
|
|
86
|
+
readonly who: "anyone";
|
|
87
|
+
readonly can: ["read"];
|
|
88
|
+
}, {
|
|
89
|
+
readonly role: "social:friend";
|
|
90
|
+
readonly can: ["read"];
|
|
91
|
+
}];
|
|
92
|
+
readonly reaction: {
|
|
93
|
+
readonly $actions: [{
|
|
94
|
+
readonly role: "social:friend";
|
|
95
|
+
readonly can: ["create", "read", "delete"];
|
|
96
|
+
}];
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}, StatusSchemaMap>;
|
|
101
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,sCAAsC;AACtC,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAMF,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BU,CAAC;AAMxC,wDAAwD;AACxD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAG1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enbox/protocols",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standard reusable DWN protocol definitions for the Enbox ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/esm/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"build:esm": "rimraf dist/esm dist/types && bun tsc -p tsconfig.json",
|
|
12
|
+
"build": "bun run clean && bun run build:esm",
|
|
13
|
+
"lint": "eslint . --max-warnings 0",
|
|
14
|
+
"lint:fix": "eslint . --fix",
|
|
15
|
+
"test:node": "bun test .spec.ts",
|
|
16
|
+
"test:node:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage .spec.ts"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/enboxorg/enbox/tree/main/packages/protocols#readme",
|
|
19
|
+
"bugs": "https://github.com/enboxorg/enbox/issues",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/enboxorg/enbox.git",
|
|
23
|
+
"directory": "packages/protocols"
|
|
24
|
+
},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"import": "./dist/esm/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"decentralized",
|
|
38
|
+
"dwn",
|
|
39
|
+
"protocols",
|
|
40
|
+
"web5"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"bun": ">=1.0.0"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@enbox/api": "0.1.0",
|
|
50
|
+
"@enbox/dwn-sdk-js": "0.0.5"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "8.32.1",
|
|
54
|
+
"@typescript-eslint/parser": "8.32.1",
|
|
55
|
+
"bun-types": "latest",
|
|
56
|
+
"eslint": "9.7.0",
|
|
57
|
+
"rimraf": "5.0.7",
|
|
58
|
+
"typescript": "5.5.4"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard reusable DWN protocol definitions for the Enbox ecosystem.
|
|
3
|
+
*
|
|
4
|
+
* Each protocol exports:
|
|
5
|
+
* - A raw `ProtocolDefinition` (e.g. `SocialGraphDefinition`)
|
|
6
|
+
* - A typed protocol created via `defineProtocol()` (e.g. `SocialGraphProtocol`)
|
|
7
|
+
* - Data shape types for each record type (e.g. `FriendData`, `ProfileData`)
|
|
8
|
+
* - A `SchemaMap` type mapping type names to data shapes
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export * from './lists.js';
|
|
14
|
+
export * from './preferences.js';
|
|
15
|
+
export * from './profile.js';
|
|
16
|
+
export * from './social-graph.js';
|
|
17
|
+
export * from './status.js';
|