diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 0ac3b2b14..a0faef162 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -30,4 +30,4 @@ jobs: with: machine_key: ${{ secrets.FISSION_PRODUCTION_KEY }} build_dir: ./docs - app_url: webnative.fission.app + app_url: odd.fission.app diff --git a/CHANGELOG.md b/CHANGELOG.md index 20ac631ee..09a4c2c11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Adds browser extension support - Moves events onto top-level program and renames them. For example, the `local-change` is now `fileSystem:local-change`. - Adds session create and destroy events +- Rename Webnative SDK to ODD SDK and update external URLs ### V0.36.3 diff --git a/README.md b/README.md index 55b3bebf9..ab5ce6332 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# Webnative SDK +# ODD SDK -[![NPM](https://img.shields.io/npm/v/webnative)](https://www.npmjs.com/package/webnative) -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/fission-suite/blob/master/LICENSE) +[![NPM](https://img.shields.io/npm/v/@oddjs/odd)](https://www.npmjs.com/package/@oddjs/odd) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/oddsdk/ts-odd/blob/main/LICENSE) [![Built by FISSION](https://img.shields.io/badge/⌘-Built_by_FISSION-purple.svg)](https://fission.codes) [![Discord](https://img.shields.io/discord/478735028319158273.svg)](https://discord.gg/zAQBDEq) [![Discourse](https://img.shields.io/discourse/https/talk.fission.codes/topics)](https://talk.fission.codes) -The Webnative SDK empowers developers to build fully distributed web applications without needing a complex back-end. The SDK provides: +The ODD SDK empowers developers to build fully distributed web applications without needing a complex back-end. The SDK provides: -- **User accounts** via the browser's [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) or by using a blockchain wallet as a [webnative plugin](https://github.com/fission-codes/webnative-walletauth). +- **User accounts** via the browser's [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) or by using a blockchain wallet as a [ODD plugin](https://github.com/oddsdk/odd-walletauth). - **Authorization** using [UCAN](https://ucan.xyz/). -- **Encrypted file storage** via the [Webnative File System](https://guide.fission.codes/developers/webnative/file-system-wnfs) backed by [IPLD](https://ipld.io/). -- **Key management** via websockets and a two-factor auth-like flow. +- **Encrypted file storage** using [WNFS](https://docs.odd.dev/developers/odd/file-system-wnfs) backed by [IPLD](https://ipld.io/). +- **Key management** using websockets and a two-factor auth-like flow. -Webnative applications work offline and store data encrypted for the user by leveraging the power of the web platform. You can read more about Webnative in Fission's [Webnative Guide](https://guide.fission.codes/developers/webnative). There's also an API reference which can be found at [webnative.fission.app](https://webnative.fission.app) +ODD applications work offline and store data encrypted for the user by leveraging the power of the web platform. You can read more about the ODD SDK in Fission's [ODD SDK Guide](https://docs.odd.dev). There's also an API reference which can be found at [api.odd.dev](https://api.odd.dev) @@ -21,18 +21,18 @@ Webnative applications work offline and store data encrypted for the user by lev ```ts // ESM -import * as wn from "webnative" +import * as odd from "@oddjs/odd" // Browser/UMD build -const wn = globalThis.webnative +const odd = globalThis.oddjs ``` ## Creating a Program -A Webnative program is an assembly of components that make up a distributed web application. Several of the components can be customized. _Let's stick with the default components for now, which means we'll be using the Web Crypto API._ +An ODD program is an assembly of components that make up a distributed web application. Several of the components can be customized. _Let's stick with the default components for now, which means we'll be using the Web Crypto API._ ```ts -const program = await wn.program({ +const program = await odd.program({ // Can also be a string, used as an identifier for caches. // If you're developing multiple apps on the same localhost port, // make sure these differ. @@ -40,17 +40,17 @@ const program = await wn.program({ }).catch(error => { switch (error) { - case webnative.ProgramError.InsecureContext: - // Webnative requires HTTPS + case odd.ProgramError.InsecureContext: + // The ODD SDK requires HTTPS break; - case webnative.ProgramError.UnsupportedBrowser: + case odd.ProgramError.UnsupportedBrowser: break; } }) ``` -`wn.program` returns a `Program` object, which can create a new user session or reuse an existing session. There are two ways to create a user session, either by using an authentication strategy or by requesting access from another app through the "capabilities" system. Let's start with the default authentication strategy. +`odd.program` returns a `Program` object, which can create a new user session or reuse an existing session. There are two ways to create a user session, either by using an authentication strategy or by requesting access from another app through the "capabilities" system. Let's start with the default authentication strategy. ```ts let session @@ -98,7 +98,7 @@ if (program.session) { } ``` -Alternatively you can use the "capabilities" system when you want partial access to a file system. At the moment of writing, capabilities are only supported through the "Fission auth lobby", which is a Webnative app that uses the auth strategy shown above. +Alternatively you can use the "capabilities" system when you want partial access to a file system. At the moment of writing, capabilities are only supported through the "Fission auth lobby", which is an ODD app that uses the auth strategy shown above. This Fission auth lobby flow works as follows: 1. You get redirected to the Fission lobby from your app. @@ -118,7 +118,7 @@ const permissions = { } // We need to pass this object to our program -const program = await webnative.program({ +const program = await odd.program({ namespace: { creator: "Nullsoft", name: "Winamp" }, permissions }) @@ -139,26 +139,26 @@ const fs = session.fs __Notes:__ -- You can use alternative authentication strategies, such as [webnative-walletauth](https://github.com/fission-codes/webnative-walletauth). +- You can use alternative authentication strategies, such as [odd-walletauth](https://github.com/oddsdk/odd-walletauth). - You can remove all traces of the user using `await session.destroy()` - You can load the file system separately if you're using a web worker. This is done using the combination of `configuration.fileSystem.loadImmediately = false` and `program.fileSystem.load()` -- You can recover a file system if you've downloaded a Recovery Kit by calling `program.fileSystem.recover({ newUsername, oldUsername, readKey })`. The `oldUsername` and `readKey` can be parsed from the uploaded Recovery Kit and the `newUsername` can be generated before calling the function. Please refer to [this example](https://github.com/webnative-examples/webnative-app-template/blob/5498e7062a4578028b8b55d2ac4c611bd5daab85/src/components/auth/recover/HasRecoveryKit.svelte#L49) from Fission's Webnative App Template. Additionally, if you would like to see how to generate a Recovery Kit, you can reference [this example](https://github.com/webnative-examples/webnative-app-template/blob/main/src/lib/account-settings.ts#L186) +- You can recover a file system if you've downloaded a Recovery Kit by calling `program.fileSystem.recover({ newUsername, oldUsername, readKey })`. The `oldUsername` and `readKey` can be parsed from the uploaded Recovery Kit and the `newUsername` can be generated before calling the function. Please refer to [this example](https://github.com/oddsdk/odd-app-template/blob/5498e7062a4578028b8b55d2ac4c611bd5daab85/src/components/auth/recover/HasRecoveryKit.svelte#L49) from Fission's ODD App Template. Additionally, if you would like to see how to generate a Recovery Kit, you can reference [this example](https://github.com/oddsdk/odd-app-template/blob/main/src/lib/account-settings.ts#L186) ## Working with the file system -The Web Native File System (WNFS) is a file system built on top of [IPLD](https://ipld.io/). It supports operations similar to your macOS, Windows, or Linux desktop file system. It consists of a public and private branch: The public branch is "live" and publicly accessible on the Internet. The private branch is encrypted so that only the owner can see the contents. Read more about it [here](https://github.com/wnfs-wg). +The Webnative File System (WNFS) is a file system built on top of [IPLD](https://ipld.io/). It supports operations similar to your macOS, Windows, or Linux desktop file system. It consists of a public and private branch: The public branch is "live" and publicly accessible on the Internet. The private branch is encrypted so that only the owner can see the contents. Read more about it [here](https://github.com/wnfs-wg). ```ts -const { Branch } = wn.path +const { Branch } = odd.path // List the user's private files await fs.ls( - wn.path.directory(Branch.Private) + odd.path.directory(Branch.Private) ) // Create a sub directory and add some content -const contentPath = wn.file( +const contentPath = odd.file( Branch.Private, "Sub Directory", "hello.txt" ) @@ -176,7 +176,7 @@ const content = new TextDecoder().decode( ) ``` -That's it, you have successfully created a Webnative app! 🚀 +That's it, you have successfully created an ODD app! 🚀 ## POSIX Interface @@ -196,7 +196,7 @@ WNFS exposes a familiar POSIX-style interface: Each file and directory has a `history` property, which you can use to get an earlier version of that item. We use the `delta` variable as the order index. Primarily because the timestamps can be slightly out of sequence, due to device inconsistencies. ```ts -const file = await fs.get(wn.path.file("private", "Blog Posts", "article.md")) +const file = await fs.get(odd.path.file("private", "Blog Posts", "article.md")) file.history.list() // { delta: -1, timestamp: 1606236743 } @@ -218,26 +218,26 @@ file.history.prior(1606236743) ## Sharing Private Data -[https://guide.fission.codes/developers/webnative/sharing-private-data](https://guide.fission.codes/developers/webnative/sharing-private-data) +[https://docs.odd.dev/developers/odd/sharing-private-data](https://docs.odd.dev/developers/odd/sharing-private-data) ## Migration -Some versions of Webnative require apps to migrate their codebase to address breaking changes. Please see our [migration guide](https://guide.fission.codes/developers/webnative/migration) for help migrating your apps to the latest Webnative version. +Some versions of the ODD SDK require apps to migrate their codebase to address breaking changes. Please see our [migration guide](https://docs.odd.dev/developers/odd/migration) for help migrating your apps to the latest ODD SDK version. ## Debugging -Debugging mode can be enable by setting `debug` to `true` in your configuration object that you pass to your `Program`. By default this will add your programs to the global context object (eg. `window`) under `globalThis.__webnative.programs` (can be disabled, see API docs). +Debugging mode can be enable by setting `debug` to `true` in your configuration object that you pass to your `Program`. By default this will add your programs to the global context object (eg. `window`) under `globalThis.__odd.programs` (can be disabled, see API docs). ```ts const appInfo = { creator: "Nullsoft", name: "Winamp" } -await wn.program({ +await odd.program({ namespace: appInfo, debug: true }) // Automatically exposed Program in debug mode -const program = globalThis.__webnative[ wn.namespace(appInfo) ] // namespace: "Nullsoft/Winamp" +const program = globalThis.__odd[ odd.namespace(appInfo) ] // namespace: "Nullsoft/Winamp" ``` \ No newline at end of file diff --git a/flake.nix b/flake.nix index cadcce30a..59cc655a3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "webnative"; + description = "oddjs"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/release-22.05"; @@ -16,7 +16,7 @@ in { devShell = pkgs.mkShell { - name = "webnative"; + name = "oddjs"; buildInputs = with pkgs; [ nodejs-18_x ]; }; }); diff --git a/package-lock.json b/package-lock.json index 772b45eaa..4e1d09b6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "webnative", - "version": "0.36.3", + "name": "@oddjs/odd", + "version": "0.37.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "webnative", - "version": "0.36.3", + "name": "@oddjs/odd", + "version": "0.37.0", "license": "Apache-2.0", "dependencies": { "@ipld/dag-cbor": "^8.0.0", diff --git a/package.json b/package.json index 0a9165507..ee6acff5c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "webnative", + "name": "@oddjs/odd", "version": "0.37.0", - "description": "Webnative SDK", + "description": "ODD SDK", "keywords": [ "WebCrypto", "auth", @@ -55,9 +55,9 @@ ], "repository": { "type": "git", - "url": "https://github.com/fission-codes/webnative" + "url": "https://github.com/oddsdk/ts-odd" }, - "homepage": "https://webnative.dev", + "homepage": "https://odd.dev", "license": "Apache-2.0", "engines": { "node": ">=16" diff --git a/scripts/build-minified.js b/scripts/build-minified.js index 5161ee62e..a932d0bee 100644 --- a/scripts/build-minified.js +++ b/scripts/build-minified.js @@ -5,7 +5,7 @@ import fs from "fs" import zlib from "zlib" -const globalName = "webnative" +const globalName = "oddjs" console.log("📦 Bundling & minifying...") diff --git a/src/common/cid.ts b/src/common/cid.ts index ff51683b5..3cd6fed13 100644 --- a/src/common/cid.ts +++ b/src/common/cid.ts @@ -45,7 +45,7 @@ export function decodeCID(val: CID | object | string): CID { } // Sometimes we can encounter a DAG-JSON encoded CID - // https://github.com/fission-codes/webnative/issues/459 + // https://github.com/oddsdk/ts-odd/issues/459 // Related to the `ensureSkeletonStringCIDs` function in the `PrivateTree` class if ( typeof val === "object" && diff --git a/src/components/capabilities/implementation/fission-lobby.ts b/src/components/capabilities/implementation/fission-lobby.ts index 3da6dce24..e3fc9c8f5 100644 --- a/src/components/capabilities/implementation/fission-lobby.ts +++ b/src/components/capabilities/implementation/fission-lobby.ts @@ -94,7 +94,7 @@ export async function request( const exchangeDid = await DID.exchange(dependencies.crypto) const writeDid = await DID.write(dependencies.crypto) - const sharedRepo = !!document.body.querySelector("iframe#webnative-ipfs") && typeof SharedWorker === "function" + const sharedRepo = false const redirectTo = options.returnUrl || window.location.href // Compile params @@ -154,7 +154,7 @@ async function getClassifiedViaPostMessage( const didExchange = await DID.exchange(crypto) const iframe: HTMLIFrameElement = await new Promise(resolve => { const iframe = document.createElement("iframe") - iframe.id = "webnative-secret-exchange" + iframe.id = "odd-secret-exchange" iframe.style.width = "0" iframe.style.height = "0" iframe.style.border = "none" @@ -202,7 +202,7 @@ async function getClassifiedViaPostMessage( } const message = { - webnative: "exchange-secrets", + odd: "exchange-secrets", didExchange } @@ -235,7 +235,7 @@ async function translateClassifiedInfo( ) // The encrypted session key and read keys can be encoded in both UTF-16 and UTF-8. - // This is because keystore-idb uses UTF-16 by default, and that's what webnative used before. + // This is because keystore-idb uses UTF-16 by default, and that's what the ODD SDK used before. // --- // This easy way of detection works because the decrypted session key is encoded in base 64. // That means it'll only ever use the first byte to encode it, and if it were UTF-16 it would diff --git a/src/configuration.ts b/src/configuration.ts index d7ae9a1b6..042fef3f2 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -64,12 +64,12 @@ export type Configuration = { permissions?: Permissions /** - * Configure messages that webnative sends to users. + * Configure messages that the ODD SDK sends to users. * - * `versionMismatch.newer` is shown when webnative detects - * that the user's filesystem is newer than what this version of webnative supports. - * `versionMismatch.older` is shown when webnative detects that the user's - * filesystem is older than what this version of webnative supports. + * `versionMismatch.newer` is shown when the ODD SDK detects + * that the user's filesystem is newer than what this version of the ODD SDK supports. + * `versionMismatch.older` is shown when the ODD SDK detects that the user's + * filesystem is older than what this version of the ODD SDK supports. */ userMessages?: UserMessages } diff --git a/src/filesystem.ts b/src/filesystem.ts index 081189f77..267b3f123 100644 --- a/src/filesystem.ts +++ b/src/filesystem.ts @@ -209,7 +209,7 @@ export async function checkFileSystemVersion( const errorVersionBigger = async () => { await (config.userMessages || DEFAULT_USER_MESSAGES).versionMismatch.newer(versionStr) - return new Error(`Incompatible filesystem version. Version: ${versionStr} Supported versions: ${Versions.supported.map(v => Versions.toString(v)).join(", ")}. Please upgrade this app's webnative version.`) + return new Error(`Incompatible filesystem version. Version: ${versionStr} Supported versions: ${Versions.supported.map(v => Versions.toString(v)).join(", ")}. Please upgrade this app's ODD SDK version.`) } const errorVersionSmaller = async () => { diff --git a/src/fs/v3/PublicRootWasm.ts b/src/fs/v3/PublicRootWasm.ts index dd124d2ed..8452e32e8 100644 --- a/src/fs/v3/PublicRootWasm.ts +++ b/src/fs/v3/PublicRootWasm.ts @@ -20,7 +20,7 @@ let initialized = false async function loadWasm({ manners }: Dependencies) { // MUST be prevented from initializing twice: - // https://github.com/fission-codes/webnative/issues/429 + // https://github.com/oddsdk/ts-odd/issues/429 // https://github.com/rustwasm/wasm-bindgen/issues/3307 if (initialized) return initialized = true diff --git a/src/index.ts b/src/index.ts index 06bb823e0..4690b7787 100644 --- a/src/index.ts +++ b/src/index.ts @@ -205,7 +205,7 @@ export type FileSystemShortHands = { /** - * 🚀 Build a webnative program. + * 🚀 Build an ODD program. * * This will give you a `Program` object which has the following properties: * - `session`, a `Session` object if a session was created before. @@ -215,7 +215,7 @@ export type FileSystemShortHands = { * * This object also has a few other functions, for example to load a filesystem. * These are called "shorthands" because they're the same functions available - * through other places in webnative, but you don't have to pass in the components. + * through other places in the ODD SDK, but you don't have to pass in the components. * * See `assemble` for more information. Note that this function checks for browser support, * while `assemble` does not. Use the latter in case you want to bypass the indexedDB check, @@ -304,7 +304,7 @@ export const auth = { */ export const capabilities = { /** - * A secure enclave in the form of a webnative app which serves as the root authority. + * A secure enclave in the form of a ODD app which serves as the root authority. * Your app is redirected to the lobby where the user can create an account or link a device, * and then request permissions from the user for reading or write to specific parts of the filesystem. */ @@ -361,7 +361,7 @@ export const depot = { * This depot uses IPFS and the Fission servers. * The data is transferred to the Fission IPFS node, * where all of your encrypted and public data lives. - * Other webnative programs with this depot fetch the data from there. + * Other ODD programs with this depot fetch the data from there. */ async fissionIPFS( settings: Configuration & { @@ -383,12 +383,12 @@ export const depot = { /** * Predefined manners configurations. * - * The manners component allows you to tweak various behaviours of a Webnative program, + * The manners component allows you to tweak various behaviours of an ODD program, * such as logging and file system hooks (eg. what to do after a new file system is created). */ export const manners = { /** - * The default Webnative behaviour. + * The default ODD SDK behaviour. */ default(settings: Configuration): Manners.Implementation { return defaultMannersComponent(settings) @@ -458,15 +458,15 @@ export const storage = { /** - * Build a Webnative Program based on a given set of `Components`. - * These are various customisable components that determine how a Webnative app works. + * Build an ODD Program based on a given set of `Components`. + * These are various customisable components that determine how an ODD app works. * Use `program` to work with a default, or partial, set of components. * * Additionally this does a few other things: * - Restores a session if one was made before and loads the user's file system if needed. * - Attempts to collect capabilities if the configuration has permissions. * - Provides shorthands to functions so you don't have to pass in components. - * - Ensure backwards compatibility with older Webnative clients. + * - Ensure backwards compatibility with older ODD SDK clients. * * See the `program.fileSystem.load` function if you want to load the user's file system yourself. */ @@ -665,7 +665,7 @@ export async function assemble(config: Configuration, components: Components): P container.__odd.extension.connect = connect container.__odd.extension.disconnect = disconnect - // Notify extension that ODD is ready + // Notify extension that the ODD SDK is ready globalThis.postMessage({ id: "odd-devtools-ready-message", }) @@ -828,7 +828,7 @@ async function ensureBackwardsCompatibility(components: Components, config: Conf const [ migK, migV ] = [ "migrated", VERSION ] const currentVersion = Semver.fromString(VERSION) - if (!currentVersion) throw new Error("The webnative VERSION should be a semver string") + if (!currentVersion) throw new Error("The ODD SDK VERSION should be a semver string") // If already migrated, stop here. const migrationOccurred = await components.storage diff --git a/tests/fixtures/webnative-integration-test-v1-0-0.car b/tests/fixtures/odd-integration-test-v1-0-0.car similarity index 100% rename from tests/fixtures/webnative-integration-test-v1-0-0.car rename to tests/fixtures/odd-integration-test-v1-0-0.car diff --git a/tests/fixtures/webnative-integration-test-v2-0-0.car b/tests/fixtures/odd-integration-test-v2-0-0.car similarity index 100% rename from tests/fixtures/webnative-integration-test-v2-0-0.car rename to tests/fixtures/odd-integration-test-v2-0-0.car diff --git a/tests/fs/integration.node.test.ts b/tests/fs/integration.node.test.ts index f1e72bb1b..3e750e985 100644 --- a/tests/fs/integration.node.test.ts +++ b/tests/fs/integration.node.test.ts @@ -14,7 +14,7 @@ import { isSoftLink } from "../../src/fs/types/check.js" describe("the filesystem", () => { it("can load filesystem fixtures", async function () { - const rootCID = await loadCARWithRoot("tests/fixtures/webnative-integration-test-v2-0-0.car") + const rootCID = await loadCARWithRoot("tests/fixtures/odd-integration-test-v2-0-0.car") const readKey = Uint8arrays.fromString("pJW/xgBGck9/ZXwQHNPhV3zSuqGlUpXiChxwigwvUws=", "base64pad") const fs = await loadFilesystem(rootCID, readKey) diff --git a/tests/helpers/components.ts b/tests/helpers/components.ts index 46d22d23f..1b86f006a 100644 --- a/tests/helpers/components.ts +++ b/tests/helpers/components.ts @@ -42,7 +42,7 @@ import { Storage as LocalForageStore } from "./localforage/in-memory-storage.js" export const configuration: Configuration = { - namespace: { name: "Webnative Tests", creator: "Fission" }, + namespace: { name: "ODD SDK Tests", creator: "Fission" }, debug: false, fileSystem: { loadImmediately: false diff --git a/tests/index.node.test.ts b/tests/index.node.test.ts index 720b4f725..5995b4eb7 100644 --- a/tests/index.node.test.ts +++ b/tests/index.node.test.ts @@ -1,11 +1,11 @@ import expect from "expect" import * as DID from "../src/did/index.js" -import * as Webnative from "../src/index.js" +import * as ODD from "../src/index.js" import { components, configuration, username } from "./helpers/components.js" describe("accountDID shorthand", async () => { - const program = await Webnative.assemble(configuration, { ...components }) + const program = await ODD.assemble(configuration, { ...components }) expect(await program.accountDID(username)).toEqual( await DID.write(components.crypto) diff --git a/typedoc.json b/typedoc.json index 6a0c2d0c4..f049710a2 100644 --- a/typedoc.json +++ b/typedoc.json @@ -6,7 +6,7 @@ "**/*.test.ts" ], "excludeExternals": true, - "name": "Webnative SDK", + "name": "ODD SDK", "out": "docs", "theme": "default" } \ No newline at end of file