How do I define a custom #context for a verifiable credential? - json-ld

Here is an example of a verifiable credential I want to create
{
"#context": ["https://www.w3.org/2018/credentials/v1"],
"credentialSubject": {
"id": "did:example:not-a-real-did",
"competence": ["AM", "B"],
"dateOfBirth": "1995-09-23",
"name": "Frank Franksson",
"picture": "some-random-url.png",
"ssn": "19950923-9965"
},
"holder": "did:ethr:goerli:0x027d0d3347a44b5469a8acd6e9195f6e5c3b7253ddce558238d096dd927b23055a",
"id": "https://verify.stepstone.com/credentials/c7c077a6-f0c0-4843-9718-68dfba008587",
"issuanceDate": "2022-11-18T09:00:38.000Z",
"issuer": {
"id": "did:ethr:goerli:0x02f163e34f0c84d85bf0b5becc119c86362e36fab4c9247515610a0b1cc4eff74a"
},
"proof": {
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2cCI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVQcmVzZW50YXRpb24iLCJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIlN3ZWRpc2hEcml2ZXJzTGljZW5zZSJdfSwiaXNzdWVyIjp7ImlkIjoiZGlkOmV0aHI6Z29lcmxpOjB4MDJmMTYzZTM0ZjBjODRkODViZjBiNWJlY2MxMTljODYzNjJlMzZmYWI0YzkyNDc1MTU2MTBhMGIxY2M0ZWZmNzRhIn0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InNzbiI6IjE5OTUwOTIzLTk5NjUiLCJkYXRlT2ZCaXJ0aCI6IjE5OTUtMDktMjMiLCJuYW1lIjoiRnJhbmsgRnJhbmtzc29uIiwicGljdHVyZSI6InN1cGVyLWdvb2QtbG9va2luZy5wbmciLCJjb21wZXRlbmNlIjpbIkFNIiwiQiJdLCJpZCI6InNvbWUgZGlkIn0sInByb29mIjp7InR5cGUiOiJKd3RQcm9vZjIwMjAiLCJjcmVhdGVkIjoiMjAyMi0xMS0x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1aamMwWVNKOS5LZU04STNCWWlxaVBUcDNLWDNBUThHMHU4ODlYS0hKbkJqYlFvQXpqOTFzY2Y5UDZVM1NQN05sZVVpVjJQREZRMTdlMWV4Qk9HdndLbWRoMzhRNFJwZyJ9LCJqdGkiOiJodHRwczovL3ZlcmlmeS5zdGVwc3RvbmUuY29tL2NyZWRlbnRpYWxzL2M3YzA3N2E2LWYwYzAtNDg0My05NzE4LTY4ZGZiYTAwODU4NyIsIm5iZiI6MTY2ODc2MjAzOCwiaXNzIjoiZGlkOmV0aHI6Z29lcmxpOjB4MDI3ZDBkMzM0N2E0NGI1NDY5YThhY2Q2ZTkxOTVmNmU1YzNiNzI1M2RkY2U1NTgyMzhkMDk2ZGQ5MjdiMjMwNTVhIn0.-9Kd8qEpZXNDWw-RsHO9nzh-citxi8yaas_Yhaxfx4ykj4HqJz3h3SvD94HRRTWFRvXty8z2Hl3FP1vCExVLIg",
"type": "JwtProof2020"
},
"type": [
"VerifiablePresentation",
"VerifiableCredential",
"SwedishDriversLicense"
]
}
But right now I'm only using the standard #context for verifiable credentials, I also want to include the custom fields for my specific verifiable credential like so:
{
"#context":
[
"https://www.w3.org/2018/credentials/v1",
"https://www.example.org/2022/swedish-drivers-license.jsonld"
],
....
}
How do I define my custom context https://www.example.org/2022/swedish-drivers-license.jsonld so that it matches my credential? Do I have to build on top of someone else's ontology or can is it possible for me to define the base definitions myself? How do I define that there is a required field "name" of type "string"?
This is how far I've gotten:
{
"#context": [
{
"competence": "http://example.com/vocabulary#competence",
"dateOfBirth": "http://example.com/vocabulary#dateOfBirth",
"name": "http://example.com/vocabulary#name",
"picture": "http://example.com/vocabulary#picture",
"ssn": "http://example.com/vocabulary#ssn",
}
]
}
But everything is just a uri and all examples I've found also just keep defining things in terms of more uri:s until they end at "http://schema.org/". Can I define what an "ssn" myself is without referencing a third party?
Update 1
Here is my current solution:
{
"#context": [
"https://www.w3.org/2018/credentials/v1",
{
"competence": "https://schema.org/swedishdriverslicence/competence",
"dateOfBirth": "https://schema.org/birthDate",
"name": "https://schema.org/givenName",
"picture": {
"#id": "http://schema.org/image",
"#type": "#id"
},
"ssn": "https://example.org/sweden/ssn"
}
],
"credentialSubject": {
"id": "did:example:not-a-real-did",
"competence": ["AM", "B"],
"dateOfBirth": "1995-09-23",
"name": "Frank Franksson",
"picture": "some-random-url.png",
"ssn": "19950923-9965"
},
"holder": "did:ethr:goerli:0x027d0d3347a44b5469a8acd6e9195f6e5c3b7253ddce558238d096dd927b23055a",
"id": "https://example.org/credentials/c7c077a6-f0c0-4843-9718-68dfba008587",
"issuanceDate": "2022-11-18T09:00:38.000Z",
"issuer": {
"id": "did:ethr:goerli:0x02f163e34f0c84d85bf0b5becc119c86362e36fab4c9247515610a0b1cc4eff74a"
},
"proof": {
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2cCI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVQcmVzZW50YXRpb24iLCJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIlN3ZWRpc2hEcml2ZXJzTGljZW5zZSJdfSwiaXNzdWVyIjp7ImlkIjoiZGlkOmV0aHI6Z29lcmxpOjB4MDJmMTYzZTM0ZjBjODRkODViZjBiNWJlY2MxMTljODYzNjJlMzZmYWI0YzkyNDc1MTU2MTBhMGIxY2M0ZWZmNzRhIn0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InNzbiI6IjE5OTUwOTIzLTk5NjUiLCJkYXRlT2ZCaXJ0aCI6IjE5OTUtMDktMjMiLCJuYW1lIjoiRnJhbmsgRnJhbmtzc29uIiwicGljdHVyZSI6InN1cGVyLWdvb2QtbG9va2luZy5wbmciLCJjb21wZXRlbmNlIjpbIkFNIiwiQiJdLCJpZCI6InNvbWUgZGlkIn0sInByb29mIjp7InR5cGUiOiJKd3RQcm9vZjIwMjAiLCJjcmVhdGVkI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dZVEJpTVdOak5HVm1aamMwWVNKOS5LZU04STNCWWlxaVBUcDNLWDNBUThHMHU4ODlYS0hKbkJqYlFvQXpqOTFzY2Y5UDZVM1NQN05sZVVpVjJQREZRMTdlMWV4Qk9HdndLbWRoMzhRNFJwZyJ9LCJqdGkiOiJodHRwczovL3ZlcmlmeS5zdGVwc3RvbmUuY29tL2NyZWRlbnRpYWxzL2M3YzA3N2E2LWYwYzAtNDg0My05NzE4LTY4ZGZiYTAwODU4NyIsIm5iZiI6MTY2ODc2MjAzOCwiaXNzIjoiZGlkOmV0aHI6Z29lcmxpOjB4MDI3ZDBkMzM0N2E0NGI1NDY5YThhY2Q2ZTkxOTVmNmU1YzNiNzI1M2RkY2U1NTgyMzhkMDk2ZGQ5MjdiMjMwNTVhIn0.-9Kd8qEpZXNDWw-RsHO9nzh-citxi8yaas_Yhaxfx4ykj4HqJz3h3SvD94HRRTWFRvXty8z2Hl3FP1vCExVLIg",
"type": "JwtProof2020"
},
"type": [
"VerifiablePresentation",
"VerifiableCredential",
"SwedishDriversLicense"
]
}
You can view it in the playground

