{"id":31156104,"url":"https://github.com/aborroy/alfresco-b64-jscript-root","last_synced_at":"2025-09-18T20:54:49.864Z","repository":{"id":310511684,"uuid":"1040147572","full_name":"aborroy/alfresco-b64-jscript-root","owner":"aborroy","description":"Adds a new JavaScript Root Object `base64` to Alfresco Repo","archived":false,"fork":false,"pushed_at":"2025-08-18T14:32:39.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-18T16:23:12.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aborroy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-18T14:24:42.000Z","updated_at":"2025-08-18T14:31:33.000Z","dependencies_parsed_at":"2025-08-18T16:36:11.186Z","dependency_job_id":null,"html_url":"https://github.com/aborroy/alfresco-b64-jscript-root","commit_stats":null,"previous_names":["aborroy/alfresco-b64-jscript-root"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aborroy/alfresco-b64-jscript-root","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Falfresco-b64-jscript-root","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Falfresco-b64-jscript-root/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Falfresco-b64-jscript-root/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Falfresco-b64-jscript-root/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aborroy","download_url":"https://codeload.github.com/aborroy/alfresco-b64-jscript-root/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aborroy%2Falfresco-b64-jscript-root/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275830188,"owners_count":25536280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-18T20:54:48.627Z","updated_at":"2025-09-18T20:54:49.857Z","avatar_url":"https://github.com/aborroy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alfresco Base64 JavaScript Root Object\n\nAdds a small Java‑backed **Repository JavaScript Root Object** named `base64` for Alfresco Content Services. It lets your RhinoJS scripts (Rules, Actions, Repo Web Scripts, Workflows) **encode content to Base64** and **decode Base64 back to bytes** without resorting to `Packages` (which is blocked in unsafe contexts like *Data Dictionary \u003e Scripts*).\n\n## What you get\n\nA single root object available to Rhino scripts:\n\n| API | Description |\n|---|---|\n| `base64.encode(node)` | Streams the node’s primary content (`cm:content`) and returns a Base64 **string**. |\n| `base64.encodeBytes(value)` | Encodes **raw bytes** you already have (e.g., `document.content`) and returns a Base64 string. |\n| `base64.decodeToBytes(base64String)` | Decodes a Base64 string and returns **byte[]** (Rhino sees this as a Java byte array). |\n\n### Why this exists\n\nScripts under *Data Dictionary \u003e Scripts* cannot access Spring beans via `Packages.org.springframework...` for security reasons. Exposing a tiny, focused root object is the **supported** and **safe** way to extend the JS API for rules and other contexts.\n\n## Usage examples (Rhino JS)\n\n```javascript\n// Encode the primary content of the current document (streaming, memory‑friendly)\nvar b64 = base64.encode(document);\nlogger.log(\"B64 size: \" + b64.length);\n\n// If you already have raw bytes (e.g., document.content), encode them:\nvar b64FromBytes = base64.encodeBytes(document.content);\n\n// Decode back to bytes (Java byte[])\nvar bytes = base64.decodeToBytes(b64);\nlogger.log(\"Decoded bytes: \" + bytes.length);\n```\n\n\u003e Tip: prefer `base64.encode(document)` for large files — it streams from the repository and avoids loading the full content into memory.\n\n## Requirements\n\n- **Alfresco Content Services**: 25.2.x (built and tested with `${alfresco.platform.version}` 25.2.0)\n- **Java**: 17\n- **Maven**: 3.8+\n- **Packaging**: Repository **JAR** module (to be placed in the `alfresco.war`)\n\n\u003e Should also work with nearby ACS 25.x versions. For older versions, re‑compile against the desired BOM and Java level.\n\n## Build\n\n```bash\nmvn clean package\nls target/\n# alfresco-b64-jscript-root-1.0-SNAPSHOT.jar\n```\n\n## Deploy\n\nDeploy like any other repository JAR module.\n\n### Classic Tomcat/WAR\n\nCopy the JAR into the repository webapp:\n\n```bash\ncp target/alfresco-b64-jscript-root-*.jar $TOMCAT/webapps/alfresco/WEB-INF/lib/\n```\n\nRestart Alfresco; you should see the bean `base64Script` registered and the JS root object `base64` available in scripts.\n\n### Docker image (recommended)\n\nCreate a tiny image that layers the JAR into the repo webapp:\n\n```dockerfile\n# Dockerfile\nFROM alfresco/alfresco-content-repository-community:25.2.0\nCOPY target/alfresco-b64-jscript-root-*.jar /usr/local/tomcat/webapps/alfresco/WEB-INF/lib/\n```\n\nThen build and run with your existing Compose stack, or add a service override that uses the custom image.\n\n## Testing it quickly\n\nCreate a test script under **Repository \u003e Data Dictionary \u003e Scripts \u003e test-b64.js**:\n\n```javascript\nif (!document) {\n  throw \"Run this as a rule on a document.\";\n}\nvar s = base64.encode(document);\nlogger.log(\"Base64 starts with: \" + s.substring(0, 60) + \"...\");\n```\n\nAttach a **rule** to a folder: *when items are created or enter this folder \u003e Execute script \u003e `test-b64.js`*. Upload a file and watch `alfresco.log` for the output.\n\n## License\n\nApache License 2.0 (see source headers).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborroy%2Falfresco-b64-jscript-root","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faborroy%2Falfresco-b64-jscript-root","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborroy%2Falfresco-b64-jscript-root/lists"}