Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add updateSafeSession #310

Merged
merged 1 commit into from
Dec 7, 2023
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
13 changes: 12 additions & 1 deletion src/client/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosInstance } from 'axios';
import { AppResponse, AppPropertyResponse, AppRequest, AppSecretResponse, AppSessionResponse } from './types/app';
import { AppResponse, AppPropertyResponse, AppRequest, AppSecretResponse, AppSessionResponse, AppSafeSessionRequest } from './types/app';
import { buildClient } from './utils/client';

// TODO add app api for developer document
Expand Down Expand Up @@ -51,6 +51,17 @@ export const AppKeystoreClient = (axiosInstance: AxiosInstance) => ({
return axiosInstance.post<unknown, AppSessionResponse>(`/apps/${appID}/session`, data);
},

/**
* Get a new app session
* `public_hex` and `signature` are required to upgrade to tip and register to safe if `has_tip` of the app is false
* the spend private key would be same as the tip private key
* @param session_secret: public key of ed25519 session keys
* @param public_hex: public key of ed25519 tip/spend keys
* @param signature: signature of the SHA256Hash of the app_id using ed25519 tip/spend private key
*/
updateSafeSession: (appID: string, data: AppSafeSessionRequest): Promise<AppSessionResponse> =>
axiosInstance.post<unknown, AppSessionResponse>(`/safe/apps/${appID}/session`, data),

/**
* Add to your share list
* User can have up to 3 favorite apps
Expand Down
6 changes: 6 additions & 0 deletions src/client/types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ export interface AppRequest {
capabilities: string[];
resource_patterns: string[];
}

export interface AppSafeSessionRequest {
public_hex?: string;
signature?: string;
session_secret: string;
}