⚠ī¸JWS Token

⚠ī¸ Deprecated API Notice

This API is deprecated and will be removed in a future release.

Data Signing

import * as jose from 'jose'

const algorithm = 'ES256'
const keyPem = `-----BEGIN PRIVATE KEY-----
    MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
    nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
    l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
    -----END PRIVATE KEY-----`
const privateKey = await jose.importPKCS8(keyPem, algorithm)

const verifyingKeyJWKS = {
    jku: 'jwks_endpoint',
    kid: 'jwks_kid',
};
const payload = 'user_data or dvr object';
const userDataJWS = await new jose.SignJWT({ 'data': payload })
  .setProtectedHeader({
    alg: algorithm,
    jku: verifyingKeyJWKS.jku,
    kid: verifyingKeyJWKS.kid,
  })
  .sign(privateKey);
console.log(userDataJWS);

User Data


Raw Example

const userData = {
  "data": {
    "bcaDocID": "DOC897923CP",
    "bcaDocName": "BCA Customer Profile",
    "customerID": "BCA123756108",
    "personalInfo": {
      "firstName": "Dewi",
      "lastName": "Putri",
      "dateOfBirth": "1980-01-01",
      "driverLicenseNumber": "DL123456789"
    },
    "financialInfo": {
      "averageMonthlyBalance": 200000000,
      "creditRatings": {
        "pefindo": 720,
        "creditKarma": 725,
        "equiInfo": 730
      },
      "accounts": {
        "checking": {
          "accountNumber": "CHK1234567",
          "balance": 50000000
        },
        "savings": {
          "accountNumber": "SAV1234567",
          "balance": 150000000
        }
      }
    },
    "loanHistory": [
      {
        "loanType": "auto",
        "loanAmount": 200000000,
        "loanStatus": "closed"
      }
    ],
    "contactInfo": {
      "email": "dewi.putri@yahoo.com",
      "phone": "+62-855-123-4567"
    },
    "flags": {
      "isOverdraftProtected": true,
      "isVIP": false,
      "fraudAlerts": false
    }
  }
}

Signed User Data JWS Token

eyJ0eXAiOiJKV1QiLCJqa3Ui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ZnJhdWRBbGVydHMiOmZhbHNlfX19.63naWQ6I3Yg4WFzuiUneYQ85leg5scPDK_CMzQUuAYk2PjlNaJ8Hujp7uk0ml8qf9lSUI2YOgL0iwu8AL_D6hg

DVR


Raw Example

const dvr = {
  "data": {
    "dvr_title": "My DVR",
    "dvr_id": "15fd4304-cec0-46c4-85b7-f9d8d5daee1a",
    "query_engine_ver": "0.1.0",
    "query_method_ver": "a788c686bf77b9ceafcf81b5f39625fbfa9f7a7a2658a8b8a134b6839cd92cf5",
    "query": "{\"and\":[{\"==\":[\"bcaDocID\",\"DOC897923CP\"]},{\"~==\":[\"personalInfo.firstName\",\"Dewi\"]},{\"~==\":[\"personalInfo.lastName\",\"Putri\"]},{\"~==\":[\"personalInfo.driverLicenseNumber\",\"DL123456789\"]},{\">=\":[\"financialInfo.creditRatings.pefindo\",650]},{\">=\":[\"financialInfo.accounts.savings.balance\",30000000]}]}",
    "user_data_url": "https://xyz.com",
    "user_data_verifying_key": {
      "KeysetEndpoint": {
        "jku": "https://raw.githubusercontent.com/zulamdat/zulamdat.github.io/sample-key/zkp-key/issuer-key.json",
        "kid": "k-1"
      }
    },
    "dvr_verifiying_key": {
      "PublicKey": {
        "x": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEp6WJlwAtld/U4hDmmuuMdZCVtMeU",
        "y": "IT3xkDdUwLOvsVVA+iiSwfaX4HqKlRPDGG+F6WGjnxys9T5GtNe3nvewOA=="
      }
    }
  }
}

Signed DVR JWS Token

eyJ0eXAiOiJKV1QiLCJqa3UiOiJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20venVsYW1kYXQvenVsYW1kYXQuZ2l0aHViLmlvL3NhbXBsZS1rZXkvemtwLWtleS92ZXJpZmllci1rZXkuanNvbiIsImtpZCI6ImstMSIsImFsZyI6IkVTMjU2In0.eyJkYXRhIjp7ImR2cl90aXRsZSI6Ik15IERWUiIsImR2cl9pZCI6IjE1ZmQ0MzA0LWNlYzAtND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