@synopackageland/cli 0.4.1 → 0.5.3
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/README.md +7 -3
- package/dist/authorization-sdk.d.ts +5 -0
- package/dist/authorization-sdk.js +5 -0
- package/dist/build-spk/delete-app-data.d.ts +27 -7
- package/dist/build-spk/delete-app-data.js +35 -34
- package/dist/build-spk/dsm-arch.d.ts +6 -1
- package/dist/build-spk/dsm-arch.js +25 -1
- package/dist/build-spk/dsm-version.d.ts +14 -0
- package/dist/build-spk/dsm-version.js +47 -0
- package/dist/build-spk/gateway.d.ts +31 -0
- package/dist/build-spk/gateway.js +55 -0
- package/dist/build-spk/generator.d.ts +5 -0
- package/dist/build-spk/generator.js +103 -107
- package/dist/build-spk/install-wizard.d.ts +20 -0
- package/dist/build-spk/install-wizard.js +76 -0
- package/dist/build-spk/native-lifecycle.d.ts +5 -0
- package/dist/build-spk/native-lifecycle.js +12 -2
- package/dist/build-spk/resource-worker.d.ts +9 -4
- package/dist/build-spk/resource-worker.js +15 -6
- package/dist/build-spk/share-combobox.d.ts +3 -0
- package/dist/build-spk/share-combobox.js +27 -0
- package/dist/build-spk/uninstall-wizard.d.ts +14 -0
- package/dist/build-spk/uninstall-wizard.js +33 -0
- package/dist/build-spk/wizard-i18n.d.ts +18 -0
- package/dist/build-spk/wizard-i18n.js +38 -0
- package/dist/build-spk/wizard-messages.d.ts +388 -0
- package/dist/build-spk/wizard-messages.js +387 -0
- package/dist/cli.js +132 -32
- package/dist/compose/analyze.d.ts +20 -0
- package/dist/compose/analyze.js +75 -11
- package/dist/contract/validate.js +33 -1
- package/dist/contract/web-launch.d.ts +22 -0
- package/dist/contract/web-launch.js +37 -0
- package/dist/deploy/deploy.d.ts +3 -0
- package/dist/deploy/deploy.js +11 -2
- package/dist/error-registry.js +62 -3
- package/dist/host/dsm-port-profile.d.ts +1 -1
- package/dist/host/dsm-port-profile.js +1 -1
- package/dist/host/open-url.d.ts +2 -0
- package/dist/host/open-url.js +4 -1
- package/dist/images/pin.d.ts +52 -0
- package/dist/images/pin.js +249 -0
- package/dist/init.d.ts +27 -3
- package/dist/init.js +126 -16
- package/dist/inspect.d.ts +3 -0
- package/dist/inspect.js +15 -3
- package/dist/standalone/authorization-window.d.ts +2 -0
- package/dist/standalone/authorization-window.js +28 -0
- package/dist/standalone/authorization.d.ts +48 -0
- package/dist/standalone/authorization.js +116 -0
- package/dist/standalone/background.d.ts +21 -0
- package/dist/standalone/background.js +52 -0
- package/dist/standalone/binary.d.ts +1 -0
- package/dist/standalone/binary.js +1 -1
- package/dist/standalone/build.d.ts +2 -0
- package/dist/standalone/build.js +54 -10
- package/dist/standalone/dsm-window.js +10 -3
- package/dist/standalone/helper-inventory.d.ts +15 -0
- package/dist/standalone/helper-inventory.js +9 -0
- package/dist/standalone/helper.d.ts +1 -0
- package/dist/standalone/helper.js +29 -11
- package/dist/standalone/host-adapter.d.ts +1 -1
- package/dist/standalone/host-adapter.js +33 -15
- package/dist/standalone/host-file-navigation.d.ts +7 -0
- package/dist/standalone/host-file-navigation.js +172 -0
- package/dist/standalone/inspect-helper.js +21 -6
- package/dist/standalone/inspect-spk.d.ts +1 -1
- package/dist/standalone/inspect-spk.js +211 -7
- package/dist/standalone/job-diagnostics.d.ts +1 -0
- package/dist/standalone/job-diagnostics.js +49 -0
- package/dist/standalone/lifecycle-helper.d.ts +1 -1
- package/dist/standalone/lifecycle-helper.js +2 -2
- package/dist/standalone/lifecycle.d.ts +1 -1
- package/dist/standalone/lifecycle.js +14 -4
- package/dist/standalone/manifest.d.ts +15 -2
- package/dist/standalone/manifest.js +37 -6
- package/dist/standalone/native-layout.d.ts +74 -0
- package/dist/standalone/native-layout.js +318 -0
- package/dist/standalone/resource.d.ts +11 -0
- package/dist/standalone/resource.js +13 -0
- package/dist/standalone/root-ops.d.ts +2 -0
- package/dist/standalone/root-ops.js +10 -0
- package/dist/standalone/root-window.d.ts +3 -1
- package/dist/standalone/root-window.js +156 -38
- package/dist/standalone/shared-folder.d.ts +39 -0
- package/dist/standalone/shared-folder.js +141 -0
- package/dist/standalone/spk.d.ts +4 -0
- package/dist/standalone/spk.js +47 -3
- package/dist/standalone/worker-contract-json.d.ts +8 -0
- package/dist/standalone/worker-contract-json.js +141 -0
- package/dist/standalone/worker-contract.d.ts +189 -0
- package/dist/standalone/worker-contract.js +175 -0
- package/dist/standalone/worker-registry.d.ts +40 -0
- package/dist/standalone/worker-registry.js +167 -0
- package/dist/templates/_authorization/main.go +104 -0
- package/dist/templates/_authorization/main_test.go +35 -0
- package/dist/templates/_daemon/go.mod +2 -0
- package/dist/templates/_gateway/auth.go +101 -0
- package/dist/templates/_gateway/auth_test.go +216 -0
- package/dist/templates/_gateway/cgi.go +133 -0
- package/dist/templates/_gateway/cgi_test.go +156 -0
- package/dist/templates/_gateway/csrf.go +73 -0
- package/dist/templates/_gateway/csrf_test.go +155 -0
- package/dist/templates/_gateway/directory.go +108 -0
- package/dist/templates/_gateway/directory_test.go +202 -0
- package/dist/templates/_gateway/gateway.go +412 -0
- package/dist/templates/_gateway/gateway_test.go +676 -0
- package/dist/templates/_gateway/go.mod +3 -0
- package/dist/templates/_gateway/groups.go +66 -0
- package/dist/templates/_gateway/main.go +45 -0
- package/dist/templates/binary/synology-app.yaml +1 -1
- package/dist/templates/compose-import/compose.yaml +1 -1
- package/dist/templates/compose-import/synology-app.yaml +1 -1
- package/dist/templates/hello-files/compose.yaml +1 -1
- package/dist/templates/hello-files/synology-app.yaml +1 -1
- package/dist/templates/native-go/README.md +118 -5
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/dist/templates/native-go/backend/cmd/app/main.go +25 -6
- package/dist/templates/native-go/backend/cmd/app/sdk_main.go +62 -0
- package/dist/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +27 -1
- package/dist/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/dist/templates/native-go/backend/go.mod +5 -3
- package/dist/templates/native-go/backend/go.sum +4 -4
- package/dist/templates/native-go/backend/internal/api/registry.go +17 -6
- package/dist/templates/native-go/backend/internal/api/server.go +7 -1
- package/dist/templates/native-go/backend/internal/app/authorization_none.go +5 -0
- package/dist/templates/native-go/backend/internal/app/background.go +270 -0
- package/dist/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/dist/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/dist/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/dist/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/dist/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/dist/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/dist/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +22 -5
- package/dist/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/dist/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/dist/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/dist/templates/native-go/backend/internal/app/sdk_routes.go +177 -0
- package/dist/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/dist/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/dist/templates/native-go/backend/internal/background/access.go +57 -0
- package/dist/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/dist/templates/native-go/backend/internal/background/runner.go +185 -0
- package/dist/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/dist/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/dist/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/dist/templates/native-go/backend/internal/background/store.go +807 -0
- package/dist/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/dist/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/dist/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/dist/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/dist/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/dist/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/dist/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/dist/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/dist/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/dist/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/dist/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/dist/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/dist/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/management.go +86 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/purge.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/purge_test.go +59 -0
- package/dist/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/revoke.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/revoke_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/dist/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_server_linux.go +161 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +14 -2
- package/dist/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +22 -13
- package/dist/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/dist/templates/native-go/dsm-package.yaml +2 -2
- package/dist/templates/native-go-authorization/backend/internal/app/authorization.go +298 -0
- package/dist/templates/native-go-authorization/backend/internal/app/authorization_test.go +96 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/AuthorizationGate.vue +89 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/de.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/en.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/es.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/fr.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/index.ts +15 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/it.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/ja.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/ko.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/zh-CN.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/zh-TW.json +36 -0
- package/dist/templates/native-go-authorization/frontend/test/authorization-preview.html +14 -0
- package/dist/templates/native-go-authorization/frontend/test/authorization.test.ts +59 -0
- package/dist/templates/native-go-background/BACKGROUND.md +111 -0
- package/dist/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/dist/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/dist/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/dist/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/dist/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/dist/templates/native-go-vue/README.md +38 -7
- package/dist/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/dist/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/dist/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/dist/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/dist/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +3 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/dist/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/dist/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/dist/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/dist/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/dist/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +2 -6
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/dist/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/dist/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/dist/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/dist/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/dist/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/dist/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/dist/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/dist/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/dist/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/dist/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +6 -3
- package/package.json +5 -2
- package/schema/synology-app.schema.json +19 -0
- package/skills/reference/create.md +6 -2
- package/templates/_authorization/main.go +104 -0
- package/templates/_authorization/main_test.go +35 -0
- package/templates/_daemon/go.mod +2 -0
- package/templates/_gateway/auth.go +101 -0
- package/templates/_gateway/auth_test.go +216 -0
- package/templates/_gateway/cgi.go +133 -0
- package/templates/_gateway/cgi_test.go +156 -0
- package/templates/_gateway/csrf.go +73 -0
- package/templates/_gateway/csrf_test.go +155 -0
- package/templates/_gateway/directory.go +108 -0
- package/templates/_gateway/directory_test.go +202 -0
- package/templates/_gateway/gateway.go +412 -0
- package/templates/_gateway/gateway_test.go +676 -0
- package/templates/_gateway/go.mod +3 -0
- package/templates/_gateway/groups.go +66 -0
- package/templates/_gateway/main.go +45 -0
- package/templates/binary/synology-app.yaml +1 -1
- package/templates/compose-import/compose.yaml +1 -1
- package/templates/compose-import/synology-app.yaml +1 -1
- package/templates/hello-files/compose.yaml +1 -1
- package/templates/hello-files/synology-app.yaml +1 -1
- package/templates/native-go/README.md +118 -5
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/templates/native-go/backend/cmd/app/main.go +25 -6
- package/templates/native-go/backend/cmd/app/sdk_main.go +62 -0
- package/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/templates/native-go/backend/cmd/helper/main.go +27 -1
- package/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/templates/native-go/backend/go.mod +5 -3
- package/templates/native-go/backend/go.sum +4 -4
- package/templates/native-go/backend/internal/api/registry.go +17 -6
- package/templates/native-go/backend/internal/api/server.go +7 -1
- package/templates/native-go/backend/internal/app/authorization_none.go +5 -0
- package/templates/native-go/backend/internal/app/background.go +270 -0
- package/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/templates/native-go/backend/internal/app/routes.go +22 -5
- package/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/templates/native-go/backend/internal/app/sdk_routes.go +177 -0
- package/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/templates/native-go/backend/internal/background/access.go +57 -0
- package/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/templates/native-go/backend/internal/background/runner.go +185 -0
- package/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/templates/native-go/backend/internal/background/store.go +807 -0
- package/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/management.go +86 -0
- package/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/templates/native-go/backend/internal/helper/purge.go +115 -0
- package/templates/native-go/backend/internal/helper/purge_test.go +59 -0
- package/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/templates/native-go/backend/internal/helper/revoke.go +109 -0
- package/templates/native-go/backend/internal/helper/revoke_test.go +121 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/templates/native-go/backend/internal/helper/sdk_server_linux.go +161 -0
- package/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +14 -2
- package/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/templates/native-go/backend/internal/helper/status.go +22 -13
- package/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/templates/native-go/dsm-package.yaml +2 -2
- package/templates/native-go-authorization/backend/internal/app/authorization.go +298 -0
- package/templates/native-go-authorization/backend/internal/app/authorization_test.go +96 -0
- package/templates/native-go-authorization/frontend/src/authorization/AuthorizationGate.vue +89 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/de.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/en.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/es.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/fr.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/index.ts +15 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/it.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/ja.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/ko.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/zh-CN.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/zh-TW.json +36 -0
- package/templates/native-go-authorization/frontend/test/authorization-preview.html +14 -0
- package/templates/native-go-authorization/frontend/test/authorization.test.ts +59 -0
- package/templates/native-go-background/BACKGROUND.md +111 -0
- package/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/templates/native-go-vue/README.md +38 -7
- package/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/templates/native-go-vue/frontend/src/context.ts +3 -0
- package/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/templates/native-go-vue/frontend/src/style.css +2 -6
- package/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/templates/native-go-vue/frontend/vite.config.ts +2 -2
- package/dist/templates/hello-web/compose.yaml +0 -21
- package/dist/templates/hello-web/html/app.js +0 -1
- package/dist/templates/hello-web/html/index.html +0 -13
- package/dist/templates/hello-web/synology-app.yaml +0 -13
- package/dist/templates/hello-web-page/compose.yaml +0 -21
- package/dist/templates/hello-web-page/html/app.js +0 -1
- package/dist/templates/hello-web-page/html/index.html +0 -13
- package/dist/templates/hello-web-page/synology-app.yaml +0 -13
- package/templates/hello-web/compose.yaml +0 -21
- package/templates/hello-web/html/app.js +0 -1
- package/templates/hello-web/html/index.html +0 -13
- package/templates/hello-web/synology-app.yaml +0 -13
- package/templates/hello-web-page/compose.yaml +0 -21
- package/templates/hello-web-page/html/app.js +0 -1
- package/templates/hello-web-page/html/index.html +0 -13
- package/templates/hello-web-page/synology-app.yaml +0 -13
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
//go:build synopkgland_sdk_workers
|
|
2
|
+
|
|
3
|
+
package filestation
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"context"
|
|
7
|
+
"dsmapp/internal/api"
|
|
8
|
+
"dsmapp/internal/helper/jobcontract"
|
|
9
|
+
"fmt"
|
|
10
|
+
"golang.org/x/sys/unix"
|
|
11
|
+
"net/http"
|
|
12
|
+
"os"
|
|
13
|
+
"path/filepath"
|
|
14
|
+
"strings"
|
|
15
|
+
"sync/atomic"
|
|
16
|
+
"testing"
|
|
17
|
+
"time"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
type sdkAuth struct {
|
|
21
|
+
identity api.Identity
|
|
22
|
+
err error
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func (a sdkAuth) Authenticate(*http.Request) (api.Identity, error) { return a.identity, a.err }
|
|
26
|
+
func TestSDKSessionIdentityFreshAndMatched(t *testing.T) {
|
|
27
|
+
var calls atomic.Int32
|
|
28
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
29
|
+
calls.Add(1)
|
|
30
|
+
fmt.Fprint(w, `{"success":true,"data":{"username":"alice"}}`)
|
|
31
|
+
})
|
|
32
|
+
s := NewService(c, NewGrantRepository(t.TempDir()))
|
|
33
|
+
s.lookupUID = func(string) (string, error) { return "1000", nil }
|
|
34
|
+
a := sdkAuth{identity: api.Identity{User: "alice", Admin: true}}
|
|
35
|
+
for range 2 {
|
|
36
|
+
id, e := s.CheckSession(context.Background(), a, sessionRequest())
|
|
37
|
+
if e != nil || id.User != "alice" || id.UID != "1000" || !id.Admin {
|
|
38
|
+
t.Fatalf("missing verified identity: %v", e)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if calls.Load() != 2 {
|
|
42
|
+
t.Fatal("session cached")
|
|
43
|
+
}
|
|
44
|
+
a.identity.User = "bob"
|
|
45
|
+
if _, e := s.CheckSession(context.Background(), a, sessionRequest()); e == nil {
|
|
46
|
+
t.Fatal("mismatched session accepted")
|
|
47
|
+
}
|
|
48
|
+
a.identity.User = "alice"
|
|
49
|
+
s.lookupUID = func(string) (string, error) { return "0", nil }
|
|
50
|
+
if _, e := s.CheckSession(context.Background(), a, sessionRequest()); e == nil {
|
|
51
|
+
t.Fatal("root identity accepted")
|
|
52
|
+
}
|
|
53
|
+
a.err = api.ErrNoSession
|
|
54
|
+
if _, e := s.CheckSession(context.Background(), a, sessionRequest()); e == nil {
|
|
55
|
+
t.Fatal("expired session accepted")
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
func TestSDKJobUsesSelectionAndFileStation(t *testing.T) {
|
|
59
|
+
var calls atomic.Int32
|
|
60
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
61
|
+
calls.Add(1)
|
|
62
|
+
r.ParseForm()
|
|
63
|
+
if r.Form.Get("api") != "SYNO.FileStation.List" {
|
|
64
|
+
t.Error("unexpected API")
|
|
65
|
+
}
|
|
66
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/home/item","name":"item","isdir":false,"additional":{"size":7}}]}}`)
|
|
67
|
+
})
|
|
68
|
+
repo := NewGrantRepository(t.TempDir())
|
|
69
|
+
s := NewService(c, repo)
|
|
70
|
+
ctx := context.Background()
|
|
71
|
+
id := SessionIdentity{User: "alice", UID: "1000"}
|
|
72
|
+
g, e := repo.Confirm(ctx, id.User, id.UID, "/home", false)
|
|
73
|
+
if e != nil {
|
|
74
|
+
t.Fatal(e)
|
|
75
|
+
}
|
|
76
|
+
if e = s.JobSelection(ctx, id, g.ID); e != nil {
|
|
77
|
+
t.Fatal(e)
|
|
78
|
+
}
|
|
79
|
+
step := jobcontract.Step{Action: jobcontract.Stat, Segments: []string{"item"}}
|
|
80
|
+
result, e := s.JobStep(ctx, sessionRequest(), id, g.ID, step)
|
|
81
|
+
if e != nil || result.Entries != 1 || result.CompletedSteps != 1 {
|
|
82
|
+
t.Fatalf("step failed: %v", e)
|
|
83
|
+
}
|
|
84
|
+
for _, other := range []SessionIdentity{{User: "bob", UID: "1000", Admin: true}, {User: "alice", UID: "1001"}} {
|
|
85
|
+
if _, e = s.JobStep(ctx, sessionRequest(), other, g.ID, step); e == nil {
|
|
86
|
+
t.Fatal("foreign selection accepted")
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
step.Segments = []string{"..", "item"}
|
|
90
|
+
if _, e = s.JobStep(ctx, sessionRequest(), id, g.ID, step); e == nil {
|
|
91
|
+
t.Fatal("traversal accepted")
|
|
92
|
+
}
|
|
93
|
+
step.Action = jobcontract.ReadStream
|
|
94
|
+
step.Segments = []string{"item"}
|
|
95
|
+
if _, e = s.JobStep(ctx, sessionRequest(), id, g.ID, step); e == nil {
|
|
96
|
+
t.Fatal("stream accepted")
|
|
97
|
+
}
|
|
98
|
+
if calls.Load() != 1 {
|
|
99
|
+
t.Fatal("refused input reached File Station")
|
|
100
|
+
}
|
|
101
|
+
if e = repo.Revoke(ctx, id.User, id.UID, g.ID); e != nil {
|
|
102
|
+
t.Fatal(e)
|
|
103
|
+
}
|
|
104
|
+
if e = s.JobSelection(ctx, id, g.ID); e == nil {
|
|
105
|
+
t.Fatal("revoked selection accepted")
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
func TestSDKJobReadUsesBoundedDownloadAndSafeCounters(t *testing.T) {
|
|
110
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
111
|
+
r.ParseForm()
|
|
112
|
+
if r.Form.Get("method") == "getinfo" {
|
|
113
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/home/item","name":"item","additional":{"size":3}}]}}`)
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
if r.Method != "GET" || r.URL.Query().Has("SynoToken") {
|
|
117
|
+
t.Error("credential URL or non-GET download")
|
|
118
|
+
}
|
|
119
|
+
w.Header().Set("Content-Disposition", `attachment; filename="item"`)
|
|
120
|
+
fmt.Fprint(w, "abc")
|
|
121
|
+
})
|
|
122
|
+
repo := NewGrantRepository(t.TempDir())
|
|
123
|
+
s := NewService(c, repo)
|
|
124
|
+
id := SessionIdentity{User: "alice", UID: "1000"}
|
|
125
|
+
g, e := repo.Confirm(context.Background(), id.User, id.UID, "/home", false)
|
|
126
|
+
if e != nil {
|
|
127
|
+
t.Fatal(e)
|
|
128
|
+
}
|
|
129
|
+
n := uint64(3)
|
|
130
|
+
step := jobcontract.Step{Action: jobcontract.Read, Segments: []string{"item"}, MaxBytes: &n}
|
|
131
|
+
result, e := s.JobStep(context.Background(), sessionRequest(), id, g.ID, step)
|
|
132
|
+
if e != nil || result.BytesRead != 3 || result.CompletedSteps != 1 {
|
|
133
|
+
t.Fatal("download", e)
|
|
134
|
+
}
|
|
135
|
+
n = 2
|
|
136
|
+
if _, e = s.JobStep(context.Background(), sessionRequest(), id, g.ID, step); e == nil {
|
|
137
|
+
t.Fatal("oversized read")
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
func TestSDKJobSelectionNeverCreatesPackageFiles(t *testing.T) {
|
|
142
|
+
dir := t.TempDir()
|
|
143
|
+
s := NewService(nil, NewGrantRepository(dir))
|
|
144
|
+
_ = s.JobSelection(context.Background(), SessionIdentity{User: "alice", UID: "1000"}, strings.Repeat("a", 64))
|
|
145
|
+
files, e := os.ReadDir(dir)
|
|
146
|
+
if e != nil {
|
|
147
|
+
t.Fatal(e)
|
|
148
|
+
}
|
|
149
|
+
if len(files) != 0 {
|
|
150
|
+
t.Fatal("privileged job reader created package metadata")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
func TestSDKJobSelectionRefusesSpecialMetadataFiles(t *testing.T) {
|
|
154
|
+
for _, name := range []string{"session-selections.lock", "session-selections.json"} {
|
|
155
|
+
t.Run(name, func(t *testing.T) {
|
|
156
|
+
dir := t.TempDir()
|
|
157
|
+
repo := NewGrantRepository(dir)
|
|
158
|
+
id := SessionIdentity{User: "alice", UID: "1000"}
|
|
159
|
+
g, e := repo.Confirm(context.Background(), id.User, id.UID, "/home", false)
|
|
160
|
+
if e != nil {
|
|
161
|
+
t.Fatal(e)
|
|
162
|
+
}
|
|
163
|
+
target := filepath.Join(dir, name)
|
|
164
|
+
if e = os.Remove(target); e != nil {
|
|
165
|
+
t.Fatal(e)
|
|
166
|
+
}
|
|
167
|
+
if e = unix.Mkfifo(target, 0600); e != nil {
|
|
168
|
+
t.Fatal(e)
|
|
169
|
+
}
|
|
170
|
+
s := NewService(nil, repo)
|
|
171
|
+
done := make(chan error, 1)
|
|
172
|
+
go func() { done <- s.JobSelection(context.Background(), id, g.ID) }()
|
|
173
|
+
select {
|
|
174
|
+
case e := <-done:
|
|
175
|
+
if e == nil {
|
|
176
|
+
t.Fatal("special file accepted")
|
|
177
|
+
}
|
|
178
|
+
case <-time.After(time.Second):
|
|
179
|
+
t.Fatal("special file blocked root reader")
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
package filestation
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"io"
|
|
8
|
+
"net/http"
|
|
9
|
+
"os/user"
|
|
10
|
+
"time"
|
|
11
|
+
|
|
12
|
+
"dsmapp/internal/api"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
type Service struct {
|
|
16
|
+
client *Client
|
|
17
|
+
repository *GrantRepository
|
|
18
|
+
lookupUID func(string) (string, error)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func NewService(client *Client, repository *GrantRepository) *Service {
|
|
22
|
+
return &Service{client: client, repository: repository, lookupUID: func(name string) (string, error) {
|
|
23
|
+
u, e := user.Lookup(name)
|
|
24
|
+
if e != nil {
|
|
25
|
+
return "", e
|
|
26
|
+
}
|
|
27
|
+
return u.Uid, nil
|
|
28
|
+
}}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Local is the production assembly. DSM's HTTP loopback port is fixed here,
|
|
32
|
+
// never selected from Host, request params or a browser-supplied URL.
|
|
33
|
+
func Local(dataDir string) *Service {
|
|
34
|
+
c, e := NewClient("http://127.0.0.1:5000")
|
|
35
|
+
if e != nil {
|
|
36
|
+
return nil
|
|
37
|
+
}
|
|
38
|
+
return NewService(c, NewGrantRepository(dataDir))
|
|
39
|
+
}
|
|
40
|
+
func (s *Service) Routes() []api.Route {
|
|
41
|
+
if s == nil {
|
|
42
|
+
return nil
|
|
43
|
+
}
|
|
44
|
+
routes := []api.Route{}
|
|
45
|
+
for _, name := range []string{"nas.session.status", "nas.discovery", "nas.grants.confirm", "nas.grants.list", "nas.grants.revoke", "nas.files.stat", "nas.files.list", "nas.files.read", "nas.files.create", "nas.files.write", "nas.files.stream", "nas.files.publish"} {
|
|
46
|
+
method := name
|
|
47
|
+
routes = append(routes, api.UserRequest(method, func(ctx context.Context, c api.Caller, r *http.Request, p json.RawMessage) (any, error) {
|
|
48
|
+
return s.handle(ctx, c, r, method, p)
|
|
49
|
+
}))
|
|
50
|
+
}
|
|
51
|
+
return routes
|
|
52
|
+
}
|
|
53
|
+
func strict(p json.RawMessage, dst any) error {
|
|
54
|
+
d := json.NewDecoder(bytes.NewReader(p))
|
|
55
|
+
d.DisallowUnknownFields()
|
|
56
|
+
if d.Decode(dst) != nil || d.Decode(new(any)) != io.EOF {
|
|
57
|
+
return fail("invalid-request")
|
|
58
|
+
}
|
|
59
|
+
return nil
|
|
60
|
+
}
|
|
61
|
+
func (s *Service) handle(ctx context.Context, c api.Caller, r *http.Request, method string, p json.RawMessage) (any, error) {
|
|
62
|
+
if !c.Authenticated() {
|
|
63
|
+
return nil, fail("session_required")
|
|
64
|
+
}
|
|
65
|
+
ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
|
66
|
+
defer cancel()
|
|
67
|
+
if method == "nas.session.status" {
|
|
68
|
+
if e := strict(p, &struct{}{}); e != nil {
|
|
69
|
+
return nil, e
|
|
70
|
+
}
|
|
71
|
+
return map[string]string{"interactive": "session-required", "background": "unavailable", "mode": "filestation-session", "validation": "local-only"}, nil
|
|
72
|
+
}
|
|
73
|
+
if method == "nas.files.stream" || method == "nas.files.publish" {
|
|
74
|
+
return nil, fail("unsupported")
|
|
75
|
+
}
|
|
76
|
+
if s.client == nil || s.repository == nil {
|
|
77
|
+
return nil, fail("unavailable")
|
|
78
|
+
}
|
|
79
|
+
uid, e := s.verifiedUID(ctx, c, r)
|
|
80
|
+
if e != nil {
|
|
81
|
+
return nil, e
|
|
82
|
+
}
|
|
83
|
+
switch method {
|
|
84
|
+
case "nas.discovery":
|
|
85
|
+
var in struct {
|
|
86
|
+
Folder string `json:"folder"`
|
|
87
|
+
Offset int `json:"offset"`
|
|
88
|
+
}
|
|
89
|
+
if e := strict(p, &in); e != nil {
|
|
90
|
+
return nil, e
|
|
91
|
+
}
|
|
92
|
+
return s.discover(ctx, r, in.Folder, in.Offset)
|
|
93
|
+
case "nas.grants.confirm":
|
|
94
|
+
var in struct {
|
|
95
|
+
Folder string `json:"folder"`
|
|
96
|
+
Writable bool `json:"writable"`
|
|
97
|
+
}
|
|
98
|
+
if e := strict(p, &in); e != nil {
|
|
99
|
+
return nil, e
|
|
100
|
+
}
|
|
101
|
+
item, e := s.client.Stat(ctx, r, in.Folder)
|
|
102
|
+
if e != nil {
|
|
103
|
+
return nil, e
|
|
104
|
+
}
|
|
105
|
+
if !item.IsDir {
|
|
106
|
+
return nil, fail("invalid-request")
|
|
107
|
+
}
|
|
108
|
+
return s.repository.Confirm(ctx, c.User(), uid, in.Folder, in.Writable)
|
|
109
|
+
case "nas.grants.list":
|
|
110
|
+
if e := strict(p, &struct{}{}); e != nil {
|
|
111
|
+
return nil, e
|
|
112
|
+
}
|
|
113
|
+
return s.repository.List(ctx, c.User(), uid)
|
|
114
|
+
case "nas.grants.revoke":
|
|
115
|
+
var in struct {
|
|
116
|
+
ID string `json:"grantId"`
|
|
117
|
+
}
|
|
118
|
+
if e := strict(p, &in); e != nil {
|
|
119
|
+
return nil, e
|
|
120
|
+
}
|
|
121
|
+
e := s.repository.Revoke(ctx, c.User(), uid, in.ID)
|
|
122
|
+
return map[string]bool{"revoked": e == nil}, e
|
|
123
|
+
}
|
|
124
|
+
var in struct {
|
|
125
|
+
ID string `json:"grantId"`
|
|
126
|
+
Relative string `json:"relative"`
|
|
127
|
+
Name string `json:"name"`
|
|
128
|
+
Offset int `json:"offset"`
|
|
129
|
+
Data []byte `json:"data"`
|
|
130
|
+
}
|
|
131
|
+
if e := strict(p, &in); e != nil {
|
|
132
|
+
return nil, e
|
|
133
|
+
}
|
|
134
|
+
write := method == "nas.files.create" || method == "nas.files.write"
|
|
135
|
+
if len(in.Data) > MaxBytes {
|
|
136
|
+
return nil, fail("limit-exceeded")
|
|
137
|
+
}
|
|
138
|
+
var result any
|
|
139
|
+
e = s.repository.WithGrant(ctx, c.User(), uid, in.ID, write, func(g Selection) error {
|
|
140
|
+
target, e := relative(g.Folder, in.Relative)
|
|
141
|
+
if e != nil {
|
|
142
|
+
return e
|
|
143
|
+
}
|
|
144
|
+
switch method {
|
|
145
|
+
case "nas.files.list":
|
|
146
|
+
result, e = s.client.List(ctx, r, target, in.Offset)
|
|
147
|
+
case "nas.files.stat":
|
|
148
|
+
result, e = s.client.Stat(ctx, r, target)
|
|
149
|
+
case "nas.files.read":
|
|
150
|
+
var b []byte
|
|
151
|
+
b, e = s.readRegularFile(ctx, r, target)
|
|
152
|
+
result = map[string]any{"data": b, "bytes": len(b)}
|
|
153
|
+
case "nas.files.create":
|
|
154
|
+
e = s.client.Create(ctx, r, target, in.Name)
|
|
155
|
+
result = map[string]bool{"created": e == nil}
|
|
156
|
+
case "nas.files.write":
|
|
157
|
+
e = s.client.Write(ctx, r, target, in.Name, in.Data)
|
|
158
|
+
result = map[string]bool{"written": e == nil}
|
|
159
|
+
default:
|
|
160
|
+
return fail("unsupported")
|
|
161
|
+
}
|
|
162
|
+
return e
|
|
163
|
+
})
|
|
164
|
+
return result, e
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// verifiedUID proves the request's DSM session belongs to the caller and
|
|
168
|
+
// returns the caller's UID.
|
|
169
|
+
func (s *Service) verifiedUID(ctx context.Context, c api.Caller, r *http.Request) (string, error) {
|
|
170
|
+
if e := s.client.Verify(ctx, r, c.User()); e != nil {
|
|
171
|
+
return "", e
|
|
172
|
+
}
|
|
173
|
+
uid, e := s.lookupUID(c.User())
|
|
174
|
+
if e != nil || uid == "" {
|
|
175
|
+
return "", fail("auth_unavailable")
|
|
176
|
+
}
|
|
177
|
+
return uid, nil
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// readRegularFile avoids downloading a folder as an archive. DSM still enforces
|
|
181
|
+
// its current permissions on the subsequent download, not this metadata observation.
|
|
182
|
+
func (s *Service) readRegularFile(ctx context.Context, r *http.Request, target string) ([]byte, error) {
|
|
183
|
+
item, e := s.client.Stat(ctx, r, target)
|
|
184
|
+
if e != nil {
|
|
185
|
+
return nil, e
|
|
186
|
+
}
|
|
187
|
+
if item.IsDir {
|
|
188
|
+
return nil, fail("invalid-request")
|
|
189
|
+
}
|
|
190
|
+
if item.Additional.Size > MaxBytes {
|
|
191
|
+
return nil, fail("limit-exceeded")
|
|
192
|
+
}
|
|
193
|
+
return s.client.Read(ctx, r, target)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// discover lists the share roots for an empty folder, else one folder's page.
|
|
197
|
+
func (s *Service) discover(ctx context.Context, r *http.Request, folder string, offset int) (Page, error) {
|
|
198
|
+
if folder == "" {
|
|
199
|
+
return s.client.Discover(ctx, r, offset)
|
|
200
|
+
}
|
|
201
|
+
return s.client.List(ctx, r, folder, offset)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Browse lists share roots (empty folder) or one folder through the caller's
|
|
205
|
+
// own DSM session, so File Station's current permissions decide what is
|
|
206
|
+
// visible. It is read-only metadata and stores no grant; background jobs use it
|
|
207
|
+
// to let an administrator pick the file that ReadFile will then import.
|
|
208
|
+
func (s *Service) Browse(ctx context.Context, c api.Caller, r *http.Request, folder string, offset int) (Page, error) {
|
|
209
|
+
if !c.Authenticated() {
|
|
210
|
+
return Page{}, fail("session_required")
|
|
211
|
+
}
|
|
212
|
+
if s == nil || s.client == nil {
|
|
213
|
+
return Page{}, fail("unavailable")
|
|
214
|
+
}
|
|
215
|
+
ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
|
216
|
+
defer cancel()
|
|
217
|
+
if _, e := s.verifiedUID(ctx, c, r); e != nil {
|
|
218
|
+
return Page{}, e
|
|
219
|
+
}
|
|
220
|
+
return s.discover(ctx, r, folder, offset)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ReadFile reads one regular file below a folder the caller names, through the
|
|
224
|
+
// caller's own DSM session, up to MaxBytes. It is the single-file import used by
|
|
225
|
+
// package-private background jobs; the bytes never pass through the browser.
|
|
226
|
+
// The request itself is the consent, so no grant is stored.
|
|
227
|
+
func (s *Service) ReadFile(ctx context.Context, c api.Caller, r *http.Request, folder, rel string) ([]byte, error) {
|
|
228
|
+
if !c.Authenticated() {
|
|
229
|
+
return nil, fail("session_required")
|
|
230
|
+
}
|
|
231
|
+
if s == nil || s.client == nil {
|
|
232
|
+
return nil, fail("unavailable")
|
|
233
|
+
}
|
|
234
|
+
if rel == "" {
|
|
235
|
+
return nil, fail("invalid-request")
|
|
236
|
+
}
|
|
237
|
+
ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
|
238
|
+
defer cancel()
|
|
239
|
+
if _, e := s.verifiedUID(ctx, c, r); e != nil {
|
|
240
|
+
return nil, e
|
|
241
|
+
}
|
|
242
|
+
item, e := s.client.Stat(ctx, r, folder)
|
|
243
|
+
if e != nil {
|
|
244
|
+
return nil, e
|
|
245
|
+
}
|
|
246
|
+
if !item.IsDir {
|
|
247
|
+
return nil, fail("invalid-request")
|
|
248
|
+
}
|
|
249
|
+
target, e := relative(folder, rel)
|
|
250
|
+
if e != nil {
|
|
251
|
+
return nil, e
|
|
252
|
+
}
|
|
253
|
+
return s.readRegularFile(ctx, r, target)
|
|
254
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
package filestation
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"dsmapp/internal/api"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"io"
|
|
9
|
+
"net/http"
|
|
10
|
+
"net/http/httptest"
|
|
11
|
+
"testing"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
type testAuth struct{ user string }
|
|
15
|
+
|
|
16
|
+
func (a testAuth) Authenticate(*http.Request) (api.Identity, error) {
|
|
17
|
+
if a.user == "" {
|
|
18
|
+
return api.Identity{}, api.ErrNoSession
|
|
19
|
+
}
|
|
20
|
+
return api.Identity{User: a.user}, nil
|
|
21
|
+
}
|
|
22
|
+
func invoke(t *testing.T, s *Service, user, method, params string) map[string]any {
|
|
23
|
+
t.Helper()
|
|
24
|
+
server, e := api.NewServer(testAuth{user}, s.Routes()...)
|
|
25
|
+
if e != nil {
|
|
26
|
+
t.Fatal(e)
|
|
27
|
+
}
|
|
28
|
+
r := sessionRequest()
|
|
29
|
+
r.Body = http.NoBody
|
|
30
|
+
b := []byte(fmt.Sprintf(`{"method":%q,"params":%s}`, method, params))
|
|
31
|
+
r.Body = ioNop(b)
|
|
32
|
+
r.Header.Set("Content-Type", "application/json")
|
|
33
|
+
w := httptest.NewRecorder()
|
|
34
|
+
server.ServeHTTP(w, r)
|
|
35
|
+
var out map[string]any
|
|
36
|
+
if json.Unmarshal(w.Body.Bytes(), &out) != nil {
|
|
37
|
+
t.Fatal(w.Body.String())
|
|
38
|
+
}
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
41
|
+
func ioNop(b []byte) io.ReadCloser { return io.NopCloser(bytes.NewReader(b)) }
|
|
42
|
+
func TestInteractiveRoutesIsolationAndFreshACL(t *testing.T) {
|
|
43
|
+
denied := false
|
|
44
|
+
writes := 0
|
|
45
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
46
|
+
r.ParseForm()
|
|
47
|
+
switch r.Form.Get("method") {
|
|
48
|
+
case "get":
|
|
49
|
+
fmt.Fprint(w, `{"success":true,"data":{"username":"alice"}}`)
|
|
50
|
+
case "getinfo":
|
|
51
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/home","name":"home","isdir":true}]}}`)
|
|
52
|
+
case "list":
|
|
53
|
+
if denied {
|
|
54
|
+
fmt.Fprint(w, `{"success":false,"error":{"code":407}}`)
|
|
55
|
+
} else {
|
|
56
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[],"total":0}}`)
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
writes++
|
|
60
|
+
fmt.Fprint(w, `{"success":true}`)
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
s := NewService(c, NewGrantRepository(t.TempDir()))
|
|
64
|
+
s.lookupUID = func(string) (string, error) { return "1000", nil }
|
|
65
|
+
out := invoke(t, s, "alice", "nas.grants.confirm", `{"folder":"/home","writable":false}`)
|
|
66
|
+
if out["success"] != true {
|
|
67
|
+
t.Fatal(out)
|
|
68
|
+
}
|
|
69
|
+
id := out["data"].(map[string]any)["grantId"].(string)
|
|
70
|
+
p := fmt.Sprintf(`{"grantId":%q}`, id)
|
|
71
|
+
if out = invoke(t, s, "alice", "nas.files.list", p); out["success"] != true {
|
|
72
|
+
t.Fatal(out)
|
|
73
|
+
}
|
|
74
|
+
denied = true
|
|
75
|
+
if out = invoke(t, s, "alice", "nas.files.list", p); out["error"].(map[string]any)["code"] != "denied" {
|
|
76
|
+
t.Fatal(out)
|
|
77
|
+
}
|
|
78
|
+
if out = invoke(t, s, "bob", "nas.files.list", p); out["success"] != false {
|
|
79
|
+
t.Fatal(out)
|
|
80
|
+
}
|
|
81
|
+
if out = invoke(t, s, "", "nas.files.list", p); out["success"] != false {
|
|
82
|
+
t.Fatal(out)
|
|
83
|
+
}
|
|
84
|
+
if out = invoke(t, s, "alice", "nas.files.create", fmt.Sprintf(`{"grantId":%q,"name":"x"}`, id)); out["success"] != false || writes != 0 {
|
|
85
|
+
t.Fatal(out)
|
|
86
|
+
}
|
|
87
|
+
if out = invoke(t, s, "alice", "nas.grants.revoke", p); out["success"] != true {
|
|
88
|
+
t.Fatal(out)
|
|
89
|
+
}
|
|
90
|
+
if out = invoke(t, s, "alice", "nas.files.list", p); out["success"] != false {
|
|
91
|
+
t.Fatal(out)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|