@junobuild/analytics 0.0.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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/declarations/cmc/cmc.did +122 -0
  4. package/declarations/cmc/cmc.did.d.ts +48 -0
  5. package/declarations/cmc/cmc.factory.did.js +67 -0
  6. package/declarations/cmc/index.d.ts +45 -0
  7. package/declarations/cmc/index.js +37 -0
  8. package/declarations/console/console.did.d.ts +71 -0
  9. package/declarations/console/console.factory.did.js +79 -0
  10. package/declarations/console/console.factory.did.mjs +79 -0
  11. package/declarations/console/index.d.ts +45 -0
  12. package/declarations/console/index.js +37 -0
  13. package/declarations/ic/ic.did +195 -0
  14. package/declarations/ic/ic.did.d.ts +208 -0
  15. package/declarations/ic/ic.factory.did.js +274 -0
  16. package/declarations/mission_control/index.d.ts +45 -0
  17. package/declarations/mission_control/index.js +38 -0
  18. package/declarations/mission_control/mission_control.did.d.ts +101 -0
  19. package/declarations/mission_control/mission_control.factory.did.js +136 -0
  20. package/declarations/observatory/index.d.ts +45 -0
  21. package/declarations/observatory/index.js +38 -0
  22. package/declarations/observatory/observatory.did.d.ts +86 -0
  23. package/declarations/observatory/observatory.factory.did.js +95 -0
  24. package/declarations/observatory/observatory.factory.did.mjs +95 -0
  25. package/declarations/orbiter/index.d.ts +45 -0
  26. package/declarations/orbiter/index.js +37 -0
  27. package/declarations/orbiter/orbiter.did.d.ts +103 -0
  28. package/declarations/orbiter/orbiter.factory.did.js +124 -0
  29. package/declarations/satellite/index.d.ts +45 -0
  30. package/declarations/satellite/index.js +37 -0
  31. package/declarations/satellite/satellite.did.d.ts +201 -0
  32. package/declarations/satellite/satellite.factory.did.js +215 -0
  33. package/declarations/satellite/satellite.factory.did.mjs +215 -0
  34. package/dist/browser/index.js +2 -0
  35. package/dist/browser/index.js.map +7 -0
  36. package/dist/declarations/cmc/cmc.did +122 -0
  37. package/dist/declarations/cmc/cmc.did.d.ts +48 -0
  38. package/dist/declarations/cmc/cmc.factory.did.js +67 -0
  39. package/dist/declarations/cmc/index.d.ts +45 -0
  40. package/dist/declarations/cmc/index.js +37 -0
  41. package/dist/declarations/console/console.did.d.ts +71 -0
  42. package/dist/declarations/console/console.factory.did.js +79 -0
  43. package/dist/declarations/console/console.factory.did.mjs +79 -0
  44. package/dist/declarations/console/index.d.ts +45 -0
  45. package/dist/declarations/console/index.js +37 -0
  46. package/dist/declarations/ic/ic.did +195 -0
  47. package/dist/declarations/ic/ic.did.d.ts +208 -0
  48. package/dist/declarations/ic/ic.factory.did.js +274 -0
  49. package/dist/declarations/mission_control/index.d.ts +45 -0
  50. package/dist/declarations/mission_control/index.js +38 -0
  51. package/dist/declarations/mission_control/mission_control.did.d.ts +101 -0
  52. package/dist/declarations/mission_control/mission_control.factory.did.js +136 -0
  53. package/dist/declarations/observatory/index.d.ts +45 -0
  54. package/dist/declarations/observatory/index.js +38 -0
  55. package/dist/declarations/observatory/observatory.did.d.ts +86 -0
  56. package/dist/declarations/observatory/observatory.factory.did.js +95 -0
  57. package/dist/declarations/observatory/observatory.factory.did.mjs +95 -0
  58. package/dist/declarations/orbiter/index.d.ts +45 -0
  59. package/dist/declarations/orbiter/index.js +37 -0
  60. package/dist/declarations/orbiter/orbiter.did.d.ts +103 -0
  61. package/dist/declarations/orbiter/orbiter.factory.did.js +124 -0
  62. package/dist/declarations/satellite/index.d.ts +45 -0
  63. package/dist/declarations/satellite/index.js +37 -0
  64. package/dist/declarations/satellite/satellite.did.d.ts +201 -0
  65. package/dist/declarations/satellite/satellite.factory.did.js +215 -0
  66. package/dist/declarations/satellite/satellite.factory.did.mjs +215 -0
  67. package/dist/index.js +1 -0
  68. package/dist/node/index.mjs +4 -0
  69. package/dist/node/index.mjs.map +7 -0
  70. package/dist/types/index.d.ts +5 -0
  71. package/dist/types/services/analytics.services.d.ts +10 -0
  72. package/dist/types/services/proxy.services.d.ts +4 -0
  73. package/dist/types/types/env.d.ts +15 -0
  74. package/dist/types/types/post-message.d.ts +11 -0
  75. package/dist/types/types/proxy.d.ts +11 -0
  76. package/dist/types/types/track.d.ts +4 -0
  77. package/dist/types/utils/date.utils.d.ts +1 -0
  78. package/dist/types/utils/json.utils.d.ts +8 -0
  79. package/dist/types/workers/analytics.worker.d.ts +1 -0
  80. package/dist/workers/analytics.worker.js +6 -0
  81. package/dist/workers/analytics.worker.js.map +7 -0
  82. package/package.json +49 -0
