Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions docs/src/content/docs/reference/sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,25 @@ function getSecure(key: string): Promise<string>;

**Returns:** `Promise<string>` — the decrypted value.

**Throws:** `REPError` if the session key endpoint is unreachable, the key has expired, or decryption fails.
**Throws:** `REPError` in the following cases:
- The requested key does not exist in the sensitive payload
- The session key endpoint is unreachable or returns a non-2xx status
- The session key has expired (30s TTL)
- Decryption fails (corrupted payload or mismatched key)

Always wrap `getSecure()` in a try/catch:

```typescript
const key = await rep.getSecure('ANALYTICS_KEY');
import { rep, REPError } from '@rep-protocol/sdk';

try {
const analyticsKey = await rep.getSecure('ANALYTICS_KEY');
} catch (err) {
if (err instanceof REPError) {
// Key not found, endpoint unreachable, or decryption failed.
console.error(err.message);
}
}
```

<Aside>
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface SessionKeyResponse {
type ChangeCallback = (newValue: string, oldValue: string | undefined) => void;
type AnyChangeCallback = (key: string, newValue: string, oldValue: string | undefined) => void;

class REPError extends Error {
export class REPError extends Error {
constructor(message: string) {
super(`[REP] ${message}`);
this.name = 'REPError';
Expand Down
Loading