Skip to content

Commit 13425d2

Browse files
committed
Add full support for did.request using regular links
1 parent f1f73d5 commit 13425d2

13 files changed

Lines changed: 44 additions & 22 deletions

‎angular/src/app/services/frontend.service.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { SettingsService } from './settings.service';
1010
import { StateService } from './state.service';
1111
import { WalletManager } from './wallet-manager';
1212
import { DOCUMENT } from '@angular/common';
13+
import { DidRequestHandler } from 'src/shared/handlers/did-request-handler';
14+
import { SecureStateService } from './secure-state.service';
1315

1416
@Injectable({
1517
providedIn: 'root',
@@ -29,6 +31,7 @@ export class FrontendService implements OnInit {
2931
private router: Router,
3032
private state: StateService,
3133
private settings: SettingsService,
34+
private secure: SecureStateService,
3235
private message: MessageService,
3336
private sharedManager: SharedManager,
3437
private dwn: DecentralizedWebNode
@@ -81,10 +84,22 @@ export class FrontendService implements OnInit {
8184
return 'ok';
8285
}
8386
case 'did.request': {
84-
debugger;
8587
const msg = message as any;
88+
const handler = new DidRequestHandler(this.networkManager);
89+
90+
const state: any = {
91+
content: msg.request.params[0].challenge,
92+
message: {
93+
app: msg.app
94+
}
95+
}
96+
97+
const result = await handler.execute(state, msg, this.secure);
98+
let payload = JSON.stringify(result.response);
99+
86100
let url = msg.request.params[0].callback;
87-
url = url.replace('%s', msg.key); // This is the DID.
101+
url = url.replace('%s', payload);
102+
88103
this.document.location.href = url;
89104
return 'ok';
90105
}

‎angular/src/app/services/secure-state.service.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export class SecureStateService {
1212
// The background.ts is responsible for clearing the secure state when timeout is reached.
1313

1414
/** Contains the master seed for unlocked wallets. This object should never be persisted and only exists in memory. */
15-
private keys: Map<string, string> = new Map<string, string>();
15+
16+
// Made public to support a minor hack for frontend service.
17+
public keys: Map<string, string> = new Map<string, string>();
1618

1719
unlockedWalletsSubject: BehaviorSubject<string[]> = new BehaviorSubject<string[]>([]);
1820

‎angular/src/manifest/blockcore/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Blockcore Wallet",
3-
"version": "1.0.33",
3+
"version": "1.0.34",
44
"manifest_version": 3,
55
"description": "Non-Custodial wallet for Coins, Tokens, Identities, NFTs and more.",
66
"author": "Blockcore",

‎angular/src/manifest/blockcore/manifest.webmanifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"start_url": "./",
55
"name": "Blockcore Wallet",
66
"short_name": "Blockcore",
7-
"version": "1.0.33",
7+
"version": "1.0.34",
88
"author": "Blockcore",
99
"display": "standalone",
1010
"theme_color": "#22a893",

‎angular/src/manifest/coinvault/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CoinVault",
3-
"version": "1.0.33",
3+
"version": "1.0.34",
44
"manifest_version": 3,
55
"description": "Non-Custodial wallet for Stratis, Cirrus, NFTs and more.",
66
"author": "Softchains Ltd",

‎angular/src/manifest/coinvault/manifest.webmanifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"start_url": "./",
55
"name": "CoinVault",
66
"short_name": "CoinVault",
7-
"version": "1.0.33",
7+
"version": "1.0.34",
88
"author": "Softchains Ltd",
99
"display": "standalone",
1010
"theme_color": "#206997",

‎angular/src/manifest/freecity/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Free City Wallet",
3-
"version": "1.0.33",
3+
"version": "1.0.34",
44
"manifest_version": 3,
55
"description": "Manage your citizenship, identity, properties, social network and more.",
66
"author": "City Chain Foundation",

‎angular/src/manifest/freecity/manifest.webmanifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"start_url": "./",
55
"name": "Free City Wallet",
66
"short_name": "FreeCityWallet",
7-
"version": "1.0.33",
7+
"version": "1.0.34",
88
"author": "City Chain Foundation",
99
"display": "standalone",
1010
"theme_color": "#DFAB3C",

‎angular/src/shared/background-manager.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export class BackgroundManager {
150150
return true;
151151
}
152152

153-
async getKey(walletId: string, accountId: string, keyId: string) {
154-
await this.sharedManager.loadPrivateKeys();
153+
async getKey(walletId: string, accountId: string, keyId: string, secure: any = null) {
154+
await this.sharedManager.loadPrivateKeys(secure);
155155

156156
// Get the secret seed.
157157
const masterSeedBase64 = this.sharedManager.getPrivateKey(walletId);

‎angular/src/shared/handlers/did-request-handler.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class DidRequestHandler implements ActionHandler {
2525
};
2626
}
2727

28-
async execute(state: ActionState, permission: Permission): Promise<ActionResponse> {
28+
async execute(state: ActionState, permission: Permission, secure: any = null): Promise<ActionResponse> {
2929
// Get the private key
30-
const { network, node } = await this.backgroundManager.getKey(permission.walletId, permission.accountId, permission.keyId);
30+
const { network, node } = await this.backgroundManager.getKey(permission.walletId, permission.accountId, permission.keyId, secure);
3131

3232
if (state.content) {
3333
let contentText = state.content;
@@ -47,7 +47,6 @@ export class DidRequestHandler implements ActionHandler {
4747

4848
// "jws" or "jwt"?
4949
// const didDocument = identity.document();
50-
5150
const jws = await createJWS(proofContent, tools.getSigner(privateKey), { kid: `${identity.did}${verificationMethod.id}` });
5251

5352
let returnData: ActionResponse = {

0 commit comments

Comments
 (0)