WeSDK - The SDK Noone Asked For

API: Storage

Storage APIs provide key-value persistence via host environment storage.

Methods

All return:

Promise<CallbackPayload>;

setStorage

await sdk.setStorage({ key: "session", data: { token: "abc" } });

getStorage

const res = await sdk.getStorage({ key: "session" });
console.log(res.data);

removeStorage

await sdk.removeStorage({ key: "session" });

clearStorage

await sdk.clearStorage();

getStorageInfo

const info = await sdk.getStorageInfo();
console.log(info.keys, info.currentSize, info.limitSize);

Response Notes

v2 responses include normalized metadata (errMsg, __method, __status) in addition to method-specific fields.

Error Handling Pattern

try {
	const result = await sdk.getStorage({ key: "profile" });
	useProfile(result.data);
} catch (err) {
	if (err.code === "ENV_UNSUPPORTED") {
		useProfileFromLocalFallback();
	}
}

Migration Notes

Legacy field usage (res.data) remains valid; v2 adds predictable normalized wrappers.