copious-mail 0.0.0-stage → 0.9.1

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.
Files changed (182) hide show
  1. package/LICENSE +504 -0
  2. package/README.md +143 -2
  3. package/bin/index.js +345 -0
  4. package/client/copiousLogo.svg +123 -0
  5. package/client/hosted.html +5259 -0
  6. package/client/mail_styles.css +40 -0
  7. package/client/mikado.bundle.debug.js +1406 -0
  8. package/client/mikado.bundle.min.js +68 -0
  9. package/client/mikado.bundle.module.debug.js +1401 -0
  10. package/client/mikado.bundle.module.min.js +67 -0
  11. package/client/mikado.bundle.profiler.debug.js +1490 -0
  12. package/client/mikado.es5.debug.js +1995 -0
  13. package/client/mikado.es5.min.js +85 -0
  14. package/client/mikado.light.debug.js +535 -0
  15. package/client/mikado.light.min.js +29 -0
  16. package/client/mikado.light.module.debug.js +530 -0
  17. package/data/user_list.db +14 -0
  18. package/index.html +7242 -0
  19. package/index.js +5 -0
  20. package/jsconfig.json +32 -0
  21. package/lib/mail_repo_bridge_ops.js +1177 -0
  22. package/lib/utils.js +70 -0
  23. package/lib/websocket_con.js +249 -0
  24. package/mail_bridge.conf +10 -0
  25. package/package.json +41 -5
  26. package/svelte-src/App.svelte +2513 -0
  27. package/svelte-src/ContactGrid.svelte +98 -0
  28. package/svelte-src/FloatWindow.svelte +181 -0
  29. package/svelte-src/MessageDisplay.svelte +230 -0
  30. package/svelte-src/MessageEditor.svelte +664 -0
  31. package/svelte-src/MessageListEditor.svelte +133 -0
  32. package/svelte-src/Thing.svelte +190 -0
  33. package/svelte-src/ThingFull.svelte +117 -0
  34. package/svelte-src/ipfs_profile_proxy.js +923 -0
  35. package/svelte-src/main.js +10 -0
  36. package/svelte-src/search_box.js +69 -0
  37. package/svelte-src/utilities.js +180 -0
  38. package/test/c +28 -0
  39. package/test/copiousLogo.svg +123 -0
  40. package/test/index.html +4408 -0
  41. package/test/index.js +244 -0
  42. package/test/mail_styles.css +40 -0
  43. package/test/mikado.bundle.debug.js +1406 -0
  44. package/test/mikado.bundle.min.js +68 -0
  45. package/test/mikado.bundle.module.debug.js +1401 -0
  46. package/test/mikado.bundle.module.min.js +67 -0
  47. package/test/mikado.bundle.profiler.debug.js +1490 -0
  48. package/test/mikado.es5.debug.js +1995 -0
  49. package/test/mikado.es5.min.js +85 -0
  50. package/test/mikado.light.debug.js +535 -0
  51. package/test/mikado.light.min.js +29 -0
  52. package/test/mikado.light.module.debug.js +530 -0
  53. package/test/tpl/partial/attachment_edit.es5.js +1 -0
  54. package/test/tpl/partial/attachment_edit.html +5 -0
  55. package/test/tpl/partial/attachment_edit.js +1 -0
  56. package/test/tpl/partial/attachment_view.es5.js +1 -0
  57. package/test/tpl/partial/attachment_view.html +1 -0
  58. package/test/tpl/partial/attachment_view.js +1 -0
  59. package/test/tpl/partial/contact_list.es5.js +1 -0
  60. package/test/tpl/partial/contact_list.html +9 -0
  61. package/test/tpl/partial/contact_list.js +1 -0
  62. package/test/tpl/partial/draft_list.es5.js +1 -0
  63. package/test/tpl/partial/draft_list.html +8 -0
  64. package/test/tpl/partial/draft_list.js +1 -0
  65. package/test/tpl/partial/inbox_list.es5.js +1 -0
  66. package/test/tpl/partial/inbox_list.html +7 -0
  67. package/test/tpl/partial/inbox_list.js +1 -0
  68. package/test/tpl/partial/notify_list.es5.js +1 -0
  69. package/test/tpl/partial/notify_list.html +8 -0
  70. package/test/tpl/partial/notify_list.js +1 -0
  71. package/test/tpl/partial/sent_list.es5.js +1 -0
  72. package/test/tpl/partial/sent_list.html +7 -0
  73. package/test/tpl/partial/sent_list.js +1 -0
  74. package/test/tpl/partial/spam_list.es5.js +1 -0
  75. package/test/tpl/partial/spam_list.html +8 -0
  76. package/test/tpl/partial/spam_list.js +1 -0
  77. package/test/tpl/partial/trash_list.es5.js +1 -0
  78. package/test/tpl/partial/trash_list.html +7 -0
  79. package/test/tpl/partial/trash_list.js +1 -0
  80. package/test/tpl/partial/user.es5.js +1 -0
  81. package/test/tpl/partial/user.html +18 -0
  82. package/test/tpl/partial/user.js +1 -0
  83. package/tools/jsdoc.conf +47 -0
  84. package/tools/templates/docdash/publish.js +843 -0
  85. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  86. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  87. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  88. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  89. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  90. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  91. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  92. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  93. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  94. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  95. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  96. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  97. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  98. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  99. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  100. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  101. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  102. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  103. package/tools/templates/docdash/static/scripts/collapse.js +67 -0
  104. package/tools/templates/docdash/static/scripts/commonNav.js +28 -0
  105. package/tools/templates/docdash/static/scripts/linenumber.js +25 -0
  106. package/tools/templates/docdash/static/scripts/nav.js +12 -0
  107. package/tools/templates/docdash/static/scripts/polyfill.js +4 -0
  108. package/tools/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  109. package/tools/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  110. package/tools/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  111. package/tools/templates/docdash/static/scripts/search.js +99 -0
  112. package/tools/templates/docdash/static/styles/jsdoc.css +803 -0
  113. package/tools/templates/docdash/static/styles/prettify.css +80 -0
  114. package/tools/templates/docdash/tmpl/augments.tmpl +10 -0
  115. package/tools/templates/docdash/tmpl/container.tmpl +203 -0
  116. package/tools/templates/docdash/tmpl/details.tmpl +152 -0
  117. package/tools/templates/docdash/tmpl/example.tmpl +2 -0
  118. package/tools/templates/docdash/tmpl/examples.tmpl +13 -0
  119. package/tools/templates/docdash/tmpl/exceptions.tmpl +32 -0
  120. package/tools/templates/docdash/tmpl/layout.tmpl +102 -0
  121. package/tools/templates/docdash/tmpl/mainpage.tmpl +15 -0
  122. package/tools/templates/docdash/tmpl/members.tmpl +38 -0
  123. package/tools/templates/docdash/tmpl/method.tmpl +132 -0
  124. package/tools/templates/docdash/tmpl/modifies.tmpl +14 -0
  125. package/tools/templates/docdash/tmpl/namespace.tmpl +133 -0
  126. package/tools/templates/docdash/tmpl/params.tmpl +132 -0
  127. package/tools/templates/docdash/tmpl/properties.tmpl +107 -0
  128. package/tools/templates/docdash/tmpl/returns.tmpl +19 -0
  129. package/tools/templates/docdash/tmpl/source.tmpl +8 -0
  130. package/tools/templates/docdash/tmpl/tutorial.tmpl +19 -0
  131. package/tools/templates/docdash/tmpl/type.tmpl +26 -0
  132. package/tools/templates/templates/docdash/publish.js +843 -0
  133. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  134. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  135. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  136. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  137. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  138. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  139. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  140. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  141. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  142. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  143. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  144. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  145. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  146. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  147. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  148. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  149. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  150. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  151. package/tools/templates/templates/docdash/static/scripts/collapse.js +67 -0
  152. package/tools/templates/templates/docdash/static/scripts/commonNav.js +28 -0
  153. package/tools/templates/templates/docdash/static/scripts/linenumber.js +25 -0
  154. package/tools/templates/templates/docdash/static/scripts/nav.js +12 -0
  155. package/tools/templates/templates/docdash/static/scripts/polyfill.js +4 -0
  156. package/tools/templates/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  157. package/tools/templates/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  158. package/tools/templates/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  159. package/tools/templates/templates/docdash/static/scripts/search.js +99 -0
  160. package/tools/templates/templates/docdash/static/styles/jsdoc.css +803 -0
  161. package/tools/templates/templates/docdash/static/styles/prettify.css +80 -0
  162. package/tools/templates/templates/docdash/tmpl/augments.tmpl +10 -0
  163. package/tools/templates/templates/docdash/tmpl/container.tmpl +203 -0
  164. package/tools/templates/templates/docdash/tmpl/details.tmpl +152 -0
  165. package/tools/templates/templates/docdash/tmpl/example.tmpl +2 -0
  166. package/tools/templates/templates/docdash/tmpl/examples.tmpl +13 -0
  167. package/tools/templates/templates/docdash/tmpl/exceptions.tmpl +32 -0
  168. package/tools/templates/templates/docdash/tmpl/layout.tmpl +102 -0
  169. package/tools/templates/templates/docdash/tmpl/mainpage.tmpl +15 -0
  170. package/tools/templates/templates/docdash/tmpl/members.tmpl +38 -0
  171. package/tools/templates/templates/docdash/tmpl/method.tmpl +132 -0
  172. package/tools/templates/templates/docdash/tmpl/modifies.tmpl +14 -0
  173. package/tools/templates/templates/docdash/tmpl/namespace.tmpl +133 -0
  174. package/tools/templates/templates/docdash/tmpl/params.tmpl +132 -0
  175. package/tools/templates/templates/docdash/tmpl/properties.tmpl +107 -0
  176. package/tools/templates/templates/docdash/tmpl/returns.tmpl +19 -0
  177. package/tools/templates/templates/docdash/tmpl/source.tmpl +8 -0
  178. package/tools/templates/templates/docdash/tmpl/tutorial.tmpl +19 -0
  179. package/tools/templates/templates/docdash/tmpl/type.tmpl +26 -0
  180. package/tpl/partial/user.es5.js +1 -0
  181. package/tpl/partial/user.html +10 -0
  182. package/tpl/partial/user.js +1 -0