Related

In Azure Search how can I filter records that have tags with IDs matching any in a list

Given the following search index document schema:
{
"value": [
{
"Id": "abc",
"Name": "Some name",
"Tags": [
{
"Id": "123",
"Name": "Tag123"
},
{
"Id": "456",
"Name": "Tag456"
}
]
},
{
"Id": "xyz",
"Name": "Some name",
"Tags": [
{
"Id": "123",
"Name": "Tag123"
},
{
"Id": "789",
"Name": "Tag789"
}
]
},
]
}
What is the correct syntax for an OData query that will return all records with any Tag/Ids that are contained in input list?
The closest I have got is:
Tags/any(object: object/Id search.in ('123,456,789'))

Filter for array type of field in loopback

I am using loopback v3 with mongodb database and implementing filter for array type of field.
inq operator is not working.
I have an array of object like below
[
{
"name":"name1",
"title": "title1",
"category": ["a", "b","c"]
},
{
"name":"name2",
"title": "title2",
"category": ["x", "y","z"]
},
{
"name":"name3",
"title": "title3",
"category": ["b", "d","e"]
}
]
now i want a list where category containing "b"
So i am using below filter method
filter: {where:{category:{inq:["b"]}}}
I think inq does n't work for this case.it gives empty response.
Output : [ ]
how can i get my desired output.
Desired output:
[
{
"name":"name1",
"title": "title1",
"category": ["a", "b","c"]
},
{
"name":"name3",
"title": "title3",
"category": ["b", "d","e"]
}
]
below is my properties
"properties": {
"name": {
"type": "string"
},
"title": {
"type": "string"
},
"category": {
"type": [
"string"
]
}
},
Please suggest.
Thanks
for me the above scenario works fine. Although in your code the array closing brackets should be ] instead of }, just pointing out something I found in your code.
How did you setup your model for this?
"properties": {
"name": {
"type": "string"
},
"title": {
"type": "string"
},
"category": {
"type": [
"string"
]
}
},
Does your model properties look like this ?
"role": {
"type": "array",
"default": [
"patient"
]
}
let filter = {role:{in:['doctor']}}
this.find({
where: filter
}, cb);

