Skip to content

Commit

Permalink
Rename webnative to odd (#506)
Browse files Browse the repository at this point in the history
* Rename in nix flake

* Rename package to @oddjs/odd and update description

* Update repo URL

* Update homepage URL

* Update package lock names

* Update README

* Rename in comments, error messages, and tests

* Update changelog

* Rename iframe and classified post message to odd

* Set sharedRepo to false

* Rename ODD to ODD SDK where used as a noun

* Rename odd.fission.app to api.odd.dev

Note that this will still publish to webnative.fission.app for the
moment.

* Update docs app_url to odd.fission.app
  • Loading branch information
bgins authored Apr 11, 2023
1 parent 2784245 commit 1791b3e
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
# 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)



# Getting started

```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.
namespace: { creator: "Nullsoft", name: "Winamp" }

}).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
Expand Down Expand Up @@ -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.
Expand All @@ -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
})
Expand All @@ -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"
)

Expand All @@ -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
Expand All @@ -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 }
Expand All @@ -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"
```
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "webnative";
description = "oddjs";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
Expand All @@ -16,7 +16,7 @@
in
{
devShell = pkgs.mkShell {
name = "webnative";
name = "oddjs";
buildInputs = with pkgs; [ nodejs-18_x ];
};
});
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webnative",
"name": "@oddjs/odd",
"version": "0.37.0",
"description": "Webnative SDK",
"description": "ODD SDK",
"keywords": [
"WebCrypto",
"auth",
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-minified.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from "fs"
import zlib from "zlib"


const globalName = "webnative"
const globalName = "oddjs"


console.log("📦 Bundling & minifying...")
Expand Down
2 changes: 1 addition & 1 deletion src/common/cid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down
8 changes: 4 additions & 4 deletions src/components/capabilities/implementation/fission-lobby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -202,7 +202,7 @@ async function getClassifiedViaPostMessage(
}

const message = {
webnative: "exchange-secrets",
odd: "exchange-secrets",
didExchange
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion src/fs/v3/PublicRootWasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 1791b3e

Please sign in to comment.