@@ -0,0 +1,664 @@
1
+ <script>
2
+ import { onMount } from 'svelte';
3
+ import * as ipfs_profiles from './ipfs_profile_proxy.js'
4
+ import * as utils from './utilities.js'
5
+
6
+ // selected... A contact either from the contact list or from the message (and already there)
7
+ export let name;
8
+ export let DOB;
9
+ export let place_of_origin;
10
+ export let cool_public_info;
11
+ export let business;
12
+ export let public_key; // this may be empty... can add a contact without the key (message should have key)
13
+ export let signer_public_key;
14
+ export let answer_message // boolean
15
+ export let biometric
16
+ export let cid
17
+
18
+ export let reply_to; // the source message
19
+ export let active_identity
20
+
21
+ export let from_contact = false
22
+ export let contact_form_list
23
+ export let cc_list = []
24
+ let selected_contact_cid = 'default'
25
+
26
+ //
27
+ let receiver_pub_key = false
28
+ let special_contact_form_cid = false
29
+
30
+ let show_key = false
31
+ let introduction = false
32
+ let message_was_sent = false
33
+
34
+
35
+ let cc_index = cc_list.length > 0 ? 0 : -1
36
+ let cc_cid = -1
37
+ let cc_read_list = []
38
+ let cc_select_list = []
39
+
40
+ let attachments = []
41
+
42
+ let clear_cid = false
43
+
44
+ let message_type = "introduction"
45
+ let receiver_user_info = {
46
+ "name" : name,
47
+ "DOB" : DOB,
48
+ "place_of_origin" : place_of_origin,
49
+ "cool_public_info" : cool_public_info,
50
+ "business" : business,
51
+ "public_key" : public_key,
52
+ "signer_public_key" : signer_public_key,
53
+ "biometric" : biometric
54
+ }
55
+
56
+ let use_previous = answer_message
57
+
58
+ $: message_type = introduction ? "introduction" : "message"
59
+
60
+ let cform_index = 0
61
+ //
62
+ let reply_with = "default"
63
+ //
64
+ let augmented_contact_form_list = [{ "cid" : "default", "info" : "default "}]
65
+ $: augmented_contact_form_list = [{ "cid" : "default", "info" : "default "}].concat(contact_form_list)
66
+
67
+ $: {
68
+ if ( cform_index >= 0 ) {
69
+ selected_contact_cid = augmented_contact_form_list[cform_index].cid
70
+ reply_with = augmented_contact_form_list[cform_index].info
71
+ }
72
+ }
73
+
74
+ $: {
75
+ if ( cc_list.length === 0 ) {
76
+ cc_select_list = [{ "name" : "no cc", }]
77
+ } else {
78
+ cc_select_list = [{ "name" : "no cc", }]
79
+ cc_select_list = cc_select_list.concat(cc_list)
80
+ }
81
+ }
82
+
83
+ $: {
84
+ if ( cc_index > 0 ) {
85
+ let cc_item = cc_list[cc_index-1]
86
+ if ( cc_item ) {
87
+ cc_cid = cc_item.cid
88
+ cc_read_list.push(cc_cid)
89
+ common_contact_vars["{{id-cc-"].set_el_html(cc_read_list.join(','))
90
+ } else {
91
+ cc_read_list = []
92
+ common_contact_vars["{{id-cc-"].set_el_html("")
93
+ }
94
+ } else {
95
+ cc_read_list = []
96
+ common_contact_vars["{{id-cc-"].set_el_html("")
97
+ }
98
+ }
99
+
100
+ $: {
101
+ if ( (reply_to !== undefined) && !(from_contact) ) {
102
+ special_contact_form_cid = reply_to.reply_with
103
+ receiver_pub_key = reply_to.public_key
104
+ if ( (typeof public_key === "string" ) && (typeof receiver_pub_key === "string" ) ) {
105
+ if ( public_key !== receiver_pub_key ) {
106
+ receiver_pub_key = false
107
+ }
108
+ }
109
+ } else {
110
+ receiver_pub_key = public_key ? public_key : false
111
+ special_contact_form_cid = 'default'
112
+ }
113
+ }
114
+
115
+ $: {
116
+ if ( cid !== false ) {
117
+ fetch_clear_cid(cid)
118
+ }
119
+ }
120
+
121
+ $: {
122
+ receiver_user_info.clear_cid = clear_cid
123
+ }
124
+
125
+
126
+ // "name": 'Hans Solo', "user_cid" : "4504385938",
127
+ // "subject" : "Darth Vadier Attacks", "date" : todays_date, "readers" : "joe,jane,harry",
128
+ // "business" : false, "public_key" : false, "message" : "this is a message 1"
129
+
130
+
131
+
132
+ let common_contact_vars = {
133
+ "{{contact-top}}" : utils.cvar_factory("promail-mes-ed-contact",''),
134
+ "{{id-to-" : utils.cvar_factory("promail-recipient","name"),
135
+ "{{id-cid-" : utils.cvar_factory("promail-recipient","user_cid"),
136
+ "{{id-date-" : utils.cvar_factory("promail-date","date"),
137
+ "{{id-cc-" : utils.cvar_factory("promail-readers","readers"),
138
+ "{{id-business-" : utils.cvar_factory("promail-business","business"),
139
+ "{{id-subject-" : utils.cvar_factory("promail-subject"),
140
+ "{{id-message-" : utils.cvar_factory("promail-message"),
141
+ "{{id-sender_key-" : utils.cvar_factory("promail-sender_key","public_key"),
142
+ "{{id-sender_signer_key-" : utils.cvar_factory("promail-sender_signer_key","signer_public_key"),
143
+ "{{id-wrapped_key-" : utils.cvar_factory("promail-wrapped_key","wrapped_key"),
144
+ "{{id-attachment-" : utils.cvar_factory("promail-attachments","attachments"),
145
+ }
146
+
147
+
148
+ let cform_var_supply = {
149
+ "{{to}}" : name,
150
+ "{{DOB}}" : DOB,
151
+ "{{date}}" : (new Date()).toISOString(),
152
+ "{{place_of_origin}}" : place_of_origin,
153
+ "{{cool_public_info}}" : cool_public_info,
154
+ "{{business}}" : business ? "business" : "profile",
155
+ "{{public_key}}" : JSON.stringify(public_key),
156
+ "{{signer_public_key}}" : JSON.stringify(signer_public_key),
157
+ "{{cid}}" : JSON.stringify(active_identity.cid),
158
+ "{{from}}" : active_identity.user_info ? active_identity.user_info.name : "",
159
+ "{{clear_cid}}" : JSON.stringify(active_identity.clear_cid)
160
+ }
161
+
162
+ function process_variables(html,vars) {
163
+ console.log(Object.keys(vars))
164
+ for ( let cform_v in cform_var_supply ) {
165
+ let instances = vars[cform_v]
166
+ if ( instances !== undefined ) {
167
+ let n = instances.length
168
+ let value = cform_var_supply[cform_v]
169
+ for ( let i = 0; i < n; i++ ) {
170
+ html = html.replace(cform_v,value)
171
+ }
172
+ }
173
+ }
174
+ //
175
+ html = utils.subst_vars_app_ids(html,vars,common_contact_vars)
176
+ return(html)
177
+ }
178
+
179
+
180
+
181
+ // message_object_on_send
182
+ // -- constuct the message object
183
+
184
+ function message_object_on_send(top_level_id) {
185
+ //
186
+ let message_object = {
187
+ "name" : active_identity.user_info.name,
188
+ "user_cid" : active_identity.cid, // not the clear cid
189
+ "subject" : common_contact_vars["{{id-subject-"].extract_value(),
190
+ "date" : Date.now(),
191
+ "readers" : common_contact_vars["{{id-cc-"].extract_value(),
192
+ "business" : business,
193
+ "message" : common_contact_vars["{{id-message-"].extract_value(),
194
+ "attachments" : attachments,
195
+ "reply_with" : selected_contact_cid,
196
+ //
197
+ "public_key" : active_identity.user_info.public_key, // receiver will wrap keys back to me
198
+ // (could send a different one other than the one used in establishing identity)
199
+ "signer_public_key" : false, // only send with intro
200
+ //
201
+ "nonce" : gen_nonce() // always send a fresh nonce
202
+ }
203
+ //
204
+ if ( introduction ) {
205
+ message_object.signer_public_key = active_identity.user_info.signer_public_key // receiver will verify my signature
206
+ }
207
+ //
208
+ let message = message_object
209
+ //
210
+ if ( use_previous ) {
211
+ message.message += "<br><br><br>=====================================================<br>"
212
+ message.message += previous_message
213
+ }
214
+ //
215
+ return(message)
216
+ }
217
+
218
+ async function init_contact_form_cids(r_info) {
219
+ r_cid = false
220
+ if ( r_info.public_key && r_info.signer_public_key ) {
221
+ r_cid = await ipfs_profiles.fetch_contact_cid(r_info,false) // established contact
222
+ }
223
+ r_p_cid = await ipfs_profiles.fetch_contact_cid(r_info,true) // introduction or no privacy intended
224
+ }
225
+
226
+ let r_cid = false // receiver's private contact cid
227
+ let r_p_cid = false // receiver's public contact cid
228
+ //
229
+ let user_cid = false // the active user cid of sender (user of client)
230
+ // This is for retreiving keys, encryptors, etc. out of local storage
231
+
232
+ $: user_cid = active_identity ? active_identity.cid : false
233
+
234
+ $: {
235
+ if ( active_identity && name ) {
236
+ receiver_user_info = {
237
+ "name" : name,
238
+ "DOB" : DOB,
239
+ "place_of_origin" : place_of_origin,
240
+ "cool_public_info" : cool_public_info,
241
+ "business" : business,
242
+ "public_key" : public_key,
243
+ "signer_public_key" : signer_public_key,
244
+ "biometric" : biometric
245
+ }
246
+ init_contact_form_cids(receiver_user_info)
247
+ }
248
+ }
249
+
250
+ $: {
251
+ if ( active_identity ) {
252
+ cform_var_supply = {
253
+ "{{to}}" : name,
254
+ "{{DOB}}" : DOB,
255
+ "{{date}}" : (new Date()).toISOString(),
256
+ "{{place_of_origin}}" : place_of_origin,
257
+ "{{cool_public_info}}" : cool_public_info,
258
+ "{{business}}" : business ? "business" : "profile",
259
+ "{{public_key}}" : JSON.stringify(public_key),
260
+ "{{cid}}" : JSON.stringify(active_identity.cid),
261
+ "{{from}}" : active_identity.user_info ? active_identity.user_info.name : "",
262
+ "{{clear_cid}}" : JSON.stringify(active_identity.clear_cid)
263
+ }
264
+ }
265
+ }
266
+
267
+ let todays_date = ''
268
+ $: {
269
+ todays_date = (new Date()).toISOString()
270
+ }
271
+
272
+ let contact_page = ""
273
+
274
+ let b_label = ""
275
+ let know_of = ""
276
+ $: b_label = business ? " is a business" : " is a person"
277
+ $: know_of = (public_key !== false) ? " is someone I know" : " is a new introduction"
278
+
279
+ function toggle_showkey() {
280
+ show_key = show_key ? false : true
281
+ console.log(show_key)
282
+ }
283
+
284
+ let previous_message = ""
285
+ $: previous_message = answer_message ? JSON.stringify(reply_to,null,4) : ""
286
+
287
+ async function fetch_clear_cid(cid) {
288
+ let ccid_container = await ipfs_profiles.fetch_cid_json(cid)
289
+ if ( ccid_container ) {
290
+ clear_cid = ccid_container.clear_cid
291
+ return clear_cid
292
+ }
293
+ return false
294
+ }
295
+
296
+ async function start_introduction() {
297
+ introduction = true
298
+ message_was_sent = false
299
+ cc_read_list = []
300
+ cc_index = 0
301
+ //
302
+ // the user cid (active identity) gets any services for handling encryption locally.
303
+ // The receiver information will be stored as part of the data if encryption is required
304
+ let contact_page_descr = await ipfs_profiles.fetch_contact_page(active_identity,business,'default',r_p_cid)
305
+ if ( contact_page_descr ) {
306
+ let html = (contact_page_descr.html === undefined) ? contact_page_descr.txt_full : contact_page_descr.html
307
+ contact_page = process_variables(html,contact_page_descr.var_map) // decodeURIComponent(html)
308
+ //
309
+ let script = contact_page_descr.script
310
+ if ( script ) {
311
+ script = decodeURIComponent(script)
312
+ script = script.replace("{{when}}",Date.now())
313
+ addscript(script,"blg-window-full-text-outgo-script",true)
314
+ }
315
+
316
+ console.log(contact_page_descr.var_map)
317
+ }
318
+ //
319
+ }
320
+
321
+
322
+ async function start_composing() {
323
+ introduction = false
324
+ message_was_sent = false
325
+ cc_read_list = []
326
+ cc_index = 0
327
+ //
328
+ // the user cid (active identity) gets any services for handling encryption locally.
329
+ // The receiver information will be stored as part of the data if encryption is required
330
+ // figure out how to get custom cids from inbound messages...
331
+ let contact_page_descr = false
332
+ if ( special_contact_form_cid && (special_contact_form_cid !== 'default') ) {
333
+ contact_page_descr = await ipfs_profiles.fetch_contact_page(active_identity,business,'cid',special_contact_form_cid)
334
+ } else {
335
+ contact_page_descr = await ipfs_profiles.fetch_contact_page(active_identity,business,'default',r_cid)
336
+ }
337
+ //
338
+ if ( !contact_page_descr && r_cid ) {
339
+ contact_page_descr = await ipfs_profiles.fetch_contact_page(active_identity,business,'default',r_cid)
340
+ }
341
+ //
342
+ if ( contact_page_descr ) {
343
+ let html = (contact_page_descr.html === undefined) ? contact_page_descr.txt_full : contact_page_descr.html
344
+ contact_page = process_variables(html,contact_page_descr.var_map) // decodeURIComponent(html)
345
+ //
346
+ let script = contact_page_descr.script
347
+ if ( script ) {
348
+ script = decodeURIComponent(script)
349
+ script = script.replace("{{when}}",Date.now())
350
+ addscript(script,"blg-window-full-text-outgo-script",true)
351
+ }
352
+ }
353
+ //
354
+ }
355
+
356
+ // // // // // //
357
+ //
358
+ async function ipfs_sender(message) {
359
+ // message_object_on_send()
360
+ switch ( message_type ) {
361
+ case "introduction" : {
362
+ let identify = active_identity
363
+ if ( identify ) {
364
+ let i_cid = await ipfs_profiles.send_introduction(receiver_user_info,identify,message)
365
+ if ( i_cid ) {
366
+ if ( identify.introductions === undefined ) {
367
+ identify.introductions = []
368
+ }
369
+ identify.introductions.push(i_cid)
370
+ update_identity(identify)
371
+ message_was_sent = true
372
+ }
373
+ }
374
+ break;
375
+ }
376
+ default: {
377
+ let identify = active_identity
378
+ if ( identify ) {
379
+ let clear_cid = await fetch_clear_cid(cid)
380
+ receiver_user_info.clear_cid = clear_cid
381
+ let m_cid = await ipfs_profiles.send_message(receiver_user_info,identify,message)
382
+ if ( m_cid ) {
383
+ if ( identify.messages === undefined ) {
384
+ identify.messages = []
385
+ }
386
+ identify.messages.push(m_cid)
387
+ update_identity(identify)
388
+ message_was_sent = true
389
+ }
390
+ }
391
+ break;
392
+ }
393
+ }
394
+ }
395
+
396
+ //
397
+ onMount(() => {
398
+ if ( window._app_set_default_message_sender !== undefined ) {
399
+ window._app_set_default_message_sender(common_contact_vars,cform_var_supply,message_object_on_send,ipfs_sender)
400
+ }
401
+ })
402
+
403
+ async function drop(ev) {
404
+ ev.preventDefault();
405
+ try {
406
+ let files = ev.dataTransfer.files ? ev.dataTransfer.files : false
407
+ let items = ev.dataTransfer.items ? ev.dataTransfer.items : false
408
+ let [fname,blob64] = await utils.drop(items,files)
409
+ //
410
+ let fcid = await ipfs_profiles.upload_data_file(fname,blob64)
411
+ attachments.push(fcid)
412
+ common_contact_vars["{{id-attachment-"].set_el_html(attachments.join(','))
413
+
414
+ } catch (e) {}
415
+ }
416
+
417
+ function dragover(ev) {
418
+ ev.preventDefault();
419
+ }
420
+
421
+ </script>
422
+
423
+ <div class="blg-el-wrapper-full" >
424
+ <div style="padding:6px;" >
425
+ <span class="cool-label" style="background-color: yellowgreen">{todays_date}</span>
426
+ <span class="message_indicator">Sending a message to:</span> <span class="name">{name},</span>
427
+ <div class="tool-holder" >
428
+ <span class="about_name">Who {b_label} and {know_of}.</span>
429
+ <div class="cool-stuff">
430
+ {name} comes from {place_of_origin} and wants you to know that: &quot;{cool_public_info}&quot;
431
+ </div>
432
+ </div>
433
+
434
+ <div class="tool-holder" >
435
+ <div class="subline">
436
+ You are requesting a response through contact form: <span style="font-weight: bold;">{reply_with}</span>
437
+ </div>
438
+ Custom contact form choices:
439
+ <select bind:value={cform_index}>
440
+ {#each augmented_contact_form_list as contact_item, cform_index}
441
+ <option value={cform_index}>{contact_item.info}</option>
442
+ {/each}
443
+ </select>
444
+ <br>
445
+ <span style="font-size:65%">{selected_contact_cid}</span>
446
+ </div>
447
+ </div>
448
+
449
+ {#if answer_message }
450
+ <div class="tool-holder">
451
+ <span class="large-text-label" >Previous Message:</span>
452
+ <span class="small-text-label" >include</span><input type="checkbox" bind:checked={use_previous} >
453
+ <div id="blg-window-full-text-previous" class="full-display" >
454
+ {@html previous_message}
455
+ </div>
456
+ </div>
457
+ {/if}
458
+ <div class="tool-holder">
459
+ <span class="large-text-label" >Compose message here:</span>
460
+ {#if receiver_pub_key !== false }
461
+ <button class="medium_button" on:click={start_composing}>begin composition</button>
462
+ {:else}
463
+ <button class="medium_button" on:click={start_introduction}>begin introduction</button>
464
+ {/if}
465
+ <span class="add-attachemnt" on:drop={drop} on:dragover={dragover} >Drop attachment here (&#128206;)</span>
466
+ <span>CC</span>
467
+ <select bind:value={cc_index}>
468
+ {#each cc_select_list as cc_item, cc_index}
469
+ <option value={cc_index}>{cc_item.name}</option>
470
+ {/each}
471
+ </select>
472
+ {#if message_was_sent }
473
+ <span class="message-sent">Message was sent</span>
474
+ {/if}
475
+ </div>
476
+ <div id="blg-window-full-text-outgo" class="full-display-bottom" >
477
+ {@html contact_page}
478
+ </div>
479
+ <div id="blg-window-full-text-outgo-script" class="is-nothing" ></div>
480
+ <div style="background-color:whitesmoke;font-weight: 600;font-size: smaller;">
481
+ <span style="font-weight:bold;color:black">contact cid:</span> {cid}
482
+ {#if !(show_key) }
483
+ <button style="float:right" on:click={toggle_showkey}>(▼)</button>
484
+ {:else}
485
+ <button style="float:right" on:click={toggle_showkey}>(^)</button>
486
+ {/if}
487
+ </div>
488
+ {#if show_key }
489
+ <div class="viz-key" style="background-color:whitesmoke;font-weight: 600;font-size: smaller;">
490
+ <span style="font-weight:bold;color:black">public wrapper key:</span> {public_key}
491
+ </div>
492
+ {:else}
493
+ <div class="hide-key" style="background-color:whitesmoke;font-weight: 600;font-size: smaller;">
494
+ <span style="font-weight:bold;color:black">public wrapper key:</span> {public_key}
495
+ </div>
496
+ {/if}
497
+ </div>
498
+ <style>
499
+
500
+ .blg-el-wrapper-full {
501
+ overflow-y: hidden;
502
+ height:inherit;
503
+ }
504
+
505
+
506
+ .cool-label {
507
+ display: inline-block;
508
+ padding: 0.2em 0.5em;
509
+ margin: 0 0.2em 0.2em 0;
510
+ text-align: center;
511
+ border-radius: 0.2em;
512
+ color: white;
513
+ }
514
+
515
+
516
+ .add-attachemnt {
517
+ display: inline-block;
518
+ padding: 0.2em 0.5em;
519
+ margin: 0 0.2em 0.2em 0;
520
+ text-align: center;
521
+ border-radius: 0.2em;
522
+ border: solid 1px darkslategray;
523
+ color: rgb(19, 68, 6);
524
+ }
525
+
526
+ .add-attachemnt:hover {
527
+ background-color:rgb(244, 252, 244);
528
+ cursor:copy;
529
+ }
530
+
531
+ .blg-item-title {
532
+ color:black;
533
+ display: unset;
534
+ border-bottom: 1px darkslateblue solid;
535
+ }
536
+
537
+ .blg-item-subject {
538
+ color:black;
539
+ display: unset;
540
+ }
541
+
542
+
543
+ .full-display {
544
+ background-color: rgba(255, 255, 255, 0.9);
545
+ color: rgb(73, 1, 1);
546
+ border-top: solid 2px rgb(88, 4, 88);
547
+ padding: 6px 4px 6px 4px;
548
+ overflow-y: scroll;
549
+ height: 60px;
550
+ border-bottom: solid 1px rgb(88, 4, 88);
551
+ }
552
+
553
+ .full-display-bottom {
554
+ background-color: rgba(255, 255, 255, 0.9);
555
+ color: rgb(73, 1, 1);
556
+ border-top: solid 2px rgb(88, 4, 88);
557
+ padding: 6px 4px 6px 4px;
558
+ overflow-y: scroll;
559
+ height: calc(75vh - 300px);
560
+ border-bottom: solid 1px rgb(88, 4, 88);
561
+ }
562
+
563
+ h6 {
564
+ background-color: rgb(245, 245, 245);
565
+ border: 1px black solid;
566
+ border-radius: 0.2em;
567
+ padding: 0.2em 0.5em;
568
+ margin: 0 0.2em 0.2em 0;
569
+ color:black;
570
+ text-overflow: ellipsis;
571
+ overflow: hidden;
572
+ white-space: nowrap;
573
+ width: 200px;
574
+ }
575
+
576
+ .message_indicator {
577
+ color:rgb(2, 32, 21);
578
+ font-weight: bold;
579
+ }
580
+ .name {
581
+ font-weight: bold;
582
+ font-size: x-large;
583
+ color:rgb(71, 15, 29);
584
+ }
585
+ .about_name {
586
+ color:rgb(88, 4, 88);
587
+ border-bottom: 1px solid deepskyblue;
588
+ margin-bottom:6px;
589
+ }
590
+ .cool-stuff {
591
+ font-weight: bold;
592
+ color:rgb(29, 73, 75);
593
+ display:inline-block;
594
+ }
595
+
596
+ .large-text-label {
597
+ color:rgb(33, 7, 95);
598
+ font-weight: bold;
599
+ font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
600
+ font-style: oblique;
601
+ font-style: 105%;
602
+ margin:2px
603
+ }
604
+
605
+ .small-text-label {
606
+ color:rgb(33, 7, 95);
607
+ font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
608
+ padding:2px;
609
+ margin:2px
610
+ }
611
+
612
+ .medium_button {
613
+ width:25%;
614
+ }
615
+
616
+ .is-nothing {
617
+ display: none;
618
+ visibility: hidden;
619
+ }
620
+
621
+ .viz-key {
622
+ visibility: visible;
623
+ display: block;
624
+ }
625
+ .hide-key {
626
+ visibility: hidden;
627
+ display: none;
628
+ }
629
+
630
+ button:disabled {
631
+ cursor:not-allowed;
632
+ }
633
+
634
+ @keyframes blink {
635
+ 50% { border-color: #ff0000; }
636
+ }
637
+
638
+ .message-sent {
639
+ color: rgb(221, 131, 12);
640
+ background-color: rgb(223, 240, 223);
641
+ font-weight: bold;
642
+ border: solid 2px firebrick;
643
+ padding: 4px;
644
+ animation: blink .5s step-end infinite alternate;
645
+ }
646
+
647
+ .tool-holder {
648
+ width: 100%;
649
+ border: solid 1px burlywood;
650
+ padding:4px;
651
+ margin-top:0px;
652
+ margin-bottom:2px;
653
+ background-color: rgb(255, 253, 247);
654
+ }
655
+
656
+ .tool-holder .subline {
657
+ font-style:oblique;
658
+ color:rgb(46, 7, 73);
659
+ background-color: rgba(249, 255, 240, 0.877);
660
+ border-bottom: lightsteelblue 1px solid;
661
+ width:100%;
662
+ }
663
+
664
+ </style>