Docusign Send Multiple Envelope to multiple Signer with one to one Document to Signer mapping

I have been working on Salesforce to Docusign Integration. I have multiple documents with Specific signer for each document i.e. one document should be send to one specific user, not all. But I want to do this in one Rest API call to docusign! The documents are stored in Accounts attachments which are created dynamically for each user which are specific to user.
I have been trying this using CompositeTemplates, what I am doing is, adding document and Signer in each inlineTemplate, But it is sending all the documents to all the users in sequence.
I don't want to show all document to all the user, they should see only document specific to them.
Below is the JSON which I am sending:
{
"status": "Sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"roleName": "Signer 1",
"recipientId": "1",
"name": "Anmol",
"email": "test#gmail.com"
}
]
},
"envelope": {
"status": "Sent",
"emailSubject": "test1"
},
"documents": [
{
"name": "Doc 1",
"fileExtension": "doc",
"documentId": "1",
"documentBase64": "JVBERi0xLjQKJeLjz9MKN58HkeCg8gJEomcWGJdEFtOYYklsXV2dlT6R6Owc+FXFMNSlpckKM6M/ioTGkROkEjkxBDrgthySkvMxGpQJYapHKWwcwXtRU9GCg=="
}
],
"customFields": {
"listCustomFields": [
{
"value": "00128000003tPKB",
"show": "true",
"required": "false",
"name": "Account",
"fieldId": "1",
"configurationType": "salesforce"
}
]
}
}
],
"compositeTemplateId": "1"
},
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"roleName": "Signer 2",
"recipientId": "1",
"name": "Anmol",
"email": "test1#gmail.com"
}
]
},
"envelope": {
"status": "Sent",
"emailSubject": "test2"
},
"documents": [
{
"name": "Doc 2",
"fileExtension": "doc",
"documentId": "2",
"documentBase64": "JVBERi0xLjYNJeLjz9MNCjEzIDAgb2JqDTw8L0xpbmVhcmlmDQoxMTYNCiUlRU9GDQo="
}
],
"customFields": {
"listCustomFields": [
{
"value": "00128000003tPKB",
"show": "true",
"required": "false",
"name": "Account",
"fieldId": "1",
"configurationType": "salesforce"
}
]
}
}
],
"compositeTemplateId": "2"
}
]
}
Any doc, code or suggestions about the approach I am following for this will be very helpful.
To do it in a single api call, specify the excludedDocuments property in the EnvelopeCreate request
excludedDocuments: Specifies the documents that are not visible to the recipient. Document Visibility must be enabled for the account and the enforceSignerVisibility property must be set to true for the envelope to use this.
Here is a sample Json for POST /v2/accounts/{accountId}/envelopes
Note: I have combined both your inline templates into a single inlineTemplate.
{
"status": "Sent",
"emailSubject": "Email Subject to all recipients",
"emailBlurb": "Email body to all recipients",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"recipientId": "1",
"name": "recipient one",
"email": "recipientone#dsxtr.com",
"excludedDocuments": [ "2" ]
},
{
"recipientId": "2",
"name": "recipient two",
"email": "recipienttwo#dsxtr.com",
"excludedDocuments": [ "1" ]
}
]
},
"documents": [
{
"name": "Doc 1",
"fileExtension": "doc",
"documentId": "1",
"documentBase64": ""
},
{
"name": "Doc 2",
"fileExtension": "doc",
"documentId": "2",
"documentBase64": ""
}
]
}
],
"compositeTemplateId": "1"
}
]
}
I believe you're looking for documentVisibility on the create envelope call.
There are other supporting documentVisibility endpoints here.

