Skip to content

Instantly share code, notes, and snippets.

View csuwildcat's full-sized avatar

Daniel Buchner csuwildcat

View GitHub Profile
protocols = (() => {
const definitions = {};
const functions = {
alias: (path, map) => {
// Handling alias definitions, store the protocol URI with each alias
for (const alias in map) {
definitions[alias] = map[alias];
console.log(`Alias '${alias}' added with protocol URI: ${map[alias].protocol}`);
}
https://dweb/${DID}/read/protocols/encodeURIComponent(this.profileProtocolUri)/avatar
{
published: true,
protocol: 'https://areweweb5yet.com/protocols/blog',
types: {
follow: {
schema: "https://areweweb5yet.com/protocols/follow",
dataFormats: ["application/json"]
},
post: {
schema: "https://areweweb5yet.com/protocols/post",
import { Web5 } from '@web5/api';
import { DidJwk, DidDht, BearerDid } from '@web5/dids';
import { DwnRegistrar } from '@web5/agent';
import { Web5UserAgent } from '@web5/user-agent';
let initialize;
const instances = {};
const didLabelRegex = /(?:[^@]*@)?(did:[a-z0-9]+:[a-zA-Z0-9-]+)/;
const storage = {
class AppChannel {
static channels = {};
constructor(name, options = {}) {
this.name = name;
this.sender = new BroadcastChannel(name);
this.receiver = new BroadcastChannel(name);
this.store = options.store || false;
this.data = null;
console.log('Hello world!')
import { UniversalResolver, DidDht, DidWeb } from '@web5/dids';
if (self instanceof ServiceWorkerGlobalScope) {
const DidResolver = new UniversalResolver({ didResolvers: [DidDht, DidWeb] });
const didUrlRegex = /^https?:\/\/dweb\/(([^\/]+)\/.*)?$/;
const httpToHttpsRegex = /^http:/;
const trailingSlashRegex = /\/$/;
self.addEventListener('fetch', event => {
{
"uri": "https://slick.app",
"schemas": {
"invite": "https://slick.app/schemas/invite",
"community": "https://slick.app/schemas/community",
"details": "https://slick.app/schemas/details",
"channel": "https://slick.app/schemas/channel",
"message": "https://slick.app/schemas/message",
"reaction": "https://slick.app/schemas/reaction",
"admin": "https://slick.app/schemas/admin",
{
types: {
invitation: {
schema: "https://example.com/protocols/signdocs/invitation"
dataFormats: ['application/json']
}
},
structure: {
invitation: {
$actions: [
$ npm run test:browser
> @web5/[email protected] test:browser
> karma start karma.conf.cjs
Firefox 115.0 (Windows 10) WARN: 'failed to get tech preview dwn endpoints:', 'Network error'
18 11 2023 10:40:30.385:INFO [launcher]: Starting browser WebkitHeadless
18 11 2023 10:40:30.850:INFO [WebKit 605.1.15 (Windows 8)]: Connected on socket nFNGv_D5KWu4ABEUAAAF with id 17526702
WebKit 605.1.15 (Windows 8) LOG: 'STATUS CODE: 400 --> SchemaValidationFailure: /descriptor: must have required property 'schema''