diff --git a/apps/dashboard-for-dapps/src/routes/index.tsx b/apps/dashboard-for-dapps/src/routes/index.tsx index 465463430..9d06d1246 100644 --- a/apps/dashboard-for-dapps/src/routes/index.tsx +++ b/apps/dashboard-for-dapps/src/routes/index.tsx @@ -74,7 +74,7 @@ const useFetchGrants = () => { queryKey: ["grants"], queryFn: () => idOS.grants.list({ - grantee: address, + granteeAddress: address, }), select: (data) => data.map((grant) => ({ @@ -331,7 +331,6 @@ function CredentialDetails({ { if (profile) { // @ts-expect-error await _sdk.setSigner(signer.type, signer.value); - const _pk = _sdk.auth.currentUser.publicKey; + const _pk = _sdk.auth.currentUser.currentUserPublicKey; setPublicKey(_pk); } diff --git a/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/delete-credential.tsx b/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/delete-credential.tsx index 15643eff0..28f603964 100644 --- a/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/delete-credential.tsx +++ b/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/delete-credential.tsx @@ -142,7 +142,7 @@ export const DeleteCredential = ({ isOpen, credential, onClose }: DeleteCredenti if (!credential) return null; const [currentToRevoke] = state; - const { grantee } = currentToRevoke ?? {}; + const { granteeAddress } = currentToRevoke ?? {}; const meta = JSON.parse(credential.public_notes); @@ -172,7 +172,7 @@ export const DeleteCredential = ({ isOpen, credential, onClose }: DeleteCredenti <> Revoking grant for grantee: - {grantee} + {granteeAddress} ) : deleteCredential.isPending ? ( diff --git a/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/grants-center.tsx b/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/grants-center.tsx index c13c4ccb1..42de32d4d 100644 --- a/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/grants-center.tsx +++ b/apps/idos-data-dashboard/src/routes/dashboard/credentials/components/grants-center.tsx @@ -34,8 +34,8 @@ type GrantsCenterProps = { }; function generateGrantId(grant: idOSGrant): string { - const { dataId, grantee, owner, lockedUntil } = grant; - return [dataId, grantee, owner, lockedUntil].join("-"); + const { dataId, granteeAddress, ownerAddress, lockedUntil } = grant; + return [dataId, granteeAddress, ownerAddress, lockedUntil].join("-"); } function timelockToMs(timelock: number): number { @@ -96,7 +96,7 @@ const Shares = ({ credentialId, grants }: { credentialId: string; grants: idOSGr data-grant={JSON.stringify(grant)} > - {grant.grantee} + {grant.granteeAddress} {grant.lockedUntil ? timelockToDate(grant.lockedUntil) : "-"} diff --git a/apps/idos-data-dashboard/src/routes/dashboard/credentials/shared/index.ts b/apps/idos-data-dashboard/src/routes/dashboard/credentials/shared/index.ts index 1b6eb0ac9..dc64d432c 100644 --- a/apps/idos-data-dashboard/src/routes/dashboard/credentials/shared/index.ts +++ b/apps/idos-data-dashboard/src/routes/dashboard/credentials/shared/index.ts @@ -9,11 +9,11 @@ export const useFetchGrants = ({ credentialId }: { credentialId: string }) => { const queryClient = useQueryClient(); const credentials = queryClient.getQueryData(["credentials"]); - const owner = address?.includes("0x") ? address : publicKey; + const ownerAddress = address?.includes("0x") ? address : publicKey; return useQuery({ queryKey: ["grants", credentialId], - queryFn: () => sdk.grants.list({ owner }), + queryFn: () => sdk.grants.list({ ownerAddress }), retry: 1, select(grants) { if (!credentials || !grants) return []; @@ -34,8 +34,8 @@ export const useRevokeGrant = () => { const queryClient = useQueryClient(); return useMutation<{ transactionId: string }, DefaultError, idOSGrant, Ctx>({ - mutationFn: ({ grantee, dataId, lockedUntil }: idOSGrant) => - sdk.grants.revoke("credentials", dataId, grantee, dataId, lockedUntil), + mutationFn: ({ granteeAddress, dataId, lockedUntil }: idOSGrant) => + sdk.grants.revoke("credentials", dataId, granteeAddress, dataId, lockedUntil), mutationKey: ["revokeGrant"], async onMutate(grant) { const previousCredentials = diff --git a/apps/idos-enclave/src/lib/enclave.js b/apps/idos-enclave/src/lib/enclave.js index 2b7afeb81..b166869db 100644 --- a/apps/idos-enclave/src/lib/enclave.js +++ b/apps/idos-enclave/src/lib/enclave.js @@ -48,10 +48,10 @@ export class Enclave { }); } - storage(humanId, signerAddress, signerPublicKey, expectedUserEncryptionPublicKey) { - humanId && this.store.set("human-id", humanId); + storage(userId, signerAddress, userEncryptionPublicKey, expectedUserEncryptionPublicKey) { + userId && this.store.set("user-id", userId); signerAddress && this.store.set("signer-address", signerAddress); - signerPublicKey && this.store.set("signer-public-key", signerPublicKey); + userEncryptionPublicKey && this.store.set("signer-public-key", userEncryptionPublicKey); const litAttrs = this.store.get("litAttrs"); this.handlstoreableAttributes(litAttrs); @@ -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"), @@ -157,7 +158,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); @@ -250,10 +251,6 @@ export class Enclave { } } - messageParent(message) { - window.parent.postMessage(message, this.parentOrigin); - } - async filterCredentialsByCountries(credentials, countries) { const decrypted = await Promise.all( credentials.map(async (credential) => ({ @@ -326,12 +323,12 @@ export class Enclave { const [requestName, requestData] = Object.entries(event.data).flat(); const { fullMessage, - humanId, + userId, message, receiverPublicKey, senderPublicKey, signerAddress, - signerPublicKey, + signerEncryptionPublicKey, mode, theme, credentials, @@ -352,9 +349,9 @@ export class Enclave { reset: () => [], configure: () => [mode, theme], storage: () => [ - humanId, + userId, signerAddress, - signerPublicKey, + signerEncryptionPublicKey, expectedUserEncryptionPublicKey, litAttrs, userWallets, @@ -401,7 +398,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; @@ -417,7 +414,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 ed503841a..96a011d16 100644 --- a/apps/idos-enclave/src/pages/App.tsx +++ b/apps/idos-enclave/src/pages/App.tsx @@ -64,7 +64,7 @@ export function App({ store, enclave }: AppProps) { const [origin, setOrigin] = useState(null); const [message, setMessage] = useState(null); const [encryptionPublicKey, setEncryptionUserPublicKey] = useState(""); - const [humanId] = useState( + const [userId] = useState( new URLSearchParams(window.location.search).get("humanId"), ); @@ -197,11 +197,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/api/EVM.ts b/examples/idos-example-dapp/api/EVM.ts index 719681f62..16b6983d1 100644 --- a/examples/idos-example-dapp/api/EVM.ts +++ b/examples/idos-example-dapp/api/EVM.ts @@ -19,7 +19,7 @@ const evmGranteeSigner = new ethers.Wallet( const idosGrantee = await idOSGrantee.init({ chainType: "EVM", granteeSigner: evmGranteeSigner, - encryptionSecret: ENCRYPTION_SECRET_KEY, + recipientEncryptionPrivateKey: ENCRYPTION_SECRET_KEY, }); const encryptionPublicKey = idosGrantee.encryptionPublicKey; diff --git a/examples/idos-example-dapp/api/NEAR.ts b/examples/idos-example-dapp/api/NEAR.ts index f633e5f96..57392a4e3 100644 --- a/examples/idos-example-dapp/api/NEAR.ts +++ b/examples/idos-example-dapp/api/NEAR.ts @@ -15,7 +15,7 @@ const nearGranteeSigner = KeyPair.fromString(NEAR_GRANTEE_PRIVATE_KEY); const idosGrantee = await idOSGrantee.init({ chainType: "NEAR", granteeSigner: nearGranteeSigner, - encryptionSecret: ENCRYPTION_SECRET_KEY, + recipientEncryptionPrivateKey: ENCRYPTION_SECRET_KEY, }); const encryptionPublicKey = idosGrantee.encryptionPublicKey; @@ -38,7 +38,7 @@ export default async function (request: VercelRequest, response: VercelResponse) } const rawBody = request.read(); - let body; + let body: ReturnType; try { body = JSON.parse(rawBody); } catch (e) { 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/idos-example-dapp/src/main.js b/examples/idos-example-dapp/src/main.js index 345c7efca..c42010943 100644 --- a/examples/idos-example-dapp/src/main.js +++ b/examples/idos-example-dapp/src/main.js @@ -293,7 +293,8 @@ const connectWallet = { .h1("eyes", "User's grants to this dApp") .wait( "awaiting RPC", - cache.get("grants") || idos.grants.list({ owner, grantee: granteeInfo.grantee }), + cache.get("grants") || + idos.grants.list({ ownerAddress: owner, granteeAddress: granteeInfo.grantee }), ); cache.set("grants", grants); 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 a447e9ed9..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 { encryptionPublicKey } = - await idOSSDK.enclave.provider.discoverUserEncryptionKey(humanId); + const userId = crypto.randomUUID(); + const { userEncryptionPublicKey } = + 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(encryptionPublicKey, humanId, { + await createProfile(userEncryptionPublicKey, userId, { address: address as string, signature, message, diff --git a/packages/grantee-sdk-js/src/idOS-grantee.ts b/packages/grantee-sdk-js/src/idOS-grantee.ts index 94b987544..546874d23 100644 --- a/packages/grantee-sdk-js/src/idOS-grantee.ts +++ b/packages/grantee-sdk-js/src/idOS-grantee.ts @@ -86,7 +86,7 @@ const buildKwilSignerAndGrantee = ( }; interface idOSGranteeInitParams { - encryptionSecret: string; + recipientEncryptionPrivateKey: string; nodeUrl?: string; chainId?: string; dbId?: string; @@ -109,7 +109,7 @@ export class idOSGrantee { grants?: GrantChild; static async init(_: { - encryptionSecret: string; + recipientEncryptionPrivateKey: string; nodeUrl?: string; chainId?: string; dbId?: string; @@ -119,7 +119,7 @@ export class idOSGrantee { }): Promise; static async init(_: { - encryptionSecret: string; + recipientEncryptionPrivateKey: string; nodeUrl?: string; chainId?: string; dbId?: string; @@ -129,7 +129,7 @@ export class idOSGrantee { }): Promise; static async init({ - encryptionSecret, + recipientEncryptionPrivateKey, nodeUrl = KwilWrapper.defaults.kwilProvider, chainId, dbId, @@ -173,7 +173,7 @@ export class idOSGrantee { } return new idOSGrantee( - NoncedBox.fromBase64SecretKey(encryptionSecret), + NoncedBox.fromBase64SecretKey(recipientEncryptionPrivateKey), nodeKwil, kwilSigner, dbId, @@ -250,8 +250,8 @@ export class idOSGrantee { if (!this.grants) throw new Error("NEAR is not implemented yet"); return this.grants.list({ - owner: address, - grantee: this.grantee, + ownerAddress: address, + granteeAddress: this.grantee, }); } diff --git a/packages/grantee-sdk-js/src/idOS.ts b/packages/grantee-sdk-js/src/idOS.ts index 11439338f..91d4de440 100644 --- a/packages/grantee-sdk-js/src/idOS.ts +++ b/packages/grantee-sdk-js/src/idOS.ts @@ -10,28 +10,28 @@ export class idOS { static async init( chainType: "EVM" | "NEAR", - privateKey: string, - encryptionSecretKey: string, + authnPrivateKey: string, + recipientEncryptionPrivateKey: string, nodeUrl: string, ) { let grantee: idOSGrantee; switch (chainType) { case "EVM": { - const signer = new ethers.Wallet(privateKey, new JsonRpcProvider(nodeUrl)); + const signer = new ethers.Wallet(authnPrivateKey, new JsonRpcProvider(nodeUrl)); grantee = await idOSGrantee.init({ chainType, granteeSigner: signer, - encryptionSecret: encryptionSecretKey, + recipientEncryptionPrivateKey, }); return new idOS(grantee); } case "NEAR": { - const signer = KeyPair.fromString(privateKey); + const signer = KeyPair.fromString(authnPrivateKey); grantee = await idOSGrantee.init({ chainType, granteeSigner: signer, - encryptionSecret: privateKey, + recipientEncryptionPrivateKey: authnPrivateKey, }); return new idOS(grantee); } diff --git a/packages/idos-sdk-js/README.md b/packages/idos-sdk-js/README.md index 41ff3e008..4e55552e3 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..ae8514a11 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); @@ -33,14 +33,14 @@ describe("auth", () => { test("should set a user from an EVM signer", async () => { const signer = Wallet.createRandom(); - const address = await signer.getAddress(); + const userAddress = await signer.getAddress(); await auth.setEvmSigner(signer); expect(auth.currentUser).toEqual({ - humanId, + userId, currentUserPublicKey, - address, + userAddress, }); }); diff --git a/packages/idos-sdk-js/src/lib/auth.ts b/packages/idos-sdk-js/src/lib/auth.ts index 8ffb387f7..530d04c81 100644 --- a/packages/idos-sdk-js/src/lib/auth.ts +++ b/packages/idos-sdk-js/src/lib/auth.ts @@ -15,9 +15,16 @@ import { Nonce } from "./nonce"; import { implicitAddressFromPublicKey } from "./utils"; export interface AuthUser { - humanId: string | null; - address: string; - publicKey?: string; + userId: string | null; + userAddress: string; + /** + * The public key of the wallet that was used to sign the message. + * It's only available when the `signer` is a NEAR wallet. + */ + nearWalletPublicKey?: string; + /** + * The derived public key of the user from the password / passkey. + */ currentUserPublicKey?: string; } @@ -69,12 +76,12 @@ 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, - address: currentAddress, + userAddress: currentAddress, }; } @@ -205,13 +212,13 @@ 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, - address: currentAddress, - publicKey, + 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 14c1b46e0..b93399f1a 100644 --- a/packages/idos-sdk-js/src/lib/data.ts +++ b/packages/idos-sdk-js/src/lib/data.ts @@ -76,18 +76,19 @@ export class Data { records: T[], synchronous?: boolean, ) { - let receiverPublicKey: string | undefined; + let recipientEncryptionPublicKey: string | undefined; if (tableName === "credentials") { - receiverPublicKey = receiverPublicKey ?? base64Encode(await this.enclave.ready()); + recipientEncryptionPublicKey = + recipientEncryptionPublicKey ?? base64Encode(await this.enclave.ready()); for (const record of records) { Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, record.public_notes, record.content, - receiverPublicKey, // Encryption + recipientEncryptionPublicKey, ), ); } @@ -113,10 +114,10 @@ export class Data { synchronous?: boolean, ): Promise & { id: string }> { const name = `add_${this.singularize( - tableName === "human_attributes" ? "attributes" : tableName, + tableName === "user_attributes" ? "attributes" : tableName, )}`; - let receiverPublicKey: string | undefined; + let recipientEncryptionPublicKey: string | undefined; const inputs: string[] = ((await this.kwilWrapper.schema) as AnyRecord).data.actions .find((action: AnyRecord) => action.name === name) @@ -129,14 +130,14 @@ export class Data { } if (tableName === "credentials") { - receiverPublicKey ??= base64Encode(await this.enclave.ready()); + recipientEncryptionPublicKey ??= base64Encode(await this.enclave.ready()); 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, - receiverPublicKey, // Encryption + recipientEncryptionPublicKey, ), ); } @@ -257,21 +258,21 @@ export class Data { description?: string, synchronous?: boolean, ): Promise { - if (!this.enclave.encryptionPublicKey) await this.enclave.ready(); + if (!this.enclave.userEncryptionPublicKey) await this.enclave.ready(); - let receiverPublicKey: string | undefined; + let recipientEncryptionPublicKey: string | undefined; // biome-ignore lint/suspicious/noExplicitAny: using any to avoid type errors for now. const record: any = recordLike; if (tableName === "credentials") { - receiverPublicKey ??= base64Encode(await this.enclave.ready()); + recipientEncryptionPublicKey ??= base64Encode(await this.enclave.ready()); Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, record.public_notes, record.content, - receiverPublicKey, // Encryption + recipientEncryptionPublicKey, ), ); } @@ -289,7 +290,7 @@ export class Data { async share( tableName: string, recordId: string, - receiverPublicKey: string, + granteeRecipientEncryptionPublicKey: string, synchronous?: boolean, ): Promise<{ id: string }> { const name = this.singularize(tableName); @@ -301,10 +302,10 @@ export class Data { Object.assign( record, await this.#buildInsertableIDOSCredential( - record.human_id, + record.user_id, "", record.content, - receiverPublicKey, // Encryption + granteeRecipientEncryptionPublicKey, ), ); } @@ -335,35 +336,37 @@ export class Data { return await this.delete(tableName, recordId, undefined, synchronous); } - async addWriteGrant(grantee: string, synchronous?: boolean) { + async addWriteGrant(granteeAddress: string, synchronous?: boolean) { return await this.kwilWrapper.execute( "add_write_grant", [ { - wg_grantee: grantee, + wg_grantee: granteeAddress, }, ], - `Grant ${grantee} write access to your idOS credentials`, + `Grant ${granteeAddress} write access to your idOS credentials`, synchronous, ); } - 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(grantee: string) { - return await this.kwilWrapper.call("has_write_grant_given_to", { grantee }); + async hasWriteGrantGivenTo(granteeAddress: string) { + return await this.kwilWrapper.call("has_write_grant_given_to", { grantee: granteeAddress }); } async #buildInsertableIDOSCredential( - humanId: string, + userId: string, publicNotes: string, plaintextContent: string, - receiverEncryptionPublicKey: string, + receiverEncryptionPublicKey: string | undefined, ): Promise { const issuerAuthenticationKeyPair = nacl.sign.keyPair(); + if (!receiverEncryptionPublicKey) throw new Error("Missing recipientEncryptionPublicKey"); + const { content, encryptorPublicKey } = await this.enclave.encrypt( plaintextContent, receiverEncryptionPublicKey, @@ -374,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 63420c536..cea759b8c 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 @@ -3,7 +3,7 @@ import type { idOSCredential } from "@idos-network/idos-sdk-types"; import type { BackupPasswordInfo } from "../types"; import type { - DiscoverEncryptionKeyResponse, + DiscoverUserEncryptionPublicKeyResponse, EnclaveOptions, EnclaveProvider, StoredData, @@ -33,24 +33,24 @@ export class IframeEnclave implements EnclaveProvider { } async ready( - humanId?: string, + userId?: string, signerAddress?: string, - signerPublicKey?: string, + signerEncryptionPublicKey?: string, expectedUserEncryptionPublicKey?: string, ): Promise { - let { encryptionPublicKey } = (await this.#requestToEnclave({ + let { userEncryptionPublicKey } = (await this.#requestToEnclave({ storage: { - humanId, + userId, signerAddress, - signerPublicKey, + signerEncryptionPublicKey, expectedUserEncryptionPublicKey, }, })) as StoredData; - while (!encryptionPublicKey) { + while (!userEncryptionPublicKey) { this.#showEnclave(); try { - encryptionPublicKey = (await this.#requestToEnclave({ + userEncryptionPublicKey = (await this.#requestToEnclave({ keys: {}, })) as Uint8Array; } catch (e) { @@ -60,7 +60,7 @@ export class IframeEnclave implements EnclaveProvider { } } - return encryptionPublicKey; + return userEncryptionPublicKey; } async store(key: string, value: string): Promise { @@ -239,15 +239,17 @@ export class IframeEnclave implements EnclaveProvider { } } - async discoverUserEncryptionKey(humanId: string): Promise { + async discoverUserEncryptionPublicKey( + userId: string, + ): Promise { if (this.options.mode !== "new") - throw new Error("You can only call discoverUserEncryptionKey when mode is 'new'."); + throw new Error("You can only call `discoverUserEncryptionPublicKey` when mode is `new`."); - const encryptionPublicKey = await this.ready(humanId); + const userEncryptionPublicKey = await this.ready(userId); return { - humanId, - encryptionPublicKey: base64Encode(encryptionPublicKey), + userId, + userEncryptionPublicKey: base64Encode(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 d8a838d0f..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 @@ -1,5 +1,5 @@ import type { idOSCredential } from "@idos-network/idos-sdk-types"; -import type { DiscoverEncryptionKeyResponse, EnclaveProvider, StoredData } from "./types"; +import type { DiscoverUserEncryptionPublicKeyResponse, EnclaveProvider, StoredData } from "./types"; export class MetaMaskSnapEnclave implements EnclaveProvider { // biome-ignore lint/suspicious/noExplicitAny: Types will be added later @@ -19,7 +19,7 @@ export class MetaMaskSnapEnclave implements EnclaveProvider { throw new Error("Method not implemented."); } - async discoverUserEncryptionKey(): Promise { + async discoverUserEncryptionPublicKey(): Promise { throw new Error("Method not implemented."); } @@ -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 a3909352f..19a77b040 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/types.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/types.ts @@ -2,15 +2,15 @@ import type { idOSCredential } from "@idos-network/idos-sdk-types"; import type { BackupPasswordInfo } from "../types"; export interface StoredData { - encryptionPublicKey?: Uint8Array; - humanId?: string; + userEncryptionPublicKey?: Uint8Array; + userId?: string; signerAddress?: string; - signerPublicKey?: string; + signerEncryptionPublicKey?: string; } -export interface DiscoverEncryptionKeyResponse { - humanId: string; - encryptionPublicKey: string; +export interface DiscoverUserEncryptionPublicKeyResponse { + userId: string; + userEncryptionPublicKey: string; } export interface EnclaveOptions { @@ -25,10 +25,10 @@ export interface EnclaveProvider { load(): Promise; ready( - humanId?: string, + userId?: string, signerAddress?: string, - signerPublicKey?: string, - currentUserPublicKey?: string, + signerEncryptionPublicKey?: string, + currentUserEncryptionPublicKey?: string, ): Promise; store(key: string, value: string): Promise; reset(): Promise; @@ -39,7 +39,7 @@ export interface EnclaveProvider { receiverPublicKey?: Uint8Array, ): Promise<{ content: Uint8Array; encryptorPublicKey: Uint8Array }>; decrypt(message: Uint8Array, senderPublicKey?: Uint8Array): Promise; - discoverUserEncryptionKey(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 29ab27d83..5577a381e 100644 --- a/packages/idos-sdk-js/src/lib/enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave.ts @@ -5,7 +5,7 @@ import type { EnclaveProvider } from "./enclave-providers/types"; import type { BackupPasswordInfo } from "./types"; export class Enclave { - encryptionPublicKey?: Uint8Array; + userEncryptionPublicKey?: Uint8Array; constructor( public readonly auth: Auth, @@ -17,9 +17,10 @@ export class Enclave { } async ready(): Promise { - const { humanId, address, publicKey, currentUserPublicKey } = this.auth.currentUser; + 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(); @@ -27,27 +28,29 @@ export class Enclave { await this.provider.updateStore("litAttrs", litAttrs); await this.provider.updateStore("new-user-wallets", userWallets); - if (this.encryptionPublicKey) return this.encryptionPublicKey; + if (this.userEncryptionPublicKey) return this.userEncryptionPublicKey; - this.encryptionPublicKey = await this.provider.ready( - humanId, - address, - publicKey, + this.userEncryptionPublicKey = await this.provider.ready( + userId, + userAddress, + nearWalletPublicKey, currentUserPublicKey, ); - return this.encryptionPublicKey; + return this.userEncryptionPublicKey; } async encrypt( message: string, - receiverPublicKey?: string, + recipientEncryptionPublicKey?: string, ): Promise<{ content: string; encryptorPublicKey: string }> { - if (!this.encryptionPublicKey) await this.ready(); + if (!this.userEncryptionPublicKey) await this.ready(); const { content, encryptorPublicKey } = await this.provider.encrypt( utf8Encode(message), - receiverPublicKey === undefined ? undefined : base64Decode(receiverPublicKey), + recipientEncryptionPublicKey === undefined + ? undefined + : base64Decode(recipientEncryptionPublicKey), ); return { @@ -56,13 +59,15 @@ export class Enclave { }; } - async decrypt(message: string, senderPublicKey?: string): Promise { - if (!this.encryptionPublicKey) await this.ready(); + async decrypt(message: string, senderEncryptionPublicKey?: string): Promise { + if (!this.userEncryptionPublicKey) await this.ready(); return utf8Decode( await this.provider.decrypt( base64Decode(message), - senderPublicKey === undefined ? undefined : base64Decode(senderPublicKey), + senderEncryptionPublicKey === undefined + ? undefined + : base64Decode(senderEncryptionPublicKey), ), ); } @@ -80,7 +85,7 @@ export class Enclave { } async filterCredentialsByCountries(credentials: Record[], countries: string[]) { - if (!this.encryptionPublicKey) await this.ready(); + if (!this.userEncryptionPublicKey) await this.ready(); return await this.provider.filterCredentialsByCountries(credentials, countries); } @@ -91,7 +96,7 @@ export class Enclave { omit: Record; }, ): Promise { - if (!this.encryptionPublicKey) await this.ready(); + if (!this.userEncryptionPublicKey) await this.ready(); return await this.provider.filterCredentials(credentials, privateFieldFilters); } @@ -101,7 +106,7 @@ export class Enclave { return this.provider.backupPasswordOrSecret(callbackFn); } - async discoverUserEncryptionKey(humanId: string) { - return this.provider.discoverUserEncryptionKey(humanId); + async discoverUserEncryptionPublicKey(userId: string) { + return this.provider.discoverUserEncryptionPublicKey(userId); } } diff --git a/packages/idos-sdk-js/src/lib/grants/evm.ts b/packages/idos-sdk-js/src/lib/grants/evm.ts index c3661cd97..e79e5bf87 100644 --- a/packages/idos-sdk-js/src/lib/grants/evm.ts +++ b/packages/idos-sdk-js/src/lib/grants/evm.ts @@ -403,23 +403,28 @@ export class EvmGrants implements GrantChild { } async list({ - owner = ZERO_ADDRESS, - grantee = ZERO_ADDRESS, + ownerAddress = ZERO_ADDRESS, + granteeAddress = ZERO_ADDRESS, dataId = ZERO_DATA_ID, }: Partial> = {}): Promise { - if (owner === ZERO_ADDRESS && grantee === ZERO_ADDRESS) + if (ownerAddress === ZERO_ADDRESS && granteeAddress === ZERO_ADDRESS) throw new Error("Must provide `owner` and/or `grantee`"); - const grants = await this.#contract.findGrants(owner, grantee, dataId); + const grants = await this.#contract.findGrants(ownerAddress, granteeAddress, dataId); return grants.map( - ([owner, grantee, dataId, lockedUntil]: [string, string, string, bigint]) => - new Grant({ owner, grantee, dataId, lockedUntil: Number(lockedUntil) }), + ([ownerAddress, granteeAddress, dataId, lockedUntil]: [string, string, string, bigint]) => + new Grant({ + ownerAddress, + granteeAddress, + dataId, + lockedUntil: Number(lockedUntil), + }), ); } async create({ - grantee = ZERO_ADDRESS, + granteeAddress = ZERO_ADDRESS, dataId = ZERO_DATA_ID, lockedUntil = ZERO_TIMELOCK, wait = true, @@ -427,17 +432,22 @@ export class EvmGrants implements GrantChild { grant: Grant; transactionId: string; }> { - if (grantee === ZERO_ADDRESS || dataId === ZERO_DATA_ID) { + if (granteeAddress === ZERO_ADDRESS || dataId === ZERO_DATA_ID) { throw new Error("Must provide `grantee` and `dataId`"); } - const owner = await this.signer.getAddress(); - const grant: Grant = { owner, grantee, dataId, lockedUntil }; + const ownerAddress = await this.signer.getAddress(); + const grant: Grant = { + ownerAddress, + granteeAddress, + dataId, + lockedUntil, + }; let transaction: TransactionResponse; try { transaction = (await this.#contract.insertGrant( - grantee, + granteeAddress, dataId, lockedUntil, )) as TransactionResponse; @@ -448,17 +458,22 @@ export class EvmGrants implements GrantChild { } async messageForCreateBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, }: Grant): Promise { - return await this.#contract.insertGrantBySignatureMessage(owner, grantee, dataId, lockedUntil); + return await this.#contract.insertGrantBySignatureMessage( + ownerAddress, + granteeAddress, + dataId, + lockedUntil, + ); } async createBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, @@ -467,13 +482,13 @@ export class EvmGrants implements GrantChild { grant: Grant; transactionId: string; }> { - const grant: Grant = { owner, grantee, dataId, lockedUntil }; + const grant: Grant = { ownerAddress, granteeAddress, dataId, lockedUntil }; let transaction: TransactionResponse; try { transaction = (await this.#contract.insertGrantBySignature( - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, @@ -485,25 +500,25 @@ export class EvmGrants implements GrantChild { } async revoke({ - grantee = ZERO_ADDRESS, + granteeAddress = ZERO_ADDRESS, dataId = ZERO_DATA_ID, lockedUntil = ZERO_TIMELOCK, wait = true, - }: Omit & { wait?: boolean }): Promise<{ + }: Omit & { wait?: boolean }): Promise<{ grant: Grant; transactionId: string; }> { - if (grantee === ZERO_ADDRESS || dataId === ZERO_DATA_ID) { + if (granteeAddress === ZERO_ADDRESS || dataId === ZERO_DATA_ID) { throw new Error("Must provide `grantee` and `dataId`"); } - const owner = await this.signer.getAddress(); - const grant: Grant = { owner, grantee, dataId, lockedUntil }; + const ownerAddress = await this.signer.getAddress(); + const grant: Grant = { ownerAddress, granteeAddress, dataId, lockedUntil }; let transaction: TransactionResponse; try { transaction = (await this.#contract.deleteGrant( - grantee, + granteeAddress, dataId, lockedUntil, )) as TransactionResponse; @@ -515,17 +530,22 @@ export class EvmGrants implements GrantChild { } async messageForRevokeBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, }: Grant): Promise { - return await this.#contract.deleteGrantBySignatureMessage(owner, grantee, dataId, lockedUntil); + return await this.#contract.deleteGrantBySignatureMessage( + ownerAddress, + granteeAddress, + dataId, + lockedUntil, + ); } async revokeBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, @@ -534,13 +554,13 @@ export class EvmGrants implements GrantChild { grant: Grant; transactionId: string; }> { - const grant: Grant = { owner, grantee, dataId, lockedUntil }; + const grant: Grant = { ownerAddress, granteeAddress, dataId, lockedUntil }; let transaction: TransactionResponse; try { transaction = (await this.#contract.deleteGrantBySignature( - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, diff --git a/packages/idos-sdk-js/src/lib/grants/grant-child.ts b/packages/idos-sdk-js/src/lib/grants/grant-child.ts index 16564e2f2..9d9e041b3 100644 --- a/packages/idos-sdk-js/src/lib/grants/grant-child.ts +++ b/packages/idos-sdk-js/src/lib/grants/grant-child.ts @@ -3,7 +3,7 @@ import type Grant from "./grant"; export interface GrantChild { list(_: Partial>): Promise; create( - _: Omit & { wait?: boolean }, + _: Omit & { wait?: boolean }, ): Promise<{ grant: Grant; transactionId: string }>; messageForCreateBySignature(_: Grant): Promise; createBySignature(_: Grant & { signature: Uint8Array; wait?: boolean }): Promise<{ @@ -11,7 +11,7 @@ export interface GrantChild { transactionId: string; }>; revoke( - _: Omit & { wait?: boolean }, + _: Omit & { wait?: boolean }, ): Promise<{ grant: Grant; transactionId: string }>; messageForRevokeBySignature(_: Grant): Promise; revokeBySignature(_: Grant & { signature: Uint8Array; wait?: boolean }): Promise<{ diff --git a/packages/idos-sdk-js/src/lib/grants/grant.ts b/packages/idos-sdk-js/src/lib/grants/grant.ts index 4b4428c19..64d876e91 100644 --- a/packages/idos-sdk-js/src/lib/grants/grant.ts +++ b/packages/idos-sdk-js/src/lib/grants/grant.ts @@ -1,12 +1,12 @@ export default class Grant { - owner: string; - grantee: string; + ownerAddress: string; + granteeAddress: string; dataId: string; lockedUntil: number; - constructor({ owner, grantee, dataId, lockedUntil }: Grant) { - this.owner = owner; - this.grantee = grantee; + constructor({ ownerAddress, granteeAddress, dataId, lockedUntil }: Grant) { + this.ownerAddress = ownerAddress; + this.granteeAddress = granteeAddress; this.dataId = dataId; this.lockedUntil = lockedUntil; } diff --git a/packages/idos-sdk-js/src/lib/grants/grants.ts b/packages/idos-sdk-js/src/lib/grants/grants.ts index 7ac4b6693..5a334a866 100644 --- a/packages/idos-sdk-js/src/lib/grants/grants.ts +++ b/packages/idos-sdk-js/src/lib/grants/grants.ts @@ -55,24 +55,24 @@ export class Grants { type, signer, accountId, - publicKey, + nearWalletPublicKey, }: { type: "NEAR"; signer: Wallet; accountId: string; - publicKey: string; + nearWalletPublicKey: string; }): Promise; async connect({ type, signer, accountId, - publicKey, + nearWalletPublicKey, }: { type: SignerType; signer: Wallet | Signer; accountId?: string; - publicKey?: string; + nearWalletPublicKey?: string; }): Promise { let child: EvmGrants | NearGrants; @@ -82,12 +82,13 @@ export class Grants { break; case "NEAR": if (accountId === undefined) throw new Error("accountId required for NEAR signers"); - if (publicKey === undefined) throw new Error("publicKey required for NEAR signers"); + if (nearWalletPublicKey === undefined) + throw new Error("publicKey required for NEAR signers"); child = await NearGrants.init({ accountId, signer: signer as Wallet, options: this.nearGrantsOptions, - publicKey, + nearWalletPublicKey, }); break; default: @@ -99,8 +100,8 @@ export class Grants { async list( _args: { - owner?: string; - grantee?: string; + ownerAddress?: string; + granteeAddress?: string; dataId?: string; } = {}, ): Promise { @@ -112,19 +113,19 @@ export class Grants { _recordId: string, _address: string, _lockedUntil: number, - _receiverPublicKey: string, + _receiverEncryptionPublicKey: string, ): Promise<{ grant: Grant; transactionId: string }> { - throw new Error("Call idOS.setSigner first."); + throw new Error("Call `idOS.setSigner` first."); } async revoke( _tableName: string, _recordId: string, - _grantee: string, + _granteeAddress: string, _dataId: string, _lockedUntil: number, ): Promise<{ grant: Grant; transactionId: string }> { - throw new Error("Call idOS.setSigner first."); + throw new Error("Call `idOS.setSigner` first."); } async shareMatchingEntry( @@ -134,11 +135,11 @@ export class Grants { pick: Record; omit: Record; }, - _address: string, + _granteeAddress: string, _lockedUntil: number, - _receiverPublicKey: string, + _receiverEncryptionPublicKey: string, ): Promise<{ grant: Grant; transactionId: string }> { - throw new Error("Call idOS.setSigner first."); + throw new Error("Call `idOS.setSigner` first."); } } @@ -167,14 +168,14 @@ class ConnectedGrants extends Grants { async create( tableName: string, recordId: string, - address: string, + granteeAddress: string, lockedUntil: number, - receiverPublicKey: string, + granteeEncryptionPublicKey: string, ): Promise<{ grant: Grant; transactionId: string }> { - const share = await this.data.share(tableName, recordId, receiverPublicKey); + const share = await this.data.share(tableName, recordId, granteeEncryptionPublicKey); return await this.#child.create({ - grantee: address, + granteeAddress, dataId: share.id, lockedUntil: lockedUntil, }); @@ -187,9 +188,9 @@ class ConnectedGrants extends Grants { pick: Record; omit: Record; }, - address: string, + granteeAddress: string, lockedUntil: number, - receiverPublicKey: string, + receiverEncryptionPublicKey: string, ): Promise<{ grant: Grant; transactionId: string }> { const allEntries = (await this.data.list(tableName)) as unknown as idOSCredential[]; @@ -225,10 +226,14 @@ class ConnectedGrants extends Grants { if (!eligibleEntries.length) throw new Error("No matching credentials"); const selectedEntry = eligibleEntries[0]; - const { id: dataId } = await this.data.share(tableName, selectedEntry.id, receiverPublicKey); + const { id: dataId } = await this.data.share( + tableName, + selectedEntry.id, + receiverEncryptionPublicKey, + ); return await this.#child.create({ - grantee: address, + granteeAddress, dataId, lockedUntil, }); @@ -237,13 +242,13 @@ class ConnectedGrants extends Grants { async revoke( tableName: string, recordId: string, - grantee: string, + granteeAddress: string, dataId: string, lockedUntil: number, ): Promise<{ grant: Grant; transactionId: string }> { await this.data.unshare(tableName, recordId); - return this.#child.revoke({ grantee, dataId, lockedUntil }); + return this.#child.revoke({ granteeAddress, dataId, lockedUntil }); } async messageForCreateBySignature(grant: Grant) { diff --git a/packages/idos-sdk-js/src/lib/grants/near.ts b/packages/idos-sdk-js/src/lib/grants/near.ts index 8181edb2e..4f2e1a40c 100644 --- a/packages/idos-sdk-js/src/lib/grants/near.ts +++ b/packages/idos-sdk-js/src/lib/grants/near.ts @@ -50,12 +50,12 @@ export class NearGrants implements GrantChild { accountId, signer, options, - publicKey, + nearWalletPublicKey, }: { accountId: string; signer: Wallet; options: NearGrantsOptions; - publicKey: string; + nearWalletPublicKey: string; }): Promise { let near_api: { Contract: typeof Contract; @@ -95,7 +95,7 @@ export class NearGrants implements GrantChild { // biome-ignore lint/suspicious/noExplicitAny: fix `useLocalViewExecution` is not in types. } as any, ), - publicKey, + nearWalletPublicKey, ); } @@ -107,8 +107,8 @@ export class NearGrants implements GrantChild { return { grant: { - owner: grant.owner, - grantee: grant.grantee, + ownerAddress: grant.owner, + granteeAddress: grant.grantee, lockedUntil: grant.locked_until, dataId: grant.data_id, }, @@ -141,8 +141,8 @@ export class NearGrants implements GrantChild { } async list({ - owner, - grantee, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, }: Partial> = {}): Promise { if (!(owner || grantee)) throw new Error("Must provide `owner` and/or `grantee`"); @@ -159,9 +159,11 @@ export class NearGrants implements GrantChild { ) => Promise; return (await method(grantsFilter)).map( - ({ data_id, locked_until, ...values }) => + ({ data_id, locked_until, owner, grantee, ...values }) => new Grant({ ...values, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, lockedUntil: locked_until / 1e6, }), @@ -173,16 +175,19 @@ export class NearGrants implements GrantChild { /// NOTE: NEAR is problematic for the current implementation. The only way to create an AG in the contract if to /// create an dAG for yourself. async create({ - grantee, + granteeAddress, dataId, lockedUntil, - }: Omit & { wait?: boolean }): Promise<{ grant: Grant; transactionId: string }> { - const owner = this.#publicKey; + }: Omit & { wait?: boolean }): Promise<{ + grant: Grant; + transactionId: string; + }> { + const ownerAddress = this.#publicKey; const recipient = await this.messageRecipient(); const message = await this.messageForCreateBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, }); @@ -190,8 +195,8 @@ export class NearGrants implements GrantChild { const { nonce, signature } = await this.#sign(message, recipient); return this.createBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, @@ -209,8 +214,8 @@ export class NearGrants implements GrantChild { } async messageForCreateBySignature({ - owner, - grantee, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, lockedUntil, }: Grant): Promise { @@ -230,8 +235,8 @@ export class NearGrants implements GrantChild { } async createBySignature({ - owner, - grantee, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, lockedUntil, signature, @@ -282,16 +287,19 @@ export class NearGrants implements GrantChild { /// NOTE: NEAR is problematic for the current implementation. The only way to revoke an AG in the contract if to /// create an dAG for yourself. async revoke({ - grantee, + granteeAddress, dataId, lockedUntil, - }: Omit & { wait?: boolean }): Promise<{ grant: Grant; transactionId: string }> { - const owner = this.#publicKey; + }: Omit & { wait?: boolean }): Promise<{ + grant: Grant; + transactionId: string; + }> { + const ownerAddress = this.#publicKey; const recipient = await this.messageRecipient(); const message = await this.messageForRevokeBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, }); @@ -299,8 +307,8 @@ export class NearGrants implements GrantChild { const { nonce, signature } = await this.#sign(message, recipient); return this.revokeBySignature({ - owner, - grantee, + ownerAddress, + granteeAddress, dataId, lockedUntil, signature, @@ -309,8 +317,8 @@ export class NearGrants implements GrantChild { } async messageForRevokeBySignature({ - owner, - grantee, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, lockedUntil, }: Grant): Promise { @@ -330,8 +338,8 @@ export class NearGrants implements GrantChild { } async revokeBySignature({ - owner, - grantee, + ownerAddress: owner, + granteeAddress: grantee, dataId: data_id, lockedUntil, signature, diff --git a/packages/idos-sdk-js/src/lib/idos.ts b/packages/idos-sdk-js/src/lib/idos.ts index 47b7c5af0..79f4a92a0 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"; @@ -82,10 +82,9 @@ export class idOS { const currentUser = this.auth.currentUser; this.grants = await this.grants.connect({ type, - accountId: currentUser.address, + accountId: currentUser.userAddress, signer: signer as Wallet, - // biome-ignore lint/style/noNonNullAssertion: we put it there when we're using NEAR. - publicKey: currentUser.publicKey!, + nearWalletPublicKey: currentUser.nearWalletPublicKey ?? "", }); return currentUser; @@ -102,8 +101,8 @@ export class idOS { return assertNever(type, `Signer type "${type}" not recognized`); } - async hasProfile(address: string): Promise { - return this.kwilWrapper.hasProfile(address); + async hasProfile(userAddress: string): Promise { + return this.kwilWrapper.hasProfile(userAddress); } async reset({ enclave = false } = {}): Promise { @@ -116,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 { @@ -126,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: @@ -135,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) => { @@ -224,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, @@ -234,7 +233,7 @@ export class idOS { }); } - async discoverEncryptionKey(humanId: string) { - return this.enclave.discoverUserEncryptionKey(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 0ffbf5bf1..ae256c97f 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,29 +128,34 @@ 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(address: string): Promise { + async hasProfile(userAddress: string): Promise { // biome-ignore lint/suspicious/noExplicitAny: TBD - const result = (await this.call("has_profile", { address }, undefined, false)) as any; + const result = (await this.call( + "has_profile", + { address: userAddress }, + undefined, + false, + )) as any; return !!result[0]?.has_profile; } 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 bde8de9bd..6d14e5f19 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.discoverEncryptionKey` 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.discoverEncryptionKey(humanId); +const { userEncryptionPublicKey } = await idos.discoverUserEncryptionPublicKey(userId); // Report it back to your server -await yourServer.reportIdosEncryptionPublicKey(encryptionPublicKey); +await yourServer.reportIdosEncryptionPublicKey(userEncryptionPublicKey); ``` -#### 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 5b9fd1a97..797854eef 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 5fa57b244..6a82786ea 100644 --- a/packages/issuer-sdk-js/src/credentials.ts +++ b/packages/issuer-sdk-js/src/credentials.ts @@ -31,12 +31,12 @@ type InsertableIDOSCredential = Omit & { const buildInsertableIDOSCredential = ( issuerConfig: IssuerConfig, { - humanId, + userId, publicNotes, plaintextContent, receiverEncryptionPublicKey, }: { - humanId: string; + userId: string; publicNotes: string; plaintextContent: Uint8Array; receiverEncryptionPublicKey: Uint8Array; @@ -52,7 +52,7 @@ const buildInsertableIDOSCredential = ( }); return { - human_id: humanId, + user_id: userId, content: base64Encode(content), public_notes, @@ -72,7 +72,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 e2be9995e..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; @@ -16,15 +16,15 @@ export interface idOSCredential { } export interface idOSGrant { - owner: string; - grantee: string; + ownerAddress: string; + granteeAddress: string; dataId: string; lockedUntil: number; } 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; }