Skip to content

Commit

Permalink
Merge pull request #1 from kristoferlund/dev
Browse files Browse the repository at this point in the history
v0.1.0
  • Loading branch information
kristoferlund authored Aug 22, 2024
2 parents 81b4c47 + bd0933d commit 192f2d8
Show file tree
Hide file tree
Showing 17 changed files with 9,259 additions and 17,706 deletions.
22 changes: 0 additions & 22 deletions .eslintrc.cjs

This file was deleted.

75 changes: 39 additions & 36 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
create-canisters:
dfx canister create --all
dfx generate backend
dfx generate ic_siwe_provider

deploy-provider:
dfx deploy ic_siwe_provider --argument "( \
Expand Down Expand Up @@ -41,14 +43,14 @@ deploy-backend:
dfx deploy backend

deploy-frontend:
npm install
pnpm install
dfx deploy frontend

deploy-all: create-canisters deploy-provider deploy-backend deploy-frontend

run-frontend:
npm install
npm run dev
pnpm install
pnpm run dev

clean:
rm -rf .dfx
Expand Down
8 changes: 3 additions & 5 deletions dfx.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"canisters": {
"ic_siwe_provider": {
"candid": "https://github.com/kristoferlund/ic-siwe/releases/download/v0.0.6/ic_siwe_provider.did",
"candid": "ic_siwe_provider.did",
"type": "custom",
"wasm": "https://github.com/kristoferlund/ic-siwe/releases/download/v0.0.6/ic_siwe_provider.wasm.gz"
"wasm": "ic_siwe_provider.wasm.gz"
},
"backend": {
"candid": "src/backend/backend.did",
"dependencies": ["ic_siwe_provider"],
"package": "backend",
"type": "rust"
},
"frontend": {
"build": ["npm run build"],
"dependencies": ["backend", "ic_siwe_provider"],
"build": ["pnpm run build"],
"source": ["dist"],
"type": "assets"
}
Expand Down
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
83 changes: 83 additions & 0 deletions ic_siwe_provider.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
type Address = text;
type CanisterPublicKey = PublicKey;
type Principal = blob;
type PublicKey = blob;
type SessionKey = PublicKey;
type SiweMessage = text;
type SiweSignature = text;
type Timestamp = nat64;
type Nonce = text;

type RuntimeFeature = variant {
IncludeUriInSeed;
DisableEthToPrincipalMapping;
DisablePrincipalToEthMapping
};

type SettingsInput = record {
domain : text;
uri : text;
salt : text;
chain_id : opt nat;
scheme : opt text;
statement : opt text;
sign_in_expires_in : opt nat64;
session_expires_in : opt nat64;
targets : opt vec text;
runtime_features: opt vec RuntimeFeature;
};

type GetAddressResponse = variant {
Ok : Address;
Err : text;
};

type GetDelegationResponse = variant {
Ok : SignedDelegation;
Err : text;
};

type SignedDelegation = record {
delegation : Delegation;
signature : blob;
};

type Delegation = record {
pubkey : PublicKey;
expiration : Timestamp;
targets : opt vec principal;
};

type GetPrincipalResponse = variant {
Ok : Principal;
Err : text;
};

type LoginResponse = variant {
Ok : LoginDetails;
Err : text;
};

type LoginDetails = record {
expiration : Timestamp;
user_canister_pubkey : CanisterPublicKey;
};

type PrepareLoginOkResponse = record {
siwe_message: SiweMessage;
nonce : text;
};

type PrepareLoginResponse = variant {
Ok : PrepareLoginOkResponse;
Err : text;
};

service : (settings_input : SettingsInput) -> {
"get_address" : (Principal) -> (GetAddressResponse) query;
"get_caller_address" : () -> (GetAddressResponse) query;
"get_principal" : (Address) -> (GetPrincipalResponse) query;
"siwe_prepare_login" : (Address) -> (PrepareLoginResponse);
"siwe_login" : (SiweSignature, Address, SessionKey, Nonce) -> (LoginResponse);
"siwe_get_delegation" : (Address, SessionKey, Timestamp) -> (GetDelegationResponse) query;
};
Binary file added ic_siwe_provider.wasm.gz
Binary file not shown.
Loading

0 comments on commit 192f2d8

Please sign in to comment.