Skip to content

Files

Latest commit

 

History

History
57 lines (39 loc) · 2.42 KB

NON-BUNDLERS.md

File metadata and controls

57 lines (39 loc) · 2.42 KB

Deploying Local-Data-Lock WITHOUT A Bundler

To use this library directly -- i.e., in a classic/vanilla web project without a modern bundler tool -- make a directory for it (e.g., local-data-lock/) in your browser app's JS assets directory.

Then copy over all @lo-fi/local-data-lock/dist/auto/* contents, as-is:

  • @lo-fi/local-data-lock/dist/auto/ldl.js

    Note: this is not the same as @lo-fi/local-data-lock/dist/bundlers/ldl.mjs, which is only intended for web application projects WITH a bundler

  • @byojs/storage/dist/util.mjs

  • @byojs/storage/dist/worker.opfs.mjs

  • @byojs/storage/dist/adapter.*.mjs

    Client-side storage adapters

  • @lo-fi/local-data-lock/dist/auto/external/* (preserve the whole external/ sub-directory):

    • @lo-fi/webauthn-local-client/walc.js
    • @lo-fi/webauthn-local-client/external.js
    • @lo-fi/webauthn-local-client/external/asn1.all.min.js
    • @lo-fi/webauthn-local-client/external/cbor.js
    • @lo-fi/webauthn-local-client/external/libsodium.js
    • @lo-fi/webauthn-local-client/external/libsodium-wrappers.js

Import/Usage

To import and use local-data-lock in a non-bundled browser app:

import { getLockKey, lockData, unlockData } from "/path/to/js-assets/local-data-lock/ldl.js";

Using Import Map

If your non-bundled browser app has an Import Map in its HTML (strongly recommended!), you can improve the import by adding an entries for this library and its dependencies:

<script type="importmap">
{
    "imports": {
        "local-data-lock": "/path/to/js-assets/local-data-lock/ldl.js",

        "@lo-fi/webauthn-local-client": "/path/to/js-assets/local-data-lock/external/@lo-fi/webauthn-local-client/walc.js"
    }
}
</script>

Now, you'll be able to import the library in your app in a friendly/readable way:

import { getLockKey, lockData, unlockData } from "local-data-lock";

Note: If you omit the above "local-data-lock" import-map entry, you can still import local-data-lock by specifying the proper path to ldl.js (as shown above). However, the entry above for "@lo-fi/webauthn-local-client" is more required. Alternatively, you'll have to make the following manual edits:

  • edit the ldl.js file to change its import specifier for "@lo-fi/webauthn-local-client" to the proper path to walc.js.