Docley / app / commits / 1e7f3c56
App source: current code new
written by Branchwell · 1e7f3c5676afd9233347784fee1a716ce4771602
33 files changed
.gitignore added
| 1 | + node_modules/ | |
| 2 | + .wrangler/ | |
| 3 | + .dev.vars | |
| 4 | + out/ | |
| 5 | + data/ | |
| 6 | + .wrangler-test.jsonc |
Apps/iOS/Docley.entitlements added
| 1 | + <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| 3 | + <plist version="1.0"> | |
| 4 | + <dict> | |
| 5 | + <key>com.apple.developer.associated-domains</key> | |
| 6 | + <array> | |
| 7 | + <string>webcredentials:doctors.projectatom.ai</string> | |
| 8 | + </array> | |
| 9 | + </dict> | |
| 10 | + </plist> |
Apps/iOS/DocleyApp.swift added
| 1 | + import SwiftUI | |
| 2 | + import StoreKit | |
| 3 | + | |
| 4 | + // Docley for iPhone and iPad. Search and doctor pages are native, built on the site's JSON API. | |
| 5 | + // Signing in, rating, claiming and replying open the website in an in-app browser, so there is one | |
| 6 | + // set of rules and one account system. Mac users use the website. | |
| 7 | + | |
| 8 | + @main | |
| 9 | + struct DocleyApp: App { | |
| 10 | + var body: some Scene { | |
| 11 | + WindowGroup { | |
| 12 | + TabView { | |
| 13 | + NavigationStack { SearchView() } | |
| 14 | + .tabItem { Label("Search", systemImage: "magnifyingglass") } | |
| 15 | + NavigationStack { SettingsView() } | |
| 16 | + .tabItem { Label("Settings", systemImage: "gearshape") } | |
| 17 | + } | |
| 18 | + .tint(Theme.accent) | |
| 19 | + .preferredColorScheme(.dark) | |
| 20 | + .onAppear { RatingPrompt.countLaunch() } | |
| 21 | + } | |
| 22 | + } | |
| 23 | + } | |
| 24 | + | |
| 25 | + enum Theme { | |
| 26 | + static let accent = Color(red: 0.96, green: 0.50, blue: 0.15) // #F58025 | |
| 27 | + static let panel = Color(white: 0.07) | |
| 28 | + } | |
| 29 | + | |
| 30 | + enum Site { | |
| 31 | + static let base = URL(string: "https://doctors.projectatom.ai")! | |
| 32 | + static func url(_ path: String) -> URL { URL(string: path, relativeTo: base)!.absoluteURL } | |
| 33 | + } | |
| 34 | + | |
| 35 | + // MARK: - API | |
| 36 | + | |
| 37 | + struct DoctorSummary: Codable, Identifiable, Hashable { | |
| 38 | + let npi: String | |
| 39 | + let name: String | |
| 40 | + let credential: String? | |
| 41 | + let specialty: String? | |
| 42 | + let city: String? | |
| 43 | + let state: String? | |
| 44 | + var id: String { npi } | |
| 45 | + var title: String { credential.map { "\(name), \($0)" } ?? name } | |
| 46 | + } | |
| 47 | + | |
| 48 | + struct PublicRecord: Codable, Identifiable, Hashable { | |
| 49 | + let id: String | |
| 50 | + let source: String | |
| 51 | + let kind: String | |
| 52 | + let case_status: String? | |
| 53 | + let action_date: String? | |
| 54 | + let summary: String | |
| 55 | + let url: String | |
| 56 | + let ended: String? | |
| 57 | + let reply: String? | |
| 58 | + } | |
| 59 | + | |
| 60 | + struct Score: Codable, Hashable { let count: Int; let score: Double? } | |
| 61 | + | |
| 62 | + struct Comment: Codable, Identifiable, Hashable { | |
| 63 | + let id: String | |
| 64 | + let kind: String | |
| 65 | + let alias: String? | |
| 66 | + let comment: String | |
| 67 | + let updated: String? | |
| 68 | + let avg: Double | |
| 69 | + let reply: String? | |
| 70 | + } | |
| 71 | + | |
| 72 | + struct Doctor: Codable, Hashable { | |
| 73 | + let npi: String | |
| 74 | + let name: String | |
| 75 | + let credential: String? | |
| 76 | + let specialty: String? | |
| 77 | + let address: String? | |
| 78 | + let city: String? | |
| 79 | + let state: String? | |
| 80 | + let zip: String? | |
| 81 | + let phone: String? | |
| 82 | + let records: [PublicRecord] | |
| 83 | + let scores: [String: Score] | |
| 84 | + let comments: [Comment] | |
| 85 | + } | |
| 86 | + | |
| 87 | + struct SearchResponse: Codable { let page: Int; let more: Bool; let results: [DoctorSummary] } | |
| 88 | + | |
| 89 | + enum API { | |
| 90 | + static func search(q: String, state: String, page: Int) async throws -> SearchResponse { | |
| 91 | + var c = URLComponents(url: Site.url("/api/search"), resolvingAgainstBaseURL: false)! | |
| 92 | + c.queryItems = [.init(name: "q", value: q), .init(name: "state", value: state), .init(name: "page", value: String(page))] | |
| 93 | + let (data, _) = try await URLSession.shared.data(from: c.url!) | |
| 94 | + return try JSONDecoder().decode(SearchResponse.self, from: data) | |
| 95 | + } | |
| 96 | + static func doctor(_ npi: String) async throws -> Doctor { | |
| 97 | + let (data, _) = try await URLSession.shared.data(from: Site.url("/api/doctor/\(npi)")) | |
| 98 | + return try JSONDecoder().decode(Doctor.self, from: data) | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + // MARK: - Search | |
| 103 | + | |
| 104 | + struct SearchView: View { | |
| 105 | + @State private var query = "" | |
| 106 | + @State private var state = "" | |
| 107 | + @State private var results: [DoctorSummary] = [] | |
| 108 | + @State private var page = 1 | |
| 109 | + @State private var more = false | |
| 110 | + @State private var loading = false | |
| 111 | + @State private var error: String? | |
| 112 | + | |
| 113 | + var body: some View { | |
| 114 | + List { | |
| 115 | + Section { | |
| 116 | + Picker("State", selection: $state) { | |
| 117 | + Text("All states").tag("") | |
| 118 | + ForEach(States.all, id: \.0) { Text($0.1).tag($0.0) } | |
| 119 | + } | |
| 120 | + .onChange(of: state) { Task { await run(reset: true) } } | |
| 121 | + } | |
| 122 | + if let error { Text(error).foregroundStyle(.secondary) } | |
| 123 | + ForEach(results) { d in | |
| 124 | + NavigationLink(value: d) { | |
| 125 | + VStack(alignment: .leading, spacing: 2) { | |
| 126 | + Text(d.title).font(.headline) | |
| 127 | + Text("\(d.specialty ?? "Physician") · \(d.city ?? ""), \(d.state ?? "")") | |
| 128 | + .font(.subheadline).foregroundStyle(.secondary) | |
| 129 | + } | |
| 130 | + .padding(.vertical, 2) | |
| 131 | + } | |
| 132 | + } | |
| 133 | + if more { | |
| 134 | + Button(loading ? "Loading…" : "Show more") { Task { await run(reset: false) } }.disabled(loading) | |
| 135 | + } | |
| 136 | + if results.isEmpty && error == nil && !loading { | |
| 137 | + Text("Search every licensed doctor in America by name, specialty or city.") | |
| 138 | + .foregroundStyle(.secondary) | |
| 139 | + } | |
| 140 | + } | |
| 141 | + .navigationTitle("Docley") | |
| 142 | + .navigationDestination(for: DoctorSummary.self) { DoctorView(npi: $0.npi, title: $0.title) } | |
| 143 | + .searchable(text: $query, prompt: "Name, specialty or city") | |
| 144 | + .onSubmit(of: .search) { Task { await run(reset: true) } } | |
| 145 | + } | |
| 146 | + | |
| 147 | + func run(reset: Bool) async { | |
| 148 | + guard !query.isEmpty || !state.isEmpty else { results = []; more = false; return } | |
| 149 | + loading = true; defer { loading = false } | |
| 150 | + let next = reset ? 1 : page + 1 | |
| 151 | + do { | |
| 152 | + let r = try await API.search(q: query, state: state, page: next) | |
| 153 | + results = reset ? r.results : results + r.results | |
| 154 | + page = next; more = r.more; error = r.results.isEmpty && reset ? "No doctors found. Try fewer words or another state." : nil | |
| 155 | + } catch { | |
| 156 | + self.error = "We couldn't reach Docley. Check your connection and try again." | |
| 157 | + } | |
| 158 | + } | |
| 159 | + } | |
| 160 | + | |
| 161 | + // MARK: - Doctor | |
| 162 | + | |
| 163 | + struct DoctorView: View { | |
| 164 | + let npi: String | |
| 165 | + let title: String | |
| 166 | + @State private var doctor: Doctor? | |
| 167 | + @State private var web: URL? | |
| 168 | + @State private var failed = false | |
| 169 | + | |
| 170 | + var body: some View { | |
| 171 | + List { | |
| 172 | + if let d = doctor { | |
| 173 | + Section { | |
| 174 | + VStack(alignment: .leading, spacing: 4) { | |
| 175 | + Text(title).font(.title2.bold()) | |
| 176 | + Text("\(d.specialty ?? "Physician") · \(d.city ?? ""), \(d.state ?? "")").foregroundStyle(.secondary) | |
| 177 | + } | |
| 178 | + } | |
| 179 | + Section("Public record") { | |
| 180 | + if d.records.isEmpty { | |
| 181 | + Text("No federal exclusions found in the HHS Office of Inspector General list. State board and malpractice court records are being added state by state.") | |
| 182 | + .font(.subheadline).foregroundStyle(.secondary) | |
| 183 | + } | |
| 184 | + ForEach(d.records) { r in RecordRow(record: r) } | |
| 185 | + } | |
| 186 | + Section("Ratings") { | |
| 187 | + ScoreRow(label: "Patients", score: d.scores["patient"]) | |
| 188 | + ScoreRow(label: "Colleagues", score: d.scores["colleague"]) | |
| 189 | + Button { web = Site.url("/doctor/\(d.npi)/rate") } label: { | |
| 190 | + Text("Rate this doctor").frame(maxWidth: .infinity).fontWeight(.semibold) | |
| 191 | + } | |
| 192 | + .buttonStyle(.borderedProminent).buttonBorderShape(.capsule) | |
| 193 | + .listRowBackground(Color.clear) | |
| 194 | + } | |
| 195 | + if !d.comments.isEmpty { | |
| 196 | + Section("What people say") { | |
| 197 | + ForEach(d.comments) { c in | |
| 198 | + VStack(alignment: .leading, spacing: 6) { | |
| 199 | + Text("\(c.alias ?? "Verified person") · \(c.kind == "colleague" ? "Colleague" : "Patient") · \(String(format: "%.1f", c.avg)) of 5") | |
| 200 | + .font(.caption).foregroundStyle(.secondary) | |
| 201 | + Text(c.comment) | |
| 202 | + if let reply = c.reply { | |
| 203 | + Text("The doctor's reply: \(reply)").font(.subheadline) | |
| 204 | + .padding(.leading, 10).overlay(alignment: .leading) { Rectangle().fill(Theme.accent).frame(width: 2) } | |
| 205 | + } | |
| 206 | + } | |
| 207 | + } | |
| 208 | + } | |
| 209 | + } | |
| 210 | + Section("Practice") { | |
| 211 | + if let a = d.address { LabeledContent("Address", value: "\(a), \(d.city ?? ""), \(d.state ?? "") \(d.zip ?? "")") } | |
| 212 | + if let p = d.phone, let tel = URL(string: "tel:" + p.filter(\.isNumber)) { Link(p, destination: tel) } | |
| 213 | + LabeledContent("NPI", value: d.npi) | |
| 214 | + } | |
| 215 | + Section { | |
| 216 | + Button("Are you this doctor? Claim your page") { web = Site.url("/doctor/\(d.npi)/claim") } | |
| 217 | + Link("Open on the web", destination: Site.url("/doctor/\(d.npi)")) | |
| 218 | + } | |
| 219 | + } else if failed { | |
| 220 | + Text("We couldn't load this doctor. Pull to try again.").foregroundStyle(.secondary) | |
| 221 | + } else { | |
| 222 | + ProgressView().frame(maxWidth: .infinity) | |
| 223 | + } | |
| 224 | + } | |
| 225 | + .navigationTitle(doctor == nil ? "" : "Doctor") | |
| 226 | + .navigationBarTitleDisplayMode(.inline) | |
| 227 | + .task { await load() } | |
| 228 | + .refreshable { await load() } | |
| 229 | + .sheet(item: $web, onDismiss: { Task { await load() } }) { url in WebSheet(url: url) } | |
| 230 | + } | |
| 231 | + | |
| 232 | + func load() async { | |
| 233 | + do { doctor = try await API.doctor(npi); failed = false } catch { failed = true } | |
| 234 | + } | |
| 235 | + } | |
| 236 | + | |
| 237 | + struct RecordRow: View { | |
| 238 | + let record: PublicRecord | |
| 239 | + static let kinds = ["exclusion": "Federal exclusion", "license_action": "License action", "malpractice_case": "Malpractice case"] | |
| 240 | + static let statuses = ["filed": "Filed, not yet decided", "settled": "Settled", "dismissed": "Dismissed", "judgment_for_patient": "Judgment for the patient", "judgment_for_doctor": "Judgment for the doctor"] | |
| 241 | + var body: some View { | |
| 242 | + VStack(alignment: .leading, spacing: 6) { | |
| 243 | + Text([Self.kinds[record.kind] ?? record.kind, record.case_status.flatMap { Self.statuses[$0] }, record.action_date].compactMap { $0 }.joined(separator: " · ")) | |
| 244 | + .font(.headline).foregroundStyle(Theme.accent) | |
| 245 | + Text(record.summary) | |
| 246 | + if let u = URL(string: record.url) { Link("Source: \(record.source)", destination: u).font(.subheadline) } | |
| 247 | + if let reply = record.reply { Text("The doctor's reply: \(reply)").font(.subheadline).foregroundStyle(.secondary) } | |
| 248 | + } | |
| 249 | + .padding(.vertical, 4) | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | + struct ScoreRow: View { | |
| 254 | + let label: String | |
| 255 | + let score: Score? | |
| 256 | + var body: some View { | |
| 257 | + LabeledContent(label) { | |
| 258 | + if let s = score?.score { Text(String(format: "%.1f of 5 · %d ratings", s, score?.count ?? 0)).bold() } | |
| 259 | + else if let n = score?.count, n > 0 { Text("\(n) of 5 ratings needed") } | |
| 260 | + else { Text("No ratings yet") } | |
| 261 | + } | |
| 262 | + } | |
| 263 | + } | |
| 264 | + | |
| 265 | + extension URL: @retroactive Identifiable { public var id: String { absoluteString } } | |
| 266 | + | |
| 267 | + // MARK: - Settings (house standard: rating row, free support, no tips, no nag screens) | |
| 268 | + | |
| 269 | + struct SettingsView: View { | |
| 270 | + @Environment(\.requestReview) private var requestReview | |
| 271 | + var body: some View { | |
| 272 | + Form { | |
| 273 | + Section { | |
| 274 | + Button("Rate Docley") { requestReview() } | |
| 275 | + Link("Send feedback", destination: URL(string: "https://projectatom.ai/apps?app=docley#feedback")!) | |
| 276 | + Link("Ask ATOM", destination: URL(string: "https://projectatom.ai")!) | |
| 277 | + ShareLink("Share Docley", item: Site.base) | |
| 278 | + } header: { Text("Support Docley") } footer: { Text("Docley is free for everyone. Support is free too.") } | |
| 279 | + Section("About") { | |
| 280 | + LabeledContent("Version", value: "\(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") (\(Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? ""))") | |
| 281 | + Link("Rating rules", destination: Site.url("/rules")) | |
| 282 | + Link("Privacy", destination: URL(string: "https://projectatom.ai/privacy")!) | |
| 283 | + Link("Source code (public domain, Unlicense)", destination: URL(string: "https://github.com/projectatomai/docley")!) | |
| 284 | + } | |
| 285 | + Section { | |
| 286 | + Link(destination: URL(string: "https://projectatom.ai")!) { | |
| 287 | + Text("A Project ATOM project").font(.subheadline.weight(.semibold)) | |
| 288 | + .padding(.horizontal, 18).padding(.vertical, 10) | |
| 289 | + .overlay(Capsule().stroke(Theme.accent)) | |
| 290 | + } | |
| 291 | + .frame(maxWidth: .infinity) | |
| 292 | + } | |
| 293 | + .listRowBackground(Color.clear) | |
| 294 | + } | |
| 295 | + .navigationTitle("Settings") | |
| 296 | + } | |
| 297 | + } | |
| 298 | + | |
| 299 | + /// The only automatic prompt: Apple's rating request, after a few launches. | |
| 300 | + enum RatingPrompt { | |
| 301 | + static func countLaunch() { | |
| 302 | + let n = UserDefaults.standard.integer(forKey: "launches") + 1 | |
| 303 | + UserDefaults.standard.set(n, forKey: "launches") | |
| 304 | + guard n == 5, let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return } | |
| 305 | + AppStore.requestReview(in: scene) | |
| 306 | + } | |
| 307 | + } |
Apps/iOS/States.swift added
| 1 | + enum States { | |
| 2 | + static let all: [(String, String)] = [ | |
| 3 | + ("AL", "Alabama"), | |
| 4 | + ("AK", "Alaska"), | |
| 5 | + ("AZ", "Arizona"), | |
| 6 | + ("AR", "Arkansas"), | |
| 7 | + ("CA", "California"), | |
| 8 | + ("CO", "Colorado"), | |
| 9 | + ("CT", "Connecticut"), | |
| 10 | + ("DE", "Delaware"), | |
| 11 | + ("DC", "District of Columbia"), | |
| 12 | + ("FL", "Florida"), | |
| 13 | + ("GA", "Georgia"), | |
| 14 | + ("HI", "Hawaii"), | |
| 15 | + ("ID", "Idaho"), | |
| 16 | + ("IL", "Illinois"), | |
| 17 | + ("IN", "Indiana"), | |
| 18 | + ("IA", "Iowa"), | |
| 19 | + ("KS", "Kansas"), | |
| 20 | + ("KY", "Kentucky"), | |
| 21 | + ("LA", "Louisiana"), | |
| 22 | + ("ME", "Maine"), | |
| 23 | + ("MD", "Maryland"), | |
| 24 | + ("MA", "Massachusetts"), | |
| 25 | + ("MI", "Michigan"), | |
| 26 | + ("MN", "Minnesota"), | |
| 27 | + ("MS", "Mississippi"), | |
| 28 | + ("MO", "Missouri"), | |
| 29 | + ("MT", "Montana"), | |
| 30 | + ("NE", "Nebraska"), | |
| 31 | + ("NV", "Nevada"), | |
| 32 | + ("NH", "New Hampshire"), | |
| 33 | + ("NJ", "New Jersey"), | |
| 34 | + ("NM", "New Mexico"), | |
| 35 | + ("NY", "New York"), | |
| 36 | + ("NC", "North Carolina"), | |
| 37 | + ("ND", "North Dakota"), | |
| 38 | + ("OH", "Ohio"), | |
| 39 | + ("OK", "Oklahoma"), | |
| 40 | + ("OR", "Oregon"), | |
| 41 | + ("PA", "Pennsylvania"), | |
| 42 | + ("RI", "Rhode Island"), | |
| 43 | + ("SC", "South Carolina"), | |
| 44 | + ("SD", "South Dakota"), | |
| 45 | + ("TN", "Tennessee"), | |
| 46 | + ("TX", "Texas"), | |
| 47 | + ("UT", "Utah"), | |
| 48 | + ("VT", "Vermont"), | |
| 49 | + ("VA", "Virginia"), | |
| 50 | + ("WA", "Washington"), | |
| 51 | + ("WV", "West Virginia"), | |
| 52 | + ("WI", "Wisconsin"), | |
| 53 | + ("WY", "Wyoming"), | |
| 54 | + ("PR", "Puerto Rico"), | |
| 55 | + ("GU", "Guam"), | |
| 56 | + ("VI", "U.S. Virgin Islands") | |
| 57 | + ] | |
| 58 | + } |
Apps/iOS/WebSheet.swift added
| 1 | + import SwiftUI | |
| 2 | + import WebKit | |
| 3 | + | |
| 4 | + /// Signing in, rating, claiming and replying happen on the website, inside the app. | |
| 5 | + /// Sign-in is passkeys only. The webcredentials associated domain (Docley.entitlements) lets WebAuthn run in this web view. | |
| 6 | + struct WebSheet: View { | |
| 7 | + let url: URL | |
| 8 | + @Environment(\.dismiss) private var dismiss | |
| 9 | + var body: some View { | |
| 10 | + NavigationStack { | |
| 11 | + WebView(url: url) | |
| 12 | + .ignoresSafeArea(edges: .bottom) | |
| 13 | + .navigationTitle("Docley").navigationBarTitleDisplayMode(.inline) | |
| 14 | + .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } } | |
| 15 | + } | |
| 16 | + } | |
| 17 | + } | |
| 18 | + | |
| 19 | + struct WebView: UIViewRepresentable { | |
| 20 | + let url: URL | |
| 21 | + func makeUIView(context: Context) -> WKWebView { | |
| 22 | + let config = WKWebViewConfiguration() | |
| 23 | + config.websiteDataStore = .default() // keeps the Docley sign-in between visits | |
| 24 | + let view = WKWebView(frame: .zero, configuration: config) | |
| 25 | + view.isOpaque = false | |
| 26 | + view.backgroundColor = .black | |
| 27 | + view.navigationDelegate = context.coordinator | |
| 28 | + view.load(URLRequest(url: url)) | |
| 29 | + return view | |
| 30 | + } | |
| 31 | + func updateUIView(_ view: WKWebView, context: Context) {} | |
| 32 | + func makeCoordinator() -> Coordinator { Coordinator() } | |
| 33 | + | |
| 34 | + final class Coordinator: NSObject, WKNavigationDelegate { | |
| 35 | + // Stay on Docley; open everything else (sources, projectatom.ai) in Safari. | |
| 36 | + func webView(_ webView: WKWebView, decidePolicyFor action: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { | |
| 37 | + if let u = action.request.url, u.host != Site.base.host, action.navigationType == .linkActivated { | |
| 38 | + UIApplication.shared.open(u); decisionHandler(.cancel); return | |
| 39 | + } | |
| 40 | + decisionHandler(.allow) | |
| 41 | + } | |
| 42 | + } | |
| 43 | + } |
LICENSE added
| 1 | + This is free and unencumbered software released into the public domain. | |
| 2 | + | |
| 3 | + Anyone is free to copy, modify, publish, use, compile, sell, or | |
| 4 | + distribute this software, either in source code form or as a compiled | |
| 5 | + binary, for any purpose, commercial or non-commercial, and by any | |
| 6 | + means. | |
| 7 | + | |
| 8 | + In jurisdictions that recognize copyright laws, the author or authors | |
| 9 | + of this software dedicate any and all copyright interest in the | |
| 10 | + software to the public domain. We make this dedication for the benefit | |
| 11 | + of the public at large and to the detriment of our heirs and | |
| 12 | + successors. We intend this dedication to be an overt act of | |
| 13 | + relinquishment in perpetuity of all present and future rights to this | |
| 14 | + software under copyright law. | |
| 15 | + | |
| 16 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 17 | + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 18 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 19 | + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
| 20 | + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
| 21 | + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
| 22 | + OTHER DEALINGS IN THE SOFTWARE. | |
| 23 | + | |
| 24 | + For more information, please refer to <https://unlicense.org> |
README.md added
| 1 | + # Docley | |
| 2 | + | |
| 3 | + Every licensed doctor in America, in one free, publicly owned registry, rated by the people. | |
| 4 | + Live at **https://doctors.projectatom.ai**. A [Project ATOM](https://projectatom.ai) project. | |
| 5 | + | |
| 6 | + - **Every doctor.** Loaded from the CMS NPPES NPI Registry (individual MD and DO physicians), refreshed monthly. | |
| 7 | + - **The record follows them.** Official public records sit at the top of each doctor's page, tied to the | |
| 8 | + doctor's NPI so they follow the doctor to any hospital or state: federal exclusions from the HHS-OIG LEIE | |
| 9 | + list today, with state medical board actions and malpractice court cases (with status: filed, settled, | |
| 10 | + dismissed or judgment) added state by state. Every entry links to its official source, and the doctor can reply. | |
| 11 | + - **One person, one rating.** Passkeys only: no passwords, email links, texted codes or third-party sign-in. | |
| 12 | + One person, one account, and new accounts are limited per network per day (we keep only an HMAC of the IP). | |
| 13 | + The way back in after losing a device is a second passkey, added from `/account`. Patients answer five | |
| 14 | + questions; doctors who claim their page can rate colleagues and reply. A score appears after 5 ratings, | |
| 15 | + as a weighted average. | |
| 16 | + - **Fair.** Comments get an automatic first check (health details, accusations, insults, contact details) and | |
| 17 | + doubtful ones wait for a person in the review queue at `/admin` (signed-in admins only). See the [rating rules](https://doctors.projectatom.ai/rules). | |
| 18 | + | |
| 19 | + ## Stack | |
| 20 | + | |
| 21 | + Cloudflare Worker (`src/`), D1 with FTS5 search (`migrations/`), Workers AI for the first comment check. | |
| 22 | + Passkeys use [`@simplewebauthn/server`](https://simplewebauthn.dev) in `src/passkeys.js`, with single-use | |
| 23 | + challenges in D1 and a small same-origin script at `/assets/passkey.js`. | |
| 24 | + iPhone and iPad app in `Apps/iOS` (SwiftUI, native search and doctor pages over the JSON API; sign-in and | |
| 25 | + rating open the website in the app). `Apps/iOS/Docley.entitlements` adds the | |
| 26 | + `webcredentials:doctors.projectatom.ai` associated domain, and the site serves | |
| 27 | + `/.well-known/apple-app-site-association`, so passkeys work in the app's web view. There is no Mac app: Mac users use the website. | |
| 28 | + | |
| 29 | + ## Run it | |
| 30 | + | |
| 31 | + ```sh | |
| 32 | + npm install | |
| 33 | + npx wrangler d1 migrations apply docley-db --local | |
| 34 | + node tools/import-nppes.mjs --nppes test/fixtures/npidata.csv --nucc test/fixtures/nucc.csv --out out | |
| 35 | + node tools/import-leie.mjs --leie test/fixtures/leie.csv --out out | |
| 36 | + tools/load-d1.sh out --local | |
| 37 | + npx wrangler dev # put SITE_URL="http://localhost:8787" and RATINGS_OPEN="true" in .dev.vars to test passkeys | |
| 38 | + npm test | |
| 39 | + ``` | |
| 40 | + | |
| 41 | + Full data: `tools/refresh.sh /path/to/work --remote` downloads the newest NPPES, NUCC and LEIE files and | |
| 42 | + reloads the database. | |
| 43 | + | |
| 44 | + ## Secrets (production) | |
| 45 | + | |
| 46 | + - `SESSION_SECRET`: signs session cookies. | |
| 47 | + - `DOCLEY_ADMIN_SETUP_SECRET`: at least 32 characters. Guards `POST /api/admin-setup`; without it that route is a 404. | |
| 48 | + | |
| 49 | + ```sh | |
| 50 | + openssl rand -base64 48 | npx wrangler secret put SESSION_SECRET | |
| 51 | + openssl rand -base64 48 | npx wrangler secret put DOCLEY_ADMIN_SETUP_SECRET | |
| 52 | + npm run migrate # applies migrations/0003_passkeys.sql | |
| 53 | + ``` | |
| 54 | + | |
| 55 | + Ratings stay closed until `RATINGS_OPEN` is `"true"`. Signing in works either way, so admins can reach `/admin`. | |
| 56 | + | |
| 57 | + ## The first admin | |
| 58 | + | |
| 59 | + Admins are people with `is_admin` set; there is no admin password or token. Make a one-time link: | |
| 60 | + | |
| 61 | + ```sh | |
| 62 | + curl -X POST https://doctors.projectatom.ai/api/admin-setup \ | |
| 63 | + -H "x-setup-secret: $DOCLEY_ADMIN_SETUP_SECRET" \ | |
| 64 | + -H "content-type: application/json" -d '{"label":"first admin"}' | |
| 65 | + # {"url":"https://doctors.projectatom.ai/admin/setup?token=...","expires":"..."} | |
| 66 | + ``` | |
| 67 | + | |
| 68 | + Open the link within 15 minutes. Signed out, it creates a new admin account with a passkey on that device. | |
| 69 | + Signed in, it makes the current account an admin. Each link works once. Then add a second passkey on another | |
| 70 | + device from `/account`. | |
| 71 | + | |
| 72 | + ## JSON API | |
| 73 | + | |
| 74 | + - `GET /api/search?q=cardiology&state=FL&page=1` | |
| 75 | + - `GET /api/doctor/{NPI}` | |
| 76 | + | |
| 77 | + ## License | |
| 78 | + | |
| 79 | + Public domain ([The Unlicense](LICENSE)). |
migrations/0001_init.sql added
| 1 | + -- Docley: every US physician from the CMS NPPES NPI registry. | |
| 2 | + CREATE TABLE IF NOT EXISTS doctors ( | |
| 3 | + npi TEXT PRIMARY KEY, | |
| 4 | + name TEXT NOT NULL, | |
| 5 | + first_name TEXT NOT NULL, | |
| 6 | + middle_name TEXT, | |
| 7 | + last_name TEXT NOT NULL, | |
| 8 | + suffix TEXT, | |
| 9 | + credential TEXT, | |
| 10 | + sex TEXT, | |
| 11 | + taxonomy TEXT, | |
| 12 | + specialty TEXT, | |
| 13 | + address TEXT, | |
| 14 | + city TEXT, | |
| 15 | + state TEXT, | |
| 16 | + zip TEXT, | |
| 17 | + phone TEXT, | |
| 18 | + enumerated TEXT, | |
| 19 | + updated TEXT | |
| 20 | + ); | |
| 21 | + CREATE INDEX IF NOT EXISTS doctors_state_city ON doctors(state, city); | |
| 22 | + CREATE INDEX IF NOT EXISTS doctors_state_specialty ON doctors(state, specialty); | |
| 23 | + | |
| 24 | + CREATE VIRTUAL TABLE IF NOT EXISTS doctors_fts USING fts5( | |
| 25 | + name, specialty, city, state UNINDEXED, | |
| 26 | + content='doctors', content_rowid='rowid', tokenize='unicode61 remove_diacritics 2' | |
| 27 | + ); | |
| 28 | + | |
| 29 | + -- Ratings (open once verification is switched on). One rating per person per doctor per kind. | |
| 30 | + CREATE TABLE IF NOT EXISTS people ( | |
| 31 | + id TEXT PRIMARY KEY, | |
| 32 | + token_hash TEXT NOT NULL UNIQUE, | |
| 33 | + clinician_npi TEXT, | |
| 34 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 35 | + ); | |
| 36 | + CREATE TABLE IF NOT EXISTS ratings ( | |
| 37 | + id TEXT PRIMARY KEY, | |
| 38 | + person_id TEXT NOT NULL REFERENCES people(id), | |
| 39 | + npi TEXT NOT NULL REFERENCES doctors(npi), | |
| 40 | + kind TEXT NOT NULL CHECK (kind IN ('patient','colleague')), | |
| 41 | + q1 INTEGER, q2 INTEGER, q3 INTEGER, q4 INTEGER, q5 INTEGER, | |
| 42 | + comment TEXT, | |
| 43 | + status TEXT NOT NULL DEFAULT 'live' CHECK (status IN ('live','held','removed')), | |
| 44 | + created TEXT NOT NULL DEFAULT (datetime('now')), | |
| 45 | + updated TEXT NOT NULL DEFAULT (datetime('now')), | |
| 46 | + UNIQUE (person_id, npi, kind) | |
| 47 | + ); | |
| 48 | + CREATE INDEX IF NOT EXISTS ratings_npi ON ratings(npi, kind, status); | |
| 49 | + CREATE TABLE IF NOT EXISTS replies ( | |
| 50 | + rating_id TEXT PRIMARY KEY REFERENCES ratings(id), | |
| 51 | + npi TEXT NOT NULL, | |
| 52 | + body TEXT NOT NULL, | |
| 53 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 54 | + ); | |
| 55 | + CREATE TABLE IF NOT EXISTS flags ( | |
| 56 | + id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| 57 | + rating_id TEXT NOT NULL, | |
| 58 | + reason TEXT NOT NULL, | |
| 59 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 60 | + ); | |
| 61 | + | |
| 62 | + -- Official public records that follow a doctor by NPI, wherever they move. | |
| 63 | + -- Only government sources, each row cites its source URL. | |
| 64 | + CREATE TABLE IF NOT EXISTS records ( | |
| 65 | + id TEXT PRIMARY KEY, | |
| 66 | + npi TEXT NOT NULL, | |
| 67 | + source TEXT NOT NULL, -- e.g. 'HHS-OIG LEIE', 'FL Board of Medicine' | |
| 68 | + state TEXT, | |
| 69 | + kind TEXT NOT NULL, -- exclusion | license_action | malpractice_case | |
| 70 | + case_status TEXT, -- malpractice cases: filed | settled | dismissed | judgment_for_patient | judgment_for_doctor | |
| 71 | + action_date TEXT, | |
| 72 | + summary TEXT NOT NULL, | |
| 73 | + url TEXT NOT NULL, | |
| 74 | + ended TEXT, -- reinstatement / end date, when the source gives one | |
| 75 | + imported TEXT NOT NULL DEFAULT (datetime('now')) | |
| 76 | + ); | |
| 77 | + CREATE INDEX IF NOT EXISTS records_npi ON records(npi); |
migrations/0002_accounts.sql added
| 1 | + -- Sign-in code sends, for rate limiting (hashed phone only). | |
| 2 | + CREATE TABLE IF NOT EXISTS sends ( | |
| 3 | + token_hash TEXT NOT NULL, | |
| 4 | + at TEXT NOT NULL DEFAULT (datetime('now')) | |
| 5 | + ); | |
| 6 | + CREATE INDEX IF NOT EXISTS sends_hash ON sends(token_hash, at); | |
| 7 | + | |
| 8 | + -- A doctor claiming their own page. Checked by a person (call to the practice phone in NPPES). | |
| 9 | + CREATE TABLE IF NOT EXISTS claims ( | |
| 10 | + id TEXT PRIMARY KEY, | |
| 11 | + npi TEXT NOT NULL, | |
| 12 | + person_id TEXT NOT NULL REFERENCES people(id), | |
| 13 | + note TEXT, | |
| 14 | + status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending','approved','denied')), | |
| 15 | + created TEXT NOT NULL DEFAULT (datetime('now')), | |
| 16 | + UNIQUE (npi, person_id) | |
| 17 | + ); | |
| 18 | + CREATE INDEX IF NOT EXISTS claims_status ON claims(status); | |
| 19 | + | |
| 20 | + -- Replies can answer a rating or a public record. | |
| 21 | + CREATE TABLE IF NOT EXISTS record_replies ( | |
| 22 | + record_id TEXT PRIMARY KEY, | |
| 23 | + npi TEXT NOT NULL, | |
| 24 | + body TEXT NOT NULL, | |
| 25 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 26 | + ); | |
| 27 | + ALTER TABLE ratings ADD COLUMN alias TEXT; | |
| 28 | + ALTER TABLE ratings ADD COLUMN hold_reason TEXT; |
migrations/0003_passkeys.sql added
| 1 | + -- Passkeys only. No phone numbers, passwords, email or texted codes. | |
| 2 | + -- Rebuild people without the phone token, and add the admin flag. | |
| 3 | + PRAGMA defer_foreign_keys = on; | |
| 4 | + CREATE TABLE people_new ( | |
| 5 | + id TEXT PRIMARY KEY, | |
| 6 | + clinician_npi TEXT, | |
| 7 | + is_admin INTEGER NOT NULL DEFAULT 0, | |
| 8 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 9 | + ); | |
| 10 | + INSERT INTO people_new (id, clinician_npi, created) SELECT id, clinician_npi, created FROM people; | |
| 11 | + DROP TABLE people; | |
| 12 | + ALTER TABLE people_new RENAME TO people; | |
| 13 | + PRAGMA defer_foreign_keys = off; | |
| 14 | + | |
| 15 | + DROP TABLE IF EXISTS sends; | |
| 16 | + | |
| 17 | + -- One row per passkey. Recovery is a second passkey on another device. | |
| 18 | + CREATE TABLE IF NOT EXISTS passkeys ( | |
| 19 | + credential_id TEXT PRIMARY KEY, -- base64url | |
| 20 | + person_id TEXT NOT NULL REFERENCES people(id), | |
| 21 | + public_key TEXT NOT NULL, -- base64url COSE key | |
| 22 | + counter INTEGER NOT NULL DEFAULT 0, | |
| 23 | + transports TEXT, -- JSON array | |
| 24 | + device_type TEXT, -- singleDevice | multiDevice | |
| 25 | + backed_up INTEGER NOT NULL DEFAULT 0, | |
| 26 | + name TEXT, | |
| 27 | + created TEXT NOT NULL DEFAULT (datetime('now')), | |
| 28 | + last_used TEXT | |
| 29 | + ); | |
| 30 | + CREATE INDEX IF NOT EXISTS passkeys_person ON passkeys(person_id); | |
| 31 | + | |
| 32 | + -- Server-side WebAuthn challenges, single use, found by a short-lived HttpOnly cookie. | |
| 33 | + CREATE TABLE IF NOT EXISTS webauthn_challenges ( | |
| 34 | + id TEXT PRIMARY KEY, | |
| 35 | + challenge TEXT NOT NULL, | |
| 36 | + purpose TEXT NOT NULL CHECK (purpose IN ('register','add','admin','signin')), | |
| 37 | + person_id TEXT, -- the account a new passkey belongs to | |
| 38 | + setup_hash TEXT, -- admin setup link being used | |
| 39 | + expires INTEGER NOT NULL -- unix seconds | |
| 40 | + ); | |
| 41 | + CREATE INDEX IF NOT EXISTS webauthn_challenges_expires ON webauthn_challenges(expires); | |
| 42 | + | |
| 43 | + -- New accounts per network per day (HMAC of the IP, never the IP). | |
| 44 | + CREATE TABLE IF NOT EXISTS account_ips ( | |
| 45 | + ip_hash TEXT NOT NULL, | |
| 46 | + at TEXT NOT NULL DEFAULT (datetime('now')) | |
| 47 | + ); | |
| 48 | + CREATE INDEX IF NOT EXISTS account_ips_hash ON account_ips(ip_hash, at); | |
| 49 | + | |
| 50 | + -- One-time links that let a person create the first admin passkey. | |
| 51 | + CREATE TABLE IF NOT EXISTS admin_setup_links ( | |
| 52 | + token_hash TEXT PRIMARY KEY, -- SHA-256 of the token, base64url | |
| 53 | + label TEXT, | |
| 54 | + person_id TEXT, -- who used it | |
| 55 | + expires INTEGER NOT NULL, -- unix seconds | |
| 56 | + used TEXT, | |
| 57 | + created TEXT NOT NULL DEFAULT (datetime('now')) | |
| 58 | + ); |
package-lock.json added
| 1 | + { | |
| 2 | + "name": "docley", | |
| 3 | + "lockfileVersion": 3, | |
| 4 | + "requires": true, | |
| 5 | + "packages": { | |
| 6 | + "": { | |
| 7 | + "name": "docley", | |
| 8 | + "dependencies": { | |
| 9 | + "@simplewebauthn/server": "14.1.0" | |
| 10 | + }, | |
| 11 | + "devDependencies": { | |
| 12 | + "wrangler": "4.169.0" | |
| 13 | + } | |
| 14 | + }, | |
| 15 | + "node_modules/@cloudflare/kv-asset-handler": { | |
| 16 | + "version": "0.5.1", | |
| 17 | + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.1.tgz", | |
| 18 | + "integrity": "sha512-48OysfSW3MkQY1XjkhkpPkgrEkOvgfoyHzA2eyX5wpzFpijC02uWigv3hkNdJdT3C7ybW/U17yYHXeR68pLeww==", | |
| 19 | + "dev": true, | |
| 20 | + "license": "MIT OR Apache-2.0", | |
| 21 | + "engines": { | |
| 22 | + "node": ">=22.0.0" | |
| 23 | + } | |
| 24 | + }, | |
| 25 | + "node_modules/@cloudflare/unenv-preset": { | |
| 26 | + "version": "2.16.2", | |
| 27 | + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.2.tgz", | |
| 28 | + "integrity": "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==", | |
| 29 | + "dev": true, | |
| 30 | + "license": "MIT OR Apache-2.0", | |
| 31 | + "peerDependencies": { | |
| 32 | + "unenv": "2.0.0-rc.24", | |
| 33 | + "workerd": ">1.20260305.0 <2.0.0-0" | |
| 34 | + }, | |
| 35 | + "peerDependenciesMeta": { | |
| 36 | + "workerd": { | |
| 37 | + "optional": true | |
| 38 | + } | |
| 39 | + } | |
| 40 | + }, | |
| 41 | + "node_modules/@cloudflare/workerd-darwin-64": { | |
| 42 | + "version": "1.20261127.1", | |
| 43 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261127.1.tgz", | |
| 44 | + "integrity": "sha512-7kDdqYmmWX8S/P9pE6ae9BFU807UjivLqtF2dzUGXIQVYEenY+S8zQcKtaRm9wzhkmq8ZYyIjm0XYW5SEc8kMg==", | |
| 45 | + "cpu": [ | |
| 46 | + "x64" | |
| 47 | + ], | |
| 48 | + "dev": true, | |
| 49 | + "license": "Apache-2.0", | |
| 50 | + "optional": true, | |
| 51 | + "os": [ | |
| 52 | + "darwin" | |
| 53 | + ], | |
| 54 | + "engines": { | |
| 55 | + "node": ">=16" | |
| 56 | + } | |
| 57 | + }, | |
| 58 | + "node_modules/@cloudflare/workerd-darwin-arm64": { | |
| 59 | + "version": "1.20261127.1", | |
| 60 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261127.1.tgz", | |
| 61 | + "integrity": "sha512-mSgMwlIlMsfLfzWTUi3ngrahDb8P+TKTbtic4nvEJOnnYM1KtZNf8EfYQHtB2GVoXau79uK0UEdS+kAN0WItAg==", | |
| 62 | + "cpu": [ | |
| 63 | + "arm64" | |
| 64 | + ], | |
| 65 | + "dev": true, | |
| 66 | + "license": "Apache-2.0", | |
| 67 | + "optional": true, | |
| 68 | + "os": [ | |
| 69 | + "darwin" | |
| 70 | + ], | |
| 71 | + "engines": { | |
| 72 | + "node": ">=16" | |
| 73 | + } | |
| 74 | + }, | |
| 75 | + "node_modules/@cloudflare/workerd-linux-64": { | |
| 76 | + "version": "1.20261127.1", | |
| 77 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261127.1.tgz", | |
| 78 | + "integrity": "sha512-/7c3pJfyn9tg38nXEzLqdZPTwWolhlVOVyBv85FoWSmMPC23eQsFunRQAgsWi1Os/h1a6n3505MAChgqYrpq7w==", | |
| 79 | + "cpu": [ | |
| 80 | + "x64" | |
| 81 | + ], | |
| 82 | + "dev": true, | |
| 83 | + "license": "Apache-2.0", | |
| 84 | + "optional": true, | |
| 85 | + "os": [ | |
| 86 | + "linux" | |
| 87 | + ], | |
| 88 | + "engines": { | |
| 89 | + "node": ">=16" | |
| 90 | + } | |
| 91 | + }, | |
| 92 | + "node_modules/@cloudflare/workerd-linux-arm64": { | |
| 93 | + "version": "1.20261127.1", | |
| 94 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261127.1.tgz", | |
| 95 | + "integrity": "sha512-x/MJ8Vd+Q9VamNtj3pFRJZdZc9r3HcSqOpU6XfhcOTFuQEpA9t/0/DWdP27NrzxKNdHV5139XYxUw+x/oGY/Kw==", | |
| 96 | + "cpu": [ | |
| 97 | + "arm64" | |
| 98 | + ], | |
| 99 | + "dev": true, | |
| 100 | + "license": "Apache-2.0", | |
| 101 | + "optional": true, | |
| 102 | + "os": [ | |
| 103 | + "linux" | |
| 104 | + ], | |
| 105 | + "engines": { | |
| 106 | + "node": ">=16" | |
| 107 | + } | |
| 108 | + }, | |
| 109 | + "node_modules/@cloudflare/workerd-windows-64": { | |
| 110 | + "version": "1.20261127.1", | |
| 111 | + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261127.1.tgz", | |
| 112 | + "integrity": "sha512-ebko9XaZy6iqDHLr4WH2dC01Hf8L8xQe2GxBwqdsUfAmhMPGbnk33GtvR5FFaae+CPCPiU/H2TY1WeJ8cNSKdQ==", | |
| 113 | + "cpu": [ | |
| 114 | + "x64" | |
| 115 | + ], | |
| 116 | + "dev": true, | |
| 117 | + "license": "Apache-2.0", | |
| 118 | + "optional": true, | |
| 119 | + "os": [ | |
| 120 | + "win32" | |
| 121 | + ], | |
| 122 | + "engines": { | |
| 123 | + "node": ">=16" | |
| 124 | + } | |
| 125 | + }, | |
| 126 | + "node_modules/@cloudflare/workers-utils": { | |
| 127 | + "version": "0.58.0", | |
| 128 | + "resolved": "https://registry.npmjs.org/@cloudflare/workers-utils/-/workers-utils-0.58.0.tgz", | |
| 129 | + "integrity": "sha512-Mib8I2ijrBIm7mEykEYq369kOHtJvHIwhUh4n6w+RSuOL8LeXCHRXTKt8luE8irRM9d35kYlG+crDKjE7PQj6g==", | |
| 130 | + "dev": true, | |
| 131 | + "license": "MIT OR Apache-2.0", | |
| 132 | + "dependencies": { | |
| 133 | + "@cspotcode/source-map-support": "0.8.1", | |
| 134 | + "chalk": "5.3.0", | |
| 135 | + "dotenv": "16.3.1", | |
| 136 | + "undici": "7.30.2" | |
| 137 | + }, | |
| 138 | + "peerDependencies": { | |
| 139 | + "vitest": "^4.1.0 || ^5.0.0" | |
| 140 | + }, | |
| 141 | + "peerDependenciesMeta": { | |
| 142 | + "vitest": { | |
| 143 | + "optional": true | |
| 144 | + } | |
| 145 | + } | |
| 146 | + }, | |
| 147 | + "node_modules/@cspotcode/source-map-support": { | |
| 148 | + "version": "0.8.1", | |
| 149 | + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", | |
| 150 | + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", | |
| 151 | + "dev": true, | |
| 152 | + "license": "MIT", | |
| 153 | + "dependencies": { | |
| 154 | + "@jridgewell/trace-mapping": "0.3.9" | |
| 155 | + }, | |
| 156 | + "engines": { | |
| 157 | + "node": ">=12" | |
| 158 | + } | |
| 159 | + }, | |
| 160 | + "node_modules/@emnapi/runtime": { | |
| 161 | + "version": "1.11.3", | |
| 162 | + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", | |
| 163 | + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", | |
| 164 | + "dev": true, | |
| 165 | + "license": "MIT", | |
| 166 | + "optional": true, | |
| 167 | + "dependencies": { | |
| 168 | + "tslib": "^2.4.0" | |
| 169 | + } | |
| 170 | + }, | |
| 171 | + "node_modules/@esbuild/aix-ppc64": { | |
| 172 | + "version": "0.28.2", | |
| 173 | + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", | |
| 174 | + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", | |
| 175 | + "cpu": [ | |
| 176 | + "ppc64" | |
| 177 | + ], | |
| 178 | + "dev": true, | |
| 179 | + "license": "MIT", | |
| 180 | + "optional": true, | |
| 181 | + "os": [ | |
| 182 | + "aix" | |
| 183 | + ], | |
| 184 | + "engines": { | |
| 185 | + "node": ">=18" | |
| 186 | + } | |
| 187 | + }, | |
| 188 | + "node_modules/@esbuild/android-arm": { | |
| 189 | + "version": "0.28.2", | |
| 190 | + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", | |
| 191 | + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", | |
| 192 | + "cpu": [ | |
| 193 | + "arm" | |
| 194 | + ], | |
| 195 | + "dev": true, | |
| 196 | + "license": "MIT", | |
| 197 | + "optional": true, | |
| 198 | + "os": [ | |
| 199 | + "android" | |
| 200 | + ], | |
| 201 | + "engines": { | |
| 202 | + "node": ">=18" | |
| 203 | + } | |
| 204 | + }, | |
| 205 | + "node_modules/@esbuild/android-arm64": { | |
| 206 | + "version": "0.28.2", | |
| 207 | + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", | |
| 208 | + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", | |
| 209 | + "cpu": [ | |
| 210 | + "arm64" | |
| 211 | + ], | |
| 212 | + "dev": true, | |
| 213 | + "license": "MIT", | |
| 214 | + "optional": true, | |
| 215 | + "os": [ | |
| 216 | + "android" | |
| 217 | + ], | |
| 218 | + "engines": { | |
| 219 | + "node": ">=18" | |
| 220 | + } | |
| 221 | + }, | |
| 222 | + "node_modules/@esbuild/android-x64": { | |
| 223 | + "version": "0.28.2", | |
| 224 | + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", | |
| 225 | + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", | |
| 226 | + "cpu": [ | |
| 227 | + "x64" | |
| 228 | + ], | |
| 229 | + "dev": true, | |
| 230 | + "license": "MIT", | |
| 231 | + "optional": true, | |
| 232 | + "os": [ | |
| 233 | + "android" | |
| 234 | + ], | |
| 235 | + "engines": { | |
| 236 | + "node": ">=18" | |
| 237 | + } | |
| 238 | + }, | |
| 239 | + "node_modules/@esbuild/darwin-arm64": { | |
| 240 | + "version": "0.28.2", | |
| 241 | + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", | |
| 242 | + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", | |
| 243 | + "cpu": [ | |
| 244 | + "arm64" | |
| 245 | + ], | |
| 246 | + "dev": true, | |
| 247 | + "license": "MIT", | |
| 248 | + "optional": true, | |
| 249 | + "os": [ | |
| 250 | + "darwin" | |
| 251 | + ], | |
| 252 | + "engines": { | |
| 253 | + "node": ">=18" | |
| 254 | + } | |
| 255 | + }, | |
| 256 | + "node_modules/@esbuild/darwin-x64": { | |
| 257 | + "version": "0.28.2", | |
| 258 | + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", | |
| 259 | + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", | |
| 260 | + "cpu": [ | |
| 261 | + "x64" | |
| 262 | + ], | |
| 263 | + "dev": true, | |
| 264 | + "license": "MIT", | |
| 265 | + "optional": true, | |
| 266 | + "os": [ | |
| 267 | + "darwin" | |
| 268 | + ], | |
| 269 | + "engines": { | |
| 270 | + "node": ">=18" | |
| 271 | + } | |
| 272 | + }, | |
| 273 | + "node_modules/@esbuild/freebsd-arm64": { | |
| 274 | + "version": "0.28.2", | |
| 275 | + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", | |
| 276 | + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", | |
| 277 | + "cpu": [ | |
| 278 | + "arm64" | |
| 279 | + ], | |
| 280 | + "dev": true, | |
| 281 | + "license": "MIT", | |
| 282 | + "optional": true, | |
| 283 | + "os": [ | |
| 284 | + "freebsd" | |
| 285 | + ], | |
| 286 | + "engines": { | |
| 287 | + "node": ">=18" | |
| 288 | + } | |
| 289 | + }, | |
| 290 | + "node_modules/@esbuild/freebsd-x64": { | |
| 291 | + "version": "0.28.2", | |
| 292 | + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", | |
| 293 | + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", | |
| 294 | + "cpu": [ | |
| 295 | + "x64" | |
| 296 | + ], | |
| 297 | + "dev": true, | |
| 298 | + "license": "MIT", | |
| 299 | + "optional": true, | |
| 300 | + "os": [ | |
| 301 | + "freebsd" | |
| 302 | + ], | |
| 303 | + "engines": { | |
| 304 | + "node": ">=18" | |
| 305 | + } | |
| 306 | + }, | |
| 307 | + "node_modules/@esbuild/linux-arm": { | |
| 308 | + "version": "0.28.2", | |
| 309 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", | |
| 310 | + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", | |
| 311 | + "cpu": [ | |
| 312 | + "arm" | |
| 313 | + ], | |
| 314 | + "dev": true, | |
| 315 | + "license": "MIT", | |
| 316 | + "optional": true, | |
| 317 | + "os": [ | |
| 318 | + "linux" | |
| 319 | + ], | |
| 320 | + "engines": { | |
| 321 | + "node": ">=18" | |
| 322 | + } | |
| 323 | + }, | |
| 324 | + "node_modules/@esbuild/linux-arm64": { | |
| 325 | + "version": "0.28.2", | |
| 326 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", | |
| 327 | + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", | |
| 328 | + "cpu": [ | |
| 329 | + "arm64" | |
| 330 | + ], | |
| 331 | + "dev": true, | |
| 332 | + "license": "MIT", | |
| 333 | + "optional": true, | |
| 334 | + "os": [ | |
| 335 | + "linux" | |
| 336 | + ], | |
| 337 | + "engines": { | |
| 338 | + "node": ">=18" | |
| 339 | + } | |
| 340 | + }, | |
| 341 | + "node_modules/@esbuild/linux-ia32": { | |
| 342 | + "version": "0.28.2", | |
| 343 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", | |
| 344 | + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", | |
| 345 | + "cpu": [ | |
| 346 | + "ia32" | |
| 347 | + ], | |
| 348 | + "dev": true, | |
| 349 | + "license": "MIT", | |
| 350 | + "optional": true, | |
| 351 | + "os": [ | |
| 352 | + "linux" | |
| 353 | + ], | |
| 354 | + "engines": { | |
| 355 | + "node": ">=18" | |
| 356 | + } | |
| 357 | + }, | |
| 358 | + "node_modules/@esbuild/linux-loong64": { | |
| 359 | + "version": "0.28.2", | |
| 360 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", | |
| 361 | + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", | |
| 362 | + "cpu": [ | |
| 363 | + "loong64" | |
| 364 | + ], | |
| 365 | + "dev": true, | |
| 366 | + "license": "MIT", | |
| 367 | + "optional": true, | |
| 368 | + "os": [ | |
| 369 | + "linux" | |
| 370 | + ], | |
| 371 | + "engines": { | |
| 372 | + "node": ">=18" | |
| 373 | + } | |
| 374 | + }, | |
| 375 | + "node_modules/@esbuild/linux-mips64el": { | |
| 376 | + "version": "0.28.2", | |
| 377 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", | |
| 378 | + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", | |
| 379 | + "cpu": [ | |
| 380 | + "mips64el" | |
| 381 | + ], | |
| 382 | + "dev": true, | |
| 383 | + "license": "MIT", | |
| 384 | + "optional": true, | |
| 385 | + "os": [ | |
| 386 | + "linux" | |
| 387 | + ], | |
| 388 | + "engines": { | |
| 389 | + "node": ">=18" | |
| 390 | + } | |
| 391 | + }, | |
| 392 | + "node_modules/@esbuild/linux-ppc64": { | |
| 393 | + "version": "0.28.2", | |
| 394 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", | |
| 395 | + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", | |
| 396 | + "cpu": [ | |
| 397 | + "ppc64" | |
| 398 | + ], | |
| 399 | + "dev": true, | |
| 400 | + "license": "MIT", | |
| 401 | + "optional": true, | |
| 402 | + "os": [ | |
| 403 | + "linux" | |
| 404 | + ], | |
| 405 | + "engines": { | |
| 406 | + "node": ">=18" | |
| 407 | + } | |
| 408 | + }, | |
| 409 | + "node_modules/@esbuild/linux-riscv64": { | |
| 410 | + "version": "0.28.2", | |
| 411 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", | |
| 412 | + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", | |
| 413 | + "cpu": [ | |
| 414 | + "riscv64" | |
| 415 | + ], | |
| 416 | + "dev": true, | |
| 417 | + "license": "MIT", | |
| 418 | + "optional": true, | |
| 419 | + "os": [ | |
| 420 | + "linux" | |
| 421 | + ], | |
| 422 | + "engines": { | |
| 423 | + "node": ">=18" | |
| 424 | + } | |
| 425 | + }, | |
| 426 | + "node_modules/@esbuild/linux-s390x": { | |
| 427 | + "version": "0.28.2", | |
| 428 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", | |
| 429 | + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", | |
| 430 | + "cpu": [ | |
| 431 | + "s390x" | |
| 432 | + ], | |
| 433 | + "dev": true, | |
| 434 | + "license": "MIT", | |
| 435 | + "optional": true, | |
| 436 | + "os": [ | |
| 437 | + "linux" | |
| 438 | + ], | |
| 439 | + "engines": { | |
| 440 | + "node": ">=18" | |
| 441 | + } | |
| 442 | + }, | |
| 443 | + "node_modules/@esbuild/linux-x64": { | |
| 444 | + "version": "0.28.2", | |
| 445 | + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", | |
| 446 | + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", | |
| 447 | + "cpu": [ | |
| 448 | + "x64" | |
| 449 | + ], | |
| 450 | + "dev": true, | |
| 451 | + "license": "MIT", | |
| 452 | + "optional": true, | |
| 453 | + "os": [ | |
| 454 | + "linux" | |
| 455 | + ], | |
| 456 | + "engines": { | |
| 457 | + "node": ">=18" | |
| 458 | + } | |
| 459 | + }, | |
| 460 | + "node_modules/@esbuild/netbsd-arm64": { | |
| 461 | + "version": "0.28.2", | |
| 462 | + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", | |
| 463 | + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", | |
| 464 | + "cpu": [ | |
| 465 | + "arm64" | |
| 466 | + ], | |
| 467 | + "dev": true, | |
| 468 | + "license": "MIT", | |
| 469 | + "optional": true, | |
| 470 | + "os": [ | |
| 471 | + "netbsd" | |
| 472 | + ], | |
| 473 | + "engines": { | |
| 474 | + "node": ">=18" | |
| 475 | + } | |
| 476 | + }, | |
| 477 | + "node_modules/@esbuild/netbsd-x64": { | |
| 478 | + "version": "0.28.2", | |
| 479 | + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", | |
| 480 | + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", | |
| 481 | + "cpu": [ | |
| 482 | + "x64" | |
| 483 | + ], | |
| 484 | + "dev": true, | |
| 485 | + "license": "MIT", | |
| 486 | + "optional": true, | |
| 487 | + "os": [ | |
| 488 | + "netbsd" | |
| 489 | + ], | |
| 490 | + "engines": { | |
| 491 | + "node": ">=18" | |
| 492 | + } | |
| 493 | + }, | |
| 494 | + "node_modules/@esbuild/openbsd-arm64": { | |
| 495 | + "version": "0.28.2", | |
| 496 | + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", | |
| 497 | + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", | |
| 498 | + "cpu": [ | |
| 499 | + "arm64" | |
| 500 | + ], | |
| 501 | + "dev": true, | |
| 502 | + "license": "MIT", | |
| 503 | + "optional": true, | |
| 504 | + "os": [ | |
| 505 | + "openbsd" | |
| 506 | + ], | |
| 507 | + "engines": { | |
| 508 | + "node": ">=18" | |
| 509 | + } | |
| 510 | + }, | |
| 511 | + "node_modules/@esbuild/openbsd-x64": { | |
| 512 | + "version": "0.28.2", | |
| 513 | + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", | |
| 514 | + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", | |
| 515 | + "cpu": [ | |
| 516 | + "x64" | |
| 517 | + ], | |
| 518 | + "dev": true, | |
| 519 | + "license": "MIT", | |
| 520 | + "optional": true, | |
| 521 | + "os": [ | |
| 522 | + "openbsd" | |
| 523 | + ], | |
| 524 | + "engines": { | |
| 525 | + "node": ">=18" | |
| 526 | + } | |
| 527 | + }, | |
| 528 | + "node_modules/@esbuild/openharmony-arm64": { | |
| 529 | + "version": "0.28.2", | |
| 530 | + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", | |
| 531 | + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", | |
| 532 | + "cpu": [ | |
| 533 | + "arm64" | |
| 534 | + ], | |
| 535 | + "dev": true, | |
| 536 | + "license": "MIT", | |
| 537 | + "optional": true, | |
| 538 | + "os": [ | |
| 539 | + "openharmony" | |
| 540 | + ], | |
| 541 | + "engines": { | |
| 542 | + "node": ">=18" | |
| 543 | + } | |
| 544 | + }, | |
| 545 | + "node_modules/@esbuild/sunos-x64": { | |
| 546 | + "version": "0.28.2", | |
| 547 | + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", | |
| 548 | + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", | |
| 549 | + "cpu": [ | |
| 550 | + "x64" | |
| 551 | + ], | |
| 552 | + "dev": true, | |
| 553 | + "license": "MIT", | |
| 554 | + "optional": true, | |
| 555 | + "os": [ | |
| 556 | + "sunos" | |
| 557 | + ], | |
| 558 | + "engines": { | |
| 559 | + "node": ">=18" | |
| 560 | + } | |
| 561 | + }, | |
| 562 | + "node_modules/@esbuild/win32-arm64": { | |
| 563 | + "version": "0.28.2", | |
| 564 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", | |
| 565 | + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", | |
| 566 | + "cpu": [ | |
| 567 | + "arm64" | |
| 568 | + ], | |
| 569 | + "dev": true, | |
| 570 | + "license": "MIT", | |
| 571 | + "optional": true, | |
| 572 | + "os": [ | |
| 573 | + "win32" | |
| 574 | + ], | |
| 575 | + "engines": { | |
| 576 | + "node": ">=18" | |
| 577 | + } | |
| 578 | + }, | |
| 579 | + "node_modules/@esbuild/win32-ia32": { | |
| 580 | + "version": "0.28.2", | |
| 581 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", | |
| 582 | + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", | |
| 583 | + "cpu": [ | |
| 584 | + "ia32" | |
| 585 | + ], | |
| 586 | + "dev": true, | |
| 587 | + "license": "MIT", | |
| 588 | + "optional": true, | |
| 589 | + "os": [ | |
| 590 | + "win32" | |
| 591 | + ], | |
| 592 | + "engines": { | |
| 593 | + "node": ">=18" | |
| 594 | + } | |
| 595 | + }, | |
| 596 | + "node_modules/@esbuild/win32-x64": { | |
| 597 | + "version": "0.28.2", | |
| 598 | + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", | |
| 599 | + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", | |
| 600 | + "cpu": [ | |
| 601 | + "x64" | |
| 602 | + ], | |
| 603 | + "dev": true, | |
| 604 | + "license": "MIT", | |
| 605 | + "optional": true, | |
| 606 | + "os": [ | |
| 607 | + "win32" | |
| 608 | + ], | |
| 609 | + "engines": { | |
| 610 | + "node": ">=18" | |
| 611 | + } | |
| 612 | + }, | |
| 613 | + "node_modules/@hexagon/base64": { | |
| 614 | + "version": "1.1.28", | |
| 615 | + "resolved": "https://registry.npmjs.org/@hexagon/base64/-/base64-1.1.28.tgz", | |
| 616 | + "integrity": "sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw==", | |
| 617 | + "license": "MIT" | |
| 618 | + }, | |
| 619 | + "node_modules/@img/colour": { | |
| 620 | + "version": "1.1.0", | |
| 621 | + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", | |
| 622 | + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", | |
| 623 | + "dev": true, | |
| 624 | + "license": "MIT", | |
| 625 | + "engines": { | |
| 626 | + "node": ">=18" | |
| 627 | + } | |
| 628 | + }, | |
| 629 | + "node_modules/@img/sharp-darwin-arm64": { | |
| 630 | + "version": "0.35.5", | |
| 631 | + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", | |
| 632 | + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", | |
| 633 | + "cpu": [ | |
| 634 | + "arm64" | |
| 635 | + ], | |
| 636 | + "dev": true, | |
| 637 | + "license": "Apache-2.0", | |
| 638 | + "optional": true, | |
| 639 | + "os": [ | |
| 640 | + "darwin" | |
| 641 | + ], | |
| 642 | + "engines": { | |
| 643 | + "node": ">=20.9.0" | |
| 644 | + }, | |
| 645 | + "funding": { | |
| 646 | + "url": "https://opencollective.com/libvips" | |
| 647 | + }, | |
| 648 | + "optionalDependencies": { | |
| 649 | + "@img/sharp-libvips-darwin-arm64": "1.3.4" | |
| 650 | + } | |
| 651 | + }, | |
| 652 | + "node_modules/@img/sharp-darwin-x64": { | |
| 653 | + "version": "0.35.5", | |
| 654 | + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", | |
| 655 | + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", | |
| 656 | + "cpu": [ | |
| 657 | + "x64" | |
| 658 | + ], | |
| 659 | + "dev": true, | |
| 660 | + "license": "Apache-2.0", | |
| 661 | + "optional": true, | |
| 662 | + "os": [ | |
| 663 | + "darwin" | |
| 664 | + ], | |
| 665 | + "engines": { | |
| 666 | + "node": ">=20.9.0" | |
| 667 | + }, | |
| 668 | + "funding": { | |
| 669 | + "url": "https://opencollective.com/libvips" | |
| 670 | + }, | |
| 671 | + "optionalDependencies": { | |
| 672 | + "@img/sharp-libvips-darwin-x64": "1.3.4" | |
| 673 | + } | |
| 674 | + }, | |
| 675 | + "node_modules/@img/sharp-freebsd-wasm32": { | |
| 676 | + "version": "0.35.5", | |
| 677 | + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", | |
| 678 | + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", | |
| 679 | + "dev": true, | |
| 680 | + "license": "Apache-2.0", | |
| 681 | + "optional": true, | |
| 682 | + "os": [ | |
| 683 | + "freebsd" | |
| 684 | + ], | |
| 685 | + "dependencies": { | |
| 686 | + "@img/sharp-wasm32": "0.35.5" | |
| 687 | + }, | |
| 688 | + "engines": { | |
| 689 | + "node": ">=20.9.0" | |
| 690 | + }, | |
| 691 | + "funding": { | |
| 692 | + "url": "https://opencollective.com/libvips" | |
| 693 | + } | |
| 694 | + }, | |
| 695 | + "node_modules/@img/sharp-libvips-darwin-arm64": { | |
| 696 | + "version": "1.3.4", | |
| 697 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", | |
| 698 | + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", | |
| 699 | + "cpu": [ | |
| 700 | + "arm64" | |
| 701 | + ], | |
| 702 | + "dev": true, | |
| 703 | + "license": "LGPL-3.0-or-later", | |
| 704 | + "optional": true, | |
| 705 | + "os": [ | |
| 706 | + "darwin" | |
| 707 | + ], | |
| 708 | + "funding": { | |
| 709 | + "url": "https://opencollective.com/libvips" | |
| 710 | + } | |
| 711 | + }, | |
| 712 | + "node_modules/@img/sharp-libvips-darwin-x64": { | |
| 713 | + "version": "1.3.4", | |
| 714 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", | |
| 715 | + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", | |
| 716 | + "cpu": [ | |
| 717 | + "x64" | |
| 718 | + ], | |
| 719 | + "dev": true, | |
| 720 | + "license": "LGPL-3.0-or-later", | |
| 721 | + "optional": true, | |
| 722 | + "os": [ | |
| 723 | + "darwin" | |
| 724 | + ], | |
| 725 | + "funding": { | |
| 726 | + "url": "https://opencollective.com/libvips" | |
| 727 | + } | |
| 728 | + }, | |
| 729 | + "node_modules/@img/sharp-libvips-linux-arm": { | |
| 730 | + "version": "1.3.4", | |
| 731 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", | |
| 732 | + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", | |
| 733 | + "cpu": [ | |
| 734 | + "arm" | |
| 735 | + ], | |
| 736 | + "dev": true, | |
| 737 | + "license": "LGPL-3.0-or-later", | |
| 738 | + "optional": true, | |
| 739 | + "os": [ | |
| 740 | + "linux" | |
| 741 | + ], | |
| 742 | + "funding": { | |
| 743 | + "url": "https://opencollective.com/libvips" | |
| 744 | + } | |
| 745 | + }, | |
| 746 | + "node_modules/@img/sharp-libvips-linux-arm64": { | |
| 747 | + "version": "1.3.4", | |
| 748 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", | |
| 749 | + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", | |
| 750 | + "cpu": [ | |
| 751 | + "arm64" | |
| 752 | + ], | |
| 753 | + "dev": true, | |
| 754 | + "license": "LGPL-3.0-or-later", | |
| 755 | + "optional": true, | |
| 756 | + "os": [ | |
| 757 | + "linux" | |
| 758 | + ], | |
| 759 | + "funding": { | |
| 760 | + "url": "https://opencollective.com/libvips" | |
| 761 | + } | |
| 762 | + }, | |
| 763 | + "node_modules/@img/sharp-libvips-linux-ppc64": { | |
| 764 | + "version": "1.3.4", | |
| 765 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", | |
| 766 | + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", | |
| 767 | + "cpu": [ | |
| 768 | + "ppc64" | |
| 769 | + ], | |
| 770 | + "dev": true, | |
| 771 | + "license": "LGPL-3.0-or-later", | |
| 772 | + "optional": true, | |
| 773 | + "os": [ | |
| 774 | + "linux" | |
| 775 | + ], | |
| 776 | + "funding": { | |
| 777 | + "url": "https://opencollective.com/libvips" | |
| 778 | + } | |
| 779 | + }, | |
| 780 | + "node_modules/@img/sharp-libvips-linux-riscv64": { | |
| 781 | + "version": "1.3.4", | |
| 782 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", | |
| 783 | + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", | |
| 784 | + "cpu": [ | |
| 785 | + "riscv64" | |
| 786 | + ], | |
| 787 | + "dev": true, | |
| 788 | + "license": "LGPL-3.0-or-later", | |
| 789 | + "optional": true, | |
| 790 | + "os": [ | |
| 791 | + "linux" | |
| 792 | + ], | |
| 793 | + "funding": { | |
| 794 | + "url": "https://opencollective.com/libvips" | |
| 795 | + } | |
| 796 | + }, | |
| 797 | + "node_modules/@img/sharp-libvips-linux-s390x": { | |
| 798 | + "version": "1.3.4", | |
| 799 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", | |
| 800 | + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", | |
| 801 | + "cpu": [ | |
| 802 | + "s390x" | |
| 803 | + ], | |
| 804 | + "dev": true, | |
| 805 | + "license": "LGPL-3.0-or-later", | |
| 806 | + "optional": true, | |
| 807 | + "os": [ | |
| 808 | + "linux" | |
| 809 | + ], | |
| 810 | + "funding": { | |
| 811 | + "url": "https://opencollective.com/libvips" | |
| 812 | + } | |
| 813 | + }, | |
| 814 | + "node_modules/@img/sharp-libvips-linux-x64": { | |
| 815 | + "version": "1.3.4", | |
| 816 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", | |
| 817 | + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", | |
| 818 | + "cpu": [ | |
| 819 | + "x64" | |
| 820 | + ], | |
| 821 | + "dev": true, | |
| 822 | + "license": "LGPL-3.0-or-later", | |
| 823 | + "optional": true, | |
| 824 | + "os": [ | |
| 825 | + "linux" | |
| 826 | + ], | |
| 827 | + "funding": { | |
| 828 | + "url": "https://opencollective.com/libvips" | |
| 829 | + } | |
| 830 | + }, | |
| 831 | + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { | |
| 832 | + "version": "1.3.4", | |
| 833 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", | |
| 834 | + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", | |
| 835 | + "cpu": [ | |
| 836 | + "arm64" | |
| 837 | + ], | |
| 838 | + "dev": true, | |
| 839 | + "license": "LGPL-3.0-or-later", | |
| 840 | + "optional": true, | |
| 841 | + "os": [ | |
| 842 | + "linux" | |
| 843 | + ], | |
| 844 | + "funding": { | |
| 845 | + "url": "https://opencollective.com/libvips" | |
| 846 | + } | |
| 847 | + }, | |
| 848 | + "node_modules/@img/sharp-libvips-linuxmusl-x64": { | |
| 849 | + "version": "1.3.4", | |
| 850 | + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", | |
| 851 | + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", | |
| 852 | + "cpu": [ | |
| 853 | + "x64" | |
| 854 | + ], | |
| 855 | + "dev": true, | |
| 856 | + "license": "LGPL-3.0-or-later", | |
| 857 | + "optional": true, | |
| 858 | + "os": [ | |
| 859 | + "linux" | |
| 860 | + ], | |
| 861 | + "funding": { | |
| 862 | + "url": "https://opencollective.com/libvips" | |
| 863 | + } | |
| 864 | + }, | |
| 865 | + "node_modules/@img/sharp-linux-arm": { | |
| 866 | + "version": "0.35.5", | |
| 867 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", | |
| 868 | + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", | |
| 869 | + "cpu": [ | |
| 870 | + "arm" | |
| 871 | + ], | |
| 872 | + "dev": true, | |
| 873 | + "license": "Apache-2.0", | |
| 874 | + "optional": true, | |
| 875 | + "os": [ | |
| 876 | + "linux" | |
| 877 | + ], | |
| 878 | + "engines": { | |
| 879 | + "node": ">=20.9.0" | |
| 880 | + }, | |
| 881 | + "funding": { | |
| 882 | + "url": "https://opencollective.com/libvips" | |
| 883 | + }, | |
| 884 | + "optionalDependencies": { | |
| 885 | + "@img/sharp-libvips-linux-arm": "1.3.4" | |
| 886 | + } | |
| 887 | + }, | |
| 888 | + "node_modules/@img/sharp-linux-arm64": { | |
| 889 | + "version": "0.35.5", | |
| 890 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", | |
| 891 | + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", | |
| 892 | + "cpu": [ | |
| 893 | + "arm64" | |
| 894 | + ], | |
| 895 | + "dev": true, | |
| 896 | + "license": "Apache-2.0", | |
| 897 | + "optional": true, | |
| 898 | + "os": [ | |
| 899 | + "linux" | |
| 900 | + ], | |
| 901 | + "engines": { | |
| 902 | + "node": ">=20.9.0" | |
| 903 | + }, | |
| 904 | + "funding": { | |
| 905 | + "url": "https://opencollective.com/libvips" | |
| 906 | + }, | |
| 907 | + "optionalDependencies": { | |
| 908 | + "@img/sharp-libvips-linux-arm64": "1.3.4" | |
| 909 | + } | |
| 910 | + }, | |
| 911 | + "node_modules/@img/sharp-linux-ppc64": { | |
| 912 | + "version": "0.35.5", | |
| 913 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", | |
| 914 | + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", | |
| 915 | + "cpu": [ | |
| 916 | + "ppc64" | |
| 917 | + ], | |
| 918 | + "dev": true, | |
| 919 | + "license": "Apache-2.0", | |
| 920 | + "optional": true, | |
| 921 | + "os": [ | |
| 922 | + "linux" | |
| 923 | + ], | |
| 924 | + "engines": { | |
| 925 | + "node": ">=20.9.0" | |
| 926 | + }, | |
| 927 | + "funding": { | |
| 928 | + "url": "https://opencollective.com/libvips" | |
| 929 | + }, | |
| 930 | + "optionalDependencies": { | |
| 931 | + "@img/sharp-libvips-linux-ppc64": "1.3.4" | |
| 932 | + } | |
| 933 | + }, | |
| 934 | + "node_modules/@img/sharp-linux-riscv64": { | |
| 935 | + "version": "0.35.5", | |
| 936 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", | |
| 937 | + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", | |
| 938 | + "cpu": [ | |
| 939 | + "riscv64" | |
| 940 | + ], | |
| 941 | + "dev": true, | |
| 942 | + "license": "Apache-2.0", | |
| 943 | + "optional": true, | |
| 944 | + "os": [ | |
| 945 | + "linux" | |
| 946 | + ], | |
| 947 | + "engines": { | |
| 948 | + "node": ">=20.9.0" | |
| 949 | + }, | |
| 950 | + "funding": { | |
| 951 | + "url": "https://opencollective.com/libvips" | |
| 952 | + }, | |
| 953 | + "optionalDependencies": { | |
| 954 | + "@img/sharp-libvips-linux-riscv64": "1.3.4" | |
| 955 | + } | |
| 956 | + }, | |
| 957 | + "node_modules/@img/sharp-linux-s390x": { | |
| 958 | + "version": "0.35.5", | |
| 959 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", | |
| 960 | + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", | |
| 961 | + "cpu": [ | |
| 962 | + "s390x" | |
| 963 | + ], | |
| 964 | + "dev": true, | |
| 965 | + "license": "Apache-2.0", | |
| 966 | + "optional": true, | |
| 967 | + "os": [ | |
| 968 | + "linux" | |
| 969 | + ], | |
| 970 | + "engines": { | |
| 971 | + "node": ">=20.9.0" | |
| 972 | + }, | |
| 973 | + "funding": { | |
| 974 | + "url": "https://opencollective.com/libvips" | |
| 975 | + }, | |
| 976 | + "optionalDependencies": { | |
| 977 | + "@img/sharp-libvips-linux-s390x": "1.3.4" | |
| 978 | + } | |
| 979 | + }, | |
| 980 | + "node_modules/@img/sharp-linux-x64": { | |
| 981 | + "version": "0.35.5", | |
| 982 | + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", | |
| 983 | + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", | |
| 984 | + "cpu": [ | |
| 985 | + "x64" | |
| 986 | + ], | |
| 987 | + "dev": true, | |
| 988 | + "license": "Apache-2.0", | |
| 989 | + "optional": true, | |
| 990 | + "os": [ | |
| 991 | + "linux" | |
| 992 | + ], | |
| 993 | + "engines": { | |
| 994 | + "node": ">=20.9.0" | |
| 995 | + }, | |
| 996 | + "funding": { | |
| 997 | + "url": "https://opencollective.com/libvips" | |
| 998 | + }, | |
| 999 | + "optionalDependencies": { | |
| 1000 | + "@img/sharp-libvips-linux-x64": "1.3.4" | |
| 1001 | + } | |
| 1002 | + }, | |
| 1003 | + "node_modules/@img/sharp-linuxmusl-arm64": { | |
| 1004 | + "version": "0.35.5", | |
| 1005 | + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", | |
| 1006 | + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", | |
| 1007 | + "cpu": [ | |
| 1008 | + "arm64" | |
| 1009 | + ], | |
| 1010 | + "dev": true, | |
| 1011 | + "license": "Apache-2.0", | |
| 1012 | + "optional": true, | |
| 1013 | + "os": [ | |
| 1014 | + "linux" | |
| 1015 | + ], | |
| 1016 | + "engines": { | |
| 1017 | + "node": ">=20.9.0" | |
| 1018 | + }, | |
| 1019 | + "funding": { | |
| 1020 | + "url": "https://opencollective.com/libvips" | |
| 1021 | + }, | |
| 1022 | + "optionalDependencies": { | |
| 1023 | + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" | |
| 1024 | + } | |
| 1025 | + }, | |
| 1026 | + "node_modules/@img/sharp-linuxmusl-x64": { | |
| 1027 | + "version": "0.35.5", | |
| 1028 | + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", | |
| 1029 | + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", | |
| 1030 | + "cpu": [ | |
| 1031 | + "x64" | |
| 1032 | + ], | |
| 1033 | + "dev": true, | |
| 1034 | + "license": "Apache-2.0", | |
| 1035 | + "optional": true, | |
| 1036 | + "os": [ | |
| 1037 | + "linux" | |
| 1038 | + ], | |
| 1039 | + "engines": { | |
| 1040 | + "node": ">=20.9.0" | |
| 1041 | + }, | |
| 1042 | + "funding": { | |
| 1043 | + "url": "https://opencollective.com/libvips" | |
| 1044 | + }, | |
| 1045 | + "optionalDependencies": { | |
| 1046 | + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" | |
| 1047 | + } | |
| 1048 | + }, | |
| 1049 | + "node_modules/@img/sharp-wasm32": { | |
| 1050 | + "version": "0.35.5", | |
| 1051 | + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", | |
| 1052 | + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", | |
| 1053 | + "dev": true, | |
| 1054 | + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", | |
| 1055 | + "optional": true, | |
| 1056 | + "dependencies": { | |
| 1057 | + "@emnapi/runtime": "^1.11.3" | |
| 1058 | + }, | |
| 1059 | + "engines": { | |
| 1060 | + "node": ">=20.9.0" | |
| 1061 | + }, | |
| 1062 | + "funding": { | |
| 1063 | + "url": "https://opencollective.com/libvips" | |
| 1064 | + } | |
| 1065 | + }, | |
| 1066 | + "node_modules/@img/sharp-webcontainers-wasm32": { | |
| 1067 | + "version": "0.35.5", | |
| 1068 | + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", | |
| 1069 | + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", | |
| 1070 | + "cpu": [ | |
| 1071 | + "wasm32" | |
| 1072 | + ], | |
| 1073 | + "dev": true, | |
| 1074 | + "license": "Apache-2.0", | |
| 1075 | + "optional": true, | |
| 1076 | + "dependencies": { | |
| 1077 | + "@img/sharp-wasm32": "0.35.5" | |
| 1078 | + }, | |
| 1079 | + "engines": { | |
| 1080 | + "node": ">=20.9.0" | |
| 1081 | + }, | |
| 1082 | + "funding": { | |
| 1083 | + "url": "https://opencollective.com/libvips" | |
| 1084 | + } | |
| 1085 | + }, | |
| 1086 | + "node_modules/@img/sharp-win32-arm64": { | |
| 1087 | + "version": "0.35.5", | |
| 1088 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", | |
| 1089 | + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", | |
| 1090 | + "cpu": [ | |
| 1091 | + "arm64" | |
| 1092 | + ], | |
| 1093 | + "dev": true, | |
| 1094 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1095 | + "optional": true, | |
| 1096 | + "os": [ | |
| 1097 | + "win32" | |
| 1098 | + ], | |
| 1099 | + "engines": { | |
| 1100 | + "node": ">=20.9.0" | |
| 1101 | + }, | |
| 1102 | + "funding": { | |
| 1103 | + "url": "https://opencollective.com/libvips" | |
| 1104 | + } | |
| 1105 | + }, | |
| 1106 | + "node_modules/@img/sharp-win32-ia32": { | |
| 1107 | + "version": "0.35.5", | |
| 1108 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", | |
| 1109 | + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", | |
| 1110 | + "cpu": [ | |
| 1111 | + "ia32" | |
| 1112 | + ], | |
| 1113 | + "dev": true, | |
| 1114 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1115 | + "optional": true, | |
| 1116 | + "os": [ | |
| 1117 | + "win32" | |
| 1118 | + ], | |
| 1119 | + "engines": { | |
| 1120 | + "node": "^20.9.0" | |
| 1121 | + }, | |
| 1122 | + "funding": { | |
| 1123 | + "url": "https://opencollective.com/libvips" | |
| 1124 | + } | |
| 1125 | + }, | |
| 1126 | + "node_modules/@img/sharp-win32-x64": { | |
| 1127 | + "version": "0.35.5", | |
| 1128 | + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", | |
| 1129 | + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", | |
| 1130 | + "cpu": [ | |
| 1131 | + "x64" | |
| 1132 | + ], | |
| 1133 | + "dev": true, | |
| 1134 | + "license": "Apache-2.0 AND LGPL-3.0-or-later", | |
| 1135 | + "optional": true, | |
| 1136 | + "os": [ | |
| 1137 | + "win32" | |
| 1138 | + ], | |
| 1139 | + "engines": { | |
| 1140 | + "node": ">=20.9.0" | |
| 1141 | + }, | |
| 1142 | + "funding": { | |
| 1143 | + "url": "https://opencollective.com/libvips" | |
| 1144 | + } | |
| 1145 | + }, | |
| 1146 | + "node_modules/@jridgewell/resolve-uri": { | |
| 1147 | + "version": "3.1.3", | |
| 1148 | + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", | |
| 1149 | + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", | |
| 1150 | + "dev": true, | |
| 1151 | + "license": "MIT", | |
| 1152 | + "engines": { | |
| 1153 | + "node": ">=6.0.0" | |
| 1154 | + } | |
| 1155 | + }, | |
| 1156 | + "node_modules/@jridgewell/sourcemap-codec": { | |
| 1157 | + "version": "1.6.0", | |
| 1158 | + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", | |
| 1159 | + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", | |
| 1160 | + "dev": true, | |
| 1161 | + "license": "MIT" | |
| 1162 | + }, | |
| 1163 | + "node_modules/@jridgewell/trace-mapping": { | |
| 1164 | + "version": "0.3.9", | |
| 1165 | + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", | |
| 1166 | + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", | |
| 1167 | + "dev": true, | |
| 1168 | + "license": "MIT", | |
| 1169 | + "dependencies": { | |
| 1170 | + "@jridgewell/resolve-uri": "^3.0.3", | |
| 1171 | + "@jridgewell/sourcemap-codec": "^1.4.10" | |
| 1172 | + } | |
| 1173 | + }, | |
| 1174 | + "node_modules/@levischuck/tiny-cbor": { | |
| 1175 | + "version": "0.2.13", | |
| 1176 | + "resolved": "https://registry.npmjs.org/@levischuck/tiny-cbor/-/tiny-cbor-0.2.13.tgz", | |
| 1177 | + "integrity": "sha512-cGi6gJbe8/gC11KLNeBSUlq6jyuPTO4xQWka+8xn3m3JROdW062nu/x156z/7N4TnhMMBKSNOOpNw7++prLr5Q==", | |
| 1178 | + "license": "MIT" | |
| 1179 | + }, | |
| 1180 | + "node_modules/@peculiar/asn1-android": { | |
| 1181 | + "version": "2.11.1", | |
| 1182 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-android/-/asn1-android-2.11.1.tgz", | |
| 1183 | + "integrity": "sha512-AuUBRDNdWrgtnuJGXARa0Xdtq6OAD8GqezDQz6Qka7kyynMo9fzkcrtpBEHuX984uEB570BrhMZfJfkUDfpQfw==", | |
| 1184 | + "license": "MIT", | |
| 1185 | + "dependencies": { | |
| 1186 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1187 | + "asn1js": "^3.0.10", | |
| 1188 | + "tslib": "^2.8.1" | |
| 1189 | + }, | |
| 1190 | + "engines": { | |
| 1191 | + "node": ">=14" | |
| 1192 | + } | |
| 1193 | + }, | |
| 1194 | + "node_modules/@peculiar/asn1-asym-key": { | |
| 1195 | + "version": "2.11.1", | |
| 1196 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-asym-key/-/asn1-asym-key-2.11.1.tgz", | |
| 1197 | + "integrity": "sha512-YtXR0FbDtjHuNGvWXD4HFE7th5xYwG67O+ApDH/FZsjj5MOrWHzDvqwZ1vm6uFUJtMAkUDcF6VMPGOJ5gnLyUA==", | |
| 1198 | + "license": "MIT", | |
| 1199 | + "dependencies": { | |
| 1200 | + "@peculiar/asn1-pkcs8": "^2.11.1", | |
| 1201 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1202 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1203 | + "asn1js": "^3.0.10", | |
| 1204 | + "tslib": "^2.8.1" | |
| 1205 | + }, | |
| 1206 | + "engines": { | |
| 1207 | + "node": ">=14" | |
| 1208 | + } | |
| 1209 | + }, | |
| 1210 | + "node_modules/@peculiar/asn1-cms": { | |
| 1211 | + "version": "2.11.1", | |
| 1212 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.11.1.tgz", | |
| 1213 | + "integrity": "sha512-Bk+oatE62dW0Tzzpfk6vdQxfGGEfvuGdWgmijnKjcv7HqZCJISs85z4zw2uDArrk+R1Oel1wts/BBl7HHrtAcA==", | |
| 1214 | + "license": "MIT", | |
| 1215 | + "dependencies": { | |
| 1216 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1217 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1218 | + "@peculiar/asn1-x509-attr": "^2.11.1", | |
| 1219 | + "asn1js": "^3.0.10", | |
| 1220 | + "tslib": "^2.8.1" | |
| 1221 | + }, | |
| 1222 | + "engines": { | |
| 1223 | + "node": ">=14" | |
| 1224 | + } | |
| 1225 | + }, | |
| 1226 | + "node_modules/@peculiar/asn1-csr": { | |
| 1227 | + "version": "2.11.1", | |
| 1228 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.11.1.tgz", | |
| 1229 | + "integrity": "sha512-KVfbXaKng8886/tOPG55t5K1XkTkGbR4amjIJzytXWobFU5nZgw/sKnSpa1hxP17nUSsrOF/7Mt9WUYeyLsi6Q==", | |
| 1230 | + "license": "MIT", | |
| 1231 | + "dependencies": { | |
| 1232 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1233 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1234 | + "asn1js": "^3.0.10", | |
| 1235 | + "tslib": "^2.8.1" | |
| 1236 | + }, | |
| 1237 | + "engines": { | |
| 1238 | + "node": ">=14" | |
| 1239 | + } | |
| 1240 | + }, | |
| 1241 | + "node_modules/@peculiar/asn1-ecc": { | |
| 1242 | + "version": "2.11.1", | |
| 1243 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.11.1.tgz", | |
| 1244 | + "integrity": "sha512-7MSNji77fQa/oN3WAfwagMy8EoJFg50sW4hZ1dtr0zU1BSugit0I2DGpIdPhvkNplopQhz5bogxpn1077eaamA==", | |
| 1245 | + "license": "MIT", | |
| 1246 | + "dependencies": { | |
| 1247 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1248 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1249 | + "asn1js": "^3.0.10", | |
| 1250 | + "tslib": "^2.8.1" | |
| 1251 | + }, | |
| 1252 | + "engines": { | |
| 1253 | + "node": ">=14" | |
| 1254 | + } | |
| 1255 | + }, | |
| 1256 | + "node_modules/@peculiar/asn1-pfx": { | |
| 1257 | + "version": "2.11.1", | |
| 1258 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.11.1.tgz", | |
| 1259 | + "integrity": "sha512-2SN2z8qkc2hk/GgTYA8RN54wtsCDZShg9gI2Mq1vLhdj1adcv5fhTbiEmExZUaAMqlizxiEpULQDfHM5iYtn1g==", | |
| 1260 | + "license": "MIT", | |
| 1261 | + "dependencies": { | |
| 1262 | + "@peculiar/asn1-cms": "^2.11.1", | |
| 1263 | + "@peculiar/asn1-pkcs8": "^2.11.1", | |
| 1264 | + "@peculiar/asn1-rsa": "^2.11.1", | |
| 1265 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1266 | + "asn1js": "^3.0.10", | |
| 1267 | + "tslib": "^2.8.1" | |
| 1268 | + }, | |
| 1269 | + "engines": { | |
| 1270 | + "node": ">=14" | |
| 1271 | + } | |
| 1272 | + }, | |
| 1273 | + "node_modules/@peculiar/asn1-pkcs8": { | |
| 1274 | + "version": "2.11.1", | |
| 1275 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.11.1.tgz", | |
| 1276 | + "integrity": "sha512-HqsSrnpQghRp9SM9QSmR6fa4z/BNktnKq7928+oq4qF0VAnuHZ4cyePKvcxh9fP4taBCP/WHNItlVNsYaQm2qw==", | |
| 1277 | + "license": "MIT", | |
| 1278 | + "dependencies": { | |
| 1279 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1280 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1281 | + "asn1js": "^3.0.10", | |
| 1282 | + "tslib": "^2.8.1" | |
| 1283 | + }, | |
| 1284 | + "engines": { | |
| 1285 | + "node": ">=14" | |
| 1286 | + } | |
| 1287 | + }, | |
| 1288 | + "node_modules/@peculiar/asn1-pkcs9": { | |
| 1289 | + "version": "2.11.1", | |
| 1290 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.11.1.tgz", | |
| 1291 | + "integrity": "sha512-OHFkTg8D2zYafILqFE4KPbqX8srpvd3diGDc2h2cduumawc765mOHGcuFMGvLWlL2bbCMWMmMSCtlXptsOuiPA==", | |
| 1292 | + "license": "MIT", | |
| 1293 | + "dependencies": { | |
| 1294 | + "@peculiar/asn1-cms": "^2.11.1", | |
| 1295 | + "@peculiar/asn1-pfx": "^2.11.1", | |
| 1296 | + "@peculiar/asn1-pkcs8": "^2.11.1", | |
| 1297 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1298 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1299 | + "@peculiar/asn1-x509-attr": "^2.11.1", | |
| 1300 | + "asn1js": "^3.0.10", | |
| 1301 | + "tslib": "^2.8.1" | |
| 1302 | + }, | |
| 1303 | + "engines": { | |
| 1304 | + "node": ">=14" | |
| 1305 | + } | |
| 1306 | + }, | |
| 1307 | + "node_modules/@peculiar/asn1-rsa": { | |
| 1308 | + "version": "2.11.1", | |
| 1309 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.11.1.tgz", | |
| 1310 | + "integrity": "sha512-6KwKGjulF489CpidZqkogNgLj6oGzgC4BL2FClM8PuJQ4t5NqT4q4a6A4vrSxBIBhMnL8hGYkLOpbVw0Vq38Tw==", | |
| 1311 | + "license": "MIT", | |
| 1312 | + "dependencies": { | |
| 1313 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1314 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1315 | + "asn1js": "^3.0.10", | |
| 1316 | + "tslib": "^2.8.1" | |
| 1317 | + }, | |
| 1318 | + "engines": { | |
| 1319 | + "node": ">=14" | |
| 1320 | + } | |
| 1321 | + }, | |
| 1322 | + "node_modules/@peculiar/asn1-schema": { | |
| 1323 | + "version": "2.11.1", | |
| 1324 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.11.1.tgz", | |
| 1325 | + "integrity": "sha512-jaU9OaCcbZUdyXx9hMETZB9xoNmxTGjOGFqd3cOwKFkpKnyKd9WxF3uqj4PvX4cyOMP9bSdHg5YyML2qtx/d/g==", | |
| 1326 | + "license": "MIT", | |
| 1327 | + "dependencies": { | |
| 1328 | + "@peculiar/utils": "^2.0.2", | |
| 1329 | + "asn1js": "^3.0.10", | |
| 1330 | + "tslib": "^2.8.1" | |
| 1331 | + }, | |
| 1332 | + "engines": { | |
| 1333 | + "node": ">=14" | |
| 1334 | + } | |
| 1335 | + }, | |
| 1336 | + "node_modules/@peculiar/asn1-x509": { | |
| 1337 | + "version": "2.11.1", | |
| 1338 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.11.1.tgz", | |
| 1339 | + "integrity": "sha512-SXU4/X6B3FquqQAN6ARI0bFDUV7+L1WlvPEPMKzEMkstd2D7UyM0r93fv241+OjdhqAKYGx5MvV3gzZMAp0APA==", | |
| 1340 | + "license": "MIT", | |
| 1341 | + "dependencies": { | |
| 1342 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1343 | + "@peculiar/utils": "^2.0.2", | |
| 1344 | + "asn1js": "^3.0.10", | |
| 1345 | + "tslib": "^2.8.1" | |
| 1346 | + }, | |
| 1347 | + "engines": { | |
| 1348 | + "node": ">=14" | |
| 1349 | + } | |
| 1350 | + }, | |
| 1351 | + "node_modules/@peculiar/asn1-x509-attr": { | |
| 1352 | + "version": "2.11.1", | |
| 1353 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.11.1.tgz", | |
| 1354 | + "integrity": "sha512-n7RKFrbTzt8pGBlZ90kmKEn1qsLTTyw7lrvHMK0xsA42kQugPk/GXYpNbEcl7DkkdVsU/one5UX7KQPfxLj8vQ==", | |
| 1355 | + "license": "MIT", | |
| 1356 | + "dependencies": { | |
| 1357 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1358 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1359 | + "asn1js": "^3.0.10", | |
| 1360 | + "tslib": "^2.8.1" | |
| 1361 | + }, | |
| 1362 | + "engines": { | |
| 1363 | + "node": ">=14" | |
| 1364 | + } | |
| 1365 | + }, | |
| 1366 | + "node_modules/@peculiar/asn1-x509-post-quantum": { | |
| 1367 | + "version": "2.11.1", | |
| 1368 | + "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-post-quantum/-/asn1-x509-post-quantum-2.11.1.tgz", | |
| 1369 | + "integrity": "sha512-yD/pxCQ97nzwF7MGAW4kRd1WVLiMPhD39HxOnAr38DfGFwbpVhPnMbq+r6WX0XUrxn4w8ulsTdUafwVl46igLA==", | |
| 1370 | + "license": "MIT", | |
| 1371 | + "dependencies": { | |
| 1372 | + "@peculiar/asn1-asym-key": "^2.11.1", | |
| 1373 | + "@peculiar/asn1-schema": "^2.11.1", | |
| 1374 | + "@peculiar/asn1-x509": "^2.11.1", | |
| 1375 | + "asn1js": "^3.0.10", | |
| 1376 | + "tslib": "^2.8.1" | |
| 1377 | + }, | |
| 1378 | + "engines": { | |
| 1379 | + "node": ">=14" | |
| 1380 | + } | |
| 1381 | + }, | |
| 1382 | + "node_modules/@peculiar/utils": { | |
| 1383 | + "version": "2.0.3", | |
| 1384 | + "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz", | |
| 1385 | + "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==", | |
| 1386 | + "license": "MIT", | |
| 1387 | + "dependencies": { | |
| 1388 | + "tslib": "^2.8.1" | |
| 1389 | + } | |
| 1390 | + }, | |
| 1391 | + "node_modules/@peculiar/x509": { | |
| 1392 | + "version": "2.2.0", | |
| 1393 | + "resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-2.2.0.tgz", | |
| 1394 | + "integrity": "sha512-adpW58ySPQMOUPv8pTKT3RIyCFqfUFt8X05ukPdtkQToXDVr8dMtxuenik1yx8tNFTbpApWsM/Hi5SzlIx48+Q==", | |
| 1395 | + "license": "MIT", | |
| 1396 | + "dependencies": { | |
| 1397 | + "@peculiar/asn1-cms": "^2.11.0", | |
| 1398 | + "@peculiar/asn1-csr": "^2.11.0", | |
| 1399 | + "@peculiar/asn1-ecc": "^2.11.0", | |
| 1400 | + "@peculiar/asn1-pkcs9": "^2.11.0", | |
| 1401 | + "@peculiar/asn1-rsa": "^2.11.0", | |
| 1402 | + "@peculiar/asn1-schema": "^2.11.0", | |
| 1403 | + "@peculiar/asn1-x509": "^2.11.0", | |
| 1404 | + "@peculiar/asn1-x509-post-quantum": "^2.11.0", | |
| 1405 | + "pvtsutils": "^1.3.6", | |
| 1406 | + "tslib": "^2.8.1", | |
| 1407 | + "tsyringe": "^4.10.0" | |
| 1408 | + }, | |
| 1409 | + "engines": { | |
| 1410 | + "node": ">=20.0.0" | |
| 1411 | + } | |
| 1412 | + }, | |
| 1413 | + "node_modules/@poppinss/colors": { | |
| 1414 | + "version": "4.1.6", | |
| 1415 | + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", | |
| 1416 | + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", | |
| 1417 | + "dev": true, | |
| 1418 | + "license": "MIT", | |
| 1419 | + "dependencies": { | |
| 1420 | + "kleur": "^4.1.5" | |
| 1421 | + } | |
| 1422 | + }, | |
| 1423 | + "node_modules/@poppinss/dumper": { | |
| 1424 | + "version": "0.6.5", | |
| 1425 | + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", | |
| 1426 | + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", | |
| 1427 | + "dev": true, | |
| 1428 | + "license": "MIT", | |
| 1429 | + "dependencies": { | |
| 1430 | + "@poppinss/colors": "^4.1.5", | |
| 1431 | + "@sindresorhus/is": "^7.0.2", | |
| 1432 | + "supports-color": "^10.0.0" | |
| 1433 | + } | |
| 1434 | + }, | |
| 1435 | + "node_modules/@poppinss/exception": { | |
| 1436 | + "version": "1.2.3", | |
| 1437 | + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", | |
| 1438 | + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", | |
| 1439 | + "dev": true, | |
| 1440 | + "license": "MIT" | |
| 1441 | + }, | |
| 1442 | + "node_modules/@simplewebauthn/server": { | |
| 1443 | + "version": "14.1.0", | |
| 1444 | + "resolved": "https://registry.npmjs.org/@simplewebauthn/server/-/server-14.1.0.tgz", | |
| 1445 | + "integrity": "sha512-HPRRBR4Vzr45+RVvbmf6JuCfGdYYcSs4Pnnnp9YSY2IABa4JKnG+wxybczoB7rmdLCOMS/mbBa2ZL/Bcz58UlA==", | |
| 1446 | + "license": "MIT", | |
| 1447 | + "dependencies": { | |
| 1448 | + "@hexagon/base64": "^1.1.27", | |
| 1449 | + "@levischuck/tiny-cbor": "^0.2.2", | |
| 1450 | + "@peculiar/asn1-android": "^2.6.0", | |
| 1451 | + "@peculiar/asn1-ecc": "^2.6.1", | |
| 1452 | + "@peculiar/asn1-rsa": "^2.6.1", | |
| 1453 | + "@peculiar/asn1-schema": "^2.6.0", | |
| 1454 | + "@peculiar/asn1-x509": "^2.6.1", | |
| 1455 | + "@peculiar/asn1-x509-post-quantum": "^2.9.4", | |
| 1456 | + "@peculiar/x509": "^2.1.0", | |
| 1457 | + "reflect-metadata": "^0.2.2" | |
| 1458 | + }, | |
| 1459 | + "engines": { | |
| 1460 | + "node": ">=22.0.0" | |
| 1461 | + } | |
| 1462 | + }, | |
| 1463 | + "node_modules/@sindresorhus/is": { | |
| 1464 | + "version": "7.2.0", | |
| 1465 | + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", | |
| 1466 | + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", | |
| 1467 | + "dev": true, | |
| 1468 | + "license": "MIT", | |
| 1469 | + "engines": { | |
| 1470 | + "node": ">=18" | |
| 1471 | + }, | |
| 1472 | + "funding": { | |
| 1473 | + "url": "https://github.com/sindresorhus/is?sponsor=1" | |
| 1474 | + } | |
| 1475 | + }, | |
| 1476 | + "node_modules/@speed-highlight/core": { | |
| 1477 | + "version": "1.2.24", | |
| 1478 | + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz", | |
| 1479 | + "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==", | |
| 1480 | + "dev": true, | |
| 1481 | + "license": "CC0-1.0" | |
| 1482 | + }, | |
| 1483 | + "node_modules/@types/node": { | |
| 1484 | + "version": "18.19.130", | |
| 1485 | + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", | |
| 1486 | + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", | |
| 1487 | + "dev": true, | |
| 1488 | + "license": "MIT", | |
| 1489 | + "dependencies": { | |
| 1490 | + "undici-types": "~5.26.4" | |
| 1491 | + } | |
| 1492 | + }, | |
| 1493 | + "node_modules/@types/node-fetch": { | |
| 1494 | + "version": "2.6.13", | |
| 1495 | + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz", | |
| 1496 | + "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==", | |
| 1497 | + "dev": true, | |
| 1498 | + "license": "MIT", | |
| 1499 | + "dependencies": { | |
| 1500 | + "@types/node": "*", | |
| 1501 | + "form-data": "^4.0.4" |
package.json added
| 1 | + { | |
| 2 | + "name": "docley", | |
| 3 | + "private": true, | |
| 4 | + "type": "module", | |
| 5 | + "scripts": { | |
| 6 | + "dev": "wrangler dev", | |
| 7 | + "deploy": "wrangler deploy", | |
| 8 | + "migrate": "wrangler d1 migrations apply docley-db --remote", | |
| 9 | + "test": "node --test test/*.test.mjs" | |
| 10 | + }, | |
| 11 | + "devDependencies": { | |
| 12 | + "wrangler": "4.169.0" | |
| 13 | + }, | |
| 14 | + "dependencies": { | |
| 15 | + "@simplewebauthn/server": "14.1.0" | |
| 16 | + } | |
| 17 | + } |
project.yml added
| 1 | + # XcodeGen spec: `brew install xcodegen && xcodegen` creates Docley.xcodeproj. | |
| 2 | + # iPhone and iPad only. There is no Mac app: Mac users use https://doctors.projectatom.ai. | |
| 3 | + name: Docley | |
| 4 | + options: | |
| 5 | + bundleIdPrefix: ai.projectatom | |
| 6 | + deploymentTarget: { iOS: "18.0" } | |
| 7 | + settings: | |
| 8 | + base: | |
| 9 | + MARKETING_VERSION: "1.0.0" | |
| 10 | + CURRENT_PROJECT_VERSION: "1" | |
| 11 | + SWIFT_VERSION: "5.0" | |
| 12 | + PRODUCT_NAME: Docley | |
| 13 | + PRODUCT_BUNDLE_IDENTIFIER: ai.projectatom.docley | |
| 14 | + DEVELOPMENT_TEAM: 22HV69L32T | |
| 15 | + CODE_SIGN_STYLE: Automatic | |
| 16 | + ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon | |
| 17 | + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: AccentColor | |
| 18 | + targets: | |
| 19 | + Docley: | |
| 20 | + type: application | |
| 21 | + platform: iOS | |
| 22 | + sources: [Apps/iOS] | |
| 23 | + settings: | |
| 24 | + base: | |
| 25 | + TARGETED_DEVICE_FAMILY: "1,2" # iPhone and iPad | |
| 26 | + SUPPORTS_MACCATALYST: NO | |
| 27 | + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: NO | |
| 28 | + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD: NO | |
| 29 | + PROVISIONING_PROFILE_SPECIFIER: $(DOCLEY_IOS_RELEASE_PROFILE) | |
| 30 | + CODE_SIGN_ENTITLEMENTS: Apps/iOS/Docley.entitlements # webcredentials: passkeys work in the in-app web view | |
| 31 | + info: | |
| 32 | + path: Apps/iOS/Info.plist | |
| 33 | + properties: | |
| 34 | + CFBundleDisplayName: Docley | |
| 35 | + CFBundleShortVersionString: $(MARKETING_VERSION) | |
| 36 | + CFBundleVersion: $(CURRENT_PROJECT_VERSION) | |
| 37 | + ITSAppUsesNonExemptEncryption: false | |
| 38 | + LSApplicationCategoryType: public.app-category.medical | |
| 39 | + NSHumanReadableCopyright: "A Project ATOM project. Free and open source, public domain (Unlicense)." | |
| 40 | + UILaunchScreen: { UIColorName: LaunchBackground } | |
| 41 | + UISupportedInterfaceOrientations: [UIInterfaceOrientationPortrait] | |
| 42 | + UISupportedInterfaceOrientations~ipad: [UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight] |
src/assets.js added
| 1 | + export const ATOM_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><rect width="512" height="512" rx="96" fill="#0d0d0f"/><g fill="none" stroke="#F58025" stroke-width="22"><ellipse cx="256" cy="256" rx="196" ry="74"/><ellipse cx="256" cy="256" rx="196" ry="74" transform="rotate(60 256 256)"/><ellipse cx="256" cy="256" rx="196" ry="74" transform="rotate(-60 256 256)"/></g><circle cx="256" cy="256" r="58" fill="#F58025"/><circle cx="452" cy="256" r="22" fill="#fff"/><circle cx="158" cy="86" r="22" fill="#fff"/><circle cx="158" cy="426" r="22" fill="#fff"/></svg>`; | |
| 2 | + | |
| 3 | + export const CSS = ` | |
| 4 | + :root{--bg:#000;--panel:#111114;--line:#26262c;--text:#f4f4f5;--muted:#a1a1aa;--accent:#F58025;--accent-ink:#1a0d03;--ok:#4ade80} | |
| 5 | + *{box-sizing:border-box}html{-webkit-text-size-adjust:100%} | |
| 6 | + body{margin:0;background:var(--bg);color:var(--text);font:16px/1.55 -apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Helvetica,Arial,sans-serif} | |
| 7 | + a{color:var(--text)}a:hover{color:var(--accent)} | |
| 8 | + .wrap{max-width:960px;margin:0 auto;padding:0 16px} | |
| 9 | + header.top{border-bottom:1px solid var(--line)} | |
| 10 | + header.top .wrap{display:flex;align-items:center;justify-content:space-between;height:60px;gap:12px} | |
| 11 | + .brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:700;font-size:18px;letter-spacing:-.01em} | |
| 12 | + .brand img{width:28px;height:28px} | |
| 13 | + nav.links{display:flex;gap:18px;font-size:15px}nav.links a{text-decoration:none;color:var(--muted)}nav.links a:hover{color:var(--text)} | |
| 14 | + .hero{padding:56px 0 28px} | |
| 15 | + .hero h1{font-size:clamp(30px,6vw,52px);line-height:1.08;letter-spacing:-.025em;margin:0 0 14px;text-wrap:balance} | |
| 16 | + .hero p{color:var(--muted);font-size:clamp(16px,2.4vw,19px);max-width:640px;margin:0;text-wrap:pretty} | |
| 17 | + form.search{display:flex;gap:10px;flex-wrap:wrap;margin:28px 0 8px} | |
| 18 | + form.search input,form.search select{background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:999px;padding:13px 18px;font-size:16px;min-width:0} | |
| 19 | + form.search input{flex:1 1 280px}form.search select{flex:0 0 auto} | |
| 20 | + .pill{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:999px;padding:13px 22px;font-weight:600;font-size:16px;border:1px solid var(--accent);background:var(--accent);color:var(--accent-ink);text-decoration:none;cursor:pointer} | |
| 21 | + .pill:hover{color:var(--accent-ink);filter:brightness(1.08)} | |
| 22 | + .pill.ghost{background:transparent;color:var(--text);border-color:var(--line)}.pill.ghost:hover{border-color:var(--accent);color:var(--text)} | |
| 23 | + .pill[disabled]{opacity:.55;cursor:not-allowed} | |
| 24 | + .hint{color:var(--muted);font-size:14px} | |
| 25 | + .grid3{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px;margin:36px 0} | |
| 26 | + .card{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:20px} | |
| 27 | + .card h2,.card h3{margin:0 0 6px;font-size:18px}.card p{margin:0;color:var(--muted)} | |
| 28 | + .results{list-style:none;padding:0;margin:20px 0} | |
| 29 | + .results li{border-bottom:1px solid var(--line)} | |
| 30 | + .results a{display:flex;justify-content:space-between;gap:12px;padding:16px 4px;text-decoration:none} | |
| 31 | + .results .nm{font-weight:600;font-size:17px}.results .meta{color:var(--muted);font-size:14px} | |
| 32 | + .results .loc{color:var(--muted);font-size:14px;text-align:right;white-space:nowrap} | |
| 33 | + .pager{display:flex;gap:10px;justify-content:space-between;margin:20px 0 40px} | |
| 34 | + .doc h1{font-size:clamp(28px,5vw,40px);letter-spacing:-.02em;margin:36px 0 4px;line-height:1.15} | |
| 35 | + .doc .sub{color:var(--muted);font-size:18px;margin:0 0 24px} | |
| 36 | + .facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px;margin:0 0 24px} | |
| 37 | + .facts div span{display:block;color:var(--muted);font-size:13px;text-transform:uppercase;letter-spacing:.06em} | |
| 38 | + .scores{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px;margin:0 0 24px} | |
| 39 | + .score .big{font-size:40px;font-weight:700;letter-spacing:-.02em} | |
| 40 | + .score .big small{font-size:16px;color:var(--muted);font-weight:500} | |
| 41 | + .prose{max-width:720px}.prose h1{font-size:clamp(28px,5vw,40px);letter-spacing:-.02em;margin:36px 0 12px} | |
| 42 | + .prose h2{font-size:20px;margin:28px 0 8px}.prose p,.prose li{color:#d4d4d8} | |
| 43 | + .prose ol,.prose ul{padding-left:22px} | |
| 44 | + footer.bot{border-top:1px solid var(--line);margin-top:56px;padding:24px 0 40px;color:var(--muted);font-size:14px} | |
| 45 | + footer.bot .wrap{display:flex;flex-wrap:wrap;gap:10px 22px;justify-content:space-between} | |
| 46 | + footer.bot a{color:var(--muted)} | |
| 47 | + .notice{border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:12px;padding:14px 16px;background:var(--panel);margin:0 0 24px} | |
| 48 | + @media (max-width:560px){.results a{flex-direction:column;gap:2px}.results .loc{text-align:left}nav.links{gap:14px;font-size:14px}} | |
| 49 | + `; | |
| 50 | + | |
| 51 | + export const CSS_FORMS = ` | |
| 52 | + .stack{display:flex;flex-direction:column;gap:16px;margin:20px 0} | |
| 53 | + .stack label{display:flex;flex-direction:column;gap:6px;font-weight:600} | |
| 54 | + .stack input[type=text],.stack input:not([type]),.stack input[inputmode],.stack textarea,form.inline select{background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:14px;padding:12px 14px;font:inherit;font-weight:400} | |
| 55 | + .stack label.check{flex-direction:row;align-items:flex-start;gap:10px;font-weight:400} | |
| 56 | + fieldset.q{border:1px solid var(--line);border-radius:14px;padding:12px 14px;margin:0}fieldset.q legend{padding:0 6px;font-weight:600} | |
| 57 | + .stars{display:flex;gap:8px}.stars label{cursor:pointer}.stars input{position:absolute;opacity:0;width:1px;height:1px} | |
| 58 | + .stars span{display:inline-flex;width:44px;height:44px;border-radius:999px;border:1px solid var(--line);align-items:center;justify-content:center;font-weight:700} | |
| 59 | + .stars input:checked+span{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}.stars input:focus-visible+span{outline:2px solid var(--accent);outline-offset:2px} | |
| 60 | + form.inline{display:inline-flex;gap:6px;align-items:center;margin:6px 6px 0 0} | |
| 61 | + button.link{background:none;border:0;color:var(--muted);text-decoration:underline;cursor:pointer;font:inherit;font-size:14px;padding:0} | |
| 62 | + .comments{list-style:none;padding:0;margin:0 0 24px}.comments li{border-bottom:1px solid var(--line);padding:14px 0} | |
| 63 | + .comments .by{color:var(--muted);font-size:14px}.answer{margin:10px 0 0 14px;padding-left:12px;border-left:2px solid var(--accent)} | |
| 64 | + details.reply summary{cursor:pointer;color:var(--muted);font-size:14px;margin-top:6px} | |
| 65 | + .row{display:flex;gap:10px;flex-wrap:wrap;margin:0 0 24px} | |
| 66 | + .keys{list-style:none;padding:0;margin:20px 0;display:flex;flex-direction:column;gap:12px}.prose .keys li{color:var(--text)}.keys .card p{margin:0 0 8px} | |
| 67 | + .notice[hidden]{display:none} | |
| 68 | + `; |
src/auth.js added
| 1 | + // Signed session cookies and small crypto helpers. Sign-in itself is passkeys only (passkeys.js). | |
| 2 | + const enc = new TextEncoder(); | |
| 3 | + export const b64u = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); | |
| 4 | + | |
| 5 | + async function hmac(secret, msg) { | |
| 6 | + const key = await crypto.subtle.importKey('raw', enc.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']); | |
| 7 | + return b64u(await crypto.subtle.sign('HMAC', key, enc.encode(msg))); | |
| 8 | + } | |
| 9 | + | |
| 10 | + const COOKIE = 'dly'; | |
| 11 | + const DAYS = 90; | |
| 12 | + | |
| 13 | + export async function makeSession(env, personId) { | |
| 14 | + const exp = Math.floor(Date.now() / 1000) + DAYS * 86400; | |
| 15 | + const body = `${personId}.${exp}`; | |
| 16 | + return `${COOKIE}=${body}.${await hmac(env.SESSION_SECRET || 'dev-secret', body)}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${DAYS * 86400}`; | |
| 17 | + } | |
| 18 | + export const clearSession = () => `${COOKIE}=; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=0`; | |
| 19 | + | |
| 20 | + export async function readSession(env, request) { | |
| 21 | + const raw = (request.headers.get('cookie') || '').split(/;\s*/).find((c) => c.startsWith(COOKIE + '=')); | |
| 22 | + if (!raw) return null; | |
| 23 | + const [id, exp, sig] = raw.slice(COOKIE.length + 1).split('.'); | |
| 24 | + if (!id || !exp || !sig || Number(exp) < Date.now() / 1000) return null; | |
| 25 | + if ((await hmac(env.SESSION_SECRET || 'dev-secret', `${id}.${exp}`)) !== sig) return null; | |
| 26 | + return env.DB.prepare('SELECT id, clinician_npi, is_admin FROM people WHERE id=?1').bind(id).first(); | |
| 27 | + } | |
| 28 | + | |
| 29 | + export async function sha256(text) { | |
| 30 | + return b64u(await crypto.subtle.digest('SHA-256', enc.encode(text))); | |
| 31 | + } | |
| 32 | + | |
| 33 | + // Constant-time comparison: hash both sides so the lengths always match. | |
| 34 | + export async function safeEqual(a, b) { | |
| 35 | + const [x, y] = await Promise.all([a, b].map((s) => crypto.subtle.digest('SHA-256', enc.encode(String(s))))); | |
| 36 | + const u = new Uint8Array(x), v = new Uint8Array(y); | |
| 37 | + let diff = 0; | |
| 38 | + for (let i = 0; i < u.length; i++) diff |= u[i] ^ v[i]; | |
| 39 | + return diff === 0; | |
| 40 | + } | |
| 41 | + | |
| 42 | + // For the new-accounts-per-day limit. Keeps an HMAC of the IP, never the IP. | |
| 43 | + export const ipHash = (env, ip) => hmac(env.SESSION_SECRET || 'dev-secret', 'ip:' + (ip || 'unknown')); | |
| 44 | + | |
| 45 | + export const newToken = () => b64u(crypto.getRandomValues(new Uint8Array(32))); | |
| 46 | + export const newId = () => b64u(crypto.getRandomValues(new Uint8Array(12))); | |
| 47 | + | |
| 48 | + const ADJ = ['Kind', 'Bright', 'Calm', 'Brave', 'Gentle', 'Honest', 'Steady', 'Warm', 'Clear', 'Quiet', 'Hopeful', 'Patient']; | |
| 49 | + const NOUN = ['Oak', 'River', 'Sparrow', 'Harbor', 'Meadow', 'Cedar', 'Comet', 'Willow', 'Lantern', 'Falcon', 'Maple', 'Summit']; | |
| 50 | + export function alias() { | |
| 51 | + const r = crypto.getRandomValues(new Uint16Array(3)); | |
| 52 | + return `${ADJ[r[0] % ADJ.length]} ${NOUN[r[1] % NOUN.length]} ${100 + (r[2] % 900)}`; | |
| 53 | + } |
src/forms.js added
| 1 | + import { esc, docUrl } from './views.js'; | |
| 2 | + | |
| 3 | + export const QUESTIONS = { | |
| 4 | + patient: ['Listened to me', 'Explained things clearly', 'Respected my time', 'Treated me with kindness and respect', 'Would recommend to family'], | |
| 5 | + colleague: ['Clinical skill', 'Sound judgment', 'Teamwork', 'Treats patients with respect', 'Treats staff with respect'], | |
| 6 | + }; | |
| 7 | + | |
| 8 | + const msg = (m) => (m ? `<div class="notice">${esc(m)}</div>` : ''); | |
| 9 | + | |
| 10 | + const status = '<p class="notice" data-passkey-status role="status" hidden></p>'; | |
| 11 | + | |
| 12 | + export const signinPage = ({ next, error }) => `<article class="prose"><h1>Sign in with a passkey</h1> | |
| 13 | + <p>Docley uses passkeys only: no passwords, no email, no texted codes. Your phone or computer unlocks your passkey with Face ID, a fingerprint or your screen lock, and we never see any of it.</p> | |
| 14 | + ${msg(error)}${status}<div class="stack"> | |
| 15 | + <button class="pill" type="button" data-passkey="signin" data-next="${esc(next)}">Sign in with passkey</button> | |
| 16 | + <button class="pill ghost" type="button" data-passkey="register" data-next="${esc(next)}">Create an account with a passkey</button></div> | |
| 17 | + <p class="hint">One person, one account. New here? Creating an account makes a passkey on this device. Afterwards, add a second passkey on another device from your Passkeys page: it is your way back in if you lose this one.</p></article>`; | |
| 18 | + | |
| 19 | + const fmtWhen = (s) => (s ? esc(String(s).slice(0, 10)) : 'never'); | |
| 20 | + | |
| 21 | + export function accountPage({ passkeys }) { | |
| 22 | + const only = passkeys.length === 1; | |
| 23 | + const rows = passkeys.map((k) => `<li class="card"><p><strong>${esc(k.name || 'Passkey')}</strong></p> | |
| 24 | + <p class="hint">${k.backed_up ? 'Synced to your other devices' : 'Saved on one device'} · added ${fmtWhen(k.created)} · last used ${fmtWhen(k.last_used)}</p> | |
| 25 | + <button class="pill ghost" type="button" data-passkey="remove" data-id="${esc(k.credential_id)}"${only ? ' disabled title="Add another passkey before removing this one"' : ''}>Remove</button></li>`).join(''); | |
| 26 | + return `<article class="prose"><h1>Your passkeys</h1> | |
| 27 | + <p>Passkeys are the only way into your Docley account. There are no passwords, email links or texted codes, so <strong>add a second passkey on another device</strong>. If you lose this phone or computer, that second passkey is your way back in.</p> | |
| 28 | + ${status}<ul class="keys">${rows}</ul> | |
| 29 | + <div class="stack"><label>Name for the new passkey (optional)<input name="passkey-name" data-passkey-name maxlength="60" placeholder="For example: work laptop"></label> | |
| 30 | + <button class="pill" type="button" data-passkey="add">Add another passkey</button></div> | |
| 31 | + <p class="hint">To add a passkey on another device, sign in there with a passkey you already have (most browsers can use your phone by scanning a QR code), then add one from this page.</p></article>`; | |
| 32 | + } | |
| 33 | + | |
| 34 | + export const adminSetupPage = ({ token, me }) => `<article class="prose"><h1>Set up an admin passkey</h1> | |
| 35 | + ${me ? `<p>This one-time link makes the account you are signed in to a Docley admin.</p> | |
| 36 | + <form class="stack" method="post" action="/admin/setup"><input type="hidden" name="token" value="${esc(token)}"><button class="pill" type="submit">Make this account an admin</button></form>` | |
| 37 | + : `<p>This one-time link creates a new Docley admin account with a passkey on this device. It works once and expires 15 minutes after it was made.</p> | |
| 38 | + ${status}<div class="stack"><button class="pill" type="button" data-passkey="admin" data-token="${esc(token)}" data-next="/admin">Create admin passkey</button></div> | |
| 39 | + <p class="hint">Then add a second passkey on another device from your Passkeys page.</p>`}</article>`; | |
| 40 | + | |
| 41 | + const stars = (name, label, val) => `<fieldset class="q"><legend>${esc(label)}</legend><div class="stars">${[1, 2, 3, 4, 5] | |
| 42 | + .map((n) => `<label><input type="radio" name="${name}" value="${n}" required${val === n ? ' checked' : ''}><span>${n}</span></label>`) | |
| 43 | + .join('')}</div></fieldset>`; | |
| 44 | + | |
| 45 | + export function ratePage({ d, kind, existing, error }) { | |
| 46 | + const qs = QUESTIONS[kind]; | |
| 47 | + return `<article class="prose"><h1>Rate ${esc(d.name)}${d.credential ? ', ' + esc(d.credential) : ''}</h1> | |
| 48 | + <p class="hint">${kind === 'colleague' ? 'Colleague rating, as a verified clinician.' : 'Patient rating.'} 1 is poor, 5 is excellent. ${existing ? 'This updates your earlier rating.' : ''}</p> | |
| 49 | + ${msg(error)}<form class="stack" method="post" action="/doctor/${d.npi}/rate"> | |
| 50 | + <input type="hidden" name="kind" value="${kind}"> | |
| 51 | + ${qs.map((q, i) => stars('q' + (i + 1), q, existing?.['q' + (i + 1)])).join('')} | |
| 52 | + <label>Comment (optional)<textarea name="comment" maxlength="600" rows="4" placeholder="Your own experience, kind and specific. No health details.">${esc(existing?.comment || '')}</textarea></label> | |
| 53 | + <label class="check"><input type="checkbox" name="attest" value="1" required> ${kind === 'colleague' ? 'I have worked with this doctor, and I am not rating my own practice.' : 'I was this doctor’s patient, and I am not their family, staff or colleague.'}</label> | |
| 54 | + <button class="pill" type="submit">${existing ? 'Update rating' : 'Post rating'}</button> | |
| 55 | + <p class="hint">Please follow the <a href="/rules">rating rules</a>.</p></form></article>`; | |
| 56 | + } | |
| 57 | + | |
| 58 | + export const claimPage = ({ d, error, done }) => `<article class="prose"><h1>Claim your page</h1> | |
| 59 | + ${done ? `<div class="notice">Thanks. We will call the practice phone listed for this NPI to confirm it's you. Once confirmed, you can reply to ratings and records, and rate colleagues.</div>` : ` | |
| 60 | + <p>For ${esc(d.name)}${d.credential ? ', ' + esc(d.credential) : ''} (NPI ${d.npi}). To confirm it's you, we call the practice phone listed in the NPI registry${d.phone ? ` (${esc(d.phone)})` : ''}.</p> | |
| 61 | + ${msg(error)}<form class="stack" method="post" action="/doctor/${d.npi}/claim"> | |
| 62 | + <label>Best time and person to ask for at your practice<textarea name="note" maxlength="300" rows="3" required></textarea></label> | |
| 63 | + <button class="pill" type="submit">Request to claim</button></form>`} | |
| 64 | + <p><a href="${docUrl(d)}">Back to the page</a></p></article>`; | |
| 65 | + | |
| 66 | + export const replyForm = (action) => `<details class="reply"><summary>Reply as this doctor</summary><form class="stack" method="post" action="${action}"> | |
| 67 | + <textarea name="body" maxlength="800" rows="3" required placeholder="Your public reply. Never share anything about a patient."></textarea><button class="pill ghost" type="submit">Post reply</button></form></details>`; | |
| 68 | + | |
| 69 | + export const flagForm = (id) => `<form class="inline" method="post" action="/flag/${esc(id)}"><select name="reason" aria-label="Why"><option value="rules">Breaks the rules</option><option value="health">Shares health details</option><option value="fake">Looks fake</option><option value="accusation">Accuses of a crime</option></select><button class="link" type="submit">Flag</button></form>`; | |
| 70 | + | |
| 71 | + export const thanksPage = ({ title, text, back }) => `<article class="prose"><h1>${esc(title)}</h1><p>${esc(text)}</p>${back ? `<p><a class="pill ghost" href="${esc(back)}">Back</a></p>` : ''}</article>`; | |
| 72 | + | |
| 73 | + export function adminPage({ held, flags, claims }) { | |
| 74 | + const act = (type, id, action, label, ghost) => | |
| 75 | + `<form class="inline" method="post" action="/admin/action"><input type="hidden" name="type" value="${type}"><input type="hidden" name="id" value="${esc(id)}"><input type="hidden" name="action" value="${action}"><button class="pill${ghost ? ' ghost' : ''}" type="submit">${label}</button></form>`; | |
| 76 | + return `<article class="prose"><h1>Review queue</h1> | |
| 77 | + <h2>Held comments (${held.length})</h2>${held.map((r) => `<div class="card"><p><a href="/doctor/${r.npi}">${esc(r.name)}</a> · ${esc(r.hold_reason || '')}</p><p>${esc(r.comment)}</p>${act('rating', r.id, 'approve', 'Show comment')} ${act('rating', r.id, 'remove', 'Remove rating', true)}</div>`).join('') || '<p class="hint">Nothing held.</p>'} | |
| 78 | + <h2>Flags (${flags.length})</h2>${flags.map((f) => `<div class="card"><p><a href="/doctor/${f.npi}">${esc(f.name)}</a> · flagged ${f.n}x: ${esc(f.reasons)}</p><p>${esc(f.comment || '(no comment)')}</p>${act('flag', f.rating_id, 'keep', 'Keep')} ${act('rating', f.rating_id, 'hide', 'Hide comment', true)} ${act('rating', f.rating_id, 'remove', 'Remove rating', true)}</div>`).join('') || '<p class="hint">No flags.</p>'} | |
| 79 | + <h2>Doctor claims (${claims.length})</h2>${claims.map((c) => `<div class="card"><p><a href="/doctor/${c.npi}">${esc(c.name)}</a> · NPI ${c.npi} · call ${esc(c.phone || 'no phone listed')}</p><p>${esc(c.note)}</p>${act('claim', c.id, 'approve', 'Approve')} ${act('claim', c.id, 'deny', 'Deny', true)}</div>`).join('') || '<p class="hint">No claims waiting.</p>'} | |
| 80 | + </article>`; | |
| 81 | + } |
src/index.js added
| 1 | + import { ATOM_SVG, CSS, CSS_FORMS } from './assets.js'; | |
| 2 | + import { NO_ORPHANS_CSS, NO_ORPHANS_JS } from './no-orphans.js'; | |
| 3 | + import { clearSession, readSession, newId, alias } from './auth.js'; | |
| 4 | + import { signinPage, accountPage, adminSetupPage, ratePage, claimPage, thanksPage, adminPage, QUESTIONS } from './forms.js'; | |
| 5 | + import { passkeyApi, adminSetup, findSetupLink, useSetupLink, listPasskeys } from './passkeys.js'; | |
| 6 | + import { PASSKEY_JS } from './passkey-client.js'; | |
| 7 | + import { moderate } from './moderate.js'; | |
| 8 | + import { STATES, layout, esc, homePage, searchPage, doctorPage, rulesPage, notFoundPage } from './views.js'; | |
| 9 | + | |
| 10 | + const PAGE = 25; | |
| 11 | + const MIN_RATINGS = 5; | |
| 12 | + const PRIOR = 3.5; // weighted average pulls small counts toward the middle | |
| 13 | + | |
| 14 | + const html = (body, status = 200, cache = 300, extra = {}) => | |
| 15 | + new Response(body, { | |
| 16 | + status, | |
| 17 | + headers: { | |
| 18 | + ...extra, | |
| 19 | + 'content-type': 'text/html; charset=utf-8', | |
| 20 | + 'cache-control': cache ? `public, max-age=${cache}` : 'private, no-store', | |
| 21 | + 'content-security-policy': "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'", | |
| 22 | + 'x-content-type-options': 'nosniff', | |
| 23 | + 'referrer-policy': 'strict-origin-when-cross-origin', | |
| 24 | + }, | |
| 25 | + }); | |
| 26 | + const json = (data, status = 200) => | |
| 27 | + new Response(JSON.stringify(data), { | |
| 28 | + status, | |
| 29 | + headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'public, max-age=300', 'access-control-allow-origin': '*' }, | |
| 30 | + }); | |
| 31 | + | |
| 32 | + // Turn free text into a safe FTS5 prefix query: "jane smi" -> "jane"* "smi"* | |
| 33 | + export function ftsQuery(q) { | |
| 34 | + const words = (q || '').toLowerCase().normalize('NFKD').replace(/[^\p{L}\p{N}\s]/gu, ' ').split(/\s+/).filter(Boolean).slice(0, 6); | |
| 35 | + return words.map((w) => `"${w}"*`).join(' '); | |
| 36 | + } | |
| 37 | + | |
| 38 | + export async function search(db, { q, state, page }) { | |
| 39 | + const off = (page - 1) * PAGE; | |
| 40 | + const st = STATES[state] ? state : null; | |
| 41 | + const fq = ftsQuery(q); | |
| 42 | + let rows; | |
| 43 | + if (fq) { | |
| 44 | + const sql = `SELECT d.npi,d.name,d.credential,d.specialty,d.city,d.state FROM doctors_fts f JOIN doctors d ON d.rowid=f.rowid | |
| 45 | + WHERE doctors_fts MATCH ?1 ${st ? 'AND d.state=?2' : ''} ORDER BY rank LIMIT ${PAGE + 1} OFFSET ${off}`; | |
| 46 | + rows = (await db.prepare(sql).bind(...(st ? [fq, st] : [fq])).all()).results; | |
| 47 | + } else if (st) { | |
| 48 | + rows = (await db.prepare(`SELECT npi,name,credential,specialty,city,state FROM doctors WHERE state=?1 ORDER BY city,last_name LIMIT ${PAGE + 1} OFFSET ${off}`).bind(st).all()).results; | |
| 49 | + } else rows = []; | |
| 50 | + return { rows: rows.slice(0, PAGE), more: rows.length > PAGE }; | |
| 51 | + } | |
| 52 | + | |
| 53 | + export async function getDoctor(db, npi) { | |
| 54 | + const [doc, recs, agg, com] = await db.batch([ | |
| 55 | + db.prepare('SELECT * FROM doctors WHERE npi=?1').bind(npi), | |
| 56 | + db.prepare('SELECT r.id,r.source,r.state,r.kind,r.case_status,r.action_date,r.summary,r.url,r.ended,x.body reply FROM records r LEFT JOIN record_replies x ON x.record_id=r.id WHERE r.npi=?1 ORDER BY r.action_date DESC').bind(npi), | |
| 57 | + db.prepare(`SELECT kind, COUNT(*) n, AVG((q1+q2+q3+q4+q5)/5.0) avg FROM ratings WHERE npi=?1 AND status!='removed' GROUP BY kind`).bind(npi), | |
| 58 | + db.prepare(`SELECT r.id,r.kind,r.alias,r.comment,r.updated,(r.q1+r.q2+r.q3+r.q4+r.q5)/5.0 avg,x.body reply FROM ratings r LEFT JOIN replies x ON x.rating_id=r.id | |
| 59 | + WHERE r.npi=?1 AND r.status='live' AND r.comment IS NOT NULL AND r.comment!='' ORDER BY r.updated DESC LIMIT 30`).bind(npi), | |
| 60 | + ]); | |
| 61 | + const d = doc.results[0]; | |
| 62 | + if (!d) return null; | |
| 63 | + const scores = {}; | |
| 64 | + for (const r of agg.results) { | |
| 65 | + scores[r.kind] = { | |
| 66 | + count: r.n, | |
| 67 | + score: r.n >= MIN_RATINGS ? Math.round(((r.avg * r.n + PRIOR * MIN_RATINGS) / (r.n + MIN_RATINGS)) * 10) / 10 : null, | |
| 68 | + }; | |
| 69 | + } | |
| 70 | + const { sex, first_name, middle_name, last_name, suffix, ...pub } = d; | |
| 71 | + return { ...pub, records: recs.results, scores, comments: com.results }; | |
| 72 | + } | |
| 73 | + | |
| 74 | + async function count(env, ctx) { | |
| 75 | + const cache = caches.default; | |
| 76 | + const key = new Request(env.SITE_URL + '/__count'); | |
| 77 | + const hit = await cache.match(key); | |
| 78 | + if (hit) return Number(await hit.text()); | |
| 79 | + const n = (await env.DB.prepare('SELECT COUNT(*) n FROM doctors').first('n')) || 0; | |
| 80 | + ctx.waitUntil(cache.put(key, new Response(String(n), { headers: { 'cache-control': 'max-age=3600' } }))); | |
| 81 | + return n; | |
| 82 | + } | |
| 83 | + | |
| 84 | + export default { | |
| 85 | + async fetch(request, env, ctx) { | |
| 86 | + const url = new URL(request.url); | |
| 87 | + const p = url.pathname.replace(/\/+$/, '') || '/'; | |
| 88 | + const site = env.SITE_URL || url.origin; | |
| 89 | + const ratingsOpen = env.RATINGS_OPEN === 'true'; | |
| 90 | + if (request.method === 'POST') return handlePost(request, env, url, p, site); | |
| 91 | + if (request.method !== 'GET' && request.method !== 'HEAD') return new Response('Method not allowed', { status: 405 }); | |
| 92 | + if (p === '/.well-known/apple-app-site-association') return new Response(JSON.stringify(AASA), { headers: { 'content-type': 'application/json', 'cache-control': 'public, max-age=3600' } }); | |
| 93 | + const me = await readSession(env, request); | |
| 94 | + const L = (o) => layout({ site, me, ...o }); | |
| 95 | + | |
| 96 | + if (p === '/assets/site.css') return new Response(CSS + CSS_FORMS + NO_ORPHANS_CSS, { headers: { 'content-type': 'text/css', 'cache-control': 'public, max-age=86400' } }); | |
| 97 | + if (p === '/assets/no-orphans.js') return new Response(NO_ORPHANS_JS, { headers: { 'content-type': 'text/javascript; charset=utf-8', 'cache-control': 'public, max-age=3600' } }); | |
| 98 | + if (p === '/assets/passkey.js') return new Response(PASSKEY_JS, { headers: { 'content-type': 'text/javascript; charset=utf-8', 'cache-control': 'public, max-age=3600' } }); | |
| 99 | + if (p === '/favicon.svg' || p === '/atom.svg') return new Response(ATOM_SVG, { headers: { 'content-type': 'image/svg+xml', 'cache-control': 'public, max-age=86400' } }); | |
| 100 | + if (p === '/robots.txt') | |
| 101 | + return new Response(`User-agent: *\nAllow: /\n\nUser-agent: GPTBot\nAllow: /\nUser-agent: ClaudeBot\nAllow: /\nUser-agent: PerplexityBot\nAllow: /\nUser-agent: Google-Extended\nAllow: /\n\nSitemap: ${site}/sitemap.xml\n`, { headers: { 'content-type': 'text/plain' } }); | |
| 102 | + if (p === '/sitemap.xml') { | |
| 103 | + const urls = ['/', '/rules', ...Object.keys(STATES).map((s) => `/search?state=${s}`)]; | |
| 104 | + return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls.map((u) => `<url><loc>${esc(site + u)}</loc></url>`).join('')}</urlset>`, { headers: { 'content-type': 'application/xml' } }); | |
| 105 | + } | |
| 106 | + if (p === '/llms.txt') | |
| 107 | + return new Response(`# Docley\n\n> A free, publicly owned registry of every licensed physician in the United States, built from the CMS NPPES NPI registry, with official public records (such as federal exclusions) shown on each doctor's page. Ratings are one per verified person. A Project ATOM project: https://projectatom.ai\n\n- Search: ${site}/search?q={name, specialty or city}&state={XX}\n- Doctor page: ${site}/doctor/{NPI}\n- JSON API: ${site}/api/search?q=...&state=XX and ${site}/api/doctor/{NPI}\n- Rating rules: ${site}/rules\n`, { headers: { 'content-type': 'text/plain; charset=utf-8' } }); | |
| 108 | + | |
| 109 | + if (p.startsWith('/api/passkeys')) return (await passkeyApi(request, env, url, p, me)) || json({ error: 'not_found' }, 404); | |
| 110 | + if (p === '/api/search') { | |
| 111 | + const page = Math.max(1, Math.min(40, Number(url.searchParams.get('page')) || 1)); | |
| 112 | + const r = await search(env.DB, { q: url.searchParams.get('q'), state: (url.searchParams.get('state') || '').toUpperCase(), page }); | |
| 113 | + return json({ page, more: r.more, results: r.rows }); | |
| 114 | + } | |
| 115 | + let m = /^\/api\/doctor\/(\d{10})$/.exec(p); | |
| 116 | + if (m) { | |
| 117 | + const d = await getDoctor(env.DB, m[1]); | |
| 118 | + return d ? json(d) : json({ error: 'not_found' }, 404); | |
| 119 | + } | |
| 120 | + | |
| 121 | + if (p === '/') return html(L({ title: 'Docley: every doctor in America, rated by the people', site, path: '/', body: homePage({ count: await count(env, ctx), ratingsOpen }) })); | |
| 122 | + if (p === '/rules') return html(L({ title: 'Rating rules · Docley', site, path: '/rules', body: rulesPage() }), 200, 3600); | |
| 123 | + if (p === '/search') { | |
| 124 | + const q = (url.searchParams.get('q') || '').slice(0, 80); | |
| 125 | + const state = (url.searchParams.get('state') || '').toUpperCase(); | |
| 126 | + const page = Math.max(1, Math.min(40, Number(url.searchParams.get('page')) || 1)); | |
| 127 | + const r = await search(env.DB, { q, state, page }); | |
| 128 | + const title = q ? `“${q}”${STATES[state] ? ' in ' + STATES[state] : ''} · Docley` : STATES[state] ? `Doctors in ${STATES[state]} · Docley` : 'Search · Docley'; | |
| 129 | + return html(L({ title, site, path: url.pathname + url.search, body: searchPage({ q, state, page, ...r }) })); | |
| 130 | + } | |
| 131 | + m = /^\/doctor\/(\d{10})(?:-[a-z0-9-]*)?$/.exec(p); | |
| 132 | + if (m) { | |
| 133 | + const d = await getDoctor(env.DB, m[1]); | |
| 134 | + if (!d) return html(L({ title: 'Not found · Docley', site, path: p, body: notFoundPage() }), 404); | |
| 135 | + return html(L({ title: `${d.name}${d.credential ? ', ' + d.credential : ''} · ${d.specialty || 'Physician'} in ${d.city}, ${d.state} · Docley`, site, path: `/doctor/${d.npi}`, body: doctorPage(d, { ratingsOpen, minRatings: MIN_RATINGS, me }), description: `${d.name} is a ${d.specialty || 'physician'} in ${d.city}, ${d.state} (NPI ${d.npi}). See public records and ratings from patients and colleagues.` })); | |
| 136 | + } | |
| 137 | + if (p === '/signin') { | |
| 138 | + const next = safeNext(url.searchParams.get('next')); | |
| 139 | + if (me) return redirect(next); | |
| 140 | + return html(L({ title: 'Sign in · Docley', path: p, passkeys: true, body: signinPage({ next }) }), 200, 0); | |
| 141 | + } | |
| 142 | + if (p === '/account') { | |
| 143 | + if (!me) return redirect('/signin?next=/account'); | |
| 144 | + return html(L({ title: 'Passkeys · Docley', path: p, passkeys: true, body: accountPage({ passkeys: await listPasskeys(env.DB, me.id) }) }), 200, 0); | |
| 145 | + } | |
| 146 | + if (p === '/admin/setup') { | |
| 147 | + const token = url.searchParams.get('token') || ''; | |
| 148 | + if (!(await findSetupLink(env.DB, token))) return notFound(); | |
| 149 | + return html(L({ title: 'Admin setup · Docley', path: p, passkeys: true, body: adminSetupPage({ token, me }) }), 200, 0, { 'referrer-policy': 'no-referrer' }); | |
| 150 | + } | |
| 151 | + if (p === '/signout') return new Response(null, { status: 303, headers: { location: '/', 'set-cookie': clearSession() } }); | |
| 152 | + m = /^\/doctor\/(\d{10})\/(rate|claim)$/.exec(p); | |
| 153 | + if (m) { | |
| 154 | + if (!ratingsOpen) return Response.redirect(site + '/doctor/' + m[1], 303); | |
| 155 | + if (!me) return Response.redirect(`${site}/signin?next=${encodeURIComponent(p + url.search)}`, 303); | |
| 156 | + const d = await env.DB.prepare('SELECT * FROM doctors WHERE npi=?1').bind(m[1]).first(); | |
| 157 | + if (!d) return html(L({ title: 'Not found · Docley', path: p, body: notFoundPage() }), 404); | |
| 158 | + if (m[2] === 'claim') return html(L({ title: 'Claim your page · Docley', path: p, body: claimPage({ d }) }), 200, 0); | |
| 159 | + const kind = url.searchParams.get('kind') === 'colleague' ? 'colleague' : 'patient'; | |
| 160 | + if (kind === 'colleague' && !me.clinician_npi) return Response.redirect(site + '/doctor/' + d.npi, 303); | |
| 161 | + if (me.clinician_npi === d.npi) return Response.redirect(site + '/doctor/' + d.npi, 303); | |
| 162 | + const existing = await env.DB.prepare('SELECT * FROM ratings WHERE person_id=?1 AND npi=?2 AND kind=?3').bind(me.id, d.npi, kind).first(); | |
| 163 | + return html(L({ title: `Rate ${d.name} · Docley`, path: p, body: ratePage({ d, kind, existing }) }), 200, 0); | |
| 164 | + } | |
| 165 | + if (p === '/admin') { | |
| 166 | + if (!me?.is_admin) return notFound(); | |
| 167 | + const [held, flags, claims] = await env.DB.batch([ | |
| 168 | + env.DB.prepare(`SELECT r.id,r.npi,r.comment,r.hold_reason,d.name FROM ratings r JOIN doctors d ON d.npi=r.npi WHERE r.status='held' ORDER BY r.updated LIMIT 100`), | |
| 169 | + env.DB.prepare(`SELECT f.rating_id, COUNT(*) n, GROUP_CONCAT(DISTINCT f.reason) reasons, r.npi, r.comment, d.name FROM flags f JOIN ratings r ON r.id=f.rating_id JOIN doctors d ON d.npi=r.npi WHERE r.status='live' GROUP BY f.rating_id ORDER BY n DESC LIMIT 100`), | |
| 170 | + env.DB.prepare(`SELECT c.id,c.npi,c.note,d.name,d.phone FROM claims c JOIN doctors d ON d.npi=c.npi WHERE c.status='pending' ORDER BY c.created LIMIT 100`), | |
| 171 | + ]); | |
| 172 | + return html(L({ title: 'Review · Docley', path: p, body: adminPage({ held: held.results, flags: flags.results, claims: claims.results }) }), 200, 0); | |
| 173 | + } | |
| 174 | + return html(L({ title: 'Not found · Docley', site, path: p, body: notFoundPage() }), 404); | |
| 175 | + }, | |
| 176 | + }; | |
| 177 | + | |
| 178 | + const safeNext = (n) => (n && /^\/[a-zA-Z0-9/_\-?=&.]*$/.test(n) && !n.startsWith('//') ? n : '/'); | |
| 179 | + const redirect = (to, cookie) => new Response(null, { status: 303, headers: { location: to, ...(cookie ? { 'set-cookie': cookie } : {}) } }); | |
| 180 | + const FORM_ROUTE = /^\/(doctor\/\d{10}\/(rate|claim)|reply\/(rating|record)\/[\w-]+|flag\/[\w-]+)$/; | |
| 181 | + const notFound = () => new Response('Not found', { status: 404 }); | |
| 182 | + | |
| 183 | + // Lets the Docley iPhone and iPad app use this site's passkeys in its web view. | |
| 184 | + const AASA = { webcredentials: { apps: ['22HV69L32T.ai.projectatom.docley'] } }; | |
| 185 | + | |
| 186 | + async function handlePost(request, env, url, p, site) { | |
| 187 | + // Same-origin posts only. | |
| 188 | + const origin = request.headers.get('origin'); | |
| 189 | + if (origin && origin !== url.origin) return new Response('Forbidden', { status: 403 }); | |
| 190 | + if (p === '/api/admin-setup') return adminSetup(request, env, site); | |
| 191 | + const me = await readSession(env, request); | |
| 192 | + if (p.startsWith('/api/passkeys')) return (await passkeyApi(request, env, url, p, me)) || notFound(); | |
| 193 | + const f = await request.formData().catch(() => new FormData()); | |
| 194 | + if (p === '/admin/action') { | |
| 195 | + if (!me?.is_admin) return notFound(); | |
| 196 | + await adminAction(env, String(f.get('type')), String(f.get('id')), String(f.get('action'))); | |
| 197 | + return redirect('/admin'); | |
| 198 | + } | |
| 199 | + if (p === '/admin/setup') { | |
| 200 | + const link = me && (await findSetupLink(env.DB, String(f.get('token') || ''))); | |
| 201 | + if (!link || !(await useSetupLink(env.DB, link.token_hash, me.id))) return notFound(); | |
| 202 | + await env.DB.prepare('UPDATE people SET is_admin=1 WHERE id=?1').bind(me.id).run(); | |
| 203 | + return redirect('/admin'); | |
| 204 | + } | |
| 205 | + if (env.RATINGS_OPEN !== 'true') return new Response('Ratings are not open yet', { status: 403 }); | |
| 206 | + const L = (o) => layout({ site, me, ...o }); | |
| 207 | + const db = env.DB; | |
| 208 | + | |
| 209 | + if (!FORM_ROUTE.test(p)) return notFound(); | |
| 210 | + if (!me) return redirect(`/signin?next=${encodeURIComponent(p)}`); | |
| 211 | + | |
| 212 | + let m = /^\/doctor\/(\d{10})\/rate$/.exec(p); | |
| 213 | + if (m) { | |
| 214 | + const d = await db.prepare('SELECT * FROM doctors WHERE npi=?1').bind(m[1]).first(); | |
| 215 | + if (!d) return new Response('Not found', { status: 404 }); | |
| 216 | + const kind = f.get('kind') === 'colleague' ? 'colleague' : 'patient'; | |
| 217 | + if (me.clinician_npi === d.npi) return redirect('/doctor/' + d.npi); | |
| 218 | + if (kind === 'colleague' && !me.clinician_npi) return redirect('/doctor/' + d.npi); | |
| 219 | + const q = [1, 2, 3, 4, 5].map((i) => Number(f.get('q' + i))); | |
| 220 | + const comment = String(f.get('comment') || '').trim().slice(0, 600); | |
| 221 | + const back = (error) => html(L({ title: `Rate ${d.name} · Docley`, path: p, body: ratePage({ d, kind, existing: { q1: q[0], q2: q[1], q3: q[2], q4: q[3], q5: q[4], comment }, error }) }), 400, 0); | |
| 222 | + if (q.some((n) => !(n >= 1 && n <= 5))) return back('Please answer all five questions.'); | |
| 223 | + if (f.get('attest') !== '1') return back('Please confirm the statement at the bottom.'); | |
| 224 | + const today = await db.prepare(`SELECT COUNT(*) n FROM ratings WHERE person_id=?1 AND created > datetime('now','-1 day')`).bind(me.id).first('n'); | |
| 225 | + const existing = await db.prepare('SELECT id, alias FROM ratings WHERE person_id=?1 AND npi=?2 AND kind=?3').bind(me.id, d.npi, kind).first(); | |
| 226 | + if (!existing && today >= 5) return back('You can post up to 5 new ratings a day. Please come back tomorrow.'); | |
| 227 | + const mod = comment ? await moderate(env, comment) : { ok: true }; | |
| 228 | + const status = mod.ok ? 'live' : 'held'; | |
| 229 | + if (existing) { | |
| 230 | + await db.prepare(`UPDATE ratings SET q1=?1,q2=?2,q3=?3,q4=?4,q5=?5,comment=?6,status=?7,hold_reason=?8,updated=datetime('now') WHERE id=?9`) | |
| 231 | + .bind(...q, comment || null, status, mod.reason || null, existing.id).run(); | |
| 232 | + await db.prepare('DELETE FROM replies WHERE rating_id=?1').bind(existing.id).run(); | |
| 233 | + } else { | |
| 234 | + await db.prepare(`INSERT INTO ratings (id,person_id,npi,kind,q1,q2,q3,q4,q5,comment,status,hold_reason,alias) VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13)`) | |
| 235 | + .bind(newId(), me.id, d.npi, kind, ...q, comment || null, status, mod.reason || null, alias()).run(); | |
| 236 | + } | |
| 237 | + return html(L({ title: 'Thank you · Docley', path: p, body: thanksPage({ title: 'Thank you', text: status === 'live' ? 'Your rating is posted.' : 'Your stars count now. A person will check your comment against the rating rules before it shows.', back: '/doctor/' + d.npi }) }), 200, 0); | |
| 238 | + } | |
| 239 | + | |
| 240 | + m = /^\/doctor\/(\d{10})\/claim$/.exec(p); | |
| 241 | + if (m) { | |
| 242 | + const d = await db.prepare('SELECT * FROM doctors WHERE npi=?1').bind(m[1]).first(); | |
| 243 | + if (!d) return new Response('Not found', { status: 404 }); | |
| 244 | + const note = String(f.get('note') || '').trim().slice(0, 300); | |
| 245 | + if (!note) return html(L({ title: 'Claim your page · Docley', path: p, body: claimPage({ d, error: 'Please tell us who to ask for.' }) }), 400, 0); | |
| 246 | + await db.prepare('INSERT OR IGNORE INTO claims (id,npi,person_id,note) VALUES (?1,?2,?3,?4)').bind(newId(), d.npi, me.id, note).run(); | |
| 247 | + return html(L({ title: 'Claim requested · Docley', path: p, body: claimPage({ d, done: true }) }), 200, 0); | |
| 248 | + } | |
| 249 | + | |
| 250 | + m = /^\/reply\/(rating|record)\/([\w-]+)$/.exec(p); | |
| 251 | + if (m) { | |
| 252 | + const body = String(f.get('body') || '').trim().slice(0, 800); | |
| 253 | + const row = m[1] === 'rating' | |
| 254 | + ? await db.prepare('SELECT npi FROM ratings WHERE id=?1').bind(m[2]).first() | |
| 255 | + : await db.prepare('SELECT npi FROM records WHERE id=?1').bind(m[2]).first(); | |
| 256 | + if (!row || row.npi !== me.clinician_npi || !body) return new Response('Forbidden', { status: 403 }); | |
| 257 | + const mod = await moderate(env, body, { doctorReply: true }); | |
| 258 | + if (!mod.ok) return html(L({ title: 'Reply not posted · Docley', path: p, body: thanksPage({ title: 'Reply not posted', text: 'Replies must not include anything about a patient or their health. Please rewrite it and try again.', back: '/doctor/' + row.npi }) }), 400, 0); | |
| 259 | + const t = m[1] === 'rating' ? 'replies (rating_id, npi, body)' : 'record_replies (record_id, npi, body)'; | |
| 260 | + await db.prepare(`INSERT OR REPLACE INTO ${t} VALUES (?1, ?2, ?3)`).bind(m[2], row.npi, body).run(); | |
| 261 | + return redirect('/doctor/' + row.npi); | |
| 262 | + } | |
| 263 | + | |
| 264 | + m = /^\/flag\/([\w-]+)$/.exec(p); | |
| 265 | + if (m) { | |
| 266 | + const reason = ['rules', 'health', 'fake', 'accusation'].includes(f.get('reason')) ? f.get('reason') : 'rules'; | |
| 267 | + const r = await db.prepare('SELECT npi FROM ratings WHERE id=?1').bind(m[1]).first(); | |
| 268 | + if (!r) return new Response('Not found', { status: 404 }); | |
| 269 | + await db.prepare('INSERT INTO flags (rating_id, reason) VALUES (?1, ?2)').bind(m[1], reason + ':' + me.id).run(); | |
| 270 | + return html(L({ title: 'Thanks · Docley', path: p, body: thanksPage({ title: 'Thanks for flagging', text: 'A person will check it against the rating rules.', back: '/doctor/' + r.npi }) }), 200, 0); | |
| 271 | + } | |
| 272 | + return new Response('Not found', { status: 404 }); | |
| 273 | + } | |
| 274 | + | |
| 275 | + export async function adminAction(env, type, id, action) { | |
| 276 | + const db = env.DB; | |
| 277 | + if (type === 'rating') { | |
| 278 | + const st = { approve: 'live', remove: 'removed' }[action]; | |
| 279 | + if (st) await db.prepare(`UPDATE ratings SET status=?1, hold_reason=NULL WHERE id=?2`).bind(st, id).run(); | |
| 280 | + if (action === 'hide') await db.prepare(`UPDATE ratings SET status='held', hold_reason='hidden after flags' WHERE id=?1`).bind(id).run(); | |
| 281 | + await db.prepare('DELETE FROM flags WHERE rating_id=?1').bind(id).run(); | |
| 282 | + } else if (type === 'flag' && action === 'keep') { | |
| 283 | + await db.prepare('DELETE FROM flags WHERE rating_id=?1').bind(id).run(); | |
| 284 | + } else if (type === 'claim') { | |
| 285 | + const c = await db.prepare('SELECT npi, person_id FROM claims WHERE id=?1').bind(id).first(); | |
| 286 | + if (!c) return; | |
| 287 | + await db.prepare('UPDATE claims SET status=?1 WHERE id=?2').bind(action === 'approve' ? 'approved' : 'denied', id).run(); | |
| 288 | + if (action === 'approve') await db.prepare('UPDATE people SET clinician_npi=?1 WHERE id=?2').bind(c.npi, c.person_id).run(); | |
| 289 | + } | |
| 290 | + } |
src/moderate.js added
| 1 | + // First pass on comments and doctor replies. Anything doubtful is held for a person. | |
| 2 | + const HEALTH = /\b(diagnos\w*|prescri\w*|biops\w*|cancer|tumou?r|hiv|std|pregnan\w*|abortion|miscarr\w*|depress\w*|bipolar|schizo\w*|surgery on my|my (?:test|lab|mri|scan|results?)|mg\b|dosage)\b/i; | |
| 3 | + const ACCUSE = /\b(malpractice|sued|lawsuit|negligen\w*|fraud\w*|crimin\w*|felon\w*|illegal\w*|arrest\w*|killed|murder\w*|rap(?:e|ed|ist)|molest\w*|drunk|high on|addict\w*|license (?:revoked|suspended))\b/i; | |
| 4 | + const ABUSE = /\b(idiot|stupid|moron|retard\w*|bitch|bastard|fuck\w*|shit\w*|asshole|cunt|whore|scum)\b/i; | |
| 5 | + const CONTACT = /(https?:\/\/|www\.|@\w+\.\w|\b\d{3}[\s.-]?\d{3}[\s.-]?\d{4}\b)/i; | |
| 6 | + | |
| 7 | + export async function moderate(env, text, { doctorReply = false } = {}) { | |
| 8 | + if (HEALTH.test(text)) return { ok: false, reason: 'possible health details' }; | |
| 9 | + if (!doctorReply && ACCUSE.test(text)) return { ok: false, reason: 'possible accusation' }; | |
| 10 | + if (ABUSE.test(text)) return { ok: false, reason: 'insult or profanity' }; | |
| 11 | + if (CONTACT.test(text)) return { ok: false, reason: 'link or contact details' }; | |
| 12 | + if (!env.AI) return { ok: true }; | |
| 13 | + try { | |
| 14 | + const out = await env.AI.run('@cf/meta/llama-3.1-8b-instruct-fast', { | |
| 15 | + messages: [ | |
| 16 | + { role: 'system', content: 'You check public comments about doctors against these rules: no health details about any patient, no accusations of crimes or malpractice, no insults, threats or slurs, no personal information. Answer with one word: OK or HOLD.' }, | |
| 17 | + { role: 'user', content: text }, | |
| 18 | + ], | |
| 19 | + max_tokens: 3, | |
| 20 | + }); | |
| 21 | + const verdict = String(out?.response || '').trim().toUpperCase(); | |
| 22 | + return verdict.startsWith('HOLD') ? { ok: false, reason: 'flagged by first check' } : { ok: true }; | |
| 23 | + } catch { | |
| 24 | + return { ok: true }; | |
| 25 | + } | |
| 26 | + } |
src/no-orphans.js added
| 1 | + // No orphans: no single word alone on a last line. Source: projectatomai/hosting-research assets/no-orphans. | |
| 2 | + export const NO_ORPHANS_CSS = "/* No orphans: balanced headings, no lone last words in body text. Pairs with no-orphans.js. */\nh1,h2,h3,h4,h5,h6,summary,legend,caption,blockquote{text-wrap:balance}\np,li,dd,dt,figcaption,td,th,label,small{text-wrap:pretty}\n"; | |
| 3 | + export const NO_ORPHANS_JS = "/* No orphans: never leave one word alone on the last line of a paragraph, card or heading.\n Joins the last two words of each block of text with a non-breaking space, on load and for text added later.\n Pairs with no-orphans.css (text-wrap: pretty / balance). Public domain (CC0). */\n(function () {\n if (window.__noOrphans) return;\n window.__noOrphans = 1;\n var SKIP = /^(SCRIPT|STYLE|PRE|CODE|TEXTAREA|INPUT|SELECT|OPTION|SVG|MATH|KBD|SAMP|NOSCRIPT|TEMPLATE|IFRAME|CANVAS|TITLE)$/;\n var NB = '\u00a0';\n var WS = /[ \\t\\n\\r]/;\n\n function skipped(el) {\n for (var n = el; n && n.nodeType === 1; n = n.parentNode) {\n if (SKIP.test(n.nodeName.toUpperCase()) || n.isContentEditable || n.hasAttribute('data-orphans-ok')) return true;\n }\n return false;\n }\n\n // The box a run of text wraps inside: the nearest ancestor that is not an inline element.\n function blockOf(node, cache) {\n for (var el = node.parentNode; el && el.nodeType === 1; el = el.parentNode) {\n var d = cache.get(el);\n if (d === undefined) { d = getComputedStyle(el).display; cache.set(el, d); }\n if (d !== 'inline' && d !== 'contents') return el;\n }\n return null;\n }\n\n function fix(block, nodes) {\n var text = '';\n for (var i = 0; i < nodes.length; i++) text += nodes[i].nodeValue;\n var words = text.trim().split(/\\s+/);\n if (words.length < 3) return;\n var last = words[words.length - 1], prev = words[words.length - 2];\n if (last.indexOf(NB) >= 0 || last.length + prev.length > 30) return;\n var seenWord = false;\n for (i = nodes.length - 1; i >= 0; i--) {\n var s = nodes[i].nodeValue;\n for (var j = s.length - 1; j >= 0; j--) {\n var c = s.charAt(j);\n if (c === NB) { if (seenWord) return; continue; }\n if (WS.test(c)) {\n if (!seenWord) continue;\n var k = j;\n while (k > 0 && WS.test(s.charAt(k - 1))) k--;\n var node = nodes[i], before = s;\n node.nodeValue = s.slice(0, k) + NB + s.slice(j + 1);\n // A long pair could push past a narrow box; put the space back if it does.\n if (last.length + prev.length > 14) {\n var de = document.documentElement;\n if (block.scrollWidth > block.clientWidth + 1 || de.scrollWidth > de.clientWidth + 1) node.nodeValue = before;\n }\n return;\n }\n seenWord = true;\n }\n }\n }\n\n function run(root) {\n if (!root || root.nodeType !== 1 || skipped(root)) return;\n var cache = new Map(), blocks = [], groups = new Map();\n var w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {\n acceptNode: function (t) { return t.nodeValue.trim() && !skipped(t.parentNode) ? 1 : 3; }\n });\n for (var t = w.nextNode(); t; t = w.nextNode()) {\n var b = blockOf(t, cache);\n if (!b) continue;\n var g = groups.get(b);\n if (!g) { g = []; groups.set(b, g); blocks.push(b); }\n g.push(t);\n }\n for (var i = 0; i < blocks.length; i++) {\n var blk = blocks[i];\n // When only part of a block was handed in, read the whole block.\n if (!root.contains(blk) || blk === root.parentNode) continue;\n fix(blk, groups.get(blk));\n }\n }\n\n var queued = [], timer = 0;\n function flush() {\n timer = 0;\n var q = queued; queued = [];\n var cache = new Map(), seen = new Set();\n for (var i = 0; i < q.length; i++) {\n var n = q[i];\n if (!n || !n.isConnected) continue;\n // Re-run from the text's own block so a new word at the end of a paragraph is handled.\n var b = n.nodeType === 3 ? blockOf(n, cache) : (n.nodeType === 1 ? (getComputedStyle(n).display === 'inline' ? blockOf(n, cache) : n) : null);\n if (b && !seen.has(b)) { seen.add(b); run(b); }\n }\n }\n function start() {\n run(document.body);\n if (!window.MutationObserver) return;\n new MutationObserver(function (muts) {\n for (var i = 0; i < muts.length; i++) {\n var m = muts[i];\n if (m.type === 'characterData') queued.push(m.target);\n for (var j = 0; j < m.addedNodes.length; j++) queued.push(m.addedNodes[j]);\n }\n if (queued.length && !timer) timer = setTimeout(flush, 60);\n }).observe(document.body, { childList: true, subtree: true, characterData: true });\n }\n // Wait for the page (and any app framework) to finish its first render.\n if (document.readyState === 'complete') setTimeout(start, 0);\n else window.addEventListener('load', function () { setTimeout(start, 0); });\n})();\n"; |
src/passkey-client.js added
| 1 | + // Browser script served at /assets/passkey.js. Buttons opt in with data-passkey="signin|register|add|admin|remove". | |
| 2 | + // Kept as a raw string (not Function#toString) because the bundler adds helpers like __name to functions. | |
| 3 | + // No backticks or template placeholders inside. | |
| 4 | + export const PASSKEY_JS = String.raw`(function () { | |
| 5 | + 'use strict'; | |
| 6 | + const status = document.querySelector('[data-passkey-status]'); | |
| 7 | + const show = (text) => { | |
| 8 | + if (!status) return; | |
| 9 | + status.textContent = text; | |
| 10 | + status.hidden = !text; | |
| 11 | + }; | |
| 12 | + | |
| 13 | + const toBytes = (s) => { | |
| 14 | + const b64 = s.replace(/-/g, '+').replace(/_/g, '/') + '==='.slice((s.length + 3) % 4); | |
| 15 | + return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)); | |
| 16 | + }; | |
| 17 | + const toB64u = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); | |
| 18 | + | |
| 19 | + async function post(path, body) { | |
| 20 | + const r = await fetch(path, { method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body || {}) }); | |
| 21 | + const data = await r.json().catch(() => ({})); | |
| 22 | + if (!r.ok) throw new Error(data.message || 'Something went wrong. Please try again.'); | |
| 23 | + return data; | |
| 24 | + } | |
| 25 | + | |
| 26 | + const withIds = (list) => (list || []).map((c) => ({ ...c, id: toBytes(c.id) })); | |
| 27 | + const creationOptions = (o) => ({ ...o, challenge: toBytes(o.challenge), user: { ...o.user, id: toBytes(o.user.id) }, excludeCredentials: withIds(o.excludeCredentials) }); | |
| 28 | + const requestOptions = (o) => ({ ...o, challenge: toBytes(o.challenge), allowCredentials: withIds(o.allowCredentials) }); | |
| 29 | + | |
| 30 | + const registrationJSON = (c) => ({ | |
| 31 | + id: c.id, | |
| 32 | + rawId: toB64u(c.rawId), | |
| 33 | + type: c.type, | |
| 34 | + authenticatorAttachment: c.authenticatorAttachment || undefined, | |
| 35 | + clientExtensionResults: c.getClientExtensionResults(), | |
| 36 | + response: { | |
| 37 | + clientDataJSON: toB64u(c.response.clientDataJSON), | |
| 38 | + attestationObject: toB64u(c.response.attestationObject), | |
| 39 | + transports: c.response.getTransports ? c.response.getTransports() : [], | |
| 40 | + }, | |
| 41 | + }); | |
| 42 | + const authenticationJSON = (c) => ({ | |
| 43 | + id: c.id, | |
| 44 | + rawId: toB64u(c.rawId), | |
| 45 | + type: c.type, | |
| 46 | + authenticatorAttachment: c.authenticatorAttachment || undefined, | |
| 47 | + clientExtensionResults: c.getClientExtensionResults(), | |
| 48 | + response: { | |
| 49 | + clientDataJSON: toB64u(c.response.clientDataJSON), | |
| 50 | + authenticatorData: toB64u(c.response.authenticatorData), | |
| 51 | + signature: toB64u(c.response.signature), | |
| 52 | + userHandle: c.response.userHandle ? toB64u(c.response.userHandle) : undefined, | |
| 53 | + }, | |
| 54 | + }); | |
| 55 | + | |
| 56 | + async function createPasskey(kind, el) { | |
| 57 | + const base = kind === 'add' ? '/api/passkeys/add' : '/api/passkeys/register'; | |
| 58 | + const options = await post(base + '/options', kind === 'admin' ? { setupToken: el.dataset.token } : {}); | |
| 59 | + const credential = await navigator.credentials.create({ publicKey: creationOptions(options) }); | |
| 60 | + const nameInput = document.querySelector('[data-passkey-name]'); | |
| 61 | + await post(base + '/verify', { response: registrationJSON(credential), name: nameInput ? nameInput.value : '' }); | |
| 62 | + } | |
| 63 | + | |
| 64 | + async function signIn() { | |
| 65 | + const options = await post('/api/passkeys/signin/options'); | |
| 66 | + const credential = await navigator.credentials.get({ publicKey: requestOptions(options) }); | |
| 67 | + await post('/api/passkeys/signin/verify', { response: authenticationJSON(credential) }); | |
| 68 | + } | |
| 69 | + | |
| 70 | + const safeNext = (n) => (n && n[0] === '/' && n[1] !== '/' && n[1] !== '\\' ? n : '/'); | |
| 71 | + const errorText = (e) => | |
| 72 | + e.name === 'NotAllowedError' ? 'The passkey request was cancelled or timed out. Please try again.' | |
| 73 | + : e.name === 'InvalidStateError' ? 'This device already has a passkey for this account.' | |
| 74 | + : e.message; | |
| 75 | + | |
| 76 | + async function run(el) { | |
| 77 | + const kind = el.dataset.passkey; | |
| 78 | + if (kind === 'remove' && !confirm('Remove this passkey? You will not be able to sign in with it again.')) return; | |
| 79 | + el.disabled = true; | |
| 80 | + show(''); | |
| 81 | + try { | |
| 82 | + if (kind === 'signin') await signIn(); | |
| 83 | + else if (kind === 'remove') await post('/api/passkeys/delete', { id: el.dataset.id }); | |
| 84 | + else await createPasskey(kind, el); | |
| 85 | + location.assign(kind === 'add' || kind === 'remove' ? '/account' : safeNext(el.dataset.next)); | |
| 86 | + } catch (e) { | |
| 87 | + show(errorText(e)); | |
| 88 | + el.disabled = false; | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + if (!window.PublicKeyCredential) show('This browser does not support passkeys. Please update it, or use a phone or computer that does.'); | |
| 93 | + document.addEventListener('click', (e) => { | |
| 94 | + const el = e.target.closest('[data-passkey]'); | |
| 95 | + if (!el) return; | |
| 96 | + e.preventDefault(); | |
| 97 | + run(el); | |
| 98 | + }); | |
| 99 | + })(); | |
| 100 | + `; |
src/passkeys.js added
| 1 | + // Passkeys are the only way in: no passwords, email links, texted codes or third-party sign-in. | |
| 2 | + // Losing a device is covered by a second passkey on another device. | |
| 3 | + import { generateRegistrationOptions, verifyRegistrationResponse, generateAuthenticationOptions, verifyAuthenticationResponse } from '@simplewebauthn/server'; | |
| 4 | + import { isoBase64URL } from '@simplewebauthn/server/helpers'; | |
| 5 | + import { makeSession, newId, newToken, sha256, safeEqual, ipHash } from './auth.js'; | |
| 6 | + | |
| 7 | + const CHALLENGE_COOKIE = 'dlc'; | |
| 8 | + const CHALLENGE_SECONDS = 300; | |
| 9 | + const SETUP_LINK_SECONDS = 15 * 60; | |
| 10 | + const NEW_ACCOUNTS_PER_IP_PER_DAY = 3; | |
| 11 | + const MIN_SETUP_SECRET = 32; | |
| 12 | + const enc = new TextEncoder(); | |
| 13 | + const dec = new TextDecoder(); | |
| 14 | + const now = () => Math.floor(Date.now() / 1000); | |
| 15 | + | |
| 16 | + export function relyingParty(env, url) { | |
| 17 | + const site = new URL(env.SITE_URL || url.origin); | |
| 18 | + return { rpID: site.hostname, origin: site.origin }; | |
| 19 | + } | |
| 20 | + | |
| 21 | + function reply(data, status = 200, cookies = []) { | |
| 22 | + const headers = new Headers({ 'content-type': 'application/json; charset=utf-8', 'cache-control': 'private, no-store', 'x-content-type-options': 'nosniff' }); | |
| 23 | + for (const c of cookies) headers.append('set-cookie', c); | |
| 24 | + return new Response(JSON.stringify(data), { status, headers }); | |
| 25 | + } | |
| 26 | + const fail = (error, message, status = 400, cookies = []) => reply({ error, message }, status, cookies); | |
| 27 | + const notFound = () => new Response('Not found', { status: 404 }); | |
| 28 | + | |
| 29 | + const readCookie = (request, name) => { | |
| 30 | + const raw = (request.headers.get('cookie') || '').split(/;\s*/).find((c) => c.startsWith(name + '=')); | |
| 31 | + return raw ? raw.slice(name.length + 1) : ''; | |
| 32 | + }; | |
| 33 | + const clearChallenge = `${CHALLENGE_COOKIE}=; Path=/api/passkeys; HttpOnly; Secure; SameSite=Strict; Max-Age=0`; | |
| 34 | + | |
| 35 | + // Challenges live in D1, keyed by a random id in a short-lived HttpOnly cookie. | |
| 36 | + async function saveChallenge(db, { challenge, purpose, personId = null, setupHash = null }) { | |
| 37 | + const id = newToken(); | |
| 38 | + await db.batch([ | |
| 39 | + db.prepare('DELETE FROM webauthn_challenges WHERE expires < ?1').bind(now()), | |
| 40 | + db.prepare('INSERT INTO webauthn_challenges (id, challenge, purpose, person_id, setup_hash, expires) VALUES (?1, ?2, ?3, ?4, ?5, ?6)') | |
| 41 | + .bind(id, challenge, purpose, personId, setupHash, now() + CHALLENGE_SECONDS), | |
| 42 | + ]); | |
| 43 | + return `${CHALLENGE_COOKIE}=${id}; Path=/api/passkeys; HttpOnly; Secure; SameSite=Strict; Max-Age=${CHALLENGE_SECONDS}`; | |
| 44 | + } | |
| 45 | + | |
| 46 | + // Single use: the row is deleted as it is read, whether or not verification then succeeds. | |
| 47 | + export async function takeChallenge(db, request, purposes) { | |
| 48 | + const id = readCookie(request, CHALLENGE_COOKIE); | |
| 49 | + if (!id) return null; | |
| 50 | + const row = await db.prepare('DELETE FROM webauthn_challenges WHERE id=?1 RETURNING *').bind(id).first(); | |
| 51 | + if (!row || row.expires < now() || !purposes.includes(row.purpose)) return null; | |
| 52 | + return row; | |
| 53 | + } | |
| 54 | + | |
| 55 | + export async function findSetupLink(db, token) { | |
| 56 | + if (!token || typeof token !== 'string') return null; | |
| 57 | + return db.prepare('SELECT * FROM admin_setup_links WHERE token_hash=?1 AND used IS NULL AND expires > ?2').bind(await sha256(token), now()).first(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + export async function useSetupLink(db, tokenHash, personId) { | |
| 61 | + const r = await db.prepare(`UPDATE admin_setup_links SET used=datetime('now'), person_id=?2 WHERE token_hash=?1 AND used IS NULL AND expires > ?3`) | |
| 62 | + .bind(tokenHash, personId, now()).run(); | |
| 63 | + return r.meta.changes === 1; | |
| 64 | + } | |
| 65 | + | |
| 66 | + async function accountsFromIp(env, request) { | |
| 67 | + const hash = await ipHash(env, request.headers.get('cf-connecting-ip')); | |
| 68 | + const n = await env.DB.prepare(`SELECT COUNT(*) n FROM account_ips WHERE ip_hash=?1 AND at > datetime('now','-1 day')`).bind(hash).first('n'); | |
| 69 | + return { hash, blocked: n >= NEW_ACCOUNTS_PER_IP_PER_DAY }; | |
| 70 | + } | |
| 71 | + | |
| 72 | + const registrationOptions = (rp, personId, exclude = []) => | |
| 73 | + generateRegistrationOptions({ | |
| 74 | + rpName: 'Docley', | |
| 75 | + rpID: rp.rpID, | |
| 76 | + userName: 'Docley account', | |
| 77 | + userDisplayName: 'Docley account', | |
| 78 | + userID: enc.encode(personId), | |
| 79 | + attestationType: 'none', | |
| 80 | + excludeCredentials: exclude.map((c) => ({ id: c.credential_id, transports: JSON.parse(c.transports || '[]') })), | |
| 81 | + authenticatorSelection: { residentKey: 'required', requireResidentKey: true, userVerification: 'required' }, | |
| 82 | + }); | |
| 83 | + | |
| 84 | + async function registerOptions(request, env, rp, me, body) { | |
| 85 | + if (me) return fail('signed_in', 'You are already signed in. Add another passkey from your Passkeys page.', 409); | |
| 86 | + let purpose = 'register', setupHash = null; | |
| 87 | + if (body.setupToken) { | |
| 88 | + const link = await findSetupLink(env.DB, body.setupToken); | |
| 89 | + if (!link) return fail('link_expired', 'This admin link has expired or was already used.', 404); | |
| 90 | + purpose = 'admin'; | |
| 91 | + setupHash = link.token_hash; | |
| 92 | + } else if ((await accountsFromIp(env, request)).blocked) { | |
| 93 | + return fail('too_many_accounts', 'Too many new accounts from this network today. Please try again tomorrow.', 429); | |
| 94 | + } | |
| 95 | + const personId = newId(); | |
| 96 | + const options = await registrationOptions(rp, personId); | |
| 97 | + const cookie = await saveChallenge(env.DB, { challenge: options.challenge, purpose, personId, setupHash }); | |
| 98 | + return reply(options, 200, [cookie]); | |
| 99 | + } | |
| 100 | + | |
| 101 | + async function addOptions(env, rp, me) { | |
| 102 | + if (!me) return fail('signed_out', 'Please sign in first.', 401); | |
| 103 | + const existing = (await env.DB.prepare('SELECT credential_id, transports FROM passkeys WHERE person_id=?1').bind(me.id).all()).results; | |
| 104 | + const options = await registrationOptions(rp, me.id, existing); | |
| 105 | + const cookie = await saveChallenge(env.DB, { challenge: options.challenge, purpose: 'add', personId: me.id }); | |
| 106 | + return reply(options, 200, [cookie]); | |
| 107 | + } | |
| 108 | + | |
| 109 | + const passkeyName = (name, info) => String(name || '').trim().slice(0, 60) || (info.credentialBackedUp ? 'Synced passkey' : 'Passkey on this device'); | |
| 110 | + | |
| 111 | + function insertPasskey(db, personId, info, body) { | |
| 112 | + const c = info.credential; | |
| 113 | + const transports = c.transports || body.response?.response?.transports || []; | |
| 114 | + return db.prepare('INSERT INTO passkeys (credential_id, person_id, public_key, counter, transports, device_type, backed_up, name) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)') | |
| 115 | + .bind(c.id, personId, isoBase64URL.fromBuffer(c.publicKey), c.counter, JSON.stringify(transports), info.credentialDeviceType, info.credentialBackedUp ? 1 : 0, passkeyName(body.name, info)); | |
| 116 | + } | |
| 117 | + | |
| 118 | + async function checkRegistration(rp, row, body) { | |
| 119 | + try { | |
| 120 | + const v = await verifyRegistrationResponse({ response: body.response, expectedChallenge: row.challenge, expectedOrigin: rp.origin, expectedRPID: rp.rpID, requireUserVerification: true }); | |
| 121 | + return v.verified ? v.registrationInfo : null; | |
| 122 | + } catch { | |
| 123 | + return null; | |
| 124 | + } | |
| 125 | + } | |
| 126 | + | |
| 127 | + async function registerVerify(request, env, rp, me, body, purposes) { | |
| 128 | + const row = await takeChallenge(env.DB, request, purposes); | |
| 129 | + if (!row) return fail('challenge_expired', 'That took too long. Please try again.', 400, [clearChallenge]); | |
| 130 | + if (row.purpose === 'add' && me?.id !== row.person_id) return fail('signed_out', 'Please sign in first.', 401, [clearChallenge]); | |
| 131 | + const info = await checkRegistration(rp, row, body); | |
| 132 | + if (!info) return fail('not_verified', 'We could not verify that passkey. Please try again.', 400, [clearChallenge]); | |
| 133 | + const db = env.DB; | |
| 134 | + const steps = []; | |
| 135 | + if (row.purpose === 'admin') { | |
| 136 | + if (!(await useSetupLink(db, row.setup_hash, row.person_id))) return fail('link_expired', 'This admin link has expired or was already used.', 410, [clearChallenge]); | |
| 137 | + steps.push(db.prepare('INSERT INTO people (id, is_admin) VALUES (?1, 1)').bind(row.person_id)); | |
| 138 | + } else if (row.purpose === 'register') { | |
| 139 | + const ip = await accountsFromIp(env, request); | |
| 140 | + if (ip.blocked) return fail('too_many_accounts', 'Too many new accounts from this network today. Please try again tomorrow.', 429, [clearChallenge]); | |
| 141 | + steps.push(db.prepare('INSERT INTO account_ips (ip_hash) VALUES (?1)').bind(ip.hash)); | |
| 142 | + steps.push(db.prepare('INSERT INTO people (id) VALUES (?1)').bind(row.person_id)); | |
| 143 | + } | |
| 144 | + steps.push(insertPasskey(db, row.person_id, info, body)); | |
| 145 | + try { | |
| 146 | + await db.batch(steps); | |
| 147 | + } catch { | |
| 148 | + return fail('already_registered', 'That passkey is already registered.', 409, [clearChallenge]); | |
| 149 | + } | |
| 150 | + const cookies = [clearChallenge]; | |
| 151 | + if (row.purpose !== 'add') cookies.push(await makeSession(env, row.person_id)); | |
| 152 | + return reply({ ok: true }, 200, cookies); | |
| 153 | + } | |
| 154 | + | |
| 155 | + async function signinOptions(env, rp) { | |
| 156 | + const options = await generateAuthenticationOptions({ rpID: rp.rpID, userVerification: 'required' }); | |
| 157 | + const cookie = await saveChallenge(env.DB, { challenge: options.challenge, purpose: 'signin' }); | |
| 158 | + return reply(options, 200, [cookie]); | |
| 159 | + } | |
| 160 | + | |
| 161 | + const userHandleMatches = (body, personId) => { | |
| 162 | + const handle = body.response?.response?.userHandle; | |
| 163 | + return !handle || dec.decode(isoBase64URL.toBuffer(handle)) === personId; | |
| 164 | + }; | |
| 165 | + | |
| 166 | + async function signinVerify(request, env, rp, body) { | |
| 167 | + const row = await takeChallenge(env.DB, request, ['signin']); | |
| 168 | + if (!row) return fail('challenge_expired', 'That took too long. Please try again.', 400, [clearChallenge]); | |
| 169 | + const pk = await env.DB.prepare('SELECT * FROM passkeys WHERE credential_id=?1').bind(String(body.response?.id || '')).first(); | |
| 170 | + if (!pk || !userHandleMatches(body, pk.person_id)) return fail('unknown_passkey', 'We do not know that passkey. Create an account, or use a passkey you added before.', 400, [clearChallenge]); | |
| 171 | + let v; | |
| 172 | + try { | |
| 173 | + v = await verifyAuthenticationResponse({ | |
| 174 | + response: body.response, | |
| 175 | + expectedChallenge: row.challenge, | |
| 176 | + expectedOrigin: rp.origin, | |
| 177 | + expectedRPID: rp.rpID, | |
| 178 | + requireUserVerification: true, | |
| 179 | + credential: { id: pk.credential_id, publicKey: isoBase64URL.toBuffer(pk.public_key), counter: pk.counter, transports: JSON.parse(pk.transports || '[]') }, | |
| 180 | + }); | |
| 181 | + } catch { | |
| 182 | + v = { verified: false }; | |
| 183 | + } | |
| 184 | + if (!v.verified) return fail('not_verified', 'We could not verify that passkey. Please try again.', 400, [clearChallenge]); | |
| 185 | + await env.DB.prepare(`UPDATE passkeys SET counter=?1, backed_up=?2, last_used=datetime('now') WHERE credential_id=?3`) | |
| 186 | + .bind(v.authenticationInfo.newCounter, v.authenticationInfo.credentialBackedUp ? 1 : 0, pk.credential_id).run(); | |
| 187 | + return reply({ ok: true }, 200, [clearChallenge, await makeSession(env, pk.person_id)]); | |
| 188 | + } | |
| 189 | + | |
| 190 | + export const listPasskeys = async (db, personId) => | |
| 191 | + (await db.prepare('SELECT credential_id, name, device_type, backed_up, created, last_used FROM passkeys WHERE person_id=?1 ORDER BY created, rowid').bind(personId).all()).results; | |
| 192 | + | |
| 193 | + async function removePasskey(env, me, body) { | |
| 194 | + if (!me) return fail('signed_out', 'Please sign in first.', 401); | |
| 195 | + const r = await env.DB.prepare('DELETE FROM passkeys WHERE credential_id=?1 AND person_id=?2 AND (SELECT COUNT(*) FROM passkeys WHERE person_id=?2) > 1') | |
| 196 | + .bind(String(body.id || ''), me.id).run(); | |
| 197 | + if (r.meta.changes !== 1) return fail('last_passkey', 'You cannot remove your only passkey. Add another one first.', 400); | |
| 198 | + return reply({ ok: true }); | |
| 199 | + } | |
| 200 | + | |
| 201 | + // POST /api/admin-setup with header x-setup-secret. Anything wrong looks like a missing page. | |
| 202 | + export async function adminSetup(request, env, site) { | |
| 203 | + const secret = env.DOCLEY_ADMIN_SETUP_SECRET || ''; | |
| 204 | + const given = request.headers.get('x-setup-secret') || ''; | |
| 205 | + if (secret.length < MIN_SETUP_SECRET || !given || !(await safeEqual(given, secret))) return notFound(); | |
| 206 | + const body = await request.json().catch(() => ({})); | |
| 207 | + const token = newToken(); | |
| 208 | + const expires = now() + SETUP_LINK_SECONDS; | |
| 209 | + await env.DB.prepare('INSERT INTO admin_setup_links (token_hash, label, expires) VALUES (?1, ?2, ?3)') | |
| 210 | + .bind(await sha256(token), String(body?.label || '').slice(0, 80) || null, expires).run(); | |
| 211 | + return reply({ url: `${site}/admin/setup?token=${token}`, expires: new Date(expires * 1000).toISOString() }); | |
| 212 | + } | |
| 213 | + | |
| 214 | + // JSON API for passkeys. Returns null when the path is not a passkey route. | |
| 215 | + export async function passkeyApi(request, env, url, p, me) { | |
| 216 | + const rp = relyingParty(env, url); | |
| 217 | + if (request.method === 'GET') { | |
| 218 | + if (p !== '/api/passkeys') return null; | |
| 219 | + if (!me) return fail('signed_out', 'Please sign in first.', 401); | |
| 220 | + return reply({ passkeys: await listPasskeys(env.DB, me.id) }); | |
| 221 | + } | |
| 222 | + if (!/^application\/json\b/.test(request.headers.get('content-type') || '')) return fail('json_only', 'Send JSON.', 415); | |
| 223 | + const body = (await request.json().catch(() => null)) || {}; | |
| 224 | + switch (p) { | |
| 225 | + case '/api/passkeys/register/options': return registerOptions(request, env, rp, me, body); | |
| 226 | + case '/api/passkeys/register/verify': return registerVerify(request, env, rp, me, body, ['register', 'admin']); | |
| 227 | + case '/api/passkeys/add/options': return addOptions(env, rp, me); | |
| 228 | + case '/api/passkeys/add/verify': return registerVerify(request, env, rp, me, body, ['add']); | |
| 229 | + case '/api/passkeys/signin/options': return signinOptions(env, rp); | |
| 230 | + case '/api/passkeys/signin/verify': return signinVerify(request, env, rp, body); | |
| 231 | + case '/api/passkeys/delete': return removePasskey(env, me, body); | |
| 232 | + default: return null; | |
| 233 | + } | |
| 234 | + } |
src/views.js added
| 1 | + import { replyForm, flagForm } from './forms.js'; | |
| 2 | + export const STATES = {AL:'Alabama',AK:'Alaska',AZ:'Arizona',AR:'Arkansas',CA:'California',CO:'Colorado',CT:'Connecticut',DE:'Delaware',DC:'District of Columbia',FL:'Florida',GA:'Georgia',HI:'Hawaii',ID:'Idaho',IL:'Illinois',IN:'Indiana',IA:'Iowa',KS:'Kansas',KY:'Kentucky',LA:'Louisiana',ME:'Maine',MD:'Maryland',MA:'Massachusetts',MI:'Michigan',MN:'Minnesota',MS:'Mississippi',MO:'Missouri',MT:'Montana',NE:'Nebraska',NV:'Nevada',NH:'New Hampshire',NJ:'New Jersey',NM:'New Mexico',NY:'New York',NC:'North Carolina',ND:'North Dakota',OH:'Ohio',OK:'Oklahoma',OR:'Oregon',PA:'Pennsylvania',RI:'Rhode Island',SC:'South Carolina',SD:'South Dakota',TN:'Tennessee',TX:'Texas',UT:'Utah',VT:'Vermont',VA:'Virginia',WA:'Washington',WV:'West Virginia',WI:'Wisconsin',WY:'Wyoming',PR:'Puerto Rico',GU:'Guam',VI:'U.S. Virgin Islands'}; | |
| 3 | + | |
| 4 | + export const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]); | |
| 5 | + const slug = (s) => String(s || '').toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, ''); | |
| 6 | + export const docUrl = (d) => `/doctor/${d.npi}-${slug(d.name + (d.credential ? ' ' + d.credential : ''))}`; | |
| 7 | + const fmtDate = (iso) => { | |
| 8 | + if (!iso) return ''; | |
| 9 | + const [y, m, d] = iso.split('-').map(Number); | |
| 10 | + return new Date(Date.UTC(y, m - 1, d)).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }); | |
| 11 | + }; | |
| 12 | + | |
| 13 | + export function layout({ title, site, path, body, description, me, passkeys }) { | |
| 14 | + const desc = description || 'Every licensed doctor in America in one free, publicly owned registry, with official public records and honest ratings from verified people.'; | |
| 15 | + return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"> | |
| 16 | + <title>${esc(title)}</title><meta name="description" content="${esc(desc)}"> | |
| 17 | + <link rel="canonical" href="${esc(site + path)}"><link rel="icon" href="/favicon.svg" type="image/svg+xml"><link rel="stylesheet" href="/assets/site.css">${passkeys ? '<script src="/assets/passkey.js" defer></script>' : ''} | |
| 18 | + <meta property="og:title" content="${esc(title)}"><meta property="og:description" content="${esc(desc)}"><meta property="og:url" content="${esc(site + path)}"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"> | |
| 19 | + <meta name="theme-color" content="#000000"><script src="/assets/no-orphans.js" defer></script></head><body> | |
| 20 | + <header class="top"><div class="wrap"><a class="brand" href="/"><img src="/atom.svg" alt="" width="28" height="28">Docley</a> | |
| 21 | + <nav class="links"><a href="/search">Search</a><a href="/rules">Rules</a>${me ? `<a href="/account">Passkeys</a><a href="/signout">Sign out</a>` : `<a href="/signin">Sign in</a>`}</nav></div></header> | |
| 22 | + <main class="wrap">${body}</main> | |
| 23 | + <footer class="bot"><div class="wrap"><span><a href="https://projectatom.ai">A Project ATOM project</a>. Free and open source, public domain.</span> | |
| 24 | + <span><a href="https://projectatom.ai/apps?app=docley#feedback">Feedback</a> · <a href="https://projectatom.ai/privacy">Privacy</a> · <a href="/rules">Rating rules</a> · Hosted on Cloudflare</span></div></footer> | |
| 25 | + </body></html>`; | |
| 26 | + } | |
| 27 | + | |
| 28 | + const stateOptions = (sel) => | |
| 29 | + `<option value="">All states</option>` + Object.entries(STATES).map(([k, v]) => `<option value="${k}"${k === sel ? ' selected' : ''}>${esc(v)}</option>`).join(''); | |
| 30 | + | |
| 31 | + const searchForm = (q = '', state = '') => `<form class="search" action="/search" method="get" role="search"> | |
| 32 | + <input name="q" value="${esc(q)}" placeholder="Doctor name, specialty or city" aria-label="Doctor name, specialty or city" autocomplete="off"> | |
| 33 | + <select name="state" aria-label="State">${stateOptions(state)}</select><button class="pill" type="submit">Search</button></form>`; | |
| 34 | + | |
| 35 | + export function homePage({ count, ratingsOpen }) { | |
| 36 | + return `<section class="hero"><h1>Every doctor in America, rated by the people.</h1> | |
| 37 | + <p>A free, publicly owned registry of ${count ? count.toLocaleString('en-US') : 'every'} licensed physicians. Official public records sit at the top of every page, so a doctor's record follows them wherever they practice.</p> | |
| 38 | + ${searchForm()}<p class="hint">${ratingsOpen ? 'One verified person, one rating per doctor.' : 'Ratings open soon: one verified person, one rating per doctor.'}</p></section> | |
| 39 | + <section class="grid3"> | |
| 40 | + <div class="card"><h2>Every doctor</h2><p>Loaded from the government's own NPI registry and refreshed every month.</p></div> | |
| 41 | + <div class="card"><h2>The record follows them</h2><p>Federal exclusions, license actions and malpractice cases, each with its outcome and its official source.</p></div> | |
| 42 | + <div class="card"><h2>One person, one rating</h2><p>Patients rate their care and verified clinicians rate colleagues. Doctors can reply. Nobody can buy a score.</p></div> | |
| 43 | + </section>`; | |
| 44 | + } | |
| 45 | + | |
| 46 | + export function searchPage({ q, state, page, rows, more }) { | |
| 47 | + const qs = (n) => `/search?${new URLSearchParams({ ...(q ? { q } : {}), ...(state ? { state } : {}), page: String(n) })}`; | |
| 48 | + const list = rows.length | |
| 49 | + ? `<ul class="results">${rows.map((d) => `<li><a href="${docUrl(d)}"><span><span class="nm">${esc(d.name)}${d.credential ? ', ' + esc(d.credential) : ''}</span><br><span class="meta">${esc(d.specialty || 'Physician')}</span></span><span class="loc">${esc(d.city)}, ${esc(d.state)}</span></a></li>`).join('')}</ul>` | |
| 50 | + : q || state ? `<p class="hint">No doctors found. Try fewer words, or another state.</p>` : `<p class="hint">Search by a doctor's name, a specialty like "cardiology", or a city.</p>`; | |
| 51 | + const pager = rows.length && (page > 1 || more) | |
| 52 | + ? `<nav class="pager">${page > 1 ? `<a class="pill ghost" href="${esc(qs(page - 1))}">Previous</a>` : '<span></span>'}${more ? `<a class="pill ghost" href="${esc(qs(page + 1))}">Next</a>` : ''}</nav>` : ''; | |
| 53 | + return `<section class="hero"><h1>Find a doctor</h1>${searchForm(q, state)}</section>${list}${pager}`; | |
| 54 | + } | |
| 55 | + | |
| 56 | + const KIND = { exclusion: 'Federal exclusion', license_action: 'License action', malpractice_case: 'Malpractice case' }; | |
| 57 | + const STATUS = { filed: 'Filed, not yet decided', settled: 'Settled', dismissed: 'Dismissed', judgment_for_patient: 'Judgment for the patient', judgment_for_doctor: 'Judgment for the doctor' }; | |
| 58 | + | |
| 59 | + function recordsBlock(d, mine) { | |
| 60 | + if (!d.records.length) | |
| 61 | + return `<div class="notice"><strong>Public record</strong><p class="hint">No federal exclusions found in the HHS Office of Inspector General list, checked monthly. State medical board actions and malpractice court records are being added state by state.</p></div>`; | |
| 62 | + return `<section class="notice" aria-label="Public record"><strong>Public record: ${d.records.length} ${d.records.length === 1 ? 'entry' : 'entries'}</strong> | |
| 63 | + <ul>${d.records.map((r) => `<li><strong>${esc(KIND[r.kind] || r.kind)}</strong>${r.case_status ? ` · ${esc(STATUS[r.case_status] || r.case_status)}` : ''}${r.action_date ? ` · ${esc(fmtDate(r.action_date))}` : ''}${r.ended ? ` · ended ${esc(fmtDate(r.ended))}` : ''}<br>${esc(r.summary)} <a href="${esc(r.url)}" rel="nofollow noopener">Source: ${esc(r.source)}</a>${r.reply ? `<div class="answer"><strong>The doctor's reply</strong><br>${esc(r.reply)}</div>` : mine ? replyForm(`/reply/record/${r.id}`) : ''}</li>`).join('')}</ul> | |
| 64 | + <p class="hint">Records come only from official government and court sources and are shown as the source states them. The doctor may reply to any entry.</p></section>`; | |
| 65 | + } | |
| 66 | + | |
| 67 | + function scoreCard(label, s, minRatings) { | |
| 68 | + const n = s?.count || 0; | |
| 69 | + const body = s?.score != null | |
| 70 | + ? `<div class="big">${s.score.toFixed(1)} <small>of 5 · ${n} ratings</small></div>` | |
| 71 | + : `<div class="big"><small>${n ? `${n} of ${minRatings} ratings needed for a score` : 'No ratings yet'}</small></div>`; | |
| 72 | + return `<div class="card score"><h3>${label}</h3>${body}</div>`; | |
| 73 | + } | |
| 74 | + | |
| 75 | + function commentsBlock(d, me, mine) { | |
| 76 | + if (!d.comments.length) return ''; | |
| 77 | + return `<h2>What people say</h2><ul class="comments">${d.comments.map((c) => `<li><div class="by">${esc(c.alias || 'Verified person')} · ${c.kind === 'colleague' ? 'Colleague' : 'Patient'} · ${esc(fmtDate((c.updated || '').slice(0, 10)))} · ${c.avg.toFixed(1)} of 5</div><p>${esc(c.comment)}</p> | |
| 78 | + ${c.reply ? `<div class="answer"><strong>The doctor's reply</strong><br>${esc(c.reply)}</div>` : mine ? replyForm(`/reply/rating/${c.id}`) : ''}${me ? flagForm(c.id) : ''}</li>`).join('')}</ul>`; | |
| 79 | + } | |
| 80 | + | |
| 81 | + export function doctorPage(d, { ratingsOpen, minRatings, me }) { | |
| 82 | + const mine = !!me && me.clinician_npi === d.npi; | |
| 83 | + const canColleague = !!me && !!me.clinician_npi && !mine; | |
| 84 | + const jsonld = { '@context': 'https://schema.org', '@type': 'Physician', name: d.name, identifier: d.npi, medicalSpecialty: d.specialty || undefined, telephone: d.phone || undefined, address: { '@type': 'PostalAddress', streetAddress: d.address, addressLocality: d.city, addressRegion: d.state, postalCode: d.zip, addressCountry: 'US' } }; | |
| 85 | + const rateBtns = !ratingsOpen | |
| 86 | + ? `<button class="pill" type="button" disabled>Ratings open soon</button>` | |
| 87 | + : mine ? '' : `<a class="pill" href="/doctor/${d.npi}/rate">Rate as a patient</a>${canColleague ? `<a class="pill ghost" href="/doctor/${d.npi}/rate?kind=colleague">Rate as a colleague</a>` : ''}`; | |
| 88 | + return `<article class="doc"><h1>${esc(d.name)}${d.credential ? ', ' + esc(d.credential) : ''}</h1> | |
| 89 | + <p class="sub">${esc(d.specialty || 'Physician')} · ${esc(d.city)}, ${esc(d.state)}</p> | |
| 90 | + ${recordsBlock(d, mine)} | |
| 91 | + <div class="scores">${scoreCard('Patients', d.scores.patient, minRatings)}${scoreCard('Colleagues', d.scores.colleague, minRatings)}</div> | |
| 92 | + <div class="row">${rateBtns}</div> | |
| 93 | + ${commentsBlock(d, me, mine)} | |
| 94 | + <div class="facts card"> | |
| 95 | + <div><span>Practice address</span>${esc(d.address)}<br>${esc(d.city)}, ${esc(d.state)} ${esc(d.zip)}</div> | |
| 96 | + ${d.phone ? `<div><span>Phone</span>${esc(d.phone)}</div>` : ''} | |
| 97 | + <div><span>NPI</span><a href="https://npiregistry.cms.hhs.gov/provider-view/${d.npi}" rel="nofollow noopener">${d.npi}</a></div> | |
| 98 | + ${d.enumerated ? `<div><span>In the NPI registry since</span>${esc(fmtDate(d.enumerated))}</div>` : ''} | |
| 99 | + </div> | |
| 100 | + <p class="hint">${mine ? 'This is your page. You can reply to any rating or record.' : ratingsOpen ? `Are you this doctor? <a href="/doctor/${d.npi}/claim">Claim your page</a> to reply to ratings and records.` : 'Are you this doctor? Claiming your page and replying opens soon.'} Details come from the CMS NPPES NPI Registry${d.updated ? `, last updated by the provider on ${esc(fmtDate(d.updated))}` : ''}.</p> | |
| 101 | + <script type="application/ld+json">${JSON.stringify(jsonld).replace(/</g, '\\u003c')}</script></article>`; | |
| 102 | + } | |
| 103 | + | |
| 104 | + export function rulesPage() { | |
| 105 | + return `<article class="prose"><h1>Rating rules</h1> | |
| 106 | + <p>Docley belongs to the public. These rules keep it fair to patients and to doctors.</p> | |
| 107 | + <h2>One person, one rating</h2><ol> | |
| 108 | + <li>Each verified person gets one rating per doctor. You can update it any time; the newest one replaces the old.</li> | |
| 109 | + <li>Rate only a doctor you have seen as a patient, or, for colleague ratings, worked with as a verified clinician.</li> | |
| 110 | + <li>Doctors, their staff and their families may not rate their own practice.</li> | |
| 111 | + <li>Nobody may pay for, trade or ask for ratings. Fake ratings are removed.</li></ol> | |
| 112 | + <h2>What to write</h2><ol> | |
| 113 | + <li>Share your own experience and your honest opinion.</li> | |
| 114 | + <li>Keep it kind and specific. No insults, threats, slurs or personal attacks.</li> | |
| 115 | + <li>Never post health details: no diagnoses, medicines, test results or anything that could identify a patient.</li> | |
| 116 | + <li>Don't accuse anyone of a crime or of malpractice in a comment. Public records of that kind come only from official sources and are shown separately, with their outcome.</li></ol> | |
| 117 | + <h2>How scores work</h2><ol> | |
| 118 | + <li>Patients answer five questions from 1 to 5: listened to me, explained clearly, respected my time, treated me with kindness and respect, and would recommend to family.</li> | |
| 119 | + <li>Patient and colleague scores are kept separate. A score appears after 5 ratings and uses a weighted average, so a few early ratings can't swing it.</li></ol> | |
| 120 | + <h2>Public records</h2><ol> | |
| 121 | + <li>Federal exclusions, state license actions and malpractice cases are shown at the top of a doctor's page, with their status or outcome (filed, settled, dismissed or judgment), the date, and a link to the official source.</li> | |
| 122 | + <li>Records follow the doctor by their national provider number, wherever they practice.</li> | |
| 123 | + <li>If a record is wrong, the doctor or anyone else can tell us through the feedback form, and we check it against the source.</li></ol> | |
| 124 | + <h2>Doctors</h2><ol> | |
| 125 | + <li>Doctors can claim their page and post one public reply to any rating or record.</li> | |
| 126 | + <li>Replies must not reveal anything about a patient. That protects the patient, and it protects the doctor under HIPAA.</li> | |
| 127 | + <li>Doctors can flag a rating that breaks these rules. Flagged ratings are checked by a person.</li></ol> | |
| 128 | + <h2>Privacy</h2><p>Accounts use passkeys only: no passwords, email addresses or phone numbers. We keep no health data and never sell anything. Ratings show under a random name, and nobody, including us, can see which person wrote which rating. See our <a href="https://projectatom.ai/privacy">privacy page</a>.</p></article>`; | |
| 129 | + } | |
| 130 | + | |
| 131 | + export const notFoundPage = () => `<section class="hero"><h1>We couldn't find that page.</h1><p>Try searching for the doctor instead.</p>${searchForm()}</section>`; |
test/fixtures/leie.csv added
| 1 | + LASTNAME,FIRSTNAME,MIDNAME,BUSNAME,GENERAL,SPECIALTY,UPIN,NPI,DOB,ADDRESS,CITY,STATE,ZIP,EXCLTYPE,EXCLDATE,REINDATE,WAIVERDATE,WVRSTATE | |
| 2 | + MCDONALD,ROSE,,,IND- LIC HC SERV PRO,SURGERY,,1000000003,19700101,9 ELM,AUSTIN,TX,78701,1128b4,20190315,00000000,00000000, | |
| 3 | + NOBODY,NO,,,,,,0000000000,,,,,,1128a1,20190315,00000000,00000000, |
test/fixtures/npidata.csv added
| 1 | + "NPI","Entity Type Code","Replacement NPI","Employer Identification Number (EIN)","Provider Organization Name (Legal Business Name)","Provider Last Name (Legal Name)","Provider First Name","Provider Middle Name","Provider Name Prefix Text","Provider Name Suffix Text","Provider Credential Text","Provider First Line Business Practice Location Address","Provider Business Practice Location Address City Name","Provider Business Practice Location Address State Name","Provider Business Practice Location Address Postal Code","Provider Business Practice Location Address Telephone Number","Provider Enumeration Date","Last Update Date","NPI Deactivation Reason Code","NPI Deactivation Date","NPI Reactivation Date","Provider Sex Code","Healthcare Provider Taxonomy Code_1","Provider License Number_1","Provider License Number State Code_1","Healthcare Provider Primary Taxonomy Switch_1","Healthcare Provider Taxonomy Code_2","Provider License Number_2","Provider License Number State Code_2","Healthcare Provider Primary Taxonomy Switch_2","Healthcare Provider Taxonomy Code_3","Provider License Number_3","Provider License Number State Code_3","Healthcare Provider Primary Taxonomy Switch_3","Healthcare Provider Taxonomy Code_4","Provider License Number_4","Provider License Number State Code_4","Healthcare Provider Primary Taxonomy Switch_4","Healthcare Provider Taxonomy Code_5","Provider License Number_5","Provider License Number State Code_5","Healthcare Provider Primary Taxonomy Switch_5","Healthcare Provider Taxonomy Code_6","Provider License Number_6","Provider License Number State Code_6","Healthcare Provider Primary Taxonomy Switch_6","Healthcare Provider Taxonomy Code_7","Provider License Number_7","Provider License Number State Code_7","Healthcare Provider Primary Taxonomy Switch_7","Healthcare Provider Taxonomy Code_8","Provider License Number_8","Provider License Number State Code_8","Healthcare Provider Primary Taxonomy Switch_8","Healthcare Provider Taxonomy Code_9","Provider License Number_9","Provider License Number State Code_9","Healthcare Provider Primary Taxonomy Switch_9","Healthcare Provider Taxonomy Code_10","Provider License Number_10","Provider License Number State Code_10","Healthcare Provider Primary Taxonomy Switch_10","Healthcare Provider Taxonomy Code_11","Provider License Number_11","Provider License Number State Code_11","Healthcare Provider Primary Taxonomy Switch_11","Healthcare Provider Taxonomy Code_12","Provider License Number_12","Provider License Number State Code_12","Healthcare Provider Primary Taxonomy Switch_12","Healthcare Provider Taxonomy Code_13","Provider License Number_13","Provider License Number State Code_13","Healthcare Provider Primary Taxonomy Switch_13","Healthcare Provider Taxonomy Code_14","Provider License Number_14","Provider License Number State Code_14","Healthcare Provider Primary Taxonomy Switch_14","Healthcare Provider Taxonomy Code_15","Provider License Number_15","Provider License Number State Code_15","Healthcare Provider Primary Taxonomy Switch_15" | |
| 2 | + "1000000001","1","","","","SMITH","JANE","A","","","M.D.","100 MAIN ST","SARASOTA","FL","342360000","9415551234","05/23/2005","07/08/2026","","","","F","207RC0000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" | |
| 3 | + "1000000002","1","","","","O'BRIEN","SEAN","","","","D.O.","2 OAK AVE","TAMPA","FL","33602","8135550000","05/23/2005","07/08/2026","","","","F","207Q00000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" | |
| 4 | + "1000000003","1","","","","MCDONALD","ROSE","","","","MD","9 ELM","AUSTIN","TX","78701","5125550000","05/23/2005","07/08/2026","","","","F","208600000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" | |
| 5 | + "1000000004","1","","","","NURSE","NANCY","","","","RN","1 X","AUSTIN","TX","78701","","05/23/2005","07/08/2026","","","","F","163W00000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" | |
| 6 | + "1000000005","2","","","","","","","","","","1 HOSP","AUSTIN","TX","78701","","05/23/2005","07/08/2026","","","","F","282N00000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" | |
| 7 | + "1000000006","1","","","","GONE","GARY","","","","MD","1 X","MIAMI","FL","33101","","05/23/2005","07/08/2026","","01/01/2020","","F","207Q00000X","","","Y","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" |
test/fixtures/nucc.csv added
| 1 | + Code,Grouping,Classification,Specialization,Definition,Notes,Display Name,Section | |
| 2 | + 207RC0000X,Allopathic & Osteopathic Physicians,Internal Medicine,Cardiovascular Disease,,,Cardiovascular Disease Physician,Individual | |
| 3 | + 207Q00000X,Allopathic & Osteopathic Physicians,Family Medicine,,,,Family Medicine Physician,Individual | |
| 4 | + 208600000X,Allopathic & Osteopathic Physicians,Surgery,,,,Surgery Physician,Individual |
test/import.test.mjs added
| 1 | + import { test } from 'node:test'; | |
| 2 | + import assert from 'node:assert/strict'; | |
| 3 | + import { execFileSync } from 'node:child_process'; | |
| 4 | + import { readFileSync, mkdtempSync } from 'node:fs'; | |
| 5 | + import { tmpdir } from 'node:os'; | |
| 6 | + import { join } from 'node:path'; | |
| 7 | + import { parseCsvLine } from '../tools/csv.mjs'; | |
| 8 | + import { ftsQuery } from '../src/index.js'; | |
| 9 | + | |
| 10 | + test('csv parser handles quotes and commas', () => { | |
| 11 | + assert.deepEqual(parseCsvLine('"a","b, c","d ""e"""'), ['a', 'b, c', 'd "e"']); | |
| 12 | + }); | |
| 13 | + | |
| 14 | + test('fts query is safe and prefix based', () => { | |
| 15 | + assert.equal(ftsQuery('Jane Smi'), '"jane"* "smi"*'); | |
| 16 | + assert.equal(ftsQuery('"; DROP TABLE doctors; --'), '"drop"* "table"* "doctors"*'); | |
| 17 | + assert.equal(ftsQuery(''), ''); | |
| 18 | + }); | |
| 19 | + | |
| 20 | + test('nppes import keeps active individual physicians only', () => { | |
| 21 | + const out = mkdtempSync(join(tmpdir(), 'docley-')); | |
| 22 | + execFileSync('node', ['tools/import-nppes.mjs', '--nppes', 'test/fixtures/npidata.csv', '--nucc', 'test/fixtures/nucc.csv', '--out', out], { stdio: 'pipe' }); | |
| 23 | + const sql = readFileSync(join(out, 'doctors-0000.sql'), 'utf8'); | |
| 24 | + assert.match(sql, /'1000000001','Jane A Smith'/); | |
| 25 | + assert.match(sql, /'Sean O''Brien'/); | |
| 26 | + assert.match(sql, /'Rose McDonald'/); | |
| 27 | + assert.doesNotMatch(sql, /1000000004|1000000005|1000000006/); // nurse, organization, deactivated | |
| 28 | + }); | |
| 29 | + | |
| 30 | + test('leie import cites the source and formats the statute', () => { | |
| 31 | + const out = mkdtempSync(join(tmpdir(), 'docley-')); | |
| 32 | + execFileSync('node', ['tools/import-leie.mjs', '--leie', 'test/fixtures/leie.csv', '--out', out], { stdio: 'pipe' }); | |
| 33 | + const sql = readFileSync(join(out, 'records-leie.sql'), 'utf8'); | |
| 34 | + assert.match(sql, /'1000000003','HHS-OIG LEIE'/); | |
| 35 | + assert.match(sql, /§1128\(b\)\(4\)/); | |
| 36 | + assert.match(sql, /https:\/\/exclusions\.oig\.hhs\.gov\//); | |
| 37 | + assert.doesNotMatch(sql, /0000000000/); | |
| 38 | + }); |
test/passkeys.test.mjs added
| 1 | + import { test } from 'node:test'; | |
| 2 | + import assert from 'node:assert/strict'; | |
| 3 | + import { DatabaseSync } from 'node:sqlite'; | |
| 4 | + import { readFileSync, readdirSync } from 'node:fs'; | |
| 5 | + import { webcrypto as crypto } from 'node:crypto'; | |
| 6 | + import worker from '../src/index.js'; | |
| 7 | + | |
| 8 | + const SITE = 'https://doctors.projectatom.ai'; | |
| 9 | + const SECRET = 'x'.repeat(40); | |
| 10 | + | |
| 11 | + // ---- A tiny D1 stand-in on node:sqlite, with every migration applied. ---- | |
| 12 | + function d1() { | |
| 13 | + const db = new DatabaseSync(':memory:'); | |
| 14 | + for (const f of readdirSync('migrations').sort()) db.exec(readFileSync('migrations/' + f, 'utf8')); | |
| 15 | + const statement = (sql, args = []) => ({ | |
| 16 | + bind: (...a) => statement(sql, a), | |
| 17 | + first: async (col) => { | |
| 18 | + const row = db.prepare(sql).get(...args) ?? null; | |
| 19 | + return row && col ? row[col] : row; | |
| 20 | + }, | |
| 21 | + all: async () => ({ results: db.prepare(sql).all(...args) }), | |
| 22 | + run: async () => ({ meta: { changes: Number(db.prepare(sql).run(...args).changes) } }), | |
| 23 | + sql, | |
| 24 | + }); | |
| 25 | + return { | |
| 26 | + raw: db, | |
| 27 | + prepare: (sql) => statement(sql), | |
| 28 | + batch: async (list) => { | |
| 29 | + db.exec('BEGIN'); | |
| 30 | + try { | |
| 31 | + const out = []; | |
| 32 | + for (const s of list) out.push(/^\s*(SELECT|.*RETURNING)/is.test(s.sql) ? await s.all() : await s.run()); | |
| 33 | + db.exec('COMMIT'); | |
| 34 | + return out; | |
| 35 | + } catch (e) { | |
| 36 | + db.exec('ROLLBACK'); | |
| 37 | + throw e; | |
| 38 | + } | |
| 39 | + }, | |
| 40 | + }; | |
| 41 | + } | |
| 42 | + | |
| 43 | + const makeEnv = (extra = {}) => ({ DB: d1(), SITE_URL: SITE, RATINGS_OPEN: 'true', SESSION_SECRET: 'test-session-secret', DOCLEY_ADMIN_SETUP_SECRET: SECRET, ...extra }); | |
| 44 | + | |
| 45 | + // ---- A browser with a cookie jar. ---- | |
| 46 | + function browser(env) { | |
| 47 | + const jar = new Map(); | |
| 48 | + async function call(path, { method = 'GET', body, headers = {} } = {}) { | |
| 49 | + const h = { ...headers }; | |
| 50 | + if (jar.size) h.cookie = [...jar].map(([k, v]) => `${k}=${v}`).join('; '); | |
| 51 | + if (body !== undefined) { | |
| 52 | + h['content-type'] ??= 'application/json'; | |
| 53 | + h.origin ??= SITE; | |
| 54 | + } | |
| 55 | + const res = await worker.fetch(new Request(SITE + path, { method, headers: h, body: body === undefined ? undefined : typeof body === 'string' ? body : JSON.stringify(body), redirect: 'manual' }), env, { waitUntil() {} }); | |
| 56 | + for (const c of res.headers.getSetCookie()) { | |
| 57 | + const [pair, ...attrs] = c.split(';'); | |
| 58 | + const [k, v] = [pair.slice(0, pair.indexOf('=')), pair.slice(pair.indexOf('=') + 1)]; | |
| 59 | + if (/max-age=0/i.test(attrs.join(';'))) jar.delete(k); | |
| 60 | + else jar.set(k, v); | |
| 61 | + } | |
| 62 | + return res; | |
| 63 | + } | |
| 64 | + return { call, jar, post: (path, body = {}, headers) => call(path, { method: 'POST', body, headers }) }; | |
| 65 | + } | |
| 66 | + | |
| 67 | + // ---- A software authenticator (ES256, "none" attestation). ---- | |
| 68 | + const b64u = (buf) => Buffer.from(buf).toString('base64url'); | |
| 69 | + const fromB64u = (s) => new Uint8Array(Buffer.from(s, 'base64url')); | |
| 70 | + const concat = (...parts) => new Uint8Array(Buffer.concat(parts.map((p) => Buffer.from(p)))); | |
| 71 | + const sha = async (data) => new Uint8Array(await crypto.subtle.digest('SHA-256', data)); | |
| 72 | + | |
| 73 | + function cbor(value) { | |
| 74 | + const head = (major, n) => (n < 24 ? [(major << 5) | n] : n < 256 ? [(major << 5) | 24, n] : [(major << 5) | 25, n >> 8, n & 255]); | |
| 75 | + if (typeof value === 'number') return new Uint8Array(value >= 0 ? head(0, value) : head(1, -1 - value)); | |
| 76 | + if (typeof value === 'string') return concat(head(3, Buffer.byteLength(value)), Buffer.from(value)); | |
| 77 | + if (value instanceof Uint8Array) return concat(head(2, value.length), value); | |
| 78 | + if (value instanceof Map) return concat(head(5, value.size), ...[...value].flatMap(([k, v]) => [cbor(k), cbor(v)])); | |
| 79 | + throw new Error('cbor: unsupported'); | |
| 80 | + } | |
| 81 | + | |
| 82 | + function derSignature(raw) { | |
| 83 | + const int = (b) => { | |
| 84 | + let i = 0; | |
| 85 | + while (i < b.length - 1 && b[i] === 0) i++; | |
| 86 | + b = b.slice(i); | |
| 87 | + return b[0] & 0x80 ? concat([0], b) : b; | |
| 88 | + }; | |
| 89 | + const r = int(raw.slice(0, 32)), s = int(raw.slice(32)); | |
| 90 | + return concat([0x30, r.length + s.length + 4, 0x02, r.length], r, [0x02, s.length], s); | |
| 91 | + } | |
| 92 | + | |
| 93 | + async function authenticator() { | |
| 94 | + const keys = await crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, ['sign', 'verify']); | |
| 95 | + const jwk = await crypto.subtle.exportKey('jwk', keys.publicKey); | |
| 96 | + const credId = crypto.getRandomValues(new Uint8Array(16)); | |
| 97 | + let counter = 0, userHandle = null; | |
| 98 | + const rpHash = () => sha(Buffer.from(new URL(SITE).hostname)); | |
| 99 | + const flags = 0x01 | 0x04 | 0x08 | 0x10; // user present, user verified, backup eligible, backed up | |
| 100 | + return { | |
| 101 | + id: b64u(credId), | |
| 102 | + async create(options) { | |
| 103 | + userHandle = options.user.id; | |
| 104 | + const cose = cbor(new Map([[1, 2], [3, -7], [-1, 1], [-2, fromB64u(jwk.x)], [-3, fromB64u(jwk.y)]])); | |
| 105 | + const authData = concat(await rpHash(), [flags | 0x40], [0, 0, 0, 0], new Uint8Array(16), [0, credId.length], credId, cose); | |
| 106 | + const clientData = Buffer.from(JSON.stringify({ type: 'webauthn.create', challenge: options.challenge, origin: SITE, crossOrigin: false })); | |
| 107 | + return { | |
| 108 | + id: b64u(credId), rawId: b64u(credId), type: 'public-key', clientExtensionResults: {}, | |
| 109 | + response: { clientDataJSON: b64u(clientData), attestationObject: b64u(cbor(new Map([['fmt', 'none'], ['attStmt', new Map()], ['authData', authData]]))), transports: ['internal', 'hybrid'] }, | |
| 110 | + }; | |
| 111 | + }, | |
| 112 | + async get(options) { | |
| 113 | + counter += 1; | |
| 114 | + const authData = concat(await rpHash(), [flags], [0, 0, 0, counter]); | |
| 115 | + const clientData = Buffer.from(JSON.stringify({ type: 'webauthn.get', challenge: options.challenge, origin: SITE, crossOrigin: false })); | |
| 116 | + const raw = new Uint8Array(await crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, keys.privateKey, concat(authData, await sha(clientData)))); | |
| 117 | + return { | |
| 118 | + id: b64u(credId), rawId: b64u(credId), type: 'public-key', clientExtensionResults: {}, | |
| 119 | + response: { clientDataJSON: b64u(clientData), authenticatorData: b64u(authData), signature: b64u(derSignature(raw)), userHandle }, | |
| 120 | + }; | |
| 121 | + }, | |
| 122 | + }; | |
| 123 | + } | |
| 124 | + | |
| 125 | + async function createAccount(b, key, extra = {}) { | |
| 126 | + const options = await (await b.post('/api/passkeys/register/options', extra)).json(); | |
| 127 | + return b.post('/api/passkeys/register/verify', { response: await key.create(options), name: 'Test phone' }); | |
| 128 | + } | |
| 129 | + | |
| 130 | + async function signIn(b, key) { | |
| 131 | + const options = await (await b.post('/api/passkeys/signin/options')).json(); | |
| 132 | + return b.post('/api/passkeys/signin/verify', { response: await key.get(options) }); | |
| 133 | + } | |
| 134 | + | |
| 135 | + // ---- Tests ---- | |
| 136 | + test('options endpoints use the site hostname as rpID and require user verification and discoverable keys', async () => { | |
| 137 | + const b = browser(makeEnv()); | |
| 138 | + const reg = await b.post('/api/passkeys/register/options'); | |
| 139 | + assert.equal(reg.status, 200); | |
| 140 | + assert.match(reg.headers.get('cache-control'), /no-store/); | |
| 141 | + const r = await reg.json(); | |
| 142 | + assert.equal(r.rp.id, 'doctors.projectatom.ai'); | |
| 143 | + assert.equal(r.authenticatorSelection.residentKey, 'required'); | |
| 144 | + assert.equal(r.authenticatorSelection.userVerification, 'required'); | |
| 145 | + assert.equal(r.attestation, 'none'); | |
| 146 | + assert.ok(b.jar.get('dlc'), 'challenge cookie set'); | |
| 147 | + | |
| 148 | + const s = await (await b.post('/api/passkeys/signin/options')).json(); | |
| 149 | + assert.equal(s.rpId, 'doctors.projectatom.ai'); | |
| 150 | + assert.equal(s.userVerification, 'required'); | |
| 151 | + assert.deepEqual(s.allowCredentials ?? [], []); | |
| 152 | + }); | |
| 153 | + | |
| 154 | + test('rpID follows SITE_URL, so local dev uses localhost', async () => { | |
| 155 | + const env = makeEnv({ SITE_URL: 'http://localhost:8787' }); | |
| 156 | + const res = await worker.fetch(new Request('http://localhost:8787/api/passkeys/signin/options', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }), env, {}); | |
| 157 | + assert.equal((await res.json()).rpId, 'localhost'); | |
| 158 | + }); | |
| 159 | + | |
| 160 | + test('challenge cookie is HttpOnly, short lived and scoped to the passkey API', async () => { | |
| 161 | + const b = browser(makeEnv()); | |
| 162 | + const res = await b.post('/api/passkeys/signin/options'); | |
| 163 | + const c = res.headers.getSetCookie().find((x) => x.startsWith('dlc=')); | |
| 164 | + assert.match(c, /HttpOnly/); | |
| 165 | + assert.match(c, /Secure/); | |
| 166 | + assert.match(c, /SameSite=Strict/); | |
| 167 | + assert.match(c, /Max-Age=300/); | |
| 168 | + assert.match(c, /Path=\/api\/passkeys/); | |
| 169 | + }); | |
| 170 | + | |
| 171 | + test('create an account, sign out, and sign back in with the passkey', async () => { | |
| 172 | + const env = makeEnv(); | |
| 173 | + const b = browser(env); | |
| 174 | + const key = await authenticator(); | |
| 175 | + const created = await createAccount(b, key); | |
| 176 | + assert.equal(created.status, 200, await created.clone().text()); | |
| 177 | + assert.ok(b.jar.get('dly'), 'signed in after creating the account'); | |
| 178 | + const row = env.DB.raw.prepare('SELECT * FROM passkeys').get(); | |
| 179 | + assert.equal(row.credential_id, key.id); | |
| 180 | + assert.equal(row.backed_up, 1); | |
| 181 | + assert.equal(row.name, 'Test phone'); | |
| 182 | + assert.equal(env.DB.raw.prepare('SELECT COUNT(*) n FROM people').get().n, 1); | |
| 183 | + | |
| 184 | + b.jar.delete('dly'); | |
| 185 | + const signedIn = await signIn(b, key); | |
| 186 | + assert.equal(signedIn.status, 200, await signedIn.clone().text()); | |
| 187 | + assert.ok(b.jar.get('dly')); | |
| 188 | + assert.equal(env.DB.raw.prepare('SELECT counter FROM passkeys').get().counter, 1); | |
| 189 | + const list = await (await b.call('/api/passkeys')).json(); | |
| 190 | + assert.equal(list.passkeys.length, 1); | |
| 191 | + assert.equal((await b.call('/account')).status, 200); | |
| 192 | + }); | |
| 193 | + | |
| 194 | + test('a challenge works once', async () => { | |
| 195 | + const env = makeEnv(); | |
| 196 | + const b = browser(env); | |
| 197 | + const key = await authenticator(); | |
| 198 | + await createAccount(b, key); | |
| 199 | + b.jar.delete('dly'); | |
| 200 | + | |
| 201 | + const options = await (await b.post('/api/passkeys/signin/options')).json(); | |
| 202 | + const cookie = b.jar.get('dlc'); | |
| 203 | + const assertion = await key.get(options); | |
| 204 | + assert.equal((await b.post('/api/passkeys/signin/verify', { response: assertion })).status, 200); | |
| 205 | + b.jar.set('dlc', cookie); // replay the same challenge | |
| 206 | + const again = await b.post('/api/passkeys/signin/verify', { response: assertion }); | |
| 207 | + assert.equal(again.status, 400); | |
| 208 | + assert.equal((await again.json()).error, 'challenge_expired'); | |
| 209 | + }); | |
| 210 | + | |
| 211 | + test('a challenge expires', async () => { | |
| 212 | + const env = makeEnv(); | |
| 213 | + const b = browser(env); | |
| 214 | + const key = await authenticator(); | |
| 215 | + await createAccount(b, key); | |
| 216 | + b.jar.delete('dly'); | |
| 217 | + const options = await (await b.post('/api/passkeys/signin/options')).json(); | |
| 218 | + env.DB.raw.prepare('UPDATE webauthn_challenges SET expires = expires - 600').run(); | |
| 219 | + const res = await b.post('/api/passkeys/signin/verify', { response: await key.get(options) }); | |
| 220 | + assert.equal(res.status, 400); | |
| 221 | + assert.equal((await res.json()).error, 'challenge_expired'); | |
| 222 | + assert.equal(b.jar.get('dly'), undefined); | |
| 223 | + }); | |
| 224 | + | |
| 225 | + test('a sign-in challenge cannot be used to register', async () => { | |
| 226 | + const b = browser(makeEnv()); | |
| 227 | + const key = await authenticator(); | |
| 228 | + const options = await (await b.post('/api/passkeys/signin/options')).json(); | |
| 229 | + const res = await b.post('/api/passkeys/register/verify', { response: await key.create({ challenge: options.challenge, user: { id: 'eA' } }) }); | |
| 230 | + assert.equal((await res.json()).error, 'challenge_expired'); | |
| 231 | + }); | |
| 232 | + | |
| 233 | + test('add a second passkey, and the last one cannot be removed', async () => { | |
| 234 | + const env = makeEnv(); | |
| 235 | + const b = browser(env); | |
| 236 | + const first = await authenticator(); | |
| 237 | + await createAccount(b, first); | |
| 238 | + assert.equal((await b.post('/api/passkeys/delete', { id: first.id })).status, 400, 'only passkey stays'); | |
| 239 | + | |
| 240 | + const second = await authenticator(); | |
| 241 | + const options = await (await b.post('/api/passkeys/add/options')).json(); | |
| 242 | + assert.deepEqual(options.excludeCredentials.map((c) => c.id), [first.id]); | |
| 243 | + const added = await b.post('/api/passkeys/add/verify', { response: await second.create(options), name: '' }); | |
| 244 | + assert.equal(added.status, 200, await added.clone().text()); | |
| 245 | + assert.equal(env.DB.raw.prepare('SELECT COUNT(DISTINCT person_id) n, COUNT(*) k FROM passkeys').get().k, 2); | |
| 246 | + assert.equal(env.DB.raw.prepare('SELECT COUNT(DISTINCT person_id) n FROM passkeys').get().n, 1); | |
| 247 | + | |
| 248 | + assert.equal((await b.post('/api/passkeys/delete', { id: first.id })).status, 200); | |
| 249 | + assert.equal((await b.post('/api/passkeys/delete', { id: second.id })).status, 400); | |
| 250 | + | |
| 251 | + b.jar.delete('dly'); | |
| 252 | + assert.equal((await signIn(b, second)).status, 200, 'the second passkey is the way back in'); | |
| 253 | + }); | |
| 254 | + | |
| 255 | + test('signed-out people cannot add, list or remove passkeys', async () => { | |
| 256 | + const b = browser(makeEnv()); | |
| 257 | + assert.equal((await b.post('/api/passkeys/add/options')).status, 401); | |
| 258 | + assert.equal((await b.call('/api/passkeys')).status, 401); | |
| 259 | + assert.equal((await b.post('/api/passkeys/delete', { id: 'x' })).status, 401); | |
| 260 | + assert.equal((await b.call('/account')).headers.get('location'), '/signin?next=/account'); | |
| 261 | + }); | |
| 262 | + | |
| 263 | + test('new accounts are limited per network per day', async () => { | |
| 264 | + const env = makeEnv(); | |
| 265 | + const ip = { 'cf-connecting-ip': '203.0.113.9' }; | |
| 266 | + for (let i = 0; i < 3; i++) { | |
| 267 | + const b = browser(env); | |
| 268 | + const options = await (await b.post('/api/passkeys/register/options', {}, ip)).json(); | |
| 269 | + const res = await b.post('/api/passkeys/register/verify', { response: await (await authenticator()).create(options) }, ip); | |
| 270 | + assert.equal(res.status, 200); | |
| 271 | + } | |
| 272 | + const blocked = await browser(env).post('/api/passkeys/register/options', {}, ip); | |
| 273 | + assert.equal(blocked.status, 429); | |
| 274 | + assert.equal((await browser(env).post('/api/passkeys/register/options', {}, { 'cf-connecting-ip': '198.51.100.1' })).status, 200); | |
| 275 | + assert.doesNotMatch(JSON.stringify(env.DB.raw.prepare('SELECT * FROM account_ips').all()), /203\.0\.113\.9/); | |
| 276 | + }); | |
| 277 | + | |
| 278 | + test('passkey API rejects other origins and non-JSON bodies', async () => { | |
| 279 | + const b = browser(makeEnv()); | |
| 280 | + assert.equal((await b.post('/api/passkeys/signin/options', {}, { origin: 'https://evil.example' })).status, 403); | |
| 281 | + assert.equal((await b.post('/api/passkeys/signin/options', 'a=1', { 'content-type': 'application/x-www-form-urlencoded' })).status, 415); | |
| 282 | + }); | |
| 283 | + | |
| 284 | + test('admin setup is 404 without the right secret', async () => { | |
| 285 | + const b = browser(makeEnv()); | |
| 286 | + assert.equal((await b.call('/api/admin-setup', { method: 'POST' })).status, 404); | |
| 287 | + assert.equal((await b.call('/api/admin-setup', { method: 'POST', headers: { 'x-setup-secret': 'y'.repeat(40) } })).status, 404); | |
| 288 | + assert.equal((await b.call('/api/admin-setup', { method: 'POST', headers: { 'x-setup-secret': SECRET.slice(1) } })).status, 404); | |
| 289 | + const short = browser(makeEnv({ DOCLEY_ADMIN_SETUP_SECRET: 'short-secret' })); | |
| 290 | + assert.equal((await short.call('/api/admin-setup', { method: 'POST', headers: { 'x-setup-secret': 'short-secret' } })).status, 404, 'secrets under 32 characters are refused'); | |
| 291 | + const none = browser(makeEnv({ DOCLEY_ADMIN_SETUP_SECRET: undefined })); | |
| 292 | + assert.equal((await none.call('/api/admin-setup', { method: 'POST', headers: { 'x-setup-secret': '' } })).status, 404); | |
| 293 | + }); | |
| 294 | + | |
| 295 | + async function setupLink(env) { | |
| 296 | + const res = await browser(env).call('/api/admin-setup', { method: 'POST', headers: { 'x-setup-secret': SECRET } }); | |
| 297 | + assert.equal(res.status, 200); | |
| 298 | + const { url, expires } = await res.json(); | |
| 299 | + assert.match(url, /^https:\/\/doctors\.projectatom\.ai\/admin\/setup\?token=[\w-]{40,}$/); | |
| 300 | + const minutes = (Date.parse(expires) - Date.now()) / 60000; | |
| 301 | + assert.ok(minutes > 14 && minutes <= 15, 'expires in 15 minutes'); | |
| 302 | + return new URL(url); | |
| 303 | + } | |
| 304 | + | |
| 305 | + test('admin setup link makes a new admin passkey once, then is dead', async () => { | |
| 306 | + const env = makeEnv(); | |
| 307 | + const link = await setupLink(env); | |
| 308 | + const token = link.searchParams.get('token'); | |
| 309 | + assert.equal(env.DB.raw.prepare('SELECT COUNT(*) n FROM admin_setup_links WHERE token_hash=?').get(token).n, 0, 'only the hash is stored'); | |
| 310 | + | |
| 311 | + const b = browser(env); | |
| 312 | + assert.equal((await b.call(link.pathname + link.search)).status, 200); | |
| 313 | + const created = await createAccount(b, await authenticator(), { setupToken: token }); | |
| 314 | + assert.equal(created.status, 200, await created.clone().text()); | |
| 315 | + assert.equal(env.DB.raw.prepare('SELECT is_admin FROM people').get().is_admin, 1); | |
| 316 | + assert.equal((await b.call('/admin')).status, 200); | |
| 317 | + | |
| 318 | + const other = browser(env); | |
| 319 | + assert.equal((await other.call(link.pathname + link.search)).status, 404, 'link page is gone'); | |
| 320 | + assert.equal((await other.post('/api/passkeys/register/options', { setupToken: token })).status, 404, 'token is single use'); | |
| 321 | + }); | |
| 322 | + | |
| 323 | + test('an admin token cannot be spent twice even with two challenges open', async () => { | |
| 324 | + const env = makeEnv(); | |
| 325 | + const token = (await setupLink(env)).searchParams.get('token'); | |
| 326 | + const a = browser(env), b = browser(env); | |
| 327 | + const oa = await (await a.post('/api/passkeys/register/options', { setupToken: token })).json(); | |
| 328 | + const ob = await (await b.post('/api/passkeys/register/options', { setupToken: token })).json(); | |
| 329 | + assert.equal((await a.post('/api/passkeys/register/verify', { response: await (await authenticator()).create(oa) })).status, 200); | |
| 330 | + assert.equal((await b.post('/api/passkeys/register/verify', { response: await (await authenticator()).create(ob) })).status, 410); | |
| 331 | + assert.equal(env.DB.raw.prepare('SELECT COUNT(*) n FROM people WHERE is_admin=1').get().n, 1); | |
| 332 | + }); | |
| 333 | + | |
| 334 | + test('a signed-in person can use the admin link once to become admin', async () => { | |
| 335 | + const env = makeEnv(); | |
| 336 | + const b = browser(env); | |
| 337 | + await createAccount(b, await authenticator()); | |
| 338 | + assert.equal((await b.call('/admin')).status, 404); | |
| 339 | + const token = (await setupLink(env)).searchParams.get('token'); | |
| 340 | + const res = await b.call('/admin/setup', { method: 'POST', body: `token=${token}`, headers: { 'content-type': 'application/x-www-form-urlencoded' } }); | |
| 341 | + assert.equal(res.status, 303); | |
| 342 | + assert.equal((await b.call('/admin')).status, 200); | |
| 343 | + const again = await b.call('/admin/setup', { method: 'POST', body: `token=${token}`, headers: { 'content-type': 'application/x-www-form-urlencoded' } }); | |
| 344 | + assert.equal(again.status, 404); | |
| 345 | + }); | |
| 346 | + | |
| 347 | + test('/admin and /admin/action are 404 for anyone who is not an admin', async () => { | |
| 348 | + const env = makeEnv({ ADMIN_TOKEN: 'old-token' }); | |
| 349 | + const anon = browser(env); | |
| 350 | + assert.equal((await anon.call('/admin')).status, 404); | |
| 351 | + assert.equal((await anon.call('/admin?key=old-token')).status, 404, 'the old ?key= admin is gone'); | |
| 352 | + const b = browser(env); | |
| 353 | + await createAccount(b, await authenticator()); | |
| 354 | + assert.equal((await b.call('/admin')).status, 404); | |
| 355 | + const action = await b.call('/admin/action', { method: 'POST', body: 'type=rating&id=x&action=remove', headers: { 'content-type': 'application/x-www-form-urlencoded' } }); | |
| 356 | + assert.equal(action.status, 404); | |
| 357 | + }); | |
| 358 | + | |
| 359 | + test('apple-app-site-association is served as JSON without a redirect', async () => { | |
| 360 | + const res = await browser(makeEnv()).call('/.well-known/apple-app-site-association'); | |
| 361 | + assert.equal(res.status, 200); | |
| 362 | + assert.equal(res.headers.get('content-type'), 'application/json'); | |
| 363 | + assert.deepEqual(await res.json(), { webcredentials: { apps: ['22HV69L32T.ai.projectatom.docley'] } }); | |
| 364 | + }); | |
| 365 | + | |
| 366 | + test('pages allow only same-origin scripts, and the passkey script is served', async () => { | |
| 367 | + const b = browser(makeEnv()); | |
| 368 | + const page = await b.call('/signin'); | |
| 369 | + const csp = page.headers.get('content-security-policy'); | |
| 370 | + assert.match(csp, /script-src 'self'/); | |
| 371 | + const body = await page.text(); | |
| 372 | + assert.match(body, /src="\/assets\/passkey\.js"/); | |
| 373 | + assert.match(body, /Sign in with passkey/); | |
| 374 | + assert.match(body, /Create an account with a passkey/); | |
| 375 | + assert.doesNotMatch(body, /<script>|<script (?!src|type="application\/ld\+json")/, 'no inline script'); | |
| 376 | + const js = await b.call('/assets/passkey.js'); | |
| 377 | + assert.match(js.headers.get('content-type'), /javascript/); | |
| 378 | + const src = await js.text(); | |
| 379 | + assert.match(src, /navigator\.credentials\.create/); | |
| 380 | + assert.doesNotMatch(src, /https?:\/\//, 'no CDN'); | |
| 381 | + // Runs on its own (no bundler helpers or globals it does not define) and wires up the click handler. | |
| 382 | + let listening = false; | |
| 383 | + const document = { querySelector: () => null, addEventListener: (type) => (listening = type === 'click') }; | |
| 384 | + new Function('document', 'window', src)(document, { PublicKeyCredential() {} }); | |
| 385 | + assert.ok(listening); | |
| 386 | + }); | |
| 387 | + | |
| 388 | + test('no route accepts a phone number anymore', async () => { | |
| 389 | + const env = makeEnv({ DEV_CODE: '123456' }); | |
| 390 | + const b = browser(env); | |
| 391 | + const form = { 'content-type': 'application/x-www-form-urlencoded' }; | |
| 392 | + for (const path of ['/signin', '/signin/verify']) { | |
| 393 | + const res = await b.call(path, { method: 'POST', body: 'phone=5555550123&code=123456', headers: form }); | |
| 394 | + assert.equal(res.status, 404, path); | |
| 395 | + assert.equal(res.headers.get('set-cookie'), null); | |
| 396 | + } | |
| 397 | + const signin = await (await b.call('/signin')).text(); | |
| 398 | + assert.doesNotMatch(signin, /name="phone"|name="code"|inputmode="tel"|one-time-code/); | |
| 399 | + for (const f of readdirSync('src')) { | |
| 400 | + const src = readFileSync('src/' + f, 'utf8'); | |
| 401 | + assert.doesNotMatch(src, /twilio|PHONE_PEPPER|normalizePhone|sendCode|checkCode|ADMIN_TOKEN|DEV_CODE/i, f); | |
| 402 | + } | |
| 403 | + assert.equal(env.DB.raw.prepare(`SELECT COUNT(*) n FROM sqlite_master WHERE name='sends'`).get().n, 0); | |
| 404 | + assert.equal(env.DB.raw.prepare(`SELECT COUNT(*) n FROM pragma_table_info('people') WHERE name='token_hash'`).get().n, 0); | |
| 405 | + }); |
tools/csv.mjs added
| 1 | + export function parseCsvLine(line) { | |
| 2 | + const out = []; | |
| 3 | + let cur = ''; | |
| 4 | + let q = false; | |
| 5 | + for (let i = 0; i < line.length; i++) { | |
| 6 | + const c = line[i]; | |
| 7 | + if (q) { | |
| 8 | + if (c === '"') { | |
| 9 | + if (line[i + 1] === '"') { cur += '"'; i++; } else q = false; | |
| 10 | + } else cur += c; | |
| 11 | + } else if (c === '"') q = true; | |
| 12 | + else if (c === ',') { out.push(cur); cur = ''; } | |
| 13 | + else cur += c; | |
| 14 | + } | |
| 15 | + out.push(cur); | |
| 16 | + return out; | |
| 17 | + } | |
| 18 | + |
tools/import-leie.mjs added
| 1 | + #!/usr/bin/env node | |
| 2 | + // HHS Office of Inspector General List of Excluded Individuals/Entities (LEIE). | |
| 3 | + // Federal, public, updated monthly, and keyed by NPI, so an exclusion follows the | |
| 4 | + // doctor to any hospital or state. Source: https://oig.hhs.gov/exclusions/exclusions_list.asp | |
| 5 | + // Download: https://oig.hhs.gov/exclusions/downloadables/UPDATED.csv | |
| 6 | + // Usage: node tools/import-leie.mjs --leie UPDATED.csv --out out-records/ | |
| 7 | + import { readFileSync, mkdirSync, writeFileSync } from 'node:fs'; | |
| 8 | + import { join } from 'node:path'; | |
| 9 | + import { createHash } from 'node:crypto'; | |
| 10 | + import { parseCsvLine } from './csv.mjs'; | |
| 11 | + | |
| 12 | + const a = process.argv.slice(2); | |
| 13 | + const arg = (k) => a[a.indexOf('--' + k) + 1]; | |
| 14 | + const file = arg('leie'), out = arg('out'); | |
| 15 | + if (!a.includes('--leie') || !a.includes('--out')) { console.error('usage: --leie UPDATED.csv --out dir'); process.exit(1); } | |
| 16 | + mkdirSync(out, { recursive: true }); | |
| 17 | + | |
| 18 | + // Exclusion authorities, Social Security Act 1128 / 1156. Plain words from OIG's own descriptions. | |
| 19 | + const TYPES = { | |
| 20 | + '1128a1': 'Convicted of a crime related to Medicare or Medicaid', | |
| 21 | + '1128a2': 'Convicted of patient abuse or neglect', | |
| 22 | + '1128a3': 'Felony conviction for health care fraud', | |
| 23 | + '1128a4': 'Felony conviction involving controlled substances', | |
| 24 | + '1128b1': 'Misdemeanor conviction for health care fraud', | |
| 25 | + '1128b2': 'Conviction for obstructing an investigation', | |
| 26 | + '1128b3': 'Misdemeanor conviction involving controlled substances', | |
| 27 | + '1128b4': 'License revoked, suspended or surrendered by a state board', | |
| 28 | + '1128b5': 'Suspended or excluded by another federal or state health program', | |
| 29 | + '1128b6': 'Excessive charges, unnecessary services or substandard care', | |
| 30 | + '1128b7': 'Fraud, kickbacks and other prohibited activities', | |
| 31 | + '1128b8': 'Owner or officer of a sanctioned entity', | |
| 32 | + '1128b11': 'Failure to provide payment information', | |
| 33 | + '1128b14': 'Default on health education loan or scholarship', | |
| 34 | + '1128b15': 'Individual controlling a sanctioned entity', | |
| 35 | + '1128b16': 'False statements or misrepresentations', | |
| 36 | + '1156': 'Failed obligations under a Quality Improvement Organization review', | |
| 37 | + }; | |
| 38 | + const iso = (d) => (/^\d{8}$/.test(d || '') && d !== '00000000' ? `${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6)}` : null); | |
| 39 | + const sq = (v) => (v == null || v === '' ? 'NULL' : "'" + String(v).replace(/'/g, "''") + "'"); | |
| 40 | + | |
| 41 | + const lines = readFileSync(file, 'utf8').split(/\r?\n/); | |
| 42 | + const h = parseCsvLine(lines[0]).map((s) => s.trim().replace(/^/, '')); | |
| 43 | + const c = (n) => h.indexOf(n); | |
| 44 | + const I = { npi: c('NPI'), type: c('EXCLTYPE'), date: c('EXCLDATE'), rein: c('REINDATE'), state: c('STATE') }; | |
| 45 | + const rows = []; | |
| 46 | + for (const line of lines.slice(1)) { | |
| 47 | + if (!line.trim()) continue; | |
| 48 | + const r = parseCsvLine(line); | |
| 49 | + const npi = (r[I.npi] || '').trim(); | |
| 50 | + if (!/^\d{10}$/.test(npi) || npi === '0000000000') continue; | |
| 51 | + const type = (r[I.type] || '').trim().toLowerCase().replace(/\s/g, ''); | |
| 52 | + const date = iso(r[I.date]); | |
| 53 | + const id = createHash('sha256').update(`leie|${npi}|${type}|${date}`).digest('hex').slice(0, 24); | |
| 54 | + const summary = `Excluded from Medicare, Medicaid and all federal health programs: ${TYPES[type] || 'see source'} (Social Security Act §${type.replace(/^(\d{4})([ab])(\d+)$/, '$1($2)($3)')}).`; | |
| 55 | + rows.push(`(${[sq(id), sq(npi), "'HHS-OIG LEIE'", sq((r[I.state] || '').trim()), "'exclusion'", sq(date), sq(summary), "'https://exclusions.oig.hhs.gov/'", sq(iso(r[I.rein]))].join(',')})`); | |
| 56 | + } | |
| 57 | + const chunks = []; | |
| 58 | + for (let i = 0; i < rows.length; i += 500) | |
| 59 | + chunks.push('INSERT OR REPLACE INTO records (id,npi,source,state,kind,action_date,summary,url,ended) VALUES\n' + rows.slice(i, i + 500).join(',\n') + ';'); | |
| 60 | + writeFileSync(join(out, 'records-leie.sql'), "DELETE FROM records WHERE source='HHS-OIG LEIE';\n" + chunks.join('\n') + '\n'); | |
| 61 | + console.error(`LEIE: ${rows.length} exclusions with an NPI`); |
tools/import-nppes.mjs added
| 1 | + #!/usr/bin/env node | |
| 2 | + // Turns the CMS NPPES full file (npidata_pfile_*.csv) into SQL batches for D1. | |
| 3 | + // Keeps individual physicians (Entity Type 1, primary taxonomy in the 20xxxxxxxX | |
| 4 | + // "Allopathic & Osteopathic Physicians" group) that are not deactivated. | |
| 5 | + // | |
| 6 | + // Usage: | |
| 7 | + // node tools/import-nppes.mjs --nppes npidata_pfile.csv --nucc nucc_taxonomy.csv --out out/ | |
| 8 | + // Then load with tools/load-d1.sh out/ | |
| 9 | + import { createReadStream, mkdirSync, writeFileSync, readFileSync } from 'node:fs'; | |
| 10 | + import { createInterface } from 'node:readline'; | |
| 11 | + import { join } from 'node:path'; | |
| 12 | + import { parseCsvLine } from './csv.mjs'; | |
| 13 | + | |
| 14 | + const args = Object.fromEntries( | |
| 15 | + process.argv.slice(2).reduce((acc, v, i, a) => (v.startsWith('--') ? [...acc, [v.slice(2), a[i + 1]]] : acc), []) | |
| 16 | + ); | |
| 17 | + if (!args.nppes || !args.out) { | |
| 18 | + console.error('usage: --nppes <npidata_pfile.csv> [--nucc <nucc_taxonomy.csv>] --out <dir> [--batch 500] [--per-file 50000]'); | |
| 19 | + process.exit(1); | |
| 20 | + } | |
| 21 | + const BATCH = Number(args.batch || 500); | |
| 22 | + const PER_FILE = Number(args['per-file'] || 50000); | |
| 23 | + mkdirSync(args.out, { recursive: true }); | |
| 24 | + | |
| 25 | + function loadNucc(path) { | |
| 26 | + const map = new Map(); | |
| 27 | + if (!path) return map; | |
| 28 | + const lines = readFileSync(path, 'utf8').split(/\r?\n/); | |
| 29 | + const h = parseCsvLine(lines[0]).map((s) => s.trim().replace(/^/, '')); | |
| 30 | + const iCode = h.indexOf('Code'); | |
| 31 | + const iClass = h.indexOf('Classification'); | |
| 32 | + const iSpec = h.indexOf('Specialization'); | |
| 33 | + const iDisp = h.indexOf('Display Name'); | |
| 34 | + for (const line of lines.slice(1)) { | |
| 35 | + if (!line.trim()) continue; | |
| 36 | + const r = parseCsvLine(line); | |
| 37 | + const spec = (r[iSpec] || '').trim(); | |
| 38 | + const cls = (r[iClass] || '').trim(); | |
| 39 | + const name = spec || cls || (iDisp >= 0 ? (r[iDisp] || '').trim() : ''); | |
| 40 | + if (r[iCode]) map.set(r[iCode].trim(), name); | |
| 41 | + } | |
| 42 | + return map; | |
| 43 | + } | |
| 44 | + | |
| 45 | + const titleCase = (s) => | |
| 46 | + (s || '') | |
| 47 | + .toLowerCase() | |
| 48 | + .replace(/(^|[\s\-'’.])([a-z])/g, (m, p, c) => p + c.toUpperCase()) | |
| 49 | + .replace(/\bMc([a-z])/g, (m, c) => 'Mc' + c.toUpperCase()); | |
| 50 | + const sq = (v) => (v === null || v === undefined || v === '' ? 'NULL' : "'" + String(v).replace(/'/g, "''") + "'"); | |
| 51 | + const isoDate = (d) => { | |
| 52 | + const m = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(d || ''); | |
| 53 | + return m ? `${m[3]}-${m[1]}-${m[2]}` : null; | |
| 54 | + }; | |
| 55 | + const zip5 = (z) => (z || '').slice(0, 5) || null; | |
| 56 | + const phone = (p) => { | |
| 57 | + const d = (p || '').replace(/\D/g, ''); | |
| 58 | + return d.length === 10 ? `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}` : null; | |
| 59 | + }; | |
| 60 | + | |
| 61 | + const nucc = loadNucc(args.nucc); | |
| 62 | + const rl = createInterface({ input: createReadStream(args.nppes), crlfDelay: Infinity }); | |
| 63 | + let header = null; | |
| 64 | + let idx = {}; | |
| 65 | + let rows = []; | |
| 66 | + let fileRows = 0; | |
| 67 | + let fileNo = 0; | |
| 68 | + let chunks = []; | |
| 69 | + let total = 0; | |
| 70 | + let seen = 0; | |
| 71 | + | |
| 72 | + function flushFile() { | |
| 73 | + if (!chunks.length) return; | |
| 74 | + const name = join(args.out, `doctors-${String(fileNo).padStart(4, '0')}.sql`); | |
| 75 | + writeFileSync(name, chunks.join('\n') + '\n'); | |
| 76 | + fileNo++; | |
| 77 | + chunks = []; | |
| 78 | + fileRows = 0; | |
| 79 | + } | |
| 80 | + function flushBatch() { | |
| 81 | + if (!rows.length) return; | |
| 82 | + chunks.push( | |
| 83 | + 'INSERT OR REPLACE INTO doctors (npi,name,first_name,middle_name,last_name,suffix,credential,sex,taxonomy,specialty,address,city,state,zip,phone,enumerated,updated) VALUES\n' + | |
| 84 | + rows.join(',\n') + | |
| 85 | + ';' | |
| 86 | + ); | |
| 87 | + fileRows += rows.length; | |
| 88 | + rows = []; | |
| 89 | + if (fileRows >= PER_FILE) flushFile(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + for await (const line of rl) { | |
| 93 | + if (!header) { | |
| 94 | + header = parseCsvLine(line).map((s) => s.replace(/^/, '').trim()); | |
| 95 | + const f = (n) => header.indexOf(n); | |
| 96 | + idx = { | |
| 97 | + npi: f('NPI'), | |
| 98 | + type: f('Entity Type Code'), | |
| 99 | + last: f('Provider Last Name (Legal Name)'), | |
| 100 | + first: f('Provider First Name'), | |
| 101 | + middle: f('Provider Middle Name'), | |
| 102 | + suffix: f('Provider Name Suffix Text'), | |
| 103 | + cred: f('Provider Credential Text'), | |
| 104 | + sex: f('Provider Sex Code') >= 0 ? f('Provider Sex Code') : f('Provider Gender Code'), | |
| 105 | + addr: f('Provider First Line Business Practice Location Address'), | |
| 106 | + city: f('Provider Business Practice Location Address City Name'), | |
| 107 | + state: f('Provider Business Practice Location Address State Name'), | |
| 108 | + zip: f('Provider Business Practice Location Address Postal Code'), | |
| 109 | + tel: f('Provider Business Practice Location Address Telephone Number'), | |
| 110 | + enum: f('Provider Enumeration Date'), | |
| 111 | + upd: f('Last Update Date'), | |
| 112 | + deact: f('NPI Deactivation Date'), | |
| 113 | + react: f('NPI Reactivation Date'), | |
| 114 | + tax: Array.from({ length: 15 }, (_, i) => f(`Healthcare Provider Taxonomy Code_${i + 1}`)), | |
| 115 | + prim: Array.from({ length: 15 }, (_, i) => f(`Healthcare Provider Primary Taxonomy Switch_${i + 1}`)), | |
| 116 | + }; | |
| 117 | + if (idx.npi < 0 || idx.type < 0) throw new Error('Not an NPPES npidata file: header missing NPI / Entity Type Code'); | |
| 118 | + continue; | |
| 119 | + } | |
| 120 | + seen++; | |
| 121 | + const r = parseCsvLine(line); | |
| 122 | + if (r[idx.type] !== '1') continue; | |
| 123 | + if (r[idx.deact] && !(idx.react >= 0 && r[idx.react])) continue; | |
| 124 | + let tax = null; | |
| 125 | + for (let i = 0; i < 15; i++) { | |
| 126 | + const code = r[idx.tax[i]]; | |
| 127 | + if (!code) continue; | |
| 128 | + if (r[idx.prim[i]] === 'Y') { tax = code; break; } | |
| 129 | + if (!tax) tax = code; | |
| 130 | + } | |
| 131 | + if (!tax || !tax.startsWith('20')) continue; | |
| 132 | + const state = (r[idx.state] || '').toUpperCase() || null; | |
| 133 | + const cred = (r[idx.cred] || '').replace(/\./g, '').toUpperCase().trim(); | |
| 134 | + const name = [titleCase(r[idx.first]), titleCase(r[idx.middle]), titleCase(r[idx.last]), r[idx.suffix]] | |
| 135 | + .filter(Boolean).join(' '); | |
| 136 | + rows.push( | |
| 137 | + '(' + | |
| 138 | + [ | |
| 139 | + sq(r[idx.npi]), | |
| 140 | + sq(name), | |
| 141 | + sq(titleCase(r[idx.first])), | |
| 142 | + sq(titleCase(r[idx.middle])), | |
| 143 | + sq(titleCase(r[idx.last])), | |
| 144 | + sq(r[idx.suffix]), | |
| 145 | + sq(cred), | |
| 146 | + sq(r[idx.sex]), | |
| 147 | + sq(tax), | |
| 148 | + sq(nucc.get(tax) || null), | |
| 149 | + sq(titleCase(r[idx.addr])), | |
| 150 | + sq(titleCase(r[idx.city])), | |
| 151 | + sq(state), | |
| 152 | + sq(zip5(r[idx.zip])), | |
| 153 | + sq(phone(r[idx.tel])), | |
| 154 | + sq(isoDate(r[idx.enum])), | |
| 155 | + sq(isoDate(r[idx.upd])), | |
| 156 | + ].join(',') + | |
| 157 | + ')' | |
| 158 | + ); | |
| 159 | + total++; | |
| 160 | + if (rows.length >= BATCH) flushBatch(); | |
| 161 | + if (seen % 500000 === 0) console.error(`read ${seen.toLocaleString()} rows, kept ${total.toLocaleString()}`); | |
| 162 | + } | |
| 163 | + flushBatch(); | |
| 164 | + flushFile(); | |
| 165 | + writeFileSync( | |
| 166 | + join(args.out, `zz-fts.sql`), | |
| 167 | + "INSERT INTO doctors_fts(doctors_fts) VALUES('rebuild');\n" | |
| 168 | + ); | |
| 169 | + console.error(`done: read ${seen.toLocaleString()}, kept ${total.toLocaleString()} physicians in ${fileNo} files`); |
tools/load-d1.sh added
| 1 | + #!/usr/bin/env bash | |
| 2 | + # Loads every SQL file from tools/import-nppes.mjs into D1, in order. | |
| 3 | + # Usage: tools/load-d1.sh <dir> [--remote|--local] | |
| 4 | + set -euo pipefail | |
| 5 | + dir="$1"; where="${2:---remote}" | |
| 6 | + for f in "$dir"/*.sql; do | |
| 7 | + echo "loading $f" | |
| 8 | + for attempt in 1 2 3 4; do | |
| 9 | + if npx wrangler d1 execute docley-db "$where" --yes --file "$f" >/dev/null; then break; fi | |
| 10 | + echo "retry $attempt for $f"; sleep $((attempt * 10)) | |
| 11 | + done | |
| 12 | + done |
tools/refresh.sh added
| 1 | + #!/usr/bin/env bash | |
| 2 | + # Downloads the newest official files and reloads Docley's D1 database. | |
| 3 | + # NPPES full file (CMS): https://download.cms.gov/nppes/NPI_Files.html | |
| 4 | + # NUCC taxonomy names: https://www.nucc.org (Provider Taxonomy, CSV) | |
| 5 | + # HHS-OIG LEIE exclusions: https://oig.hhs.gov/exclusions/exclusions_list.asp | |
| 6 | + # Usage: tools/refresh.sh [work dir, default /Volumes/Expand/Projects/Docley/data] [--remote|--local] | |
| 7 | + set -euo pipefail | |
| 8 | + cd "$(dirname "$0")/.." | |
| 9 | + work="${1:-/Volumes/Expand/Projects/Docley/data}"; where="${2:---remote}" | |
| 10 | + mkdir -p "$work"; cd_repo="$PWD" | |
| 11 | + ua="Mozilla/5.0 (Docley data refresh)" | |
| 12 | + | |
| 13 | + nppes_url=$(curl -fsSL -A "$ua" https://download.cms.gov/nppes/NPI_Files.html | grep -oE 'https?://download\.cms\.gov/nppes/NPPES_Data_Dissemination_[A-Za-z]+_[0-9]{4}(_V2)?\.zip' | head -1) | |
| 14 | + [ -n "$nppes_url" ] || nppes_url="https://download.cms.gov/nppes/$(curl -fsSL -A "$ua" https://download.cms.gov/nppes/NPI_Files.html | grep -oE 'NPPES_Data_Dissemination_[A-Za-z]+_[0-9]{4}(_V2)?\.zip' | head -1)" | |
| 15 | + echo "NPPES: $nppes_url" | |
| 16 | + zip="$work/$(basename "$nppes_url")" | |
| 17 | + [ -f "$zip" ] || curl -fL -A "$ua" -o "$zip" "$nppes_url" | |
| 18 | + csv=$(unzip -Z1 "$zip" | grep -E '^npidata_pfile_[0-9-]+\.csv$' | head -1) | |
| 19 | + [ -f "$work/$csv" ] || unzip -o "$zip" "$csv" -d "$work" | |
| 20 | + | |
| 21 | + nucc_page=$(curl -fsSL -A "$ua" "https://www.nucc.org/index.php/code-sets-mainmenu-41/provider-taxonomy-mainmenu-40/csv-mainmenu-57") | |
| 22 | + nucc_path=$(echo "$nucc_page" | grep -oE '/images/stories/CSV/nucc_taxonomy_[0-9]+\.csv' | head -1) | |
| 23 | + curl -fsSL -A "$ua" -o "$work/nucc.csv" "https://www.nucc.org$nucc_path" | |
| 24 | + curl -fsSL -A "$ua" -o "$work/leie.csv" "https://oig.hhs.gov/exclusions/downloadables/UPDATED.csv" | |
| 25 | + | |
| 26 | + rm -rf "$work/sql" | |
| 27 | + node tools/import-nppes.mjs --nppes "$work/$csv" --nucc "$work/nucc.csv" --out "$work/sql" | |
| 28 | + node tools/import-leie.mjs --leie "$work/leie.csv" --out "$work/sql" | |
| 29 | + tools/load-d1.sh "$work/sql" "$where" | |
| 30 | + echo "Docley data refreshed from $nppes_url" |
wrangler.jsonc added
| 1 | + { | |
| 2 | + "$schema": "node_modules/wrangler/config-schema.json", | |
| 3 | + "name": "docley", | |
| 4 | + "main": "src/index.js", | |
| 5 | + "compatibility_date": "2026-11-01", | |
| 6 | + "routes": [{ "pattern": "doctors.projectatom.ai", "custom_domain": true }], | |
| 7 | + "d1_databases": [ | |
| 8 | + { | |
| 9 | + "binding": "DB", | |
| 10 | + "database_name": "docley-db", | |
| 11 | + "database_id": "REPLACE_WITH_D1_ID", | |
| 12 | + "migrations_dir": "migrations" | |
| 13 | + } | |
| 14 | + ], | |
| 15 | + "vars": { | |
| 16 | + "SITE_URL": "https://doctors.projectatom.ai", | |
| 17 | + "RATINGS_OPEN": "false" | |
| 18 | + }, | |
| 19 | + "ai": { "binding": "AI" }, | |
| 20 | + "observability": { "enabled": true } | |
| 21 | + } |