Skip to content

Commit

Permalink
working build
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed Nov 9, 2023
1 parent ccbe67f commit 4a9ecc4
Show file tree
Hide file tree
Showing 25 changed files with 3,113 additions and 124 deletions.
8 changes: 4 additions & 4 deletions demos/sample-javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dfinity/ic-agent-sample-javascript-app",
"private": true,
"version": "0.19.3",
"version": "0.19.3-react-native",
"scripts": {
"build": "webpack",
"develop": "webpack-dev-server",
Expand All @@ -10,9 +10,9 @@
"test": ""
},
"dependencies": {
"@dfinity/agent": "^0.19.3",
"@dfinity/identity": "^0.19.3",
"@dfinity/principal": "^0.19.3"
"@dfinity/agent": "^0.19.3-react-native",
"@dfinity/identity": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native"
},
"devDependencies": {
"assert": "^2.0.0",
Expand Down
8 changes: 4 additions & 4 deletions e2e/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@do-not-publish/ic-cypress-e2e-tests",
"version": "0.19.3",
"version": "0.19.3-react-native",
"scripts": {
"ci": "npm run e2e",
"setup": "dfx deploy; dfx generate; pm2 --name parcel start npm -- start",
Expand All @@ -27,9 +27,9 @@
"size-limit": "^8.1.0"
},
"dependencies": {
"@dfinity/agent": "^0.19.3",
"@dfinity/identity": "^0.19.3",
"@dfinity/principal": "^0.19.3",
"@dfinity/agent": "^0.19.3-react-native",
"@dfinity/identity": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native",
"idb-keyval": "^6.2.0"
}
}
10 changes: 5 additions & 5 deletions e2e/node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@do-not-publish/ic-node-e2e-tests",
"version": "0.19.3",
"version": "0.19.3-react-native",
"scripts": {
"ci": "npm run e2e",
"e2e": "vitest",
Expand All @@ -15,10 +15,10 @@
"test": ""
},
"dependencies": {
"@dfinity/agent": "^0.19.3",
"@dfinity/assets": "^0.19.3",
"@dfinity/identity": "^0.19.3",
"@dfinity/principal": "^0.19.3",
"@dfinity/agent": "^0.19.3-react-native",
"@dfinity/assets": "^0.19.3-react-native",
"@dfinity/identity": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native",
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/agent-monorepo",
"version": "0.19.3",
"version": "0.19.3-react-native",
"private": true,
"description": "Use an Agent to interact with the Internet Computer from your JavaScript program.",
"workspaces": {
Expand Down
8 changes: 5 additions & 3 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/agent",
"version": "0.19.3",
"version": "0.19.3-react-native",
"author": "DFINITY Stiftung <[email protected]>",
"license": "Apache-2.0",
"description": "JavaScript and TypeScript library to interact with the Internet Computer",
Expand Down Expand Up @@ -49,8 +49,10 @@
"tslint": "tslint --project tsconfig.json --config tslint.json"
},
"peerDependencies": {
"@dfinity/candid": "^0.19.3",
"@dfinity/principal": "^0.19.3"
"@dfinity/candid": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native",
"@dfinity/bls-verify": "0.19.3-react-native",
"@noble/curves": "file:noble-curves-1.2.0.tgz"
},
"dependencies": {
"@noble/curves": "^1.2.0",
Expand Down
17 changes: 3 additions & 14 deletions packages/agent/src/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { pollForResponse, PollStrategyFactory, strategy } from './polling';
import { Principal } from '@dfinity/principal';
import { RequestId } from './request_id';
import { toHex } from './utils/buffer';
import { CreateCertificateOptions } from './certificate';
import managementCanisterIdl from './canisters/management_idl';
import _SERVICE from './canisters/management_service';

Expand Down Expand Up @@ -130,11 +129,6 @@ export interface ActorConfig extends CallConfig {
args: unknown[],
callConfig: CallConfig,
): Partial<CallConfig> | void;

/**
* Polyfill for BLS Certificate verification in case wasm is not supported
*/
blsVerify?: CreateCertificateOptions['blsVerify'];
}

// TODO: move this to proper typing when Candid support TypeScript.
Expand Down Expand Up @@ -308,7 +302,7 @@ export class Actor {
func.annotations.push(ACTOR_METHOD_WITH_HTTP_DETAILS);
}

this[methodName] = _createActorMethod(this, methodName, func, config.blsVerify);
this[methodName] = _createActorMethod(this, methodName, func);
}
}
}
Expand Down Expand Up @@ -369,12 +363,7 @@ export type ActorConstructor = new (config: ActorConfig) => ActorSubclass;

