SecureStore API
암호화된 로컬 저장소 API예요. storage와 동일한 인터페이스를 제공하지만, 데이터가 암호화되어 저장돼요.
Methods
get
지정된 키에 해당하는 값을 조회해요.
ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';
const value = await posPluginSdk.secureStore.get('key');Parameters
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | O | 조회할 데이터의 키 |
Response
Promise<string | undefined> — 저장된 값이에요. 키가 없으면 undefined를 반환해요.
set
지정된 키에 값을 저장해요.
ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';
await posPluginSdk.secureStore.set('key', 'value');Parameters
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | O | 저장할 데이터의 키 |
value | string | O | 저장할 값. 문자열만 저장할 수 있어요 |
Response
반환값이 없어요.
del
지정된 키에 해당하는 값을 삭제해요.
ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';
await posPluginSdk.secureStore.del('key');Parameters
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | O | 삭제할 데이터의 키 |
Response
반환값이 없어요.
사용 예시
API 키 관리
ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';
const API_KEY = 'api_key';
async function saveApiKey(apiKey: string) {
await posPluginSdk.secureStore.set(API_KEY, apiKey);
}
async function getApiKey(): Promise<string | undefined> {
return await posPluginSdk.secureStore.get(API_KEY);
}
async function removeApiKey() {
await posPluginSdk.secureStore.del(API_KEY);
}