-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathdefinition-wrapper.js
More file actions
1027 lines (949 loc) · 36.2 KB
/
definition-wrapper.js
File metadata and controls
1027 lines (949 loc) · 36.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const terms = [
// Please add new terms in alphabetical order.
{
titles: ["Agent Endpoint"],
meaning:
"An Agent Endpoint is an ngrok endpoint created by an ngrok agent (or Agent SDK) that connects to an upstream service. The agent establishes a secure tunnel to the ngrok cloud, which forwards traffic to your local or remote service.",
link: "/docs/universal-gateway/agent-endpoints/",
pluralEnding: "s",
},
{
titles: ["ALPN"],
caseSensitive: true,
link: "https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation",
meaning:
"ALPN (Application-Layer Protocol Negotiation) allows a client and server to negotiate which application protocol (like HTTP/2 or HTTP/1.1) to use over a secure connection during the TLS handshake.",
},
{
titles: ["CEL"],
caseSensitive: true,
link: "https://github.com/google/cel-spec/tree/master?tab=readme-ov-file#common-expression-language",
meaning:
"CEL (Common Expression Language) is a fast, safe, and portable expression language developed by Google for evaluating expressions in configuration, policy, and runtime environments.",
},
{
titles: ["circuit breaker"],
meaning:
"A circuit breaker is a resilience pattern that monitors for failures and temporarily stops forwarding requests to an unhealthy upstream service, allowing it time to recover.",
link: "https://en.wikipedia.org/wiki/Circuit_breaker_design_pattern",
pluralEnding: "s",
},
{
titles: ["Cloud Endpoint"],
meaning:
"A Cloud Endpoint is a persistent ngrok endpoint that runs in ngrok's cloud service. Configured entirely in the ngrok dashboard or API, Cloud Endpoints can route traffic to upstream URLs and other endpoints, send custom responses, and more using Traffic Policy.",
link: "/docs/universal-gateway/cloud-endpoints/",
pluralEnding: "s",
},
{
titles: ["CORS"],
caseSensitive: true,
meaning:
"CORS (Cross-Origin Resource Sharing) is a browser security mechanism that controls which web domains are allowed to make requests to a different domain, preventing unauthorized cross-site interactions.",
link: "https://en.wikipedia.org/wiki/Cross-origin_resource_sharing",
},
{
titles: ["CRD"],
caseSensitive: true,
meaning:
"CustomResourceDefinitions allow users to extend the Kubernetes API by defining their own resource types.",
link: "https://kubernetes.io//tasks/extend-kubernetes/custom-resources/custom-resource-definitions/",
pluralEnding: "s",
},
{
titles: ["Endpoint Pooling", "Endpoint pool"],
meaning:
'When your create two ngrok endpoints with the same URL (and binding), those endpoints automatically form a "pool" and share incoming traffic.',
link: "/docs/universal-gateway/endpoint-pooling/",
pluralEnding: "s",
},
{
titles: ["Gateway API CRD", "Gateway API"],
glossaryIndex: 0,
link: "https://gateway-api.sigs.k8s.io/guides/",
meaning:
"Gateway API CRDs (Custom Resource Definitions) are a set of standardized, extensible resources that manage networking configurations like routing, gateways, and Traffic Policies.",
pluralEnding: "s",
},
{
titles: ["gRPC"],
caseSensitive: true,
meaning:
"gRPC is a high-performance, open-source remote procedure call (RPC) framework developed by Google that uses HTTP/2 for transport and Protocol Buffers for serialization.",
link: "https://grpc.io/",
},
{
titles: ["Helm"],
meaning:
"Helm is a package manager for Kubernetes that simplifies the deployment and management of applications on Kubernetes clusters.",
link: "https://helm.sh/",
},
{
titles: ["HMAC"],
caseSensitive: true,
meaning:
"HMAC (Hash-based Message Authentication Code) is a cryptographic technique that uses a secret key and a hash function to verify both the integrity and authenticity of a message.",
link: "https://en.wikipedia.org/wiki/HMAC",
},
{
titles: ["IdP"],
caseSensitive: true,
meaning:
"An IdP (Identity Provider) is a service that stores and manages digital identities, authenticating users and providing identity information to other applications via protocols like SAML or OIDC.",
link: "https://en.wikipedia.org/wiki/Identity_provider",
},
{
titles: ["Ingress"],
meaning:
"An ingress is an entry point into a network for traffic from outside of the network.",
pluralEnding: "es",
},
{
titles: ["Internal Endpoint"],
meaning:
"Internal Endpoints are only accessible to traffic from your other ngrok endpoints, enabling service-to-service communication without exposing traffic to the public internet. Internal Endpoints use the .internal top-level domain.",
link: "/docs/universal-gateway/internal-endpoints/",
pluralEnding: "s",
},
{
titles: ["IP CIDR", "CIDR"],
glossaryIndex: 1,
meaning:
"Classless Inter-Domain Routing is a method used to allocate IP addresses more efficiently and route IP packets more flexibly than older class-based systems.",
link: "https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing",
pluralEnding: "s",
},
{
titles: ["JIT provisioning"],
meaning:
"Just-In-Time Single Sign-On Provisioning is a user account provisioning method that automatically creates (or updates) user accounts at the time of login via Single Sign-On, rather than pre-creating all user accounts in advance.",
link: "https://en.wikipedia.org/wiki/System_for_Cross-domain_Identity_Management",
},
{
titles: ["JWT"],
caseSensitive: true,
meaning:
"A JWT (JSON Web Token) is a compact, URL-safe token format used to securely transmit information between parties as a JSON object, commonly used for authentication and authorization.",
link: "https://en.wikipedia.org/wiki/JSON_Web_Token",
pluralEnding: "s",
},
{
titles: ["K8", "K8s"],
glossaryIndex: 1,
meaning: "K8s is an industry-standard abbreviation for Kubernetes.",
pluralEnding: "s",
link: "https://kubernetes.io/docs/concepts/overview/",
},
{
titles: ["Let's Encrypt", "Let's Encrypt", "LetsEncrypt", "Lets encrypt"],
meaning:
"A free, automated, and open certificate authority (CA) that provides digital certificates to enable HTTPS (SSL/TLS) for websites.",
link: "https://letsencrypt.org/about/",
},
{
titles: ["MCP server", "MCP"],
glossaryIndex: 1,
meaning:
"MCP (Model Context Protocol) is an open standard that allows AI models to access external data, tools, and services, and potentially use them to automate workflows.",
link: "https://en.wikipedia.org/wiki/Model_Context_Protocol",
pluralEnding: "s",
},
{
titles: ["mTLS"],
caseSensitive: true,
meaning:
"mTLS (Mutual TLS) is a security protocol where both the client and server authenticate each other using TLS certificates, ensuring both parties are who they claim to be.",
link: "https://en.wikipedia.org/wiki/Mutual_authentication",
},
{
titles: ["ngrok Agent"],
meaning:
"The ngrok agent is a lightweight command-line application that you install on your machine or server. It establishes secure, outbound-only connections to the ngrok cloud to create endpoints for your upstream services.",
link: "/docs/agent/",
},
{
titles: ["OAuth"],
caseSensitive: true,
meaning:
"OAuth is an open standard for authorization that allows users to grant third-party applications limited access to their resources without sharing their credentials.",
link: "https://en.wikipedia.org/wiki/OAuth",
},
{
titles: ["OIDC"],
meaning:
"OpenID Connect (OIDC) is an authentication protocol that enables third-party applications to confirm a user's identity and access basic profile details through a single sign-on (SSO) process.",
link: "https://en.wikipedia.org/wiki/OpenID",
},
{
titles: ["OWASP"],
caseSensitive: true,
meaning:
"The Open Web Application Security Project is a non-profit organization dedicated to improving software security through providing resources, tools, and community support.",
link: "https://owasp.org/about/",
},
{
titles: ["Point of Presence", "PoP"],
meaning:
"A Point of Presence (PoP) is a physical location in ngrok's global network where traffic enters the ngrok cloud. ngrok operates PoPs around the world to minimize latency for end users.",
link: "/docs/universal-gateway/points-of-presence/",
pluralEnding: "s",
},
{
titles: ["RBAC"],
caseSensitive: true,
meaning:
"RBAC (Role-Based Access Control) is a method of restricting system access based on the roles assigned to individual users within an organization.",
link: "https://en.wikipedia.org/wiki/Role-based_access_control",
},
{
titles: ["reverse proxy", "reverse proxies", "Reverse Proxy"],
glossaryIndex: 2,
link: "https://en.wikipedia.org/wiki/Reverse_proxy",
meaning:
"Reverse proxies are an extra security layer between public traffic and your internal services. They live on servers or cloud services, and they intercept and forward traffic to upstream services.",
},
{
titles: ["Service User", "Service Users"],
caseSensitive: false,
meaning:
"A Service User (previously called a Bot User) is a service account that owns a set of credentials (authtokens, API keys, and SSH keys) independently of a person. This is useful for automated systems that programmatically interact with your ngrok accounts.",
link: "/iam/service-users/",
},
{
titles: ["SAML"],
caseSensitive: true,
meaning:
"SAML (Security Assertion Markup Language) is an open standard for exchanging authentication and authorization data between an identity provider and a service provider, commonly used for enterprise single sign-on.",
link: "https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language",
},
{
titles: ["SCIM"],
caseSensitive: true,
meaning:
"SCIM (System for Cross-domain Identity Management) is an open standard for automating the exchange of user identity information between identity domains or IT systems.",
link: "https://en.wikipedia.org/wiki/System_for_Cross-domain_Identity_Management",
},
{
titles: ["Shadow IT", "shadow IT"],
meaning:
"Shadow IT refers to IT systems, software, and cloud services used by individuals within an organization without the IT department's knowledge or approval.",
link: "https://en.wikipedia.org/wiki/Shadow_IT",
},
{
titles: ["SSO"],
caseSensitive: true,
meaning:
"SSO (Single Sign-On) is an authentication method that allows users to log in once and gain access to multiple related applications or systems without re-entering credentials.",
link: "https://en.wikipedia.org/wiki/Single_sign-on",
},
{
titles: ["SNI"],
caseSensitive: true,
link: "https://en.wikipedia.org/wiki/Server_Name_Indication",
meaning:
"SNI (Server Name Indication) is a TLS extension that allows a client to specify the hostname it is trying to connect to during the TLS handshake, enabling servers to present the correct SSL/TLS certificate for that hostname.",
},
{
titles: [
"TCP-KeepAlive",
"TCP KeepAlive",
"TCP Keep-Alive",
"TCP Keep Alive",
],
meaning:
"TCP KeepAlive enables TCP connections to remain active even when no data is exchanged between the connected endpoints.",
link: "https://en.wikipedia.org/wiki/Keepalive",
},
{
titles: ["TLS Certificate"],
pluralEnding: "s",
link: "https://en.wikipedia.org/wiki/Transport_Layer_Security",
meaning:
"A TLS certificate (or SSL certificate) is a digital certificate that ensure your connection to a website or server is securly encrypted.",
},
{
titles: ["TLS Termination"],
meaning:
"TLS (Transport Layer Security) termination is the process of decrypting incoming TLS traffic at a server or load balancer before passing the unencrypted traffic to internal systems.",
link: "/docs/universal-gateway/tls-termination/",
},
{
titles: ["Traffic Policy", "Traffic Policies"],
meaning:
"Traffic Policy is a configuration language that enables you to filter, match, manage, and orchestrate traffic to your endpoints. For example, you can add authentication, send custom responses, rate limit traffic, and more.",
link: "/docs/traffic-policy/",
},
{
titles: ["upstream"],
meaning:
"An upstream is the service, server, or URL that ngrok forwards incoming traffic to. When you create an ngrok endpoint, the upstream is the destination that ultimately handles the request.",
},
{
titles: ["v2"],
caseSensitive: true,
meaning: "v2 is shorthand for the second major version of the ngrok Agent.",
link: "/docs/agent/config/v2",
},
{
titles: ["v3"],
caseSensitive: true,
meaning: "v3 is shorthand for the third major version of the ngrok Agent.",
link: "/docs/agent/config/v3",
},
{
titles: ["WAF"],
link: "https://en.wikipedia.org/wiki/Web_application_firewall",
caseSensitive: true,
meaning:
"A web application firewall (WAF) is an intermediary service in the cloud or on a server that protects web services by filtering and monitoring HTTP traffic.",
},
{
titles: ["WebSocket"],
meaning:
"WebSocket is a communication protocol that provides full-duplex (two-way) communication channels over a single TCP connection, enabling real-time data exchange between a client and server.",
link: "https://en.wikipedia.org/wiki/WebSocket",
pluralEnding: "s",
},
];
// Terms specific to the pricing and limits section.
const pricingTerms = [
{
titles: ["Online endpoints"],
meaning: "The number of endpoints you can have online at the same time.",
link: "/docs/universal-gateway/agent-endpoints/",
},
{
titles: ["Development endpoint hours"],
meaning:
"Public endpoints started with your development domain do not accrue endpoint hours.",
link: "/docs/pricing-limits/#limits-and-licensing",
},
{
titles: ["Active endpoint hours"],
meaning: "An endpoint is active if it has outgoing traffic during the hour.",
link: "/docs/pricing-limits/#limits-and-licensing",
},
{
titles: ["Endpoint protocols"],
meaning:
"These are the different protocols available to you as a subscriber of each plan.",
link: "/docs/universal-gateway/agent-endpoints#protocols%2C-binding-and-pooling"
},
{
titles: ["Endpoint hours"],
meaning:
"The amount of time your endpoints are online.",
},
{
titles: ["Load balancing"],
meaning: "Load balancing at ngrok is called endpoint pooling.",
link: "/docs/universal-gateway/endpoint-pooling"
},
{
titles: ["Domains"],
meaning: "Domains you own registered in the ngrok dashboard.",
link: "/docs/universal-gateway/domains/",
},
{
titles: ["Development domain"],
meaning:
"Your development domain is specific to your account, and does not incur usage charges. You can use anything for free on your sandbox domain within your account's limits.",
link: "/docs/universal-gateway/domains/",
},
{
titles: ["ngrok-branded domains"],
meaning: "Use any ngrok-branded domain that you pick from ngrok's pool.",
link: "/docs/universal-gateway/domains/",
},
{
titles: ["Traffic Policy Units"],
meaning: "Traffic Processing Units (TPUs) are ngrok’s usage-based metric for measuring the work your Traffic Policies perform.",
link: "/docs/pricing-limits/traffic-policy-unit-pricing"
},
{
titles: ["Bring your own custom domains"],
meaning: "Use any custom domain name that you already own with ngrok.",
link: "/docs/universal-gateway/custom-domains/",
},
{
titles: ["Wildcard Domains"],
meaning:
"You can create an endpoint which will receive traffic for all of the subdomains matching a given wildcard domain like *.example.com.",
link: "/docs/universal-gateway/http/#wildcard-endpoints",
},
{
titles: ["TCP Addresses"],
meaning:
"TCP Addresses enable you to create public TCP Endpoints on a fixed address.",
link: "/docs/universal-gateway/tcp-addresses/",
},
{
titles: ["Data transfer out"],
meaning:
"The total volume of data transferred outbound from ngrok's network to clients, including traffic forwarded to agents.",
link: "/docs/pricing-limits/#limits-and-licensing",
},
{
titles: ["Requests to HTTP/s endpoints"],
meaning:
"The maximum number of HTTP/s requests a client can make to an account's endpoints in a month.",
link: "/docs/universal-gateway/http/",
},
{
titles: ["Connections to TCP / TLS endpoints"],
meaning:
"The maximum number of TCP/TLS connections a client can make to an account's endpoints in a month.",
link: "/docs/universal-gateway/tcp/",
},
{
titles: ["HTTP Requests"],
meaning:
"The maximum number of HTTP requests across all endpoints per minute.",
link: "/docs/pricing-limits/how-ngrok-charges/",
},
{
titles: ["TCP Connections"],
meaning:
"The maximum number of TCP connections across all endpoints per minute.",
link: "/docs/pricing-limits/how-ngrok-charges/",
},
// Universal Gateway > TLS
{
titles: ["Bring your own certificates"],
meaning:
"Upload your own TLS certificates if you don't want to use the TLS certificates that ngrok automatically provisions for you.",
link: "/docs/universal-gateway/tls/",
},
{
titles: ["End to End TLS"],
meaning:
"Terminate TLS at your upstream service or at the ngrok agent to achieve end-to-end encryption.",
link: "/docs/universal-gateway/tls-termination/",
},
{
titles: ["Mutual TLS"],
meaning:
"Mutual TLS Authentication (mTLS) is a network security protocol that ensures both the client and server authenticate each other using digital certificates.",
link: "/docs/traffic-policy/",
},
// Traffic Policy
{
titles: ["Traffic Policy Units (TPUs)"],
meaning:
"This is a combination of the actions, macros, and variables applied to a request. WAF, mTLS, and more are included in TPUs.",
link: "/docs/pricing-limits/traffic-policy-unit-pricing/",
},
{
titles: ["Traffic Identities"],
meaning:
"OAuth/SAML/OIDC. This is calculated by the number of end users that authenticate into your app or service via the traffic policy action.",
link: "/docs/traffic-policy/",
},
// Traffic Observability
{
titles: ["Traffic Inspector Retention"],
meaning:
"This is the number of hours ngrok retains your traffic data in traffic inspector.",
link: "/docs/obs/traffic-inspection",
},
{
titles: ["Traffic Log Exporting"],
meaning:
"Export event logs when traffic transits through your endpoints to S3, Datadog, Azure Logs, CloudWatch Logs + more.",
link: "/docs/obs/",
},
// Secure Tunnels
{
titles: ["Concurrent Agents"],
meaning:
"The maximum number of ngrok agents that can be simultaneously connected to the ngrok cloud service under a single account.",
link: "/docs/agent/",
},
{
titles: ["Dedicated Agent Connect IPs"],
meaning: "Get a constant, dedicated IP for your account's agents.",
link: "/docs/agent/",
},
{
titles: ["Custom Agent Connect URLs"],
meaning: "Customize the URL that the agent connects to.",
link: "/docs/agent/",
},
{
titles: ["Remote Agent Update Operations"],
meaning: "Run ngrok in the background as a service.",
link: "/docs/agent/",
},
// Identity & Access
{
titles: ["Users"],
meaning: "Members of your account that can view or create endpoints.",
link: "/docs/iam/users/",
},
{
titles: ["Service Users"],
meaning:
"Service users are accounts for automated systems that programmatically interact with your ngrok accounts either by starting ngrok Agents or making requests to the API.",
link: "/docs/iam/service-users/",
},
{
titles: ["SSO/RBAC"],
meaning:
"Federate auth to your Identity Provider (IdP) with SAML or OpenID Connect.",
link: "/docs/iam/sso/",
},
{
titles: ["Identity and Access Governance Suite"],
meaning:
"SCIM, Domain Controls, Account-Wide IP Restrictions, Audit Logs.",
link: "/docs/iam/",
},
{
titles: ["Authtoken ACLs"],
meaning:
"Authtoken ACLs restrict what endpoints an ngrok agent can create when using that authtoken.",
link: "/docs/agent/config/",
},
// Support
{
titles: ["Basic support"],
meaning: "Email support and best-effort response times.",
},
{
titles: ["Slack and MS Teams"],
meaning: "Dedicated channel with 24 hour response SLA.",
},
{
titles: ["Dedicated On-Call"],
meaning: "Committed/Contractual Uptime SLA and Support SLA.",
},
// Compliance
{
titles: ["Region-specific routing"],
meaning:
"Configure your domains to only route traffic through specific geographic regions.",
},
{
titles: ["HIPAA / BAAs"],
meaning:
"HIPAA compliance is built in: ngrok handles the BAA so you can focus on building the app.",
},
{
titles: ["SOC2"],
meaning: "Independent verification that your data is secure.",
},
{
titles: ["Security questionnaires"],
meaning:
"If your team requires a security questionnaire, ngrok can prepare it.",
},
{
titles: ["Invoicing"],
meaning:
"If your team requires an invoice for billing purposes, ngrok can send it.",
},
];
function wrapTermsOnLoad() {
// Get page title to check against
const pageTitle = document.getElementById('page-title');
const pageTitleText = pageTitle ? pageTitle.textContent.toLowerCase() : '';
// Pricing terms are only applied on pricing-limits pages
const isPricingPage = window.location.pathname.includes('/pricing-limits');
const activeTerms = isPricingPage ? [...terms, ...pricingTerms] : terms;
console.log("Is pricing page", isPricingPage)
// Get all mdx-content containers
const mdxContainers = document.querySelectorAll('div[class*="mdx-content"]');
// Track which terms have been wrapped to only wrap the first instance
const wrappedTerms = new Set();
mdxContainers.forEach((container, containerIndex) => {
// Find all p spans and li elements within this container
const pSpans = container.querySelectorAll('span[data-as="p"]');
const tableCells = container.querySelectorAll('strong');
const listItems = container.querySelectorAll('li');
const elementsToProcess = [...pSpans, ...tableCells, ...listItems];
elementsToProcess.forEach((element, elementIndex) => {
const elementText = element.textContent;
// Skip if element is inside a link, heading, or code block
if (isInsideExcludedElement(element)) {
return;
}
activeTerms.forEach(termObj => {
termObj.titles.forEach(termTitle => {
// Skip if this term is already wrapped or if it appears in the page title
if (wrappedTerms.has(termTitle) || pageTitleText.includes(termTitle.toLowerCase())) {
return;
}
// Skip if we're already on the page that this term links to
if (termObj.link && window.location.pathname.includes(termObj.link)) {
return;
}
// Create regex for term matching (no global flag to replace only first occurrence)
const flags = termObj.caseSensitive ? '' : 'i';
const regex = new RegExp(`\\b${escapeRegex(termTitle)}\\b`, flags);
// Check if term exists in this element
if (regex.test(element.textContent)) {
// Use text node replacement instead of innerHTML replacement
if (replaceInTextNodes(element, regex, termTitle, termObj)) {
wrappedTerms.add(termTitle);
return; // Exit early since we only want first instance
}
}
});
});
});
});
}
function escapeRegex(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function isInsideExcludedElement(element) {
// List of tag names to exclude
const excludedTags = ['A', 'BUTTON', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'PRE', 'CODE'];
// Check current element and all ancestors
let current = element;
while (current && current !== document.body) {
if (excludedTags.includes(current.tagName)) {
return true;
}
// Check if parent has data-component-part="tabs-list"
if (current.getAttribute('data-component-part') === 'tabs-list') {
return true;
}
current = current.parentElement;
}
return false;
}
function replaceInTextNodes(element, regex, termTitle, termObj) {
// Get all text nodes within the element
const textNodes = [];
const walker = document.createTreeWalker(
element,
NodeFilter.SHOW_TEXT,
{
acceptNode: function(node) {
// Skip text nodes that are inside excluded elements
if (isInsideExcludedElement(node.parentElement) || window?.location?.pathname?.includes("glossary")) {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
}
);
let currentNode;
while (currentNode = walker.nextNode()) {
textNodes.push(currentNode);
}
// Find the first text node that contains our term
for (let textNode of textNodes) {
const text = textNode.textContent;
if (regex.test(text)) {
// Create the replacement elements
const definition = termObj.meaning || 'Definition not available';
const link = termObj.link || '';
const button = document.createElement('button');
button.setAttribute('data-state', 'closed');
button.setAttribute('data-tooltip', definition);
if (link) {
button.setAttribute('data-link', link);
}
button.style.display = 'inline';
button.style.textAlign = 'inherit';
const span = document.createElement('span');
span.className = 'tooltip underline decoration-dotted decoration-2 underline-offset-4 decoration-gray-400 dark:decoration-gray-500';
// Preserve styling from parent elements (italics, bold, etc.)
copyParentStyles(textNode.parentElement, span);
// Split the text and create new nodes
const match = text.match(regex);
if (match) {
const matchText = match[0];
const beforeText = text.substring(0, match.index);
const afterText = text.substring(match.index + matchText.length);
span.textContent = matchText;
button.appendChild(span);
// Replace the text node with the new structure
const parent = textNode.parentNode;
if (beforeText) {
parent.insertBefore(document.createTextNode(beforeText), textNode);
}
parent.insertBefore(button, textNode);
if (afterText) {
parent.insertBefore(document.createTextNode(afterText), textNode);
}
parent.removeChild(textNode);
// Add tooltip behavior
addTooltipBehavior(button);
return true; // Successfully replaced
}
}
}
return false; // No replacement made
}
function copyParentStyles(sourceElement, targetElement) {
// Walk up the DOM tree to find styling elements
let current = sourceElement;
const stylesToPreserve = {
fontStyle: '',
fontWeight: '',
textDecoration: ''
};
while (current && current !== document.body) {
const computedStyle = window.getComputedStyle(current);
// Preserve italic styling from <em>, <i>, or CSS
if (computedStyle.fontStyle === 'italic' && !stylesToPreserve.fontStyle) {
stylesToPreserve.fontStyle = 'italic';
}
// Preserve bold styling from <strong>, <b>, or CSS
const fontWeight = computedStyle.fontWeight;
if ((fontWeight === 'bold' || parseInt(fontWeight) >= 600) && !stylesToPreserve.fontWeight) {
stylesToPreserve.fontWeight = fontWeight;
}
// Preserve underline styling from <u> or CSS (but not our tooltip underline)
const textDecoration = computedStyle.textDecoration;
if (textDecoration && textDecoration !== 'none' && !current.classList.contains('tooltip')) {
stylesToPreserve.textDecoration = textDecoration;
}
current = current.parentElement;
}
// Apply the preserved styles to the target element
if (stylesToPreserve.fontStyle) {
targetElement.style.fontStyle = stylesToPreserve.fontStyle;
}
if (stylesToPreserve.fontWeight) {
targetElement.style.fontWeight = stylesToPreserve.fontWeight;
}
if (stylesToPreserve.textDecoration) {
targetElement.style.textDecoration = stylesToPreserve.textDecoration;
}
}
function addTooltipBehavior(button) {
const tooltip = button.getAttribute('data-tooltip');
const link = button.getAttribute('data-link');
if (!tooltip) return;
let tooltipElement = null;
let hideTimeout = null;
function showTooltip(e) {
// Clear any pending hide timeout
if (hideTimeout) {
clearTimeout(hideTimeout);
hideTimeout = null;
}
// Remove any existing tooltip
hideTooltip();
// Create tooltip element
tooltipElement = document.createElement('div');
// Create the main content
const contentDiv = document.createElement('div');
contentDiv.textContent = tooltip;
tooltipElement.appendChild(contentDiv);
// Add "Learn More" link if there's a link
if (link) {
const learnMoreDiv = document.createElement('div');
learnMoreDiv.style.cssText = `
margin-top: 8px !important;
padding-top: 8px !important;
border-top: 1px solid light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.2)) !important;
`;
const learnMoreLink = document.createElement('a');
learnMoreLink.href = link;
learnMoreLink.style.cssText = `
color: light-dark(#1e40af, #60a5fa) !important;
text-decoration: none !important;
cursor: pointer !important;
font-size: 14px !important;
display: inline-flex !important;
align-items: center !important;
gap: 4px !important;
`;
// Add hover effects
learnMoreLink.addEventListener('mouseenter', () => {
learnMoreLink.style.textDecoration = 'underline';
});
learnMoreLink.addEventListener('mouseleave', () => {
learnMoreLink.style.textDecoration = 'none';
});
// Determine if URL is absolute or relative
const isInternalLink = link.startsWith("/");
// Create appropriate SVG icon
const iconSvg = document.createElement('span');
iconSvg.innerHTML = `
<div>
${isInternalLink
? `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-link2-icon lucide-link-2"><path d="M9 17H7A5 5 0 0 1 7 7h2"/><path d="M15 7h2a5 5 0 1 1 0 10h-2"/><line x1="8" x2="16" y1="12" y2="12"/></svg>`
: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link-icon lucide-external-link"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg>`}
</div>`;
// Add text and icon to the link
learnMoreLink.appendChild(document.createTextNode('Learn More'));
learnMoreLink.appendChild(iconSvg);
// Handle link clicks
learnMoreLink.addEventListener('click', (e) => {
e.preventDefault();
if (link.startsWith('http')) {
window.open(link, '_blank');
} else {
window.location.href = link;
}
hideTooltip();
});
learnMoreDiv.appendChild(learnMoreLink);
tooltipElement.appendChild(learnMoreDiv);
}
// Determine if we're on a mobile device
const isMobile = window.innerWidth <= 768;
const maxWidth = isMobile ? 'calc(100vw - 32px)' : 'min(320px, 90vw)';
// Style with light/dark mode support
tooltipElement.style.cssText = `
position: fixed !important;
z-index: 999999 !important;
background-color: light-dark(white, #000000) !important;
color: light-dark(black, white) !important;
border: 1px solid light-dark(#e5e7eb, #374151) !important;
padding: ${isMobile ? '12px' : '12px'} !important;
border-radius: 8px !important;
font-size: 16px !important;
font-weight: 400 !important;
line-height: 1.75 !important;
width: auto !important;
max-width: ${maxWidth} !important;
min-width: 0 !important;
word-wrap: break-word !important;
overflow-wrap: break-word !important;
white-space: normal !important;
pointer-events: auto !important;
box-shadow: 0 2px 8px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3)) !important;
display: block !important;
visibility: visible !important;
opacity: 1 !important;
box-sizing: border-box !important;
overflow: hidden !important;
`;
// Position tooltip above the element like in the image
const rect = button.getBoundingClientRect();
// Add to body first to measure
document.body.appendChild(tooltipElement);
const tooltipRect = tooltipElement.getBoundingClientRect();
// Center horizontally and position above (using fixed positioning, so no scroll offset needed)
let left = rect.left + (rect.width / 2) - (tooltipRect.width / 2);
let top = rect.top - tooltipRect.height - 8;
// Keep tooltip on screen
if (left < 10) left = 10;
if (left + tooltipRect.width > window.innerWidth - 10) {
left = window.innerWidth - tooltipRect.width - 10;
}
// If no room above, show below
if (top < 10) {
top = rect.bottom + 8;
}
tooltipElement.style.left = left + 'px';
tooltipElement.style.top = top + 'px';
// Add hover behavior to tooltip to keep it open
tooltipElement.addEventListener('mouseenter', () => {
if (hideTimeout) {
clearTimeout(hideTimeout);
hideTimeout = null;
}
});
tooltipElement.addEventListener('mouseleave', () => {
hideTimeout = setTimeout(hideTooltip, 100);
});
}
function hideTooltip() {
if (tooltipElement) {
tooltipElement.remove();
tooltipElement = null;
}
if (hideTimeout) {
clearTimeout(hideTimeout);
hideTimeout = null;
}
}
function scheduleHide() {
hideTimeout = setTimeout(hideTooltip, 100);
}
// Add event listeners
button.addEventListener('mouseenter', showTooltip);
button.addEventListener('mouseleave', scheduleHide);
button.addEventListener('focus', showTooltip);
button.addEventListener('blur', scheduleHide);
}
// Set up MutationObserver to handle theme changes and re-renders
function setupContentObserver() {
// Throttle function to avoid excessive re-runs
let timeout = null;
function throttledWrapTerms() {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(() => {
wrapTermsOnLoad();
}, 100);
}
// Watch for changes to the main content area
const observer = new MutationObserver((mutations) => {
let shouldRerun = false;
mutations.forEach((mutation) => {
// Check if mdx-content or main content areas changed
if (mutation.type === 'childList') {
const target = mutation.target;
if (target.classList && (
target.classList.contains('mdx-content') ||
target.id === 'content' ||
target.id === 'content-area'
)) {
shouldRerun = true;
}
// Also check if added nodes contain mdx-content
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
if (node.classList && node.classList.contains('mdx-content')) {
shouldRerun = true;
}
// Check if added node contains mdx-content
if (node.querySelector && node.querySelector('.mdx-content')) {
shouldRerun = true;
}
}
});
}
// Also watch for attribute changes that might indicate theme changes
if (mutation.type === 'attributes' &&
(mutation.attributeName === 'class' || mutation.attributeName === 'data-theme')) {
shouldRerun = true;
}
});
if (shouldRerun) {
throttledWrapTerms();
}
});
// Start observing
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['class', 'data-theme']
});