diff --git a/README.md b/README.md index 6bcf8383b..2d9e280b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Web5 JS SDK + Making developing with Web5 components at least 5 times easier to work with. ⚠️ WEB5 JS SDK IS CURRENTLY IN TECH PREVIEW ⚠️ @@ -8,44 +9,50 @@ The SDK is currently still under active development, but having entered the Tech ## Introduction Web5 consists of the following components: + - Decentralized Identifiers - Verifiable Credentials - DWeb Node personal datastores -The SDK sets out to gather the most oft used functionality from all three of these -pillar technologies to provide a simple library that is as close to effortless as +The SDK sets out to gather the most oft used functionality from all three of these +pillar technologies to provide a simple library that is as close to effortless as possible. ## Docs ### Installation -*NPM* +_NPM_ + ```yaml npm install @tbd54566975/web5 ``` -*CDNs* +_CDNs_ + ```yaml -https://unpkg.com/@tbd54566975/web5@0.7.0/dist/browser.js +https://unpkg.com/@tbd54566975/web5@0.7.2/dist/browser.js ``` + ```yaml -https://cdn.jsdelivr.net/npm/@tbd54566975/web5@0.7.0/dist/browser.mjs +https://cdn.jsdelivr.net/npm/@tbd54566975/web5@0.7.2/dist/browser.mjs ``` ### Importing the SDK ```javascript -import { Web5 } from '@tbd54566975/web5'; +import { Web5 } from "@tbd54566975/web5"; ``` + or + ```javascript import { Web5 } from CDN_LINK_HERE; ``` ### **`Web5.connect()`** - Enables an app to request connection to a user's local identity app (like a desktop or mobile agent - work is underway for reference apps of each), or generate an in-app DID to represent the user (e.g. if the user does not have an identity app). +Enables an app to request connection to a user's local identity app (like a desktop or mobile agent - work is underway for reference apps of each), or generate an in-app DID to represent the user (e.g. if the user does not have an identity app). > **NOTE:** The outputs of this method invocation with be used throughout the other API methods below. @@ -59,67 +66,69 @@ const { web5, did: myDid } = await Web5.connect(); An invocation of `Web5.connect()` produces the following items in response: -- **`web5`** - *`Web5 instance`*: A class instance that enables access to a locally running DWeb Node, DID interaction methods, and other capabilities related to the connected DID. -- **`did`** - *`DID instance`*: A class instance representing the Decentralized Identifier of the DID that was created or attained connection to. - +- **`web5`** - _`Web5 instance`_: A class instance that enables access to a locally running DWeb Node, DID interaction methods, and other capabilities related to the connected DID. +- **`did`** - _`string`_: The DID that was created or attained connection to. ### **`Record` instances from responses** -Every modifying method (`create`, `write`, etc.) and the `entries` from queries return an instance of a `Record` class, which is a representation of the Record(s) being referenced. `Record` class instances offer the following properties and methods: +Every modifying method (`create`, `write`, etc.) and the `entries` from queries return an instance of a `Record` class, which is a representation of the Record(s) being referenced. + +Each `Record` instance has the following instance properties: `id`, `attestation`, `contextId`, `dataFormat`, `dateCreated`, `encryption`, `interface`, `method`, `parentId`, `protocol`, `protocolPath`, `recipient`, `schema`, `dataCid`, `dataSize`, `dateModified`, `datePublished`, and `published`. + +> **Note** The **`id`** property is a unique identifier based on the record entry's composition. All entries across all records are deterministically unique. -- **`id`** - *`string`*: The unique identifier based on the record entry's composition. Note: all entries across all records are deterministically unique. -- **`descriptor`** - *`object`*: The descriptor object for the constructed DWeb Node message. -- **`data`** - *`object`*: a object with the following convenience methods that read out the data of the record entry in the following formats: - - **`text`** - *`function`*: produces a textual representation of the data. - - **`json`** - *`function`*: if the value is JSON data, this method will return a parsed JSON object. - - **`stream`** - *`function`*: returns the raw stream of bytes for the data. -- **`send`** - *`function`*: generates a `delete` entry tombstone for the record. This is a convenience method that allows you to easily delete records with less verbosity. -- **`update`** - *`function`*: takes in a new request object matching the expected method signature of a `write` and overwrites the record. This is a convenience method that allows you to easily overwrite records with less verbosity. -- **`delete`** - *`function`*: generates a `delete` entry tombstone for the record. This is a convenience method that allows you to easily delete records with less verbosity. +Each `Record` instance has the following instance methods: + +- **`data`** - _`object`_: a object with the following convenience methods that read out the data of the record entry in the following formats: + - **`text`** - _`function`_: produces a textual representation of the data. + - **`json`** - _`function`_: if the value is JSON data, this method will return a parsed JSON object. + - **`stream`** - _`function`_: returns the raw stream of bytes for the data. +- **`send`** - _`function`_: generates a `delete` entry tombstone for the record. This is a convenience method that allows you to easily delete records with less verbosity. +- **`update`** - _`function`_: takes in a new request object matching the expected method signature of a `write` and overwrites the record. This is a convenience method that allows you to easily overwrite records with less verbosity. +- **`delete`** - _`function`_: generates a `delete` entry tombstone for the record. This is a convenience method that allows you to easily delete records with less verbosity. ### **`web5.dwn.records.query()`** -Method for querying the DWeb Node of a provided `target` DID. +Method for querying either the locally connected DWeb Node or any remote DWeb Node specified in the `from` property. ```javascript // This invocation will query the user's own DWeb Nodes const { records } = await web5.dwn.records.query({ message: { filter: { - schema: 'https://schema.org/Playlist', - dataFormat: 'application/json' - } - } + schema: "https://schema.org/Playlist", + dataFormat: "application/json", + }, + }, }); - -console.log(records) // an array of record entries from Bob's DWeb Nodes +console.log(records); // an array of record entries from Bob's DWeb Nodes // This invocation will query Bob's DWeb Nodes const { records } = await web5.dwn.records.query({ - from: 'did:example:bob', + from: "did:example:bob", message: { filter: { - protocol: 'https://music.org/protocol', - schema: 'https://schema.org/Playlist', - dataFormat: 'application/json' - } - } + protocol: "https://music.org/protocol", + schema: "https://schema.org/Playlist", + dataFormat: "application/json", + }, + }, }); -console.log(records) // an array of record entries from Bob's DWeb Nodes +console.log(records); // an array of record entries from Bob's DWeb Nodes ``` #### **Request** -The query `request` must contain the following: +The query `request` contains the following properties: -- **`from`** - *`DID string`* (*optional*): the decentralized identifier of the DID of the DWeb Node the query will fetch results from. -- **`message`** - *`object`*: the properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: - - **`filter`** - *`object`*: properties against which results of the query will be filtered: - - **`protocol`** - *`URI string`* (*optional*): the URI of the protocol bucket in which to query. - - **`schema`** - *`URI string`* (*optional*): the URI of the protocol bucket in which to query. - - **`dataFormat`** - *`Media Type string`* (*optional*): the IANA string corresponding with the format of the data to filter for. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml +- **`from`** - _`DID string`_ (_optional_): the decentralized identifier of the DID of the DWeb Node the query will fetch results from. +- **`message`** - _`object`_: the properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: + - **`filter`** - _`object`_: properties against which results of the query will be filtered: + - **`protocol`** - _`URI string`_ (_optional_): the URI of the protocol bucket in which to query. + - **`schema`** - _`URI string`_ (_optional_): the URI of the protocol bucket in which to query. + - **`dataFormat`** - _`Media Type string`_ (_optional_): the IANA string corresponding with the format of the data to filter for. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml ### **`web5.dwn.records.create()`** @@ -128,86 +137,42 @@ Method for creating a new record and storing it in the user's local DWeb Node, r ```javascript // this creates a record and stores it in the user's local DWeb Node const { record } = await web5.dwn.records.create({ - data: 'Hello World!', + data: "Hello World!", message: { - dataFormat: 'text/plain' - } + dataFormat: "text/plain", + }, }); -console.log(await record.data.text()) // logs "Hello World!" -const { status } = await record.send(myDid) // send the record to the user's remote DWeb Nodes -const { status } = await record.send('did:example:bob') // send the newly generated record to Bob's DWeb Nodes +console.log(await record.data.text()); // logs "Hello World!" +const { status } = await record.send(myDid); // send the record to the user's remote DWeb Nodes +const { status } = await record.send("did:example:bob"); // send the newly generated record to Bob's DWeb Nodes // this creates a record, but does not store it in the user's local DWeb Node const { record } = await web5.dwn.records.create({ store: false, - data: 'Hello again, World!', + data: "Hello again, World!", message: { - dataFormat: 'text/plain' - } + dataFormat: "text/plain", + }, }); -const { status } = await record.send('did:example:bob') // send the newly generated record to Bob's DWeb Nodes +const { status } = await record.send("did:example:bob"); // send the newly generated record to Bob's DWeb Nodes ``` #### **Request** The `create` request object is composed as follows: -- **`store`** - *`boolean`*: tells the create function whether or not to store the record in the user's local DWeb Node. (you might pass `false` if you didn't want to retain a copy of the record for yourself) -- **`data`** - *`text|object|file|blob`*: The data payload of the record. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: - - **`protocol`** - *`URI string`* (*optional*): the URI of the protocol under which the record will be bucketed. - - **`schema`** - *`URI string`* (*optional*): the URI of the schema under which the record will be bucketed. - - **`dataFormat`** - *`Media Type string`* (*optional*): the IANA string corresponding with the format of the data the record will be bucketed. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml - +- **`store`** - _`boolean`_: tells the create function whether or not to store the record in the user's local DWeb Node. (you might pass `false` if you didn't want to retain a copy of the record for yourself) +- **`data`** - _`text|object|file|blob`_: The data payload of the record. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: + - **`protocol`** - _`URI string`_ (_optional_): the URI of the protocol under which the record will be bucketed. + - **`schema`** - _`URI string`_ (_optional_): the URI of the schema under which the record will be bucketed. + - **`dataFormat`** - _`Media Type string`_ (_optional_): the IANA string corresponding with the format of the data the record will be bucketed. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml ### **`web5.dwn.records.write()`** -Method for writing an update to a record in the user's local DWeb Node, remote DWeb Nodes, or another party's DWeb Nodes (if permitted). - - -```javascript -// this creates a record and stores it in the user's local DWeb Node -const { record } = await web5.dwn.records.create({ - data: 'Hello World!', - message: { - dataFormat: 'text/plain' - } -}); - -console.log(await record.data.text()) // logs "Hello World!" -const { status } = await record.send(myDid) // send the record to the user's remote DWeb Nodes -const { status } = await record.send('did:example:bob') // send the newly generated record to Bob's DWeb Nodes - -// this overwrites the existing a record, but does not store it in the user's local DWeb Node -const { record } = await web5.dwn.records.write({ - data: 'Hello again, World!', - message: { - recordId: record.id, - dataFormat: 'text/plain' - } -}); - -console.log(await record.data.text()) // logs "Hello again, World!" -const { status } = await record.send(myDid) // send updated record to the user's remote DWeb Nodes -const { status } = await record.send('did:example:bob') // send the updated record to Bob's DWeb Nodes - -// A convenience method of the Record instance -const { status } = await record.update({ - data: 'Hello for a final time, world' -}) -``` -#### **Request** - -The `write` request object is composed as follows: - -- **`store`** - *`boolean`*: tells the `write` function whether or not to store the record in the user's local DWeb Node. (you might pass `false` if you didn't want to retain a copy of the record for yourself) -- **`data`** - *`text|object|file|blob`*: The data payload of the record. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: - - **`protocol`** - *`URI string`* (*optional*): the URI of the protocol under which the record will be bucketed. - - **`schema`** - *`URI string`* (*optional*): the URI of the schema under which the record will be bucketed. - - **`dataFormat`** - *`Media Type string`* (*optional*): the IANA string corresponding with the format of the data the record will be bucketed. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml +The `create()` method is an alias for `write()` and both can take the same request object properties. ### **`web5.dwn.records.read()`** @@ -217,30 +182,30 @@ Method for reading a record stored in the DWeb Node of the user's local DWeb Nod // Reads the indicated record from the user's DWeb Nodes const { record } = await web5.dwn.records.read({ message: { - recordId: 'bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5' - } + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, }); -console.log(await record.data.text()) // assuming the record is a text payload, logs the text +console.log(await record.data.text()); // assuming the record is a text payload, logs the text // Reads the indicated record from Bob's DWeb Nodes const { record } = await web5.dwn.records.read({ - from: 'did:example:bob', + from: "did:example:bob", message: { - recordId: 'bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5' - } + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, }); -console.log(await record.data.text()) // assuming the record is a text payload, logs the text +console.log(await record.data.text()); // assuming the record is a text payload, logs the text ``` #### **Request** The `read` request object is composed as follows: -- **`from`** - *`DID string`* (*optional*): The DID of the DWeb Node the read request will fetch the indicated record from. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. - - **`recordId`** - *`string`*: the required record ID string that identifies the record data you are fetching. +- **`from`** - _`DID string`_ (_optional_): The DID of the DWeb Node the read request will fetch the indicated record from. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`recordId`** - _`string`_: the required record ID string that identifies the record data you are fetching. ### **`web5.dwn.records.delete()`** @@ -250,16 +215,16 @@ Method for deleting a record stored in the DWeb Node of the user's local DWeb No // Deletes the indicated record from the user's DWeb Node const { record } = await web5.dwn.records.delete({ message: { - recordId: 'bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5' - } + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, }); // Deletes the indicated record from Bob's DWeb Node const { record } = await web5.dwn.records.delete({ - from: 'did:example:bob', + from: "did:example:bob", message: { - recordId: 'bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5' - } + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, }); ``` @@ -267,9 +232,9 @@ const { record } = await web5.dwn.records.delete({ The `delete` request object is composed as follows: -- **`from`** - *`DID string`* (*optional*): The DID of the DWeb Node the delete tombstone will be sent to. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. - - **`recordId`** - *`string`*: the required record ID string that identifies the record being deleted. +- **`from`** - _`DID string`_ (_optional_): The DID of the DWeb Node the delete tombstone will be sent to. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`recordId`** - _`string`_: the required record ID string that identifies the record being deleted. ### **`web5.dwn.protocols.configure()`** @@ -281,73 +246,68 @@ const { protocol } = await web5.dwn.protocols.configure({ definition: { protocol: "https://photos.org/protocol", types: { - "album": { - "schema": "https://photos.org/protocol/album", - "dataFormat": [ "application/json" ] + album: { + schema: "https://photos.org/protocol/album", + dataFormat: ["application/json"], }, - "photo": { - "schema": "https://photos.org/protocols/photo", - "dataFormat": [ "application/json" ] + photo: { + schema: "https://photos.org/protocols/photo", + dataFormat: ["application/json"], + }, + binaryImage: { + dataFormat: ["image/png", "jpeg", "gif"], }, - "binaryImage": { - "dataFormat": [ - "image/png", - "jpeg", - "gif" - ] - } }, structure: { - "album": { + album: { $actions: [ { who: "recipient", - can: "read" - } - ] + can: "read", + }, + ], }, - "photo": { + photo: { $actions: [ { who: "recipient", - can: "read" - } + can: "read", + }, ], - "binaryImage": { + binaryImage: { $actions: [ { who: "author", of: "photo", - can: "write" - } - ] - } - } - } - } - } + can: "write", + }, + ], + }, + }, + }, + }, + }, }); -protocol.send(myDid) // sends the protocol configuration to the user's other DWeb Nodes. +protocol.send(myDid); // sends the protocol configuration to the user's other DWeb Nodes. ``` #### **Request** The `configure` request object is composed as follows: -- **`from`** - *`string`*: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. - - **`definition`** - *`object`*: an object that defines the enforced composition of the protocol. - - **`protocol`** - *`URI string`*: a URI that represents the protocol being configured. - - **`types`** - *`object`*: an object that defines the records that can be used in the `structure` graph of the `definition` object. The following properties are optional constraints you can set for the type being defined: - - **`schema`** - *`URI string`* (*optional*): the URI of the schema under which the record will be bucketed. - - **`dataFormat`** - *`Media Type string`* (*optional*): the IANA string corresponding with the format of the data the record will be bucketed. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml - - **`structure`** - *`object`*: an object that defines the structure of a protocol, including data relationships and constraints on which entities can perform various activities. Fields under the `structure` object of the Protocol definition are expected to be either type references matching those defined in the `types` object. The type structures are recursive, so types form a graph and each type can have within it further attached types or the following rule statements that are all denoted with the prefix `$`: - - **`$actions`** - *`array`*: one or more rule objects that expose various allowed actions to actors (`author`, `recipient`), composed as follows: - - **`who`** - *`string`*: the actor (`author`, `recipient`) that is being permitted to invoke a given action. - - **`of`** - *`string`*: the protocol path that refers to the record subject. Using the above example protocol, the protocol path to `binaryImage` would be `photo/binaryImage`. - - **`can`** - *`string`*: the action being permitted by the rule. - +- **`from`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`definition`** - _`object`_: an object that defines the enforced composition of the protocol. + - **`protocol`** - _`URI string`_: a URI that represents the protocol being configured. + - **`types`** - _`object`_: an object that defines the records that can be used in the `structure` graph of the `definition` object. The following properties are optional constraints you can set for the type being defined: + - **`schema`** - _`URI string`_ (_optional_): the URI of the schema under which the record will be bucketed. + - **`dataFormat`** - _`Media Type string`_ (_optional_): the IANA string corresponding with the format of the data the record will be bucketed. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml + - **`structure`** - _`object`_: an object that defines the structure of a protocol, including data relationships and constraints on which entities can perform various activities. Fields under the `structure` object of the Protocol definition are expected to be either type references matching those defined in the `types` object. The type structures are recursive, so types form a graph and each type can have within it further attached types or the following rule statements that are all denoted with the prefix `$`: + - **`$actions`** - _`array`_: one or more rule objects that expose various allowed actions to actors (`author`, `recipient`), composed as follows: + - **`who`** - _`string`_: the actor (`author`, `recipient`) that is being permitted to invoke a given action. + - **`of`** - _`string`_: the protocol path that refers to the record subject. Using the above example protocol, the protocol path to `binaryImage` would be `photo/binaryImage`. + - **`can`** - _`string`_: the action being permitted by the rule. ### **`web5.dwn.protocols.query()`** @@ -357,34 +317,33 @@ Method for querying a DID's DWeb Nodes for the presence of a protocol. This meth const { protocols } = await web5.dwn.protocols.query({ message: { filter: { - protocol: 'https://music.org/protocol' - } - } + protocol: "https://music.org/protocol", + }, + }, }); -console.log(protocols) // logs an array of protocol configurations installed on the user's own DWeb Node +console.log(protocols); // logs an array of protocol configurations installed on the user's own DWeb Node const { protocols } = await web5.dwn.protocols.query({ - from: 'did:example:bob', + from: "did:example:bob", message: { filter: { - protocol: 'https://music.org/protocol' - } - } + protocol: "https://music.org/protocol", + }, + }, }); -console.log(protocols) // logs an array of protocol configurations installed on Bob's DWeb Node +console.log(protocols); // logs an array of protocol configurations installed on Bob's DWeb Node ``` #### **Request** The query `request` must contain the following: -- **`from`** - *`DID string`* (*optional*): the decentralized identifier of the DID of the DWeb Node the query will fetch results from. -- **`message`** - *`object`*: The properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: - - **`filter`** - *`object`*: properties against which results of the query will be filtered: - - **`protocol`** - *`URI string`* (*optional*): the URI of the protocol bucket in which to query. - +- **`from`** - _`DID string`_ (_optional_): the decentralized identifier of the DID of the DWeb Node the query will fetch results from. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid record query: + - **`filter`** - _`object`_: properties against which results of the query will be filtered: + - **`protocol`** - _`URI string`_ (_optional_): the URI of the protocol bucket in which to query. ### **`web5.did.create(method, options)`** @@ -393,15 +352,15 @@ The `create` method under the `did` object enables generation of DIDs for a supp > NOTE: You do not usually need to manually invoke this, as the `Web5.connect()` method already acquires a DID for the user (either by direct creation or connection to an identity agent app). ```javascript -const myDid = await Web5.did.create('ion'); +const myDid = await Web5.did.create("ion"); ``` ## Project Resources -| Resource | Description | -| ------------------------------------------ | ------------------------------------------------------------------------------ | -| [CODEOWNERS](./CODEOWNERS) | Outlines the project lead(s) | +| Resource | Description | +| ------------------------------------------ | ----------------------------------------------------------------------------- | +| [CODEOWNERS](./CODEOWNERS) | Outlines the project lead(s) | | [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) | Expected behavior for project contributors, promoting a welcoming environment | -| [CONTRIBUTING.md](./CONTRIBUTING.md) | Developer guide to build, test, run, access CI, chat, discuss, file issues | -| [GOVERNANCE.md](./GOVERNANCE.md) | Project governance | -| [LICENSE](./LICENSE) | Apache License, Version 2.0 | \ No newline at end of file +| [CONTRIBUTING.md](./CONTRIBUTING.md) | Developer guide to build, test, run, access CI, chat, discuss, file issues | +| [GOVERNANCE.md](./GOVERNANCE.md) | Project governance | +| [LICENSE](./LICENSE) | Apache License, Version 2.0 | diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 6a6d72f53..161f01206 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/crypto", - "version": "0.1.1", + "version": "0.1.2", "description": "TBD crypto library", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", diff --git a/packages/dids/package.json b/packages/dids/package.json index 12ad19fee..5c36e5b5c 100644 --- a/packages/dids/package.json +++ b/packages/dids/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/dids", - "version": "0.1.1", + "version": "0.1.2", "description": "TBD DIDs library", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", @@ -74,7 +79,7 @@ }, "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", - "@tbd54566975/crypto": "0.1.1", + "@tbd54566975/crypto": "0.1.2", "@tbd54566975/dwn-sdk-js": "0.0.32", "cross-fetch": "3.1.5" }, diff --git a/packages/web5-agent/package.json b/packages/web5-agent/package.json index ea6c1b606..bfa2ba637 100644 --- a/packages/web5-agent/package.json +++ b/packages/web5-agent/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/web5-agent", - "version": "0.1.1", + "version": "0.1.2", "description": "Web5 Agent", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", diff --git a/packages/web5-proxy-agent/package.json b/packages/web5-proxy-agent/package.json index 3a7017c6f..55161158d 100644 --- a/packages/web5-proxy-agent/package.json +++ b/packages/web5-proxy-agent/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/web5-proxy-agent", - "version": "0.1.1", + "version": "0.1.2", "description": "Web5 Proxy Agent", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", @@ -70,7 +75,7 @@ "node": ">=18.0.0" }, "dependencies": { - "@tbd54566975/web5-agent": "0.1.1" + "@tbd54566975/web5-agent": "0.1.2" }, "devDependencies": { "@types/chai": "4.3.0", diff --git a/packages/web5-user-agent/package.json b/packages/web5-user-agent/package.json index 12e5d5855..616302704 100644 --- a/packages/web5-user-agent/package.json +++ b/packages/web5-user-agent/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/web5-user-agent", - "version": "0.1.1", + "version": "0.1.2", "description": "Web5 User Agent", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", @@ -71,7 +76,7 @@ }, "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", - "@tbd54566975/dids": "0.1.1", + "@tbd54566975/dids": "0.1.2", "@tbd54566975/dwn-sdk-js": "0.0.32", "abstract-level": "1.0.3", "cross-fetch": "3.1.5", diff --git a/packages/web5/package.json b/packages/web5/package.json index 71631e526..7218902ea 100644 --- a/packages/web5/package.json +++ b/packages/web5/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/web5", - "version": "0.7.1", + "version": "0.7.2", "description": "SDK for accessing the features and capabilities of Web5", "type": "module", "main": "./dist/cjs/main.cjs", @@ -45,6 +45,11 @@ "require": "./dist/cjs/main.cjs", "types": "./dist/types/main.d.ts" }, + "./browser": { + "import": "./dist/browser.mjs", + "require": "./dist/browser.js", + "types": "./dist/types/main.d.ts" + }, "./electron": { "import": "./dist/esm/main.mjs", "require": "./dist/electron/main.cjs", @@ -75,12 +80,12 @@ }, "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", - "@tbd54566975/crypto": "0.1.1", - "@tbd54566975/dids": "0.1.1", + "@tbd54566975/crypto": "0.1.2", + "@tbd54566975/dids": "0.1.2", "@tbd54566975/dwn-sdk-js": "0.0.32", - "@tbd54566975/web5-agent": "0.1.1", - "@tbd54566975/web5-proxy-agent": "0.1.1", - "@tbd54566975/web5-user-agent": "0.1.1", + "@tbd54566975/web5-agent": "0.1.2", + "@tbd54566975/web5-proxy-agent": "0.1.2", + "@tbd54566975/web5-user-agent": "0.1.2", "cross-fetch": "3.1.5", "level": "8.0.0", "ms": "2.1.3", diff --git a/packages/web5/src/record.ts b/packages/web5/src/record.ts index 7e9246a73..103aababb 100644 --- a/packages/web5/src/record.ts +++ b/packages/web5/src/record.ts @@ -5,7 +5,7 @@ import type { RecordsReadReply, RecordsWriteDescriptor, RecordsWriteMessage, Rec import { ReadableWebToNodeStream } from 'readable-web-to-node-stream'; import { DataStream, DwnInterfaceName, DwnMethodName, Encoder } from '@tbd54566975/dwn-sdk-js'; -import { dataToBlob, isDataSizeUnderCacheLimit } from './utils.js'; +import { dataToBlob } from './utils.js'; import type { RecordsDeleteResponse } from './dwn-api.js'; export type RecordOptions = RecordsWriteMessage & { diff --git a/test.mjs b/test.mjs deleted file mode 100644 index b5c53004b..000000000 --- a/test.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import { Web5 } from '@tbd54566975/web5'; -import { DidIonApi } from '@tbd54566975/dids'; -import { Web5 as OldWeb5 } from './packages/old/dist/esm/index.mjs' - -const oldWeb5 = new OldWeb5(); -await oldWeb5.did.create('ion'); - -const DidIon = new DidIonApi(); - -const did = await DidIon.create(); -console.log(did); - -const drr = await DidIon.resolve(did.id); -console.log(JSON.stringify(drr, null, 2)); - -//! NOTE: this only works in browser right now because storage is localStorage. will swap that out tomorrow -// const { web5 } = await Web5.connect(); -// console.log(web5); \ No newline at end of file