{"_id":"@ao-framework/serializer","_rev":"1-472de43cbac4f21c690a0901c2274f71","name":"@ao-framework/serializer","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@ao-framework/serializer","version":"0.0.1","description":"The serializer is a library used to convert an instance of anything to a string and a string to an instance of anything. It does so in such a way as to where all of the pointer references remain intact. It allows for a table of constructors to be presente","main":"dist/src/index","types":"dist/src/index.d.ts","scripts":{"test":"jest","dev":"tsc --watch","build":"tsc","doc":"typedoc --out docs src --theme markdown"},"devDependencies":{"@types/jest":"^22.2.0","@types/node":"^10.12.12","jest":"^22.4.2","typedoc":"^0.14.2","typedoc-plugin-markdown":"^1.1.26","typescript":"^2.7.2"},"jest":{"testEnvironment":"node","collectCoverage":true,"collectCoverageFrom":["dist/src/**/*.js","!**dist/src/interface/**"],"verbose":true,"testURL":"http://localhost/"},"directories":{"doc":"docs","test":"test"},"dependencies":{},"repository":{"type":"git","url":"git+https://github.com/ao-framework/serializer.git"},"author":{"name":"Josh Miller"},"license":"MIT","bugs":{"url":"https://github.com/ao-framework/serializer/issues"},"homepage":"https://github.com/ao-framework/serializer#readme","gitHead":"0ac1e0dba5840d1ccd71a34f85b5826c9719a52f","_id":"@ao-framework/serializer@0.0.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"josh-josh-miller","email":"wickedhillsmedia@gmail.com"},"dist":{"integrity":"sha512-ubScP+OwLiLugH5eW6CkUZzxg4M9FaqcYpRI+45BkMeWxGj1uLiK/j0LpT7WLaDcsKRYscSva8OYtzmpCec+Dg==","shasum":"4ade513b6d503e8f9cfc3168834c9e5a4d0677ec","tarball":"https://registry.npmjs.org/@ao-framework/serializer/-/serializer-0.0.1.tgz","fileCount":153,"unpackedSize":120353,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdcKECRA9TVsSAnZWagAABiEP/1krhO/eLIbom8V7yd7A\nZ6auJfp0y72WRnbe4EHN5WI84zmFtykDSWbXi5+XJrq5Cdo6+RjsWG/BBd8F\nbfxqZHqh44ykpou3cMv99vNAXvitGltm7763oMOTHo7VjHspFFbzvRO7gDbi\nOSwfFFbeaT75C3WcK6EnG06TXQD2kaLLIPN3YNe7iA0wihmKkFR70ppHaH6s\n6iD7Xsaz5ismxgXpq/MIBkAEMhjjdbO+o7e5UOLRTslaz3aV+gw99Fi/4cXO\nc1uN4FaXQyKUxDqTAK9JFt/+YqKY4n6OVRNXKs3PFmsl0MfiSSOimqCwsV55\nZt4JKC1Qk0ijacQzAO6GfMlVlQsj/6dnq5PjHRxuyoCsQl4uNzu/mCXYtWAk\nrl6DzNNwToTvlyLPfP5BbjLl6EWXCi5W0Afa66pb0D21dNxBJZZH4RMxEUyg\nCg+8y5PZlQGtyYk42xotkj7l6/8n/2jwusSBKcJToICZJjOjy9Fhxlwyuigw\n0/SNcYyEiW+XrX5JgbXvXN4fQmdai0PkyHkR4kNaIQqw0gZhYwEWmkIKwGxh\n9pvyiQkeZC4tUehbJTpPy3pSm4jju8xmiqMcBiiFXu2xaU3a51dAXE81IF+Y\nCwu1ENUqIQd+VlKiZ7rKpEG02Ip8f3HVg3Cld3FugJzcjFhsmE1rZDvT9zUv\nmc8v\r\n=rDBa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDmhgGm9zKhbblzChJl/TXRIdwPHUnRpa26JSr315EbKQIgHHmadPsAr245SyKRlxc91wwYU2r7zI9uydHz4ZibShQ="}]},"maintainers":[{"name":"josh-josh-miller","email":"wickedhillsmedia@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/serializer_0.0.1_1551221379406_0.6713644435316724"},"_hasShrinkwrap":false}},"time":{"created":"2019-02-26T22:49:39.224Z","0.0.1":"2019-02-26T22:49:39.616Z","modified":"2022-04-04T14:28:27.430Z"},"maintainers":[{"name":"josh-josh-miller","email":"wickedhillsmedia@gmail.com"}],"description":"The serializer is a library used to convert an instance of anything to a string and a string to an instance of anything. It does so in such a way as to where all of the pointer references remain intact. It allows for a table of constructors to be presente","homepage":"https://github.com/ao-framework/serializer#readme","repository":{"type":"git","url":"git+https://github.com/ao-framework/serializer.git"},"author":{"name":"Josh Miller"},"bugs":{"url":"https://github.com/ao-framework/serializer/issues"},"license":"MIT","readme":"<p align=\"center\">\r\n<img width=\"150\" src=\"./assets/ao.logo.svg\"><br>\r\n<b>Serializer</b>\r\n</p>\r\n\r\nThe serializer is a library used to convert an instance of anything to a string and a string to an instance of anything. It does so in such a way as to where all of the pointer references remain intact. It allows for a table of constructors to be presented so that context, on deserialization, could be remembered or changed. It’s an appropriate tool for cloning instances with deeply nested structures. **However, be advised serializing state to disk without encrypting and signing is a dangerous practice that should be avoided at all cost.**\r\n\r\n#### Import the library\r\n```ts\r\nimport Serializer from \"@ao-framework/serializer\"\r\n```\r\n#### Lets say we have a model \r\n```ts\r\nnamespace Model {\r\n  \r\n  export class User {\r\n      public self: User;\r\n      public name: string;\r\n      public email: string;\r\n  }\r\n\r\n  export class Note {\r\n      public title: string;\r\n      public content: string;\r\n  }\r\n\r\n}\r\n```\r\n\r\n#### Set up context\r\n```ts\r\nlet serializer = new Serializer(Model, \"name-of-context\")\r\n```\r\n\r\n#### Work with your models\r\n```ts\r\nlet user = new User();\r\nuser.self = user;\r\nuser.name = \"Something\";\r\nuser.email = \"Something@gmail.com\"\r\n```\r\n\r\n#### Serialize\r\n```ts\r\nlet userString = serializer.down(user);\r\n```\r\n\r\n#### De-serialize\r\n```ts\r\nlet newUser = serializer.up(userString);\r\n```\r\n\r\n#### Did it work?\r\n```ts\r\nconsole.log(newUser.self === newUser) //outputs: true\r\n```\r\n\r\n### Security Considerations\r\nSerializing state down to a string and reviving it to its original state\r\nwithout validation raises strong security concerns. Encrypt and sign everything!\r\n\r\n<blockquote>\r\n    \"Be Kind and <strike>Please Rewind</strike> Encrypt Everything\"\r\n</blockquote>\r\n","readmeFilename":"README.md"}