@civic/did-registry
Advanced tools
Comparing version 0.0.3-alpha.3 to 0.0.3-alpha.4
@@ -11,3 +11,2 @@ import { PublicKey } from "@solana/web3.js"; | ||
export declare type Wallet = AnchorProvider["wallet"]; | ||
export declare const toDid: (key: PublicKey, cluster?: ExtendedCluster) => string; | ||
declare type DidAccount = { | ||
@@ -20,2 +19,3 @@ authority: PublicKey; | ||
protected program: Program<DidRegistry>; | ||
protected cluster: ExtendedCluster; | ||
protected address: Uint8Array; | ||
@@ -25,3 +25,3 @@ protected seedPrefix: string; | ||
protected registryBump: number; | ||
protected constructor(address: Uint8Array, seedPrefix: string); | ||
protected constructor(address: Uint8Array, seedPrefix: string, cluster: ExtendedCluster); | ||
protected didToAccount(did: string): Promise<DidAccount>; | ||
@@ -33,8 +33,8 @@ getRegistryAddressAndBump(): [PublicKey, number]; | ||
private constructor(); | ||
static for(publicKey: PublicKey, connection: Connection): ReadOnlyRegistry; | ||
static forEthAddress(ethAddress: string, connection: Connection): ReadOnlyRegistry; | ||
static for(publicKey: PublicKey, connection: Connection, cluster?: ExtendedCluster): ReadOnlyRegistry; | ||
static forEthAddress(ethAddress: string, connection: Connection, cluster?: ExtendedCluster): ReadOnlyRegistry; | ||
} | ||
export declare class Registry extends ARegistry { | ||
protected wallet: Wallet; | ||
protected constructor(wallet: Wallet, connection: Connection, address: Uint8Array, seedPrefix: string); | ||
protected constructor(wallet: Wallet, connection: Connection, address: Uint8Array, seedPrefix: string, cluster: ExtendedCluster); | ||
private confirm; | ||
@@ -45,6 +45,6 @@ protected init(): Promise<void>; | ||
remove(did: string): Promise<string>; | ||
static for(wallet: Wallet, connection: Connection): Registry; | ||
static for(wallet: Wallet, connection: Connection, cluster?: ExtendedCluster): Registry; | ||
} | ||
export declare class EthRegistry extends Registry { | ||
static forEthAddress(ethAddress: string, wallet: Wallet, connection: Connection): EthRegistry; | ||
static forEthAddress(ethAddress: string, wallet: Wallet, connection: Connection, cluster?: ExtendedCluster): EthRegistry; | ||
register(did: string): Promise<string>; | ||
@@ -51,0 +51,0 @@ private ethSignMessage; |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EthRegistry = exports.Registry = exports.ReadOnlyRegistry = exports.ARegistry = exports.toDid = exports.ETH_KEY_REGISTRY_SEED_PREFIX = exports.KEY_REGISTRY_SEED_PREFIX = exports.DID_REGISTRY_PROGRAM_ID = void 0; | ||
exports.EthRegistry = exports.Registry = exports.ReadOnlyRegistry = exports.ARegistry = exports.ETH_KEY_REGISTRY_SEED_PREFIX = exports.KEY_REGISTRY_SEED_PREFIX = exports.DID_REGISTRY_PROGRAM_ID = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
@@ -26,9 +26,7 @@ const anchor_1 = require("@project-serum/anchor"); | ||
exports.ETH_KEY_REGISTRY_SEED_PREFIX = "eth_key_registry"; | ||
// TODO use DidSolIdentifier instead | ||
const toDid = (key, cluster) => `did:sol:${cluster ? cluster + ":" : ""}${key.toBase58()}`; | ||
exports.toDid = toDid; | ||
class ARegistry { | ||
constructor(address, seedPrefix) { | ||
constructor(address, seedPrefix, cluster) { | ||
this.address = address; | ||
this.seedPrefix = seedPrefix; | ||
this.cluster = cluster; | ||
[this.registryAddress, this.registryBump] = | ||
@@ -56,3 +54,3 @@ this.getRegistryAddressAndBump(); | ||
return []; | ||
return registryAccount.dids.map((did) => "did:sol:" + did.toBase58()); | ||
return registryAccount.dids.map((identifier) => sol_did_client_1.DidSolIdentifier.create(identifier, this.cluster).toString()); | ||
}); | ||
@@ -63,4 +61,4 @@ } | ||
class ReadOnlyRegistry extends ARegistry { | ||
constructor(connection, address, seedPrefix) { | ||
super(address, seedPrefix); | ||
constructor(connection, address, seedPrefix, cluster) { | ||
super(address, seedPrefix, cluster); | ||
const dummyAuthority = { | ||
@@ -78,8 +76,8 @@ publicKey: new web3_js_1.PublicKey("11111111111111111111111111111111"), | ||
} | ||
static for(publicKey, connection) { | ||
return new ReadOnlyRegistry(connection, publicKey.toBuffer(), exports.KEY_REGISTRY_SEED_PREFIX); | ||
static for(publicKey, connection, cluster = "mainnet-beta") { | ||
return new ReadOnlyRegistry(connection, publicKey.toBuffer(), exports.KEY_REGISTRY_SEED_PREFIX, cluster); | ||
} | ||
static forEthAddress(ethAddress, connection) { | ||
static forEthAddress(ethAddress, connection, cluster = "mainnet-beta") { | ||
const trimmedEthAddress = ethAddress.substring(2); // without 0x | ||
return new ReadOnlyRegistry(connection, Buffer.from(trimmedEthAddress, "hex"), exports.ETH_KEY_REGISTRY_SEED_PREFIX); | ||
return new ReadOnlyRegistry(connection, Buffer.from(trimmedEthAddress, "hex"), exports.ETH_KEY_REGISTRY_SEED_PREFIX, cluster); | ||
} | ||
@@ -89,4 +87,4 @@ } | ||
class Registry extends ARegistry { | ||
constructor(wallet, connection, address, seedPrefix) { | ||
super(address, seedPrefix); | ||
constructor(wallet, connection, address, seedPrefix, cluster) { | ||
super(address, seedPrefix, cluster); | ||
this.wallet = wallet; | ||
@@ -149,4 +147,4 @@ this.program = new anchor_1.Program(did_registry_1.IDL, exports.DID_REGISTRY_PROGRAM_ID, new anchor_1.AnchorProvider(connection, wallet, {})); | ||
} | ||
static for(wallet, connection) { | ||
return new Registry(wallet, connection, wallet.publicKey.toBuffer(), exports.KEY_REGISTRY_SEED_PREFIX); | ||
static for(wallet, connection, cluster = "mainnet-beta") { | ||
return new Registry(wallet, connection, wallet.publicKey.toBuffer(), exports.KEY_REGISTRY_SEED_PREFIX, cluster); | ||
} | ||
@@ -156,5 +154,5 @@ } | ||
class EthRegistry extends Registry { | ||
static forEthAddress(ethAddress, wallet, connection) { | ||
static forEthAddress(ethAddress, wallet, connection, cluster = "mainnet-beta") { | ||
const trimmedEthAddress = ethAddress.substring(2); // without 0x | ||
return new EthRegistry(wallet, connection, Buffer.from(trimmedEthAddress, "hex"), exports.ETH_KEY_REGISTRY_SEED_PREFIX); | ||
return new EthRegistry(wallet, connection, Buffer.from(trimmedEthAddress, "hex"), exports.ETH_KEY_REGISTRY_SEED_PREFIX, cluster); | ||
} | ||
@@ -161,0 +159,0 @@ register(did) { |
{ | ||
"name": "@civic/did-registry", | ||
"version": "0.0.3-alpha.3", | ||
"version": "0.0.3-alpha.4", | ||
"description": "An on-chain protocol to provide reverse-lookup on did:sol key membership", | ||
@@ -5,0 +5,0 @@ "author": "Daniel Kelleher <daniel@civic.com>", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
46190
927
1