Skip to content

Commit 32ceda1

Browse files
authored
chore: remove obsolete request and present methods (#287)
1 parent 1b747f8 commit 32ceda1

File tree

2 files changed

+0
-180
lines changed

2 files changed

+0
-180
lines changed

src/keri/app/credentialing.ts

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -472,133 +472,6 @@ export class Credentials {
472472
op,
473473
};
474474
}
475-
476-
/**
477-
* Present a credential
478-
* @async
479-
* @param {string} name Name or alias of the identifier
480-
* @param {string} said SAID of the credential
481-
* @param {string} recipient Identifier prefix of the receiver of the presentation
482-
* @param {boolean} [include=true] Flag to indicate whether to stream credential alongside presentation exchange message
483-
* @returns {Promise<string>} A promise to the long-running operation
484-
*/
485-
async present(
486-
name: string,
487-
said: string,
488-
recipient: string,
489-
include: boolean = true
490-
): Promise<string> {
491-
const hab = await this.client.identifiers().get(name);
492-
const pre: string = hab.prefix;
493-
494-
const cred = await this.get(said);
495-
const data = {
496-
i: cred.sad.i,
497-
s: cred.sad.s,
498-
n: said,
499-
};
500-
501-
const vs = versify(Ident.KERI, undefined, Serials.JSON, 0);
502-
503-
const _sad = {
504-
v: vs,
505-
t: Ilks.exn,
506-
d: '',
507-
dt: new Date().toISOString().replace('Z', '000+00:00'),
508-
r: '/presentation',
509-
q: {},
510-
a: data,
511-
};
512-
const [, sad] = Saider.saidify(_sad);
513-
const exn = new Serder(sad);
514-
515-
const keeper = this.client!.manager!.get(hab);
516-
517-
const sig = await keeper.sign(b(exn.raw), true);
518-
519-
const siger = new Siger({ qb64: sig[0] });
520-
const seal = ['SealLast', { i: pre }];
521-
let ims = messagize(exn, [siger], seal, undefined, undefined, true);
522-
ims = ims.slice(JSON.stringify(exn.ked).length);
523-
524-
const body = {
525-
exn: exn.ked,
526-
sig: new TextDecoder().decode(ims),
527-
recipient: recipient,
528-
include: include,
529-
};
530-
531-
const path = `/identifiers/${name}/credentials/${said}/presentations`;
532-
const method = 'POST';
533-
const headers = new Headers({
534-
Accept: 'application/json+cesr',
535-
});
536-
const res = await this.client.fetch(path, method, body, headers);
537-
return await res.text();
538-
}
539-
540-
/**
541-
* Request a presentation of a credential
542-
* @async
543-
* @param {string} name Name or alias of the identifier
544-
* @param {string} recipient Identifier prefix of the receiver of the presentation
545-
* @param {string} schema SAID of the schema
546-
* @param {string} [issuer] Optional prefix of the issuer of the credential
547-
* @returns {Promise<string>} A promise to the long-running operation
548-
*/
549-
async request(
550-
name: string,
551-
recipient: string,
552-
schema: string,
553-
issuer?: string
554-
): Promise<string> {
555-
const hab = await this.client.identifiers().get(name);
556-
const pre: string = hab.prefix;
557-
558-
const data: any = {
559-
s: schema,
560-
};
561-
if (issuer !== undefined) {
562-
data['i'] = issuer;
563-
}
564-
565-
const vs = versify(Ident.KERI, undefined, Serials.JSON, 0);
566-
567-
const _sad = {
568-
v: vs,
569-
t: Ilks.exn,
570-
d: '',
571-
dt: new Date().toISOString().replace('Z', '000+00:00'),
572-
r: '/presentation/request',
573-
q: {},
574-
a: data,
575-
};
576-
const [, sad] = Saider.saidify(_sad);
577-
const exn = new Serder(sad);
578-
579-
const keeper = this.client!.manager!.get(hab);
580-
581-
const sig = await keeper.sign(b(exn.raw), true);
582-
583-
const siger = new Siger({ qb64: sig[0] });
584-
const seal = ['SealLast', { i: pre }];
585-
let ims = messagize(exn, [siger], seal, undefined, undefined, true);
586-
ims = ims.slice(JSON.stringify(exn.ked).length);
587-
588-
const body = {
589-
exn: exn.ked,
590-
sig: new TextDecoder().decode(ims),
591-
recipient: recipient,
592-
};
593-
594-
const path = `/identifiers/${name}/requests`;
595-
const method = 'POST';
596-
const headers = new Headers({
597-
Accept: 'application/json+cesr',
598-
});
599-
const res = await this.client.fetch(path, method, body, headers);
600-
return await res.text();
601-
}
602475
}
603476

604477
export interface CreateRegistryArgs {

test/app/credentialing.test.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -315,59 +315,6 @@ describe('Credentialing', () => {
315315
);
316316
assert.equal(lastBody.sigs[0].substring(0, 2), 'AA');
317317
assert.equal(lastBody.sigs[0].length, 88);
318-
319-
await credentials.present(
320-
'aid1',
321-
credential,
322-
'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX',
323-
false
324-
);
325-
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
326-
lastBody = JSON.parse(lastCall[1]!.body!.toString());
327-
assert.equal(
328-
lastCall[0]!,
329-
url +
330-
'/identifiers/aid1/credentials/' +
331-
credential +
332-
'/presentations'
333-
);
334-
assert.equal(lastCall[1]!.method, 'POST');
335-
assert.equal(lastBody.exn.t, 'exn');
336-
assert.equal(lastBody.exn.r, '/presentation');
337-
assert.equal(
338-
lastBody.exn.a.n,
339-
'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK'
340-
);
341-
assert.equal(lastBody.exn.a.s, schema);
342-
assert.equal(lastBody.sig.length, 144);
343-
assert.equal(
344-
lastBody.recipient,
345-
'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX'
346-
);
347-
assert.equal(lastBody.include, false);
348-
349-
await credentials.request(
350-
'aid1',
351-
'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX',
352-
credential,
353-
'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX'
354-
);
355-
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
356-
lastBody = JSON.parse(lastCall[1]!.body!.toString());
357-
assert.equal(lastCall[0]!, url + '/identifiers/aid1/requests');
358-
assert.equal(lastCall[1]!.method, 'POST');
359-
assert.equal(lastBody.exn.t, 'exn');
360-
assert.equal(lastBody.exn.r, '/presentation/request');
361-
assert.equal(lastBody.exn.a.i, registry);
362-
assert.equal(
363-
lastBody.exn.a.s,
364-
'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK'
365-
);
366-
assert.equal(lastBody.sig.length, 144);
367-
assert.equal(
368-
lastBody.recipient,
369-
'EP10ooRj0DJF0HWZePEYMLPl-arMV-MAoTKK-o3DXbgX'
370-
);
371318
});
372319
});
373320

0 commit comments

Comments
 (0)