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 algorand auth #49

Merged
merged 2 commits into from
Jan 8, 2024
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
1 change: 1 addition & 0 deletions packages/ipfs-w3auth/auth-algorand/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
3 changes: 3 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts/"
}
3 changes: 3 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('gts/.prettierrc.json')
}
23 changes: 23 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@crustio/ipfs-w3auth-algorand",
"version": "0.0.3",
"description": "Algorand authentication of IPFS W3Auth",
"main": "./src/index.js",
"license": "Apache-2.0",
"scripts": {
"build:types": "npx ts-node src/scripts/generate.ts",
"lint": "gts lint",
"clean": "gts clean",
"compile": "tsc",
"fix": "gts fix"
},
"dependencies": {
"algosdk": "^2.7.0"
},
"devDependencies": {
"@babel/runtime": "^7.13.2",
"@types/node": "^14.17.21",
"gts": "^3.1.0",
"typescript": "^4.1.3"
}
}
14 changes: 14 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {AuthData} from './types';
import {verifyBytes} from 'algosdk';

async function auth(data: AuthData): Promise<boolean> {
return verifyBytes(
Buffer.from(data.address),
Buffer.from(data.signature, 'base64'),
data.address
);
}

export default {
auth,
};
13 changes: 13 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface AuthData {
address: string;
signature: string;
}

class AuthError extends Error {
constructor(msg: string) {
super(msg);
Object.setPrototypeOf(this, AuthError.prototype);
}
}

export {AuthData, AuthError};
12 changes: 12 additions & 0 deletions packages/ipfs-w3auth/auth-algorand/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"rootDir": "./",
"outDir": "build",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"declaration": true
}
}
Loading
Loading