Get dynamic key value from an array angularjs

I have a mongo collection called settings
{
"_id": "123",
"type": "subject",
"name": "Main",
"list": [{
"_id": "123",
"name": "Maths"
}, {
"_id": "123",
"name": " Physics"
}]
}
{
"_id": "123",
"type": "exam",
"name": "Activities",
"list": [{
"_id": "123",
"name": "Reading"
}, {
"_id": "123",
"name": "Fluency"
}]
}
Note: the values provided in my mongo is only for reference purpose.
Now I have generated an array with the records in settings collection
self.sample = function() {
self.settingsObj = {}
// console.log(self.settings)
_.each(self.settings, function(settings) {
//_.each(self.settings, function(settings) {
if (!self.settingsObj[settings.type]) {
self.settingsObj[settings.type] = []
}
self.settingsObj[settings.type] = settings.list
})
console.log(self.settingsObj)
}
When I console the settingsObj I get result like this in my console
Object {subject: Array[2], exam: Array[2]}
Now I want to loop this inside a scope variable
$scope.search = [{
"name": "",
"data": ""
}]
inside this name i want to get the object name in this situation subject,exam and inside loop i want to loop the arrays for subject and exam.
I tried another ._each, and I got the key and value but how can I loop them correctly.
Otherwise please help me in generating subject and exams as different array
I'm not very sure if I understand your question.
But if I see well you're using a Lodash.js library so I provide below script using a lodash:
I assume that you have settings variable like this:
var settings = [ {
"_id": "123",
"type": "subject",
"name": "Main",
"list": [{
"_id": "123",
"name": "Maths"
}, {
"_id": "123",
"name": " Physics"
}]
}
,
{
"_id": "123",
"type": "exam",
"name": "Activities",
"list": [{
"_id": "123",
"name": "Reading"
}, {
"_id": "123",
"name": "Fluency"
}]
}];
And I create functions for process those settings:
function createSearch(settings){
return _(settings).flatMap(toSearchArray).value();
}
function toSearchArray(setting){
return _(setting.list).map("name").map(toSearchObject).value()
function toSearchObject(data){
return {
name: setting.type,
data: data
}
}
}
And when you call createSearch(settings)
you will receive this result:
[
{
"name": "subject",
"data": "Maths"
},
{
"name": "subject",
"data": " Physics"
},
{
"name": "exam",
"data": "Reading"
},
{
"name": "exam",
"data": "Fluency"
}
]
Hopefully this is what you need.

In JSON-LD, is it possible to define a URI mapping for a property value?

Suppose we have the following JSON:
{
"#context":
{
"name": "http://schema.org/name",
"status": "http://schema.org/status"
},
"name": "Manu Sporny",
"status": "trollin'"
}
(JSON-LD Playground)
The trollin' status is identified with a URI: http://example.com/trolling. Is it possible to expand the trollin' keyword in the example above to the URI http://example.com/trolling?
A straightforward manipulation of the context does not work:
{
"#context":
{
"name": "http://schema.org/name",
"status": "http://schema.org/status",
"trollin'": "http://example.com/trolling"
},
"name": "Manu Sporny",
"status": "trollin'"
}
(JSON Playground)
Forcing the type of status to #id also won't work, because it will assume trollin' is a relative URI.
{
"#context":
{
"name": "http://schema.org/name",
"status": {
"#id": "http://schema.org/status",
"#type": "#id"
},
"trollin'": "http://example.com/trolling"
},
"name": "Manu Sporny",
"status": "trollin'"
}
(JSON-LD Playground)
Yes, you can do it, you need to set the type of status to #vocab:
{
"#context":
{
"name": "http://schema.org/name",
"status": {
"#id": "http://schema.org/status",
"#type": "#vocab"
},
"trollin'": "http://example.com/trolling"
},
"name": "Manu Sporny",
"status": "trollin'"
}
Here's a link to the playground.

Resources