@@ -0,0 +1,215 @@
1
+ // @ts-ignore
2
+ export const idlFactory = ({IDL}) => {
3
+ const CommitBatch = IDL.Record({
4
+ batch_id: IDL.Nat,
5
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
6
+ chunk_ids: IDL.Vec(IDL.Nat)
7
+ });
8
+ const DeleteControllersArgs = IDL.Record({
9
+ controllers: IDL.Vec(IDL.Principal)
10
+ });
11
+ const ControllerScope = IDL.Variant({
12
+ Write: IDL.Null,
13
+ Admin: IDL.Null
14
+ });
15
+ const Controller = IDL.Record({
16
+ updated_at: IDL.Nat64,
17
+ metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
18
+ created_at: IDL.Nat64,
19
+ scope: ControllerScope,
20
+ expires_at: IDL.Opt(IDL.Nat64)
21
+ });
22
+ const DelDoc = IDL.Record({updated_at: IDL.Opt(IDL.Nat64)});
23
+ const RulesType = IDL.Variant({Db: IDL.Null, Storage: IDL.Null});
24
+ const StorageConfig = IDL.Record({
25
+ rewrites: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
26
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))))
27
+ });
28
+ const Config = IDL.Record({storage: StorageConfig});
29
+ const Doc = IDL.Record({
30
+ updated_at: IDL.Nat64,
31
+ owner: IDL.Principal,
32
+ data: IDL.Vec(IDL.Nat8),
33
+ description: IDL.Opt(IDL.Text),
34
+ created_at: IDL.Nat64
35
+ });
36
+ const HttpRequest = IDL.Record({
37
+ url: IDL.Text,
38
+ method: IDL.Text,
39
+ body: IDL.Vec(IDL.Nat8),
40
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
41
+ });
42
+ const StreamingCallbackToken = IDL.Record({
43
+ token: IDL.Opt(IDL.Text),
44
+ sha256: IDL.Opt(IDL.Vec(IDL.Nat8)),
45
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
46
+ index: IDL.Nat64,
47
+ encoding_type: IDL.Text,
48
+ full_path: IDL.Text
49
+ });
50
+ const StreamingStrategy = IDL.Variant({
51
+ Callback: IDL.Record({
52
+ token: StreamingCallbackToken,
53
+ callback: IDL.Func([], [], ['query'])
54
+ })
55
+ });
56
+ const HttpResponse = IDL.Record({
57
+ body: IDL.Vec(IDL.Nat8),
58
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
59
+ streaming_strategy: IDL.Opt(StreamingStrategy),
60
+ status_code: IDL.Nat16
61
+ });
62
+ const StreamingCallbackHttpResponse = IDL.Record({
63
+ token: IDL.Opt(StreamingCallbackToken),
64
+ body: IDL.Vec(IDL.Nat8)
65
+ });
66
+ const InitAssetKey = IDL.Record({
67
+ token: IDL.Opt(IDL.Text),
68
+ collection: IDL.Text,
69
+ name: IDL.Text,
70
+ description: IDL.Opt(IDL.Text),
71
+ encoding_type: IDL.Opt(IDL.Text),
72
+ full_path: IDL.Text
73
+ });
74
+ const InitUploadResult = IDL.Record({batch_id: IDL.Nat});
75
+ const ListOrderField = IDL.Variant({
76
+ UpdatedAt: IDL.Null,
77
+ Keys: IDL.Null,
78
+ CreatedAt: IDL.Null
79
+ });
80
+ const ListOrder = IDL.Record({field: ListOrderField, desc: IDL.Bool});
81
+ const ListMatcher = IDL.Record({
82
+ key: IDL.Opt(IDL.Text),
83
+ description: IDL.Opt(IDL.Text)
84
+ });
85
+ const ListPaginate = IDL.Record({
86
+ start_after: IDL.Opt(IDL.Text),
87
+ limit: IDL.Opt(IDL.Nat64)
88
+ });
89
+ const ListParams = IDL.Record({
90
+ order: IDL.Opt(ListOrder),
91
+ owner: IDL.Opt(IDL.Principal),
92
+ matcher: IDL.Opt(ListMatcher),
93
+ paginate: IDL.Opt(ListPaginate)
94
+ });
95
+ const AssetKey = IDL.Record({
96
+ token: IDL.Opt(IDL.Text),
97
+ collection: IDL.Text,
98
+ owner: IDL.Principal,
99
+ name: IDL.Text,
100
+ description: IDL.Opt(IDL.Text),
101
+ full_path: IDL.Text
102
+ });
103
+ const AssetEncodingNoContent = IDL.Record({
104
+ modified: IDL.Nat64,
105
+ sha256: IDL.Vec(IDL.Nat8),
106
+ total_length: IDL.Nat
107
+ });
108
+ const AssetNoContent = IDL.Record({
109
+ key: AssetKey,
110
+ updated_at: IDL.Nat64,
111
+ encodings: IDL.Vec(IDL.Tuple(IDL.Text, AssetEncodingNoContent)),
112
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
113
+ created_at: IDL.Nat64
114
+ });
115
+ const ListResults = IDL.Record({
116
+ matches_pages: IDL.Opt(IDL.Nat64),
117
+ matches_length: IDL.Nat64,
118
+ items_page: IDL.Opt(IDL.Nat64),
119
+ items: IDL.Vec(IDL.Tuple(IDL.Text, AssetNoContent)),
120
+ items_length: IDL.Nat64
121
+ });
122
+ const CustomDomain = IDL.Record({
123
+ updated_at: IDL.Nat64,
124
+ created_at: IDL.Nat64,
125
+ bn_id: IDL.Opt(IDL.Text)
126
+ });
127
+ const ListResults_1 = IDL.Record({
128
+ matches_pages: IDL.Opt(IDL.Nat64),
129
+ matches_length: IDL.Nat64,
130
+ items_page: IDL.Opt(IDL.Nat64),
131
+ items: IDL.Vec(IDL.Tuple(IDL.Text, Doc)),
132
+ items_length: IDL.Nat64
133
+ });
134
+ const Permission = IDL.Variant({
135
+ Controllers: IDL.Null,
136
+ Private: IDL.Null,
137
+ Public: IDL.Null,
138
+ Managed: IDL.Null
139
+ });
140
+ const Rule = IDL.Record({
141
+ updated_at: IDL.Nat64,
142
+ max_size: IDL.Opt(IDL.Nat),
143
+ read: Permission,
144
+ created_at: IDL.Nat64,
145
+ write: Permission
146
+ });
147
+ const SetController = IDL.Record({
148
+ metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
149
+ scope: ControllerScope,
150
+ expires_at: IDL.Opt(IDL.Nat64)
151
+ });
152
+ const SetControllersArgs = IDL.Record({
153
+ controller: SetController,
154
+ controllers: IDL.Vec(IDL.Principal)
155
+ });
156
+ const SetDoc = IDL.Record({
157
+ updated_at: IDL.Opt(IDL.Nat64),
158
+ data: IDL.Vec(IDL.Nat8),
159
+ description: IDL.Opt(IDL.Text)
160
+ });
161
+ const SetRule = IDL.Record({
162
+ updated_at: IDL.Opt(IDL.Nat64),
163
+ max_size: IDL.Opt(IDL.Nat),
164
+ read: Permission,
165
+ write: Permission
166
+ });
167
+ const UploadChunk = IDL.Record({
168
+ content: IDL.Vec(IDL.Nat8),
169
+ batch_id: IDL.Nat,
170
+ order_id: IDL.Opt(IDL.Nat)
171
+ });
172
+ const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
173
+ return IDL.Service({
174
+ commit_asset_upload: IDL.Func([CommitBatch], [], []),
175
+ del_asset: IDL.Func([IDL.Text, IDL.Text], [], []),
176
+ del_assets: IDL.Func([IDL.Text], [], []),
177
+ del_controllers: IDL.Func(
178
+ [DeleteControllersArgs],
179
+ [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
180
+ []
181
+ ),
182
+ del_custom_domain: IDL.Func([IDL.Text], [], []),
183
+ del_doc: IDL.Func([IDL.Text, IDL.Text, DelDoc], [], []),
184
+ del_rule: IDL.Func([RulesType, IDL.Text, DelDoc], [], []),
185
+ get_config: IDL.Func([], [Config], []),
186
+ get_doc: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(Doc)], ['query']),
187
+ http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
188
+ http_request_streaming_callback: IDL.Func(
189
+ [StreamingCallbackToken],
190
+ [StreamingCallbackHttpResponse],
191
+ ['query']
192
+ ),
193
+ init_asset_upload: IDL.Func([InitAssetKey], [InitUploadResult], []),
194
+ list_assets: IDL.Func([IDL.Text, ListParams], [ListResults], ['query']),
195
+ list_controllers: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], ['query']),
196
+ list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
197
+ list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
198
+ list_rules: IDL.Func([RulesType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
199
+ set_config: IDL.Func([Config], [], []),
200
+ set_controllers: IDL.Func(
201
+ [SetControllersArgs],
202
+ [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
203
+ []
204
+ ),
205
+ set_custom_domain: IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
206
+ set_doc: IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []),
207
+ set_rule: IDL.Func([RulesType, IDL.Text, SetRule], [], []),
208
+ upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
209
+ version: IDL.Func([], [IDL.Text], ['query'])
210
+ });
211
+ };
212
+ // @ts-ignore
213
+ export const init = ({IDL}) => {
214
+ return [];
215
+ };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './browser/index.js';
@@ -0,0 +1,4 @@
1
+ import { createRequire as topLevelCreateRequire } from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ import{createRequire as w}from"module";var h=w(import.meta.url),p=e=>e==null,i=e=>!p(e),k=class extends Error{},s=(e,t)=>{if(p(e))throw new k(t)},c=e=>i(e)?[e]:[];var n,u=e=>{let{path:t}=e.worker??{},r=t===void 0?"./workers/analytics.worker.js":t;n=new Worker(r),g(e)},m=()=>{let e=new Proxy(history.pushState,{apply:(t,r,a)=>{t.apply(r,a),o()}});return history.pushState=e,addEventListener("popstate",o,{passive:!0}),{cleanup(){e=null,removeEventListener("popstate",o,!1)}}},l="Analytics worker not initialized. Did you call `initWorker`?",o=()=>{s(n,l);let{title:e,location:{href:t},referrer:r}=document,{innerWidth:a,innerHeight:y}=window,f={title:e,href:t,referrer:c(i(r)&&r!==""?r:void 0),device:{inner_width:a,inner_height:y}};n?.postMessage({msg:"junoTrackPageView",data:f})},d=e=>{s(n,l),n?.postMessage({msg:"junoTrackEvent",data:e})},g=e=>{s(n,l),n?.postMessage({msg:"junoInitEnvironment",data:e})};var A=async e=>{u(e);let{cleanup:t}=m();return o(),()=>{t()}};export{A as initOrbiter,d as trackEvent,o as trackPageView};
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
4
+ "sourcesContent": ["/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "import {assertNonNullish, nonNullish, toNullable} from '@junobuild/utils';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {PostMessageInitAnalytics, PostMessagePageView} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment) => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n initWorkerEnvironment(env);\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n trackPageView();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPageView, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPageView, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initWorker`?' as const;\n\nexport const trackPageView = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n\n const data: PostMessagePageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n }\n };\n\n worker?.postMessage({msg: 'junoTrackPageView', data});\n};\n\nexport const trackEvent = (data: TrackEvent) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoTrackEvent', data});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitAnalytics) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n", "import {initTrackPageViews, initWorker, trackPageView} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\nexport * from './types/proxy';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n initWorker(env);\n\n const {cleanup} = initTrackPageViews();\n\n // Tack first page\n trackPageView();\n\n return () => {\n cleanup();\n };\n};\n"],
5
+ "mappings": ";;gEACaA,EAAgBC,GAC3BA,GAAa,KAGFC,EAAiBD,GAC5B,CAACD,EAAUC,CAAQ,EAERE,EAAN,cAA2B,KAAM,CAAC,EAE5BC,EAG0B,CAAIC,EAAUC,IAA2B,CAC9E,GAAIN,EAAUK,CAAK,EACjB,MAAM,IAAIF,EAAaG,CAAO,CAElC,ECfaC,EAAiBF,GACrBH,EAAWG,CAAK,EAAI,CAACA,CAAK,EAAI,CAAC,ECExC,IAAIG,EAESC,EAAcC,GAAqB,CAC9C,GAAM,CAAC,KAAAC,CAAI,EAAuBD,EAAI,QAAU,CAAC,EAC3CE,EAAYD,IAAS,OAAY,gCAAkCA,EAEzEH,EAAS,IAAI,OAAOI,CAAS,EAE7BC,EAAsBH,CAAG,CAC3B,EAEaI,EAAqB,IAA6B,CAC7D,IAAIC,EAAkD,IAAI,MAAM,QAAQ,UAAW,CACjF,MAAO,CACLC,EACAC,EACAC,IACG,CACHF,EAAO,MAAMC,EAASC,CAAQ,EAC9BC,EAAc,CAChB,CACF,CAAC,EAED,eAAQ,UAAYJ,EAEpB,iBAAiB,WAAYI,EAAe,CAAC,QAAS,EAAI,CAAC,EAEpD,CACL,SAAU,CACRJ,EAAiB,KACjB,oBAAoB,WAAYI,EAAe,EAAK,CACtD,CACF,CACF,EAEMC,EACJ,+DAEWD,EAAgB,IAAM,CACjC,EAAiBX,EAAQY,CAAoB,EAE7C,GAAM,CACJ,MAAAC,EACA,SAAU,CAAC,KAAAC,CAAI,EACf,SAAAC,CACF,EAAI,SACE,CAAC,WAAAC,EAAY,YAAAC,CAAW,EAAI,OAE5BC,EAA4B,CAChC,MAAAL,EACA,KAAAC,EACA,SAAUK,EAAWC,EAAWL,CAAQ,GAAKA,IAAa,GAAKA,EAAW,MAAS,EACnF,OAAQ,CACN,YAAaC,EACb,aAAcC,CAChB,CACF,EAEAjB,GAAQ,YAAY,CAAC,IAAK,oBAAqB,KAAAkB,CAAI,CAAC,CACtD,EAEaG,EAAcH,GAAqB,CAC9C,EAAiBlB,EAAQY,CAAoB,EAE7CZ,GAAQ,YAAY,CAAC,IAAK,iBAAkB,KAAAkB,CAAI,CAAC,CACnD,EAEab,EAAyBH,GAAkC,CACtE,EAAiBF,EAAQY,CAAoB,EAE7CZ,GAAQ,YAAY,CAAC,IAAK,sBAAuB,KAAME,CAAG,CAAC,CAC7D,ECrEO,IAAMoB,EAAc,MAAOC,GAA0C,CAC1EC,EAAWD,CAAG,EAEd,GAAM,CAAC,QAAAE,CAAO,EAAIC,EAAmB,EAGrC,OAAAC,EAAc,EAEP,IAAM,CACXF,EAAQ,CACV,CACF",
6
+ "names": ["isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "worker", "initWorker", "env", "path", "workerUrl", "initWorkerEnvironment", "initTrackPageViews", "pushStateProxy", "target", "thisArg", "argArray", "trackPageView", "WORKER_UNDEFINED_MSG", "title", "href", "referrer", "innerWidth", "innerHeight", "data", "a", "o", "trackEvent", "initOrbiter", "env", "initWorker", "cleanup", "initTrackPageViews", "trackPageView"]
7
+ }
@@ -0,0 +1,5 @@
1
+ import type { Environment } from './types/env';
2
+ export { trackEvent, trackPageView } from './services/analytics.services';
3
+ export * from './types/env';
4
+ export * from './types/proxy';
5
+ export declare const initOrbiter: (env: Environment) => Promise<() => void>;
@@ -0,0 +1,10 @@
1
+ import type { Environment } from '../types/env';
2
+ import type { PostMessageInitAnalytics } from '../types/post-message';
3
+ import type { TrackEvent } from '../types/track';
4
+ export declare const initWorker: (env: Environment) => void;
5
+ export declare const initTrackPageViews: () => {
6
+ cleanup: () => void;
7
+ };
8
+ export declare const trackPageView: () => void;
9
+ export declare const trackEvent: (data: TrackEvent) => void;
10
+ export declare const initWorkerEnvironment: (env: PostMessageInitAnalytics) => void;
@@ -0,0 +1,4 @@
1
+ import type { EnvironmentProxy } from '../types/env';
2
+ import type { PageViewProxy, TrackEventProxy } from '../types/proxy';
3
+ export declare const setPageViewProxy: ({ pageViewProxyUrl, ...rest }: PageViewProxy & Pick<EnvironmentProxy, 'pageViewProxyUrl'>) => Promise<void>;
4
+ export declare const setTrackEventProxy: ({ trackEventProxyUrl, ...rest }: TrackEventProxy & Pick<EnvironmentProxy, 'trackEventProxyUrl'>) => Promise<void>;
@@ -0,0 +1,15 @@
1
+ export type EnvironmentWorkerPath = string;
2
+ export interface EnvironmentWorker {
3
+ path?: EnvironmentWorkerPath;
4
+ }
5
+ export interface EnvironmentProxyUrls {
6
+ pageViewProxyUrl?: string;
7
+ trackEventProxyUrl?: string;
8
+ }
9
+ export type EnvironmentProxy = {
10
+ orbiterId: string;
11
+ satelliteId: string;
12
+ } & EnvironmentProxyUrls;
13
+ export type Environment = EnvironmentProxy & {
14
+ worker?: EnvironmentWorker;
15
+ };
@@ -0,0 +1,11 @@
1
+ import type { SetPageView } from '../../declarations/orbiter/orbiter.did';
2
+ import type { EnvironmentProxy } from './env';
3
+ import type { TrackEvent } from './track';
4
+ export type PostMessageRequest = 'junoInitEnvironment' | 'junoTrackPageView' | 'junoTrackEvent';
5
+ export type PostMessageInitAnalytics = EnvironmentProxy;
6
+ export type PostMessagePageView = Omit<SetPageView, 'time_zone' | 'user_agent' | 'collected_at' | 'updated_at'>;
7
+ export type PostMessageTrackEvent = TrackEvent;
8
+ export interface PostMessage {
9
+ msg: PostMessageRequest;
10
+ data: PostMessageInitAnalytics | PostMessagePageView | PostMessageTrackEvent;
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { AnalyticKey, SetPageView, SetTrackEvent } from '../../declarations/orbiter/orbiter.did';
2
+ import type { EnvironmentProxy } from './env';
3
+ export type Proxy = {
4
+ key: AnalyticKey;
5
+ } & Omit<EnvironmentProxy, 'proxyUrl'>;
6
+ export type PageViewProxy = {
7
+ pageView: SetPageView;
8
+ } & Proxy;
9
+ export type TrackEventProxy = {
10
+ trackEvent: SetTrackEvent;
11
+ } & Proxy;
@@ -0,0 +1,4 @@
1
+ export interface TrackEvent {
2
+ name: string;
3
+ metadata?: Record<string, string>;
4
+ }
@@ -0,0 +1 @@
1
+ export declare const nowInBigIntNanoSeconds: () => bigint;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A parser that interprets revived BigInt, Principal, and Uint8Array when constructing JavaScript values or objects.
3
+ */
4
+ export declare const jsonReplacer: (_key: string, value: unknown) => unknown;
5
+ /**
6
+ * A function that alters the behavior of the stringification process for BigInt, Principal and Uint8Array.
7
+ */
8
+ export declare const jsonReviver: (_key: string, value: unknown) => unknown;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";(()=>{var _="abcdefghijklmnopqrstuvwxyz234567",g=Object.create(null);for(let e=0;e<_.length;e++)g[_[e]]=e;g[0]=g.o;g[1]=g.i;function C(e){let t=0,r=0,n="";function o(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=_[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=o(e[s]);return n+(t<0?_[r>>3]:"")}function V(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),o=0;function s(i){let a=g[i.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(i)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[o++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let i of e)s(i);return n.slice(0,o)}var X=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function j(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=X[s]^r>>>8}return(r^-1)>>>0}function z(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function T(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function R(e,t){z(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Z=e=>e instanceof Uint8Array;var A=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t,Q=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Q)throw new Error("Non little-endian hardware is not supported");function tt(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function k(e){if(typeof e=="string"&&(e=tt(e)),!Z(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var E=class{clone(){return this._cloneInto()}},Ut={}.toString;function M(e){let t=n=>e().update(k(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function et(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),x=n?4:0,f=n?0:4;e.setUint32(t+x,i,n),e.setUint32(t+f,a,n)}var U=class extends E{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=A(this.buffer)}update(t){T(this);let{view:r,buffer:n,blockLen:o}=this;t=k(t);let s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let x=A(t);for(;o<=s-i;i+=o)this.process(x,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){T(this),R(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let c=i;c<o;c++)r[c]=0;et(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=A(t),x=this.outputLen;if(x%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=x/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<f;c++)a.setUint32(4*c,l[c],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=i,o%r&&t.buffer.set(n),t}};var rt=(e,t,r)=>e&t^~e&r,nt=(e,t,r)=>e&t^e&r^t&r,ot=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),p=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),h=new Uint32Array(64),N=class extends U{constructor(){super(64,32,8,!1),this.A=p[0]|0,this.B=p[1]|0,this.C=p[2]|0,this.D=p[3]|0,this.E=p[4]|0,this.F=p[5]|0,this.G=p[6]|0,this.H=p[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:x}=this;return[t,r,n,o,s,i,a,x]}set(t,r,n,o,s,i,a,x){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=x|0}process(t,r){for(let c=0;c<16;c++,r+=4)h[c]=t.getUint32(r,!1);for(let c=16;c<64;c++){let m=h[c-15],y=h[c-2],v=d(m,7)^d(m,18)^m>>>3,P=d(y,17)^d(y,19)^y>>>10;h[c]=P+h[c-7]+v+h[c-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:x,G:f,H:l}=this;for(let c=0;c<64;c++){let m=d(a,6)^d(a,11)^d(a,25),y=l+m+rt(a,x,f)+ot[c]+h[c]|0,P=(d(n,2)^d(n,13)^d(n,22))+nt(n,o,s)|0;l=f,f=x,x=a,a=i+y|0,i=s,s=o,o=n,n=y+P|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,x=x+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,o,s,i,a,x,f,l)}roundClean(){h.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},L=class extends N{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};var D=M(()=>new L);function H(e){return D.create().update(new Uint8Array(e)).digest()}var st=2,F=4,it="aaaaa-aa",at=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},ct=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),u=class{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([F]))}static managementCanister(){return this.fromHex(it)}static selfAuthenticating(t){let r=H(t);return new this(new Uint8Array([...r,st]))}static from(t){if(typeof t=="string")return u.fromText(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new u(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(at(t))}static fromText(t){let r=t.toLowerCase().replace(/-/g,""),n=V(r);n=n.slice(4,n.length);let o=new this(n);if(o.toText()!==t)throw new Error(`Principal "${o.toText()}" does not have a valid checksum (original value "${t}" may not be a valid Principal ID).`);return o}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===F}toUint8Array(){return this._arr}toHex(){return ct(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,j(this._arr));let n=new Uint8Array(t),o=Uint8Array.from(this._arr),s=new Uint8Array([...n,...o]),a=C(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};var w=e=>e==null,I=e=>!w(e),xt=class extends Error{},S=(e,t)=>{if(w(e))throw new xt(t)},$=e=>I(e)?[e]:[];var O=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");var ft="__bigint__",dt="__principal__",bt="__uint8array__",B=(e,t)=>typeof t=="bigint"?{[ft]:`${t}`}:I(t)&&t instanceof u?{[dt]:t.toText()}:I(t)&&t instanceof Uint8Array?{[bt]:Array.from(t)}:t;var G="llaqvdlz6a-ew.a.run.app",ut=`https://pageview-${G}`,lt=`https://trackevent-${G}`,J=async({pageViewProxyUrl:e,...t})=>{if(!(await fetch(e??ut,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t},B)})).ok)throw new Error("Post page view error.")},q=async({trackEventProxyUrl:e,...t})=>{if(!(await fetch(e??lt,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t},B)})).ok)throw new Error("Post track event error.")};var Y=()=>BigInt(Date.now())*BigInt(1e6);onmessage=async({data:e})=>{let{msg:t,data:r}=e;switch(t){case"junoInitEnvironment":await yt(r);return;case"junoTrackPageView":await wt(r);return;case"junoTrackEvent":await mt(r);return}};var pt="Analytics worker not initialized. Did you set `satelliteId`?",ht="Analytics worker not initialized. Did you set `orbiterId`?",b,yt=async e=>{let{orbiterId:t,satelliteId:r}=e;S(t,ht),S(r,pt),b=e},gt=O(),wt=async e=>{if(w(b)||b?.orbiterId===void 0||b?.satelliteId===void 0)return;let{timeZone:t}=Intl.DateTimeFormat().resolvedOptions(),{userAgent:r}=navigator,n={...e,time_zone:t,user_agent:$(r),...W()};await J({key:K(b),pageView:n,...b})},mt=async({name:e,metadata:t})=>{if(w(b)||b?.orbiterId===void 0||b?.satelliteId===void 0)return;let r={name:e,metadata:w(t)?[]:[Object.entries(t??{})],...W()};await q({key:K(b),trackEvent:r,...b})},K=e=>({key:O(),session_id:gt,satellite_id:u.fromText(e.satelliteId)}),W=()=>({collected_at:Y(),updated_at:[]});})();
2
+ /*! Bundled license information:
3
+
4
+ @noble/hashes/esm/utils.js:
5
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
6
+ */
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../node_modules/@dfinity/principal/src/utils/base32.ts", "../../../../node_modules/@dfinity/principal/src/utils/getCrc.ts", "../../../../node_modules/@noble/hashes/src/_assert.ts", "../../../../node_modules/@noble/hashes/src/utils.ts", "../../../../node_modules/@noble/hashes/src/_sha2.ts", "../../../../node_modules/@noble/hashes/src/sha256.ts", "../../../../node_modules/@dfinity/principal/src/utils/sha224.ts", "../../../../node_modules/@dfinity/principal/src/index.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../../node_modules/nanoid/index.browser.js", "../../src/utils/json.utils.ts", "../../src/services/proxy.services.ts", "../../src/utils/date.utils.ts", "../../src/workers/analytics.worker.ts"],
4
+ "sourcesContent": ["// tslint:disable:no-bitwise\nconst alphabet = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// Build a lookup table for decoding.\nconst lookupTable: Record<string, number> = Object.create(null);\nfor (let i = 0; i < alphabet.length; i++) {\n lookupTable[alphabet[i]] = i;\n}\n\n// Add aliases for rfc4648.\nlookupTable['0'] = lookupTable.o;\nlookupTable['1'] = lookupTable.i;\n\n/**\n * @param input The input array to encode.\n * @returns A Base32 string encoding the input.\n */\nexport function encode(input: Uint8Array): string {\n // How many bits will we skip from the first byte.\n let skip = 0;\n // 5 high bits, carry from one byte to the next.\n let bits = 0;\n\n // The output string in base32.\n let output = '';\n\n function encodeByte(byte: number) {\n if (skip < 0) {\n // we have a carry from the previous byte\n bits |= byte >> -skip;\n } else {\n // no carry\n bits = (byte << skip) & 248;\n }\n\n if (skip > 3) {\n // Not enough data to produce a character, get us another one\n skip -= 8;\n return 1;\n }\n\n if (skip < 4) {\n // produce a character\n output += alphabet[bits >> 3];\n skip += 5;\n }\n\n return 0;\n }\n\n for (let i = 0; i < input.length; ) {\n i += encodeByte(input[i]);\n }\n\n return output + (skip < 0 ? alphabet[bits >> 3] : '');\n}\n\n/**\n * @param input The base32 encoded string to decode.\n */\nexport function decode(input: string): Uint8Array {\n // how many bits we have from the previous character.\n let skip = 0;\n // current byte we're producing.\n let byte = 0;\n\n const output = new Uint8Array(((input.length * 4) / 3) | 0);\n let o = 0;\n\n function decodeChar(char: string) {\n // Consume a character from the stream, store\n // the output in this.output. As before, better\n // to use update().\n let val = lookupTable[char.toLowerCase()];\n if (val === undefined) {\n throw new Error(`Invalid character: ${JSON.stringify(char)}`);\n }\n\n // move to the high bits\n val <<= 3;\n byte |= val >>> skip;\n skip += 5;\n\n if (skip >= 8) {\n // We have enough bytes to produce an output\n output[o++] = byte;\n skip -= 8;\n\n if (skip > 0) {\n byte = (val << (5 - skip)) & 255;\n } else {\n byte = 0;\n }\n }\n }\n\n for (const c of input) {\n decodeChar(c);\n }\n\n return output.slice(0, o);\n}\n", "// tslint:disable:no-bitwise\n\n// This file is translated to JavaScript from\n// https://lxp32.github.io/docs/a-simple-example-crc32-calculation/\nconst lookUpTable: Uint32Array = new Uint32Array([\n 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,\n 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,\n 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,\n 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,\n 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,\n 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,\n 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,\n 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,\n 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,\n 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,\n 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,\n 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,\n 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,\n 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,\n 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,\n 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,\n 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,\n 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,\n 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,\n 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,\n 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,\n 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,\n 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,\n 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,\n 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,\n 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,\n 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,\n 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,\n 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,\n 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,\n 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,\n 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,\n]);\n\n/**\n * Calculate the CRC32 of an ArrayBufferLike.\n * @param buf The BufferLike to calculate the CRC32 of.\n */\nexport function getCrc32(buf: ArrayBufferLike): number {\n const b = new Uint8Array(buf);\n let crc = -1;\n\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < b.length; i++) {\n const byte = b[i];\n const t = (byte ^ crc) & 0xff;\n crc = lookUpTable[t] ^ (crc >>> 8);\n }\n\n return (crc ^ -1) >>> 0;\n}\n", "function number(n: number) {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error(`Wrong positive integer: ${n}`);\n}\n\nfunction bool(b: boolean) {\n if (typeof b !== 'boolean') throw new Error(`Expected boolean, not ${b}`);\n}\n\nfunction bytes(b: Uint8Array | undefined, ...lengths: number[]) {\n if (!(b instanceof Uint8Array)) throw new Error('Expected Uint8Array');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);\n}\n\ntype Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\nfunction hash(hash: Hash) {\n if (typeof hash !== 'function' || typeof hash.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(hash.outputLen);\n number(hash.blockLen);\n}\n\nfunction exists(instance: any, checkFinished = true) {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\nfunction output(out: any, instance: any) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nexport { number, bool, bytes, hash, exists, output };\n\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n", "/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated, we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\nconst u8a = (a: any): a is Uint8Array => a instanceof Uint8Array;\n// Cast array to different type\nexport const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr: TypedArray) =>\n new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n\n// Cast array to view\nexport const createView = (arr: TypedArray) =>\n new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word: number, shift: number) => (word << (32 - shift)) | (word >>> shift);\n\n// big-endian hardware is rare. Just in case someone still decides to run hashes:\n// early-throw an error because we don't support BE yet.\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\nif (!isLE) throw new Error('Non little-endian hardware is not supported');\n\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n if (!u8a(bytes)) throw new Error('Uint8Array expected');\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const len = hex.length;\n if (len % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + len);\n const array = new Uint8Array(len / 2);\n for (let i = 0; i < array.length; i++) {\n const j = i * 2;\n const hexByte = hex.slice(j, j + 2);\n const byte = Number.parseInt(hexByte, 16);\n if (Number.isNaN(byte) || byte < 0) throw new Error('Invalid byte sequence');\n array[i] = byte;\n }\n return array;\n}\n\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => {};\n\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters: number, tick: number, cb: (i: number) => void) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n if (!u8a(data)) throw new Error(`expected Uint8Array, got ${typeof data}`);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));\n let pad = 0; // walk through each item, ensure they have proper type\n arrays.forEach((a) => {\n if (!u8a(a)) throw new Error('Uint8Array expected');\n r.set(a, pad);\n pad += a.length;\n });\n return r;\n}\n\n// For runtime check if class implements interface\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\nconst toStr = {}.toString;\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\nexport type CHash = ReturnType<typeof wrapConstructor>;\n\nexport function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>) {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "import { exists, output } from './_assert.js';\nimport { Hash, createView, Input, toBytes } from './utils.js';\n\n// Polyfill for Safari 14\nfunction setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n// Base SHA2 class (RFC 6234)\nexport abstract class SHA2<T extends SHA2<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(\n readonly blockLen: number,\n public outputLen: number,\n readonly padOffset: number,\n readonly isLE: boolean\n ) {\n super();\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\n", "import { SHA2 } from './_sha2.js';\nimport { rotr, wrapConstructor } from './utils.js';\n\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n\n// Choice: a ? b : c\nconst Chi = (a: number, b: number, c: number) => (a & b) ^ (~a & c);\n// Majority function, true if any two inpust is true\nconst Maj = (a: number, b: number, c: number) => (a & b) ^ (a & c) ^ (b & c);\n\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n// prettier-ignore\nconst IV = /* @__PURE__ */new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends SHA2<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = IV[0] | 0;\n B = IV[1] | 0;\n C = IV[2] | 0;\n D = IV[3] | 0;\n E = IV[4] | 0;\n F = IV[5] | 0;\n G = IV[6] | 0;\n H = IV[7] | 0;\n\n constructor() {\n super(64, 32, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n A = 0xc1059ed8 | 0;\n B = 0x367cd507 | 0;\n C = 0x3070dd17 | 0;\n D = 0xf70e5939 | 0;\n E = 0xffc00b31 | 0;\n F = 0x68581511 | 0;\n G = 0x64f98fa7 | 0;\n H = 0xbefa4fa4 | 0;\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n", "import { sha224 as jsSha224 } from '@noble/hashes/sha256';\n\n/**\n * Returns the SHA224 hash of the buffer.\n * @param data Arraybuffer to encode\n */\nexport function sha224(data: ArrayBuffer): Uint8Array {\n return jsSha224.create().update(new Uint8Array(data)).digest();\n}\n", "import { decode, encode } from './utils/base32';\nimport { getCrc32 } from './utils/getCrc';\nimport { sha224 } from './utils/sha224';\n\nconst SELF_AUTHENTICATING_SUFFIX = 2;\nconst ANONYMOUS_SUFFIX = 4;\n\nconst MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR = 'aaaaa-aa';\n\nconst fromHexString = (hexString: string) =>\n new Uint8Array((hexString.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)));\n\nconst toHexString = (bytes: Uint8Array) =>\n bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');\n\nexport class Principal {\n public static anonymous(): Principal {\n return new this(new Uint8Array([ANONYMOUS_SUFFIX]));\n }\n\n /**\n * Utility method, returning the principal representing the management canister, decoded from the hex string `'aaaaa-aa'`\n * @returns {Principal} principal of the management canister\n */\n public static managementCanister(): Principal {\n return this.fromHex(MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR);\n }\n\n public static selfAuthenticating(publicKey: Uint8Array): Principal {\n const sha = sha224(publicKey);\n return new this(new Uint8Array([...sha, SELF_AUTHENTICATING_SUFFIX]));\n }\n\n public static from(other: unknown): Principal {\n if (typeof other === 'string') {\n return Principal.fromText(other);\n } else if (\n typeof other === 'object' &&\n other !== null &&\n (other as Principal)._isPrincipal === true\n ) {\n return new Principal((other as Principal)._arr);\n }\n\n throw new Error(`Impossible to convert ${JSON.stringify(other)} to Principal.`);\n }\n\n public static fromHex(hex: string): Principal {\n return new this(fromHexString(hex));\n }\n\n public static fromText(text: string): Principal {\n const canisterIdNoDash = text.toLowerCase().replace(/-/g, '');\n\n let arr = decode(canisterIdNoDash);\n arr = arr.slice(4, arr.length);\n\n const principal = new this(arr);\n if (principal.toText() !== text) {\n throw new Error(\n `Principal \"${principal.toText()}\" does not have a valid checksum (original value \"${text}\" may not be a valid Principal ID).`,\n );\n }\n\n return principal;\n }\n\n public static fromUint8Array(arr: Uint8Array): Principal {\n return new this(arr);\n }\n\n public readonly _isPrincipal = true;\n\n protected constructor(private _arr: Uint8Array) {}\n\n public isAnonymous(): boolean {\n return this._arr.byteLength === 1 && this._arr[0] === ANONYMOUS_SUFFIX;\n }\n\n public toUint8Array(): Uint8Array {\n return this._arr;\n }\n\n public toHex(): string {\n return toHexString(this._arr).toUpperCase();\n }\n\n public toText(): string {\n const checksumArrayBuf = new ArrayBuffer(4);\n const view = new DataView(checksumArrayBuf);\n view.setUint32(0, getCrc32(this._arr));\n const checksum = new Uint8Array(checksumArrayBuf);\n\n const bytes = Uint8Array.from(this._arr);\n const array = new Uint8Array([...checksum, ...bytes]);\n\n const result = encode(array);\n const matches = result.match(/.{1,5}/g);\n if (!matches) {\n // This should only happen if there's no character, which is unreachable.\n throw new Error();\n }\n return matches.join('-');\n }\n\n public toString(): string {\n return this.toText();\n }\n\n /**\n * Utility method taking a Principal to compare against. Used for determining canister ranges in certificate verification\n * @param {Principal} other - a {@link Principal} to compare\n * @returns {'lt' | 'eq' | 'gt'} `'lt' | 'eq' | 'gt'` a string, representing less than, equal to, or greater than\n */\n public compareTo(other: Principal): 'lt' | 'eq' | 'gt' {\n for (let i = 0; i < Math.min(this._arr.length, other._arr.length); i++) {\n if (this._arr[i] < other._arr[i]) return 'lt';\n else if (this._arr[i] > other._arr[i]) return 'gt';\n }\n // Here, at least one principal is a prefix of the other principal (they could be the same)\n if (this._arr.length < other._arr.length) return 'lt';\n if (this._arr.length > other._arr.length) return 'gt';\n return 'eq';\n }\n\n /**\n * Utility method checking whether a provided Principal is less than or equal to the current one using the {@link Principal.compareTo} method\n * @param other a {@link Principal} to compare\n * @returns {boolean} boolean\n */\n public ltEq(other: Principal): boolean {\n const cmp = this.compareTo(other);\n return cmp == 'lt' || cmp == 'eq';\n }\n\n /**\n * Utility method checking whether a provided Principal is greater than or equal to the current one using the {@link Principal.compareTo} method\n * @param other a {@link Principal} to compare\n * @returns {boolean} boolean\n */\n public gtEq(other: Principal): boolean {\n const cmp = this.compareTo(other);\n return cmp == 'gt' || cmp == 'eq';\n }\n}\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "import {Principal} from '@dfinity/principal';\nimport {nonNullish} from '@junobuild/utils';\n\nconst JSON_KEY_BIGINT = '__bigint__';\nconst JSON_KEY_PRINCIPAL = '__principal__';\nconst JSON_KEY_UINT8ARRAY = '__uint8array__';\n\n/**\n * A parser that interprets revived BigInt, Principal, and Uint8Array when constructing JavaScript values or objects.\n */\nexport const jsonReplacer = (_key: string, value: unknown): unknown => {\n if (typeof value === 'bigint') {\n return {[JSON_KEY_BIGINT]: `${value}`};\n }\n\n if (nonNullish(value) && value instanceof Principal) {\n return {[JSON_KEY_PRINCIPAL]: value.toText()};\n }\n\n if (nonNullish(value) && value instanceof Uint8Array) {\n return {[JSON_KEY_UINT8ARRAY]: Array.from(value)};\n }\n\n return value;\n};\n\n/**\n * A function that alters the behavior of the stringification process for BigInt, Principal and Uint8Array.\n */\nexport const jsonReviver = (_key: string, value: unknown): unknown => {\n const mapValue = <T>(key: string): T => (value as Record<string, T>)[key];\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_BIGINT in value) {\n return BigInt(mapValue(JSON_KEY_BIGINT));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_PRINCIPAL in value) {\n return Principal.fromText(mapValue(JSON_KEY_PRINCIPAL));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_UINT8ARRAY in value) {\n return Uint8Array.from(mapValue(JSON_KEY_UINT8ARRAY));\n }\n\n return value;\n};\n", "import type {EnvironmentProxy} from '../types/env';\nimport type {PageViewProxy, TrackEventProxy} from '../types/proxy';\nimport {jsonReplacer} from '../utils/json.utils';\n\nconst JUNO_FUNCTION_PROXY_URL = 'llaqvdlz6a-ew.a.run.app';\nconst JUNO_PAGE_VIEW_PROXY_URL = `https://pageview-${JUNO_FUNCTION_PROXY_URL}`;\nconst JUNO_TRACK_EVENT_PROXY_URL = `https://trackevent-${JUNO_FUNCTION_PROXY_URL}`;\n\nexport const setPageViewProxy = async ({\n pageViewProxyUrl,\n ...rest\n}: PageViewProxy & Pick<EnvironmentProxy, 'pageViewProxyUrl'>) => {\n const response = await fetch(pageViewProxyUrl ?? JUNO_PAGE_VIEW_PROXY_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({...rest}, jsonReplacer)\n });\n\n if (!response.ok) {\n throw new Error(`Post page view error.`);\n }\n};\n\nexport const setTrackEventProxy = async ({\n trackEventProxyUrl,\n ...rest\n}: TrackEventProxy & Pick<EnvironmentProxy, 'trackEventProxyUrl'>) => {\n const response = await fetch(trackEventProxyUrl ?? JUNO_TRACK_EVENT_PROXY_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({...rest}, jsonReplacer)\n });\n\n if (!response.ok) {\n throw new Error(`Post track event error.`);\n }\n};\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {Principal} from '@dfinity/principal';\nimport {assertNonNullish, isNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {AnalyticKey, SetPageView, SetTrackEvent} from '../../declarations/orbiter/orbiter.did';\nimport {setPageViewProxy, setTrackEventProxy} from '../services/proxy.services';\nimport type {EnvironmentProxy} from '../types/env';\nimport type {\n PostMessage,\n PostMessageInitAnalytics,\n PostMessagePageView,\n PostMessageTrackEvent\n} from '../types/post-message';\nimport {nowInBigIntNanoSeconds} from '../utils/date.utils';\n\nonmessage = async ({data: dataMsg}: MessageEvent<PostMessage>) => {\n const {msg, data} = dataMsg;\n\n switch (msg) {\n case 'junoInitEnvironment':\n await init(data as PostMessageInitAnalytics);\n return;\n case 'junoTrackPageView':\n await trackPageView(data as PostMessagePageView);\n return;\n case 'junoTrackEvent':\n await trackPageEvent(data as PostMessageTrackEvent);\n return;\n }\n};\n\nconst SATELLITE_ID_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you set `satelliteId`?' as const;\n\nconst ORBITER_ID_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you set `orbiterId`?' as const;\n\nlet env: EnvironmentProxy | undefined;\n\nconst init = async (environment: PostMessageInitAnalytics) => {\n const {orbiterId, satelliteId} = environment;\n\n assertNonNullish(orbiterId, ORBITER_ID_UNDEFINED_MSG);\n assertNonNullish(satelliteId, SATELLITE_ID_UNDEFINED_MSG);\n\n env = environment;\n};\n\nconst sessionId = nanoid();\n\nconst trackPageView = async (data: PostMessagePageView) => {\n if (isNullish(env) || env?.orbiterId === undefined || env?.satelliteId === undefined) {\n return;\n }\n\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n const {userAgent} = navigator;\n\n const pageView: SetPageView = {\n ...data,\n time_zone: timeZone,\n user_agent: toNullable(userAgent),\n ...timestamp()\n };\n\n await setPageViewProxy({\n key: key(env),\n pageView,\n ...env\n });\n};\n\nconst trackPageEvent = async ({name, metadata}: PostMessageTrackEvent) => {\n if (isNullish(env) || env?.orbiterId === undefined || env?.satelliteId === undefined) {\n return;\n }\n\n const trackEvent: SetTrackEvent = {\n name,\n metadata: isNullish(metadata) ? [] : [Object.entries(metadata ?? {})],\n ...timestamp()\n };\n\n await setTrackEventProxy({\n key: key(env),\n trackEvent,\n ...env\n });\n};\n\nconst key = (env: EnvironmentProxy): AnalyticKey => ({\n key: nanoid(),\n session_id: sessionId,\n satellite_id: Principal.fromText(env.satelliteId)\n});\n\nconst timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n"],
5
+ "mappings": "mBACA,IAAMA,EAAW,mCAGXC,EAAsC,OAAO,OAAO,IAAI,EAC9D,QAASC,EAAI,EAAGA,EAAIF,EAAS,OAAQE,IACnCD,EAAYD,EAASE,CAAC,CAAC,EAAIA,EAI7BD,EAAY,CAAG,EAAIA,EAAY,EAC/BA,EAAY,CAAG,EAAIA,EAAY,EAMzB,SAAUE,EAAOC,EAAiB,CAEtC,IAAIC,EAAO,EAEPC,EAAO,EAGPC,EAAS,GAEb,SAASC,EAAWC,EAAY,CAS9B,OARIJ,EAAO,EAETC,GAAQG,GAAQ,CAACJ,EAGjBC,EAAQG,GAAQJ,EAAQ,IAGtBA,EAAO,GAETA,GAAQ,EACD,IAGLA,EAAO,IAETE,GAAUP,EAASM,GAAQ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MI,GACJ,+DAEIC,GACJ,6DAEEC,EAEEL,GAAO,MAAOM,GAA0C,CAC5D,GAAM,CAAC,UAAAC,EAAW,YAAAC,CAAW,EAAIF,EAEjCG,EAAiBF,EAAWH,EAAwB,EACpDK,EAAiBD,EAAaL,EAA0B,EAExDE,EAAMC,CACR,EAEMI,GAAYC,EAAO,EAEnBV,GAAgB,MAAOF,GAA8B,CACzD,GAAIa,EAAUP,CAAG,GAAKA,GAAK,YAAc,QAAaA,GAAK,cAAgB,OACzE,OAGF,GAAM,CAAC,SAAAQ,CAAQ,EAAI,KAAK,eAAe,EAAE,gBAAgB,EACnD,CAAC,UAAAC,CAAS,EAAI,UAEdC,EAAwB,CAC5B,GAAGhB,EACH,UAAWc,EACX,WAAYG,EAAWF,CAAS,EAChC,GAAGG,EAAU,CACf,EAEA,MAAMC,EAAiB,CACrB,IAAKC,EAAId,CAAG,EACZ,SAAAU,EACA,GAAGV,CACL,CAAC,CACH,EAEMH,GAAiB,MAAO,CAAC,KAAAkB,EAAM,SAAAC,CAAQ,IAA6B,CACxE,GAAIT,EAAUP,CAAG,GAAKA,GAAK,YAAc,QAAaA,GAAK,cAAgB,OACzE,OAGF,IAAMiB,EAA4B,CAChC,KAAAF,EACA,SAAUR,EAAUS,CAAQ,EAAI,CAAC,EAAI,CAAC,OAAO,QAAQA,GAAY,CAAC,CAAC,CAAC,EACpE,GAAGJ,EAAU,CACf,EAEA,MAAMM,EAAmB,CACvB,IAAKJ,EAAId,CAAG,EACZ,WAAAiB,EACA,GAAGjB,CACL,CAAC,CACH,EAEMc,EAAOd,IAAwC,CACnD,IAAKM,EAAO,EACZ,WAAYD,GACZ,aAAcc,EAAU,SAASnB,EAAI,WAAW,CAClD,GAEMY,EAAY,KAA0D,CAC1E,aAAcQ,EAAuB,EACrC,WAAY,CAAC,CACf",
6
+ "names": ["alphabet", "lookupTable", "i", "encode", "input", "skip", "bits", "output", "encodeByte", "byte", "decode", "decodeChar", "char", "val", "c", "lookUpTable", "getCrc32", "buf", "b", "crc", "i", "t", "bytes", "b", "lengths", "exists", "instance", "checkFinished", "output", "out", "bytes", "min", "u8a", "a", "createView", "arr", "rotr", "word", "shift", "isLE", "utf8ToBytes", "str", "toBytes", "data", "u8a", "Hash", "toStr", "wrapConstructor", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "h", "l", "SHA2", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "exists", "buffer", "toBytes", "len", "pos", "take", "dataView", "out", "output", "i", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "Chi", "a", "b", "c", "Maj", "SHA256_K", "IV", "SHA256_W", "SHA256", "SHA2", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "i", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "T2", "SHA224", "sha224", "wrapConstructor", "SHA224", "sha224", "data", "SELF_AUTHENTICATING_SUFFIX", "ANONYMOUS_SUFFIX", "MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR", "fromHexString", "hexString", "_a", "byte", "toHexString", "bytes", "str", "Principal", "_arr", "publicKey", "sha", "sha224", "other", "hex", "text", "canisterIdNoDash", "arr", "decode", "principal", "checksumArrayBuf", "getCrc32", "checksum", "array", "matches", "encode", "i", "cmp", "isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "nanoid", "size", "id", "byte", "JSON_KEY_BIGINT", "JSON_KEY_PRINCIPAL", "JSON_KEY_UINT8ARRAY", "jsonReplacer", "_key", "value", "o", "Principal", "JUNO_FUNCTION_PROXY_URL", "JUNO_PAGE_VIEW_PROXY_URL", "JUNO_TRACK_EVENT_PROXY_URL", "setPageViewProxy", "pageViewProxyUrl", "rest", "jsonReplacer", "setTrackEventProxy", "trackEventProxyUrl", "nowInBigIntNanoSeconds", "dataMsg", "msg", "data", "init", "trackPageView", "trackPageEvent", "SATELLITE_ID_UNDEFINED_MSG", "ORBITER_ID_UNDEFINED_MSG", "env", "environment", "orbiterId", "satelliteId", "s", "sessionId", "nanoid", "t", "timeZone", "userAgent", "pageView", "a", "timestamp", "setPageViewProxy", "key", "name", "metadata", "trackEvent", "setTrackEventProxy", "Principal", "nowInBigIntNanoSeconds"]
7
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@junobuild/analytics",
3
+ "version": "0.0.1",
4
+ "description": "Tracker for Juno analytics",
5
+ "author": "David Dal Busco (https://daviddalbusco.com)",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/node/index.mjs",
9
+ "module": "dist/browser/index.js",
10
+ "types": "dist/types/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE",
15
+ "declarations"
16
+ ],
17
+ "scripts": {
18
+ "rmdir": "node ../../scripts/rmdir.mjs",
19
+ "ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
20
+ "build": "npm run rmdir && mkdir -p dist && cp -R declarations dist && node esbuild.mjs && npm run ts-declaration",
21
+ "prepack": "npm run build"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/buildwithjuno/juno-js.git",
26
+ "directory": "packages/analytics"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/buildwithjuno/juno-js"
30
+ },
31
+ "keywords": [
32
+ "blockchain-as-a-service",
33
+ "baas",
34
+ "dapps",
35
+ "dapps-development",
36
+ "internet computer",
37
+ "smart-contracts",
38
+ "web3",
39
+ "marketing",
40
+ "statistics",
41
+ "analytics",
42
+ "metrics"
43
+ ],
44
+ "homepage": "https://juno.build",
45
+ "dependencies": {
46
+ "@junobuild/utils": "*",
47
+ "nanoid": "^4.0.2"
48
+ }
49
+ }