├── .env ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── api_docs.md ├── build ├── index.html ├── manual_tests.html ├── manual_tests_cosmos.html ├── manual_tests_error_messages.html ├── manual_tests_evm_contract_conditions.html ├── manual_tests_files.html ├── manual_tests_sol.html └── manual_tests_unified.html ├── create_subpackage_packagejson.sh ├── docs ├── api_docs_html │ ├── assets │ │ ├── anchor.js │ │ ├── bass-addons.css │ │ ├── bass.css │ │ ├── fonts │ │ │ ├── EOT │ │ │ │ ├── SourceCodePro-Bold.eot │ │ │ │ └── SourceCodePro-Regular.eot │ │ │ ├── LICENSE.txt │ │ │ ├── OTF │ │ │ │ ├── SourceCodePro-Bold.otf │ │ │ │ └── SourceCodePro-Regular.otf │ │ │ ├── TTF │ │ │ │ ├── SourceCodePro-Bold.ttf │ │ │ │ └── SourceCodePro-Regular.ttf │ │ │ ├── WOFF │ │ │ │ ├── OTF │ │ │ │ │ ├── SourceCodePro-Bold.otf.woff │ │ │ │ │ └── SourceCodePro-Regular.otf.woff │ │ │ │ └── TTF │ │ │ │ │ ├── SourceCodePro-Bold.ttf.woff │ │ │ │ │ └── SourceCodePro-Regular.ttf.woff │ │ │ ├── WOFF2 │ │ │ │ ├── OTF │ │ │ │ │ ├── SourceCodePro-Bold.otf.woff2 │ │ │ │ │ └── SourceCodePro-Regular.otf.woff2 │ │ │ │ └── TTF │ │ │ │ │ ├── SourceCodePro-Bold.ttf.woff2 │ │ │ │ │ └── SourceCodePro-Regular.ttf.woff2 │ │ │ └── source-code-pro.css │ │ ├── github.css │ │ ├── site.js │ │ ├── split.css │ │ ├── split.js │ │ └── style.css │ └── index.html └── index.html ├── docs_md ├── documentation.yml ├── esbuild-nodejs-shims.js ├── esbuild-nodejs.js ├── esbuild-plugins.js ├── esbuild-tests.js ├── esbuild-web-shims.js ├── esbuild-web.js ├── gen_docs.sh ├── package.json ├── packages ├── sdk-browser-standalone │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── package.json │ └── package.json.template ├── sdk-browser │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── package.json │ └── package.json.template └── sdk-nodejs │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── package.json │ └── package.json.template ├── publish.sh ├── src ├── abis │ ├── ERC20.json │ └── LIT.json ├── index.js ├── lib │ ├── bls-sdk.js │ ├── constants.js │ ├── uint8arrays.js │ └── utils.js ├── utils │ ├── browser.js │ ├── cosmos.js │ ├── crypto.js │ ├── eth.js │ ├── frameComms.js │ ├── init.js │ ├── lit.js │ ├── litNodeClient.js │ └── sol.js └── version.js ├── tests.md ├── tests ├── constants.js ├── provisioningAndSigning.js └── utils.js └── yarn.lock /.env: -------------------------------------------------------------------------------- 1 | FAST_REFRESH=false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Before reporting, I have already *** 11 | - checked LIT Protocol [developer docs](https://developer.litprotocol.com/) and/or the [lit-js-sdk](https://lit-protocol.github.io/lit-js-sdk/api_docs_html/). 12 | - searched for other [open issues](https://github.com/LIT-Protocol/lit-js-sdk/issues). 13 | - verified the correctness of my access control condition in the [Debugger](https://lit-accs-debugger.vercel.app/), if the issue is regarding access control conditions 14 | - checked out Lit's [Discord](https://discord.com/invite/GnTtFukpHq) with a keyword search 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **To Reproduce** 20 | Steps to reproduce the behavior: 21 | 1. Go to '...' 22 | 2. Click on '....' 23 | 3. Scroll down to '....' 24 | 4. See error 25 | 26 | **Expected behavior** 27 | A clear and concise description of what you expected to happen. 28 | 29 | **Screenshots** 30 | If applicable, add screenshots to help explain your problem. 31 | 32 | **Environment:** 33 | - Lit SDK version (including the network (ie, "serrano") if different, and type - browser or backend) 34 | - Node version 35 | - Framework (React, Vue, Angular, Svelte - just Plain HTML!, etc) 36 | - Specific tooling (Webpack, Vite, browserify, etc) 37 | 38 | **Additional info** 39 | Add any other context about the problem here. 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build/index*.js 14 | /build/index*.js.map 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .idea 28 | 29 | packages/sdk-nodejs/node_modules -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | packages/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 WorkGraph Inc 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - [Deprecated](#deprecated) 5 | - [Lit Protocol JS SDK V1](#lit-protocol-js-sdk-v1) 6 | - [Support](#support) 7 | - [Publishing](#publishing) 8 | 9 | 10 | 11 | # Deprecated 12 | 13 | This SDK is deprecated and will only receive critical security updates. Please use our new typescript sdk here: https://github.com/LIT-Protocol/js-sdk 14 | 15 | There is a migration guide here: https://developer.litprotocol.com/SDK/Explanation/migration 16 | 17 | ## Lit Protocol JS SDK V1 18 | 19 | Docs for the JS SDK live here: https://developer.litprotocol.com/docs/SDK/intro 20 | 21 | ## Support 22 | 23 | If you need help, join our discord: https://litgateway.com/discord 24 | 25 | ## Publishing 26 | 27 | To publish, use ./publish.sh and select "patch" for your version bump. You must have the "documentation" package installed globally on NPM which you can do with `npm install -g documentation`. You must also have the "jq" program installed, which you can install on mac with `brew install jq`. Only members of the Lit Protocol team can publish to NPM. 28 | -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This is the LIT JS SDK CDN. You may find the web version of the LIT JS SDK at /index.web.js and embed it using the script tag in any HTML website. Read more here: https://github.com/LIT-Protocol/lit-js-sdk 4 | 5 | -------------------------------------------------------------------------------- /build/manual_tests_cosmos.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Manual Tests V2 6 | 7 | 11 | 15 | 345 | 346 | 347 | 348 |

Manual tests

349 |
350 |
351 |
Connecting to Lit Protocol Network...
352 |
353 |
354 | 355 |
356 |
357 | 358 |
359 |
360 | 361 | 364 |
365 |
366 | 369 |
370 |
371 | 372 | 373 |
374 |
375 | 378 |
379 |
380 | 381 | 384 |
385 |
386 | 387 | 390 |
391 |
392 | 393 | 394 |
395 |
396 |

397 |
398 |

399 | 400 | 401 | -------------------------------------------------------------------------------- /build/manual_tests_files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Unified Access Control Conditions 6 | 7 | 11 | 15 | 178 | 179 | 180 | 181 |

Manual tests

182 |
183 |
184 |
Connecting to Lit Protocol Network...
185 |
186 |
187 | 188 |
189 |
190 | 191 |
192 |
193 | 194 |
195 |
196 | 197 | 198 |
199 |
200 |

201 |     
202 |

203 |
204 |

205 | 206 | 207 | -------------------------------------------------------------------------------- /build/manual_tests_sol.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Manual Tests V2 6 | 7 | 11 | 15 | 469 | 470 | 471 | 472 |

Manual tests

473 |
474 |
475 |
Connecting to Lit Protocol Network...
476 |
477 |
478 | 479 |
480 |
481 | 482 |
483 |
484 | 485 | 486 |
487 |
488 | 489 | 492 |
493 |
494 | 495 | 498 |
499 |
500 | 503 |
504 |
505 | 506 | 509 |
510 |
511 | 514 |
515 |
516 | 517 | 520 |
521 |
522 | 523 | 524 |
525 |
526 | 527 | 530 |
531 |
532 | 533 | 534 |
535 |
536 | 537 | 538 |
539 |
540 | 541 | 542 |
543 |
544 | 545 | 546 |
547 |
548 |

549 |
550 |

551 | 552 | 553 | -------------------------------------------------------------------------------- /build/manual_tests_unified.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Unified Access Control Conditions 6 | 7 | 11 | 15 | 390 | 391 | 392 | 393 |

Manual tests

394 |
395 |
396 |
Connecting to Lit Protocol Network...
397 |
398 |
399 | 400 |
401 |
402 | 403 |
404 |
405 | 406 | 407 |
408 |
409 | 410 | 413 |
414 |
415 | 416 | 417 |
418 |
419 |

420 |
421 |

422 | 423 | 424 | -------------------------------------------------------------------------------- /create_subpackage_packagejson.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | DEPS="$(cat package.json | jq .dependencies)" 5 | DEV_DEPS="$(cat package.json | jq .devDependencies)" 6 | 7 | cat packages/sdk-browser/package.json.template | jq ".dependencies|=$DEPS | .devDependencies|=$DEV_DEPS" > packages/sdk-browser/package.json 8 | 9 | cat packages/sdk-browser-standalone/package.json.template | jq ".dependencies|=$DEPS | .devDependencies|=$DEV_DEPS" > packages/sdk-browser-standalone/package.json 10 | 11 | cat packages/sdk-nodejs/package.json.template | jq ".dependencies|=$DEPS | .devDependencies|=$DEV_DEPS" > packages/sdk-nodejs/package.json 12 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/anchor.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * AnchorJS - v4.0.0 - 2017-06-02 3 | * https://github.com/bryanbraun/anchorjs 4 | * Copyright (c) 2017 Bryan Braun; Licensed MIT 5 | */ 6 | /* eslint-env amd, node */ 7 | 8 | // https://github.com/umdjs/umd/blob/master/templates/returnExports.js 9 | (function (root, factory) { 10 | 'use strict'; 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define([], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node. Does not work with strict CommonJS, but 16 | // only CommonJS-like environments that support module.exports, 17 | // like Node. 18 | module.exports = factory(); 19 | } else { 20 | // Browser globals (root is window) 21 | root.AnchorJS = factory(); 22 | root.anchors = new root.AnchorJS(); 23 | } 24 | })(this, function () { 25 | 'use strict'; 26 | function AnchorJS(options) { 27 | this.options = options || {}; 28 | this.elements = []; 29 | 30 | /** 31 | * Assigns options to the internal options object, and provides defaults. 32 | * @param {Object} opts - Options object 33 | */ 34 | function _applyRemainingDefaultOptions(opts) { 35 | opts.icon = opts.hasOwnProperty('icon') ? opts.icon : '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'. 36 | opts.visible = opts.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always' & 'touch' 37 | opts.placement = opts.hasOwnProperty('placement') 38 | ? opts.placement 39 | : 'right'; // Also accepts 'left' 40 | opts.class = opts.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name. 41 | // Using Math.floor here will ensure the value is Number-cast and an integer. 42 | opts.truncate = opts.hasOwnProperty('truncate') 43 | ? Math.floor(opts.truncate) 44 | : 64; // Accepts any value that can be typecast to a number. 45 | } 46 | 47 | _applyRemainingDefaultOptions(this.options); 48 | 49 | /** 50 | * Checks to see if this device supports touch. Uses criteria pulled from Modernizr: 51 | * https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40 52 | * @returns {Boolean} - true if the current device supports touch. 53 | */ 54 | this.isTouchDevice = function () { 55 | return !!( 56 | 'ontouchstart' in window || 57 | (window.DocumentTouch && document instanceof DocumentTouch) 58 | ); 59 | }; 60 | 61 | /** 62 | * Add anchor links to page elements. 63 | * @param {String|Array|Nodelist} selector - A CSS selector for targeting the elements you wish to add anchor links 64 | * to. Also accepts an array or nodeList containing the relavant elements. 65 | * @returns {this} - The AnchorJS object 66 | */ 67 | this.add = function (selector) { 68 | var elements, 69 | elsWithIds, 70 | idList, 71 | elementID, 72 | i, 73 | index, 74 | count, 75 | tidyText, 76 | newTidyText, 77 | readableID, 78 | anchor, 79 | visibleOptionToUse, 80 | indexesToDrop = []; 81 | 82 | // We reapply options here because somebody may have overwritten the default options object when setting options. 83 | // For example, this overwrites all options but visible: 84 | // 85 | // anchors.options = { visible: 'always'; } 86 | _applyRemainingDefaultOptions(this.options); 87 | 88 | visibleOptionToUse = this.options.visible; 89 | if (visibleOptionToUse === 'touch') { 90 | visibleOptionToUse = this.isTouchDevice() ? 'always' : 'hover'; 91 | } 92 | 93 | // Provide a sensible default selector, if none is given. 94 | if (!selector) { 95 | selector = 'h2, h3, h4, h5, h6'; 96 | } 97 | 98 | elements = _getElements(selector); 99 | 100 | if (elements.length === 0) { 101 | return this; 102 | } 103 | 104 | _addBaselineStyles(); 105 | 106 | // We produce a list of existing IDs so we don't generate a duplicate. 107 | elsWithIds = document.querySelectorAll('[id]'); 108 | idList = [].map.call(elsWithIds, function assign(el) { 109 | return el.id; 110 | }); 111 | 112 | for (i = 0; i < elements.length; i++) { 113 | if (this.hasAnchorJSLink(elements[i])) { 114 | indexesToDrop.push(i); 115 | continue; 116 | } 117 | 118 | if (elements[i].hasAttribute('id')) { 119 | elementID = elements[i].getAttribute('id'); 120 | } else if (elements[i].hasAttribute('data-anchor-id')) { 121 | elementID = elements[i].getAttribute('data-anchor-id'); 122 | } else { 123 | tidyText = this.urlify(elements[i].textContent); 124 | 125 | // Compare our generated ID to existing IDs (and increment it if needed) 126 | // before we add it to the page. 127 | newTidyText = tidyText; 128 | count = 0; 129 | do { 130 | if (index !== undefined) { 131 | newTidyText = tidyText + '-' + count; 132 | } 133 | 134 | index = idList.indexOf(newTidyText); 135 | count += 1; 136 | } while (index !== -1); 137 | index = undefined; 138 | idList.push(newTidyText); 139 | 140 | elements[i].setAttribute('id', newTidyText); 141 | elementID = newTidyText; 142 | } 143 | 144 | readableID = elementID.replace(/-/g, ' '); 145 | 146 | // The following code builds the following DOM structure in a more effiecient (albeit opaque) way. 147 | // ''; 148 | anchor = document.createElement('a'); 149 | anchor.className = 'anchorjs-link ' + this.options.class; 150 | anchor.href = '#' + elementID; 151 | anchor.setAttribute('aria-label', 'Anchor link for: ' + readableID); 152 | anchor.setAttribute('data-anchorjs-icon', this.options.icon); 153 | 154 | if (visibleOptionToUse === 'always') { 155 | anchor.style.opacity = '1'; 156 | } 157 | 158 | if (this.options.icon === '\ue9cb') { 159 | anchor.style.font = '1em/1 anchorjs-icons'; 160 | 161 | // We set lineHeight = 1 here because the `anchorjs-icons` font family could otherwise affect the 162 | // height of the heading. This isn't the case for icons with `placement: left`, so we restore 163 | // line-height: inherit in that case, ensuring they remain positioned correctly. For more info, 164 | // see https://github.com/bryanbraun/anchorjs/issues/39. 165 | if (this.options.placement === 'left') { 166 | anchor.style.lineHeight = 'inherit'; 167 | } 168 | } 169 | 170 | if (this.options.placement === 'left') { 171 | anchor.style.position = 'absolute'; 172 | anchor.style.marginLeft = '-1em'; 173 | anchor.style.paddingRight = '0.5em'; 174 | elements[i].insertBefore(anchor, elements[i].firstChild); 175 | } else { 176 | // if the option provided is `right` (or anything else). 177 | anchor.style.paddingLeft = '0.375em'; 178 | elements[i].appendChild(anchor); 179 | } 180 | } 181 | 182 | for (i = 0; i < indexesToDrop.length; i++) { 183 | elements.splice(indexesToDrop[i] - i, 1); 184 | } 185 | this.elements = this.elements.concat(elements); 186 | 187 | return this; 188 | }; 189 | 190 | /** 191 | * Removes all anchorjs-links from elements targed by the selector. 192 | * @param {String|Array|Nodelist} selector - A CSS selector string targeting elements with anchor links, 193 | * OR a nodeList / array containing the DOM elements. 194 | * @returns {this} - The AnchorJS object 195 | */ 196 | this.remove = function (selector) { 197 | var index, 198 | domAnchor, 199 | elements = _getElements(selector); 200 | 201 | for (var i = 0; i < elements.length; i++) { 202 | domAnchor = elements[i].querySelector('.anchorjs-link'); 203 | if (domAnchor) { 204 | // Drop the element from our main list, if it's in there. 205 | index = this.elements.indexOf(elements[i]); 206 | if (index !== -1) { 207 | this.elements.splice(index, 1); 208 | } 209 | // Remove the anchor from the DOM. 210 | elements[i].removeChild(domAnchor); 211 | } 212 | } 213 | return this; 214 | }; 215 | 216 | /** 217 | * Removes all anchorjs links. Mostly used for tests. 218 | */ 219 | this.removeAll = function () { 220 | this.remove(this.elements); 221 | }; 222 | 223 | /** 224 | * Urlify - Refine text so it makes a good ID. 225 | * 226 | * To do this, we remove apostrophes, replace nonsafe characters with hyphens, 227 | * remove extra hyphens, truncate, trim hyphens, and make lowercase. 228 | * 229 | * @param {String} text - Any text. Usually pulled from the webpage element we are linking to. 230 | * @returns {String} - hyphen-delimited text for use in IDs and URLs. 231 | */ 232 | this.urlify = function (text) { 233 | // Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\ 234 | var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g, 235 | urlText; 236 | 237 | // The reason we include this _applyRemainingDefaultOptions is so urlify can be called independently, 238 | // even after setting options. This can be useful for tests or other applications. 239 | if (!this.options.truncate) { 240 | _applyRemainingDefaultOptions(this.options); 241 | } 242 | 243 | // Note: we trim hyphens after truncating because truncating can cause dangling hyphens. 244 | // Example string: // " ⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." 245 | urlText = text 246 | .trim() // "⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." 247 | .replace(/\'/gi, '') // "⚡⚡ Dont forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." 248 | .replace(nonsafeChars, '-') // "⚡⚡-Dont-forget--URL-fragments-should-be-i18n-friendly--hyphenated--short--and-clean-" 249 | .replace(/-{2,}/g, '-') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-short-and-clean-" 250 | .substring(0, this.options.truncate) // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-" 251 | .replace(/^-+|-+$/gm, '') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated" 252 | .toLowerCase(); // "⚡⚡-dont-forget-url-fragments-should-be-i18n-friendly-hyphenated" 253 | 254 | return urlText; 255 | }; 256 | 257 | /** 258 | * Determines if this element already has an AnchorJS link on it. 259 | * Uses this technique: http://stackoverflow.com/a/5898748/1154642 260 | * @param {HTMLElemnt} el - a DOM node 261 | * @returns {Boolean} true/false 262 | */ 263 | this.hasAnchorJSLink = function (el) { 264 | var hasLeftAnchor = 265 | el.firstChild && 266 | (' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1, 267 | hasRightAnchor = 268 | el.lastChild && 269 | (' ' + el.lastChild.className + ' ').indexOf(' anchorjs-link ') > -1; 270 | 271 | return hasLeftAnchor || hasRightAnchor || false; 272 | }; 273 | 274 | /** 275 | * Turns a selector, nodeList, or array of elements into an array of elements (so we can use array methods). 276 | * It also throws errors on any other inputs. Used to handle inputs to .add and .remove. 277 | * @param {String|Array|Nodelist} input - A CSS selector string targeting elements with anchor links, 278 | * OR a nodeList / array containing the DOM elements. 279 | * @returns {Array} - An array containing the elements we want. 280 | */ 281 | function _getElements(input) { 282 | var elements; 283 | if (typeof input === 'string' || input instanceof String) { 284 | // See https://davidwalsh.name/nodelist-array for the technique transforming nodeList -> Array. 285 | elements = [].slice.call(document.querySelectorAll(input)); 286 | // I checked the 'input instanceof NodeList' test in IE9 and modern browsers and it worked for me. 287 | } else if (Array.isArray(input) || input instanceof NodeList) { 288 | elements = [].slice.call(input); 289 | } else { 290 | throw new Error('The selector provided to AnchorJS was invalid.'); 291 | } 292 | return elements; 293 | } 294 | 295 | /** 296 | * _addBaselineStyles 297 | * Adds baseline styles to the page, used by all AnchorJS links irregardless of configuration. 298 | */ 299 | function _addBaselineStyles() { 300 | // We don't want to add global baseline styles if they've been added before. 301 | if (document.head.querySelector('style.anchorjs') !== null) { 302 | return; 303 | } 304 | 305 | var style = document.createElement('style'), 306 | linkRule = 307 | ' .anchorjs-link {' + 308 | ' opacity: 0;' + 309 | ' text-decoration: none;' + 310 | ' -webkit-font-smoothing: antialiased;' + 311 | ' -moz-osx-font-smoothing: grayscale;' + 312 | ' }', 313 | hoverRule = 314 | ' *:hover > .anchorjs-link,' + 315 | ' .anchorjs-link:focus {' + 316 | ' opacity: 1;' + 317 | ' }', 318 | anchorjsLinkFontFace = 319 | ' @font-face {' + 320 | ' font-family: "anchorjs-icons";' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above 321 | ' src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype");' + 322 | ' }', 323 | pseudoElContent = 324 | ' [data-anchorjs-icon]::after {' + 325 | ' content: attr(data-anchorjs-icon);' + 326 | ' }', 327 | firstStyleEl; 328 | 329 | style.className = 'anchorjs'; 330 | style.appendChild(document.createTextNode('')); // Necessary for Webkit. 331 | 332 | // We place it in the head with the other style tags, if possible, so as to 333 | // not look out of place. We insert before the others so these styles can be 334 | // overridden if necessary. 335 | firstStyleEl = document.head.querySelector('[rel="stylesheet"], style'); 336 | if (firstStyleEl === undefined) { 337 | document.head.appendChild(style); 338 | } else { 339 | document.head.insertBefore(style, firstStyleEl); 340 | } 341 | 342 | style.sheet.insertRule(linkRule, style.sheet.cssRules.length); 343 | style.sheet.insertRule(hoverRule, style.sheet.cssRules.length); 344 | style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length); 345 | style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length); 346 | } 347 | } 348 | 349 | return AnchorJS; 350 | }); 351 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/bass-addons.css: -------------------------------------------------------------------------------- 1 | .input { 2 | font-family: inherit; 3 | display: block; 4 | width: 100%; 5 | height: 2rem; 6 | padding: .5rem; 7 | margin-bottom: 1rem; 8 | border: 1px solid #ccc; 9 | font-size: .875rem; 10 | border-radius: 3px; 11 | box-sizing: border-box; 12 | } 13 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/bass.css: -------------------------------------------------------------------------------- 1 | /*! Basscss | http://basscss.com | MIT License */ 2 | 3 | .h1{ font-size: 2rem } 4 | .h2{ font-size: 1.5rem } 5 | .h3{ font-size: 1.25rem } 6 | .h4{ font-size: 1rem } 7 | .h5{ font-size: .875rem } 8 | .h6{ font-size: .75rem } 9 | 10 | .font-family-inherit{ font-family:inherit } 11 | .font-size-inherit{ font-size:inherit } 12 | .text-decoration-none{ text-decoration:none } 13 | 14 | .bold{ font-weight: bold; font-weight: bold } 15 | .regular{ font-weight:normal } 16 | .italic{ font-style:italic } 17 | .caps{ text-transform:uppercase; letter-spacing: .2em; } 18 | 19 | .left-align{ text-align:left } 20 | .center{ text-align:center } 21 | .right-align{ text-align:right } 22 | .justify{ text-align:justify } 23 | 24 | .nowrap{ white-space:nowrap } 25 | .break-word{ word-wrap:break-word } 26 | 27 | .line-height-1{ line-height: 1 } 28 | .line-height-2{ line-height: 1.125 } 29 | .line-height-3{ line-height: 1.25 } 30 | .line-height-4{ line-height: 1.5 } 31 | 32 | .list-style-none{ list-style:none } 33 | .underline{ text-decoration:underline } 34 | 35 | .truncate{ 36 | max-width:100%; 37 | overflow:hidden; 38 | text-overflow:ellipsis; 39 | white-space:nowrap; 40 | } 41 | 42 | .list-reset{ 43 | list-style:none; 44 | padding-left:0; 45 | } 46 | 47 | .inline{ display:inline } 48 | .block{ display:block } 49 | .inline-block{ display:inline-block } 50 | .table{ display:table } 51 | .table-cell{ display:table-cell } 52 | 53 | .overflow-hidden{ overflow:hidden } 54 | .overflow-scroll{ overflow:scroll } 55 | .overflow-auto{ overflow:auto } 56 | 57 | .clearfix:before, 58 | .clearfix:after{ 59 | content:" "; 60 | display:table 61 | } 62 | .clearfix:after{ clear:both } 63 | 64 | .left{ float:left } 65 | .right{ float:right } 66 | 67 | .fit{ max-width:100% } 68 | 69 | .max-width-1{ max-width: 24rem } 70 | .max-width-2{ max-width: 32rem } 71 | .max-width-3{ max-width: 48rem } 72 | .max-width-4{ max-width: 64rem } 73 | 74 | .border-box{ box-sizing:border-box } 75 | 76 | .align-baseline{ vertical-align:baseline } 77 | .align-top{ vertical-align:top } 78 | .align-middle{ vertical-align:middle } 79 | .align-bottom{ vertical-align:bottom } 80 | 81 | .m0{ margin:0 } 82 | .mt0{ margin-top:0 } 83 | .mr0{ margin-right:0 } 84 | .mb0{ margin-bottom:0 } 85 | .ml0{ margin-left:0 } 86 | .mx0{ margin-left:0; margin-right:0 } 87 | .my0{ margin-top:0; margin-bottom:0 } 88 | 89 | .m1{ margin: .5rem } 90 | .mt1{ margin-top: .5rem } 91 | .mr1{ margin-right: .5rem } 92 | .mb1{ margin-bottom: .5rem } 93 | .ml1{ margin-left: .5rem } 94 | .mx1{ margin-left: .5rem; margin-right: .5rem } 95 | .my1{ margin-top: .5rem; margin-bottom: .5rem } 96 | 97 | .m2{ margin: 1rem } 98 | .mt2{ margin-top: 1rem } 99 | .mr2{ margin-right: 1rem } 100 | .mb2{ margin-bottom: 1rem } 101 | .ml2{ margin-left: 1rem } 102 | .mx2{ margin-left: 1rem; margin-right: 1rem } 103 | .my2{ margin-top: 1rem; margin-bottom: 1rem } 104 | 105 | .m3{ margin: 2rem } 106 | .mt3{ margin-top: 2rem } 107 | .mr3{ margin-right: 2rem } 108 | .mb3{ margin-bottom: 2rem } 109 | .ml3{ margin-left: 2rem } 110 | .mx3{ margin-left: 2rem; margin-right: 2rem } 111 | .my3{ margin-top: 2rem; margin-bottom: 2rem } 112 | 113 | .m4{ margin: 4rem } 114 | .mt4{ margin-top: 4rem } 115 | .mr4{ margin-right: 4rem } 116 | .mb4{ margin-bottom: 4rem } 117 | .ml4{ margin-left: 4rem } 118 | .mx4{ margin-left: 4rem; margin-right: 4rem } 119 | .my4{ margin-top: 4rem; margin-bottom: 4rem } 120 | 121 | .mxn1{ margin-left: -.5rem; margin-right: -.5rem; } 122 | .mxn2{ margin-left: -1rem; margin-right: -1rem; } 123 | .mxn3{ margin-left: -2rem; margin-right: -2rem; } 124 | .mxn4{ margin-left: -4rem; margin-right: -4rem; } 125 | 126 | .ml-auto{ margin-left:auto } 127 | .mr-auto{ margin-right:auto } 128 | .mx-auto{ margin-left:auto; margin-right:auto; } 129 | 130 | .p0{ padding:0 } 131 | .pt0{ padding-top:0 } 132 | .pr0{ padding-right:0 } 133 | .pb0{ padding-bottom:0 } 134 | .pl0{ padding-left:0 } 135 | .px0{ padding-left:0; padding-right:0 } 136 | .py0{ padding-top:0; padding-bottom:0 } 137 | 138 | .p1{ padding: .5rem } 139 | .pt1{ padding-top: .5rem } 140 | .pr1{ padding-right: .5rem } 141 | .pb1{ padding-bottom: .5rem } 142 | .pl1{ padding-left: .5rem } 143 | .py1{ padding-top: .5rem; padding-bottom: .5rem } 144 | .px1{ padding-left: .5rem; padding-right: .5rem } 145 | 146 | .p2{ padding: 1rem } 147 | .pt2{ padding-top: 1rem } 148 | .pr2{ padding-right: 1rem } 149 | .pb2{ padding-bottom: 1rem } 150 | .pl2{ padding-left: 1rem } 151 | .py2{ padding-top: 1rem; padding-bottom: 1rem } 152 | .px2{ padding-left: 1rem; padding-right: 1rem } 153 | 154 | .p3{ padding: 2rem } 155 | .pt3{ padding-top: 2rem } 156 | .pr3{ padding-right: 2rem } 157 | .pb3{ padding-bottom: 2rem } 158 | .pl3{ padding-left: 2rem } 159 | .py3{ padding-top: 2rem; padding-bottom: 2rem } 160 | .px3{ padding-left: 2rem; padding-right: 2rem } 161 | 162 | .p4{ padding: 4rem } 163 | .pt4{ padding-top: 4rem } 164 | .pr4{ padding-right: 4rem } 165 | .pb4{ padding-bottom: 4rem } 166 | .pl4{ padding-left: 4rem } 167 | .py4{ padding-top: 4rem; padding-bottom: 4rem } 168 | .px4{ padding-left: 4rem; padding-right: 4rem } 169 | 170 | .col{ 171 | float:left; 172 | box-sizing:border-box; 173 | } 174 | 175 | .col-right{ 176 | float:right; 177 | box-sizing:border-box; 178 | } 179 | 180 | .col-1{ 181 | width:8.33333%; 182 | } 183 | 184 | .col-2{ 185 | width:16.66667%; 186 | } 187 | 188 | .col-3{ 189 | width:25%; 190 | } 191 | 192 | .col-4{ 193 | width:33.33333%; 194 | } 195 | 196 | .col-5{ 197 | width:41.66667%; 198 | } 199 | 200 | .col-6{ 201 | width:50%; 202 | } 203 | 204 | .col-7{ 205 | width:58.33333%; 206 | } 207 | 208 | .col-8{ 209 | width:66.66667%; 210 | } 211 | 212 | .col-9{ 213 | width:75%; 214 | } 215 | 216 | .col-10{ 217 | width:83.33333%; 218 | } 219 | 220 | .col-11{ 221 | width:91.66667%; 222 | } 223 | 224 | .col-12{ 225 | width:100%; 226 | } 227 | @media (min-width: 40em){ 228 | 229 | .sm-col{ 230 | float:left; 231 | box-sizing:border-box; 232 | } 233 | 234 | .sm-col-right{ 235 | float:right; 236 | box-sizing:border-box; 237 | } 238 | 239 | .sm-col-1{ 240 | width:8.33333%; 241 | } 242 | 243 | .sm-col-2{ 244 | width:16.66667%; 245 | } 246 | 247 | .sm-col-3{ 248 | width:25%; 249 | } 250 | 251 | .sm-col-4{ 252 | width:33.33333%; 253 | } 254 | 255 | .sm-col-5{ 256 | width:41.66667%; 257 | } 258 | 259 | .sm-col-6{ 260 | width:50%; 261 | } 262 | 263 | .sm-col-7{ 264 | width:58.33333%; 265 | } 266 | 267 | .sm-col-8{ 268 | width:66.66667%; 269 | } 270 | 271 | .sm-col-9{ 272 | width:75%; 273 | } 274 | 275 | .sm-col-10{ 276 | width:83.33333%; 277 | } 278 | 279 | .sm-col-11{ 280 | width:91.66667%; 281 | } 282 | 283 | .sm-col-12{ 284 | width:100%; 285 | } 286 | 287 | } 288 | @media (min-width: 52em){ 289 | 290 | .md-col{ 291 | float:left; 292 | box-sizing:border-box; 293 | } 294 | 295 | .md-col-right{ 296 | float:right; 297 | box-sizing:border-box; 298 | } 299 | 300 | .md-col-1{ 301 | width:8.33333%; 302 | } 303 | 304 | .md-col-2{ 305 | width:16.66667%; 306 | } 307 | 308 | .md-col-3{ 309 | width:25%; 310 | } 311 | 312 | .md-col-4{ 313 | width:33.33333%; 314 | } 315 | 316 | .md-col-5{ 317 | width:41.66667%; 318 | } 319 | 320 | .md-col-6{ 321 | width:50%; 322 | } 323 | 324 | .md-col-7{ 325 | width:58.33333%; 326 | } 327 | 328 | .md-col-8{ 329 | width:66.66667%; 330 | } 331 | 332 | .md-col-9{ 333 | width:75%; 334 | } 335 | 336 | .md-col-10{ 337 | width:83.33333%; 338 | } 339 | 340 | .md-col-11{ 341 | width:91.66667%; 342 | } 343 | 344 | .md-col-12{ 345 | width:100%; 346 | } 347 | 348 | } 349 | @media (min-width: 64em){ 350 | 351 | .lg-col{ 352 | float:left; 353 | box-sizing:border-box; 354 | } 355 | 356 | .lg-col-right{ 357 | float:right; 358 | box-sizing:border-box; 359 | } 360 | 361 | .lg-col-1{ 362 | width:8.33333%; 363 | } 364 | 365 | .lg-col-2{ 366 | width:16.66667%; 367 | } 368 | 369 | .lg-col-3{ 370 | width:25%; 371 | } 372 | 373 | .lg-col-4{ 374 | width:33.33333%; 375 | } 376 | 377 | .lg-col-5{ 378 | width:41.66667%; 379 | } 380 | 381 | .lg-col-6{ 382 | width:50%; 383 | } 384 | 385 | .lg-col-7{ 386 | width:58.33333%; 387 | } 388 | 389 | .lg-col-8{ 390 | width:66.66667%; 391 | } 392 | 393 | .lg-col-9{ 394 | width:75%; 395 | } 396 | 397 | .lg-col-10{ 398 | width:83.33333%; 399 | } 400 | 401 | .lg-col-11{ 402 | width:91.66667%; 403 | } 404 | 405 | .lg-col-12{ 406 | width:100%; 407 | } 408 | 409 | } 410 | .flex{ display:-webkit-box; display:-webkit-flex; display:-ms-flexbox; display:flex } 411 | 412 | @media (min-width: 40em){ 413 | .sm-flex{ display:-webkit-box; display:-webkit-flex; display:-ms-flexbox; display:flex } 414 | } 415 | 416 | @media (min-width: 52em){ 417 | .md-flex{ display:-webkit-box; display:-webkit-flex; display:-ms-flexbox; display:flex } 418 | } 419 | 420 | @media (min-width: 64em){ 421 | .lg-flex{ display:-webkit-box; display:-webkit-flex; display:-ms-flexbox; display:flex } 422 | } 423 | 424 | .flex-column{ -webkit-box-orient:vertical; -webkit-box-direction:normal; -webkit-flex-direction:column; -ms-flex-direction:column; flex-direction:column } 425 | .flex-wrap{ -webkit-flex-wrap:wrap; -ms-flex-wrap:wrap; flex-wrap:wrap } 426 | 427 | .items-start{ -webkit-box-align:start; -webkit-align-items:flex-start; -ms-flex-align:start; -ms-grid-row-align:flex-start; align-items:flex-start } 428 | .items-end{ -webkit-box-align:end; -webkit-align-items:flex-end; -ms-flex-align:end; -ms-grid-row-align:flex-end; align-items:flex-end } 429 | .items-center{ -webkit-box-align:center; -webkit-align-items:center; -ms-flex-align:center; -ms-grid-row-align:center; align-items:center } 430 | .items-baseline{ -webkit-box-align:baseline; -webkit-align-items:baseline; -ms-flex-align:baseline; -ms-grid-row-align:baseline; align-items:baseline } 431 | .items-stretch{ -webkit-box-align:stretch; -webkit-align-items:stretch; -ms-flex-align:stretch; -ms-grid-row-align:stretch; align-items:stretch } 432 | 433 | .self-start{ -webkit-align-self:flex-start; -ms-flex-item-align:start; align-self:flex-start } 434 | .self-end{ -webkit-align-self:flex-end; -ms-flex-item-align:end; align-self:flex-end } 435 | .self-center{ -webkit-align-self:center; -ms-flex-item-align:center; align-self:center } 436 | .self-baseline{ -webkit-align-self:baseline; -ms-flex-item-align:baseline; align-self:baseline } 437 | .self-stretch{ -webkit-align-self:stretch; -ms-flex-item-align:stretch; align-self:stretch } 438 | 439 | .justify-start{ -webkit-box-pack:start; -webkit-justify-content:flex-start; -ms-flex-pack:start; justify-content:flex-start } 440 | .justify-end{ -webkit-box-pack:end; -webkit-justify-content:flex-end; -ms-flex-pack:end; justify-content:flex-end } 441 | .justify-center{ -webkit-box-pack:center; -webkit-justify-content:center; -ms-flex-pack:center; justify-content:center } 442 | .justify-between{ -webkit-box-pack:justify; -webkit-justify-content:space-between; -ms-flex-pack:justify; justify-content:space-between } 443 | .justify-around{ -webkit-justify-content:space-around; -ms-flex-pack:distribute; justify-content:space-around } 444 | 445 | .content-start{ -webkit-align-content:flex-start; -ms-flex-line-pack:start; align-content:flex-start } 446 | .content-end{ -webkit-align-content:flex-end; -ms-flex-line-pack:end; align-content:flex-end } 447 | .content-center{ -webkit-align-content:center; -ms-flex-line-pack:center; align-content:center } 448 | .content-between{ -webkit-align-content:space-between; -ms-flex-line-pack:justify; align-content:space-between } 449 | .content-around{ -webkit-align-content:space-around; -ms-flex-line-pack:distribute; align-content:space-around } 450 | .content-stretch{ -webkit-align-content:stretch; -ms-flex-line-pack:stretch; align-content:stretch } 451 | .flex-auto{ 452 | -webkit-box-flex:1; 453 | -webkit-flex:1 1 auto; 454 | -ms-flex:1 1 auto; 455 | flex:1 1 auto; 456 | min-width:0; 457 | min-height:0; 458 | } 459 | .flex-none{ -webkit-box-flex:0; -webkit-flex:none; -ms-flex:none; flex:none } 460 | .fs0{ flex-shrink: 0 } 461 | 462 | .order-0{ -webkit-box-ordinal-group:1; -webkit-order:0; -ms-flex-order:0; order:0 } 463 | .order-1{ -webkit-box-ordinal-group:2; -webkit-order:1; -ms-flex-order:1; order:1 } 464 | .order-2{ -webkit-box-ordinal-group:3; -webkit-order:2; -ms-flex-order:2; order:2 } 465 | .order-3{ -webkit-box-ordinal-group:4; -webkit-order:3; -ms-flex-order:3; order:3 } 466 | .order-last{ -webkit-box-ordinal-group:100000; -webkit-order:99999; -ms-flex-order:99999; order:99999 } 467 | 468 | .relative{ position:relative } 469 | .absolute{ position:absolute } 470 | .fixed{ position:fixed } 471 | 472 | .top-0{ top:0 } 473 | .right-0{ right:0 } 474 | .bottom-0{ bottom:0 } 475 | .left-0{ left:0 } 476 | 477 | .z1{ z-index: 1 } 478 | .z2{ z-index: 2 } 479 | .z3{ z-index: 3 } 480 | .z4{ z-index: 4 } 481 | 482 | .border{ 483 | border-style:solid; 484 | border-width: 1px; 485 | } 486 | 487 | .border-top{ 488 | border-top-style:solid; 489 | border-top-width: 1px; 490 | } 491 | 492 | .border-right{ 493 | border-right-style:solid; 494 | border-right-width: 1px; 495 | } 496 | 497 | .border-bottom{ 498 | border-bottom-style:solid; 499 | border-bottom-width: 1px; 500 | } 501 | 502 | .border-left{ 503 | border-left-style:solid; 504 | border-left-width: 1px; 505 | } 506 | 507 | .border-none{ border:0 } 508 | 509 | .rounded{ border-radius: 3px } 510 | .circle{ border-radius:50% } 511 | 512 | .rounded-top{ border-radius: 3px 3px 0 0 } 513 | .rounded-right{ border-radius: 0 3px 3px 0 } 514 | .rounded-bottom{ border-radius: 0 0 3px 3px } 515 | .rounded-left{ border-radius: 3px 0 0 3px } 516 | 517 | .not-rounded{ border-radius:0 } 518 | 519 | .hide{ 520 | position:absolute !important; 521 | height:1px; 522 | width:1px; 523 | overflow:hidden; 524 | clip:rect(1px, 1px, 1px, 1px); 525 | } 526 | 527 | @media (max-width: 40em){ 528 | .xs-hide{ display:none !important } 529 | } 530 | 531 | @media (min-width: 40em) and (max-width: 52em){ 532 | .sm-hide{ display:none !important } 533 | } 534 | 535 | @media (min-width: 52em) and (max-width: 64em){ 536 | .md-hide{ display:none !important } 537 | } 538 | 539 | @media (min-width: 64em){ 540 | .lg-hide{ display:none !important } 541 | } 542 | 543 | .display-none{ display:none !important } 544 | 545 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/EOT/SourceCodePro-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/EOT/SourceCodePro-Bold.eot -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/EOT/SourceCodePro-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/EOT/SourceCodePro-Regular.eot -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/OTF/SourceCodePro-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/OTF/SourceCodePro-Bold.otf -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/OTF/SourceCodePro-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/OTF/SourceCodePro-Regular.otf -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/TTF/SourceCodePro-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/TTF/SourceCodePro-Bold.ttf -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/TTF/SourceCodePro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/TTF/SourceCodePro-Regular.ttf -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIT-Protocol/lit-js-sdk/abf4189dcae3d5d6611ee0698ff69b18c5876d6c/docs/api_docs_html/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 -------------------------------------------------------------------------------- /docs/api_docs_html/assets/fonts/source-code-pro.css: -------------------------------------------------------------------------------- 1 | @font-face{ 2 | font-family: 'Source Code Pro'; 3 | font-weight: 400; 4 | font-style: normal; 5 | font-stretch: normal; 6 | src: url('EOT/SourceCodePro-Regular.eot') format('embedded-opentype'), 7 | url('WOFF2/TTF/SourceCodePro-Regular.ttf.woff2') format('woff2'), 8 | url('WOFF/OTF/SourceCodePro-Regular.otf.woff') format('woff'), 9 | url('OTF/SourceCodePro-Regular.otf') format('opentype'), 10 | url('TTF/SourceCodePro-Regular.ttf') format('truetype'); 11 | } 12 | 13 | @font-face{ 14 | font-family: 'Source Code Pro'; 15 | font-weight: 700; 16 | font-style: normal; 17 | font-stretch: normal; 18 | src: url('EOT/SourceCodePro-Bold.eot') format('embedded-opentype'), 19 | url('WOFF2/TTF/SourceCodePro-Bold.ttf.woff2') format('woff2'), 20 | url('WOFF/OTF/SourceCodePro-Bold.otf.woff') format('woff'), 21 | url('OTF/SourceCodePro-Bold.otf') format('opentype'), 22 | url('TTF/SourceCodePro-Bold.ttf') format('truetype'); 23 | } 24 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | -webkit-text-size-adjust: none; 14 | } 15 | 16 | .hljs-comment, 17 | .diff .hljs-header, 18 | .hljs-javadoc { 19 | color: #998; 20 | font-style: italic; 21 | } 22 | 23 | .hljs-keyword, 24 | .css .rule .hljs-keyword, 25 | .hljs-winutils, 26 | .nginx .hljs-title, 27 | .hljs-subst, 28 | .hljs-request, 29 | .hljs-status { 30 | color: #1184CE; 31 | } 32 | 33 | .hljs-number, 34 | .hljs-hexcolor, 35 | .ruby .hljs-constant { 36 | color: #ed225d; 37 | } 38 | 39 | .hljs-string, 40 | .hljs-tag .hljs-value, 41 | .hljs-phpdoc, 42 | .hljs-dartdoc, 43 | .tex .hljs-formula { 44 | color: #ed225d; 45 | } 46 | 47 | .hljs-title, 48 | .hljs-id, 49 | .scss .hljs-preprocessor { 50 | color: #900; 51 | font-weight: bold; 52 | } 53 | 54 | .hljs-list .hljs-keyword, 55 | .hljs-subst { 56 | font-weight: normal; 57 | } 58 | 59 | .hljs-class .hljs-title, 60 | .hljs-type, 61 | .vhdl .hljs-literal, 62 | .tex .hljs-command { 63 | color: #458; 64 | font-weight: bold; 65 | } 66 | 67 | .hljs-tag, 68 | .hljs-tag .hljs-title, 69 | .hljs-rules .hljs-property, 70 | .django .hljs-tag .hljs-keyword { 71 | color: #000080; 72 | font-weight: normal; 73 | } 74 | 75 | .hljs-attribute, 76 | .hljs-variable, 77 | .lisp .hljs-body { 78 | color: #008080; 79 | } 80 | 81 | .hljs-regexp { 82 | color: #009926; 83 | } 84 | 85 | .hljs-symbol, 86 | .ruby .hljs-symbol .hljs-string, 87 | .lisp .hljs-keyword, 88 | .clojure .hljs-keyword, 89 | .scheme .hljs-keyword, 90 | .tex .hljs-special, 91 | .hljs-prompt { 92 | color: #990073; 93 | } 94 | 95 | .hljs-built_in { 96 | color: #0086b3; 97 | } 98 | 99 | .hljs-preprocessor, 100 | .hljs-pragma, 101 | .hljs-pi, 102 | .hljs-doctype, 103 | .hljs-shebang, 104 | .hljs-cdata { 105 | color: #999; 106 | font-weight: bold; 107 | } 108 | 109 | .hljs-deletion { 110 | background: #fdd; 111 | } 112 | 113 | .hljs-addition { 114 | background: #dfd; 115 | } 116 | 117 | .diff .hljs-change { 118 | background: #0086b3; 119 | } 120 | 121 | .hljs-chunk { 122 | color: #aaa; 123 | } 124 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/site.js: -------------------------------------------------------------------------------- 1 | /* global anchors */ 2 | 3 | // add anchor links to headers 4 | anchors.options.placement = 'left'; 5 | anchors.add('h3'); 6 | 7 | // Filter UI 8 | var tocElements = document.getElementById('toc').getElementsByTagName('li'); 9 | 10 | document.getElementById('filter-input').addEventListener('keyup', function (e) { 11 | var i, element, children; 12 | 13 | // enter key 14 | if (e.keyCode === 13) { 15 | // go to the first displayed item in the toc 16 | for (i = 0; i < tocElements.length; i++) { 17 | element = tocElements[i]; 18 | if (!element.classList.contains('display-none')) { 19 | location.replace(element.firstChild.href); 20 | return e.preventDefault(); 21 | } 22 | } 23 | } 24 | 25 | var match = function () { 26 | return true; 27 | }; 28 | 29 | var value = this.value.toLowerCase(); 30 | 31 | if (!value.match(/^\s*$/)) { 32 | match = function (element) { 33 | var html = element.firstChild.innerHTML; 34 | return html && html.toLowerCase().indexOf(value) !== -1; 35 | }; 36 | } 37 | 38 | for (i = 0; i < tocElements.length; i++) { 39 | element = tocElements[i]; 40 | children = Array.from(element.getElementsByTagName('li')); 41 | if (match(element) || children.some(match)) { 42 | element.classList.remove('display-none'); 43 | } else { 44 | element.classList.add('display-none'); 45 | } 46 | } 47 | }); 48 | 49 | var items = document.getElementsByClassName('toggle-sibling'); 50 | for (var j = 0; j < items.length; j++) { 51 | items[j].addEventListener('click', toggleSibling); 52 | } 53 | 54 | function toggleSibling() { 55 | var stepSibling = this.parentNode.getElementsByClassName('toggle-target')[0]; 56 | var icon = this.getElementsByClassName('icon')[0]; 57 | var klass = 'display-none'; 58 | if (stepSibling.classList.contains(klass)) { 59 | stepSibling.classList.remove(klass); 60 | icon.innerHTML = '▾'; 61 | } else { 62 | stepSibling.classList.add(klass); 63 | icon.innerHTML = '▸'; 64 | } 65 | } 66 | 67 | function showHashTarget(targetId) { 68 | if (targetId) { 69 | var hashTarget = document.getElementById(targetId); 70 | // new target is hidden 71 | if ( 72 | hashTarget && 73 | hashTarget.offsetHeight === 0 && 74 | hashTarget.parentNode.parentNode.classList.contains('display-none') 75 | ) { 76 | hashTarget.parentNode.parentNode.classList.remove('display-none'); 77 | } 78 | } 79 | } 80 | 81 | function scrollIntoView(targetId) { 82 | // Only scroll to element if we don't have a stored scroll position. 83 | if (targetId && !history.state) { 84 | var hashTarget = document.getElementById(targetId); 85 | if (hashTarget) { 86 | hashTarget.scrollIntoView(); 87 | } 88 | } 89 | } 90 | 91 | function gotoCurrentTarget() { 92 | showHashTarget(location.hash.substring(1)); 93 | scrollIntoView(location.hash.substring(1)); 94 | } 95 | 96 | window.addEventListener('hashchange', gotoCurrentTarget); 97 | gotoCurrentTarget(); 98 | 99 | var toclinks = document.getElementsByClassName('pre-open'); 100 | for (var k = 0; k < toclinks.length; k++) { 101 | toclinks[k].addEventListener('mousedown', preOpen, false); 102 | } 103 | 104 | function preOpen() { 105 | showHashTarget(this.hash.substring(1)); 106 | } 107 | 108 | var split_left = document.querySelector('#split-left'); 109 | var split_right = document.querySelector('#split-right'); 110 | var split_parent = split_left.parentNode; 111 | var cw_with_sb = split_left.clientWidth; 112 | split_left.style.overflow = 'hidden'; 113 | var cw_without_sb = split_left.clientWidth; 114 | split_left.style.overflow = ''; 115 | 116 | Split(['#split-left', '#split-right'], { 117 | elementStyle: function (dimension, size, gutterSize) { 118 | return { 119 | 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' 120 | }; 121 | }, 122 | gutterStyle: function (dimension, gutterSize) { 123 | return { 124 | 'flex-basis': gutterSize + 'px' 125 | }; 126 | }, 127 | gutterSize: 20, 128 | sizes: [33, 67] 129 | }); 130 | 131 | // Chrome doesn't remember scroll position properly so do it ourselves. 132 | // Also works on Firefox and Edge. 133 | 134 | function updateState() { 135 | history.replaceState( 136 | { 137 | left_top: split_left.scrollTop, 138 | right_top: split_right.scrollTop 139 | }, 140 | document.title 141 | ); 142 | } 143 | 144 | function loadState(ev) { 145 | if (ev) { 146 | // Edge doesn't replace change history.state on popstate. 147 | history.replaceState(ev.state, document.title); 148 | } 149 | if (history.state) { 150 | split_left.scrollTop = history.state.left_top; 151 | split_right.scrollTop = history.state.right_top; 152 | } 153 | } 154 | 155 | window.addEventListener('load', function () { 156 | // Restore after Firefox scrolls to hash. 157 | setTimeout(function () { 158 | loadState(); 159 | // Update with initial scroll position. 160 | updateState(); 161 | // Update scroll positions only after we've loaded because Firefox 162 | // emits an initial scroll event with 0. 163 | split_left.addEventListener('scroll', updateState); 164 | split_right.addEventListener('scroll', updateState); 165 | }, 1); 166 | }); 167 | 168 | window.addEventListener('popstate', loadState); 169 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/split.css: -------------------------------------------------------------------------------- 1 | .gutter { 2 | background-color: #f5f5f5; 3 | background-repeat: no-repeat; 4 | background-position: 50%; 5 | } 6 | 7 | .gutter.gutter-vertical { 8 | background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII='); 9 | cursor: ns-resize; 10 | } 11 | 12 | .gutter.gutter-horizontal { 13 | background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg=='); 14 | cursor: ew-resize; 15 | } 16 | -------------------------------------------------------------------------------- /docs/api_docs_html/assets/style.css: -------------------------------------------------------------------------------- 1 | .documentation { 2 | font-family: Helvetica, sans-serif; 3 | color: #666; 4 | line-height: 1.5; 5 | background: #f5f5f5; 6 | } 7 | 8 | .black { 9 | color: #666; 10 | } 11 | 12 | .bg-white { 13 | background-color: #fff; 14 | } 15 | 16 | h4 { 17 | margin: 20px 0 10px 0; 18 | } 19 | 20 | .documentation h3 { 21 | color: #000; 22 | } 23 | 24 | .border-bottom { 25 | border-color: #ddd; 26 | } 27 | 28 | a { 29 | color: #1184ce; 30 | text-decoration: none; 31 | } 32 | 33 | .documentation a[href]:hover { 34 | text-decoration: underline; 35 | } 36 | 37 | a:hover { 38 | cursor: pointer; 39 | } 40 | 41 | .py1-ul li { 42 | padding: 5px 0; 43 | } 44 | 45 | .max-height-100 { 46 | max-height: 100%; 47 | } 48 | 49 | .height-viewport-100 { 50 | height: 100vh; 51 | } 52 | 53 | section:target h3 { 54 | font-weight: 700; 55 | } 56 | 57 | .documentation td, 58 | .documentation th { 59 | padding: 0.25rem 0.25rem; 60 | } 61 | 62 | h1:hover .anchorjs-link, 63 | h2:hover .anchorjs-link, 64 | h3:hover .anchorjs-link, 65 | h4:hover .anchorjs-link { 66 | opacity: 1; 67 | } 68 | 69 | .fix-3 { 70 | width: 25%; 71 | max-width: 244px; 72 | } 73 | 74 | .fix-3 { 75 | width: 25%; 76 | max-width: 244px; 77 | } 78 | 79 | @media (min-width: 52em) { 80 | .fix-margin-3 { 81 | margin-left: 25%; 82 | } 83 | } 84 | 85 | .pre, 86 | pre, 87 | code, 88 | .code { 89 | font-family: Source Code Pro, Menlo, Consolas, Liberation Mono, monospace; 90 | font-size: 14px; 91 | } 92 | 93 | .fill-light { 94 | background: #f9f9f9; 95 | } 96 | 97 | .width2 { 98 | width: 1rem; 99 | } 100 | 101 | .input { 102 | font-family: inherit; 103 | display: block; 104 | width: 100%; 105 | height: 2rem; 106 | padding: 0.5rem; 107 | margin-bottom: 1rem; 108 | border: 1px solid #ccc; 109 | font-size: 0.875rem; 110 | border-radius: 3px; 111 | box-sizing: border-box; 112 | } 113 | 114 | table { 115 | border-collapse: collapse; 116 | } 117 | 118 | .prose table th, 119 | .prose table td { 120 | text-align: left; 121 | padding: 8px; 122 | border: 1px solid #ddd; 123 | } 124 | 125 | .prose table th:nth-child(1) { 126 | border-right: none; 127 | } 128 | .prose table th:nth-child(2) { 129 | border-left: none; 130 | } 131 | 132 | .prose table { 133 | border: 1px solid #ddd; 134 | } 135 | 136 | .prose-big { 137 | font-size: 18px; 138 | line-height: 30px; 139 | } 140 | 141 | .quiet { 142 | opacity: 0.7; 143 | } 144 | 145 | .minishadow { 146 | box-shadow: 2px 2px 10px #f3f3f3; 147 | } 148 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | lit-js-sdk docs 6 | 7 | 8 |

Welcome to the LIT JS SDK Docs

9 |

Our main documentation lives in the README.md in the repo, viewable here

10 |

Our API docs live here

11 | 12 | 13 | -------------------------------------------------------------------------------- /docs_md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Table of Contents 4 | 5 | * [Welcome][1] 6 | * [Minting using our token contracts][2] 7 | * [mintLIT][3] 8 | * [Parameters][4] 9 | * [LIT Node Client][5] 10 | * [LitNodeClient][6] 11 | * [Parameters][7] 12 | * [getEncryptionKey][8] 13 | * [Parameters][9] 14 | * [saveEncryptionKey][10] 15 | * [Parameters][11] 16 | * [Creating the LIT HTML][12] 17 | * [createHtmlLIT][13] 18 | * [Parameters][14] 19 | * [toggleLock][15] 20 | * [Encryption and decryption utilities][16] 21 | * [zipAndEncryptString][17] 22 | * [Parameters][18] 23 | * [zipAndEncryptFiles][19] 24 | * [Parameters][20] 25 | * [encryptZip][21] 26 | * [Parameters][22] 27 | * [decryptZip][23] 28 | * [Parameters][24] 29 | * [Utilities][25] 30 | * [fileToDataUrl][26] 31 | * [Parameters][27] 32 | * [checkAndSignAuthMessage][28] 33 | * [Types][29] 34 | * [AuthSig][30] 35 | * [Properties][31] 36 | * [LITChain][32] 37 | * [Properties][33] 38 | * [LIT_CHAINS][34] 39 | 40 | ## Welcome 41 | 42 | Welcome to the LIT JS SDK API documentation. To understand how these functions fit together, please view the README in the github repo for this SDK. 43 | 44 | ## Minting using our token contracts 45 | 46 | You may use our pre-deployed token contracts to mint your LIT, or you may supply your own. Our contracts are ERC1155 tokens on Polygon and Ethereum. Using these contracts is the easiest way to get started. 47 | 48 | ## mintLIT 49 | 50 | Mint a LIT using our ERC1155 contract. 51 | 52 | ### Parameters 53 | 54 | * `params` **[Object][35]** 55 | 56 | * `params.chain` **[string][36]** The chain to mint on. "ethereum" and "polygon" are currently supported. 57 | * `params.quantity` **[number][37]** The number of tokens to mint. Note that these will be fungible, so they will not have serial numbers. 58 | 59 | Returns **[Object][35]** The txHash, tokenId, tokenAddress, mintingAddress, and authSig. 60 | 61 | ## LIT Node Client 62 | 63 | A client that connects directly to the LIT nodes to store and retrieve encryption keys for LITs. Only holders of an NFT that corresponds with a LIT may store and retrieve the keys. 64 | 65 | ## LitNodeClient 66 | 67 | A LIT node client. Connects directly to the LIT nodes to store and retrieve encryption keys. 68 | 69 | ### Parameters 70 | 71 | * `config` **[Object][35]** (optional, default `{alertWhenUnauthorized:true,minNodeCount:8}`) 72 | 73 | * `config.alertWhenUnauthorized` **[boolean][38]** Whether or not to show a JS alert() when a user tries to unlock a LIT but is unauthorized. If you turn this off, you should create an event listener for the "lit-authFailure" event on the document, and show your own error to the user. (optional, default `true`) 74 | * `config.minNodeCount` **[number][37]** The minimum number of nodes that must be connected for the LitNodeClient to be ready to use. (optional, default `8`) 75 | 76 | ### getEncryptionKey 77 | 78 | Retrieve the symmetric encryption key from the LIT nodes. Note that this will only work if the current user is a holder of the NFT that corresponds to this LIT. This NFT token address and ID was specified when this LIT was created. 79 | 80 | #### Parameters 81 | 82 | * `params` **[Object][35]** 83 | 84 | * `params.tokenAddress` **[string][36]** The token address of the NFT that corresponds to this LIT. This should be an ERC721 or ERC1155 token. 85 | * `params.tokenId` **[string][36]** The token ID of the NFT that corresponds to this LIT 86 | * `params.chain` **[string][36]** The chain that the corresponding NFT lives on. Currently "polygon" and "ethereum" are supported. 87 | * `params.authSig` **[AuthSig][39]** The authentication signature that proves that the user owns the crypto wallet address that should be an owner of the NFT that corresponds to this LIT. 88 | 89 | Returns **[Object][35]** The symmetric encryption key that can be used to decrypt the locked content inside the LIT. You should pass this key to the decryptZip function. 90 | 91 | ### saveEncryptionKey 92 | 93 | Securely save the symmetric encryption key to the LIT nodes. 94 | 95 | #### Parameters 96 | 97 | * `params` **[Object][35]** 98 | 99 | * `params.tokenAddress` **[string][36]** The token address of the NFT that corresponds to this LIT. This should be an ERC721 or ERC1155 token. 100 | * `params.tokenId` **[string][36]** The token ID of the NFT that corresponds to this LIT 101 | * `params.chain` **[string][36]** The chain that the corresponding NFT lives on. Currently "polygon" and "ethereum" are supported. 102 | * `params.authSig` **[AuthSig][39]** The authentication signature that proves that the user owns the crypto wallet address that should be an owner of the NFT that corresponds to this LIT. 103 | * `params.symmetricKey` **[string][36]** The symmetric encryption key that was used to encrypt the locked content inside the LIT. You should use zipAndEncryptString or zipAndEncryptFiles to get this encryption key. This key will be split up using threshold encryption so that the LIT nodes cannot decrypt a given LIT. 104 | 105 | Returns **[Object][35]** An object that gives the status of the operation, denoted via a boolean with the key "success" 106 | 107 | ## Creating the LIT HTML 108 | 109 | Creates a barebones HTML LIT with built in unlock functionality. You need to design your LIT with HTML and CSS, and provide an unlock button with the id "unlockButton" inside your HTML. 110 | 111 | ## createHtmlLIT 112 | 113 | Create a ready-to-go LIT using provided HTML/CSS body and an encrypted zip data url 114 | 115 | ### Parameters 116 | 117 | * `params` **[Object][35]** 118 | 119 | * `params.title` **[string][36]** The title that will be used for the title tag in the outputted HTML 120 | * `params.htmlBody` **[number][37]** The HTML body for the locked state of the LIT. All users will be able to see this HTML. This HTML must have a button with an id of "unlockButton" which will be automatically set up to decrypt and load the encryptedZipDataUrl 121 | * `params.css` **[string][36]** Any CSS you would like to include in the outputted HTML 122 | * `params.encryptedZipDataUrl` **[number][37]** a data URL of the encrypted zip that contains the locked content that only token holders will be able to view. 123 | * `params.tokenAddress` **[string][36]** The token address of the corresponding NFT for this LIT. ERC721 and ERC 1155 tokens are currently supported. 124 | * `params.tokenId` **[number][37]** The ID of the token of the corresponding NFT for this LIT. Only holders of this token ID will be able to unlock and decrypt this LIT. 125 | * `params.chain` **[string][36]** The chain that the corresponding NFT was minted on. "ethereum" and "polygon" are currently supported. 126 | * `params.npmPackages` **[Array][40]** An array of strings of NPM package names that should be embedded into this LIT. These packages will be pulled down via unpkg, converted to data URLs, and embedded in the LIT HTML. You can include any packages from npmjs.com. (optional, default `[]`) 127 | 128 | Returns **[string][36]** The HTML string that is now a LIT. You can send this HTML around and only token holders will be able to unlock and decrypt the content inside it. Included in the HTML is this LIT JS SDK itself, the encrypted locked content, an automatic connection to the LIT nodes network, and a handler for a button with id "unlockButton" which will perform the unlock operation when clicked. 129 | 130 | ## toggleLock 131 | 132 | Lock and unlock the encrypted content inside a LIT. This content is only viewable by holders of the NFT that corresponds to this LIT. Locked content will be decrypted and placed into the HTML element with id "mediaGridHolder". The HTML element with the id "lockedHeader" will have it's text automatically changed to LOCKED or UNLOCKED to denote the state of the LIT. Note that if you're creating a LIT using the createHtmlLIT function, you do not need to use this function, because this function is automatically bound to any button in your HTML with the id "unlockButton". 133 | 134 | ## Encryption and decryption utilities 135 | 136 | 137 | 138 | ## zipAndEncryptString 139 | 140 | Zip and encrypt a string. This is used to encrypt any string that is to be locked and included in a LIT. For example, on MintLIT, we render the HTML/CSS containing the locked files and a grid to view them to a string using ReactDOMServer.renderToString(). 141 | 142 | ### Parameters 143 | 144 | * `string` **[string][36]** The string to zip and encrypt 145 | 146 | Returns **[Object][35]** The encryptedZip as a Blob and the symmetricKey used to encrypt it, as a JSON string. The encrypted zip will contain a single file called "string.txt" 147 | 148 | ## zipAndEncryptFiles 149 | 150 | Zip and encrypt multiple files. 151 | 152 | ### Parameters 153 | 154 | * `files` **[array][40]** An array of the files you wish to zip and encrypt 155 | 156 | Returns **[Object][35]** The encryptedZip as a Blob and the symmetricKey used to encrypt it, as a JSON string. The encrypted zip will contain a folder "encryptedAssets" and all of the files will be inside it. 157 | 158 | ## encryptZip 159 | 160 | Encrypt a zip file created with JSZip using a new random symmetric key via WebCrypto. 161 | 162 | ### Parameters 163 | 164 | * `zip` **JSZip** The JSZip instance to encrypt 165 | 166 | Returns **[Object][35]** The encryptedZip as a Blob and the symmetricKey used to encrypt it, as a JSON string. 167 | 168 | ## decryptZip 169 | 170 | Decrypt and unzip a zip that was created using encryptZip, zipAndEncryptString, or zipAndEncryptFiles. 171 | 172 | ### Parameters 173 | 174 | * `encryptedZipBlob` **[Blob][41]** The encrypted zip as a Blob 175 | * `symmKey` **[Object][35]** An object containing the symmetric key used that will be used to decrypt this zip. 176 | 177 | Returns **[Array][40]** An array of the decrypted files inside the zip. 178 | 179 | ## Utilities 180 | 181 | 182 | 183 | ## fileToDataUrl 184 | 185 | Convert a file to a data URL, which could then be embedded in a LIT. A data URL is a string representation of a file. 186 | 187 | ### Parameters 188 | 189 | * `file` **File** The file to turn into a data url 190 | 191 | Returns **[string][36]** The data URL. This is a string representation that can be used anywhere the original file would be used. 192 | 193 | ## checkAndSignAuthMessage 194 | 195 | Check for an existing cryptographic authentication signature and create one of it does not exist. This is used to prove ownership of a given crypto wallet address to the LIT nodes. The result is stored in LocalStorage so the user doesn't have to sign every time they perform an operation. 196 | 197 | Returns **[AuthSig][39]** The AuthSig created or retrieved 198 | 199 | ## Types 200 | 201 | 202 | 203 | ## AuthSig 204 | 205 | Type: [Object][35] 206 | 207 | ### Properties 208 | 209 | * `sig` **[string][36]** The actual hex-encoded signature 210 | * `derivedVia` **[string][36]** The method used to derive the signature 211 | * `signedMessage` **[string][36]** The message that was signed 212 | * `address` **[string][36]** The crypto wallet address that signed the message 213 | 214 | ## LITChain 215 | 216 | Type: [Object][35] 217 | 218 | ### Properties 219 | 220 | * `contractAddress` **[string][36]** The address of the token contract 221 | * `chainId` **[string][36]** The chain ID of the chain that this token contract is deployed on. Used for EVM chains. 222 | * `name` **[string][36]** The human readable name of the chain 223 | 224 | ## LIT_CHAINS 225 | 226 | Pre-deployed token contracts that you may use for minting LITs. These are ERC1155 contracts that let you mint any quantity of a given token. Use the chain name as a key in this object. Currently "polygon" and "ethereum" are supported. 227 | 228 | Type: [LITChain][42] 229 | 230 | [1]: #welcome 231 | 232 | [2]: #minting-using-our-token-contracts 233 | 234 | [3]: #mintlit 235 | 236 | [4]: #parameters 237 | 238 | [5]: #lit-node-client 239 | 240 | [6]: #litnodeclient 241 | 242 | [7]: #parameters-1 243 | 244 | [8]: #getencryptionkey 245 | 246 | [9]: #parameters-2 247 | 248 | [10]: #saveencryptionkey 249 | 250 | [11]: #parameters-3 251 | 252 | [12]: #creating-the-lit-html 253 | 254 | [13]: #createhtmllit 255 | 256 | [14]: #parameters-4 257 | 258 | [15]: #togglelock 259 | 260 | [16]: #encryption-and-decryption-utilities 261 | 262 | [17]: #zipandencryptstring 263 | 264 | [18]: #parameters-5 265 | 266 | [19]: #zipandencryptfiles 267 | 268 | [20]: #parameters-6 269 | 270 | [21]: #encryptzip 271 | 272 | [22]: #parameters-7 273 | 274 | [23]: #decryptzip 275 | 276 | [24]: #parameters-8 277 | 278 | [25]: #utilities 279 | 280 | [26]: #filetodataurl 281 | 282 | [27]: #parameters-9 283 | 284 | [28]: #checkandsignauthmessage 285 | 286 | [29]: #types 287 | 288 | [30]: #authsig 289 | 290 | [31]: #properties 291 | 292 | [32]: #litchain 293 | 294 | [33]: #properties-1 295 | 296 | [34]: #lit_chains 297 | 298 | [35]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object 299 | 300 | [36]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String 301 | 302 | [37]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number 303 | 304 | [38]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean 305 | 306 | [39]: #authsig 307 | 308 | [40]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array 309 | 310 | [41]: https://developer.mozilla.org/docs/Web/API/Blob 311 | 312 | [42]: #litchain 313 | -------------------------------------------------------------------------------- /documentation.yml: -------------------------------------------------------------------------------- 1 | toc: 2 | - name: Welcome 3 | description: | 4 | Welcome to the LIT JS SDK API documentation. To understand how these functions fit together, please view the documentation for this SDK, located at https://developer.litprotocol.com/docs/SDK/intro 5 | - LitNodeClient 6 | - name: Static Content - Encryption and decryption utilities 7 | - encryptString 8 | - decryptString 9 | - encryptFile 10 | - decryptFile 11 | - zipAndEncryptString 12 | - zipAndEncryptFiles 13 | - encryptFileAndZipWithMetadata 14 | - decryptZipFileWithMetadata 15 | - encryptZip 16 | - decryptZip 17 | - decryptWithSymmetricKey 18 | - encryptWithSymmetricKey 19 | - name: Dynamic Content - Loading content from a server 20 | - verifyJwt 21 | - name: Authentication Signature Utilities 22 | - checkAndSignAuthMessage 23 | - signAndSaveAuthMessage 24 | - disconnectWeb3 25 | - name: Conversion Utilities 26 | - blobToBase64String 27 | - base64StringToBlob 28 | - uint8arrayToString 29 | - uint8arrayFromString 30 | - fileToDataUrl 31 | - name: Other Utilities 32 | - humanizeAccessControlConditions 33 | - hashUnifiedAccessControlConditions 34 | - name: HTML NFT Utilities 35 | - findLITs 36 | - sendLIT 37 | - createHtmlLIT 38 | - mintLIT 39 | - unlockLitWithKey 40 | - toggleLock 41 | - injectViewerIFrame 42 | - name: Types 43 | - AccessControlCondition 44 | - EVMContractCondition 45 | - SolRpcCondition 46 | - CosmosCondition 47 | - ResourceId 48 | - AuthSig 49 | - name: Chain Info 50 | - LITChain 51 | - LITEVMChain 52 | - LITSVMChain 53 | - name: Misc 54 | -------------------------------------------------------------------------------- /esbuild-nodejs-shims.js: -------------------------------------------------------------------------------- 1 | // add fetch polyfill 2 | import fetch from "node-fetch"; 3 | import { webcrypto } from "crypto"; 4 | import Blob from "cross-blob"; 5 | 6 | globalThis.fetch = fetch; 7 | globalThis.crypto = webcrypto; 8 | globalThis.Blob = Blob; 9 | -------------------------------------------------------------------------------- /esbuild-nodejs.js: -------------------------------------------------------------------------------- 1 | const { build, analyzeMetafile } = require("esbuild"); 2 | const { dedupBn } = require("./esbuild-plugins.js"); 3 | 4 | const go = async () => { 5 | let result = await build({ 6 | entryPoints: ["src/index.js"], 7 | bundle: true, 8 | minify: true, 9 | sourcemap: true, 10 | outfile: "build/index.node.js", 11 | loader: { 12 | ".svg": "dataurl", 13 | ".css": "text", 14 | }, 15 | plugins: [dedupBn], 16 | sourceRoot: "./", 17 | platform: "node", 18 | inject: ["./esbuild-nodejs-shims.js"], 19 | metafile: true, 20 | }); 21 | // let text = await analyzeMetafile(result.metafile); 22 | // console.log(text); 23 | }; 24 | 25 | go(); 26 | -------------------------------------------------------------------------------- /esbuild-plugins.js: -------------------------------------------------------------------------------- 1 | const dedupBn = { 2 | name: "dedupe-bn", 3 | setup({ onResolve }) { 4 | const bn = require.resolve("bn.js/lib/bn.js"); 5 | onResolve({ filter: /^bn\.js$/ }, () => { 6 | return { path: bn }; 7 | }); 8 | }, 9 | }; 10 | 11 | module.exports = { dedupBn }; 12 | -------------------------------------------------------------------------------- /esbuild-tests.js: -------------------------------------------------------------------------------- 1 | const { build } = require('esbuild') 2 | build({ 3 | entryPoints: ['tests/provisioningAndSigning.js'], 4 | bundle: true, 5 | minify: true, 6 | sourcemap: true, 7 | outfile: 'build/tests.js', 8 | sourceRoot: './', 9 | format: 'cjs', 10 | inject: ['./node_modules/node-fetch-polyfill/index.js'], 11 | }) 12 | -------------------------------------------------------------------------------- /esbuild-web-shims.js: -------------------------------------------------------------------------------- 1 | export const process = { versions: false, env: false }; 2 | -------------------------------------------------------------------------------- /esbuild-web.js: -------------------------------------------------------------------------------- 1 | const { build, analyzeMetafile } = require("esbuild"); 2 | const { nodeBuiltIns } = require("esbuild-node-builtins"); 3 | const { dedupBn } = require("./esbuild-plugins.js"); 4 | 5 | const go = async () => { 6 | let result = await build({ 7 | entryPoints: ["src/index.js"], 8 | bundle: true, 9 | minify: true, 10 | sourcemap: true, 11 | outfile: "build/index.web.js", 12 | loader: { 13 | ".svg": "dataurl", 14 | ".css": "text", 15 | }, 16 | sourceRoot: "./", 17 | globalName: "LitJsSdk", 18 | plugins: [nodeBuiltIns(), dedupBn], 19 | define: { global: "window" }, 20 | inject: ["./esbuild-web-shims.js"], 21 | metafile: true, 22 | }); 23 | 24 | // let text = await analyzeMetafile(result.metafile); 25 | // console.log(text); 26 | }; 27 | 28 | go(); 29 | -------------------------------------------------------------------------------- /gen_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | documentation build 'src/**' -f html --config documentation.yml -o docs/api_docs_html 4 | documentation build 'src/**' -f md --config documentation.yml -o api_docs.md 5 | doctoc README.md -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lit-js-sdk", 3 | "version": "1.1.250", 4 | "description": "LIT Javascript SDK", 5 | "source": "src/index.js", 6 | "main": "build/index.js", 7 | "scripts": { 8 | "start": "concurrently \"microbundle watch -o build/index.js -f cjs\" \"nodemon -i build esbuild-nodejs.js\" \"nodemon -i build esbuild-web.js\" \"serve -p 3050 build\" \"sleep 3; open http://localhost:3050/manual_tests.html\" \"sleep 3; open http://localhost:3050/manual_tests_evm_contract_conditions.html\"", 9 | "startNoCompressUseThisIfYouGetATerserErrorMaximumCallStackSizeExceeded": "microbundle watch --no-compress ", 10 | "buildWithMicrobundle": "microbundle build -o build/index.js -f cjs", 11 | "buildWebWithParcel": "parcel build --global LitJsSdk -d build --out-file index.web.js --public-url ./ src/index.js", 12 | "cdnDeploy": "yarn build; yarn buildWeb; yarn buildNode", 13 | "build": "microbundle build -o build/index.js -f cjs", 14 | "buildWeb": "node esbuild-web.js", 15 | "buildNode": "node esbuild-nodejs.js", 16 | "test": "node --experimental-specifier-resolution=node tests/provisioningAndSigning.js", 17 | "versionBump": "node node_modules/semver-bump/index.js ../../package.json; npx genversion -e src/version.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/LIT-Protocol/lit-js-sdk" 22 | }, 23 | "author": "Chris Cassano (https://github.com/glitch003)", 24 | "bugs": { 25 | "url": "https://github.com/LIT-Protocol/lit-js-sdk/issues" 26 | }, 27 | "homepage": "https://github.com/LIT-Protocol/lit-js-sdk", 28 | "keywords": [ 29 | "library" 30 | ], 31 | "license": "MIT", 32 | "devDependencies": { 33 | "esbuild": "^0.14.25", 34 | "esbuild-node-builtins": "^0.1.0", 35 | "genversion": "^3.0.1", 36 | "microbundle": "^0.13.0", 37 | "semver-bump": "^1.0.0", 38 | "standard": "^16.0.3" 39 | }, 40 | "dependencies": { 41 | "@ethersproject/bytes": "^5.5.0", 42 | "@ethersproject/contracts": "^5.2.0", 43 | "@ethersproject/hash": "^5.4.0", 44 | "@ethersproject/providers": "^5.2.0", 45 | "@ethersproject/strings": "^5.5.0", 46 | "@ethersproject/units": "^5.4.0", 47 | "@ethersproject/wallet": "^5.2.0", 48 | "@walletconnect/ethereum-provider": "1.7.8", 49 | "buffer": "^6.0.3", 50 | "bufferutil": "^4.0.6", 51 | "cross-blob": "^3.0.1", 52 | "jszip": "^3.6.0", 53 | "lit-connect-modal": "^0.1.11", 54 | "lit-siwe": "^1.1.8", 55 | "node-fetch": "^3.2.3", 56 | "pako": "^2.0.4", 57 | "tslib": "^2.3.1", 58 | "tweetnacl": "^1.0.3", 59 | "tweetnacl-util": "^0.15.1", 60 | "utf-8-validate": "^5.0.8" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/sdk-browser-standalone/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build/index*.js 14 | /build/index*.js.map 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .idea 28 | -------------------------------------------------------------------------------- /packages/sdk-browser-standalone/.npmignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | -------------------------------------------------------------------------------- /packages/sdk-browser-standalone/README.md: -------------------------------------------------------------------------------- 1 | This package is simply the browser build of the Lit-JS-SDK with all dependencies included. No bundling needed, you can drop this into a script tag on a webpage and it will work. 2 | 3 | Importing this package is the same as importing the web Lit-JS-SDK package web build (`import LitJsSdk from 'lit-js-sdk/build/index.web.js'`) except this package has less extra stuff you don't need. 4 | 5 | 6 | 7 | 8 | **Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_ 9 | 10 | - [Lit Protocol JS SDK](#lit-protocol-js-sdk) 11 | - [Support](#support) 12 | 13 | 14 | 15 | # Lit Protocol JS SDK 16 | 17 | Docs for the JS SDK live here: https://developer.litprotocol.com/docs/SDK/intro 18 | 19 | ## Support 20 | 21 | If you need help, join our discord: https://litgateway.com/discord 22 | -------------------------------------------------------------------------------- /packages/sdk-browser-standalone/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-browser-standalone", 3 | "version": "1.1.250", 4 | "main": "build/index.web.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@ethersproject/bytes": "^5.5.0", 8 | "@ethersproject/contracts": "^5.2.0", 9 | "@ethersproject/hash": "^5.4.0", 10 | "@ethersproject/providers": "^5.2.0", 11 | "@ethersproject/strings": "^5.5.0", 12 | "@ethersproject/units": "^5.4.0", 13 | "@ethersproject/wallet": "^5.2.0", 14 | "@walletconnect/ethereum-provider": "1.7.8", 15 | "buffer": "^6.0.3", 16 | "bufferutil": "^4.0.6", 17 | "cross-blob": "^3.0.1", 18 | "jszip": "^3.6.0", 19 | "lit-connect-modal": "^0.1.11", 20 | "lit-siwe": "^1.1.8", 21 | "node-fetch": "^3.2.3", 22 | "pako": "^2.0.4", 23 | "tslib": "^2.3.1", 24 | "tweetnacl": "^1.0.3", 25 | "tweetnacl-util": "^0.15.1", 26 | "utf-8-validate": "^5.0.8" 27 | }, 28 | "devDependencies": { 29 | "esbuild": "^0.14.25", 30 | "esbuild-node-builtins": "^0.1.0", 31 | "genversion": "^3.0.1", 32 | "microbundle": "^0.13.0", 33 | "semver-bump": "^1.0.0", 34 | "standard": "^16.0.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/sdk-browser-standalone/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-browser-standalone", 3 | "version": "1.1.215", 4 | "main": "build/index.web.js", 5 | "license": "MIT" 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk-browser/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build/index*.js 14 | /build/index*.js.map 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .idea 28 | -------------------------------------------------------------------------------- /packages/sdk-browser/.npmignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | -------------------------------------------------------------------------------- /packages/sdk-browser/README.md: -------------------------------------------------------------------------------- 1 | This package is simply the browser build of the Lit-JS-SDK. Importing this package is the same as importing the main Lit-JS-SDK package (`import LitJsSdk from 'lit-js-sdk'`) except this package has less extra stuff you don't need. 2 | 3 | 4 | 5 | 6 | **Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_ 7 | 8 | - [Lit Protocol JS SDK](#lit-protocol-js-sdk) 9 | - [Support](#support) 10 | 11 | 12 | 13 | # Lit Protocol JS SDK 14 | 15 | Docs for the JS SDK live here: https://developer.litprotocol.com/docs/SDK/intro 16 | 17 | ## Support 18 | 19 | If you need help, join our discord: https://litgateway.com/discord 20 | -------------------------------------------------------------------------------- /packages/sdk-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-browser", 3 | "version": "1.1.250", 4 | "main": "build/index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@ethersproject/bytes": "^5.5.0", 8 | "@ethersproject/contracts": "^5.2.0", 9 | "@ethersproject/hash": "^5.4.0", 10 | "@ethersproject/providers": "^5.2.0", 11 | "@ethersproject/strings": "^5.5.0", 12 | "@ethersproject/units": "^5.4.0", 13 | "@ethersproject/wallet": "^5.2.0", 14 | "@walletconnect/ethereum-provider": "1.7.8", 15 | "buffer": "^6.0.3", 16 | "bufferutil": "^4.0.6", 17 | "cross-blob": "^3.0.1", 18 | "jszip": "^3.6.0", 19 | "lit-connect-modal": "^0.1.11", 20 | "lit-siwe": "^1.1.8", 21 | "node-fetch": "^3.2.3", 22 | "pako": "^2.0.4", 23 | "tslib": "^2.3.1", 24 | "tweetnacl": "^1.0.3", 25 | "tweetnacl-util": "^0.15.1", 26 | "utf-8-validate": "^5.0.8" 27 | }, 28 | "devDependencies": { 29 | "esbuild": "^0.14.25", 30 | "esbuild-node-builtins": "^0.1.0", 31 | "genversion": "^3.0.1", 32 | "microbundle": "^0.13.0", 33 | "semver-bump": "^1.0.0", 34 | "standard": "^16.0.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/sdk-browser/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-browser", 3 | "version": "1.1.215", 4 | "main": "build/index.js", 5 | "license": "MIT", 6 | "dependencies": [], 7 | "devDependencies": [] 8 | } 9 | -------------------------------------------------------------------------------- /packages/sdk-nodejs/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build/index*.js 14 | /build/index*.js.map 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .idea 28 | -------------------------------------------------------------------------------- /packages/sdk-nodejs/.npmignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .cache 8 | 9 | # testing 10 | /coverage 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | -------------------------------------------------------------------------------- /packages/sdk-nodejs/README.md: -------------------------------------------------------------------------------- 1 | This package is simply the nodejs build of the Lit-JS-SDK. Importing this package is the same as importing the nodejs Lit-JS-SDK package (`import LitJsSdk from 'lit-js-sdk/build/index.node.js'`) except this package has less extra stuff you don't need. 2 | 3 | 4 | 5 | 6 | **Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_ 7 | 8 | - [Lit Protocol JS SDK](#lit-protocol-js-sdk) 9 | - [Support](#support) 10 | 11 | 12 | 13 | # Lit Protocol JS SDK 14 | 15 | Docs for the JS SDK live here: https://developer.litprotocol.com/docs/SDK/intro 16 | 17 | ## Support 18 | 19 | If you need help, join our discord: https://litgateway.com/discord 20 | -------------------------------------------------------------------------------- /packages/sdk-nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-nodejs", 3 | "version": "1.1.250", 4 | "main": "build/index.node.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@ethersproject/bytes": "^5.5.0", 8 | "@ethersproject/contracts": "^5.2.0", 9 | "@ethersproject/hash": "^5.4.0", 10 | "@ethersproject/providers": "^5.2.0", 11 | "@ethersproject/strings": "^5.5.0", 12 | "@ethersproject/units": "^5.4.0", 13 | "@ethersproject/wallet": "^5.2.0", 14 | "@walletconnect/ethereum-provider": "1.7.8", 15 | "buffer": "^6.0.3", 16 | "bufferutil": "^4.0.6", 17 | "cross-blob": "^3.0.1", 18 | "jszip": "^3.6.0", 19 | "lit-connect-modal": "^0.1.11", 20 | "lit-siwe": "^1.1.8", 21 | "node-fetch": "^3.2.3", 22 | "pako": "^2.0.4", 23 | "tslib": "^2.3.1", 24 | "tweetnacl": "^1.0.3", 25 | "tweetnacl-util": "^0.15.1", 26 | "utf-8-validate": "^5.0.8" 27 | }, 28 | "devDependencies": { 29 | "esbuild": "^0.14.25", 30 | "esbuild-node-builtins": "^0.1.0", 31 | "genversion": "^3.0.1", 32 | "microbundle": "^0.13.0", 33 | "semver-bump": "^1.0.0", 34 | "standard": "^16.0.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/sdk-nodejs/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lit-protocol/sdk-nodejs", 3 | "version": "1.1.215", 4 | "main": "build/index.node.js", 5 | "license": "MIT" 6 | } 7 | -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | yarn versionBump 4 | RESULT=$(cat src/version.js | grep -E -o "'.*'") 5 | VERSION="${RESULT:1:${#RESULT}-2}" # strip the 's at the beginning and end 6 | 7 | ./gen_docs.sh 8 | 9 | yarn build 10 | yarn buildWeb 11 | yarn buildNode 12 | 13 | yarn publish --new-version $VERSION 14 | 15 | ./create_subpackage_packagejson.sh 16 | 17 | # copy the nodejs build 18 | cp build/index.node.js packages/sdk-nodejs/build/ 19 | cd packages/sdk-nodejs 20 | yarn publish --new-version $VERSION --no-git-tag-version 21 | 22 | cd ../.. 23 | 24 | 25 | # copy the browser build 26 | cp build/index.js packages/sdk-browser/build/ 27 | cd packages/sdk-browser 28 | yarn publish --new-version $VERSION --no-git-tag-version 29 | 30 | cd ../.. 31 | 32 | # copy the browser-standalone build 33 | cp build/index.web.js packages/sdk-browser-standalone/build/ 34 | cd packages/sdk-browser-standalone 35 | yarn publish --new-version $VERSION --no-git-tag-version 36 | 37 | 38 | echo "Don't forget to git push to get this running on the netlify cdn" -------------------------------------------------------------------------------- /src/abis/ERC20.json: -------------------------------------------------------------------------------- 1 | { 2 | "abi": [ 3 | { 4 | "constant": true, 5 | "inputs": [], 6 | "name": "name", 7 | "outputs": [ 8 | { 9 | "name": "", 10 | "type": "string" 11 | } 12 | ], 13 | "payable": false, 14 | "stateMutability": "view", 15 | "type": "function" 16 | }, 17 | { 18 | "constant": false, 19 | "inputs": [ 20 | { 21 | "name": "_spender", 22 | "type": "address" 23 | }, 24 | { 25 | "name": "_value", 26 | "type": "uint256" 27 | } 28 | ], 29 | "name": "approve", 30 | "outputs": [ 31 | { 32 | "name": "", 33 | "type": "bool" 34 | } 35 | ], 36 | "payable": false, 37 | "stateMutability": "nonpayable", 38 | "type": "function" 39 | }, 40 | { 41 | "constant": true, 42 | "inputs": [], 43 | "name": "totalSupply", 44 | "outputs": [ 45 | { 46 | "name": "", 47 | "type": "uint256" 48 | } 49 | ], 50 | "payable": false, 51 | "stateMutability": "view", 52 | "type": "function" 53 | }, 54 | { 55 | "constant": false, 56 | "inputs": [ 57 | { 58 | "name": "_from", 59 | "type": "address" 60 | }, 61 | { 62 | "name": "_to", 63 | "type": "address" 64 | }, 65 | { 66 | "name": "_value", 67 | "type": "uint256" 68 | } 69 | ], 70 | "name": "transferFrom", 71 | "outputs": [ 72 | { 73 | "name": "", 74 | "type": "bool" 75 | } 76 | ], 77 | "payable": false, 78 | "stateMutability": "nonpayable", 79 | "type": "function" 80 | }, 81 | { 82 | "constant": true, 83 | "inputs": [], 84 | "name": "decimals", 85 | "outputs": [ 86 | { 87 | "name": "", 88 | "type": "uint8" 89 | } 90 | ], 91 | "payable": false, 92 | "stateMutability": "view", 93 | "type": "function" 94 | }, 95 | { 96 | "constant": true, 97 | "inputs": [ 98 | { 99 | "name": "_owner", 100 | "type": "address" 101 | } 102 | ], 103 | "name": "balanceOf", 104 | "outputs": [ 105 | { 106 | "name": "balance", 107 | "type": "uint256" 108 | } 109 | ], 110 | "payable": false, 111 | "stateMutability": "view", 112 | "type": "function" 113 | }, 114 | { 115 | "constant": true, 116 | "inputs": [], 117 | "name": "symbol", 118 | "outputs": [ 119 | { 120 | "name": "", 121 | "type": "string" 122 | } 123 | ], 124 | "payable": false, 125 | "stateMutability": "view", 126 | "type": "function" 127 | }, 128 | { 129 | "constant": false, 130 | "inputs": [ 131 | { 132 | "name": "_to", 133 | "type": "address" 134 | }, 135 | { 136 | "name": "_value", 137 | "type": "uint256" 138 | } 139 | ], 140 | "name": "transfer", 141 | "outputs": [ 142 | { 143 | "name": "", 144 | "type": "bool" 145 | } 146 | ], 147 | "payable": false, 148 | "stateMutability": "nonpayable", 149 | "type": "function" 150 | }, 151 | { 152 | "constant": true, 153 | "inputs": [ 154 | { 155 | "name": "_owner", 156 | "type": "address" 157 | }, 158 | { 159 | "name": "_spender", 160 | "type": "address" 161 | } 162 | ], 163 | "name": "allowance", 164 | "outputs": [ 165 | { 166 | "name": "", 167 | "type": "uint256" 168 | } 169 | ], 170 | "payable": false, 171 | "stateMutability": "view", 172 | "type": "function" 173 | }, 174 | { 175 | "payable": true, 176 | "stateMutability": "payable", 177 | "type": "fallback" 178 | }, 179 | { 180 | "anonymous": false, 181 | "inputs": [ 182 | { 183 | "indexed": true, 184 | "name": "owner", 185 | "type": "address" 186 | }, 187 | { 188 | "indexed": true, 189 | "name": "spender", 190 | "type": "address" 191 | }, 192 | { 193 | "indexed": false, 194 | "name": "value", 195 | "type": "uint256" 196 | } 197 | ], 198 | "name": "Approval", 199 | "type": "event" 200 | }, 201 | { 202 | "anonymous": false, 203 | "inputs": [ 204 | { 205 | "indexed": true, 206 | "name": "from", 207 | "type": "address" 208 | }, 209 | { 210 | "indexed": true, 211 | "name": "to", 212 | "type": "address" 213 | }, 214 | { 215 | "indexed": false, 216 | "name": "value", 217 | "type": "uint256" 218 | } 219 | ], 220 | "name": "Transfer", 221 | "type": "event" 222 | } 223 | ] 224 | } 225 | -------------------------------------------------------------------------------- /src/abis/LIT.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractName": "LIT", 3 | "abi": [ 4 | { 5 | "inputs": [], 6 | "stateMutability": "nonpayable", 7 | "type": "constructor" 8 | }, 9 | { 10 | "anonymous": false, 11 | "inputs": [ 12 | { 13 | "indexed": true, 14 | "internalType": "address", 15 | "name": "account", 16 | "type": "address" 17 | }, 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "operator", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": false, 26 | "internalType": "bool", 27 | "name": "approved", 28 | "type": "bool" 29 | } 30 | ], 31 | "name": "ApprovalForAll", 32 | "type": "event" 33 | }, 34 | { 35 | "anonymous": false, 36 | "inputs": [ 37 | { 38 | "indexed": false, 39 | "internalType": "address", 40 | "name": "userAddress", 41 | "type": "address" 42 | }, 43 | { 44 | "indexed": false, 45 | "internalType": "address payable", 46 | "name": "relayerAddress", 47 | "type": "address" 48 | }, 49 | { 50 | "indexed": false, 51 | "internalType": "bytes", 52 | "name": "functionSignature", 53 | "type": "bytes" 54 | } 55 | ], 56 | "name": "MetaTransactionExecuted", 57 | "type": "event" 58 | }, 59 | { 60 | "anonymous": false, 61 | "inputs": [ 62 | { 63 | "indexed": true, 64 | "internalType": "address", 65 | "name": "operator", 66 | "type": "address" 67 | }, 68 | { 69 | "indexed": true, 70 | "internalType": "address", 71 | "name": "from", 72 | "type": "address" 73 | }, 74 | { 75 | "indexed": true, 76 | "internalType": "address", 77 | "name": "to", 78 | "type": "address" 79 | }, 80 | { 81 | "indexed": false, 82 | "internalType": "uint256[]", 83 | "name": "ids", 84 | "type": "uint256[]" 85 | }, 86 | { 87 | "indexed": false, 88 | "internalType": "uint256[]", 89 | "name": "values", 90 | "type": "uint256[]" 91 | } 92 | ], 93 | "name": "TransferBatch", 94 | "type": "event" 95 | }, 96 | { 97 | "anonymous": false, 98 | "inputs": [ 99 | { 100 | "indexed": true, 101 | "internalType": "address", 102 | "name": "operator", 103 | "type": "address" 104 | }, 105 | { 106 | "indexed": true, 107 | "internalType": "address", 108 | "name": "from", 109 | "type": "address" 110 | }, 111 | { 112 | "indexed": true, 113 | "internalType": "address", 114 | "name": "to", 115 | "type": "address" 116 | }, 117 | { 118 | "indexed": false, 119 | "internalType": "uint256", 120 | "name": "id", 121 | "type": "uint256" 122 | }, 123 | { 124 | "indexed": false, 125 | "internalType": "uint256", 126 | "name": "value", 127 | "type": "uint256" 128 | } 129 | ], 130 | "name": "TransferSingle", 131 | "type": "event" 132 | }, 133 | { 134 | "anonymous": false, 135 | "inputs": [ 136 | { 137 | "indexed": false, 138 | "internalType": "string", 139 | "name": "value", 140 | "type": "string" 141 | }, 142 | { 143 | "indexed": true, 144 | "internalType": "uint256", 145 | "name": "id", 146 | "type": "uint256" 147 | } 148 | ], 149 | "name": "URI", 150 | "type": "event" 151 | }, 152 | { 153 | "inputs": [], 154 | "name": "ERC712_VERSION", 155 | "outputs": [ 156 | { 157 | "internalType": "string", 158 | "name": "", 159 | "type": "string" 160 | } 161 | ], 162 | "stateMutability": "view", 163 | "type": "function", 164 | "constant": true 165 | }, 166 | { 167 | "inputs": [ 168 | { 169 | "internalType": "address", 170 | "name": "account", 171 | "type": "address" 172 | }, 173 | { 174 | "internalType": "uint256", 175 | "name": "id", 176 | "type": "uint256" 177 | } 178 | ], 179 | "name": "balanceOf", 180 | "outputs": [ 181 | { 182 | "internalType": "uint256", 183 | "name": "", 184 | "type": "uint256" 185 | } 186 | ], 187 | "stateMutability": "view", 188 | "type": "function", 189 | "constant": true 190 | }, 191 | { 192 | "inputs": [ 193 | { 194 | "internalType": "address[]", 195 | "name": "accounts", 196 | "type": "address[]" 197 | }, 198 | { 199 | "internalType": "uint256[]", 200 | "name": "ids", 201 | "type": "uint256[]" 202 | } 203 | ], 204 | "name": "balanceOfBatch", 205 | "outputs": [ 206 | { 207 | "internalType": "uint256[]", 208 | "name": "", 209 | "type": "uint256[]" 210 | } 211 | ], 212 | "stateMutability": "view", 213 | "type": "function", 214 | "constant": true 215 | }, 216 | { 217 | "inputs": [ 218 | { 219 | "internalType": "address", 220 | "name": "userAddress", 221 | "type": "address" 222 | }, 223 | { 224 | "internalType": "bytes", 225 | "name": "functionSignature", 226 | "type": "bytes" 227 | }, 228 | { 229 | "internalType": "bytes32", 230 | "name": "sigR", 231 | "type": "bytes32" 232 | }, 233 | { 234 | "internalType": "bytes32", 235 | "name": "sigS", 236 | "type": "bytes32" 237 | }, 238 | { 239 | "internalType": "uint8", 240 | "name": "sigV", 241 | "type": "uint8" 242 | } 243 | ], 244 | "name": "executeMetaTransaction", 245 | "outputs": [ 246 | { 247 | "internalType": "bytes", 248 | "name": "", 249 | "type": "bytes" 250 | } 251 | ], 252 | "stateMutability": "payable", 253 | "type": "function", 254 | "payable": true 255 | }, 256 | { 257 | "inputs": [], 258 | "name": "getChainId", 259 | "outputs": [ 260 | { 261 | "internalType": "uint256", 262 | "name": "", 263 | "type": "uint256" 264 | } 265 | ], 266 | "stateMutability": "pure", 267 | "type": "function", 268 | "constant": true 269 | }, 270 | { 271 | "inputs": [], 272 | "name": "getDomainSeperator", 273 | "outputs": [ 274 | { 275 | "internalType": "bytes32", 276 | "name": "", 277 | "type": "bytes32" 278 | } 279 | ], 280 | "stateMutability": "view", 281 | "type": "function", 282 | "constant": true 283 | }, 284 | { 285 | "inputs": [ 286 | { 287 | "internalType": "address", 288 | "name": "user", 289 | "type": "address" 290 | } 291 | ], 292 | "name": "getNonce", 293 | "outputs": [ 294 | { 295 | "internalType": "uint256", 296 | "name": "nonce", 297 | "type": "uint256" 298 | } 299 | ], 300 | "stateMutability": "view", 301 | "type": "function", 302 | "constant": true 303 | }, 304 | { 305 | "inputs": [ 306 | { 307 | "internalType": "address", 308 | "name": "from", 309 | "type": "address" 310 | }, 311 | { 312 | "internalType": "address", 313 | "name": "to", 314 | "type": "address" 315 | }, 316 | { 317 | "internalType": "uint256[]", 318 | "name": "ids", 319 | "type": "uint256[]" 320 | }, 321 | { 322 | "internalType": "uint256[]", 323 | "name": "amounts", 324 | "type": "uint256[]" 325 | }, 326 | { 327 | "internalType": "bytes", 328 | "name": "data", 329 | "type": "bytes" 330 | } 331 | ], 332 | "name": "safeBatchTransferFrom", 333 | "outputs": [], 334 | "stateMutability": "nonpayable", 335 | "type": "function" 336 | }, 337 | { 338 | "inputs": [ 339 | { 340 | "internalType": "address", 341 | "name": "from", 342 | "type": "address" 343 | }, 344 | { 345 | "internalType": "address", 346 | "name": "to", 347 | "type": "address" 348 | }, 349 | { 350 | "internalType": "uint256", 351 | "name": "id", 352 | "type": "uint256" 353 | }, 354 | { 355 | "internalType": "uint256", 356 | "name": "amount", 357 | "type": "uint256" 358 | }, 359 | { 360 | "internalType": "bytes", 361 | "name": "data", 362 | "type": "bytes" 363 | } 364 | ], 365 | "name": "safeTransferFrom", 366 | "outputs": [], 367 | "stateMutability": "nonpayable", 368 | "type": "function" 369 | }, 370 | { 371 | "inputs": [ 372 | { 373 | "internalType": "address", 374 | "name": "operator", 375 | "type": "address" 376 | }, 377 | { 378 | "internalType": "bool", 379 | "name": "approved", 380 | "type": "bool" 381 | } 382 | ], 383 | "name": "setApprovalForAll", 384 | "outputs": [], 385 | "stateMutability": "nonpayable", 386 | "type": "function" 387 | }, 388 | { 389 | "inputs": [ 390 | { 391 | "internalType": "bytes4", 392 | "name": "interfaceId", 393 | "type": "bytes4" 394 | } 395 | ], 396 | "name": "supportsInterface", 397 | "outputs": [ 398 | { 399 | "internalType": "bool", 400 | "name": "", 401 | "type": "bool" 402 | } 403 | ], 404 | "stateMutability": "view", 405 | "type": "function", 406 | "constant": true 407 | }, 408 | { 409 | "inputs": [], 410 | "name": "tokenIds", 411 | "outputs": [ 412 | { 413 | "internalType": "uint256", 414 | "name": "", 415 | "type": "uint256" 416 | } 417 | ], 418 | "stateMutability": "view", 419 | "type": "function", 420 | "constant": true 421 | }, 422 | { 423 | "inputs": [ 424 | { 425 | "internalType": "uint256", 426 | "name": "", 427 | "type": "uint256" 428 | } 429 | ], 430 | "name": "uri", 431 | "outputs": [ 432 | { 433 | "internalType": "string", 434 | "name": "", 435 | "type": "string" 436 | } 437 | ], 438 | "stateMutability": "view", 439 | "type": "function", 440 | "constant": true 441 | }, 442 | { 443 | "inputs": [ 444 | { 445 | "internalType": "uint256", 446 | "name": "quantity", 447 | "type": "uint256" 448 | } 449 | ], 450 | "name": "mint", 451 | "outputs": [ 452 | { 453 | "internalType": "uint256", 454 | "name": "", 455 | "type": "uint256" 456 | } 457 | ], 458 | "stateMutability": "nonpayable", 459 | "type": "function" 460 | }, 461 | { 462 | "inputs": [ 463 | { 464 | "internalType": "address", 465 | "name": "_owner", 466 | "type": "address" 467 | }, 468 | { 469 | "internalType": "address", 470 | "name": "_operator", 471 | "type": "address" 472 | } 473 | ], 474 | "name": "isApprovedForAll", 475 | "outputs": [ 476 | { 477 | "internalType": "bool", 478 | "name": "isOperator", 479 | "type": "bool" 480 | } 481 | ], 482 | "stateMutability": "view", 483 | "type": "function", 484 | "constant": true 485 | }, 486 | { 487 | "inputs": [ 488 | { 489 | "internalType": "bool", 490 | "name": "enabled", 491 | "type": "bool" 492 | } 493 | ], 494 | "name": "setOpenseaProxyEnabled", 495 | "outputs": [], 496 | "stateMutability": "nonpayable", 497 | "type": "function" 498 | }, 499 | { 500 | "inputs": [ 501 | { 502 | "internalType": "address", 503 | "name": "newAdmin", 504 | "type": "address" 505 | } 506 | ], 507 | "name": "changeAdmin", 508 | "outputs": [], 509 | "stateMutability": "nonpayable", 510 | "type": "function" 511 | }, 512 | { 513 | "inputs": [ 514 | { 515 | "internalType": "string", 516 | "name": "uri", 517 | "type": "string" 518 | } 519 | ], 520 | "name": "setURI", 521 | "outputs": [], 522 | "stateMutability": "nonpayable", 523 | "type": "function" 524 | }, 525 | { 526 | "inputs": [], 527 | "name": "getAdmin", 528 | "outputs": [ 529 | { 530 | "internalType": "address", 531 | "name": "", 532 | "type": "address" 533 | } 534 | ], 535 | "stateMutability": "view", 536 | "type": "function", 537 | "constant": true 538 | } 539 | ] 540 | } 541 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import "regenerator-runtime/runtime"; 2 | 3 | // polyfill buffer if needed 4 | import { Buffer as buf } from "buffer/"; 5 | if (typeof Buffer === "undefined" || !Buffer) { 6 | globalThis.Buffer = buf; 7 | } 8 | 9 | // add window global on nodejs 10 | import { 11 | listenForChildFrameMessages, 12 | listenForFrameParentMessages, 13 | inIframe, 14 | } from "./utils/frameComms"; 15 | 16 | if (typeof window !== "undefined") { 17 | // only run this in browser 18 | if (inIframe()) { 19 | listenForFrameParentMessages(); 20 | } else { 21 | listenForChildFrameMessages(); 22 | } 23 | } 24 | 25 | import { 26 | encryptString, 27 | decryptString, 28 | zipAndEncryptString, 29 | zipAndEncryptFiles, 30 | encryptZip, 31 | decryptZip, 32 | encryptFile, 33 | decryptFile, 34 | createHtmlLIT, 35 | toggleLock, 36 | unlockLitWithKey, 37 | verifyJwt, 38 | encryptFileAndZipWithMetadata, 39 | decryptZipFileWithMetadata, 40 | humanizeAccessControlConditions, 41 | getTokenList, 42 | checkAndSignAuthMessage, 43 | } from "./utils/lit"; 44 | 45 | import { 46 | connectWeb3, 47 | disconnectWeb3, 48 | mintLIT, 49 | signAndSaveAuthMessage, 50 | findLITs, 51 | sendLIT, 52 | decimalPlaces, 53 | lookupNameServiceAddress, 54 | encodeCallData, 55 | decodeCallResult, 56 | signMessageAsync, 57 | } from "./utils/eth"; 58 | 59 | import { 60 | decryptWithPrivKey, 61 | encryptWithPubKey, 62 | canonicalAccessControlConditionFormatter, 63 | canonicalEVMContractConditionFormatter, 64 | canonicalUnifiedAccessControlConditionFormatter, 65 | hashAccessControlConditions, 66 | hashEVMContractConditions, 67 | hashUnifiedAccessControlConditions, 68 | encryptWithSymmetricKey, 69 | decryptWithSymmetricKey, 70 | generateSymmetricKey, 71 | importSymmetricKey, 72 | } from "./utils/crypto"; 73 | 74 | import { 75 | fileToDataUrl, 76 | injectViewerIFrame, 77 | downloadFile, 78 | uint8arrayFromString, 79 | uint8arrayToString, 80 | blobToBase64String, 81 | base64StringToBlob, 82 | } from "./utils/browser"; 83 | 84 | import { LIT_CHAINS, LIT_SVM_CHAINS, ALL_LIT_CHAINS } from "./lib/constants"; 85 | import { printError } from "./lib/utils"; 86 | import { initWasmBlsSdk, wasmBlsSdkHelpers } from "./lib/bls-sdk.js"; 87 | 88 | import LitNodeClient from "./utils/litNodeClient"; 89 | 90 | import { litJsSdkLoadedInALIT } from "./utils/init"; 91 | 92 | import { version } from "./version"; 93 | 94 | initWasmBlsSdk().then((exports) => { 95 | globalThis.wasmExports = exports; 96 | // console.log("wasmExports loaded"); 97 | }); 98 | 99 | const functions = { 100 | encryptString, 101 | decryptString, 102 | zipAndEncryptString, 103 | zipAndEncryptFiles, 104 | encryptZip, 105 | decryptZip, 106 | encryptFile, 107 | decryptFile, 108 | connectWeb3, 109 | disconnectWeb3, 110 | checkAndSignAuthMessage, 111 | signAndSaveAuthMessage, 112 | createHtmlLIT, 113 | mintLIT, 114 | toggleLock, 115 | encryptWithSymmetricKey, 116 | decryptWithSymmetricKey, 117 | LIT_CHAINS, 118 | LIT_SVM_CHAINS, 119 | ALL_LIT_CHAINS, 120 | LitNodeClient, 121 | encryptWithPubKey, 122 | decryptWithPrivKey, 123 | fileToDataUrl, 124 | findLITs, 125 | sendLIT, 126 | litJsSdkLoadedInALIT, 127 | unlockLitWithKey, 128 | injectViewerIFrame, 129 | printError, 130 | canonicalAccessControlConditionFormatter, 131 | canonicalEVMContractConditionFormatter, 132 | canonicalUnifiedAccessControlConditionFormatter, 133 | verifyJwt, 134 | encryptFileAndZipWithMetadata, 135 | hashAccessControlConditions, 136 | hashEVMContractConditions, 137 | hashUnifiedAccessControlConditions, 138 | decryptZipFileWithMetadata, 139 | downloadFile, 140 | decimalPlaces, 141 | humanizeAccessControlConditions, 142 | lookupNameServiceAddress, 143 | getTokenList, 144 | version, 145 | encodeCallData, 146 | decodeCallResult, 147 | uint8arrayFromString, 148 | uint8arrayToString, 149 | signMessageAsync, 150 | wasmBlsSdkHelpers, 151 | initWasmBlsSdk, 152 | generateSymmetricKey, 153 | importSymmetricKey, 154 | blobToBase64String, 155 | base64StringToBlob, 156 | }; 157 | 158 | module.exports = functions; 159 | -------------------------------------------------------------------------------- /src/lib/constants.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {Object} LITChain 3 | * @property {string} vmType - Either EVM for an Ethereum compatible chain or SVM for a Solana compatible chain 4 | * @property {string} name - The human readable name of the chain 5 | */ 6 | 7 | /** 8 | * @typedef {Object} LITEVMChain 9 | * @property {string} contractAddress - The address of the token contract for the optional predeployed ERC1155 contract. Only present on EVM chains. 10 | * @property {string} chainId - The chain ID of the chain that this token contract is deployed on. Used for EVM chains. 11 | * @property {string} name - The human readable name of the chain 12 | */ 13 | 14 | /** 15 | * @typedef {Object} LITSVMChain 16 | * @property {string} name - The human readable name of the chain 17 | */ 18 | 19 | /** 20 | * @typedef {Object} LITCosmosChain 21 | * @property {string} name - The human readable name of the chain 22 | */ 23 | 24 | /** 25 | * EVM Chains supported by the LIT protocol. Each chain includes an optional pre-deployed token contract that you may use for minting LITs. These are ERC1155 contracts that let you mint any quantity of a given token. Use the chain name as a key in this object. 26 | * @constant 27 | * @type {LITEVMChain} 28 | * @default 29 | */ 30 | export const LIT_CHAINS = { 31 | ethereum: { 32 | contractAddress: "0xA54F7579fFb3F98bd8649fF02813F575f9b3d353", 33 | chainId: 1, 34 | name: "Ethereum", 35 | symbol: "ETH", 36 | decimals: 18, 37 | type: "ERC1155", 38 | rpcUrls: [ 39 | "https://eth-mainnet.alchemyapi.io/v2/EuGnkVlzVoEkzdg0lpCarhm8YHOxWVxE", 40 | ], 41 | blockExplorerUrls: ["https://etherscan.io"], 42 | vmType: "EVM", 43 | }, 44 | polygon: { 45 | contractAddress: "0x7C7757a9675f06F3BE4618bB68732c4aB25D2e88", 46 | chainId: 137, 47 | name: "Polygon", 48 | symbol: "MATIC", 49 | decimals: 18, 50 | rpcUrls: ["https://polygon-rpc.com"], 51 | blockExplorerUrls: ["https://explorer.matic.network"], 52 | type: "ERC1155", 53 | vmType: "EVM", 54 | }, 55 | fantom: { 56 | contractAddress: "0x5bD3Fe8Ab542f0AaBF7552FAAf376Fd8Aa9b3869", 57 | chainId: 250, 58 | name: "Fantom", 59 | symbol: "FTM", 60 | decimals: 18, 61 | rpcUrls: ["https://rpcapi.fantom.network"], 62 | blockExplorerUrls: ["https://ftmscan.com"], 63 | type: "ERC1155", 64 | vmType: "EVM", 65 | }, 66 | xdai: { 67 | contractAddress: "0xDFc2Fd83dFfD0Dafb216F412aB3B18f2777406aF", 68 | chainId: 100, 69 | name: "xDai", 70 | symbol: "xDai", 71 | decimals: 18, 72 | rpcUrls: ["https://rpc.gnosischain.com"], 73 | blockExplorerUrls: [" https://blockscout.com/xdai/mainnet"], 74 | type: "ERC1155", 75 | vmType: "EVM", 76 | }, 77 | bsc: { 78 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 79 | chainId: 56, 80 | name: "Binance Smart Chain", 81 | symbol: "BNB", 82 | decimals: 18, 83 | rpcUrls: ["https://bsc-dataseed.binance.org/"], 84 | blockExplorerUrls: [" https://bscscan.com/"], 85 | type: "ERC1155", 86 | vmType: "EVM", 87 | }, 88 | arbitrum: { 89 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 90 | chainId: 42161, 91 | name: "Arbitrum", 92 | symbol: "AETH", 93 | decimals: 18, 94 | type: "ERC1155", 95 | rpcUrls: ["https://arb1.arbitrum.io/rpc"], 96 | blockExplorerUrls: ["https://arbiscan.io/"], 97 | vmType: "EVM", 98 | }, 99 | avalanche: { 100 | contractAddress: "0xBB118507E802D17ECDD4343797066dDc13Cde7C6", 101 | chainId: 43114, 102 | name: "Avalanche", 103 | symbol: "AVAX", 104 | decimals: 18, 105 | type: "ERC1155", 106 | rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"], 107 | blockExplorerUrls: ["https://snowtrace.io/"], 108 | vmType: "EVM", 109 | }, 110 | fuji: { 111 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 112 | chainId: 43113, 113 | name: "Avalanche FUJI Testnet", 114 | symbol: "AVAX", 115 | decimals: 18, 116 | type: "ERC1155", 117 | rpcUrls: ["https://api.avax-test.network/ext/bc/C/rpc"], 118 | blockExplorerUrls: ["https://testnet.snowtrace.io/"], 119 | vmType: "EVM", 120 | }, 121 | harmony: { 122 | contractAddress: "0xBB118507E802D17ECDD4343797066dDc13Cde7C6", 123 | chainId: 1666600000, 124 | name: "Harmony", 125 | symbol: "ONE", 126 | decimals: 18, 127 | type: "ERC1155", 128 | rpcUrls: ["https://api.harmony.one"], 129 | blockExplorerUrls: ["https://explorer.harmony.one/"], 130 | vmType: "EVM", 131 | }, 132 | kovan: { 133 | contractAddress: "0x9dB60Db3Dd9311861D87D33B0463AaD9fB4bb0E6", 134 | chainId: 42, 135 | name: "Kovan", 136 | symbol: "ETH", 137 | decimals: 18, 138 | rpcUrls: ["https://kovan.infura.io/v3/ddf1ca3700f34497bca2bf03607fde38"], 139 | blockExplorerUrls: ["https://kovan.etherscan.io"], 140 | type: "ERC1155", 141 | vmType: "EVM", 142 | }, 143 | mumbai: { 144 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 145 | chainId: 80001, 146 | name: "Mumbai", 147 | symbol: "MATIC", 148 | decimals: 18, 149 | rpcUrls: [ 150 | "https://rpc-mumbai.maticvigil.com/v1/96bf5fa6e03d272fbd09de48d03927b95633726c", 151 | ], 152 | blockExplorerUrls: ["https://mumbai.polygonscan.com"], 153 | type: "ERC1155", 154 | vmType: "EVM", 155 | }, 156 | goerli: { 157 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 158 | chainId: 5, 159 | name: "Goerli", 160 | symbol: "ETH", 161 | decimals: 18, 162 | rpcUrls: ["https://goerli.infura.io/v3/96dffb3d8c084dec952c61bd6230af34"], 163 | blockExplorerUrls: ["https://goerli.etherscan.io"], 164 | type: "ERC1155", 165 | vmType: "EVM", 166 | }, 167 | ropsten: { 168 | contractAddress: "0x61544f0AE85f8fed6Eb315c406644eb58e15A1E7", 169 | chainId: 3, 170 | name: "Ropsten", 171 | symbol: "ETH", 172 | decimals: 18, 173 | rpcUrls: ["https://ropsten.infura.io/v3/96dffb3d8c084dec952c61bd6230af34"], 174 | blockExplorerUrls: ["https://ropsten.etherscan.io"], 175 | type: "ERC1155", 176 | vmType: "EVM", 177 | }, 178 | rinkeby: { 179 | contractAddress: "0xc716950e5deae248160109f562e1c9bf8e0ca25b", 180 | chainId: 4, 181 | name: "Rinkeby", 182 | symbol: "ETH", 183 | decimals: 18, 184 | rpcUrls: ["https://rinkeby.infura.io/v3/96dffb3d8c084dec952c61bd6230af34"], 185 | blockExplorerUrls: ["https://rinkeby.etherscan.io"], 186 | type: "ERC1155", 187 | vmType: "EVM", 188 | }, 189 | cronos: { 190 | contractAddress: "0xc716950e5DEae248160109F562e1C9bF8E0CA25B", 191 | chainId: 25, 192 | name: "Cronos", 193 | symbol: "CRO", 194 | decimals: 18, 195 | rpcUrls: ["https://evm-cronos.org"], 196 | blockExplorerUrls: ["https://cronos.org/explorer/"], 197 | type: "ERC1155", 198 | vmType: "EVM", 199 | }, 200 | optimism: { 201 | contractAddress: "0xbF68B4c9aCbed79278465007f20a08Fa045281E0", 202 | chainId: 10, 203 | name: "Optimism", 204 | symbol: "ETH", 205 | decimals: 18, 206 | rpcUrls: ["https://mainnet.optimism.io"], 207 | blockExplorerUrls: ["https://optimistic.etherscan.io"], 208 | type: "ERC1155", 209 | vmType: "EVM", 210 | }, 211 | celo: { 212 | contractAddress: "0xBB118507E802D17ECDD4343797066dDc13Cde7C6", 213 | chainId: 42220, 214 | name: "Celo", 215 | symbol: "CELO", 216 | decimals: 18, 217 | rpcUrls: ["https://forno.celo.org"], 218 | blockExplorerUrls: ["https://explorer.celo.org"], 219 | type: "ERC1155", 220 | vmType: "EVM", 221 | }, 222 | aurora: { 223 | contractAddress: null, 224 | chainId: 1313161554, 225 | name: "Aurora", 226 | symbol: "ETH", 227 | decimals: 18, 228 | rpcUrls: ["https://mainnet.aurora.dev"], 229 | blockExplorerUrls: ["https://aurorascan.dev"], 230 | type: null, 231 | vmType: "EVM", 232 | }, 233 | eluvio: { 234 | contractAddress: null, 235 | chainId: 955305, 236 | name: "Eluvio", 237 | symbol: "ELV", 238 | decimals: 18, 239 | rpcUrls: ["https://host-76-74-28-226.contentfabric.io/eth"], 240 | blockExplorerUrls: ["https://explorer.eluv.io"], 241 | type: null, 242 | vmType: "EVM", 243 | }, 244 | alfajores: { 245 | contractAddress: null, 246 | chainId: 44787, 247 | name: "Alfajores", 248 | symbol: "CELO", 249 | decimals: 18, 250 | rpcUrls: ["https://alfajores-forno.celo-testnet.org"], 251 | blockExplorerUrls: ["https://alfajores-blockscout.celo-testnet.org"], 252 | type: null, 253 | vmType: "EVM", 254 | }, 255 | xdc: { 256 | contractAddress: null, 257 | chainId: 50, 258 | name: "XDC Blockchain", 259 | symbol: "XDC", 260 | decimals: 18, 261 | rpcUrls: ["https://rpc.xinfin.network"], 262 | blockExplorerUrls: ["https://explorer.xinfin.network"], 263 | type: null, 264 | vmType: "EVM", 265 | }, 266 | evmos: { 267 | contractAddress: null, 268 | chainId: 9001, 269 | name: "EVMOS", 270 | symbol: "EVMOS", 271 | decimals: 18, 272 | rpcUrls: ["https://eth.bd.evmos.org:8545"], 273 | blockExplorerUrls: ["https://evm.evmos.org"], 274 | type: null, 275 | vmType: "EVM", 276 | }, 277 | evmosTestnet: { 278 | contractAddress: null, 279 | chainId: 9000, 280 | name: "EVMOS Testnet", 281 | symbol: "EVMOS", 282 | decimals: 18, 283 | rpcUrls: ["https://eth.bd.evmos.dev:8545"], 284 | blockExplorerUrls: ["https://evm.evmos.dev"], 285 | type: null, 286 | vmType: "EVM", 287 | }, 288 | bscTestnet: { 289 | contractAddress: null, 290 | chainId: 97, 291 | name: "BSC Testnet", 292 | symbol: "BNB", 293 | decimals: 18, 294 | rpcUrls: ["https://data-seed-prebsc-1-s1.binance.org:8545"], 295 | blockExplorerUrls: ["https://testnet.bscscan.com/"], 296 | type: null, 297 | vmType: "EVM", 298 | }, 299 | baseGoerli: { 300 | contractAddress: null, 301 | chainId: 84531, 302 | name: "Base Goerli", 303 | symbol: "ETH", 304 | decimals: 18, 305 | rpcUrls: ["https://goerli.base.org"], 306 | blockExplorerUrls: ["https://goerli.basescan.org"], 307 | type: null, 308 | vmType: "EVM", 309 | }, 310 | moonbeam: { 311 | contractAddress: null, 312 | chainId: 1284, 313 | name: "Moonbeam", 314 | symbol: "GLMR", 315 | decimals: 18, 316 | rpcUrls: ["https://rpc.api.moonbeam.network"], 317 | blockExplorerUrls: ["https://moonscan.io"], 318 | type: null, 319 | vmType: "EVM", 320 | }, 321 | moonriver: { 322 | contractAddress: null, 323 | chainId: 1285, 324 | name: "Moonriver", 325 | symbol: "MOVR", 326 | decimals: 18, 327 | rpcUrls: ["https://rpc.api.moonriver.moonbeam.network"], 328 | blockExplorerUrls: ["https://moonriver.moonscan.io"], 329 | type: null, 330 | vmType: "EVM", 331 | }, 332 | moonbaseAlpha: { 333 | contractAddress: null, 334 | chainId: 1287, 335 | name: "Moonbase Alpha", 336 | symbol: "DEV", 337 | decimals: 18, 338 | rpcUrls: ["https://rpc.api.moonbase.moonbeam.network"], 339 | blockExplorerUrls: ["https://moonbase.moonscan.io/"], 340 | type: null, 341 | vmType: "EVM", 342 | }, 343 | }; 344 | 345 | /** 346 | * Solana Chains supported by the LIT protocol. Use the chain name as a key in this object. 347 | * @constant 348 | * @type {LITSVMChain} 349 | * @default 350 | */ 351 | export const LIT_SVM_CHAINS = { 352 | solana: { 353 | name: "Solana", 354 | symbol: "SOL", 355 | decimals: 9, 356 | rpcUrls: ["https://api.mainnet-beta.solana.com"], 357 | blockExplorerUrls: ["https://explorer.solana.com/"], 358 | vmType: "SVM", 359 | }, 360 | solanaDevnet: { 361 | name: "Solana Devnet", 362 | symbol: "SOL", 363 | decimals: 9, 364 | rpcUrls: ["https://api.devnet.solana.com"], 365 | blockExplorerUrls: ["https://explorer.solana.com/"], 366 | vmType: "SVM", 367 | }, 368 | solanaTestnet: { 369 | name: "Solana Testnet", 370 | symbol: "SOL", 371 | decimals: 9, 372 | rpcUrls: ["https://api.testnet.solana.com"], 373 | blockExplorerUrls: ["https://explorer.solana.com/"], 374 | vmType: "SVM", 375 | }, 376 | }; 377 | 378 | /** 379 | * Cosmos Chains supported by the LIT protocol. Use the chain name as a key in this object. 380 | * @constant 381 | * @type {LITCosmosChain} 382 | * @default 383 | */ 384 | export const LIT_COSMOS_CHAINS = { 385 | cosmos: { 386 | name: "Cosmos", 387 | symbol: "ATOM", 388 | decimals: 6, 389 | chainId: "cosmoshub-4", 390 | rpcUrls: ["https://lcd-cosmoshub.keplr.app"], 391 | blockExplorerUrls: ["https://atomscan.com/"], 392 | vmType: "CVM", 393 | }, 394 | kyve: { 395 | name: "Kyve", 396 | symbol: "KYVE", 397 | decimals: 6, 398 | chainId: "korellia", 399 | rpcUrls: ["https://api.korellia.kyve.network"], 400 | blockExplorerUrls: ["https://explorer.kyve.network/"], 401 | vmType: "CVM", 402 | }, 403 | evmosCosmos: { 404 | name: "EVMOS Cosmos", 405 | symbol: "EVMOS", 406 | decimals: 18, 407 | chainId: "evmos_9001-2", 408 | rpcUrls: ["https://rest.bd.evmos.org:1317"], 409 | blockExplorerUrls: ["https://evmos.bigdipper.live"], 410 | vmType: "CVM", 411 | }, 412 | evmosCosmosTestnet: { 413 | name: "Evmos Cosmos Testnet", 414 | symbol: "EVMOS", 415 | decimals: 18, 416 | chainId: "evmos_9000-4", 417 | rpcUrls: ["https://rest.bd.evmos.dev:1317"], 418 | blockExplorerUrls: ["https://testnet.bigdipper.live"], 419 | vmType: "CVM", 420 | }, 421 | juno: { 422 | name: "Juno", 423 | symbol: "JUNO", 424 | decimals: 6, 425 | chainId: "juno-1", 426 | rpcUrls: ["https://rest.cosmos.directory/juno"], 427 | blockExplorerUrls: ["https://www.mintscan.io/juno"], 428 | vmType: "CVM", 429 | }, 430 | }; 431 | 432 | /** 433 | * All Chains supported by the LIT protocol. Use the chain name as a key in this object. 434 | * @constant 435 | * @type {LITChain} 436 | * @default 437 | */ 438 | export const ALL_LIT_CHAINS = { 439 | ...LIT_CHAINS, 440 | ...LIT_SVM_CHAINS, 441 | ...LIT_COSMOS_CHAINS, 442 | }; 443 | 444 | export const NETWORK_PUB_KEY = 445 | "9971e835a1fe1a4d78e381eebbe0ddc84fde5119169db816900de796d10187f3c53d65c1202ac083d099a517f34a9b62"; 446 | 447 | // you can either pass a "chain" param to lit functions, which it uses to tell which network your sig came from. 448 | // or, you can pass a authSig that has and of these keys in it to tell which network your sig came from. 449 | export const LIT_AUTH_SIG_CHAIN_KEYS = ["ethereum", "solana", "cosmos", "kyve"]; 450 | -------------------------------------------------------------------------------- /src/lib/utils.js: -------------------------------------------------------------------------------- 1 | import { LIT_AUTH_SIG_CHAIN_KEYS } from "./constants.js"; 2 | 3 | export const printError = (e) => { 4 | console.log("Error Stack", e.stack); 5 | console.log("Error Name", e.name); 6 | console.log("Error Message", e.message); 7 | }; 8 | 9 | export const mostCommonString = (arr) => { 10 | return arr 11 | .sort( 12 | (a, b) => 13 | arr.filter((v) => v === a).length - arr.filter((v) => v === b).length 14 | ) 15 | .pop(); 16 | }; 17 | 18 | export const throwError = ({ message, name, errorCode }) => { 19 | throw new (function () { 20 | this.message = message; 21 | this.name = name; 22 | this.errorCode = errorCode; 23 | })(); 24 | }; 25 | 26 | export const log = (...args) => { 27 | if ( 28 | globalThis && 29 | globalThis.litConfig && 30 | globalThis.litConfig.debug === false 31 | ) { 32 | return; 33 | } 34 | args.unshift("[Lit-JS-SDK]"); 35 | console.log(...args); 36 | }; 37 | 38 | /** 39 | * 40 | * Get the type of a variable, could be an object instance type. 41 | * eg Uint8Array instance should return 'Uint8Array` as string 42 | * or simply a `string` or `int` type 43 | * 44 | * @param { * } value 45 | * @returns { String } type 46 | */ 47 | export const getVarType = (value) => { 48 | return Object.prototype.toString.call(value).slice(8, -1); 49 | // // if it's an object 50 | // if (value instanceof Object) { 51 | // if (value.constructor.name == "Object") { 52 | // return "Object"; 53 | // } 54 | // return value.constructor.name; 55 | // } 56 | 57 | // // if it's other type, like string and int 58 | // return typeof value; 59 | }; 60 | 61 | /** 62 | * 63 | * Check if the given value is the given type 64 | * If not, throw `invalidParamType` error 65 | * 66 | * @param { * } value 67 | * @param { Array } allowedTypes 68 | * @param { string } paramName 69 | * @param { string } functionName 70 | * @param { boolean } throwOnError 71 | * @returns { Boolean } true/false 72 | */ 73 | export const checkType = ({ 74 | value, 75 | allowedTypes, 76 | paramName, 77 | functionName, 78 | throwOnError = true, 79 | }) => { 80 | if (!allowedTypes.includes(getVarType(value))) { 81 | let message = `Expecting ${allowedTypes.join( 82 | " or " 83 | )} type for parameter named ${paramName} in Lit-JS-SDK function ${functionName}(), but received "${getVarType( 84 | value 85 | )}" type instead. value: ${ 86 | value instanceof Object ? JSON.stringify(value) : value 87 | }`; 88 | 89 | if (throwOnError) { 90 | throwError({ 91 | message, 92 | name: "invalidParamType", 93 | errorCode: "invalid_param_type", 94 | }); 95 | } 96 | return false; 97 | } 98 | 99 | return true; 100 | }; 101 | 102 | export const checkIfAuthSigRequiresChainParam = ( 103 | authSig, 104 | chain, 105 | functionName 106 | ) => { 107 | for (const key of LIT_AUTH_SIG_CHAIN_KEYS) { 108 | if (key in authSig) { 109 | return true; 110 | } 111 | } 112 | 113 | // if we're here, then we need the chain param 114 | if ( 115 | !checkType({ 116 | value: chain, 117 | allowedTypes: ["String"], 118 | paramName: "chain", 119 | functionName, 120 | }) 121 | ) 122 | return false; 123 | 124 | return true; 125 | }; 126 | -------------------------------------------------------------------------------- /src/utils/browser.js: -------------------------------------------------------------------------------- 1 | import Uint8arrays from "../lib/uint8arrays"; 2 | const uint8arrayFromStringFromLib = Uint8arrays.fromString; 3 | const uint8arrayToStringFromLib = Uint8arrays.toString; 4 | 5 | /** Convert a Blob to a base64urlpad string. Note: This function returns a promise. 6 | * @param {Blob | File} blob The Blob or File to turn into a base64 string 7 | * @returns {Promise} A promise that resolves to the base64 string 8 | */ 9 | export async function blobToBase64String(blob) { 10 | let ab = await blob.arrayBuffer(); 11 | return uint8arrayToString(new Uint8Array(ab), "base64urlpad"); 12 | } 13 | 14 | /** Convert a base64urlpad string to a Blob. Note: This function DOES NOT return a promise 15 | * @param {String} base64String The base64 string that to turn into a Blob 16 | * @returns {Blob} A blob that contains the decoded base64 data 17 | */ 18 | export function base64StringToBlob(base64String) { 19 | return new Blob([uint8arrayFromString(base64String, "base64urlpad")]); 20 | } 21 | 22 | /** Convert a Uint8Array to a string. Supports various encodings. This is a re-export of https://www.npmjs.com/package/uint8arrays and you can find the list of supported encodings here https://github.com/multiformats/multibase/blob/master/multibase.csv 23 | * @param {Uint8Array} uint8array The Uint8Array to convert to a string 24 | * @param {String} encoding The encoding to use when converting the Uint8Array to a string. 25 | * @returns {String} The string representation of the Uint8Array 26 | */ 27 | export function uint8arrayToString(uint8array, encoding) { 28 | return uint8arrayToStringFromLib(uint8array, encoding); 29 | } 30 | 31 | /** Convert a string to a Uint8Array. Supports various encodings. This is a re-export of https://www.npmjs.com/package/uint8arrays and you can find the list of supported encodings here https://github.com/multiformats/multibase/blob/master/multibase.csv 32 | * @param {String} str The string to convert to a Uint8Array 33 | * @param {String} encoding The encoding to use when converting the string to a Uint8Array. 34 | * @returns {String} The Uint8Array representation of the data from the string 35 | */ 36 | export function uint8arrayFromString(str, encoding) { 37 | return uint8arrayFromStringFromLib(str, encoding); 38 | } 39 | 40 | /** 41 | * Convert a file to a data URL, which could then be embedded in a LIT. A data URL is a string representation of a file. 42 | * @param {File} file The file to turn into a data url 43 | * @returns {string} The data URL. This is a string representation that can be used anywhere the original file would be used. 44 | */ 45 | export function fileToDataUrl(file) { 46 | return new Promise((resolve, reject) => { 47 | const reader = new FileReader(); 48 | reader.onloadend = () => { 49 | resolve(reader.result); 50 | }; 51 | reader.readAsDataURL(file); 52 | }); 53 | } 54 | 55 | /** 56 | * Download a file in memory to the user's computer 57 | * @param {Object} params 58 | * @param {string} params.filename The name of the file 59 | * @param {Uint8Array} params.data The actual file itself as a Uint8Array 60 | * @param {string} params.mimetype The mime type of the file 61 | * @returns {string} The data URL. This is a string representation that can be used anywhere the original file would be used. 62 | */ 63 | export function downloadFile({ filename, data, mimetype }) { 64 | var element = document.createElement("a"); 65 | element.setAttribute( 66 | "href", 67 | "data:" + mimetype + ";base64," + uint8arrayToString(data, "base64") 68 | ); 69 | element.setAttribute("download", filename); 70 | 71 | element.style.display = "none"; 72 | document.body.appendChild(element); 73 | 74 | element.click(); 75 | 76 | document.body.removeChild(element); 77 | } 78 | 79 | /** 80 | * Inject an iFrame into the current page that will display a LIT. This function safely sandboxes the content in the iFrame so that the LIT cannot see cookies or localStorage of the parent website. 81 | * @param {Object} params 82 | * @param {Object} params.destinationId The DOM ID of the element to inject the iFrame into 83 | * @param {string} params.title The title of the content being displayed 84 | * @param {string} params.fileUrl The URL of the content that will be shown in the iFrame 85 | * @param {string} params.className An optional DOM class name to add to the iFrame for styling 86 | */ 87 | export function injectViewerIFrame({ 88 | destinationId, 89 | title, 90 | fileUrl, 91 | className, 92 | }) { 93 | if (fileUrl.includes("data:")) { 94 | // data urls are not safe, refuse to do this 95 | throw new Error( 96 | "You can not inject an iFrame with a data url. Try a regular https URL." 97 | ); 98 | } 99 | 100 | const url = new URL(fileUrl); 101 | if (url.host.toLowerCase() === window.location.host.toLowerCase()) { 102 | throw new Error( 103 | "You cannot host a LIT on the same domain as the parent webpage. This is because iFrames with the same origin have access to localstorage and cookies in the parent webpage which is unsafe" 104 | ); 105 | } 106 | 107 | const iframe = document.createElement("iframe"); 108 | iframe.src = fileUrl; 109 | iframe.title = title; 110 | iframe.sandbox = 111 | "allow-forms allow-scripts allow-popups allow-modals allow-popups-to-escape-sandbox allow-same-origin"; 112 | iframe.loading = "lazy"; 113 | iframe.allow = 114 | "accelerometer; ambient-light-sensor; autoplay; battery; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr; screen-wake-lock; web-share; xr-spatial-tracking"; 115 | if (className) { 116 | iframe.className = className; 117 | } 118 | document.getElementById(destinationId).appendChild(iframe); 119 | } 120 | -------------------------------------------------------------------------------- /src/utils/cosmos.js: -------------------------------------------------------------------------------- 1 | import Uint8arrays from "../lib/uint8arrays"; 2 | const uint8arrayFromString = Uint8arrays.fromString; 3 | const uint8arrayToString = Uint8arrays.toString; 4 | import { throwError, log } from "../lib/utils"; 5 | import { LIT_COSMOS_CHAINS } from "../lib/constants"; 6 | 7 | export const AUTH_SIGNATURE_BODY = 8 | "I am creating an account to use Lit Protocol at {{timestamp}}"; 9 | 10 | function getProvider() { 11 | if ("keplr" in window) { 12 | return keplr; 13 | } else { 14 | throwError({ 15 | message: 16 | "No web3 wallet was found that works with Cosmos. Install a Cosmos wallet or choose another chain", 17 | name: "NoWalletException", 18 | errorCode: "no_wallet", 19 | }); 20 | } 21 | } 22 | 23 | export async function connectCosmosProvider({ chain }) { 24 | const chainId = LIT_COSMOS_CHAINS[chain].chainId; 25 | 26 | const keplr = getProvider(); 27 | 28 | // Enabling before using the Keplr is recommended. 29 | // This method will ask the user whether to allow access if they haven't visited this website. 30 | // Also, it will request that the user unlock the wallet if the wallet is locked. 31 | await keplr.enable(chainId); 32 | 33 | const offlineSigner = keplr.getOfflineSigner(chainId); 34 | 35 | // You can get the address/public keys by `getAccounts` method. 36 | // It can return the array of address/public key. 37 | // But, currently, Keplr extension manages only one address/public key pair. 38 | // XXX: This line is needed to set the sender address for SigningCosmosClient. 39 | const accounts = await offlineSigner.getAccounts(); 40 | 41 | // // Initialize the gaia api with the offline signer that is injected by Keplr extension. 42 | // const cosmJS = new SigningCosmosClient( 43 | // "https://lcd-cosmoshub.keplr.app", 44 | // accounts[0].address, 45 | // offlineSigner 46 | // ); 47 | 48 | // console.log("accounts[0]", accounts[0]); 49 | 50 | return { provider: keplr, account: accounts[0].address, chainId }; 51 | } 52 | 53 | export async function checkAndSignCosmosAuthMessage({ chain }) { 54 | const { provider, account, chainId } = await connectCosmosProvider({ chain }); 55 | 56 | let authSig = localStorage.getItem("lit-auth-cosmos-signature"); 57 | if (!authSig) { 58 | log("signing auth message because sig is not in local storage"); 59 | await signAndSaveAuthMessage({ provider, account, chainId }); 60 | authSig = localStorage.getItem("lit-auth-cosmos-signature"); 61 | } 62 | authSig = JSON.parse(authSig); 63 | 64 | if (account !== authSig.address) { 65 | log( 66 | "signing auth message because account is not the same as the address in the auth sig" 67 | ); 68 | await signAndSaveAuthMessage({ provider, account, chainId }); 69 | authSig = localStorage.getItem("lit-auth-cosmos-signature"); 70 | authSig = JSON.parse(authSig); 71 | } 72 | 73 | log("authSig", authSig); 74 | 75 | return authSig; 76 | } 77 | 78 | export async function signAndSaveAuthMessage({ provider, account, chainId }) { 79 | const now = new Date().toISOString(); 80 | const body = AUTH_SIGNATURE_BODY.replace("{{timestamp}}", now); 81 | 82 | // const signed = provider.signArbitrary(chainId, account, body); 83 | 84 | // const data = new TextEncoder().encode(body); 85 | // console.log("data being signed", data); 86 | const signed = await provider.signArbitrary(chainId, account, body); 87 | // const hexSig = uint8arrayToString(signed.signature, "base16"); 88 | 89 | const data = uint8arrayToString(uint8arrayFromString(body, "utf8"), "base64"); //Buffer.from(body).toString("base64"); 90 | 91 | // console.log("signed", signed); 92 | // console.log("pubkey: ", signed.pub_key.value); 93 | 94 | // ok now we have to create the actual message 95 | const signDoc = { 96 | chain_id: "", 97 | account_number: "0", 98 | sequence: "0", 99 | fee: { 100 | gas: "0", 101 | amount: [], 102 | }, 103 | msgs: [ 104 | { 105 | type: "sign/MsgSignData", 106 | value: { 107 | signer: account, 108 | data, 109 | }, 110 | }, 111 | ], 112 | memo: "", 113 | }; 114 | 115 | const encodedSignedMsg = serializeSignDoc(signDoc); 116 | const digest = await crypto.subtle.digest("SHA-256", encodedSignedMsg); 117 | // console.log("digest length", digest.byteLength); 118 | const digest_hex = uint8arrayToString(new Uint8Array(digest), "base16"); 119 | // console.log("digest_hex length", digest_hex.length); 120 | 121 | const authSig = { 122 | sig: signed.signature, 123 | derivedVia: "cosmos.signArbitrary", 124 | signedMessage: digest_hex, 125 | address: account, 126 | }; 127 | 128 | localStorage.setItem("lit-auth-cosmos-signature", JSON.stringify(authSig)); 129 | } 130 | 131 | function sortedObject(obj) { 132 | if (typeof obj !== "object" || obj === null) { 133 | return obj; 134 | } 135 | if (Array.isArray(obj)) { 136 | return obj.map(sortedObject); 137 | } 138 | const sortedKeys = Object.keys(obj).sort(); 139 | const result = {}; 140 | // NOTE: Use forEach instead of reduce for performance with large objects eg Wasm code 141 | sortedKeys.forEach((key) => { 142 | result[key] = sortedObject(obj[key]); 143 | }); 144 | return result; 145 | } 146 | 147 | export function serializeSignDoc(signDoc) { 148 | const sorted = JSON.stringify(sortedObject(signDoc)); 149 | return uint8arrayFromString(sorted, "utf8"); 150 | } 151 | -------------------------------------------------------------------------------- /src/utils/frameComms.js: -------------------------------------------------------------------------------- 1 | import { unlockLitWithKey } from "./lit"; 2 | 3 | export const listenForChildFrameMessages = async () => { 4 | console.log("calling listenForChildFrameMessages from " + window.origin); 5 | // listen for requests from child frames 6 | window.addEventListener( 7 | "message", 8 | async (event) => { 9 | // console.log('onMessage in sdk: ', event) 10 | 11 | let childFrameThatSentMessageIndex = false; 12 | for (let i = 0; i < frames.length; i++) { 13 | if (frames[i] === event.source) { 14 | childFrameThatSentMessageIndex = i; 15 | } 16 | } 17 | 18 | if (childFrameThatSentMessageIndex !== false) { 19 | console.log("onMessage in parent: ", event); 20 | 21 | const { command, params } = event.data; 22 | if (command === "LIT_SYN") { 23 | window.frames[childFrameThatSentMessageIndex].postMessage( 24 | { response: "LIT_ACK" }, 25 | "*" 26 | ); 27 | return; 28 | } 29 | // if (command === 'signAndGetEncryptionKey') { 30 | // authSig = await checkAndSignAuthMessage({ chain: params.chain }) 31 | // if (authSig.errorCode && authSig.errorCode === 'wrong_chain') { 32 | // alert('You are connected to the wrong blockchain. Please switch your metamask to ' + params.chain) 33 | // } 34 | // 35 | // // get the merkle proof 36 | // const { balanceStorageSlot } = LIT_CHAINS[params.chain] 37 | // try { 38 | // merkleProof = await getMerkleProof({ tokenAddress: params.tokenAddress, balanceStorageSlot, tokenId: params.tokenId }) 39 | // } catch (e) { 40 | // console.log(e) 41 | // alert('Error - could not obtain merkle proof. Some nodes do not support this operation yet. Please try another ETH node.') 42 | // return 43 | // } 44 | // const encryptionKey = await window.litNodeClient.getEncryptionKey({ 45 | // ...params, authSig, merkleProof 46 | // }) 47 | // window.frames[childFrameThatSentMessageIndex].postMessage({ respondingToCommand: command, encryptionKey }, '*') 48 | // return 49 | // } 50 | if (event.data.target === "LitNodeClient") { 51 | // forward this on to the nodes 52 | if (command === "getEncryptionKey") { 53 | const encryptionKey = await window.litNodeClient.getEncryptionKey({ 54 | ...params, 55 | }); 56 | window.frames[childFrameThatSentMessageIndex].postMessage( 57 | { respondingToCommand: command, encryptionKey }, 58 | "*" 59 | ); 60 | } 61 | } 62 | } 63 | }, 64 | false 65 | ); 66 | }; 67 | 68 | export const listenForFrameParentMessages = async () => { 69 | console.log("calling listenForFrameParentMessages from " + window.origin); 70 | // listen for requests from child frames 71 | window.addEventListener( 72 | "message", 73 | async (event) => { 74 | const messageIsFromFrameParent = event.source === window.parent; 75 | 76 | if (messageIsFromFrameParent) { 77 | console.log("onMessage in frame: ", event); 78 | } 79 | 80 | // console.log('messageIsFromFrameParent: ', messageIsFromFrameParent) 81 | 82 | if (messageIsFromFrameParent) { 83 | const { response, respondingToCommand } = event.data; 84 | if (response === "LIT_ACK") { 85 | window.useLitPostMessageProxy = true; 86 | if (typeof document !== "undefined") { 87 | document.dispatchEvent(new Event("lit-ready")); 88 | } 89 | return; 90 | } 91 | if (respondingToCommand === "getEncryptionKey") { 92 | const { encryptionKey } = event.data; 93 | unlockLitWithKey({ symmetricKey: encryptionKey }); 94 | } 95 | } 96 | }, 97 | false 98 | ); 99 | }; 100 | 101 | export const inIframe = () => { 102 | try { 103 | return window.self !== window.top; 104 | } catch (e) { 105 | return true; 106 | } 107 | }; 108 | -------------------------------------------------------------------------------- /src/utils/init.js: -------------------------------------------------------------------------------- 1 | import { sendMessageToFrameParent } from "./lit"; 2 | import LitNodeClient from "./litNodeClient"; 3 | 4 | export const litJsSdkLoadedInALIT = () => { 5 | try { 6 | window.localStorage.getItem("test"); 7 | } catch (e) { 8 | console.log( 9 | "Could not use localstorage in a Lit. This usually means we are stuck in the opensea sandbox." 10 | ); 11 | window.sandboxed = true; 12 | setTimeout(function () { 13 | if (typeof document !== "undefined") { 14 | document.dispatchEvent(new Event("lit-ready")); 15 | } 16 | }, 1000); 17 | return; 18 | } 19 | sendMessageToFrameParent({ command: "LIT_SYN" }, "*"); 20 | setTimeout(function () { 21 | if (!window.useLitPostMessageProxy) { 22 | // console.log( 23 | // "inside lit - no parent frame lit node connection. connecting ourselves." 24 | // ); 25 | // we're on our own with no parent frame. initiate our own connection to lit nodes 26 | const litNodeClient = new LitNodeClient(); 27 | litNodeClient.connect(); 28 | window.litNodeClient = litNodeClient; 29 | } else { 30 | // console.log( 31 | // "inside lit - parent frame is connected to lit nodes. using that." 32 | // ); 33 | } 34 | }, 1000); 35 | }; 36 | -------------------------------------------------------------------------------- /src/utils/sol.js: -------------------------------------------------------------------------------- 1 | import Uint8arrays from "../lib/uint8arrays"; 2 | const uint8arrayFromString = Uint8arrays.fromString; 3 | const uint8arrayToString = Uint8arrays.toString; 4 | import { throwError, log } from "../lib/utils"; 5 | 6 | export const AUTH_SIGNATURE_BODY = 7 | "I am creating an account to use Lit Protocol at {{timestamp}}"; 8 | 9 | function getProvider() { 10 | if ("solana" in window) { 11 | return window.solana; 12 | // const provider = window.solana; 13 | // if (provider.isPhantom) { 14 | // return provider; 15 | // } 16 | } else { 17 | throwError({ 18 | message: 19 | "No web3 wallet was found that works with Solana. Install a Solana wallet or choose another chain", 20 | name: "NoWalletException", 21 | errorCode: "no_wallet", 22 | }); 23 | } 24 | } 25 | 26 | export async function connectSolProvider() { 27 | const provider = getProvider(); 28 | await provider.connect(); 29 | const account = provider.publicKey.toBase58(); 30 | return { provider, account }; 31 | } 32 | 33 | export async function checkAndSignSolAuthMessage({ chain }) { 34 | // Connect to cluster 35 | // const connection = new solWeb3.Connection( 36 | // solWeb3.clusterApiUrl("devnet"), 37 | // "confirmed" 38 | // ); 39 | 40 | const { provider, account } = await connectSolProvider(); 41 | 42 | let authSig = localStorage.getItem("lit-auth-sol-signature"); 43 | if (!authSig) { 44 | log("signing auth message because sig is not in local storage"); 45 | await signAndSaveAuthMessage({ provider, account }); 46 | authSig = localStorage.getItem("lit-auth-sol-signature"); 47 | } 48 | authSig = JSON.parse(authSig); 49 | 50 | if (account !== authSig.address) { 51 | log( 52 | "signing auth message because account is not the same as the address in the auth sig" 53 | ); 54 | await signAndSaveAuthMessage({ provider, account }); 55 | authSig = localStorage.getItem("lit-auth-sol-signature"); 56 | authSig = JSON.parse(authSig); 57 | } 58 | 59 | log("authSig", authSig); 60 | 61 | return authSig; 62 | } 63 | 64 | export async function signAndSaveAuthMessage({ provider, account }) { 65 | const now = new Date().toISOString(); 66 | const body = AUTH_SIGNATURE_BODY.replace("{{timestamp}}", now); 67 | 68 | const data = new TextEncoder().encode(body); 69 | const signed = await provider.signMessage(data, "utf8"); 70 | 71 | const hexSig = uint8arrayToString(signed.signature, "base16"); 72 | 73 | const authSig = { 74 | sig: hexSig, 75 | derivedVia: "solana.signMessage", 76 | signedMessage: body, 77 | address: provider.publicKey.toBase58(), 78 | }; 79 | 80 | localStorage.setItem("lit-auth-sol-signature", JSON.stringify(authSig)); 81 | return authSig; 82 | } 83 | -------------------------------------------------------------------------------- /src/version.js: -------------------------------------------------------------------------------- 1 | // Generated by genversion. 2 | export const version = '1.1.250' 3 | -------------------------------------------------------------------------------- /tests.md: -------------------------------------------------------------------------------- 1 | # Manual Tests 2 | 3 | Spin up an instance of this SDK somewhere to run these tests. The easiest way to do this is to visit https://mintlit.com/ and open the developer console. Note that the tests below assume that you have a wallet that holds the NFT specified in the accessControlConditions variable. Substitute an NFT contract address and token id that you own if you want to test with your own wallet. 4 | 5 | ## Provisoning access to a resource 6 | ``` 7 | const chain = 'fantom' 8 | const authSig = await LitJsSdk.checkAndSignAuthMessage({chain}) 9 | const accessControlConditions = [ 10 | { 11 | contractAddress: '0x3110c39b428221012934A7F617913b095BC1078C', 12 | standardContractType: 'ERC1155', 13 | chain, 14 | method: 'balanceOf', 15 | parameters: [ 16 | ':userAddress', 17 | '21' 18 | ], 19 | returnValueTest: { 20 | comparator: '>', 21 | value: '0' 22 | } 23 | } 24 | ] 25 | const resourceId = { 26 | baseUrl: 'https://my-dynamic-content-server.com', 27 | path: '/a_path.html', 28 | orgId: "" 29 | } 30 | await litNodeClient.saveSigningCondition({ accessControlConditions, chain, authSig, resourceId }) 31 | ``` 32 | 33 | ## Requesting access to a resource via a signed JWT 34 | ``` 35 | const chain = 'fantom' 36 | const authSig = await LitJsSdk.checkAndSignAuthMessage({chain}) 37 | const accessControlConditions = [ 38 | { 39 | contractAddress: '0x3110c39b428221012934A7F617913b095BC1078C', 40 | standardContractType: 'ERC1155', 41 | chain, 42 | method: 'balanceOf', 43 | parameters: [ 44 | ':userAddress', 45 | '21' 46 | ], 47 | returnValueTest: { 48 | comparator: '>', 49 | value: '0' 50 | } 51 | } 52 | ] 53 | const resourceId = { 54 | baseUrl: 'https://my-dynamic-content-server.com', 55 | path: '/a_path.html', 56 | orgId: "" 57 | } 58 | const jwt = await litNodeClient.getSignedToken({ accessControlConditions, chain, authSig, resourceId }) 59 | ``` 60 | 61 | ## Verifying access to a resource via a signed JWT 62 | ``` 63 | const jwt = "eyJhbGciOiJCTFMxMi0zODEiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJMSVQiLCJzdWIiOiIweGRiZDM2MGYzMDA5N2ZiNmQ5MzhkY2M4YjdiNjI4NTRiMzYxNjBiNDUiLCJjaGFpbiI6ImZhbnRvbSIsImlhdCI6MTYyODAzMTM1OCwiZXhwIjoxNjI4MDc0NTU4LCJiYXNlVXJsIjoiaHR0cHM6Ly9teS1keW5hbWljLWNvbnRlbnQtc2VydmVyLmNvbSIsInBhdGgiOiIvYV9wYXRoLmh0bWwiLCJvcmdJZCI6IiJ9.lX_aBSgGVYWd2FL6elRHoPJ2nab0IkmmX600cwZPCyK_SazZ-pzBUGDDQ0clthPVAtoS7roHg14xpEJlcSJUZBA7VTlPiDCOrkie_Hmulj765qS44t3kxAYduLhNQ-VN" 64 | const { verified, header, payload } = LitJsSdk.verifyJwt({jwt}) 65 | ``` -------------------------------------------------------------------------------- /tests/constants.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | export const nodeClientConfig = { 4 | "alertWhenUnauthorized": true, 5 | "minNodeCount": 6, 6 | "bootstrapUrls": [ 7 | "http://127.0.0.1:7470", 8 | "http://127.0.0.1:7471", 9 | "http://127.0.0.1:7472", 10 | "http://127.0.0.1:7473", 11 | "http://127.0.0.1:7474", 12 | "http://127.0.0.1:7475", 13 | "http://127.0.0.1:7476", 14 | "http://127.0.0.1:7477", 15 | "http://127.0.0.1:7478", 16 | "http://127.0.0.1:7479" 17 | ] 18 | } -------------------------------------------------------------------------------- /tests/provisioningAndSigning.js: -------------------------------------------------------------------------------- 1 | import { randomPath } from './utils' 2 | import { nodeClientConfig } from './constants' 3 | import LitJsSdk from '../build/index.js' 4 | 5 | const litNodeClient = new LitJsSdk.LitNodeClient() 6 | litNodeClient.connect() 7 | const chain = 'polygon' 8 | 9 | const provisionAndSign = async (accessControlConditions) => { 10 | 11 | let authSig = JSON.parse("{\"sig\":\"0x18a173d68d2f78cc5c13da0dfe36eec2a293285bee6d42547b9577bf26cdc985660ed3dddc4e75d422366cac07e8a9fc77669b10373bef9c7b8e4280252dfddf1b\",\"derivedVia\":\"web3.eth.personal.sign\",\"signedMessage\":\"I am creating an account to use LITs at 2021-08-04T20:14:04.918Z\",\"address\":\"0xdbd360f30097fb6d938dcc8b7b62854b36160b45\"}") 12 | 13 | 14 | let resourceId = { 15 | baseUrl: 'https://my-dynamic-content-server.com', 16 | path: randomUrlPath(), 17 | orgId: "" 18 | } 19 | 20 | await litNodeClient.saveSigningCondition({ 21 | accessControlConditions, 22 | chain, 23 | authSig, 24 | resourceId 25 | }) 26 | 27 | 28 | let jwt = await litNodeClient.getSignedToken({ 29 | accessControlConditions, 30 | chain, 31 | authSig, 32 | resourceId 33 | }) 34 | 35 | console.log(jwt) 36 | 37 | if (jwt) { 38 | return true 39 | } 40 | return false 41 | } 42 | 43 | 44 | const accessControlConditions = [ 45 | [ // Must posess at least one ERC1155 token with a given token id 46 | { 47 | contractAddress: '0x7C7757a9675f06F3BE4618bB68732c4aB25D2e88', 48 | standardContractType: 'ERC1155', 49 | chain, 50 | method: 'balanceOf', 51 | parameters: [ 52 | ':userAddress', 53 | '8' 54 | ], 55 | returnValueTest: { 56 | comparator: '>', 57 | value: '0' 58 | } 59 | } 60 | ] 61 | ] 62 | 63 | const runTests = async () => { 64 | for (let i = 0; i < accessControlConditions.length; i++) { 65 | const res = await provisionAndSign(accessControlConditions[i]) 66 | if (res === false) { 67 | console.log('Error on access control conditions: ', accessControlConditions[i]) 68 | process.exit(1) 69 | } 70 | } 71 | } 72 | 73 | runTests() -------------------------------------------------------------------------------- /tests/utils.js: -------------------------------------------------------------------------------- 1 | export const randomPath = () => "/" + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) --------------------------------------------------------------------------------