The user's session keypair for authentication
The binary file submission data containing encryption key, file metadata, and storage URL
The Welshare API environment (name or config object)
The application ID (reserved for future use)
Promise containing insertedUid (the Nillion document ID)
import { WelshareApi, resolveEnvironment, Keypair } from "@welshare/sdk";
const { insertedUid } = await WelshareApi.submitBinaryData(
keypair,
{
encryption_key: JSON.stringify({ algorithm: "AES-GCM", key: "...", iv: "..." }),
reference: "questionnaire/abc-123/photo",
file_name: "profile.jpg",
file_size: 102400,
file_type: "image/jpeg",
controller_did: Keypair.keypairKeyDid(keypair).didString, //Nillion 2.0 requires did:key as a method
url: `welshare://${uploadKey}`,
},
"production",
"my-app-id"
);
Side effects:
fetchDelegation() to obtain a NUC delegation from the Welshare APIThe encryption key is stored with %allot modifier, making it secret-shared
and only accessible to authorized parties.
Submit binary file metadata to Nillion storage.
This function stores encrypted file metadata in Nillion, granting the builder read/execute access to the data. The actual encrypted file should be uploaded separately to S3 using
fetchS3WriteDelegation.