{"id":17300092,"url":"https://github.com/thomaspoignant/scim-patch","last_synced_at":"2025-08-20T20:33:36.842Z","repository":{"id":36996644,"uuid":"224857102","full_name":"thomaspoignant/scim-patch","owner":"thomaspoignant","description":"Simple library to perform SCIM patch as describe in RFC 7644 https://tools.ietf.org/html/rfc7644#section-3.5.2","archived":false,"fork":false,"pushed_at":"2024-04-30T04:03:50.000Z","size":1470,"stargazers_count":24,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T16:03:37.657Z","etag":null,"topics":["library","nodejs","npm-package","patch","patcher","scim","scim-2","scim-patch"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/scim-patch","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomaspoignant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"thomaspoignant"}},"created_at":"2019-11-29T13:12:44.000Z","updated_at":"2024-05-07T05:26:57.473Z","dependencies_parsed_at":"2024-04-05T05:24:43.383Z","dependency_job_id":"bfa8b8be-922a-4f33-84f7-6d9942da7d6f","html_url":"https://github.com/thomaspoignant/scim-patch","commit_stats":{"total_commits":415,"total_committers":14,"mean_commits":"29.642857142857142","dds":0.3975903614457831,"last_synced_commit":"25334b3e0899e40e22e369d570adb4111779307c"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaspoignant%2Fscim-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaspoignant%2Fscim-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaspoignant%2Fscim-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaspoignant%2Fscim-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomaspoignant","download_url":"https://codeload.github.com/thomaspoignant/scim-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230454432,"owners_count":18228392,"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","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":["library","nodejs","npm-package","patch","patcher","scim","scim-2","scim-patch"],"created_at":"2024-10-15T11:25:48.072Z","updated_at":"2024-12-19T15:10:47.646Z","avatar_url":"https://github.com/thomaspoignant.png","language":"TypeScript","funding_links":["https://github.com/sponsors/thomaspoignant"],"categories":[],"sub_categories":[],"readme":"# SCIM-PATCH\n[![npm version](http://img.shields.io/npm/v/scim-patch.svg?style=flat\u0026color=blue)](https://npmjs.org/package/scim-patch \"View this project on npm\")\n[![Downloads](https://img.shields.io/npm/dt/scim-patch.svg?style=flat\u0026color=blue)](https://npmjs.com/package/scim-patch)\n![Build Status](https://github.com/thomaspoignant/scim-patch/actions/workflows/ci.yml/badge.svg)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fthomaspoignant%2Fscim-patch.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fthomaspoignant%2Fscim-patch?ref=badge_shield)\n[![Coverage Status](https://coveralls.io/repos/github/thomaspoignant/scim-patch/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/thomaspoignant/scim-patch?branch=master\u0026service=github)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=thomaspoignant_scim-patch\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=thomaspoignant_scim-patch)\n\n[RFC7644 SCIM(System for Cross-domain Identity Management) 2.0](https://tools.ietf.org/html/rfc7644#section-3.5.2) implementation of the \"Modifying with PATCH\" section 3.5.2.\n\n## TL;DR\nImportant things to know, this library can :\n - Validate a SCIM Patch query.\n - Patch a SCIM resource from a SCIM Patch Query.\n\nWant to have an example on how it works, [check this example](./example/example.ts).\n\n\n## More Details\nThis library is implementing the `3.5.2.  Modifying with PATCH` chapter of the SCIM RFC https://tools.ietf.org/html/rfc7644#section-3.5.2.  \nIt will allow you to create a SCIM resources and to patch them using the SCIM Query language.\n\n### Validation of a SCIM Query.\n\n```typescript\nimport {patchBodyValidation} from 'scim-patch';\n\nconst scimBody: ScimPatchOperation = \n{\n  'schemas': ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],\n  'Operations': [\n    {op: 'replace', path: 'name.familyName', value: 'newFamilyName'}\n  ]\n};\n\ntry {\n  patchBodyValidation(scimBody);\n} catch (error) {\n  // Here if there are an error in you SCIM request.\n}\n```\n\n### Patch a SCIM resource from a SCIM Patch Query.\n\nThis implements the PATCH of a SCIM object from a SCIM Query.\nYou should create a valid SCIM resource by extending the [ScimResource interface](src/types.ts).\n\n```typescript\nexport interface ScimUser extends ScimResource {\n    schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'];\n    userName: string;\n    name: {\n        familyName: string;\n        givenName: string;\n    };\n    active: boolean;\n    emails: Array\u003c{\n        value: string;\n        primary: boolean;\n    }\u003e;\n    roles?: Array\u003c{\n        value: string;\n        type?: string;\n    }\u003e;\n    meta: ScimMeta \u0026 { resourceType: 'User' };\n};\n```\n\nAfter you have created your object you can patch it by calling the `scimPatch` operation.\n```typescript\nconst scimUser: ScimUser = {\n  schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'],\n  userName: 'user1@test.com',\n  name: { familyName: 'user1', givenName: 'user2' },\n  active: true,\n  emails: [{value: 'user1@test.com', primary: true}],\n  meta: { resourceType: 'User', created: new Date(), lastModified: new Date() }\n};\n\nconst patch: ScimPatchOperation = { op: 'replace', value: { active: false } };\nconst patchedUser = scimPatch(scimUser, patch);\n// scimUser === patchedUser, see Options section if you want to avoid updating the original object\n```\n\nThis particular operation will return : \n```json\n{ \n  \"schemas\": [ \"urn:ietf:params:scim:schemas:core:2.0:User\" ],\n  \"userName\": \"user1@test.com\",\n  \"name\": { \"familyName\": \"user1\", \"givenName\": \"user2\" },\n  \"active\": false,\n  \"emails\": [{\"value\": \"user1@test.com\", \"primary\": true }],\n  \"meta\": { \"resourceType\": \"User\", \"created\": \"2019-12-19T14:36:08.838Z\", \"lastModified\": \"2019-12-19T14:36:08.838Z\" }\n}\n```\n\n#### Options\n\n##### Mutate Document\nBy default `scimPatch()` is updating the scim resource you pass in the function.  \nIf you want to avoid this, you can add an option while calling `scimPatch()`, it will do a copy of the object and work\non this copy.\n\nYour call will look like this now:\n```typescript\nconst patchedUser = scimPatch(scimUser, patch, {mutateDocument: false});\n// scimUser !== patchedUser\n```\n\n##### Treat Missing as Add\n\nBy default `scimPatch()` will treat as Add a replace operation that targets an attribute that does not exist.\nIf you prefer to throw an error instead, then set `treatMissingAsAdd: false`\n\n```typescript \n// scimUser has no addresses\n const patch = {\n    op: 'replace',\n    path: 'addresses[type eq \"work\"].country',\n    value: 'Australia',\n};\nconst patchedUser = scimPatch(scimUser, patch, {treatMissingAsAdd: false});\n// patchedUser.addresses[0].country === \"Australia\"\n```\n\n# How can I contribute?\nSee the [contributor's guide](CONTRIBUTING.md) for some helpful tips.\n\n## Contributors\n\nThanks so much to our contributors.\n\n\u003ca href=\"https://github.com/thomaspoignant/scim-patch/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=thomaspoignant/scim-patch\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaspoignant%2Fscim-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomaspoignant%2Fscim-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaspoignant%2Fscim-patch/lists"}