Skip to content

Commit

Permalink
fix(app-ws): bring back cap_secret as zome call param (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: Jost Schulte <[email protected]>
  • Loading branch information
jost-s and jost-s authored Nov 21, 2024
1 parent 84d61b7 commit 7f5a036
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 23 deletions.
4 changes: 2 additions & 2 deletions docs/client.appcallzomerequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
**Signature:**

```typescript
export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequest;
export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequest | CallZomeRequestAllParams;
```
**References:** [NonProvenanceCallZomeRequest](./client.nonprovenancecallzomerequest.md)<!-- -->, [RoleNameCallZomeRequest](./client.rolenamecallzomerequest.md)<!-- -->, [CallZomeRequest](./client.callzomerequest.md)
**References:** [NonProvenanceCallZomeRequest](./client.nonprovenancecallzomerequest.md)<!-- -->, [RoleNameCallZomeRequest](./client.rolenamecallzomerequest.md)<!-- -->, [CallZomeRequest](./client.callzomerequest.md)<!-- -->, [CallZomeRequestAllParams](./client.callzomerequestallparams.md)

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestParams](./client.callzomerequestparams.md) &gt; [cap\_secret](./client.callzomerequestparams.cap_secret.md)
[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestAllParams](./client.callzomerequestallparams.md) &gt; [cap\_secret](./client.callzomerequestallparams.cap_secret.md)

## CallZomeRequestParams.cap\_secret property
## CallZomeRequestAllParams.cap\_secret property

**Signature:**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestParams](./client.callzomerequestparams.md) &gt; [expires\_at](./client.callzomerequestparams.expires_at.md)
[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestAllParams](./client.callzomerequestallparams.md) &gt; [expires\_at](./client.callzomerequestallparams.expires_at.md)

## CallZomeRequestParams.expires\_at property
## CallZomeRequestAllParams.expires\_at property

**Signature:**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestParams](./client.callzomerequestparams.md)
[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestAllParams](./client.callzomerequestallparams.md)

## CallZomeRequestParams interface
## CallZomeRequestAllParams interface


**Signature:**

```typescript
export interface CallZomeRequestParams extends CallZomeRequest
export interface CallZomeRequestAllParams extends CallZomeRequest
```
**Extends:** [CallZomeRequest](./client.callzomerequest.md)
Expand Down Expand Up @@ -37,7 +37,7 @@ Description
</th></tr></thead>
<tbody><tr><td>
[cap\_secret](./client.callzomerequestparams.cap_secret.md)
[cap\_secret](./client.callzomerequestallparams.cap_secret.md)
</td><td>
Expand All @@ -54,7 +54,7 @@ Description
</td></tr>
<tr><td>
[expires\_at](./client.callzomerequestparams.expires_at.md)
[expires\_at](./client.callzomerequestallparams.expires_at.md)
</td><td>
Expand All @@ -71,7 +71,7 @@ number
</td></tr>
<tr><td>
[nonce](./client.callzomerequestparams.nonce.md)
[nonce](./client.callzomerequestallparams.nonce.md)
</td><td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestParams](./client.callzomerequestparams.md) &gt; [nonce](./client.callzomerequestparams.nonce.md)
[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [CallZomeRequestAllParams](./client.callzomerequestallparams.md) &gt; [nonce](./client.callzomerequestallparams.nonce.md)

## CallZomeRequestParams.nonce property
## CallZomeRequestAllParams.nonce property

**Signature:**

Expand Down
2 changes: 1 addition & 1 deletion docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ Description
</td></tr>
<tr><td>

[CallZomeRequestParams](./client.callzomerequestparams.md)
[CallZomeRequestAllParams](./client.callzomerequestallparams.md)


</td><td>
Expand Down
5 changes: 3 additions & 2 deletions src/api/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export type RoleNameCallZomeRequestSigned = Omit<
export type AppCallZomeRequest =
| NonProvenanceCallZomeRequest
| RoleNameCallZomeRequest
| CallZomeRequest;
| CallZomeRequest
| CallZomeRequestAllParams;

/**
* @public
Expand Down Expand Up @@ -90,7 +91,7 @@ export interface AppEvents {
/**
* @public
*/
export interface CallZomeRequestParams extends CallZomeRequest {
export interface CallZomeRequestAllParams extends CallZomeRequest {
cap_secret: CapSecret | null;
nonce: Nonce256Bit;
expires_at: number;
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
SignalCb,
CallZomeRequest,
CallZomeRequestSigned,
CallZomeRequestParams,
CallZomeRequestAllParams,
CallZomeResponse,
CallZomeResponseGeneric,
CreateCloneCellRequest,
Expand Down Expand Up @@ -603,7 +603,7 @@ export const signZomeCall = async (request: CallZomeRequest) => {
)}, ${encodeHashToBase64(request.cell_id[1])}]`
);
}
const unsignedZomeCallPayload: CallZomeRequestParams = {
const unsignedZomeCallPayload: CallZomeRequestAllParams = {
cap_secret: signingCredentialsForCell.capSecret,
cell_id: request.cell_id,
zome_name: request.zome_name,
Expand Down
7 changes: 5 additions & 2 deletions src/environments/launcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { AppAuthenticationToken, CallZomeRequest } from "../api/index.js";
import { CallZomeRequestSigned, CallZomeRequestParams } from "../api/index.js";
import {
CallZomeRequestSigned,
CallZomeRequestAllParams,
} from "../api/index.js";
import { InstalledAppId } from "../types.js";

export interface LauncherEnvironment {
Expand Down Expand Up @@ -58,7 +61,7 @@ interface CallZomeRequestSignedElectron

interface CallZomeRequestUnsignedElectron
extends Omit<
CallZomeRequestParams,
CallZomeRequestAllParams,
| "cap_secret"
| "cell_id"
| "provenance"
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/app-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import test from "tape";
import {
AdminWebsocket,
AppCallZomeRequest,
AppWebsocket,
AppCreateCloneCellRequest,
AppEntryDef,
AppSignal,
AppWebsocket,
CellType,
CloneId,
fakeAgentPubKey,
Expand Down
39 changes: 39 additions & 0 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import {
SignalType,
Signal,
isSameCell,
CallZomeRequestAllParams,
getSigningCredentials,
randomNonce,
getNonceExpiration,
} from "../../src";
import {
FIXTURE_PATH,
Expand Down Expand Up @@ -402,6 +406,41 @@ test(
})
);

test(
"can call a zome function with different sets of params",
withConductor(ADMIN_PORT, async (t) => {
const { cell_id, client, admin } = await installAppAndDna(ADMIN_PORT);
await admin.authorizeSigningCredentials(cell_id);

const request: CallZomeRequest = {
cell_id,
zome_name: TEST_ZOME_NAME,
fn_name: "foo",
provenance: cell_id[1],
payload: null,
};
let response = await client.callZome(request, 30000);
t.equal(response, "foo", "zome can be called with all parameters");

const cap_secret = getSigningCredentials(cell_id)?.capSecret;
assert(cap_secret);

const zomeCallPayload: CallZomeRequestAllParams = {
cell_id,
zome_name: TEST_ZOME_NAME,
fn_name: "foo",
provenance: cell_id[1],
payload: null,
cap_secret,
nonce: await randomNonce(),
expires_at: getNonceExpiration(),
};

response = await client.callZome(zomeCallPayload, 30000);
t.equal(response, "foo", "zome can be called with all parameters");
})
);

test(
"can call attachAppInterface without specific port",
withConductor(ADMIN_PORT, async (t) => {
Expand Down

0 comments on commit 7f5a036

Please sign in to comment.