From 7706e5d4c9a24c82302289fab9978ba30020015b Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Fri, 13 Dec 2024 11:59:42 +0000 Subject: [PATCH] Rename human to user --- apps/idos-enclave/src/lib/enclave.js | 21 ++++---- .../idos-enclave/src/lib/idOSKeyDerivation.ts | 2 +- apps/idos-enclave/src/pages/App.tsx | 10 ++-- .../src/pages/methods/Password.tsx | 7 +-- .../src/creds2.integration.test.ts | 20 +++---- examples/issuer-sdk-demo/src/actions/index.ts | 14 ++--- examples/issuer-sdk-demo/src/app/page.tsx | 4 +- .../src/components/create-profile.tsx | 6 +-- packages/idos-sdk-js/README.md | 4 +- .../idos-sdk-js/src/__tests__/auth.test.ts | 10 ++-- packages/idos-sdk-js/src/lib/auth.ts | 10 ++-- packages/idos-sdk-js/src/lib/data.ts | 18 +++---- .../lib/enclave-providers/iframe-enclave.ts | 10 ++-- .../metamask-snap-enclave.ts | 4 +- .../src/lib/enclave-providers/types.ts | 10 ++-- packages/idos-sdk-js/src/lib/enclave.ts | 10 ++-- packages/idos-sdk-js/src/lib/idos.ts | 16 +++--- packages/idos-sdk-js/src/lib/kwil-wrapper.ts | 18 +++---- packages/issuer-sdk-js/README.md | 52 +++++++++---------- .../issuer-sdk-js/assets/add-user.drawio.svg | 30 +++++------ packages/issuer-sdk-js/package.json | 6 +-- packages/issuer-sdk-js/src/credentials.ts | 8 +-- packages/issuer-sdk-js/src/index.ts | 2 +- .../issuer-sdk-js/src/{human.ts => user.ts} | 30 +++++------ packages/issuer-sdk-js/tsup.config.ts | 2 +- packages/types/index.ts | 10 ++-- 26 files changed, 165 insertions(+), 169 deletions(-) rename packages/issuer-sdk-js/src/{human.ts => user.ts} (69%) diff --git a/apps/idos-enclave/src/lib/enclave.js b/apps/idos-enclave/src/lib/enclave.js index 579ba4c26..332a63ad4 100644 --- a/apps/idos-enclave/src/lib/enclave.js +++ b/apps/idos-enclave/src/lib/enclave.js @@ -48,8 +48,8 @@ export class Enclave { }); } - storage(humanId, signerAddress, signerEncryptionPublicKey, expectedUserEncryptionPublicKey) { - humanId && this.store.set("human-id", humanId); + storage(userId, signerAddress, signerEncryptionPublicKey, expectedUserEncryptionPublicKey) { + userId && this.store.set("user-id", userId); signerAddress && this.store.set("signer-address", signerAddress); signerEncryptionPublicKey && this.store.set("signer-public-key", signerEncryptionPublicKey); @@ -59,11 +59,11 @@ export class Enclave { const storeWithCodec = this.store.pipeCodec(Base64Codec); this.expectedUserEncryptionPublicKey = expectedUserEncryptionPublicKey; - this.humanId = humanId; + this.userId = userId; if (!this.isAuthorizedOrigin) { return { - humanId: "", + userId: "", encryptionPublicKey: "", signerAddress: "", signerPublicKey: "", @@ -71,7 +71,8 @@ export class Enclave { } return { - humanId: this.humanId ?? this.store.get("human-id"), + // TODO Remove human-user migration code. + userId: this.userId ?? this.store.get("user-id") ?? this.store.get("human-id"), encryptionPublicKey: storeWithCodec.get("encryption-public-key"), signerAddress: this.store.get("signer-address"), signerPublicKey: this.store.get("signer-public-key"), @@ -156,7 +157,7 @@ export class Enclave { async ensureKeyPair() { const password = this.store.get("password"); - const salt = this.humanId; + const salt = this.userId; const storeWithCodec = this.store.pipeCodec(Base64Codec); @@ -321,7 +322,7 @@ export class Enclave { const [requestName, requestData] = Object.entries(event.data).flat(); const { fullMessage, - humanId, + userId, message, receiverPublicKey, senderPublicKey, @@ -347,7 +348,7 @@ export class Enclave { reset: () => [], configure: () => [mode, theme], storage: () => [ - humanId, + userId, signerAddress, signerEncryptionPublicKey, expectedUserEncryptionPublicKey, @@ -396,7 +397,7 @@ export class Enclave { } async #openDialog(intent, message) { - if (!this.humanId) throw new Error("Can't open dialog without humanId"); + if (!this.userId) throw new Error("Can't open dialog without userId"); const width = 600; const height = this.configuration?.mode === "new" ? 600 : intent === "backupPasswordOrSecret" ? 520 : 400; @@ -412,7 +413,7 @@ export class Enclave { .map((feat) => feat.join("=")) .join(","); - const dialogURL = new URL(`/dialog.html?humanId=${this.humanId}`, window.location.origin); + const dialogURL = new URL(`/dialog.html?userId=${this.userId}`, window.location.origin); this.dialog = window.open(dialogURL, "idos-dialog", popupConfig); await new Promise((resolve) => this.dialog.addEventListener("ready", resolve, { once: true })); diff --git a/apps/idos-enclave/src/lib/idOSKeyDerivation.ts b/apps/idos-enclave/src/lib/idOSKeyDerivation.ts index 0591c8bf2..f43c0e928 100644 --- a/apps/idos-enclave/src/lib/idOSKeyDerivation.ts +++ b/apps/idos-enclave/src/lib/idOSKeyDerivation.ts @@ -6,7 +6,7 @@ import { scrypt } from "scrypt-js"; * Unicode normalization of input strigs * NFKC: compatibility decomposition followed by canonical composition * validateSalt - * UUID v4 format (idOS human IDs) + * UUID v4 format (idOS user IDs) * n, r, p * CPU/RAM cost (higher = costlier) * n: iteration count diff --git a/apps/idos-enclave/src/pages/App.tsx b/apps/idos-enclave/src/pages/App.tsx index 4953c0f82..22d131f6b 100644 --- a/apps/idos-enclave/src/pages/App.tsx +++ b/apps/idos-enclave/src/pages/App.tsx @@ -64,8 +64,8 @@ export function App({ store, enclave }: AppProps) { const [origin, setOrigin] = useState(null); const [message, setMessage] = useState(null); const [encryptionPublicKey, setEncryptionUserPublicKey] = useState(); - const [humanId] = useState( - new URLSearchParams(window.location.search).get("humanId"), + const [userId] = useState( + new URLSearchParams(window.location.search).get("userId"), ); const isRecoveryMode = useSignal(false); @@ -187,11 +187,7 @@ export function App({ store, enclave }: AppProps) { if (method === "password") { return ( - + ); } diff --git a/apps/idos-enclave/src/pages/methods/Password.tsx b/apps/idos-enclave/src/pages/methods/Password.tsx index 9a0624a10..6279d0524 100644 --- a/apps/idos-enclave/src/pages/methods/Password.tsx +++ b/apps/idos-enclave/src/pages/methods/Password.tsx @@ -82,10 +82,10 @@ export function PasswordForm({ onSuccess, store, encryptionPublicKey, - humanId, + userId, }: MethodProps<{ password: string; duration: number }> & { encryptionPublicKey?: string; - humanId: string | null; + userId: string | null; }) { const password = useSignal(""); const duration = useSignal(7); @@ -96,7 +96,8 @@ export function PasswordForm({ const litCipher = store.get("lit-cipher-text"); async function derivePublicKeyFromPassword(password: string) { - const salt = store.get("human-id") || humanId; + // TODO Remove human-user migration code. + const salt = store.get("user-id") || store.get("human-id") || userId; const secretKey = await idOSKeyDerivation({ password, salt }); const keyPair = nacl.box.keyPair.fromSecretKey(secretKey); return encode(keyPair.publicKey); diff --git a/examples/idos-example-dapp/src/creds2.integration.test.ts b/examples/idos-example-dapp/src/creds2.integration.test.ts index 0d97f7571..899f6efe9 100644 --- a/examples/idos-example-dapp/src/creds2.integration.test.ts +++ b/examples/idos-example-dapp/src/creds2.integration.test.ts @@ -63,7 +63,7 @@ const makePublicNotes = (plaintextW3cVc: ReturnType): export const issuer_makeUserCredential = ( idvData: IdvDataResult, - humanId: string, + userId: string, receiverEncryptionPublicKey: Uint8Array, issuerAttestationSecretKey: Uint8Array, ) => { @@ -74,7 +74,7 @@ export const issuer_makeUserCredential = ( const publicNotes = makePublicNotes(plaintextContent); return { - humanId, + userId, publicNotes: JSON.stringify(publicNotes), plaintextContent: toBytes(plaintextContent), receiverEncryptionPublicKey, @@ -83,7 +83,7 @@ export const issuer_makeUserCredential = ( export const issuer_makeUserCredentialForSharing = ( idvData: IdvDataResult, - humanId: string, + userId: string, receiverEncryptionPublicKey: Uint8Array, issuerAttestationSecretKey: Uint8Array, originalCredentialId: string, @@ -93,7 +93,7 @@ export const issuer_makeUserCredentialForSharing = ( const plaintextContent = makeW3cCredential(idvData, issuerAttestationSecretKey); return { - humanId, + userId, publicNotes: "", plaintextContent: toBytes(plaintextContent), receiverEncryptionPublicKey, @@ -115,7 +115,7 @@ import { shareCredentialByGrant, } from "@idos-network/issuer-sdk-js/credentials"; -const humanId = "bf8709ce-9dfc-11ef-a188-047c16570806"; +const userId = "bf8709ce-9dfc-11ef-a188-047c16570806"; const userEncryptionSecretKey = Base64Codec.decode("nIvx0jPbA8d83rL+I7Vs1B/Fp6pndGtXOX4GDmlEkSQ="); const userEncryptionPublicKey = nacl.box.keyPair.fromSecretKey(userEncryptionSecretKey).publicKey; const _thirdPartyEncryptionSecretKey = Base64Codec.decode( @@ -173,7 +173,7 @@ await (async () => { const issuerConfig = await issuerConfigBuild(); const credential = issuer_makeUserCredential( getIdvData(), - humanId, + userId, userEncryptionPublicKey, issuerAttestationSecretKey, ); @@ -189,7 +189,7 @@ await (async () => { const issuerConfig = await issuerConfigBuild(); const credential = issuer_makeUserCredential( getIdvData(), - humanId, + userId, userEncryptionPublicKey, issuerAttestationSecretKey, ); @@ -207,14 +207,14 @@ await (async () => { issuerConfig, issuer_makeUserCredential( getIdvData(), - humanId, + userId, userEncryptionPublicKey, issuerAttestationSecretKey, ), ); const sharedCredential = issuer_makeUserCredentialForSharing( getIdvData(), - humanId, + userId, thirdPartyEncryptionPublicKey, issuerAttestationSecretKey, insertedCredential.id, @@ -233,7 +233,7 @@ await (async () => { const issuerConfig = await issuerConfigBuild(); const credential = issuer_makeUserCredential( getIdvData(), - humanId, + userId, userEncryptionPublicKey, issuerAttestationSecretKey, ); diff --git a/examples/issuer-sdk-demo/src/actions/index.ts b/examples/issuer-sdk-demo/src/actions/index.ts index 4462cabf2..1086de5a7 100644 --- a/examples/issuer-sdk-demo/src/actions/index.ts +++ b/examples/issuer-sdk-demo/src/actions/index.ts @@ -4,7 +4,7 @@ import { type CreateWalletReqParams, createCredentialByGrant, createCredentialPermissioned, - createHuman, + createUser, editCredential, } from "@idos-network/issuer-sdk-js"; import * as Base64 from "@stablelib/base64"; @@ -65,21 +65,21 @@ const publicNotes = { export async function createProfile( publicKey: string, - humanId: string, + userId: string, wallet: CreateWalletReqParams, ) { const issuer = await getIssuerConfig(); - await createHuman(issuer, { id: humanId, current_public_key: publicKey }, wallet); + await createUser(issuer, { id: userId, current_public_key: publicKey }, wallet); } export async function createCredentialByWriteGrant( - humanId: string, + userId: string, userEncryptionPublicKey: string, ) { const issuer = await getIssuerConfig(); await createCredentialByGrant(issuer, { - humanId, + userId, plaintextContent: vcContent, publicNotes: JSON.stringify({ ...publicNotes, id: crypto.randomUUID() }), receiverEncryptionPublicKey: Base64.decode(userEncryptionPublicKey), @@ -87,13 +87,13 @@ export async function createCredentialByWriteGrant( } export async function createCredentialByPermissionedIssuer( - humanId: string, + userId: string, userEncryptionPublicKey: string, ) { const issuer = await getIssuerConfig(); await createCredentialPermissioned(issuer, { - humanId, + userId, plaintextContent: vcContent, publicNotes: JSON.stringify({ ...publicNotes, id: crypto.randomUUID() }), receiverEncryptionPublicKey: Base64.decode(userEncryptionPublicKey), diff --git a/examples/issuer-sdk-demo/src/app/page.tsx b/examples/issuer-sdk-demo/src/app/page.tsx index fd23e4609..730784b53 100644 --- a/examples/issuer-sdk-demo/src/app/page.tsx +++ b/examples/issuer-sdk-demo/src/app/page.tsx @@ -138,7 +138,7 @@ export default function Home() { try { await createCredentialByWriteGrant( - String(clientSDK.auth.currentUser.humanId), + String(clientSDK.auth.currentUser.userId), clientSDK.auth.currentUser.currentUserPublicKey as string, ); const _credentials = await clientSDK.data.list("credentials"); @@ -150,7 +150,7 @@ export default function Home() { const handleCreateCredential = () => { startCredentialRequestTransition(async () => { await createCredentialByPermissionedIssuer( - String(clientSDK.auth.currentUser.humanId), + String(clientSDK.auth.currentUser.userId), clientSDK.auth.currentUser.currentUserPublicKey as string, ); const _credentials = await clientSDK.data.list("credentials"); diff --git a/examples/issuer-sdk-demo/src/components/create-profile.tsx b/examples/issuer-sdk-demo/src/components/create-profile.tsx index 223375c70..6612be9ee 100644 --- a/examples/issuer-sdk-demo/src/components/create-profile.tsx +++ b/examples/issuer-sdk-demo/src/components/create-profile.tsx @@ -18,9 +18,9 @@ export function CreateProfile({ onSuccess }: { onSuccess: () => void }) { try { if (!idOSSDK) throw new Error("No SDK found"); setLoadingMessage("Creating user password..."); - const humanId = crypto.randomUUID(); + const userId = crypto.randomUUID(); const { userEncryptionPublicKey } = - await idOSSDK.enclave.provider.discoverUserEncryptionPublicKey(humanId); + await idOSSDK.enclave.provider.discoverUserEncryptionPublicKey(userId); setLoadingMessage("Signing message on your wallet..."); @@ -31,7 +31,7 @@ export function CreateProfile({ onSuccess }: { onSuccess: () => void }) { setLoadingMessage("Creating your profile..."); - await createProfile(userEncryptionPublicKey, humanId, { + await createProfile(userEncryptionPublicKey, userId, { address: address as string, signature, message, diff --git a/packages/idos-sdk-js/README.md b/packages/idos-sdk-js/README.md index 5f81e2f99..978cc5a3b 100644 --- a/packages/idos-sdk-js/README.md +++ b/packages/idos-sdk-js/README.md @@ -199,7 +199,7 @@ if (!hasProfile) window.location = "https://kyc-provider.example.com/enroll"; ### The `setSigner` flow and supported wallets ```js -const { humanId } = await idos.setSigner("EVM", signer); +const { userId } = await idos.setSigner("EVM", signer); ``` Besides `hasProfile`, all other queries to idOS nodes require a valid signature. These are performed by your user's wallet, whose signer must be passed to the SDK via the `setSigner` method. Your user's wallet might need to be triggered, so you should be mindful of when in your user's journey you call this method. @@ -517,7 +517,7 @@ const address = (await signer.getAccounts())[0].accountId ```js const hasProfile = await idos.hasProfile(address); if (!hasProfile) window.location = "https://kyc-provider.example.com/enroll"; -const { humanId } = await idos.setSigner(CHAIN_TYPE, signer); +const { userId } = await idos.setSigner(CHAIN_TYPE, signer); ``` ### Credentials diff --git a/packages/idos-sdk-js/src/__tests__/auth.test.ts b/packages/idos-sdk-js/src/__tests__/auth.test.ts index 350a57c26..306532be2 100644 --- a/packages/idos-sdk-js/src/__tests__/auth.test.ts +++ b/packages/idos-sdk-js/src/__tests__/auth.test.ts @@ -6,17 +6,17 @@ import { Store } from "../../../idos-store"; import { TestKwilClient } from "./test-kwil-client"; let auth: Auth; -const humanId = "human-id"; +const userId = "user-id"; const currentUserPublicKey = ""; describe("auth", () => { beforeEach(() => { auth = new Auth(new KwilWrapper(new TestKwilClient()), new Store()); - auth.kwilWrapper.getHumanId = vi.fn().mockResolvedValue("human-id"); - auth.kwilWrapper.getHumanProfile = vi.fn().mockResolvedValue({ + auth.kwilWrapper.getuserId = vi.fn().mockResolvedValue("user-id"); + auth.kwilWrapper.getUserProfile = vi.fn().mockResolvedValue({ current_public_key: currentUserPublicKey, - id: humanId, + id: userId, }); auth.kwilWrapper.client.auth.logout = vi.fn().mockResolvedValue(void 0); auth.kwilWrapper.hasProfile = vi.fn().mockResolvedValue(true); @@ -38,7 +38,7 @@ describe("auth", () => { await auth.setEvmSigner(signer); expect(auth.currentUser).toEqual({ - humanId, + userId, currentUserPublicKey, address, }); diff --git a/packages/idos-sdk-js/src/lib/auth.ts b/packages/idos-sdk-js/src/lib/auth.ts index 3167bd1b4..b63e39ad9 100644 --- a/packages/idos-sdk-js/src/lib/auth.ts +++ b/packages/idos-sdk-js/src/lib/auth.ts @@ -13,7 +13,7 @@ import { Nonce } from "./nonce"; import { implicitAddressFromPublicKey } from "./utils"; export interface AuthUser { - humanId: string | null; + userId: string | null; userAddress: string; /** * The public key of the wallet that was used to sign the message. @@ -74,10 +74,10 @@ export class Auth { signatureType: "secp256k1_ep", }); - const { current_public_key, id } = await this.kwilWrapper.getHumanProfile(); + const { current_public_key, id } = await this.kwilWrapper.getUserProfile(); this.user = { - humanId: id, + userId: id, currentUserPublicKey: current_public_key, userAddress: currentAddress, }; @@ -210,10 +210,10 @@ export class Auth { signatureType: "nep413", }); - const { current_public_key, id } = await this.kwilWrapper.getHumanProfile(); + const { current_public_key, id } = await this.kwilWrapper.getUserProfile(); this.user = { - humanId: id, + userId: id, currentUserPublicKey: current_public_key, userAddress: currentAddress, nearWalletPublicKey: publicKey, diff --git a/packages/idos-sdk-js/src/lib/data.ts b/packages/idos-sdk-js/src/lib/data.ts index ee53e1e55..446ecf716 100644 --- a/packages/idos-sdk-js/src/lib/data.ts +++ b/packages/idos-sdk-js/src/lib/data.ts @@ -87,7 +87,7 @@ export class Data { Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, record.public_notes, record.content, recipientEncryptionPublicKey, @@ -116,7 +116,7 @@ export class Data { synchronous?: boolean, ): Promise & { id: string }> { const name = `add_${this.singularize( - tableName === "human_attributes" ? "attributes" : tableName, + tableName === "user_attributes" ? "attributes" : tableName, )}`; let recipientEncryptionPublicKey: string | undefined; @@ -136,7 +136,7 @@ export class Data { Object.assign( record, await this.#buildInsertableIDOSCredential( - (record as AnyRecord).human_id, + (record as AnyRecord).user_id, (record as AnyRecord).public_notes, (record as AnyRecord).content, recipientEncryptionPublicKey, @@ -271,7 +271,7 @@ export class Data { Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, record.public_notes, record.content, recipientEncryptionPublicKey, @@ -304,7 +304,7 @@ export class Data { Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, "", record.content, granteeEncryptionPublicKey, @@ -351,8 +351,8 @@ export class Data { ); } - async hasWriteGrantGivenBy(humanId: string) { - return await this.kwilWrapper.call("has_write_grant_given_by", { human_id: humanId }); + async hasWriteGrantGivenBy(userId: string) { + return await this.kwilWrapper.call("has_write_grant_given_by", { user_id: userId }); } async hasWriteGrantGivenTo(granteeAddress: string) { @@ -360,7 +360,7 @@ export class Data { } async #buildInsertableIDOSCredential( - humanId: string, + userId: string, publicNotes: string, plaintextContent: string, receiverEncryptionPublicKey: string, @@ -377,7 +377,7 @@ export class Data { ); return { - human_id: humanId, + user_id: userId, content, public_notes: publicNotes, diff --git a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts index 603454048..ecf75111e 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts @@ -32,14 +32,14 @@ export class IframeEnclave implements EnclaveProvider { } async ready( - humanId?: string, + userId?: string, signerAddress?: string, signerEncryptionPublicKey?: string, expectedUserEncryptionPublicKey?: string, ): Promise { let { userEncryptionPublicKey } = (await this.#requestToEnclave({ storage: { - humanId, + userId, signerAddress, signerEncryptionPublicKey, expectedUserEncryptionPublicKey, @@ -239,15 +239,15 @@ export class IframeEnclave implements EnclaveProvider { } async discoverUserEncryptionPublicKey( - humanId: string, + userId: string, ): Promise { if (this.options.mode !== "new") throw new Error("You can only call `discoverUserEncryptionPublicKey` when mode is `new`."); - const userEncryptionPublicKey = await this.ready(humanId); + const userEncryptionPublicKey = await this.ready(userId); return { - humanId, + userId, userEncryptionPublicKey: Base64Codec.encode(userEncryptionPublicKey), }; } diff --git a/packages/idos-sdk-js/src/lib/enclave-providers/metamask-snap-enclave.ts b/packages/idos-sdk-js/src/lib/enclave-providers/metamask-snap-enclave.ts index f607182af..08c2b252c 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/metamask-snap-enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/metamask-snap-enclave.ts @@ -49,12 +49,12 @@ export class MetaMaskSnapEnclave implements EnclaveProvider { } async ready( - humanId?: string, + userId?: string, signerAddress?: string, signerPublicKey?: string, ): Promise { let { encryptionPublicKey } = JSON.parse( - await this.invokeSnap("storage", { humanId, signerAddress, signerPublicKey }), + await this.invokeSnap("storage", { userId, signerAddress, signerPublicKey }), ); encryptionPublicKey ||= await this.invokeSnap("init"); diff --git a/packages/idos-sdk-js/src/lib/enclave-providers/types.ts b/packages/idos-sdk-js/src/lib/enclave-providers/types.ts index a79aa6eba..19a77b040 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/types.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/types.ts @@ -3,13 +3,13 @@ import type { BackupPasswordInfo } from "../types"; export interface StoredData { userEncryptionPublicKey?: Uint8Array; - humanId?: string; + userId?: string; signerAddress?: string; signerEncryptionPublicKey?: string; } export interface DiscoverUserEncryptionPublicKeyResponse { - humanId: string; + userId: string; userEncryptionPublicKey: string; } @@ -25,7 +25,7 @@ export interface EnclaveProvider { load(): Promise; ready( - humanId?: string, + userId?: string, signerAddress?: string, signerEncryptionPublicKey?: string, currentUserEncryptionPublicKey?: string, @@ -39,9 +39,7 @@ export interface EnclaveProvider { receiverPublicKey?: Uint8Array, ): Promise<{ content: Uint8Array; encryptorPublicKey: Uint8Array }>; decrypt(message: Uint8Array, senderPublicKey?: Uint8Array): Promise; - discoverUserEncryptionPublicKey( - humanId: string, - ): Promise; + discoverUserEncryptionPublicKey(userId: string): Promise; filterCredentialsByCountries( credentials: Record[], countries: string[], diff --git a/packages/idos-sdk-js/src/lib/enclave.ts b/packages/idos-sdk-js/src/lib/enclave.ts index 4cd6f7bf7..146d9b908 100644 --- a/packages/idos-sdk-js/src/lib/enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave.ts @@ -18,10 +18,10 @@ export class Enclave { } async ready(): Promise { - const { humanId, userAddress, nearWalletPublicKey, currentUserPublicKey } = + const { userId, userAddress, nearWalletPublicKey, currentUserPublicKey } = this.auth.currentUser; - if (!humanId) throw new Error("Can't operate on a user that has no profile."); + if (!userId) throw new Error("Can't operate on a user that has no profile."); const litAttrs = await this.auth.kwilWrapper.getLitAttrs(); const userWallets = await this.auth.kwilWrapper.getEvmUserWallets(); @@ -32,7 +32,7 @@ export class Enclave { if (this.userEncryptionPublicKey) return this.userEncryptionPublicKey; this.userEncryptionPublicKey = await this.provider.ready( - humanId, + userId, userAddress, nearWalletPublicKey, currentUserPublicKey, @@ -107,7 +107,7 @@ export class Enclave { return this.provider.backupPasswordOrSecret(callbackFn); } - async discoverUserEncryptionPublicKey(humanId: string) { - return this.provider.discoverUserEncryptionPublicKey(humanId); + async discoverUserEncryptionPublicKey(userId: string) { + return this.provider.discoverUserEncryptionPublicKey(userId); } } diff --git a/packages/idos-sdk-js/src/lib/idos.ts b/packages/idos-sdk-js/src/lib/idos.ts index e58ffa6cb..4f3f60efb 100644 --- a/packages/idos-sdk-js/src/lib/idos.ts +++ b/packages/idos-sdk-js/src/lib/idos.ts @@ -1,4 +1,4 @@ -import type { idOSHumanAttribute } from "@idos-network/idos-sdk-types"; +import type { idOSUserAttribute } from "@idos-network/idos-sdk-types"; import type { Wallet } from "@near-wallet-selector/core"; import { isEqual } from "es-toolkit"; import type { Signer } from "ethers"; @@ -115,8 +115,8 @@ export class idOS { return this.kwilWrapper.kwilProvider; } - filterLitAttributes(userAttrs: idOSHumanAttribute[], storableAttributes: StorableAttribute[]) { - const hasLitKey = (attr: idOSHumanAttribute | StorableAttribute) => + filterLitAttributes(userAttrs: idOSUserAttribute[], storableAttributes: StorableAttribute[]) { + const hasLitKey = (attr: idOSUserAttribute | StorableAttribute) => "key" in attr ? attr.key.includes("lit-") : attr.attribute_key.includes("lit-"); return { @@ -125,7 +125,7 @@ export class idOS { }; } async updateAttributesIfNeeded( - filteredUserAttributes: idOSHumanAttribute[], // Arrays here are not safe (it's a string) + filteredUserAttributes: idOSUserAttribute[], // Arrays here are not safe (it's a string) litSavableAttributes: StorableAttribute[], // Arrays here are safe (it's a real array) ): Promise { // biome-ignore lint/suspicious/noAsyncPromiseExecutor: @@ -134,7 +134,7 @@ export class idOS { const userAttrMap = new Map( filteredUserAttributes.map((attr) => [attr.attribute_key, attr]), ); - const attributesToCreate: Omit[] = []; + const attributesToCreate: Omit[] = []; // Helper function to safely parse JSON strings const safeParse = (text: string) => { @@ -223,7 +223,7 @@ export class idOS { ); const userAttrs = ((await this.data.list("attributes")) || - []) as unknown as idOSHumanAttribute[]; + []) as unknown as idOSUserAttribute[]; const { filteredUserAttributes, litSavableAttributes } = this.filterLitAttributes( userAttrs, @@ -233,7 +233,7 @@ export class idOS { }); } - async discoverUserEncryptionPublicKey(humanId: string) { - return this.enclave.discoverUserEncryptionPublicKey(humanId); + async discoverUserEncryptionPublicKey(userId: string) { + return this.enclave.discoverUserEncryptionPublicKey(userId); } } diff --git a/packages/idos-sdk-js/src/lib/kwil-wrapper.ts b/packages/idos-sdk-js/src/lib/kwil-wrapper.ts index e0a398efa..4e5d23276 100644 --- a/packages/idos-sdk-js/src/lib/kwil-wrapper.ts +++ b/packages/idos-sdk-js/src/lib/kwil-wrapper.ts @@ -1,4 +1,4 @@ -import type { idOSHuman, idOSHumanAttribute, idOSWallet } from "@idos-network/idos-sdk-types"; +import type { idOSUser, idOSUserAttribute, idOSWallet } from "@idos-network/idos-sdk-types"; import { KwilSigner, Utils as KwilUtils, WebKwil } from "@kwilteam/kwil-js"; import type { ActionBody, ActionInput } from "@kwilteam/kwil-js/dist/core/action"; import type { CustomSigner, EthSigner } from "@kwilteam/kwil-js/dist/core/builders.d"; @@ -128,18 +128,18 @@ export class KwilWrapper { /** * @deprecated * - * Use {@link KwilWrapper.getHumanProfile} instead. + * Use {@link KwilWrapper.getUserProfile} instead. */ - async getHumanId(): Promise { + async getuserId(): Promise { // biome-ignore lint/suspicious/noExplicitAny: TBD - const result = (await this.call("get_wallet_human_id", {}, "See your idOS profile ID")) as any; + const result = (await this.call("get_wallet_user_id", {}, "See your idOS profile ID")) as any; - return result[0]?.human_id || null; + return result[0]?.user_id || null; } - async getHumanProfile(): Promise { - const [human] = (await this.call("get_human", null)) as unknown as [idOSHuman]; - return human; + async getUserProfile(): Promise { + const [user] = (await this.call("get_user", null)) as unknown as [idOSUser]; + return user; } async hasProfile(user: string): Promise { @@ -150,7 +150,7 @@ export class KwilWrapper { } async getLitAttrs() { - const attrs = (await this.call("get_attributes", null)) as unknown as idOSHumanAttribute[]; + const attrs = (await this.call("get_attributes", null)) as unknown as idOSUserAttribute[]; return attrs.filter((attr) => attr.attribute_key.startsWith("lit-")); } diff --git a/packages/issuer-sdk-js/README.md b/packages/issuer-sdk-js/README.md index 3204380f0..994248327 100644 --- a/packages/issuer-sdk-js/README.md +++ b/packages/issuer-sdk-js/README.md @@ -31,37 +31,37 @@ const issuerConfig = await createIssuerConfig({ }); ``` -## Creating a human profile +## Creating a user profile This procedure can only be done by a Permissioned Issuer. Get in touch with us at engineering@idos.network if you're interested in being one. -To create a human profile in idOS, you need: -1. **A wallet address** associated with the human. +To create a user profile in idOS, you need: +1. **A wallet address** associated with the user. 2. **A public encryption key** derived from either a password or a passkey chosen by the user in the idOS enclave app. -### Human Creation Process -Human Creation Process +### User Creation Process +User Creation Process -#### Step 1: Decide on a human id +#### Step 1: Decide on a user id -Deciding on a human id for a user is an issuer decision. You can use whichever you want, as long as it's an [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier). +Deciding on a user id for a user is an issuer decision. You can use whichever you want, as long as it's an [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier). ```js // Server side -const humanId = crypto.randomUUID(); +const userId = crypto.randomUUID(); // Remember it on your database -session.user.update({ humanId }) +session.user.update({ userId }) // Return it to the front-end to be used in the next step -return { humanId } +return { userId } ``` #### Step 2: Derive the Public Key -Use the `idos.discoverUserEncryptionPublicKey` function to derive a public key for the human. This key will be used to encrypt and decrypt human's credential content. +Use the `idos.discoverUserEncryptionPublicKey` function to derive a public key for the user. This key will be used to encrypt and decrypt user's credential content. ```javascript // Client side @@ -73,36 +73,36 @@ import { idOS } from "@idos-network/idos-sdk-js"; const initParams = { ...YOUR_IDOS_INIT_PARAMS, mode: "new" }; const idos = await idOS.init(...); -// Get humanId associated with this user from your server -const { humanId } = await yourServer.getIdosInformation(); +// Get userId associated with this user from your server +const { userId } = await yourServer.getIdosInformation(); // Discover user encryption key -const { encryptionPublicKey } = await idos.discoverUserEncryptionPublicKey(humanId); +const { encryptionPublicKey } = await idos.discoverUserEncryptionPublicKey(userId); // Report it back to your server await yourServer.reportIdosEncryptionPublicKey(encryptionPublicKey); ``` -#### Step 3: Creating a Human Profile -Once the public key is derived, you can create the human profile in idOS by passing it to the `createHuman` function alongside with human id and the wallet the user's going to use to drive their idOS profile. +#### Step 3: Creating a User Profile +Once the public key is derived, you can create the user profile in idOS by passing it to the `createUser` function alongside with user id and the wallet the user's going to use to drive their idOS profile. ```javascript // Server side -import { createHuman } from "@idos-network/issuer-sdk-js"; +import { createUser } from "@idos-network/issuer-sdk-js"; import issuerConfig from "./issuer-config.js"; // Get this from the user's request, and remember it const currentPublicKey = request.params['userEncryptionPublicKey'] session.user.currentPublicKey = currentPublicKey -// Get the stored human id -const humanId = session.user.humanId +// Get the stored user id +const userId = session.user.userId -// Build the human object -const human = { - id: humanId, +// Build the user object +const user = { + id: userId, current_public_key: currentPublicKey, } @@ -121,7 +121,7 @@ const walletPayload = { } // Create the user on idOS nodes, and get some information back. -const [profile, wallet] = await createHuman(issuerConfig, human, walletPayload); +const [profile, wallet] = await createUser(issuerConfig, user, walletPayload); ``` ## Writing credentials @@ -200,8 +200,8 @@ const credentialContent = JSON.stringify({ const credentialPayload = { id: crypto.randomUUID(), - // user id of the human who is creating the credential. - human_id: session.user.humanId, + // user id of the user who is creating the credential. + user_id: session.user.userId, // The verifiable credential content should be passed as it's seen in the example at https://verifiablecredentials.dev/ usually a stringfied JSON object. // credential content is encrypted, using the Issuer's secret encryption key, along with the receiver's public encryption key. @@ -218,7 +218,7 @@ const credentialPayload = { const credential = await createCredentialByGrant(issuerConfig, credentialPayload); ``` -This will create a credential in the idOS for the given human id. +This will create a credential in the idOS for the given user id. > ⚠️ Notice diff --git a/packages/issuer-sdk-js/assets/add-user.drawio.svg b/packages/issuer-sdk-js/assets/add-user.drawio.svg index caed1428a..b59828e84 100644 --- a/packages/issuer-sdk-js/assets/add-user.drawio.svg +++ b/packages/issuer-sdk-js/assets/add-user.drawio.svg @@ -17,13 +17,13 @@
- Ask for the human id + Ask for the user id
- Ask for the human id + Ask for the user id @@ -40,7 +40,7 @@ discoverUserEncryptionKey
- with the human id (step 2) + with the user id (step 2)
@@ -135,7 +135,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
@@ -154,7 +154,7 @@
- Decide on a human id + Decide on a user id
for this user (step 1)
@@ -163,7 +163,7 @@
- Decide on a human id... + Decide on a user id... @@ -175,7 +175,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
@@ -237,13 +237,13 @@
- Get the human id + Get the user id
- Get the human id + Get the user id @@ -291,7 +291,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
@@ -312,7 +312,7 @@
Call - createHuman + createuser
(step 3) @@ -321,7 +321,7 @@
- Call createHuman... + Call createuser... @@ -414,7 +414,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
@@ -435,7 +435,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
@@ -497,7 +497,7 @@
- %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20human%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E + %3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20style%3D%22edgeStyle%3DelbowEdgeStyle%3Brounded%3D0%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3Belbow%3Dvertical%3Bcurved%3D1%3B%22%20edge%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22215%22%20as%3D%22sourcePoint%22%2F%3E%3CmxPoint%20x%3D%22590%22%20y%3D%22235%22%20as%3D%22targetPoint%22%2F%3E%3CArray%20as%3D%22points%22%3E%3CmxPoint%20x%3D%22630%22%20y%3D%22225%22%2F%3E%3C%2FArray%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22Decide%20on%20a%20user%20id%26lt%3Bdiv%26gt%3Bfor%20this%20user%26lt%3B%2Fdiv%26gt%3B%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%222%22%3E%3CmxGeometry%20x%3D%22-0.072%22%20y%3D%22-1%22%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%2221%22%20y%3D%22-26%22%20as%3D%22offset%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
diff --git a/packages/issuer-sdk-js/package.json b/packages/issuer-sdk-js/package.json index 92b3ded0a..3967275f5 100644 --- a/packages/issuer-sdk-js/package.json +++ b/packages/issuer-sdk-js/package.json @@ -28,9 +28,9 @@ "types": "./dist/create-issuer-config.d.ts", "import": "./dist/create-issuer-config.js" }, - "./human": { - "types": "./dist/human.d.ts", - "import": "./dist/human.js" + "./user": { + "types": "./dist/user.d.ts", + "import": "./dist/user.js" }, "./credentials": { "types": "./dist/credentials.d.ts", diff --git a/packages/issuer-sdk-js/src/credentials.ts b/packages/issuer-sdk-js/src/credentials.ts index a0be5c301..b32474d33 100644 --- a/packages/issuer-sdk-js/src/credentials.ts +++ b/packages/issuer-sdk-js/src/credentials.ts @@ -33,12 +33,12 @@ type InsertableIDOSCredential = Omit & { const buildInsertableIDOSCredential = ( issuerConfig: IssuerConfig, { - humanId, + userId, publicNotes, plaintextContent, receiverEncryptionPublicKey, }: { - humanId: string; + userId: string; publicNotes: string; plaintextContent: Uint8Array; receiverEncryptionPublicKey: Uint8Array; @@ -54,7 +54,7 @@ const buildInsertableIDOSCredential = ( }); return { - human_id: humanId, + user_id: userId, content: Base64Codec.encode(content), public_notes, @@ -74,7 +74,7 @@ const buildInsertableIDOSCredential = ( type BaseCredentialParams = { id?: string; - humanId: string; + userId: string; publicNotes: string; plaintextContent: Uint8Array; receiverEncryptionPublicKey: Uint8Array; diff --git a/packages/issuer-sdk-js/src/index.ts b/packages/issuer-sdk-js/src/index.ts index 992947fd9..74cd86aff 100644 --- a/packages/issuer-sdk-js/src/index.ts +++ b/packages/issuer-sdk-js/src/index.ts @@ -1,6 +1,6 @@ export * from "./create-issuer-config"; export * from "./credentials"; -export * from "./human"; +export * from "./user"; // export types. export * from "../../types"; diff --git a/packages/issuer-sdk-js/src/human.ts b/packages/issuer-sdk-js/src/user.ts similarity index 69% rename from packages/issuer-sdk-js/src/human.ts rename to packages/issuer-sdk-js/src/user.ts index de1ae589d..ab208a82e 100644 --- a/packages/issuer-sdk-js/src/human.ts +++ b/packages/issuer-sdk-js/src/user.ts @@ -1,19 +1,19 @@ -import type { idOSHuman, idOSWallet } from "./../../types"; +import type { idOSUser, idOSWallet } from "./../../types"; import type { IssuerConfig } from "./create-issuer-config"; import { createActionInput, ensureEntityId } from "./internal"; -export interface CreateProfileReqParams extends Omit { +export interface CreateProfileReqParams extends Omit { id?: string; } -async function createHumanProfile( +async function createUserProfile( { dbid, kwilClient, kwilSigner }: IssuerConfig, params: CreateProfileReqParams, -): Promise { +): Promise { const payload = ensureEntityId(params); await kwilClient.execute( { - name: "add_human_as_inserter", + name: "add_user_as_inserter", dbid, inputs: [createActionInput(payload)], }, @@ -46,31 +46,31 @@ async function upsertWallet( return payload; } -export interface CreateWalletReqParams extends Omit {} +export interface CreateWalletReqParams extends Omit {} -export async function createHuman( +export async function createUser( config: IssuerConfig, - human: CreateProfileReqParams, + user: CreateProfileReqParams, wallet: CreateWalletReqParams, ) { - const human_id = human.id ?? crypto.randomUUID(); + const user_id = user.id ?? crypto.randomUUID(); const wallet_id = wallet.id ?? crypto.randomUUID(); - const humanReqParams = { - ...human, - id: human_id, + const userReqParams = { + ...user, + id: user_id, }; - const humanResponse = await createHumanProfile(config, humanReqParams); + const userResponse = await createUserProfile(config, userReqParams); const walletReqParams = { ...wallet, - human_id, + user_id, id: wallet_id, }; const walletResponse = await upsertWallet(config, walletReqParams); // @todo: I am not sure if this is the best way to return the response. Need to think about it. - return [humanResponse, walletResponse]; + return [userResponse, walletResponse]; } diff --git a/packages/issuer-sdk-js/tsup.config.ts b/packages/issuer-sdk-js/tsup.config.ts index 56459e097..6aaec382a 100644 --- a/packages/issuer-sdk-js/tsup.config.ts +++ b/packages/issuer-sdk-js/tsup.config.ts @@ -4,7 +4,7 @@ export default defineConfig({ entry: [ "./src/index.ts", "./src/create-issuer-config.ts", - "./src/human.ts", + "./src/user.ts", "./src/credentials.ts", ], splitting: false, diff --git a/packages/types/index.ts b/packages/types/index.ts index 15b9aa2c4..634d12e1e 100644 --- a/packages/types/index.ts +++ b/packages/types/index.ts @@ -1,13 +1,13 @@ export type idOSCredentialStatus = "pending" | "contacted" | "approved" | "rejected" | "expired"; -export interface idOSHuman { +export interface idOSUser { id: string; current_public_key: string; } export interface idOSCredential { id: string; - human_id: string; + user_id: string; issuer_auth_public_key: string; original_id?: string; public_notes: string; @@ -24,7 +24,7 @@ export interface idOSGrant { export interface idOSWallet { id: string; - human_id: string; + user_id: string; address: string; wallet_type: string; message: string; @@ -32,9 +32,9 @@ export interface idOSWallet { signature: string; } -export interface idOSHumanAttribute { +export interface idOSUserAttribute { id: string; - human_id: string; + user_id: string; attribute_key: string; value: string; }