Skip to content

Commit

Permalink
Use commonjs module support (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundthmcalculus committed Jul 8, 2022
1 parent 63b4216 commit 31fde3b
Show file tree
Hide file tree
Showing 23 changed files with 620 additions and 2,678 deletions.
4 changes: 2 additions & 2 deletions python/samples/credential_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def credential_demo():
)
# }
valid = verify_result.is_valid
print(f"Verification result: {valid}")
assert valid is True
print(f"Verification result: {verify_result}")
assert verify_result.validation_results['SignatureVerification'].is_valid


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions samples/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ async function vaccineDemo() {

// @ts-ignore
trinsic.options.authToken = clinic;
const info = await trinsic.account().info();
const info = await trinsic.account().getInfo();
console.log(info)

// Sign a credential as the clinic and send it to Allison
const credentialJson = getVaccineCertUnsignedJSON()
const credential = await trinsic.credential().issueCredential({documentJson: JSON.stringify(credentialJson)});
const credential = await trinsic.credential().issue({documentJson: JSON.stringify(credentialJson)});

// Alice stores the credential in her cloud wallet.
// @ts-ignore
Expand Down
1,779 changes: 251 additions & 1,528 deletions samples/node/package-lock.json

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions samples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "1.0.0",
"description": "Trinsic production test sample of node",
"main": "index.ts",
"type": "module",
"scripts": {
"main": "node --loader ts-node/esm ./index.ts"
"main": "npx ts-node ./index.ts"
},
"repository": {
"type": "git",
Expand All @@ -18,12 +17,9 @@
},
"homepage": "https://github.com/trinsic-id/sdk#readme",
"dependencies": {
"@trinsic/trinsic": "^1.6.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
"@trinsic/trinsic": "1.6.1-rc2"
},
"devDependencies": {
"@types/node": "^17.0.45",
"tslib": "^2.4.0"
"ts-node": "^10.8.2"
}
}
2 changes: 1 addition & 1 deletion samples/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2017",
"module": "ES2022",
"module": "commonjs",
"composite": true,
"outDir": "dist",
"sourceMap": true,
Expand Down
12 changes: 6 additions & 6 deletions web/.config/karma.conf.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// const webpackConfig = require("./webpack.config.js");
const {resolve} = require("path");
const {SourceMapDevToolPlugin, ProvidePlugin} = require("webpack");
const {SourceMapDevToolPlugin, ProvidePlugin, IgnorePlugin} = require("webpack");
const path = require("path");
module.exports = async (config) => {
config.set({
Expand Down Expand Up @@ -58,30 +58,29 @@ module.exports = async (config) => {
webpack: {
mode: "development",
devtool: "inline-source-map",
entry: {
wallet: "../test/web.spec.ts",
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "ts-loader",
options: {
configFile: 'tsconfig.json'
configFile: 'tsconfig.web.json'
}
}
],
},
resolve: {
alias: {
["@trinsic-id/okapi-node"]: "@trinsic-id/okapi-web"
},
extensions: [".ts", ".js"],
fallback: {
buffer: require.resolve("buffer")
},
},
output: {
path: resolve(__dirname, "../test/build"),
libraryTarget: 'umd',
globalObject: 'this',
libraryExport: 'default'
},
Expand All @@ -94,6 +93,7 @@ module.exports = async (config) => {
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
new IgnorePlugin({ resourceRegExp: /^/u, contextRegExp: /grpc-web-node-http-transport/u })
],
experiments: {
asyncWebAssembly: true,
Expand Down
5 changes: 5 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
npm install @trinsic/trinsic
```

For web usage, to reduce bundler warnings, add the following plugin to your webpack 5 plugin configuration:
```typescript
new IgnorePlugin({ resourceRegExp: /^/u, contextRegExp: /grpc-web-node-http-transport/u })
```

## Documentation

See [documentation here](https://docs-v2.trinsic.id/)
Expand Down

0 comments on commit 31fde3b

Please sign in to comment.