@synopackageland/cli 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/build-spk/generator.js +3 -0
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +9 -2
- package/dist/error-registry.js +20 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.js +20 -12
- package/dist/standalone/build.js +3 -1
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +1 -1
- package/dist/standalone/dsm-window.js +50 -10
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +2 -12
- package/dist/standalone/helper.js +8 -7
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +2 -0
- package/dist/standalone/inspect-spk.js +49 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +4 -1
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.js +9 -0
- package/dist/standalone/root-window.d.ts +4 -3
- package/dist/standalone/root-window.js +17 -5
- package/dist/standalone/spk.d.ts +4 -3
- package/dist/standalone/spk.js +20 -33
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/native-go/README.md +57 -1
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/go.mod +4 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
- package/dist/templates/native-go/backend/internal/api/server.go +4 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
- package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
- package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/ui/app.js +8 -1
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-vue/README.md +115 -1
- package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
- package/package.json +3 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/native-go/README.md +57 -1
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/go.mod +4 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/registry.go +14 -4
- package/templates/native-go/backend/internal/api/server.go +4 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/routes.go +11 -0
- package/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +226 -21
- package/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/templates/native-go/backend/internal/helper/status.go +74 -11
- package/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/ui/app.js +8 -1
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-vue/README.md +115 -1
- package/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +17 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/templates/native-go-vue/frontend/vite.config.ts +6 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Use fixture authority only as a canary for mutation. The services under test
|
|
10
|
+
// are the exact shipped assembly: no native/consent/operation/output adapter.
|
|
11
|
+
func TestS8ShippedAssemblyRefusesWithoutNativeActorOrChildren(t *testing.T) {
|
|
12
|
+
for _, user := range []string{"normal1", "normal2", "admin"} {
|
|
13
|
+
s, repo, cohort, _, grant, children := grantCohortFixture(t)
|
|
14
|
+
services := supervisorGrantAdapters(Client{})
|
|
15
|
+
if services.native != nil || services.consent != nil || services.operations != nil || services.output != nil {
|
|
16
|
+
t.Fatal("production installed an adapter")
|
|
17
|
+
}
|
|
18
|
+
s.services = services
|
|
19
|
+
s.authority.native = services.native
|
|
20
|
+
s.authority.consent = services.consent
|
|
21
|
+
before, _ := json.Marshal(repo.store)
|
|
22
|
+
commits := repo.commits
|
|
23
|
+
carriers := SessionCarriers{Cookie: user, SynoToken: "untrusted", ClientAddress: "127.0.0.1"}
|
|
24
|
+
if _, code := services.native.Resolve(context.Background(), carriers); code != ErrUnavailable {
|
|
25
|
+
t.Fatal("missing native actor", code)
|
|
26
|
+
}
|
|
27
|
+
for _, kind := range []ScopeKind{ScopePersonal, ScopeShared} {
|
|
28
|
+
if anchors, code := services.native.Discover(context.Background(), carriers, nil, kind, 1); code != ErrUnavailable || len(anchors) != 0 {
|
|
29
|
+
t.Fatal("native discovery", code, anchors)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
cases := []struct {
|
|
33
|
+
method string
|
|
34
|
+
args any
|
|
35
|
+
}{
|
|
36
|
+
{"prepare", grantPrepareArgs{grantRef('c'), ScopePersonal, []Action{ActionRead}}},
|
|
37
|
+
{"prepare", grantPrepareArgs{grantRef('c'), ScopeShared, []Action{ActionRead}}},
|
|
38
|
+
{"confirm", grantConfirmArgs{grantRef('c'), grantRef('d'), repo.store.Revision}},
|
|
39
|
+
}
|
|
40
|
+
for n, c := range cases {
|
|
41
|
+
res := s.dispatch(context.Background(), operationPeer{42, 0}, grantRef(byte('a'+n)), grantRPC(t, c.method, cohort.epoch, carriers, c.args))
|
|
42
|
+
want := ErrUnavailable
|
|
43
|
+
if c.method == "confirm" {
|
|
44
|
+
want = ErrReplay
|
|
45
|
+
} // No known intent; retain the safe replay distinction.
|
|
46
|
+
if res.Code != want || res.Grant != nil || res.Intent != nil || res.Files != nil {
|
|
47
|
+
t.Fatal(user, c.method, res)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for n, action := range []Action{ActionStat, ActionList, ActionRead, ActionReadStream, ActionCreate, ActionWriteStream, ActionPublish} {
|
|
51
|
+
req := grantControl(t, grant, '1', byte('1'+n), '3', 1)
|
|
52
|
+
req.Op = action
|
|
53
|
+
args := any(ReadArgs{Segments: []string{"fixture"}, MaxBytes: 1})
|
|
54
|
+
switch action {
|
|
55
|
+
case ActionStat:
|
|
56
|
+
args = StatArgs{Segments: []string{"fixture"}}
|
|
57
|
+
case ActionList:
|
|
58
|
+
args = ListArgs{Segments: []string{"fixture"}, Limit: 1}
|
|
59
|
+
case ActionCreate:
|
|
60
|
+
args = CreateArgs{Segments: []string{"fixture"}, Bytes: 1, Exclusive: true}
|
|
61
|
+
case ActionWriteStream:
|
|
62
|
+
args = WriteStreamArgs{Segments: []string{"fixture"}, MaxBytes: 1}
|
|
63
|
+
case ActionPublish:
|
|
64
|
+
args = PublishArgs{StageID: grantRef('c'), NoOverwrite: true}
|
|
65
|
+
}
|
|
66
|
+
req.Args, _ = json.Marshal(args)
|
|
67
|
+
// Implemented reads require a native actor; staged writes remain unsupported.
|
|
68
|
+
// Neither failure may bootstrap a child or mutate authority.
|
|
69
|
+
res := s.dispatch(context.Background(), operationPeer{42, 0}, grantRef(byte('1'+n)), grantRPC(t, "operation.start", cohort.epoch, carriers, req))
|
|
70
|
+
if (action.ReadOnly() && res.Code != ErrUnavailable) || (!action.ReadOnly() && res.Code != ErrUnsupported) || res.Files != nil || res.Grant != nil {
|
|
71
|
+
t.Fatal(user, action, res)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
after, _ := json.Marshal(repo.store)
|
|
75
|
+
if string(before) != string(after) || repo.commits != commits || len(*children) != 0 || len(cohort.operations) != 0 {
|
|
76
|
+
t.Fatal("refusal mutated grant or started child")
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func TestS1RShippedModeStillRefusesUncertifiedDSMAdapters(t *testing.T) {
|
|
82
|
+
i := Inventory{Package: "Fixture", Version: "1.0.0-0001", Protocol: DataProtocol, PayloadDigest: grantRef('a'), RegistryDigest: grantRef('b'), DataAccess: "relaxed"}
|
|
83
|
+
services := supervisorGrantAdapters(NewClient(i))
|
|
84
|
+
if services.native == nil || services.native.relaxed == nil {
|
|
85
|
+
t.Fatal("relaxed policy was not selected")
|
|
86
|
+
}
|
|
87
|
+
if actor, code := services.native.Resolve(context.Background(), SessionCarriers{}); code != ErrUnavailable || actor.valid {
|
|
88
|
+
t.Fatal("unproved adapter minted actor", code)
|
|
89
|
+
}
|
|
90
|
+
if services.consent != nil || services.operations != nil || services.output != nil || services.writes.Create || services.writes.Stream || services.writes.Publish {
|
|
91
|
+
t.Fatal("relaxed mode enabled uncertified data/write capability")
|
|
92
|
+
}
|
|
93
|
+
i.DataAccess = ""
|
|
94
|
+
if supervisorGrantAdapters(NewClient(i)).native != nil {
|
|
95
|
+
t.Fatal("default policy silently enabled relaxed")
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"slices"
|
|
7
|
+
"strings"
|
|
8
|
+
"unicode"
|
|
9
|
+
"unicode/utf8"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Discover returns bounded metadata only. Fresh native checks bracket discovery;
|
|
13
|
+
// no result is returned if the actor changed while the adapter was running.
|
|
14
|
+
// This is not a cursor/intent/grant store or a filesystem resolver.
|
|
15
|
+
func (p *NativeProvider) Discover(ctx context.Context, carriers SessionCarriers, adapter NativeDiscoveryAdapter, kind ScopeKind, limit int) ([]DiscoveryAnchor, Code) {
|
|
16
|
+
if kind != ScopePersonal && kind != ScopeShared {
|
|
17
|
+
return nil, ErrUnsupported
|
|
18
|
+
}
|
|
19
|
+
if limit < 1 || limit > MaxPageEntries {
|
|
20
|
+
return nil, ErrLimit
|
|
21
|
+
}
|
|
22
|
+
if adapter == nil {
|
|
23
|
+
return nil, ErrUnavailable
|
|
24
|
+
}
|
|
25
|
+
ctx, cancel := context.WithTimeout(ctx, MetadataTimeout)
|
|
26
|
+
defer cancel()
|
|
27
|
+
actor, c := p.Resolve(ctx, carriers)
|
|
28
|
+
if c != "" {
|
|
29
|
+
return nil, c
|
|
30
|
+
}
|
|
31
|
+
observation, c := adapter.DiscoverAnchors(ctx, actor, kind, limit)
|
|
32
|
+
if c = nativeObservationCode(ctx, c); c != "" {
|
|
33
|
+
return nil, c
|
|
34
|
+
}
|
|
35
|
+
current, c := p.Revalidate(ctx, carriers, actor)
|
|
36
|
+
if c != "" {
|
|
37
|
+
return nil, c
|
|
38
|
+
}
|
|
39
|
+
if observation.Principal != current.Principal() || observation.SessionRef != current.SessionRef() {
|
|
40
|
+
return nil, ErrDenied
|
|
41
|
+
}
|
|
42
|
+
if !nativeFresh(observation.CheckedAt, p.now()) {
|
|
43
|
+
return nil, ErrStale
|
|
44
|
+
}
|
|
45
|
+
if observation.Anchors == nil {
|
|
46
|
+
return nil, ErrUnavailable
|
|
47
|
+
}
|
|
48
|
+
if len(observation.Anchors) > limit {
|
|
49
|
+
return nil, ErrLimit
|
|
50
|
+
}
|
|
51
|
+
if kind == ScopePersonal && len(observation.Anchors) > 1 {
|
|
52
|
+
return nil, ErrUnavailable
|
|
53
|
+
}
|
|
54
|
+
seen := make(map[string]bool, len(observation.Anchors))
|
|
55
|
+
for _, anchor := range observation.Anchors {
|
|
56
|
+
if anchor.Kind != kind || (kind == ScopePersonal && anchor.Owner != current.Principal()) || (kind == ScopeShared && anchor.Owner != (Principal{})) {
|
|
57
|
+
return nil, ErrDenied
|
|
58
|
+
}
|
|
59
|
+
if !anchor.LocalFilesystem {
|
|
60
|
+
return nil, ErrUnsupported
|
|
61
|
+
}
|
|
62
|
+
if !digestPattern.MatchString(anchor.Ref) || seen[anchor.Ref] || !nativeDisplayName(anchor.DisplayName) {
|
|
63
|
+
return nil, ErrUnavailable
|
|
64
|
+
}
|
|
65
|
+
seen[anchor.Ref] = true
|
|
66
|
+
}
|
|
67
|
+
encoded, err := json.Marshal(observation.Anchors)
|
|
68
|
+
if err != nil {
|
|
69
|
+
return nil, ErrUnavailable
|
|
70
|
+
}
|
|
71
|
+
if len(encoded) > MaxMetadataBytes {
|
|
72
|
+
return nil, ErrLimit
|
|
73
|
+
}
|
|
74
|
+
return slices.Clone(observation.Anchors), ""
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func nativeDisplayName(name string) bool {
|
|
78
|
+
return name != "" && len(name) <= MaxSegmentBytes && utf8.ValidString(name) && !strings.ContainsAny(name, "/\\") && !strings.ContainsFunc(name, unicode.IsControl)
|
|
79
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"time"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// S1 contracts are staged: no provider is installed in the helper or CGI.
|
|
9
|
+
// Implementations are trusted root-side adapters, never package-supplied claims.
|
|
10
|
+
// They must obey ctx and return only closed safe codes, not native diagnostics.
|
|
11
|
+
|
|
12
|
+
// SessionCarriers are transient secrets, not identity. The transport must derive
|
|
13
|
+
// ClientAddress from its trusted peer/proxy policy. Never persist or log these.
|
|
14
|
+
type SessionCarriers struct {
|
|
15
|
+
Cookie string `json:"-"`
|
|
16
|
+
SynoToken string `json:"-"`
|
|
17
|
+
ClientAddress string `json:"-"`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// NativeSessionValidator must revalidate the native session on EVERY call.
|
|
21
|
+
// AccountInstanceRef must prove that this session belongs to the current account
|
|
22
|
+
// incarnation; a username from authenticate.cgi alone cannot supply that proof.
|
|
23
|
+
type NativeSessionValidator interface {
|
|
24
|
+
ValidateSession(context.Context, SessionCarriers) (NativeSession, Code)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type NativeSession struct {
|
|
28
|
+
Username string
|
|
29
|
+
SessionRef string // opaque server-side session binding, not a cookie hash
|
|
30
|
+
AccountInstanceRef string // proven incarnation, never a name/UID fingerprint
|
|
31
|
+
CheckedAt time.Time
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// LocalAccountProvider resolves a validated native username against the current
|
|
35
|
+
// LOCAL account database. It must prove existence, enabled status, incarnation,
|
|
36
|
+
// complete groups and current admin role in a coherent fresh observation.
|
|
37
|
+
// Unknown incarnation is represented by an empty InstanceRef, not an invented ID.
|
|
38
|
+
type LocalAccountProvider interface {
|
|
39
|
+
LookupLocalAccount(context.Context, string) (LocalAccount, Code)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type LocalAccount struct {
|
|
43
|
+
Principal Principal
|
|
44
|
+
Username string
|
|
45
|
+
Enabled bool
|
|
46
|
+
UID uint32
|
|
47
|
+
GID uint32
|
|
48
|
+
Groups []uint32 // complete supplementary groups; nil means unknown
|
|
49
|
+
Admin bool // current native role, not UID==0 or a caller flag
|
|
50
|
+
CheckedAt time.Time
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// NativeActor is an in-memory, read-only snapshot minted only by NativeProvider.
|
|
54
|
+
// IdentityBasis distinguishes strict S1 from an explicit managed enrollment;
|
|
55
|
+
// neither consumer nor serializer may reinterpret the latter as incarnation.
|
|
56
|
+
// Zero values and serialized/restored snapshots are never admission authority.
|
|
57
|
+
// S2 must revalidate before admitting work and own invalidation/cancel ordering.
|
|
58
|
+
type NativeActor struct {
|
|
59
|
+
managed *managedPilot
|
|
60
|
+
relaxed *relaxedProvider
|
|
61
|
+
account LocalAccount
|
|
62
|
+
sessionRef string
|
|
63
|
+
valid bool
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// NativeDiscoveryAdapter only discovers actor-visible local share anchors or
|
|
67
|
+
// this actor's own home. It must enforce native visibility before returning any
|
|
68
|
+
// metadata, never run discovery as admin on behalf of an ordinary actor, and
|
|
69
|
+
// never open data files. Discovery is neither a grant nor an ACL/scope proof.
|
|
70
|
+
type NativeDiscoveryAdapter interface {
|
|
71
|
+
DiscoverAnchors(context.Context, NativeActor, ScopeKind, int) (DiscoveryObservation, Code)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type DiscoveryObservation struct {
|
|
75
|
+
Principal Principal
|
|
76
|
+
SessionRef string
|
|
77
|
+
CheckedAt time.Time
|
|
78
|
+
Anchors []DiscoveryAnchor // explicit empty slice means no visible anchors
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// An anchor is a display candidate, not an absolute path or bearer authority.
|
|
82
|
+
// Personal Owner must equal the actor; shared discovery carries no grant issuer.
|
|
83
|
+
type DiscoveryAnchor struct {
|
|
84
|
+
Ref string `json:"ref"`
|
|
85
|
+
DisplayName string `json:"displayName"`
|
|
86
|
+
Kind ScopeKind `json:"kind"`
|
|
87
|
+
Owner Principal `json:"owner"`
|
|
88
|
+
LocalFilesystem bool `json:"localFilesystem"`
|
|
89
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"slices"
|
|
6
|
+
"strings"
|
|
7
|
+
"time"
|
|
8
|
+
"unicode/utf8"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
type NativeProvider struct {
|
|
12
|
+
managed *managedPilot
|
|
13
|
+
relaxed *relaxedProvider
|
|
14
|
+
sessions NativeSessionValidator
|
|
15
|
+
accounts LocalAccountProvider
|
|
16
|
+
now func() time.Time
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func NewNativeProvider(s NativeSessionValidator, a LocalAccountProvider) *NativeProvider {
|
|
20
|
+
return &NativeProvider{sessions: s, accounts: a, now: time.Now}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func (a NativeActor) Principal() Principal { return a.account.Principal }
|
|
24
|
+
func (a NativeActor) Username() string { return a.account.Username }
|
|
25
|
+
func (a NativeActor) SessionRef() string { return a.sessionRef }
|
|
26
|
+
func (a NativeActor) UID() uint32 { return a.account.UID }
|
|
27
|
+
func (a NativeActor) GID() uint32 { return a.account.GID }
|
|
28
|
+
func (a NativeActor) Groups() []uint32 { return slices.Clone(a.account.Groups) }
|
|
29
|
+
func (a NativeActor) Admin() bool { return a.valid && a.account.Admin }
|
|
30
|
+
|
|
31
|
+
// Resolve performs fresh observations; it never caches sessions or credentials.
|
|
32
|
+
// Success is only an identity snapshot, not file/grant/lifecycle admission.
|
|
33
|
+
func (p *NativeProvider) Resolve(ctx context.Context, carriers SessionCarriers) (NativeActor, Code) {
|
|
34
|
+
if p != nil && p.relaxed != nil {
|
|
35
|
+
if p.now == nil {
|
|
36
|
+
return NativeActor{}, ErrUnavailable
|
|
37
|
+
}
|
|
38
|
+
return p.relaxed.resolve(ctx, carriers, func() time.Time { return p.now() })
|
|
39
|
+
}
|
|
40
|
+
if p != nil && p.managed != nil {
|
|
41
|
+
return p.managed.resolve(ctx, carriers)
|
|
42
|
+
}
|
|
43
|
+
if p == nil || p.sessions == nil || p.accounts == nil || p.now == nil {
|
|
44
|
+
return NativeActor{}, ErrUnavailable
|
|
45
|
+
}
|
|
46
|
+
ctx, cancel := context.WithTimeout(ctx, NativeProofFreshness)
|
|
47
|
+
defer cancel()
|
|
48
|
+
if c := nativeContextCode(ctx); c != "" {
|
|
49
|
+
return NativeActor{}, c
|
|
50
|
+
}
|
|
51
|
+
if carriers.Cookie == "" {
|
|
52
|
+
return NativeActor{}, ErrDenied
|
|
53
|
+
}
|
|
54
|
+
s, c := p.sessions.ValidateSession(ctx, carriers)
|
|
55
|
+
if c = nativeObservationCode(ctx, c); c != "" {
|
|
56
|
+
return NativeActor{}, c
|
|
57
|
+
}
|
|
58
|
+
if s.Username == "" || !utf8.ValidString(s.Username) || strings.ContainsAny(s.Username, "\x00\r\n") || !digestPattern.MatchString(s.SessionRef) {
|
|
59
|
+
return NativeActor{}, ErrUnavailable
|
|
60
|
+
}
|
|
61
|
+
if s.AccountInstanceRef == "" {
|
|
62
|
+
return NativeActor{}, ErrSuspended
|
|
63
|
+
}
|
|
64
|
+
if !digestPattern.MatchString(s.AccountInstanceRef) {
|
|
65
|
+
return NativeActor{}, ErrUnavailable
|
|
66
|
+
}
|
|
67
|
+
if !nativeFresh(s.CheckedAt, p.now()) {
|
|
68
|
+
return NativeActor{}, ErrStale
|
|
69
|
+
}
|
|
70
|
+
a, c := p.accounts.LookupLocalAccount(ctx, s.Username)
|
|
71
|
+
if c = nativeObservationCode(ctx, c); c != "" {
|
|
72
|
+
return NativeActor{}, c
|
|
73
|
+
}
|
|
74
|
+
if a.Principal.Kind != "local" {
|
|
75
|
+
return NativeActor{}, ErrUnsupported
|
|
76
|
+
}
|
|
77
|
+
if !a.Enabled || a.Username != s.Username {
|
|
78
|
+
return NativeActor{}, ErrDenied
|
|
79
|
+
}
|
|
80
|
+
if a.Principal.InstanceRef == "" {
|
|
81
|
+
return NativeActor{}, ErrSuspended
|
|
82
|
+
}
|
|
83
|
+
if !digestPattern.MatchString(a.Principal.SubjectRef) || !digestPattern.MatchString(a.Principal.InstanceRef) || a.Groups == nil {
|
|
84
|
+
return NativeActor{}, ErrUnavailable
|
|
85
|
+
}
|
|
86
|
+
if a.Principal.InstanceRef != s.AccountInstanceRef {
|
|
87
|
+
return NativeActor{}, ErrSuspended
|
|
88
|
+
}
|
|
89
|
+
now := p.now()
|
|
90
|
+
if !nativeFresh(s.CheckedAt, now) || !nativeFresh(a.CheckedAt, now) {
|
|
91
|
+
return NativeActor{}, ErrStale
|
|
92
|
+
}
|
|
93
|
+
// Group order and duplicates do not change the credential set. Own the slice
|
|
94
|
+
// so neither a provider nor a consumer can mutate the admitted snapshot.
|
|
95
|
+
a.Groups = slices.Clone(a.Groups)
|
|
96
|
+
slices.Sort(a.Groups)
|
|
97
|
+
a.Groups = slices.Compact(a.Groups)
|
|
98
|
+
// Carry the oldest subject observation into later chunk deadlines. A newer
|
|
99
|
+
// account lookup must not extend an older native-session proof.
|
|
100
|
+
if s.CheckedAt.Before(a.CheckedAt) {
|
|
101
|
+
a.CheckedAt = s.CheckedAt
|
|
102
|
+
}
|
|
103
|
+
return NativeActor{account: a, sessionRef: s.SessionRef, valid: true}, ""
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Revalidate refuses old in-flight credentials after any identity/role change.
|
|
107
|
+
// A caller may Resolve a new snapshot after stale; it must redo ACL/admission.
|
|
108
|
+
// Suspension requires new consent, not replacement of the old grant's owner.
|
|
109
|
+
func (p *NativeProvider) Revalidate(ctx context.Context, carriers SessionCarriers, old NativeActor) (NativeActor, Code) {
|
|
110
|
+
if !old.valid {
|
|
111
|
+
return NativeActor{}, ErrDenied
|
|
112
|
+
}
|
|
113
|
+
if p != nil && p.relaxed != nil {
|
|
114
|
+
if p.now == nil {
|
|
115
|
+
return NativeActor{}, ErrUnavailable
|
|
116
|
+
}
|
|
117
|
+
return p.relaxed.revalidate(ctx, carriers, old, func() time.Time { return p.now() })
|
|
118
|
+
}
|
|
119
|
+
if p == nil || old.managed != p.managed {
|
|
120
|
+
return NativeActor{}, ErrSuspended
|
|
121
|
+
}
|
|
122
|
+
current, c := p.Resolve(ctx, carriers)
|
|
123
|
+
if c != "" {
|
|
124
|
+
return NativeActor{}, c
|
|
125
|
+
}
|
|
126
|
+
a, b := old.account, current.account
|
|
127
|
+
if a.Principal != b.Principal || a.Username != b.Username || a.UID != b.UID || a.GID != b.GID {
|
|
128
|
+
return NativeActor{}, ErrSuspended
|
|
129
|
+
}
|
|
130
|
+
if old.sessionRef != current.sessionRef || a.Admin != b.Admin || !slices.Equal(a.Groups, b.Groups) {
|
|
131
|
+
return NativeActor{}, ErrStale
|
|
132
|
+
}
|
|
133
|
+
return current, ""
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
func nativeFresh(checkedAt, now time.Time) bool {
|
|
137
|
+
return !checkedAt.IsZero() && !now.IsZero() && !checkedAt.After(now) && now.Sub(checkedAt) <= NativeProofFreshness
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
func nativeContextCode(ctx context.Context) Code {
|
|
141
|
+
switch ctx.Err() {
|
|
142
|
+
case context.Canceled:
|
|
143
|
+
return ErrCanceled
|
|
144
|
+
case context.DeadlineExceeded:
|
|
145
|
+
return ErrTimeout
|
|
146
|
+
default:
|
|
147
|
+
return ""
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
func nativeObservationCode(ctx context.Context, code Code) Code {
|
|
152
|
+
if c := nativeContextCode(ctx); c != "" {
|
|
153
|
+
return c
|
|
154
|
+
}
|
|
155
|
+
if code != "" && !code.Valid() {
|
|
156
|
+
return ErrUnavailable
|
|
157
|
+
}
|
|
158
|
+
return code
|
|
159
|
+
}
|