Skip to content

Commit 11fd24a

Browse files
authored
Merge pull request #839 from TokenScript/staging
Staging
2 parents 3566202 + 7d70e70 commit 11fd24a

File tree

9 files changed

+926
-820
lines changed

9 files changed

+926
-820
lines changed

CHANGELOG.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
> Description
22
3-
Feature release to support Socios OAuth2 Wallet Provider, additional configuration options and improvments.
3+
Minor release for off chain token attestations
44

55
### Upgrade Steps
66

7-
- Update NPM package to version 3.1.0
7+
- Update NPM package to version 3.1.1
88

99
### Breaking Changes
1010

1111
[none]
1212

1313
### New Features
1414

15-
- Added new configuration text to active mode ui options
16-
- Off chain Token user flows now default to re-direct mode, due to all major browsers by default denying to cross origin local storage access via Iframes.
17-
- Added Socios OAuth2 Wallet Provider support via compatbility with a new NPM package (https://www.npmjs.com/package/@tokenscript/token-negotiator-server)
15+
- Upgrade attestation lib to support validation of new EAS off-chain attestation version
16+
- Prevent delete of signedToken property on token object
17+
- Change single token auth to use tokenId instead of sending the entire token object in URL
18+
- Add labels to default ticket schema
1819

1920
### Bug Fixes
2021

21-
- Fix to ensure the validity of attestations when expired
22-
- Show retry for on chain tokens when they fail to resolve the first time
23-
- Off Chain Attestation Toggle button UX fix (for custom EAS tokens)
22+
[none]
2423

2524
### Performance Improvements
2625

2726
[none]
2827

2928
**Full Change log**:
3029

31-
https://github.com/TokenScript/token-negotiator/compare/v3.0.2...v3.1.0
30+
https://github.com/TokenScript/token-negotiator/compare/v3.1.0....v3.1.1

package-lock.json

Lines changed: 898 additions & 780 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tokenscript/token-negotiator",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Token-negotiator a token attestation bridge between web 2.0 and 3.0.",
55
"module": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -49,7 +49,7 @@
4949
"@onflow/fcl": "^1.3.2",
5050
"@onflow/types": "^1.0.5",
5151
"@peculiar/asn1-schema": "^2.2.0",
52-
"@tokenscript/attestation": "0.6.0-rc.3",
52+
"@tokenscript/attestation": "0.7.0-rc.1",
5353
"@toruslabs/torus-embed": "^2.2.5",
5454
"@walletconnect/qrcode-modal": "^1.8.0",
5555
"@walletconnect/types": "^2.1.5",

src/client/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,6 @@ export class Client {
908908

909909
requiredParams(tokenIssuer && unsignedToken, 'Issuer and unsigned token required.')
910910

911-
if (unsignedToken.signedToken) {
912-
delete unsignedToken.signedToken
913-
}
914-
915911
const config = this.tokenStore.getCurrentIssuers()[tokenIssuer]
916912

917913
if (!config) errorHandler('Provided issuer was not found.', 'error', null, null, true, true)
@@ -1142,14 +1138,13 @@ export class Client {
11421138
switch (originalAction) {
11431139
case OutletAction.GET_PROOF: {
11441140
const collectionId: string = this.getDataFromQuery('issuer')
1145-
const token: string = this.getDataFromQuery('token')
1146-
const decodedToken = JSON.parse(token) as DecodedToken
1141+
const tokenId: string = this.getDataFromQuery('tokenId')
11471142

11481143
const issuerConfig = this.tokenStore.getCurrentIssuers(false)[collectionId] as unknown as OutletIssuerInterface
11491144

11501145
const issuerHashes = createIssuerHashArray(issuerConfig)
11511146

1152-
const result = await localOutlet.authenticate(issuerConfig, issuerHashes, decodedToken)
1147+
const result = await localOutlet.authenticate(issuerConfig, issuerHashes, tokenId)
11531148

11541149
await TicketZKProof.validateProof(issuerConfig as unknown as OffChainTokenConfig, result.proof, result.type)
11551150

src/outlet/attestationIdClient.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ export class AttestationIdClient {
241241
callbackParams.set('email', email) // TODO: return with attestation.id callback
242242
callbackParams.set(URLNS + 'action', OutletAction.EMAIL_ATTEST_CALLBACK)
243243

244-
// console.log('attestation.id callback params: ', callbackParams.toString())
245-
// callbackParams.set(URLNS + 'issuer', this.tokenConfig.collectionID)
246-
// callbackParams.set(URLNS + 'token', JSON.stringify(this.decodedToken))
247-
248244
const requestor = curParams.get(URLNS + 'requestor')
249245
if (requestor) {
250246
callbackParams.set(URLNS + 'requestor', requestor)

src/outlet/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,17 @@ export class Outlet extends LocalOutlet {
210210

211211
async sendTokenProof(evtid: string) {
212212
const collectionId: string = this.getDataFromQuery('issuer')
213-
const token: string = this.getDataFromQuery('token')
213+
const tokenId: string = this.getDataFromQuery('tokenId')
214214
const wallet: string = this.getDataFromQuery('wallet')
215215
const address: string = this.getDataFromQuery('address')
216-
requiredParams(token, 'unsigned token is missing')
217-
218-
const decodedToken = JSON.parse(token) as DecodedToken
216+
requiredParams(tokenId, 'tokenId is missing')
219217

220218
const redirect = this.getDataFromQuery('redirect') === 'true' ? window.location.href : false
221219

222220
try {
223221
const issuer = this.getIssuerConfigById(collectionId)
224222

225-
const ticketRecord = await this.ticketStorage.getStoredTicketFromDecodedTokenOrId(createIssuerHashArray(issuer), decodedToken)
223+
const ticketRecord = await this.ticketStorage.getStoredTicketFromDecodedTokenOrId(createIssuerHashArray(issuer), tokenId)
226224

227225
const attestIdClient = new AttestationIdClient(
228226
issuer.attestationOrigin,
@@ -240,7 +238,7 @@ export class Outlet extends LocalOutlet {
240238
const idAttestation = await attestIdClient.getIdentifierAttestation(ticketRecord.id, wallet, address, {
241239
action: OutletAction.GET_PROOF,
242240
issuer: collectionId,
243-
token: JSON.stringify(decodedToken),
241+
tokenId,
244242
})
245243

246244
const tokenProof = await getUseToken(issuer, idAttestation.attestation, idAttestation.identifierSecret, ticketRecord)
@@ -253,7 +251,7 @@ export class Outlet extends LocalOutlet {
253251
params.set(this.getCallbackUrlKey('issuer'), collectionId)
254252
params.set(this.getCallbackUrlKey('attestation'), tokenProof.proof as string)
255253
params.set(this.getCallbackUrlKey('type'), ticketRecord.type)
256-
params.set(this.getCallbackUrlKey('token'), token)
254+
params.set(this.getCallbackUrlKey('tokenId'), tokenId)
257255

258256
requesterURL.hash = params.toString()
259257
window.location.href = requesterURL.href

src/outlet/localOutlet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ export class LocalOutlet {
3030
async authenticate(
3131
tokenConfig: OutletIssuerInterface,
3232
issuerHashes: string[],
33-
decodedToken: DecodedToken,
33+
tokenId: string,
3434
address?: string,
3535
wallet?: string,
3636
redirectMode: false | string = false,
3737
) {
38-
const ticketRecord = await this.ticketStorage.getStoredTicketFromDecodedTokenOrId(issuerHashes, decodedToken)
38+
const ticketRecord = await this.ticketStorage.getStoredTicketFromDecodedTokenOrId(issuerHashes, tokenId)
3939

4040
const attestIdClient = new AttestationIdClient(tokenConfig.attestationOrigin, undefined, redirectMode)
4141
const idAttestation = await attestIdClient.getIdentifierAttestation(ticketRecord.id, wallet, address, {
4242
action: OutletAction.GET_PROOF,
4343
issuer: tokenConfig.collectionID,
44-
token: JSON.stringify(decodedToken),
44+
tokenId,
4545
})
4646

4747
return await getUseToken(tokenConfig, idAttestation.attestation, idAttestation.identifierSecret, ticketRecord)

src/outlet/ticketStorage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { EasTicketAttestation, TicketSchema } from '@tokenscript/attestation/dist/eas/EasTicketAttestation'
1+
import { EasTicketAttestation, SchemaField, TicketSchema } from '@tokenscript/attestation/dist/eas/EasTicketAttestation'
22
import { KeyPair } from '@tokenscript/attestation/dist/libs/KeyPair'
33
import { base64ToUint8array, createIssuerHashArray, createOffChainCollectionHash, errorHandler, IssuerHashMap, logger } from '../utils'
44
import { Ticket } from '@tokenscript/attestation/dist/Ticket'
55
import { EasFieldDefinition, OutletInterface, OutletIssuerInterface } from './interfaces'
66
import { DevconTicket, SignedDevconTicket } from '@tokenscript/attestation/dist/asn1/shemas/SignedDevconTicket'
77
import { AsnParser } from '@peculiar/asn1-schema'
8-
import { decodeBase64ZippedBase64 } from '@tokenscript/attestation/dist/eas/AttestationUrl'
8+
import { decodeBase64ZippedBase64 } from '@ethereum-attestation-service/eas-sdk'
99
import { SignedOffchainAttestation } from '@ethereum-attestation-service/eas-sdk/dist/offchain/offchain'
1010
import { DEFAULT_RPC_MAP } from '../core/constants'
1111
import { TokenStore } from '../client/tokenStore'
@@ -78,12 +78,12 @@ export interface FilterInterface {
7878
[key: string]: any
7979
}
8080

81-
export const DEFAULT_EAS_SCHEMA: TicketSchema = {
81+
export const DEFAULT_EAS_SCHEMA: { fields: (SchemaField & { label?: string })[] } = {
8282
fields: [
83-
{ name: 'eventId', type: 'string' },
84-
{ name: 'ticketId', type: 'string' },
85-
{ name: 'ticketClass', type: 'uint8' },
86-
{ name: 'commitment', type: 'bytes', isCommitment: true },
83+
{ name: 'eventId', type: 'string', label: 'Event ID' },
84+
{ name: 'ticketId', type: 'string', label: 'Ticket ID' },
85+
{ name: 'ticketClass', type: 'uint8', label: 'Ticket Class' },
86+
{ name: 'commitment', type: 'bytes', isCommitment: true, label: 'Email commitment' },
8787
],
8888
}
8989

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// modified by build process.
2-
export const VERSION = '3.1.0'
2+
export const VERSION = '3.1.1'

0 commit comments

Comments
 (0)