export const ACTOR_METHOD_WITH_HTTP_DETAILS = 'http-details';

function _createActorMethod(
actor: Actor,
methodName: string,
func: IDL.FuncClass,
blsVerify?: CreateCertificateOptions['blsVerify'],
): ActorMethod {
function _createActorMethod(actor: Actor, methodName: string, func: IDL.FuncClass): ActorMethod {
let caller: (options: CallConfig, ...args: unknown[]) => Promise<unknown>;
if (func.annotations.includes('query') || func.annotations.includes('composite_query')) {
caller = async (options, ...args) => {
Expand Down Expand Up @@ -437,7 +426,7 @@ function _createActorMethod(
}

const pollStrategy = pollingStrategyFactory();
const responseBytes = await pollForResponse(agent, ecid, requestId, pollStrategy, blsVerify);
const responseBytes = await pollForResponse(agent, ecid, requestId, pollStrategy);
const shouldIncludeHttpDetails = func.annotations.includes(ACTOR_METHOD_WITH_HTTP_DETAILS);

if (responseBytes !== undefined) {
Expand Down
1 change: 0 additions & 1 deletion packages/agent/src/canisterStatus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export type CanisterStatusOptions = {
canisterId: Principal;
agent: HttpAgent;
paths?: Path[] | Set<Path>;
blsVerify?: CreateCertificateOptions['blsVerify'];
};

/**
Expand Down
12 changes: 2 additions & 10 deletions packages/agent/src/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AgentError } from './errors';
import { hash } from './request_id';
import { concat, fromHex, toHex } from './utils/buffer';
import { Principal } from '@dfinity/principal';
import * as bls from './utils/bls';
import { blsVerify } from '@dfinity/bls-verify';
import { decodeTime } from './utils/leb';

/**
Expand Down Expand Up @@ -170,15 +170,10 @@ export class Certificate {
* @throws {CertificateVerificationError}
*/
public static async create(options: CreateCertificateOptions): Promise<Certificate> {
let blsVerify = options.blsVerify;
if (!blsVerify) {
blsVerify = bls.blsVerify;
}
const cert = new Certificate(
options.certificate,
options.rootKey,
options.canisterId,
blsVerify,
options.maxAgeInMinutes,
);

Expand All @@ -190,8 +185,6 @@ export class Certificate {
certificate: ArrayBuffer,
private _rootKey: ArrayBuffer,
private _canisterId: Principal,
private _blsVerify: VerifyFunc,
// Default to 5 minutes
private _maxAgeInMinutes: number = 5,
) {
this.cert = cbor.decode(new Uint8Array(certificate));
Expand Down Expand Up @@ -245,7 +238,7 @@ export class Certificate {
}

try {
sigVer = await this._blsVerify(new Uint8Array(key), new Uint8Array(sig), new Uint8Array(msg));
sigVer = await blsVerify(new Uint8Array(key), new Uint8Array(sig), new Uint8Array(msg));
} catch (err) {
sigVer = false;
}
Expand All @@ -263,7 +256,6 @@ export class Certificate {
certificate: d.certificate,
rootKey: this._rootKey,
canisterId: this._canisterId,
blsVerify: this._blsVerify,
// Do not check max age for delegation certificates
maxAgeInMinutes: Infinity,
});
Expand Down
1 change: 0 additions & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from './der';
export * from './fetch_candid';
export * from './public_key';
export * from './request_id';
export * from './utils/bls';
export * from './utils/buffer';
export * from './utils/random';
export * as polling from './polling';
Expand Down
2 changes: 0 additions & 2 deletions packages/agent/src/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function pollForResponse(
strategy: PollStrategy,
// eslint-disable-next-line
request?: any,
blsVerify?: CreateCertificateOptions['blsVerify'],
): Promise<ArrayBuffer> {
const path = [new TextEncoder().encode('request_status'), requestId];
const currentRequest = request ?? (await agent.createReadStateRequest?.({ paths: [path] }));
Expand All @@ -39,7 +38,6 @@ export async function pollForResponse(
certificate: state.certificate,
rootKey: agent.rootKey,
canisterId: canisterId,
blsVerify,
});
const maybeBuf = cert.lookup([...path, new TextEncoder().encode('status')]);
let status;
Expand Down
21 changes: 0 additions & 21 deletions packages/agent/src/utils/bls.test.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/agent/src/utils/bls.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/assets",
"version": "0.19.3",
"version": "0.19.3-react-native",
"author": "DFINITY Stiftung <[email protected]>",
"license": "Apache-2.0",
"description": "JavaScript and TypeScript library to manage assets on the Internet Computer",
Expand Down Expand Up @@ -49,8 +49,8 @@
"test:coverage": "jest --verbose --collectCoverage"
},
"peerDependencies": {
"@dfinity/agent": "^0.19.3",
"@dfinity/principal": "^0.19.3",
"@dfinity/agent": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native",
"@noble/hashes": "^1.3.1"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/auth-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/auth-client",
"version": "0.19.3",
"version": "0.19.3-react-native",
"author": "DFINITY Stiftung <[email protected]>",
"license": "Apache-2.0",
"description": "JavaScript and TypeScript library to provide a simple integration with an IC Internet Identity",
Expand Down Expand Up @@ -46,9 +46,9 @@
"test:coverage": "jest --verbose --collectCoverage"
},
"peerDependencies": {
"@dfinity/agent": "^0.19.3",
"@dfinity/identity": "^0.19.3",
"@dfinity/principal": "^0.19.3"
"@dfinity/agent": "^0.19.3-react-native",
"@dfinity/identity": "^0.19.3-react-native",
"@dfinity/principal": "^0.19.3-react-native"
},
"dependencies": {
"idb": "^7.0.2"
Expand Down
7 changes: 0 additions & 7 deletions packages/bls-verify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ npm i --save @dfinity/bls-verify

```ts
import { blsVerify } from '@dfinity/bls-verify';
import { createActor, canisterId } from '../declarations/example';

const exampleActor = createActor(canisterId, {
actorOptions: {
blsVerify,
},
});
```
3 changes: 1 addition & 2 deletions packages/bls-verify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/bls-verify",
"version": "0.19.3",
"version": "0.19.3-react-native",
"author": "DFINITY Stiftung <[email protected]>",
"license": "Apache-2.0",
"description": "bls verification strategy in JavaScript",
Expand All @@ -13,7 +13,6 @@
"bugs": {
"url": "https://github.com/dfinity/agent-js/issues"
},
"type": "module",
"keywords": [
"internet computer",
"ic",
Expand Down
1 change: 0 additions & 1 deletion packages/bls-verify/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ test('delegation works for canisters within the subnet range', async () => {
certificate: fromHex(SAMPLE_CERT),
rootKey: fromHex(IC_ROOT_KEY),
canisterId: canisterId,
blsVerify,
}),
).resolves.not.toThrow();
}
Expand Down
6 changes: 3 additions & 3 deletions packages/bls-verify/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { toHex } from './utils';
import { bls12_381 as bls } from '@noble/curves/bls12-381';

export const blsVerify = async (
primaryKey: Uint8Array | string,
signature: Uint8Array | string,
message: Uint8Array | string,
): Promise<boolean> => {
const { verifyShortSignature } = (await import('./verifyShortSignature')).default() as any;

const pk = typeof primaryKey === 'string' ? primaryKey : toHex(primaryKey);
const sig = typeof signature === 'string' ? signature : toHex(signature);
const msg = typeof message === 'string' ? message : toHex(message);
return bls.verifyShortSignature(sig, msg, pk);
return verifyShortSignature(sig, msg, pk);
};
Loading

0 comments on commit 4a9ecc4

Please sign in to comment.