I’m using the self.id/web
library. I authenticate like so:
const CERAMIC_URL = process.env.CERAMIC_URL || 'http://localhost:7007'
export async function connectIDX(signer: Signer) : Promise<SelfID<ConfigType>> {
log.trace("IDX: Initiating connection...");
const authProvider = await createAuthProvider(signer);
const aliases = await getConfig();
const self = await SelfID.authenticate<ConfigType>({
authProvider,
ceramic: CERAMIC_URL,
connectNetwork: process.env.THREEID_NETWORK as ConnectNetwork|undefined,
aliases,
});
log.trace(`IDX: connected ${!!self?.id}...`);
// Attempt link, do not await this.
createLink(self, authProvider);
return self;
}
My .env file has the following:
# TODO: ThreeID should run entirely self-hosted
THREEID_NETWORK=local
CERAMIC_URL=http://localhost:7007
Pretty bog-standard, works on testnet and I’m pretty sure it used to work many iterations ago.
The only other thing I can think that might be relevant is our bootstrap process?
import { promises } from "fs";
import { CeramicClient } from '@ceramicnetwork/http-client'
import { ModelManager } from '@glazed/devtools'
import { Ed25519Provider } from 'key-did-provider-ed25519';
import { fromString } from 'uint8arrays';
import { getResolver } from 'key-did-resolver'
import { DID } from 'dids';
const idxFolder = new URL('../src/', import.meta.url);
const schemaPath = new URL(`config.${process.env.CONFIG_NAME}.json`, idxFolder);
const { writeFile, readFile } = promises;
//
// Publish our schema to the node (must happen once per deploy)
async function publish(manager: ModelManager) {
// Publish the two schemas
const schema = await readFile(new URL('schemaJWE.json', idxFolder), 'utf8');
const SchemaJWE = JSON.parse(schema);
const schemaId = await manager.createSchema("jwe", SchemaJWE);
const schemaUrl = manager.getSchemaURL(schemaId);
if (!schemaUrl) throw new Error("Cannot publish schema: missing URL");
const privateDetails = await manager.createDefinition("AccountDetails", {
name: 'AccountDetails',
description: 'Verified account details',
schema: schemaUrl,
})
return privateDetails;
}
//
// Connect to the Ceramic node
async function connect() {
// Create and authenticate the DID
const seed = fromString(process.env.CERAMIC_SEED!, 'base16')
const did = new DID({
provider: new Ed25519Provider(seed),
resolver: getResolver(),
})
// Authenticate the Ceramic instance with the provider
await did.authenticate()
// The seed must be provided as an environment variable
const ceramic = new CeramicClient(process.env.CERAMIC_URL)
await ceramic.setDID(did)
return ceramic;
}
async function run() {
// Connect to local node
const ceramic = await connect();
// Create a manager for the model
const manager = new ModelManager({ceramic})
// prepare schema for publishing
await publish(manager);
// Publish and store details
const model = await manager.deploy();
// Write details to path
const config = JSON.stringify(model, null, 2)
await writeFile(schemaPath, config);
console.log(`Config written to ${schemaPath}`, config)
process.exit(0)
}
run().catch(console.error)
This completes, I think correctly, and again - it used to work (I’m running on clay & mainnet).