UUID Paw Extension

While working on API's I like to user various tools to test endpoints, and in the past I would use the Google Chrome extension POSTman, which I would highly recommend. Recently though I have started using the Map application Paw, which despite costing money, is well worth the cost.

One benefit of Paw is that it comes with many built in exentsions, as well as the ability to create your own. While working on Perk.com's API, I needed a way to generate different device identifiers such as IDFA, IDFV's and more, which are typically in the format of UUID's. Unfortunately Paw doesn't have a built in UUID generator, so I decided to create my own. Paw's extensions are built on JavaScript code, and even support being written in CoffeeScript if your into that sort of thing, so creating the extension was rather easy. I decided to try my hand at CoffeeScript and came up with the following script:

1RandomUuidValue = ->
2 @evaluate = (context) ->
3 "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace /[xy]/g, (c) ->
4 r = Math.random() * 16 | 0
5 v = (if c is "x" then r else (r & 0x3 | 0x8))
6 v.toString 16
7
8 @title = ->
9 "UUID"
10
11 return
12
13RandomUuidValue.identifier = "com.hskrasek.PawExtensions.RandomUuidValue"
14RandomUuidValue.title = "Generate Random UUID"
15RandomUuidValue.inputs = []
16registerDynamicValueClass RandomUuidValue

Once this has been compiled into JavaScript, Paw can use this to generate UUID4's wherever you may need them. I have been trying to get the extension listed on the site, which makes installation easier, but unfortunately haven't had much luck. If you'd like to use this extension though, you can install it with the following commands:

1cd ~/Library/Containers/com.luckymarmot.Paw/Data/Library/Application\ Support/com.luckymarmot.Paw/Extensions
2git clone https://github.com/hskrasek/Paw-UUIDDynamicValue com.hskrasek.PawExtensions.RandomUuidValue

And then if you open Paw, it will be available under the extensions menu. If you already have Paw open you can open Preferences, go to the Extensions tab, and click Reload Installed Extensions, and you should be good to go.

If you'd like to contribute to this extension, please feel free to open a pull request on Github.